Commit | Line | Data |
---|---|---|
39423523 DD |
1 | @c Automatically generated from *.c and others (the comments before |
2 | @c each entry tell you which file and where in that file). DO NOT EDIT! | |
3 | @c Edit the *.c files, configure with --enable-maintainer-mode, | |
4 | @c and let gather-docs build you a new copy. | |
5 | ||
70ecf948 DD |
6 | @c safe-ctype.c:24 |
7 | @defvr Extension HOST_CHARSET | |
8 | This macro indicates the basic character set and encoding used by the | |
9 | host: more precisely, the encoding used for character constants in | |
10 | preprocessor @samp{#if} statements (the C "execution character set"). | |
11 | It is defined by @file{safe-ctype.h}, and will be an integer constant | |
12 | with one of the following values: | |
13 | ||
14 | @ftable @code | |
15 | @item HOST_CHARSET_UNKNOWN | |
16 | The host character set is unknown - that is, not one of the next two | |
17 | possibilities. | |
18 | ||
19 | @item HOST_CHARSET_ASCII | |
20 | The host character set is ASCII. | |
21 | ||
22 | @item HOST_CHARSET_EBCDIC | |
23 | The host character set is some variant of EBCDIC. (Only one of the | |
24 | nineteen EBCDIC varying characters is tested; exercise caution.) | |
25 | @end ftable | |
26 | @end defvr | |
27 | ||
39423523 | 28 | @c alloca.c:26 |
99b58139 | 29 | @deftypefn Replacement void* alloca (size_t @var{size}) |
39423523 DD |
30 | |
31 | This function allocates memory which will be automatically reclaimed | |
32 | after the procedure exits. The @libib{} implementation does not free | |
33 | the memory immediately but will do so eventually during subsequent | |
34 | calls to this function. Memory is allocated using @code{xmalloc} under | |
35 | normal circumstances. | |
36 | ||
37 | The header file @file{alloca-conf.h} can be used in conjunction with the | |
38 | GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make | |
39 | available this function. The @code{AC_FUNC_ALLOCA} test requires that | |
40 | client code use a block of preprocessor code to be safe (see the Autoconf | |
41 | manual for more); this header incorporates that logic and more, including | |
99b58139 | 42 | the possibility of a GCC built-in function. |
39423523 DD |
43 | |
44 | @end deftypefn | |
45 | ||
ba19b94f | 46 | @c asprintf.c:33 |
5d852400 | 47 | @deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...) |
ba19b94f DD |
48 | |
49 | Like @code{sprintf}, but instead of passing a pointer to a buffer, you | |
50 | pass a pointer to a pointer. This function will compute the size of | |
51 | the buffer needed, allocate memory with @code{malloc}, and store a | |
52 | pointer to the allocated memory in @code{*@var{resptr}}. The value | |
53 | returned is the same as @code{sprintf} would return. If memory could | |
5a4e47bd | 54 | not be allocated, minus one is returned and @code{NULL} is stored in |
ba19b94f DD |
55 | @code{*@var{resptr}}. |
56 | ||
57 | @end deftypefn | |
58 | ||
39423523 DD |
59 | @c atexit.c:6 |
60 | @deftypefn Supplemental int atexit (void (*@var{f})()) | |
61 | ||
62 | Causes function @var{f} to be called at exit. Returns 0. | |
63 | ||
64 | @end deftypefn | |
65 | ||
66 | @c basename.c:6 | |
67 | @deftypefn Supplemental char* basename (const char *@var{name}) | |
68 | ||
69 | Returns a pointer to the last component of pathname @var{name}. | |
70 | Behavior is undefined if the pathname ends in a directory separator. | |
71 | ||
72 | @end deftypefn | |
73 | ||
74 | @c bcmp.c:6 | |
75 | @deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count}) | |
76 | ||
77 | Compares the first @var{count} bytes of two areas of memory. Returns | |
56056af5 DD |
78 | zero if they are the same, nonzero otherwise. Returns zero if |
79 | @var{count} is zero. A nonzero result only indicates a difference, | |
39423523 DD |
80 | it does not indicate any sorting order (say, by having a positive |
81 | result mean @var{x} sorts before @var{y}). | |
82 | ||
83 | @end deftypefn | |
84 | ||
85 | @c bcopy.c:3 | |
86 | @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length}) | |
87 | ||
88 | Copies @var{length} bytes from memory region @var{in} to region | |
89 | @var{out}. The use of @code{bcopy} is deprecated in new programs. | |
90 | ||
91 | @end deftypefn | |
92 | ||
93 | @c bsearch.c:33 | |
94 | @deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *)) | |
95 | ||
96 | Performs a search over an array of @var{nmemb} elements pointed to by | |
97 | @var{base} for a member that matches the object pointed to by @var{key}. | |
98 | The size of each member is specified by @var{size}. The array contents | |
99 | should be sorted in ascending order according to the @var{compar} | |
100 | comparison function. This routine should take two arguments pointing to | |
101 | the @var{key} and to an array member, in that order, and should return an | |
102 | integer less than, equal to, or greater than zero if the @var{key} object | |
fa9f0e33 | 103 | is respectively less than, matching, or greater than the array member. |
39423523 DD |
104 | |
105 | @end deftypefn | |
106 | ||
ba19b94f DD |
107 | @c argv.c:139 |
108 | @deftypefn Extension char** buildargv (char *@var{sp}) | |
109 | ||
110 | Given a pointer to a string, parse the string extracting fields | |
111 | separated by whitespace and optionally enclosed within either single | |
112 | or double quotes (which are stripped off), and build a vector of | |
113 | pointers to copies of the string for each field. The input string | |
114 | remains unchanged. The last element of the vector is followed by a | |
115 | @code{NULL} element. | |
116 | ||
117 | All of the memory for the pointer array and copies of the string | |
118 | is obtained from @code{malloc}. All of the memory can be returned to the | |
119 | system with the single function call @code{freeargv}, which takes the | |
120 | returned result of @code{buildargv}, as it's argument. | |
121 | ||
5d852400 | 122 | Returns a pointer to the argument vector if successful. Returns |
ba19b94f DD |
123 | @code{NULL} if @var{sp} is @code{NULL} or if there is insufficient |
124 | memory to complete building the argument vector. | |
125 | ||
126 | If the input is a null string (as opposed to a @code{NULL} pointer), | |
127 | then buildarg returns an argument vector that has one arg, a null | |
128 | string. | |
129 | ||
130 | @end deftypefn | |
131 | ||
39423523 DD |
132 | @c bzero.c:6 |
133 | @deftypefn Supplemental void bzero (char *@var{mem}, int @var{count}) | |
134 | ||
fa9f0e33 | 135 | Zeros @var{count} bytes starting at @var{mem}. Use of this function |
39423523 DD |
136 | is deprecated in favor of @code{memset}. |
137 | ||
138 | @end deftypefn | |
139 | ||
140 | @c calloc.c:6 | |
141 | @deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize}) | |
142 | ||
143 | Uses @code{malloc} to allocate storage for @var{nelem} objects of | |
144 | @var{elsize} bytes each, then zeros the memory. | |
145 | ||
146 | @end deftypefn | |
147 | ||
ba19b94f | 148 | @c choose-temp.c:42 |
5d852400 | 149 | @deftypefn Extension char* choose_temp_base (void) |
ba19b94f DD |
150 | |
151 | Return a prefix for temporary file names or @code{NULL} if unable to | |
152 | find one. The current directory is chosen if all else fails so the | |
153 | program is exited if a temporary directory can't be found (@code{mktemp} | |
154 | fails). The buffer for the result is obtained with @code{xmalloc}. | |
155 | ||
156 | This function is provided for backwards compatability only. Its use is | |
157 | not recommended. | |
158 | ||
159 | @end deftypefn | |
160 | ||
161 | @c make-temp-file.c:88 | |
162 | @deftypefn Replacement char* choose_tmpdir () | |
163 | ||
164 | Returns a pointer to a directory path suitable for creating temporary | |
165 | files in. | |
166 | ||
167 | @end deftypefn | |
168 | ||
39423523 | 169 | @c clock.c:27 |
99b58139 | 170 | @deftypefn Supplemental long clock (void) |
39423523 DD |
171 | |
172 | Returns an approximation of the CPU time used by the process as a | |
173 | @code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the | |
174 | number of seconds used. | |
175 | ||
176 | @end deftypefn | |
177 | ||
ba19b94f | 178 | @c concat.c:24 |
5d852400 | 179 | @deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL}) |
ba19b94f DD |
180 | |
181 | Concatenate zero or more of strings and return the result in freshly | |
5d852400 | 182 | @code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is |
ba19b94f DD |
183 | available. The argument list is terminated by the first @code{NULL} |
184 | pointer encountered. Pointers to empty strings are ignored. | |
185 | ||
186 | @end deftypefn | |
187 | ||
188 | @c argv.c:65 | |
189 | @deftypefn Extension char** dupargv (char **@var{vector}) | |
190 | ||
191 | Duplicate an argument vector. Simply scans through @var{vector}, | |
192 | duplicating each argument until the terminating @code{NULL} is found. | |
5d852400 | 193 | Returns a pointer to the argument vector if successful. Returns |
ba19b94f DD |
194 | @code{NULL} if there is insufficient memory to complete building the |
195 | argument vector. | |
196 | ||
197 | @end deftypefn | |
198 | ||
b5c3b3de | 199 | @c strerror.c:567 |
ba19b94f | 200 | @deftypefn Extension int errno_max (void) |
39423523 DD |
201 | |
202 | Returns the maximum @code{errno} value for which a corresponding | |
203 | symbolic name or message is available. Note that in the case where we | |
204 | use the @code{sys_errlist} supplied by the system, it is possible for | |
205 | there to be more symbolic names than messages, or vice versa. In | |
206 | fact, the manual page for @code{perror(3C)} explicitly warns that one | |
207 | should check the size of the table (@code{sys_nerr}) before indexing | |
208 | it, since new error codes may be added to the system before they are | |
209 | added to the table. Thus @code{sys_nerr} might be smaller than value | |
99b58139 | 210 | implied by the largest @code{errno} value defined in @code{<errno.h>}. |
39423523 DD |
211 | |
212 | We return the maximum value that can be used to obtain a meaningful | |
213 | symbolic name or message. | |
214 | ||
215 | @end deftypefn | |
216 | ||
ba19b94f DD |
217 | @c fdmatch.c:23 |
218 | @deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2}) | |
219 | ||
220 | Check to see if two open file descriptors refer to the same file. | |
221 | This is useful, for example, when we have an open file descriptor for | |
222 | an unnamed file, and the name of a file that we believe to correspond | |
223 | to that fd. This can happen when we are exec'd with an already open | |
224 | file (@code{stdout} for example) or from the SVR4 @file{/proc} calls | |
225 | that return open file descriptors for mapped address spaces. All we | |
226 | have to do is open the file by name and check the two file descriptors | |
227 | for a match, which is done by comparing major and minor device numbers | |
228 | and inode numbers. | |
229 | ||
230 | @end deftypefn | |
231 | ||
232 | @c ffs.c:3 | |
233 | @deftypefn Supplemental int ffs (int @var{valu}) | |
234 | ||
5d852400 | 235 | Find the first (least significant) bit set in @var{valu}. Bits are |
ba19b94f DD |
236 | numbered from right to left, starting with bit 1 (corresponding to the |
237 | value 1). If @var{valu} is zero, zero is returned. | |
238 | ||
239 | @end deftypefn | |
240 | ||
241 | @c fnmatch.txh:1 | |
242 | @deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags}) | |
243 | ||
244 | Matches @var{string} against @var{pattern}, returning zero if it | |
245 | matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the | |
246 | wildcards @code{?} to match any one character, @code{*} to match any | |
247 | zero or more characters, or a set of alternate characters in square | |
248 | brackets, like @samp{[a-gt8]}, which match one character (@code{a} | |
249 | through @code{g}, or @code{t}, or @code{8}, in this example) if that one | |
5d852400 | 250 | character is in the set. A set may be inverted (i.e., match anything |
ba19b94f DD |
251 | except what's in the set) by giving @code{^} or @code{!} as the first |
252 | character in the set. To include those characters in the set, list them | |
253 | as anything other than the first character of the set. To include a | |
254 | dash in the set, list it last in the set. A backslash character makes | |
255 | the following character not special, so for example you could match | |
256 | against a literal asterisk with @samp{\*}. To match a literal | |
257 | backslash, use @samp{\\}. | |
258 | ||
259 | @code{flags} controls various aspects of the matching process, and is a | |
260 | boolean OR of zero or more of the following values (defined in | |
5d852400 | 261 | @code{<fnmatch.h>}): |
ba19b94f DD |
262 | |
263 | @table @code | |
264 | ||
265 | @item FNM_PATHNAME | |
266 | @itemx FNM_FILE_NAME | |
267 | @var{string} is assumed to be a path name. No wildcard will ever match | |
268 | @code{/}. | |
269 | ||
270 | @item FNM_NOESCAPE | |
271 | Do not interpret backslashes as quoting the following special character. | |
272 | ||
273 | @item FNM_PERIOD | |
274 | A leading period (at the beginning of @var{string}, or if | |
275 | @code{FNM_PATHNAME} after a slash) is not matched by @code{*} or | |
276 | @code{?} but must be matched explicitly. | |
277 | ||
278 | @item FNM_LEADING_DIR | |
279 | Means that @var{string} also matches @var{pattern} if some initial part | |
280 | of @var{string} matches, and is followed by @code{/} and zero or more | |
281 | characters. For example, @samp{foo*} would match either @samp{foobar} | |
282 | or @samp{foobar/grill}. | |
283 | ||
284 | @item FNM_CASEFOLD | |
285 | Ignores case when performing the comparison. | |
286 | ||
287 | @end table | |
288 | ||
289 | @end deftypefn | |
290 | ||
291 | @c argv.c:111 | |
292 | @deftypefn Extension void freeargv (char **@var{vector}) | |
293 | ||
294 | Free an argument vector that was built using @code{buildargv}. Simply | |
295 | scans through @var{vector}, freeing the memory for each argument until | |
296 | the terminating @code{NULL} is found, and then frees @var{vector} | |
297 | itself. | |
298 | ||
299 | @end deftypefn | |
300 | ||
2a80c0a4 | 301 | @c getruntime.c:82 |
5d852400 | 302 | @deftypefn Replacement long get_run_time (void) |
ba19b94f DD |
303 | |
304 | Returns the time used so far, in microseconds. If possible, this is | |
305 | the time used by this process, else it is the elapsed time since the | |
306 | process started. | |
307 | ||
308 | @end deftypefn | |
309 | ||
39423523 | 310 | @c getcwd.c:6 |
99b58139 | 311 | @deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len}) |
39423523 DD |
312 | |
313 | Copy the absolute pathname for the current working directory into | |
314 | @var{pathname}, which is assumed to point to a buffer of at least | |
315 | @var{len} bytes, and return a pointer to the buffer. If the current | |
316 | directory's path doesn't fit in @var{len} characters, the result is | |
99b58139 | 317 | @code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer, |
39423523 DD |
318 | @code{getcwd} will obtain @var{len} bytes of space using |
319 | @code{malloc}. | |
320 | ||
321 | @end deftypefn | |
322 | ||
323 | @c getpagesize.c:5 | |
99b58139 | 324 | @deftypefn Supplemental int getpagesize (void) |
39423523 DD |
325 | |
326 | Returns the number of bytes in a page of memory. This is the | |
327 | granularity of many of the system memory management routines. No | |
328 | guarantee is made as to whether or not it is the same as the basic | |
329 | memory management hardware page size. | |
330 | ||
331 | @end deftypefn | |
332 | ||
333 | @c getpwd.c:5 | |
99b58139 | 334 | @deftypefn Supplemental char* getpwd (void) |
39423523 DD |
335 | |
336 | Returns the current working directory. This implementation caches the | |
337 | result on the assumption that the process will not call @code{chdir} | |
338 | between calls to @code{getpwd}. | |
339 | ||
340 | @end deftypefn | |
341 | ||
0fad4bdb DD |
342 | @c gettimeofday.c:12 |
343 | @deftypefn int gettimeofday (struct timeval *@var{tp}, void *@var{tz}) | |
344 | ||
345 | Writes the current time to @var{tp}. This implementation requires | |
346 | that @var{tz} be NULL. Returns 0 on success, -1 on failure. | |
347 | ||
348 | @end deftypefn | |
349 | ||
70ecf948 | 350 | @c hex.c:30 |
7dd4d42a DD |
351 | @deftypefn Extension void hex_init (void) |
352 | ||
353 | Initializes the array mapping the current character set to | |
354 | corresponding hex values. This function must be called before any | |
2a80c0a4 DD |
355 | call to @code{hex_p} or @code{hex_value}. If you fail to call it, a |
356 | default ASCII-based table will normally be used on ASCII systems. | |
7dd4d42a DD |
357 | |
358 | @end deftypefn | |
359 | ||
70ecf948 | 360 | @c hex.c:39 |
7dd4d42a DD |
361 | @deftypefn Extension int hex_p (int @var{c}) |
362 | ||
363 | Evaluates to non-zero if the given character is a valid hex character, | |
364 | or zero if it is not. Note that the value you pass will be cast to | |
365 | @code{unsigned char} within the macro. | |
366 | ||
367 | @end deftypefn | |
368 | ||
70ecf948 | 369 | @c hex.c:47 |
b5c3b3de | 370 | @deftypefn Extension {unsigned int} hex_value (int @var{c}) |
7dd4d42a DD |
371 | |
372 | Returns the numeric equivalent of the given character when interpreted | |
373 | as a hexidecimal digit. The result is undefined if you pass an | |
374 | invalid hex digit. Note that the value you pass will be cast to | |
375 | @code{unsigned char} within the macro. | |
376 | ||
e4f79046 JB |
377 | The @code{hex_value} macro returns @code{unsigned int}, rather than |
378 | signed @code{int}, to make it easier to use in parsing addresses from | |
379 | hex dump files: a signed @code{int} would be sign-extended when | |
380 | converted to a wider unsigned type --- like @code{bfd_vma}, on some | |
381 | systems. | |
382 | ||
7dd4d42a DD |
383 | @end deftypefn |
384 | ||
39423523 DD |
385 | @c index.c:5 |
386 | @deftypefn Supplemental char* index (char *@var{s}, int @var{c}) | |
387 | ||
fa9f0e33 | 388 | Returns a pointer to the first occurrence of the character @var{c} in |
99b58139 | 389 | the string @var{s}, or @code{NULL} if not found. The use of @code{index} is |
39423523 DD |
390 | deprecated in new programs in favor of @code{strchr}. |
391 | ||
392 | @end deftypefn | |
393 | ||
ba19b94f DD |
394 | @c insque.c:6 |
395 | @deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred}) | |
396 | @deftypefnx Supplemental void remque (struct qelem *@var{elem}) | |
397 | ||
398 | Routines to manipulate queues built from doubly linked lists. The | |
399 | @code{insque} routine inserts @var{elem} in the queue immediately | |
400 | after @var{pred}. The @code{remque} routine removes @var{elem} from | |
401 | its containing queue. These routines expect to be passed pointers to | |
402 | structures which have as their first members a forward pointer and a | |
403 | back pointer, like this prototype (although no prototype is provided): | |
404 | ||
405 | @example | |
406 | struct qelem @{ | |
407 | struct qelem *q_forw; | |
408 | struct qelem *q_back; | |
409 | char q_data[]; | |
410 | @}; | |
411 | @end example | |
412 | ||
413 | @end deftypefn | |
414 | ||
70ecf948 DD |
415 | @c safe-ctype.c:45 |
416 | @deffn Extension ISALPHA (@var{c}) | |
417 | @deffnx Extension ISALNUM (@var{c}) | |
418 | @deffnx Extension ISBLANK (@var{c}) | |
419 | @deffnx Extension ISCNTRL (@var{c}) | |
420 | @deffnx Extension ISDIGIT (@var{c}) | |
421 | @deffnx Extension ISGRAPH (@var{c}) | |
422 | @deffnx Extension ISLOWER (@var{c}) | |
423 | @deffnx Extension ISPRINT (@var{c}) | |
424 | @deffnx Extension ISPUNCT (@var{c}) | |
425 | @deffnx Extension ISSPACE (@var{c}) | |
426 | @deffnx Extension ISUPPER (@var{c}) | |
427 | @deffnx Extension ISXDIGIT (@var{c}) | |
428 | ||
429 | These twelve macros are defined by @file{safe-ctype.h}. Each has the | |
430 | same meaning as the corresponding macro (with name in lowercase) | |
431 | defined by the standard header @file{ctype.h}. For example, | |
432 | @code{ISALPHA} returns true for alphabetic characters and false for | |
433 | others. However, there are two differences between these macros and | |
434 | those provided by @file{ctype.h}: | |
435 | ||
436 | @itemize @bullet | |
437 | @item These macros are guaranteed to have well-defined behavior for all | |
438 | values representable by @code{signed char} and @code{unsigned char}, and | |
439 | for @code{EOF}. | |
440 | ||
441 | @item These macros ignore the current locale; they are true for these | |
442 | fixed sets of characters: | |
443 | @multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada} | |
444 | @item @code{ALPHA} @tab @kbd{A-Za-z} | |
445 | @item @code{ALNUM} @tab @kbd{A-Za-z0-9} | |
446 | @item @code{BLANK} @tab @kbd{space tab} | |
447 | @item @code{CNTRL} @tab @code{!PRINT} | |
448 | @item @code{DIGIT} @tab @kbd{0-9} | |
449 | @item @code{GRAPH} @tab @code{ALNUM || PUNCT} | |
450 | @item @code{LOWER} @tab @kbd{a-z} | |
451 | @item @code{PRINT} @tab @code{GRAPH ||} @kbd{space} | |
452 | @item @code{PUNCT} @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?} | |
453 | @item @code{SPACE} @tab @kbd{space tab \n \r \f \v} | |
454 | @item @code{UPPER} @tab @kbd{A-Z} | |
455 | @item @code{XDIGIT} @tab @kbd{0-9A-Fa-f} | |
456 | @end multitable | |
457 | ||
458 | Note that, if the host character set is ASCII or a superset thereof, | |
459 | all these macros will return false for all values of @code{char} outside | |
460 | the range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return | |
461 | false for characters with numeric values from 128 to 255. | |
462 | @end itemize | |
463 | @end deffn | |
464 | ||
465 | @c safe-ctype.c:94 | |
466 | @deffn Extension ISIDNUM (@var{c}) | |
467 | @deffnx Extension ISIDST (@var{c}) | |
468 | @deffnx Extension IS_VSPACE (@var{c}) | |
469 | @deffnx Extension IS_NVSPACE (@var{c}) | |
470 | @deffnx Extension IS_SPACE_OR_NUL (@var{c}) | |
471 | @deffnx Extension IS_ISOBASIC (@var{c}) | |
472 | These six macros are defined by @file{safe-ctype.h} and provide | |
473 | additional character classes which are useful when doing lexical | |
474 | analysis of C or similar languages. They are true for the following | |
475 | sets of characters: | |
476 | ||
477 | @multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada} | |
478 | @item @code{IDNUM} @tab @kbd{A-Za-z0-9_} | |
479 | @item @code{IDST} @tab @kbd{A-Za-z_} | |
480 | @item @code{VSPACE} @tab @kbd{\r \n} | |
481 | @item @code{NVSPACE} @tab @kbd{space tab \f \v \0} | |
482 | @item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE} | |
483 | @item @code{ISOBASIC} @tab @code{VSPACE || NVSPACE || PRINT} | |
484 | @end multitable | |
485 | @end deffn | |
486 | ||
ba19b94f DD |
487 | @c lbasename.c:23 |
488 | @deftypefn Replacement {const char*} lbasename (const char *@var{name}) | |
489 | ||
490 | Given a pointer to a string containing a typical pathname | |
491 | (@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the | |
492 | last component of the pathname (@samp{ls.c} in this case). The | |
493 | returned pointer is guaranteed to lie within the original | |
494 | string. This latter fact is not true of many vendor C | |
495 | libraries, which return special strings or modify the passed | |
496 | strings for particular input. | |
497 | ||
498 | In particular, the empty string returns the same empty string, | |
499 | and a path ending in @code{/} returns the empty string after it. | |
500 | ||
501 | @end deftypefn | |
502 | ||
ba61a412 DJ |
503 | @c lrealpath.c:25 |
504 | @deftypefn Replacement {const char*} lrealpath (const char *@var{name}) | |
505 | ||
506 | Given a pointer to a string containing a pathname, returns a canonical | |
507 | version of the filename. Symlinks will be resolved, and ``.'' and ``..'' | |
508 | components will be simplified. The returned value will be allocated using | |
10b57b38 | 509 | @code{malloc}, or @code{NULL} will be returned on a memory allocation error. |
2a80c0a4 | 510 | |
ba61a412 | 511 | @end deftypefn |
2a80c0a4 | 512 | |
ba61a412 DJ |
513 | @c make-relative-prefix.c:24 |
514 | @deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, const char *@var{bin_prefix}, const char *@var{prefix}) | |
2a80c0a4 | 515 | |
ba61a412 DJ |
516 | Given three paths @var{progname}, @var{bin_prefix}, @var{prefix}, |
517 | return the path that is in the same position relative to | |
518 | @var{progname}'s directory as @var{prefix} is relative to | |
519 | @var{bin_prefix}. That is, a string starting with the directory | |
520 | portion of @var{progname}, followed by a relative pathname of the | |
521 | difference between @var{bin_prefix} and @var{prefix}. | |
522 | ||
523 | If @var{progname} does not contain any directory separators, | |
524 | @code{make_relative_prefix} will search @env{PATH} to find a program | |
525 | named @var{progname}. Also, if @var{progname} is a symbolic link, | |
526 | the symbolic link will be resolved. | |
527 | ||
528 | For example, if @var{bin_prefix} is @code{/alpha/beta/gamma/gcc/delta}, | |
529 | @var{prefix} is @code{/alpha/beta/gamma/omega/}, and @var{progname} is | |
530 | @code{/red/green/blue/gcc}, then this function will return | |
531 | @code{/red/green/blue/../../omega/}. | |
532 | ||
533 | The return value is normally allocated via @code{malloc}. If no | |
534 | relative prefix can be found, return @code{NULL}. | |
2a80c0a4 DD |
535 | |
536 | @end deftypefn | |
537 | ||
ba19b94f DD |
538 | @c make-temp-file.c:138 |
539 | @deftypefn Replacement char* make_temp_file (const char *@var{suffix}) | |
540 | ||
541 | Return a temporary file name (as a string) or @code{NULL} if unable to | |
542 | create one. @var{suffix} is a suffix to append to the file name. The | |
5d852400 | 543 | string is @code{malloc}ed, and the temporary file has been created. |
ba19b94f DD |
544 | |
545 | @end deftypefn | |
546 | ||
39423523 DD |
547 | @c memchr.c:3 |
548 | @deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n}) | |
549 | ||
99b58139 | 550 | This function searches memory starting at @code{*@var{s}} for the |
39423523 DD |
551 | character @var{c}. The search only ends with the first occurrence of |
552 | @var{c}, or after @var{length} characters; in particular, a null | |
553 | character does not terminate the search. If the character @var{c} is | |
99b58139 DD |
554 | found within @var{length} characters of @code{*@var{s}}, a pointer |
555 | to the character is returned. If @var{c} is not found, then @code{NULL} is | |
39423523 DD |
556 | returned. |
557 | ||
558 | @end deftypefn | |
559 | ||
560 | @c memcmp.c:6 | |
561 | @deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count}) | |
562 | ||
563 | Compares the first @var{count} bytes of two areas of memory. Returns | |
564 | zero if they are the same, a value less than zero if @var{x} is | |
565 | lexically less than @var{y}, or a value greater than zero if @var{x} | |
566 | is lexically greater than @var{y}. Note that lexical order is determined | |
567 | as if comparing unsigned char arrays. | |
568 | ||
569 | @end deftypefn | |
570 | ||
571 | @c memcpy.c:6 | |
572 | @deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) | |
573 | ||
574 | Copies @var{length} bytes from memory region @var{in} to region | |
575 | @var{out}. Returns a pointer to @var{out}. | |
576 | ||
577 | @end deftypefn | |
578 | ||
579 | @c memmove.c:6 | |
580 | @deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count}) | |
581 | ||
582 | Copies @var{count} bytes from memory area @var{from} to memory area | |
583 | @var{to}, returning a pointer to @var{to}. | |
584 | ||
585 | @end deftypefn | |
586 | ||
10b57b38 DD |
587 | @c mempcpy.c:23 |
588 | @deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) | |
589 | ||
590 | Copies @var{length} bytes from memory region @var{in} to region | |
591 | @var{out}. Returns a pointer to @var{out} + @var{length}. | |
592 | ||
593 | @end deftypefn | |
594 | ||
39423523 DD |
595 | @c memset.c:6 |
596 | @deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count}) | |
597 | ||
598 | Sets the first @var{count} bytes of @var{s} to the constant byte | |
599 | @var{c}, returning a pointer to @var{s}. | |
600 | ||
601 | @end deftypefn | |
602 | ||
ba19b94f DD |
603 | @c mkstemps.c:54 |
604 | @deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len}) | |
605 | ||
606 | Generate a unique temporary file name from @var{template}. | |
607 | @var{template} has the form: | |
608 | ||
609 | @example | |
5d852400 | 610 | @var{path}/ccXXXXXX@var{suffix} |
ba19b94f DD |
611 | @end example |
612 | ||
5d852400 DD |
613 | @var{suffix_len} tells us how long @var{suffix} is (it can be zero |
614 | length). The last six characters of @var{template} before @var{suffix} | |
615 | must be @samp{XXXXXX}; they are replaced with a string that makes the | |
ba19b94f DD |
616 | filename unique. Returns a file descriptor open on the file for |
617 | reading and writing. | |
618 | ||
619 | @end deftypefn | |
620 | ||
5a17353c | 621 | @c pexecute.txh:1 |
ba19b94f DD |
622 | @deftypefn Extension int pexecute (const char *@var{program}, char * const *@var{argv}, const char *@var{this_pname}, const char *@var{temp_base}, char **@var{errmsg_fmt}, char **@var{errmsg_arg}, int flags) |
623 | ||
624 | Executes a program. | |
625 | ||
626 | @var{program} and @var{argv} are the arguments to | |
627 | @code{execv}/@code{execvp}. | |
628 | ||
5d852400 | 629 | @var{this_pname} is name of the calling program (i.e., @code{argv[0]}). |
ba19b94f DD |
630 | |
631 | @var{temp_base} is the path name, sans suffix, of a temporary file to | |
632 | use if needed. This is currently only needed for MS-DOS ports that | |
633 | don't use @code{go32} (do any still exist?). Ports that don't need it | |
634 | can pass @code{NULL}. | |
635 | ||
5a17353c DD |
636 | (@code{@var{flags} & PEXECUTE_SEARCH}) is non-zero if @env{PATH} |
637 | should be searched (??? It's not clear that GCC passes this flag | |
638 | correctly). (@code{@var{flags} & PEXECUTE_FIRST}) is nonzero for the | |
639 | first process in chain. (@code{@var{flags} & PEXECUTE_FIRST}) is | |
640 | nonzero for the last process in chain. The first/last flags could be | |
641 | simplified to only mark the last of a chain of processes but that | |
642 | requires the caller to always mark the last one (and not give up | |
643 | early if some error occurs). It's more robust to require the caller | |
644 | to mark both ends of the chain. | |
ba19b94f DD |
645 | |
646 | The result is the pid on systems like Unix where we | |
647 | @code{fork}/@code{exec} and on systems like WIN32 and OS/2 where we | |
648 | use @code{spawn}. It is up to the caller to wait for the child. | |
649 | ||
5d852400 | 650 | The result is the @code{WEXITSTATUS} on systems like MS-DOS where we |
ba19b94f DD |
651 | @code{spawn} and wait for the child here. |
652 | ||
653 | Upon failure, @var{errmsg_fmt} and @var{errmsg_arg} are set to the | |
654 | text of the error message with an optional argument (if not needed, | |
5d852400 | 655 | @var{errmsg_arg} is set to @code{NULL}), and @minus{}1 is returned. |
ba19b94f DD |
656 | @code{errno} is available to the caller to use. |
657 | ||
658 | @end deftypefn | |
659 | ||
b5c3b3de | 660 | @c strsignal.c:546 |
ba19b94f DD |
661 | @deftypefn Supplemental void psignal (unsigned @var{signo}, char *@var{message}) |
662 | ||
663 | Print @var{message} to the standard error, followed by a colon, | |
664 | followed by the description of the signal specified by @var{signo}, | |
665 | followed by a newline. | |
666 | ||
667 | @end deftypefn | |
668 | ||
39423523 DD |
669 | @c putenv.c:21 |
670 | @deftypefn Supplemental int putenv (const char *@var{string}) | |
671 | ||
672 | Uses @code{setenv} or @code{unsetenv} to put @var{string} into | |
673 | the environment or remove it. If @var{string} is of the form | |
99b58139 | 674 | @samp{name=value} the string is added; if no @samp{=} is present the |
39423523 DD |
675 | name is unset/removed. |
676 | ||
677 | @end deftypefn | |
678 | ||
5a17353c | 679 | @c pexecute.txh:39 |
ba19b94f DD |
680 | @deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags}) |
681 | ||
682 | Waits for a program started by @code{pexecute} to finish. | |
683 | ||
684 | @var{pid} is the process id of the task to wait for. @var{status} is | |
5a17353c DD |
685 | the `status' argument to wait. @var{flags} is currently unused |
686 | (allows future enhancement without breaking upward compatibility). | |
687 | Pass 0 for now. | |
ba19b94f DD |
688 | |
689 | The result is the pid of the child reaped, or -1 for failure | |
690 | (@code{errno} says why). | |
691 | ||
5a17353c DD |
692 | On systems that don't support waiting for a particular child, |
693 | @var{pid} is ignored. On systems like MS-DOS that don't really | |
694 | multitask @code{pwait} is just a mechanism to provide a consistent | |
695 | interface for the caller. | |
ba19b94f DD |
696 | |
697 | @end deftypefn | |
698 | ||
699 | @c random.c:39 | |
5d852400 | 700 | @deftypefn Supplement {long int} random (void) |
ba19b94f DD |
701 | @deftypefnx Supplement void srandom (unsigned int @var{seed}) |
702 | @deftypefnx Supplement void* initstate (unsigned int @var{seed}, void *@var{arg_state}, unsigned long @var{n}) | |
703 | @deftypefnx Supplement void* setstate (void *@var{arg_state}) | |
704 | ||
705 | Random number functions. @code{random} returns a random number in the | |
5d852400 | 706 | range 0 to @code{LONG_MAX}. @code{srandom} initializes the random |
ba19b94f DD |
707 | number generator to some starting point determined by @var{seed} |
708 | (else, the values returned by @code{random} are always the same for each | |
5d852400 | 709 | run of the program). @code{initstate} and @code{setstate} allow fine-grained |
ba19b94f DD |
710 | control over the state of the random number generator. |
711 | ||
712 | @end deftypefn | |
713 | ||
714 | @c concat.c:177 | |
5d852400 | 715 | @deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @dots{}, @code{NULL}) |
ba19b94f DD |
716 | |
717 | Same as @code{concat}, except that if @var{optr} is not @code{NULL} it | |
718 | is freed after the string is created. This is intended to be useful | |
719 | when you're extending an existing string or building up a string in a | |
720 | loop: | |
721 | ||
722 | @example | |
723 | str = reconcat (str, "pre-", str, NULL); | |
724 | @end example | |
725 | ||
726 | @end deftypefn | |
727 | ||
39423523 DD |
728 | @c rename.c:6 |
729 | @deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new}) | |
730 | ||
731 | Renames a file from @var{old} to @var{new}. If @var{new} already | |
732 | exists, it is removed. | |
733 | ||
734 | @end deftypefn | |
735 | ||
736 | @c rindex.c:5 | |
737 | @deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c}) | |
738 | ||
fa9f0e33 | 739 | Returns a pointer to the last occurrence of the character @var{c} in |
99b58139 | 740 | the string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is |
39423523 DD |
741 | deprecated in new programs in favor of @code{strrchr}. |
742 | ||
743 | @end deftypefn | |
744 | ||
745 | @c setenv.c:22 | |
746 | @deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite}) | |
747 | @deftypefnx Supplemental void unsetenv (const char *@var{name}) | |
748 | ||
749 | @code{setenv} adds @var{name} to the environment with value | |
750 | @var{value}. If the name was already present in the environment, | |
56056af5 | 751 | the new value will be stored only if @var{overwrite} is nonzero. |
39423523 DD |
752 | The companion @code{unsetenv} function removes @var{name} from the |
753 | environment. This implementation is not safe for multithreaded code. | |
754 | ||
755 | @end deftypefn | |
756 | ||
b5c3b3de | 757 | @c strsignal.c:352 |
5d852400 | 758 | @deftypefn Extension int signo_max (void) |
ba19b94f DD |
759 | |
760 | Returns the maximum signal value for which a corresponding symbolic | |
761 | name or message is available. Note that in the case where we use the | |
762 | @code{sys_siglist} supplied by the system, it is possible for there to | |
763 | be more symbolic names than messages, or vice versa. In fact, the | |
764 | manual page for @code{psignal(3b)} explicitly warns that one should | |
765 | check the size of the table (@code{NSIG}) before indexing it, since | |
766 | new signal codes may be added to the system before they are added to | |
767 | the table. Thus @code{NSIG} might be smaller than value implied by | |
768 | the largest signo value defined in @code{<signal.h>}. | |
769 | ||
770 | We return the maximum value that can be used to obtain a meaningful | |
771 | symbolic name or message. | |
772 | ||
773 | @end deftypefn | |
774 | ||
39423523 DD |
775 | @c sigsetmask.c:8 |
776 | @deftypefn Supplemental int sigsetmask (int @var{set}) | |
777 | ||
778 | Sets the signal mask to the one provided in @var{set} and returns | |
779 | the old mask (which, for libiberty's implementation, will always | |
780 | be the value @code{1}). | |
781 | ||
782 | @end deftypefn | |
783 | ||
2ed1e5cc DD |
784 | @c snprintf.c:28 |
785 | @deftypefn Supplemental int snprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, ...) | |
786 | ||
787 | This function is similar to sprintf, but it will print at most @var{n} | |
788 | characters. On error the return value is -1, otherwise it returns the | |
789 | number of characters that would have been printed had @var{n} been | |
790 | sufficiently large, regardless of the actual value of @var{n}. Note | |
791 | some pre-C99 system libraries do not implement this correctly so users | |
792 | cannot generally rely on the return value if the system version of | |
793 | this function is used. | |
794 | ||
795 | @end deftypefn | |
796 | ||
ba19b94f DD |
797 | @c spaces.c:22 |
798 | @deftypefn Extension char* spaces (int @var{count}) | |
799 | ||
800 | Returns a pointer to a memory region filled with the specified | |
801 | number of spaces and null terminated. The returned pointer is | |
802 | valid until at least the next call. | |
803 | ||
804 | @end deftypefn | |
805 | ||
10b57b38 DD |
806 | @c stpcpy.c:23 |
807 | @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) | |
808 | ||
809 | Copies the string @var{src} into @var{dst}. Returns a pointer to | |
810 | @var{dst} + strlen(@var{src}). | |
811 | ||
812 | @end deftypefn | |
813 | ||
814 | @c stpncpy.c:23 | |
815 | @deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len}) | |
816 | ||
817 | Copies the string @var{src} into @var{dst}, copying exactly @var{len} | |
818 | and padding with zeros if necessary. If @var{len} < strlen(@var{src}) | |
819 | then return @var{dst} + @var{len}, otherwise returns @var{dst} + | |
820 | strlen(@var{src}). | |
821 | ||
822 | @end deftypefn | |
823 | ||
39423523 DD |
824 | @c strcasecmp.c:15 |
825 | @deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) | |
826 | ||
827 | A case-insensitive @code{strcmp}. | |
828 | ||
829 | @end deftypefn | |
830 | ||
831 | @c strchr.c:6 | |
832 | @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c}) | |
833 | ||
fa9f0e33 | 834 | Returns a pointer to the first occurrence of the character @var{c} in |
99b58139 | 835 | the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the |
39423523 DD |
836 | null character, the results are undefined. |
837 | ||
838 | @end deftypefn | |
839 | ||
840 | @c strdup.c:3 | |
841 | @deftypefn Supplemental char* strdup (const char *@var{s}) | |
842 | ||
843 | Returns a pointer to a copy of @var{s} in memory obtained from | |
99b58139 | 844 | @code{malloc}, or @code{NULL} if insufficient memory was available. |
39423523 DD |
845 | |
846 | @end deftypefn | |
847 | ||
b5c3b3de | 848 | @c strerror.c:671 |
ba19b94f | 849 | @deftypefn Replacement {const char*} strerrno (int @var{errnum}) |
39423523 DD |
850 | |
851 | Given an error number returned from a system call (typically returned | |
852 | in @code{errno}), returns a pointer to a string containing the | |
99b58139 | 853 | symbolic name of that error number, as found in @code{<errno.h>}. |
39423523 DD |
854 | |
855 | If the supplied error number is within the valid range of indices for | |
856 | symbolic names, but no name is available for the particular error | |
ba19b94f | 857 | number, then returns the string @samp{Error @var{num}}, where @var{num} |
fa9f0e33 | 858 | is the error number. |
39423523 DD |
859 | |
860 | If the supplied error number is not within the range of valid | |
99b58139 | 861 | indices, then returns @code{NULL}. |
39423523 DD |
862 | |
863 | The contents of the location pointed to are only guaranteed to be | |
fa9f0e33 | 864 | valid until the next call to @code{strerrno}. |
39423523 DD |
865 | |
866 | @end deftypefn | |
867 | ||
b5c3b3de | 868 | @c strerror.c:603 |
ba19b94f | 869 | @deftypefn Supplemental char* strerror (int @var{errnoval}) |
39423523 DD |
870 | |
871 | Maps an @code{errno} number to an error message string, the contents | |
872 | of which are implementation defined. On systems which have the | |
873 | external variables @code{sys_nerr} and @code{sys_errlist}, these | |
874 | strings will be the same as the ones used by @code{perror}. | |
875 | ||
876 | If the supplied error number is within the valid range of indices for | |
877 | the @code{sys_errlist}, but no message is available for the particular | |
ba19b94f | 878 | error number, then returns the string @samp{Error @var{num}}, where |
fa9f0e33 | 879 | @var{num} is the error number. |
39423523 DD |
880 | |
881 | If the supplied error number is not a valid index into | |
99b58139 | 882 | @code{sys_errlist}, returns @code{NULL}. |
39423523 DD |
883 | |
884 | The returned string is only guaranteed to be valid only until the | |
885 | next call to @code{strerror}. | |
886 | ||
887 | @end deftypefn | |
888 | ||
889 | @c strncasecmp.c:15 | |
890 | @deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2}) | |
891 | ||
892 | A case-insensitive @code{strncmp}. | |
893 | ||
894 | @end deftypefn | |
895 | ||
896 | @c strncmp.c:6 | |
897 | @deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n}) | |
898 | ||
899 | Compares the first @var{n} bytes of two strings, returning a value as | |
900 | @code{strcmp}. | |
901 | ||
902 | @end deftypefn | |
903 | ||
0fad4bdb DD |
904 | @c strndup.c:23 |
905 | @deftypefn Extension char* strndup (const char *@var{s}, size_t @var{n}) | |
906 | ||
907 | Returns a pointer to a copy of @var{s} with at most @var{n} characters | |
908 | in memory obtained from @code{malloc}, or @code{NULL} if insufficient | |
909 | memory was available. The result is always NUL terminated. | |
910 | ||
911 | @end deftypefn | |
912 | ||
39423523 DD |
913 | @c strrchr.c:6 |
914 | @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c}) | |
915 | ||
fa9f0e33 | 916 | Returns a pointer to the last occurrence of the character @var{c} in |
99b58139 | 917 | the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the |
39423523 DD |
918 | null character, the results are undefined. |
919 | ||
920 | @end deftypefn | |
921 | ||
b5c3b3de | 922 | @c strsignal.c:387 |
ba19b94f DD |
923 | @deftypefn Supplemental {const char *} strsignal (int @var{signo}) |
924 | ||
925 | Maps an signal number to an signal message string, the contents of | |
926 | which are implementation defined. On systems which have the external | |
927 | variable @code{sys_siglist}, these strings will be the same as the | |
928 | ones used by @code{psignal()}. | |
929 | ||
930 | If the supplied signal number is within the valid range of indices for | |
931 | the @code{sys_siglist}, but no message is available for the particular | |
932 | signal number, then returns the string @samp{Signal @var{num}}, where | |
933 | @var{num} is the signal number. | |
934 | ||
935 | If the supplied signal number is not a valid index into | |
936 | @code{sys_siglist}, returns @code{NULL}. | |
937 | ||
938 | The returned string is only guaranteed to be valid only until the next | |
939 | call to @code{strsignal}. | |
940 | ||
941 | @end deftypefn | |
942 | ||
b5c3b3de | 943 | @c strsignal.c:451 |
ba19b94f DD |
944 | @deftypefn Extension {const char*} strsigno (int @var{signo}) |
945 | ||
946 | Given an signal number, returns a pointer to a string containing the | |
947 | symbolic name of that signal number, as found in @code{<signal.h>}. | |
948 | ||
949 | If the supplied signal number is within the valid range of indices for | |
950 | symbolic names, but no name is available for the particular signal | |
951 | number, then returns the string @samp{Signal @var{num}}, where | |
952 | @var{num} is the signal number. | |
953 | ||
954 | If the supplied signal number is not within the range of valid | |
955 | indices, then returns @code{NULL}. | |
956 | ||
957 | The contents of the location pointed to are only guaranteed to be | |
958 | valid until the next call to @code{strsigno}. | |
959 | ||
960 | @end deftypefn | |
961 | ||
39423523 DD |
962 | @c strstr.c:6 |
963 | @deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub}) | |
964 | ||
965 | This function searches for the substring @var{sub} in the string | |
fa9f0e33 | 966 | @var{string}, not including the terminating null characters. A pointer |
99b58139 | 967 | to the first occurrence of @var{sub} is returned, or @code{NULL} if the |
39423523 DD |
968 | substring is absent. If @var{sub} points to a string with zero |
969 | length, the function returns @var{string}. | |
970 | ||
971 | @end deftypefn | |
972 | ||
973 | @c strtod.c:27 | |
974 | @deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr}) | |
975 | ||
56056af5 | 976 | This ISO C function converts the initial portion of @var{string} to a |
99b58139 | 977 | @code{double}. If @var{endptr} is not @code{NULL}, a pointer to the |
39423523 DD |
978 | character after the last character used in the conversion is stored in |
979 | the location referenced by @var{endptr}. If no conversion is | |
980 | performed, zero is returned and the value of @var{string} is stored in | |
981 | the location referenced by @var{endptr}. | |
982 | ||
983 | @end deftypefn | |
984 | ||
b5c3b3de | 985 | @c strerror.c:731 |
ba19b94f | 986 | @deftypefn Extension int strtoerrno (const char *@var{name}) |
39423523 | 987 | |
99b58139 | 988 | Given the symbolic name of a error number (e.g., @code{EACCES}), map it |
39423523 DD |
989 | to an errno value. If no translation is found, returns 0. |
990 | ||
991 | @end deftypefn | |
992 | ||
993 | @c strtol.c:33 | |
994 | @deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base}) | |
ba19b94f | 995 | @deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base}) |
39423523 DD |
996 | |
997 | The @code{strtol} function converts the string in @var{string} to a | |
998 | long integer value according to the given @var{base}, which must be | |
999 | between 2 and 36 inclusive, or be the special value 0. If @var{base} | |
1000 | is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x} | |
1001 | to indicate bases 8 and 16, respectively, else default to base 10. | |
1002 | When the base is 16 (either explicitly or implicitly), a prefix of | |
fa9f0e33 | 1003 | @code{0x} is allowed. The handling of @var{endptr} is as that of |
ba19b94f DD |
1004 | @code{strtod} above. The @code{strtoul} function is the same, except |
1005 | that the converted value is unsigned. | |
1006 | ||
1007 | @end deftypefn | |
1008 | ||
b5c3b3de | 1009 | @c strsignal.c:506 |
ba19b94f DD |
1010 | @deftypefn Extension int strtosigno (const char *@var{name}) |
1011 | ||
1012 | Given the symbolic name of a signal, map it to a signal number. If no | |
1013 | translation is found, returns 0. | |
39423523 DD |
1014 | |
1015 | @end deftypefn | |
1016 | ||
1017 | @c tmpnam.c:3 | |
1018 | @deftypefn Supplemental char* tmpnam (char *@var{s}) | |
1019 | ||
1020 | This function attempts to create a name for a temporary file, which | |
1021 | will be a valid file name yet not exist when @code{tmpnam} checks for | |
1022 | it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes, | |
99b58139 | 1023 | or be @code{NULL}. Use of this function creates a security risk, and it must |
39423523 DD |
1024 | not be used in new projects. Use @code{mkstemp} instead. |
1025 | ||
1026 | @end deftypefn | |
1027 | ||
0fad4bdb DD |
1028 | @c unlink-if-ordinary.c:27 |
1029 | @deftypefn Supplemental int unlink_if_ordinary (const char*) | |
1030 | ||
1031 | Unlinks the named file, unless it is special (e.g. a device file). | |
1032 | Returns 0 when the file was unlinked, a negative value (and errno set) when | |
1033 | there was an error deleting the file, and a positive value if no attempt | |
1034 | was made to unlink the file because it is special. | |
1035 | ||
1036 | @end deftypefn | |
1037 | ||
b5c3b3de | 1038 | @c vasprintf.c:51 |
5d852400 | 1039 | @deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args}) |
ba19b94f DD |
1040 | |
1041 | Like @code{vsprintf}, but instead of passing a pointer to a buffer, | |
1042 | you pass a pointer to a pointer. This function will compute the size | |
1043 | of the buffer needed, allocate memory with @code{malloc}, and store a | |
1044 | pointer to the allocated memory in @code{*@var{resptr}}. The value | |
1045 | returned is the same as @code{vsprintf} would return. If memory could | |
5a4e47bd | 1046 | not be allocated, minus one is returned and @code{NULL} is stored in |
ba19b94f DD |
1047 | @code{*@var{resptr}}. |
1048 | ||
1049 | @end deftypefn | |
1050 | ||
39423523 | 1051 | @c vfork.c:6 |
99b58139 | 1052 | @deftypefn Supplemental int vfork (void) |
39423523 DD |
1053 | |
1054 | Emulates @code{vfork} by calling @code{fork} and returning its value. | |
1055 | ||
1056 | @end deftypefn | |
1057 | ||
1058 | @c vprintf.c:3 | |
1059 | @deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap}) | |
1060 | @deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap}) | |
1061 | @deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap}) | |
1062 | ||
1063 | These functions are the same as @code{printf}, @code{fprintf}, and | |
1064 | @code{sprintf}, respectively, except that they are called with a | |
1065 | @code{va_list} instead of a variable number of arguments. Note that | |
1066 | they do not call @code{va_end}; this is the application's | |
1067 | responsibility. In @libib{} they are implemented in terms of the | |
1068 | nonstandard but common function @code{_doprnt}. | |
1069 | ||
1070 | @end deftypefn | |
1071 | ||
2ed1e5cc DD |
1072 | @c vsnprintf.c:28 |
1073 | @deftypefn Supplemental int vsnprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, va_list @var{ap}) | |
1074 | ||
1075 | This function is similar to vsprintf, but it will print at most | |
1076 | @var{n} characters. On error the return value is -1, otherwise it | |
1077 | returns the number of characters that would have been printed had | |
1078 | @var{n} been sufficiently large, regardless of the actual value of | |
1079 | @var{n}. Note some pre-C99 system libraries do not implement this | |
1080 | correctly so users cannot generally rely on the return value if the | |
1081 | system version of this function is used. | |
1082 | ||
1083 | @end deftypefn | |
1084 | ||
39423523 DD |
1085 | @c waitpid.c:3 |
1086 | @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int) | |
1087 | ||
1088 | This is a wrapper around the @code{wait} function. Any ``special'' | |
1089 | values of @var{pid} depend on your implementation of @code{wait}, as | |
1090 | does the return value. The third argument is unused in @libib{}. | |
1091 | ||
1092 | @end deftypefn | |
1093 | ||
1094 | @c xatexit.c:11 | |
1095 | @deftypefun int xatexit (void (*@var{fn}) (void)) | |
1096 | ||
1097 | Behaves as the standard @code{atexit} function, but with no limit on | |
99b58139 | 1098 | the number of registered functions. Returns 0 on success, or @minus{}1 on |
39423523 DD |
1099 | failure. If you use @code{xatexit} to register functions, you must use |
1100 | @code{xexit} to terminate your program. | |
1101 | ||
1102 | @end deftypefun | |
1103 | ||
fa9f0e33 | 1104 | @c xmalloc.c:38 |
99b58139 | 1105 | @deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize}) |
39423523 DD |
1106 | |
1107 | Allocate memory without fail, and set it to zero. This routine functions | |
1108 | like @code{calloc}, but will behave the same as @code{xmalloc} if memory | |
1109 | cannot be found. | |
1110 | ||
1111 | @end deftypefn | |
1112 | ||
1113 | @c xexit.c:22 | |
1114 | @deftypefn Replacement void xexit (int @var{code}) | |
1115 | ||
1116 | Terminates the program. If any functions have been registered with | |
fa9f0e33 | 1117 | the @code{xatexit} replacement function, they will be called first. |
39423523 DD |
1118 | Termination is handled via the system's normal @code{exit} call. |
1119 | ||
1120 | @end deftypefn | |
1121 | ||
1122 | @c xmalloc.c:22 | |
1123 | @deftypefn Replacement void* xmalloc (size_t) | |
1124 | ||
1125 | Allocate memory without fail. If @code{malloc} fails, this will print | |
fa9f0e33 DD |
1126 | a message to @code{stderr} (using the name set by |
1127 | @code{xmalloc_set_program_name}, | |
39423523 DD |
1128 | if any) and then call @code{xexit}. Note that it is therefore safe for |
1129 | a program to contain @code{#define malloc xmalloc} in its source. | |
1130 | ||
1131 | @end deftypefn | |
1132 | ||
fa9f0e33 | 1133 | @c xmalloc.c:53 |
39423523 DD |
1134 | @deftypefn Replacement void xmalloc_failed (size_t) |
1135 | ||
1136 | This function is not meant to be called by client code, and is listed | |
1137 | here for completeness only. If any of the allocation routines fail, this | |
1138 | function will be called to print an error message and terminate execution. | |
1139 | ||
1140 | @end deftypefn | |
1141 | ||
fa9f0e33 | 1142 | @c xmalloc.c:46 |
39423523 DD |
1143 | @deftypefn Replacement void xmalloc_set_program_name (const char *@var{name}) |
1144 | ||
1145 | You can use this to set the name of the program used by | |
1146 | @code{xmalloc_failed} when printing a failure message. | |
1147 | ||
1148 | @end deftypefn | |
1149 | ||
1150 | @c xmemdup.c:7 | |
1151 | @deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size}) | |
1152 | ||
1153 | Duplicates a region of memory without fail. First, @var{alloc_size} bytes | |
1154 | are allocated, then @var{copy_size} bytes from @var{input} are copied into | |
1155 | it, and the new memory is returned. If fewer bytes are copied than were | |
1156 | allocated, the remaining memory is zeroed. | |
1157 | ||
1158 | @end deftypefn | |
1159 | ||
fa9f0e33 | 1160 | @c xmalloc.c:32 |
99b58139 | 1161 | @deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size}) |
39423523 DD |
1162 | Reallocate memory without fail. This routine functions like @code{realloc}, |
1163 | but will behave the same as @code{xmalloc} if memory cannot be found. | |
1164 | ||
1165 | @end deftypefn | |
1166 | ||
1167 | @c xstrdup.c:7 | |
1168 | @deftypefn Replacement char* xstrdup (const char *@var{s}) | |
1169 | ||
1170 | Duplicates a character string without fail, using @code{xmalloc} to | |
1171 | obtain memory. | |
1172 | ||
1173 | @end deftypefn | |
1174 | ||
1175 | @c xstrerror.c:7 | |
1176 | @deftypefn Replacement char* xstrerror (int @var{errnum}) | |
1177 | ||
1178 | Behaves exactly like the standard @code{strerror} function, but | |
99b58139 | 1179 | will never return a @code{NULL} pointer. |
39423523 DD |
1180 | |
1181 | @end deftypefn | |
1182 | ||
0fad4bdb DD |
1183 | @c xstrndup.c:23 |
1184 | @deftypefn Replacement char* xstrndup (const char *@var{s}, size_t @var{n}) | |
1185 | ||
1186 | Returns a pointer to a copy of @var{s} with at most @var{n} characters | |
1187 | without fail, using @code{xmalloc} to obtain memory. The result is | |
1188 | always NUL terminated. | |
1189 | ||
1190 | @end deftypefn | |
1191 | ||
39423523 | 1192 |