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, | |
cf89a94a | 4 | @c run 'make stamp-functions' and gather-docs will build a new copy. |
39423523 | 5 | |
219a461e | 6 | @c splay-tree.c:277 |
70ecf948 DD |
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 | |
219a461e DD |
27 | @deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc |
28 | (splay_tree_compare_fn @var{compare_fn}, | |
29 | splay_tree_delete_key_fn @var{delete_key_fn}, | |
30 | splay_tree_delete_value_fn @var{delete_value_fn}, | |
31 | splay_tree_allocate_fn @var{tree_allocate_fn}, | |
32 | splay_tree_allocate_fn @var{node_allocate_fn}, | |
33 | splay_tree_deallocate_fn @var{deallocate_fn}, | |
34 | void * @var{allocate_data}) | |
35 | ||
36 | This function creates a splay tree that uses two different allocators | |
37 | @var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the | |
38 | tree itself and its nodes respectively. This is useful when variables of | |
39 | different types need to be allocated with different allocators. | |
40 | ||
41 | The splay tree will use @var{compare_fn} to compare nodes, | |
42 | @var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to | |
43 | deallocate values. | |
44 | ||
45 | @end deftypefn | |
70ecf948 | 46 | |
39423523 | 47 | @c alloca.c:26 |
99b58139 | 48 | @deftypefn Replacement void* alloca (size_t @var{size}) |
39423523 DD |
49 | |
50 | This function allocates memory which will be automatically reclaimed | |
51 | after the procedure exits. The @libib{} implementation does not free | |
52 | the memory immediately but will do so eventually during subsequent | |
53 | calls to this function. Memory is allocated using @code{xmalloc} under | |
54 | normal circumstances. | |
55 | ||
56 | The header file @file{alloca-conf.h} can be used in conjunction with the | |
57 | GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make | |
58 | available this function. The @code{AC_FUNC_ALLOCA} test requires that | |
59 | client code use a block of preprocessor code to be safe (see the Autoconf | |
60 | manual for more); this header incorporates that logic and more, including | |
99b58139 | 61 | the possibility of a GCC built-in function. |
39423523 DD |
62 | |
63 | @end deftypefn | |
64 | ||
c631edf1 | 65 | @c asprintf.c:32 |
5d852400 | 66 | @deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...) |
ba19b94f DD |
67 | |
68 | Like @code{sprintf}, but instead of passing a pointer to a buffer, you | |
69 | pass a pointer to a pointer. This function will compute the size of | |
70 | the buffer needed, allocate memory with @code{malloc}, and store a | |
71 | pointer to the allocated memory in @code{*@var{resptr}}. The value | |
72 | returned is the same as @code{sprintf} would return. If memory could | |
5a4e47bd | 73 | not be allocated, minus one is returned and @code{NULL} is stored in |
ba19b94f DD |
74 | @code{*@var{resptr}}. |
75 | ||
76 | @end deftypefn | |
77 | ||
39423523 DD |
78 | @c atexit.c:6 |
79 | @deftypefn Supplemental int atexit (void (*@var{f})()) | |
80 | ||
81 | Causes function @var{f} to be called at exit. Returns 0. | |
82 | ||
83 | @end deftypefn | |
84 | ||
85 | @c basename.c:6 | |
86 | @deftypefn Supplemental char* basename (const char *@var{name}) | |
87 | ||
88 | Returns a pointer to the last component of pathname @var{name}. | |
89 | Behavior is undefined if the pathname ends in a directory separator. | |
90 | ||
91 | @end deftypefn | |
92 | ||
93 | @c bcmp.c:6 | |
94 | @deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count}) | |
95 | ||
96 | Compares the first @var{count} bytes of two areas of memory. Returns | |
56056af5 DD |
97 | zero if they are the same, nonzero otherwise. Returns zero if |
98 | @var{count} is zero. A nonzero result only indicates a difference, | |
39423523 DD |
99 | it does not indicate any sorting order (say, by having a positive |
100 | result mean @var{x} sorts before @var{y}). | |
101 | ||
102 | @end deftypefn | |
103 | ||
104 | @c bcopy.c:3 | |
105 | @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length}) | |
106 | ||
107 | Copies @var{length} bytes from memory region @var{in} to region | |
108 | @var{out}. The use of @code{bcopy} is deprecated in new programs. | |
109 | ||
110 | @end deftypefn | |
111 | ||
112 | @c bsearch.c:33 | |
113 | @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 *)) | |
114 | ||
115 | Performs a search over an array of @var{nmemb} elements pointed to by | |
116 | @var{base} for a member that matches the object pointed to by @var{key}. | |
117 | The size of each member is specified by @var{size}. The array contents | |
118 | should be sorted in ascending order according to the @var{compar} | |
119 | comparison function. This routine should take two arguments pointing to | |
120 | the @var{key} and to an array member, in that order, and should return an | |
121 | integer less than, equal to, or greater than zero if the @var{key} object | |
fa9f0e33 | 122 | is respectively less than, matching, or greater than the array member. |
39423523 DD |
123 | |
124 | @end deftypefn | |
125 | ||
cf89a94a | 126 | @c argv.c:142 |
ba19b94f DD |
127 | @deftypefn Extension char** buildargv (char *@var{sp}) |
128 | ||
129 | Given a pointer to a string, parse the string extracting fields | |
130 | separated by whitespace and optionally enclosed within either single | |
131 | or double quotes (which are stripped off), and build a vector of | |
132 | pointers to copies of the string for each field. The input string | |
133 | remains unchanged. The last element of the vector is followed by a | |
134 | @code{NULL} element. | |
135 | ||
136 | All of the memory for the pointer array and copies of the string | |
137 | is obtained from @code{malloc}. All of the memory can be returned to the | |
138 | system with the single function call @code{freeargv}, which takes the | |
139 | returned result of @code{buildargv}, as it's argument. | |
140 | ||
5d852400 | 141 | Returns a pointer to the argument vector if successful. Returns |
ba19b94f DD |
142 | @code{NULL} if @var{sp} is @code{NULL} or if there is insufficient |
143 | memory to complete building the argument vector. | |
144 | ||
145 | If the input is a null string (as opposed to a @code{NULL} pointer), | |
146 | then buildarg returns an argument vector that has one arg, a null | |
147 | string. | |
148 | ||
149 | @end deftypefn | |
150 | ||
39423523 DD |
151 | @c bzero.c:6 |
152 | @deftypefn Supplemental void bzero (char *@var{mem}, int @var{count}) | |
153 | ||
fa9f0e33 | 154 | Zeros @var{count} bytes starting at @var{mem}. Use of this function |
39423523 DD |
155 | is deprecated in favor of @code{memset}. |
156 | ||
157 | @end deftypefn | |
158 | ||
159 | @c calloc.c:6 | |
160 | @deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize}) | |
161 | ||
162 | Uses @code{malloc} to allocate storage for @var{nelem} objects of | |
163 | @var{elsize} bytes each, then zeros the memory. | |
164 | ||
165 | @end deftypefn | |
166 | ||
cf89a94a | 167 | @c choose-temp.c:46 |
5d852400 | 168 | @deftypefn Extension char* choose_temp_base (void) |
ba19b94f DD |
169 | |
170 | Return a prefix for temporary file names or @code{NULL} if unable to | |
171 | find one. The current directory is chosen if all else fails so the | |
172 | program is exited if a temporary directory can't be found (@code{mktemp} | |
173 | fails). The buffer for the result is obtained with @code{xmalloc}. | |
174 | ||
6dd7f013 | 175 | This function is provided for backwards compatibility only. Its use is |
ba19b94f DD |
176 | not recommended. |
177 | ||
178 | @end deftypefn | |
179 | ||
10e1b6bb | 180 | @c make-temp-file.c:95 |
ba19b94f DD |
181 | @deftypefn Replacement char* choose_tmpdir () |
182 | ||
183 | Returns a pointer to a directory path suitable for creating temporary | |
184 | files in. | |
185 | ||
186 | @end deftypefn | |
187 | ||
39423523 | 188 | @c clock.c:27 |
99b58139 | 189 | @deftypefn Supplemental long clock (void) |
39423523 DD |
190 | |
191 | Returns an approximation of the CPU time used by the process as a | |
192 | @code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the | |
193 | number of seconds used. | |
194 | ||
195 | @end deftypefn | |
196 | ||
ba19b94f | 197 | @c concat.c:24 |
5d852400 | 198 | @deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL}) |
ba19b94f DD |
199 | |
200 | Concatenate zero or more of strings and return the result in freshly | |
5d852400 | 201 | @code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is |
ba19b94f DD |
202 | available. The argument list is terminated by the first @code{NULL} |
203 | pointer encountered. Pointers to empty strings are ignored. | |
204 | ||
205 | @end deftypefn | |
206 | ||
6e881691 DD |
207 | @c crc32.c:141 |
208 | @deftypefn Extension unsigned int crc32 (const unsigned char *@var{buf}, int @var{len}, unsigned int @var{init}) | |
209 | ||
210 | Compute the 32-bit CRC of @var{buf} which has length @var{len}. The | |
211 | starting value is @var{init}; this may be used to compute the CRC of | |
212 | data split across multiple buffers by passing the return value of each | |
213 | call as the @var{init} parameter of the next. | |
214 | ||
215 | This is intended to match the CRC used by the @command{gdb} remote | |
216 | protocol for the @samp{qCRC} command. In order to get the same | |
217 | results as gdb for a block of data, you must pass the first CRC | |
218 | parameter as @code{0xffffffff}. | |
219 | ||
cf89a94a BE |
220 | This CRC can be specified as: |
221 | ||
222 | Width : 32 | |
223 | Poly : 0x04c11db7 | |
224 | Init : parameter, typically 0xffffffff | |
225 | RefIn : false | |
226 | RefOut : false | |
227 | XorOut : 0 | |
228 | ||
229 | This differs from the "standard" CRC-32 algorithm in that the values | |
230 | are not reflected, and there is no final XOR value. These differences | |
231 | make it easy to compose the values of multiple blocks. | |
232 | ||
6e881691 DD |
233 | @end deftypefn |
234 | ||
c631edf1 | 235 | @c argv.c:52 |
ba19b94f DD |
236 | @deftypefn Extension char** dupargv (char **@var{vector}) |
237 | ||
238 | Duplicate an argument vector. Simply scans through @var{vector}, | |
239 | duplicating each argument until the terminating @code{NULL} is found. | |
5d852400 | 240 | Returns a pointer to the argument vector if successful. Returns |
ba19b94f DD |
241 | @code{NULL} if there is insufficient memory to complete building the |
242 | argument vector. | |
243 | ||
244 | @end deftypefn | |
245 | ||
b5c3b3de | 246 | @c strerror.c:567 |
ba19b94f | 247 | @deftypefn Extension int errno_max (void) |
39423523 DD |
248 | |
249 | Returns the maximum @code{errno} value for which a corresponding | |
250 | symbolic name or message is available. Note that in the case where we | |
251 | use the @code{sys_errlist} supplied by the system, it is possible for | |
252 | there to be more symbolic names than messages, or vice versa. In | |
253 | fact, the manual page for @code{perror(3C)} explicitly warns that one | |
254 | should check the size of the table (@code{sys_nerr}) before indexing | |
255 | it, since new error codes may be added to the system before they are | |
256 | added to the table. Thus @code{sys_nerr} might be smaller than value | |
99b58139 | 257 | implied by the largest @code{errno} value defined in @code{<errno.h>}. |
39423523 DD |
258 | |
259 | We return the maximum value that can be used to obtain a meaningful | |
260 | symbolic name or message. | |
261 | ||
262 | @end deftypefn | |
263 | ||
cf89a94a | 264 | @c argv.c:361 |
9223c945 DD |
265 | @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) |
266 | ||
267 | The @var{argcp} and @code{argvp} arguments are pointers to the usual | |
268 | @code{argc} and @code{argv} arguments to @code{main}. This function | |
269 | looks for arguments that begin with the character @samp{@@}. Any such | |
270 | arguments are interpreted as ``response files''. The contents of the | |
271 | response file are interpreted as additional command line options. In | |
272 | particular, the file is separated into whitespace-separated strings; | |
273 | each such string is taken as a command-line option. The new options | |
274 | are inserted in place of the option naming the response file, and | |
275 | @code{*argcp} and @code{*argvp} will be updated. If the value of | |
276 | @code{*argvp} is modified by this function, then the new value has | |
277 | been dynamically allocated and can be deallocated by the caller with | |
278 | @code{freeargv}. However, most callers will simply call | |
279 | @code{expandargv} near the beginning of @code{main} and allow the | |
280 | operating system to free the memory when the program exits. | |
281 | ||
282 | @end deftypefn | |
283 | ||
ba19b94f DD |
284 | @c fdmatch.c:23 |
285 | @deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2}) | |
286 | ||
287 | Check to see if two open file descriptors refer to the same file. | |
288 | This is useful, for example, when we have an open file descriptor for | |
289 | an unnamed file, and the name of a file that we believe to correspond | |
290 | to that fd. This can happen when we are exec'd with an already open | |
291 | file (@code{stdout} for example) or from the SVR4 @file{/proc} calls | |
292 | that return open file descriptors for mapped address spaces. All we | |
293 | have to do is open the file by name and check the two file descriptors | |
294 | for a match, which is done by comparing major and minor device numbers | |
295 | and inode numbers. | |
296 | ||
297 | @end deftypefn | |
298 | ||
c631edf1 | 299 | @c fopen_unlocked.c:48 |
e9edcedc | 300 | @deftypefn Extension {FILE *} fdopen_unlocked (int @var{fildes}, const char * @var{mode}) |
ac119ae8 DD |
301 | |
302 | Opens and returns a @code{FILE} pointer via @code{fdopen}. If the | |
303 | operating system supports it, ensure that the stream is setup to avoid | |
304 | any multi-threaded locking. Otherwise return the @code{FILE} pointer | |
305 | unchanged. | |
306 | ||
307 | @end deftypefn | |
308 | ||
ba19b94f DD |
309 | @c ffs.c:3 |
310 | @deftypefn Supplemental int ffs (int @var{valu}) | |
311 | ||
5d852400 | 312 | Find the first (least significant) bit set in @var{valu}. Bits are |
ba19b94f DD |
313 | numbered from right to left, starting with bit 1 (corresponding to the |
314 | value 1). If @var{valu} is zero, zero is returned. | |
315 | ||
316 | @end deftypefn | |
317 | ||
acf3a813 | 318 | @c filename_cmp.c:32 |
9c577e89 DD |
319 | @deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2}) |
320 | ||
acf3a813 DD |
321 | Return zero if the two file names @var{s1} and @var{s2} are equivalent. |
322 | If not equivalent, the returned value is similar to what @code{strcmp} | |
323 | would return. In other words, it returns a negative value if @var{s1} | |
324 | is less than @var{s2}, or a positive value if @var{s2} is greater than | |
325 | @var{s2}. | |
9c577e89 | 326 | |
acf3a813 | 327 | This function does not normalize file names. As a result, this function |
9c577e89 DD |
328 | will treat filenames that are spelled differently as different even in |
329 | the case when the two filenames point to the same underlying file. | |
330 | However, it does handle the fact that on DOS-like file systems, forward | |
331 | and backward slashes are equal. | |
332 | ||
333 | @end deftypefn | |
334 | ||
ba19b94f DD |
335 | @c fnmatch.txh:1 |
336 | @deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags}) | |
337 | ||
338 | Matches @var{string} against @var{pattern}, returning zero if it | |
339 | matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the | |
340 | wildcards @code{?} to match any one character, @code{*} to match any | |
341 | zero or more characters, or a set of alternate characters in square | |
342 | brackets, like @samp{[a-gt8]}, which match one character (@code{a} | |
343 | through @code{g}, or @code{t}, or @code{8}, in this example) if that one | |
5d852400 | 344 | character is in the set. A set may be inverted (i.e., match anything |
ba19b94f DD |
345 | except what's in the set) by giving @code{^} or @code{!} as the first |
346 | character in the set. To include those characters in the set, list them | |
347 | as anything other than the first character of the set. To include a | |
348 | dash in the set, list it last in the set. A backslash character makes | |
349 | the following character not special, so for example you could match | |
350 | against a literal asterisk with @samp{\*}. To match a literal | |
351 | backslash, use @samp{\\}. | |
352 | ||
353 | @code{flags} controls various aspects of the matching process, and is a | |
354 | boolean OR of zero or more of the following values (defined in | |
5d852400 | 355 | @code{<fnmatch.h>}): |
ba19b94f DD |
356 | |
357 | @table @code | |
358 | ||
359 | @item FNM_PATHNAME | |
360 | @itemx FNM_FILE_NAME | |
361 | @var{string} is assumed to be a path name. No wildcard will ever match | |
362 | @code{/}. | |
363 | ||
364 | @item FNM_NOESCAPE | |
365 | Do not interpret backslashes as quoting the following special character. | |
366 | ||
367 | @item FNM_PERIOD | |
368 | A leading period (at the beginning of @var{string}, or if | |
369 | @code{FNM_PATHNAME} after a slash) is not matched by @code{*} or | |
370 | @code{?} but must be matched explicitly. | |
371 | ||
372 | @item FNM_LEADING_DIR | |
373 | Means that @var{string} also matches @var{pattern} if some initial part | |
374 | of @var{string} matches, and is followed by @code{/} and zero or more | |
375 | characters. For example, @samp{foo*} would match either @samp{foobar} | |
376 | or @samp{foobar/grill}. | |
377 | ||
378 | @item FNM_CASEFOLD | |
379 | Ignores case when performing the comparison. | |
380 | ||
381 | @end table | |
382 | ||
383 | @end deftypefn | |
384 | ||
c631edf1 | 385 | @c fopen_unlocked.c:39 |
e9edcedc | 386 | @deftypefn Extension {FILE *} fopen_unlocked (const char *@var{path}, const char * @var{mode}) |
ac119ae8 DD |
387 | |
388 | Opens and returns a @code{FILE} pointer via @code{fopen}. If the | |
389 | operating system supports it, ensure that the stream is setup to avoid | |
390 | any multi-threaded locking. Otherwise return the @code{FILE} pointer | |
391 | unchanged. | |
392 | ||
393 | @end deftypefn | |
394 | ||
c631edf1 | 395 | @c argv.c:97 |
ba19b94f DD |
396 | @deftypefn Extension void freeargv (char **@var{vector}) |
397 | ||
398 | Free an argument vector that was built using @code{buildargv}. Simply | |
399 | scans through @var{vector}, freeing the memory for each argument until | |
400 | the terminating @code{NULL} is found, and then frees @var{vector} | |
401 | itself. | |
402 | ||
403 | @end deftypefn | |
404 | ||
c631edf1 | 405 | @c fopen_unlocked.c:57 |
e9edcedc | 406 | @deftypefn Extension {FILE *} freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream}) |
ac119ae8 DD |
407 | |
408 | Opens and returns a @code{FILE} pointer via @code{freopen}. If the | |
409 | operating system supports it, ensure that the stream is setup to avoid | |
410 | any multi-threaded locking. Otherwise return the @code{FILE} pointer | |
411 | unchanged. | |
412 | ||
413 | @end deftypefn | |
414 | ||
2a80c0a4 | 415 | @c getruntime.c:82 |
5d852400 | 416 | @deftypefn Replacement long get_run_time (void) |
ba19b94f DD |
417 | |
418 | Returns the time used so far, in microseconds. If possible, this is | |
419 | the time used by this process, else it is the elapsed time since the | |
420 | process started. | |
421 | ||
422 | @end deftypefn | |
423 | ||
39423523 | 424 | @c getcwd.c:6 |
99b58139 | 425 | @deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len}) |
39423523 DD |
426 | |
427 | Copy the absolute pathname for the current working directory into | |
428 | @var{pathname}, which is assumed to point to a buffer of at least | |
429 | @var{len} bytes, and return a pointer to the buffer. If the current | |
430 | directory's path doesn't fit in @var{len} characters, the result is | |
99b58139 | 431 | @code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer, |
39423523 DD |
432 | @code{getcwd} will obtain @var{len} bytes of space using |
433 | @code{malloc}. | |
434 | ||
435 | @end deftypefn | |
436 | ||
437 | @c getpagesize.c:5 | |
99b58139 | 438 | @deftypefn Supplemental int getpagesize (void) |
39423523 DD |
439 | |
440 | Returns the number of bytes in a page of memory. This is the | |
441 | granularity of many of the system memory management routines. No | |
442 | guarantee is made as to whether or not it is the same as the basic | |
443 | memory management hardware page size. | |
444 | ||
445 | @end deftypefn | |
446 | ||
447 | @c getpwd.c:5 | |
99b58139 | 448 | @deftypefn Supplemental char* getpwd (void) |
39423523 DD |
449 | |
450 | Returns the current working directory. This implementation caches the | |
451 | result on the assumption that the process will not call @code{chdir} | |
452 | between calls to @code{getpwd}. | |
453 | ||
454 | @end deftypefn | |
455 | ||
0fad4bdb | 456 | @c gettimeofday.c:12 |
0e867e79 | 457 | @deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz}) |
0fad4bdb DD |
458 | |
459 | Writes the current time to @var{tp}. This implementation requires | |
460 | that @var{tz} be NULL. Returns 0 on success, -1 on failure. | |
461 | ||
462 | @end deftypefn | |
463 | ||
c631edf1 | 464 | @c hex.c:33 |
7dd4d42a DD |
465 | @deftypefn Extension void hex_init (void) |
466 | ||
467 | Initializes the array mapping the current character set to | |
468 | corresponding hex values. This function must be called before any | |
2a80c0a4 DD |
469 | call to @code{hex_p} or @code{hex_value}. If you fail to call it, a |
470 | default ASCII-based table will normally be used on ASCII systems. | |
7dd4d42a DD |
471 | |
472 | @end deftypefn | |
473 | ||
c631edf1 | 474 | @c hex.c:42 |
7dd4d42a DD |
475 | @deftypefn Extension int hex_p (int @var{c}) |
476 | ||
477 | Evaluates to non-zero if the given character is a valid hex character, | |
478 | or zero if it is not. Note that the value you pass will be cast to | |
479 | @code{unsigned char} within the macro. | |
480 | ||
481 | @end deftypefn | |
482 | ||
c631edf1 | 483 | @c hex.c:50 |
b5c3b3de | 484 | @deftypefn Extension {unsigned int} hex_value (int @var{c}) |
7dd4d42a DD |
485 | |
486 | Returns the numeric equivalent of the given character when interpreted | |
6dd7f013 | 487 | as a hexadecimal digit. The result is undefined if you pass an |
7dd4d42a DD |
488 | invalid hex digit. Note that the value you pass will be cast to |
489 | @code{unsigned char} within the macro. | |
490 | ||
e4f79046 JB |
491 | The @code{hex_value} macro returns @code{unsigned int}, rather than |
492 | signed @code{int}, to make it easier to use in parsing addresses from | |
493 | hex dump files: a signed @code{int} would be sign-extended when | |
494 | converted to a wider unsigned type --- like @code{bfd_vma}, on some | |
495 | systems. | |
496 | ||
7dd4d42a DD |
497 | @end deftypefn |
498 | ||
219a461e DD |
499 | @c hashtab.c:336 |
500 | @deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, | |
501 | htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, | |
502 | htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, | |
503 | htab_free @var{free_f}) | |
504 | ||
505 | This function creates a hash table that uses two different allocators | |
506 | @var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself | |
507 | and its entries respectively. This is useful when variables of different | |
508 | types need to be allocated with different allocators. | |
509 | ||
510 | The created hash table is slightly larger than @var{size} and it is | |
511 | initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}). | |
512 | The function returns the created hash table, or @code{NULL} if memory | |
513 | allocation fails. | |
514 | ||
515 | @end deftypefn | |
516 | ||
39423523 DD |
517 | @c index.c:5 |
518 | @deftypefn Supplemental char* index (char *@var{s}, int @var{c}) | |
519 | ||
fa9f0e33 | 520 | Returns a pointer to the first occurrence of the character @var{c} in |
99b58139 | 521 | the string @var{s}, or @code{NULL} if not found. The use of @code{index} is |
39423523 DD |
522 | deprecated in new programs in favor of @code{strchr}. |
523 | ||
524 | @end deftypefn | |
525 | ||
ba19b94f DD |
526 | @c insque.c:6 |
527 | @deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred}) | |
528 | @deftypefnx Supplemental void remque (struct qelem *@var{elem}) | |
529 | ||
530 | Routines to manipulate queues built from doubly linked lists. The | |
531 | @code{insque} routine inserts @var{elem} in the queue immediately | |
532 | after @var{pred}. The @code{remque} routine removes @var{elem} from | |
533 | its containing queue. These routines expect to be passed pointers to | |
534 | structures which have as their first members a forward pointer and a | |
535 | back pointer, like this prototype (although no prototype is provided): | |
536 | ||
537 | @example | |
538 | struct qelem @{ | |
539 | struct qelem *q_forw; | |
540 | struct qelem *q_back; | |
541 | char q_data[]; | |
542 | @}; | |
543 | @end example | |
544 | ||
545 | @end deftypefn | |
546 | ||
b109e79a | 547 | @c safe-ctype.c:46 |
70ecf948 DD |
548 | @deffn Extension ISALPHA (@var{c}) |
549 | @deffnx Extension ISALNUM (@var{c}) | |
550 | @deffnx Extension ISBLANK (@var{c}) | |
551 | @deffnx Extension ISCNTRL (@var{c}) | |
552 | @deffnx Extension ISDIGIT (@var{c}) | |
553 | @deffnx Extension ISGRAPH (@var{c}) | |
554 | @deffnx Extension ISLOWER (@var{c}) | |
555 | @deffnx Extension ISPRINT (@var{c}) | |
556 | @deffnx Extension ISPUNCT (@var{c}) | |
557 | @deffnx Extension ISSPACE (@var{c}) | |
558 | @deffnx Extension ISUPPER (@var{c}) | |
559 | @deffnx Extension ISXDIGIT (@var{c}) | |
560 | ||
561 | These twelve macros are defined by @file{safe-ctype.h}. Each has the | |
562 | same meaning as the corresponding macro (with name in lowercase) | |
563 | defined by the standard header @file{ctype.h}. For example, | |
564 | @code{ISALPHA} returns true for alphabetic characters and false for | |
565 | others. However, there are two differences between these macros and | |
566 | those provided by @file{ctype.h}: | |
567 | ||
568 | @itemize @bullet | |
569 | @item These macros are guaranteed to have well-defined behavior for all | |
570 | values representable by @code{signed char} and @code{unsigned char}, and | |
571 | for @code{EOF}. | |
572 | ||
573 | @item These macros ignore the current locale; they are true for these | |
574 | fixed sets of characters: | |
575 | @multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada} | |
576 | @item @code{ALPHA} @tab @kbd{A-Za-z} | |
577 | @item @code{ALNUM} @tab @kbd{A-Za-z0-9} | |
578 | @item @code{BLANK} @tab @kbd{space tab} | |
579 | @item @code{CNTRL} @tab @code{!PRINT} | |
580 | @item @code{DIGIT} @tab @kbd{0-9} | |
581 | @item @code{GRAPH} @tab @code{ALNUM || PUNCT} | |
582 | @item @code{LOWER} @tab @kbd{a-z} | |
583 | @item @code{PRINT} @tab @code{GRAPH ||} @kbd{space} | |
584 | @item @code{PUNCT} @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?} | |
585 | @item @code{SPACE} @tab @kbd{space tab \n \r \f \v} | |
586 | @item @code{UPPER} @tab @kbd{A-Z} | |
587 | @item @code{XDIGIT} @tab @kbd{0-9A-Fa-f} | |
588 | @end multitable | |
589 | ||
590 | Note that, if the host character set is ASCII or a superset thereof, | |
591 | all these macros will return false for all values of @code{char} outside | |
592 | the range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return | |
593 | false for characters with numeric values from 128 to 255. | |
594 | @end itemize | |
595 | @end deffn | |
596 | ||
b109e79a | 597 | @c safe-ctype.c:95 |
70ecf948 DD |
598 | @deffn Extension ISIDNUM (@var{c}) |
599 | @deffnx Extension ISIDST (@var{c}) | |
600 | @deffnx Extension IS_VSPACE (@var{c}) | |
601 | @deffnx Extension IS_NVSPACE (@var{c}) | |
602 | @deffnx Extension IS_SPACE_OR_NUL (@var{c}) | |
603 | @deffnx Extension IS_ISOBASIC (@var{c}) | |
604 | These six macros are defined by @file{safe-ctype.h} and provide | |
605 | additional character classes which are useful when doing lexical | |
606 | analysis of C or similar languages. They are true for the following | |
607 | sets of characters: | |
608 | ||
609 | @multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada} | |
610 | @item @code{IDNUM} @tab @kbd{A-Za-z0-9_} | |
611 | @item @code{IDST} @tab @kbd{A-Za-z_} | |
612 | @item @code{VSPACE} @tab @kbd{\r \n} | |
613 | @item @code{NVSPACE} @tab @kbd{space tab \f \v \0} | |
614 | @item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE} | |
615 | @item @code{ISOBASIC} @tab @code{VSPACE || NVSPACE || PRINT} | |
616 | @end multitable | |
617 | @end deffn | |
618 | ||
ba19b94f DD |
619 | @c lbasename.c:23 |
620 | @deftypefn Replacement {const char*} lbasename (const char *@var{name}) | |
621 | ||
622 | Given a pointer to a string containing a typical pathname | |
623 | (@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the | |
624 | last component of the pathname (@samp{ls.c} in this case). The | |
625 | returned pointer is guaranteed to lie within the original | |
626 | string. This latter fact is not true of many vendor C | |
627 | libraries, which return special strings or modify the passed | |
628 | strings for particular input. | |
629 | ||
630 | In particular, the empty string returns the same empty string, | |
631 | and a path ending in @code{/} returns the empty string after it. | |
632 | ||
633 | @end deftypefn | |
634 | ||
ba61a412 DJ |
635 | @c lrealpath.c:25 |
636 | @deftypefn Replacement {const char*} lrealpath (const char *@var{name}) | |
637 | ||
638 | Given a pointer to a string containing a pathname, returns a canonical | |
639 | version of the filename. Symlinks will be resolved, and ``.'' and ``..'' | |
640 | components will be simplified. The returned value will be allocated using | |
10b57b38 | 641 | @code{malloc}, or @code{NULL} will be returned on a memory allocation error. |
2a80c0a4 | 642 | |
ba61a412 | 643 | @end deftypefn |
2a80c0a4 | 644 | |
ba61a412 DJ |
645 | @c make-relative-prefix.c:24 |
646 | @deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, const char *@var{bin_prefix}, const char *@var{prefix}) | |
2a80c0a4 | 647 | |
ba61a412 DJ |
648 | Given three paths @var{progname}, @var{bin_prefix}, @var{prefix}, |
649 | return the path that is in the same position relative to | |
650 | @var{progname}'s directory as @var{prefix} is relative to | |
651 | @var{bin_prefix}. That is, a string starting with the directory | |
652 | portion of @var{progname}, followed by a relative pathname of the | |
653 | difference between @var{bin_prefix} and @var{prefix}. | |
654 | ||
655 | If @var{progname} does not contain any directory separators, | |
656 | @code{make_relative_prefix} will search @env{PATH} to find a program | |
657 | named @var{progname}. Also, if @var{progname} is a symbolic link, | |
658 | the symbolic link will be resolved. | |
659 | ||
660 | For example, if @var{bin_prefix} is @code{/alpha/beta/gamma/gcc/delta}, | |
661 | @var{prefix} is @code{/alpha/beta/gamma/omega/}, and @var{progname} is | |
662 | @code{/red/green/blue/gcc}, then this function will return | |
663 | @code{/red/green/blue/../../omega/}. | |
664 | ||
665 | The return value is normally allocated via @code{malloc}. If no | |
666 | relative prefix can be found, return @code{NULL}. | |
2a80c0a4 DD |
667 | |
668 | @end deftypefn | |
669 | ||
cf89a94a | 670 | @c make-temp-file.c:168 |
ba19b94f DD |
671 | @deftypefn Replacement char* make_temp_file (const char *@var{suffix}) |
672 | ||
673 | Return a temporary file name (as a string) or @code{NULL} if unable to | |
674 | create one. @var{suffix} is a suffix to append to the file name. The | |
5d852400 | 675 | string is @code{malloc}ed, and the temporary file has been created. |
ba19b94f DD |
676 | |
677 | @end deftypefn | |
678 | ||
39423523 DD |
679 | @c memchr.c:3 |
680 | @deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n}) | |
681 | ||
99b58139 | 682 | This function searches memory starting at @code{*@var{s}} for the |
39423523 DD |
683 | character @var{c}. The search only ends with the first occurrence of |
684 | @var{c}, or after @var{length} characters; in particular, a null | |
685 | character does not terminate the search. If the character @var{c} is | |
99b58139 DD |
686 | found within @var{length} characters of @code{*@var{s}}, a pointer |
687 | to the character is returned. If @var{c} is not found, then @code{NULL} is | |
39423523 DD |
688 | returned. |
689 | ||
690 | @end deftypefn | |
691 | ||
692 | @c memcmp.c:6 | |
693 | @deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count}) | |
694 | ||
695 | Compares the first @var{count} bytes of two areas of memory. Returns | |
696 | zero if they are the same, a value less than zero if @var{x} is | |
697 | lexically less than @var{y}, or a value greater than zero if @var{x} | |
698 | is lexically greater than @var{y}. Note that lexical order is determined | |
699 | as if comparing unsigned char arrays. | |
700 | ||
701 | @end deftypefn | |
702 | ||
703 | @c memcpy.c:6 | |
704 | @deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) | |
705 | ||
706 | Copies @var{length} bytes from memory region @var{in} to region | |
707 | @var{out}. Returns a pointer to @var{out}. | |
708 | ||
709 | @end deftypefn | |
710 | ||
10e1b6bb DD |
711 | @c memmem.c:20 |
712 | @deftypefn Supplemental void* memmem (const void *@var{haystack}, size_t @var{haystack_len} const void *@var{needle}, size_t @var{needle_len}) | |
713 | ||
714 | Returns a pointer to the first occurrence of @var{needle} (length | |
715 | @var{needle_len}) in @var{haystack} (length @var{haystack_len}). | |
716 | Returns @code{NULL} if not found. | |
717 | ||
718 | @end deftypefn | |
719 | ||
39423523 DD |
720 | @c memmove.c:6 |
721 | @deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count}) | |
722 | ||
723 | Copies @var{count} bytes from memory area @var{from} to memory area | |
724 | @var{to}, returning a pointer to @var{to}. | |
725 | ||
726 | @end deftypefn | |
727 | ||
10b57b38 DD |
728 | @c mempcpy.c:23 |
729 | @deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) | |
730 | ||
731 | Copies @var{length} bytes from memory region @var{in} to region | |
732 | @var{out}. Returns a pointer to @var{out} + @var{length}. | |
733 | ||
734 | @end deftypefn | |
735 | ||
39423523 DD |
736 | @c memset.c:6 |
737 | @deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count}) | |
738 | ||
739 | Sets the first @var{count} bytes of @var{s} to the constant byte | |
740 | @var{c}, returning a pointer to @var{s}. | |
741 | ||
742 | @end deftypefn | |
743 | ||
53d7966f | 744 | @c mkstemps.c:58 |
67f3cb05 | 745 | @deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len}) |
ba19b94f | 746 | |
67f3cb05 GK |
747 | Generate a unique temporary file name from @var{pattern}. |
748 | @var{pattern} has the form: | |
ba19b94f DD |
749 | |
750 | @example | |
5d852400 | 751 | @var{path}/ccXXXXXX@var{suffix} |
ba19b94f DD |
752 | @end example |
753 | ||
5d852400 | 754 | @var{suffix_len} tells us how long @var{suffix} is (it can be zero |
67f3cb05 | 755 | length). The last six characters of @var{pattern} before @var{suffix} |
5d852400 | 756 | must be @samp{XXXXXX}; they are replaced with a string that makes the |
ba19b94f DD |
757 | filename unique. Returns a file descriptor open on the file for |
758 | reading and writing. | |
759 | ||
760 | @end deftypefn | |
761 | ||
53d7966f | 762 | @c pexecute.txh:266 |
b109e79a | 763 | @deftypefn Extension void pex_free (struct pex_obj @var{obj}) |
ba19b94f | 764 | |
f562800d DD |
765 | Clean up and free all data associated with @var{obj}. If you have not |
766 | yet called @code{pex_get_times} or @code{pex_get_status}, this will | |
767 | try to kill the subprocesses. | |
ba19b94f | 768 | |
b109e79a | 769 | @end deftypefn |
ba19b94f | 770 | |
53d7966f | 771 | @c pexecute.txh:241 |
b109e79a | 772 | @deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, int @var{count}, int *@var{vector}) |
ba19b94f | 773 | |
b109e79a ILT |
774 | Returns the exit status of all programs run using @var{obj}. |
775 | @var{count} is the number of results expected. The results will be | |
776 | placed into @var{vector}. The results are in the order of the calls | |
777 | to @code{pex_run}. Returns 0 on error, 1 on success. | |
ba19b94f | 778 | |
b109e79a | 779 | @end deftypefn |
ba19b94f | 780 | |
53d7966f | 781 | @c pexecute.txh:250 |
b109e79a | 782 | @deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, int @var{count}, struct pex_time *@var{vector}) |
ba19b94f | 783 | |
b109e79a ILT |
784 | Returns the process execution times of all programs run using |
785 | @var{obj}. @var{count} is the number of results expected. The | |
786 | results will be placed into @var{vector}. The results are in the | |
787 | order of the calls to @code{pex_run}. Returns 0 on error, 1 on | |
788 | success. | |
ba19b94f | 789 | |
e9edcedc DD |
790 | @code{struct pex_time} has the following fields of the type |
791 | @code{unsigned long}: @code{user_seconds}, | |
b109e79a ILT |
792 | @code{user_microseconds}, @code{system_seconds}, |
793 | @code{system_microseconds}. On systems which do not support reporting | |
794 | process times, all the fields will be set to @code{0}. | |
ba19b94f DD |
795 | |
796 | @end deftypefn | |
797 | ||
3db2e6dd | 798 | @c pexecute.txh:2 |
e9edcedc DD |
799 | @deftypefn Extension {struct pex_obj *} pex_init (int @var{flags}, const char *@var{pname}, const char *@var{tempbase}) |
800 | ||
801 | Prepare to execute one or more programs, with standard output of each | |
802 | program fed to standard input of the next. This is a system | |
803 | independent interface to execute a pipeline. | |
804 | ||
805 | @var{flags} is a bitwise combination of the following: | |
806 | ||
807 | @table @code | |
808 | ||
809 | @vindex PEX_RECORD_TIMES | |
810 | @item PEX_RECORD_TIMES | |
811 | Record subprocess times if possible. | |
812 | ||
813 | @vindex PEX_USE_PIPES | |
814 | @item PEX_USE_PIPES | |
815 | Use pipes for communication between processes, if possible. | |
816 | ||
817 | @vindex PEX_SAVE_TEMPS | |
818 | @item PEX_SAVE_TEMPS | |
819 | Don't delete temporary files used for communication between | |
820 | processes. | |
821 | ||
822 | @end table | |
823 | ||
824 | @var{pname} is the name of program to be executed, used in error | |
825 | messages. @var{tempbase} is a base name to use for any required | |
826 | temporary files; it may be @code{NULL} to use a randomly chosen name. | |
827 | ||
828 | @end deftypefn | |
829 | ||
53d7966f | 830 | @c pexecute.txh:155 |
3db2e6dd DD |
831 | @deftypefn Extension {FILE *} pex_input_file (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{in_name}) |
832 | ||
833 | Return a stream for a temporary file to pass to the first program in | |
834 | the pipeline as input. | |
835 | ||
836 | The name of the input file is chosen according to the same rules | |
837 | @code{pex_run} uses to choose output file names, based on | |
838 | @var{in_name}, @var{obj} and the @code{PEX_SUFFIX} bit in @var{flags}. | |
839 | ||
840 | Don't call @code{fclose} on the returned stream; the first call to | |
841 | @code{pex_run} closes it automatically. | |
842 | ||
843 | If @var{flags} includes @code{PEX_BINARY_OUTPUT}, open the stream in | |
844 | binary mode; otherwise, open it in the default mode. Including | |
845 | @code{PEX_BINARY_OUTPUT} in @var{flags} has no effect on Unix. | |
846 | @end deftypefn | |
847 | ||
53d7966f | 848 | @c pexecute.txh:172 |
3db2e6dd DD |
849 | @deftypefn Extension {FILE *} pex_input_pipe (struct pex_obj *@var{obj}, int @var{binary}) |
850 | ||
851 | Return a stream @var{fp} for a pipe connected to the standard input of | |
852 | the first program in the pipeline; @var{fp} is opened for writing. | |
853 | You must have passed @code{PEX_USE_PIPES} to the @code{pex_init} call | |
854 | that returned @var{obj}. | |
855 | ||
856 | You must close @var{fp} using @code{fclose} yourself when you have | |
857 | finished writing data to the pipeline. | |
858 | ||
859 | The file descriptor underlying @var{fp} is marked not to be inherited | |
860 | by child processes. | |
861 | ||
862 | On systems that do not support pipes, this function returns | |
863 | @code{NULL}, and sets @code{errno} to @code{EINVAL}. If you would | |
864 | like to write code that is portable to all systems the @code{pex} | |
865 | functions support, consider using @code{pex_input_file} instead. | |
866 | ||
867 | There are two opportunities for deadlock using | |
868 | @code{pex_input_pipe}: | |
869 | ||
870 | @itemize @bullet | |
871 | @item | |
872 | Most systems' pipes can buffer only a fixed amount of data; a process | |
873 | that writes to a full pipe blocks. Thus, if you write to @file{fp} | |
874 | before starting the first process, you run the risk of blocking when | |
875 | there is no child process yet to read the data and allow you to | |
876 | continue. @code{pex_input_pipe} makes no promises about the | |
877 | size of the pipe's buffer, so if you need to write any data at all | |
878 | before starting the first process in the pipeline, consider using | |
879 | @code{pex_input_file} instead. | |
880 | ||
881 | @item | |
882 | Using @code{pex_input_pipe} and @code{pex_read_output} together | |
883 | may also cause deadlock. If the output pipe fills up, so that each | |
884 | program in the pipeline is waiting for the next to read more data, and | |
885 | you fill the input pipe by writing more data to @var{fp}, then there | |
886 | is no way to make progress: the only process that could read data from | |
887 | the output pipe is you, but you are blocked on the input pipe. | |
888 | ||
889 | @end itemize | |
890 | ||
891 | @end deftypefn | |
892 | ||
f562800d | 893 | @c pexecute.txh:274 |
e9edcedc DD |
894 | @deftypefn Extension {const char *} pex_one (int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, int *@var{status}, int *@var{err}) |
895 | ||
896 | An interface to permit the easy execution of a | |
897 | single program. The return value and most of the parameters are as | |
898 | for a call to @code{pex_run}. @var{flags} is restricted to a | |
899 | combination of @code{PEX_SEARCH}, @code{PEX_STDERR_TO_STDOUT}, and | |
900 | @code{PEX_BINARY_OUTPUT}. @var{outname} is interpreted as if | |
901 | @code{PEX_LAST} were set. On a successful return, @code{*@var{status}} will | |
902 | be set to the exit status of the program. | |
903 | ||
904 | @end deftypefn | |
905 | ||
53d7966f VP |
906 | @c pexecute.txh:228 |
907 | @deftypefn Extension {FILE *} pex_read_err (struct pex_obj *@var{obj}, int @var{binary}) | |
908 | ||
909 | Returns a @code{FILE} pointer which may be used to read the standard | |
910 | error of the last program in the pipeline. When this is used, | |
911 | @code{PEX_LAST} should not be used in a call to @code{pex_run}. After | |
912 | this is called, @code{pex_run} may no longer be called with the same | |
913 | @var{obj}. @var{binary} should be non-zero if the file should be | |
914 | opened in binary mode. Don't call @code{fclose} on the returned file; | |
915 | it will be closed by @code{pex_free}. | |
916 | ||
917 | @end deftypefn | |
918 | ||
919 | @c pexecute.txh:216 | |
e9edcedc | 920 | @deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, int @var{binary}) |
b109e79a ILT |
921 | |
922 | Returns a @code{FILE} pointer which may be used to read the standard | |
923 | output of the last program in the pipeline. When this is used, | |
924 | @code{PEX_LAST} should not be used in a call to @code{pex_run}. After | |
925 | this is called, @code{pex_run} may no longer be called with the same | |
926 | @var{obj}. @var{binary} should be non-zero if the file should be | |
927 | opened in binary mode. Don't call @code{fclose} on the returned file; | |
928 | it will be closed by @code{pex_free}. | |
929 | ||
930 | @end deftypefn | |
931 | ||
3db2e6dd | 932 | @c pexecute.txh:33 |
e9edcedc DD |
933 | @deftypefn Extension {const char *} pex_run (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{outname}, const char *@var{errname}, int *@var{err}) |
934 | ||
935 | Execute one program in a pipeline. On success this returns | |
936 | @code{NULL}. On failure it returns an error message, a statically | |
937 | allocated string. | |
938 | ||
939 | @var{obj} is returned by a previous call to @code{pex_init}. | |
940 | ||
941 | @var{flags} is a bitwise combination of the following: | |
942 | ||
943 | @table @code | |
944 | ||
945 | @vindex PEX_LAST | |
946 | @item PEX_LAST | |
947 | This must be set on the last program in the pipeline. In particular, | |
948 | it should be set when executing a single program. The standard output | |
949 | of the program will be sent to @var{outname}, or, if @var{outname} is | |
950 | @code{NULL}, to the standard output of the calling program. Do @emph{not} | |
951 | set this bit if you want to call @code{pex_read_output} | |
952 | (described below). After a call to @code{pex_run} with this bit set, | |
953 | @var{pex_run} may no longer be called with the same @var{obj}. | |
954 | ||
955 | @vindex PEX_SEARCH | |
956 | @item PEX_SEARCH | |
957 | Search for the program using the user's executable search path. | |
958 | ||
959 | @vindex PEX_SUFFIX | |
960 | @item PEX_SUFFIX | |
961 | @var{outname} is a suffix. See the description of @var{outname}, | |
962 | below. | |
963 | ||
964 | @vindex PEX_STDERR_TO_STDOUT | |
965 | @item PEX_STDERR_TO_STDOUT | |
966 | Send the program's standard error to standard output, if possible. | |
967 | ||
968 | @vindex PEX_BINARY_INPUT | |
969 | @vindex PEX_BINARY_OUTPUT | |
53d7966f | 970 | @vindex PEX_BINARY_ERROR |
e9edcedc DD |
971 | @item PEX_BINARY_INPUT |
972 | @itemx PEX_BINARY_OUTPUT | |
53d7966f VP |
973 | @itemx PEX_BINARY_ERROR |
974 | The standard input (output or error) of the program should be read (written) in | |
e9edcedc DD |
975 | binary mode rather than text mode. These flags are ignored on systems |
976 | which do not distinguish binary mode and text mode, such as Unix. For | |
977 | proper behavior these flags should match appropriately---a call to | |
978 | @code{pex_run} using @code{PEX_BINARY_OUTPUT} should be followed by a | |
979 | call using @code{PEX_BINARY_INPUT}. | |
53d7966f VP |
980 | |
981 | @vindex PEX_STDERR_TO_PIPE | |
982 | @item PEX_STDERR_TO_PIPE | |
983 | Send the program's standard error to a pipe, if possible. This flag | |
984 | cannot be specified together with @code{PEX_STDERR_TO_STDOUT}. This | |
985 | flag can be specified only on the last program in pipeline. | |
986 | ||
e9edcedc DD |
987 | @end table |
988 | ||
989 | @var{executable} is the program to execute. @var{argv} is the set of | |
990 | arguments to pass to the program; normally @code{@var{argv}[0]} will | |
991 | be a copy of @var{executable}. | |
992 | ||
993 | @var{outname} is used to set the name of the file to use for standard | |
994 | output. There are two cases in which no output file will be used: | |
995 | ||
996 | @enumerate | |
997 | @item | |
998 | if @code{PEX_LAST} is not set in @var{flags}, and @code{PEX_USE_PIPES} | |
999 | was set in the call to @code{pex_init}, and the system supports pipes | |
1000 | ||
1001 | @item | |
1002 | if @code{PEX_LAST} is set in @var{flags}, and @var{outname} is | |
1003 | @code{NULL} | |
1004 | @end enumerate | |
1005 | ||
1006 | @noindent | |
1007 | Otherwise the code will use a file to hold standard | |
1008 | output. If @code{PEX_LAST} is not set, this file is considered to be | |
1009 | a temporary file, and it will be removed when no longer needed, unless | |
1010 | @code{PEX_SAVE_TEMPS} was set in the call to @code{pex_init}. | |
1011 | ||
1012 | There are two cases to consider when setting the name of the file to | |
1013 | hold standard output. | |
1014 | ||
1015 | @enumerate | |
1016 | @item | |
1017 | @code{PEX_SUFFIX} is set in @var{flags}. In this case | |
1018 | @var{outname} may not be @code{NULL}. If the @var{tempbase} parameter | |
1019 | to @code{pex_init} was not @code{NULL}, then the output file name is | |
1020 | the concatenation of @var{tempbase} and @var{outname}. If | |
1021 | @var{tempbase} was @code{NULL}, then the output file name is a random | |
1022 | file name ending in @var{outname}. | |
1023 | ||
1024 | @item | |
1025 | @code{PEX_SUFFIX} was not set in @var{flags}. In this | |
1026 | case, if @var{outname} is not @code{NULL}, it is used as the output | |
1027 | file name. If @var{outname} is @code{NULL}, and @var{tempbase} was | |
1028 | not NULL, the output file name is randomly chosen using | |
1029 | @var{tempbase}. Otherwise the output file name is chosen completely | |
1030 | at random. | |
1031 | @end enumerate | |
1032 | ||
1033 | @var{errname} is the file name to use for standard error output. If | |
1034 | it is @code{NULL}, standard error is the same as the caller's. | |
1035 | Otherwise, standard error is written to the named file. | |
1036 | ||
1037 | On an error return, the code sets @code{*@var{err}} to an @code{errno} | |
1038 | value, or to 0 if there is no relevant @code{errno}. | |
1039 | ||
1040 | @end deftypefn | |
1041 | ||
53d7966f | 1042 | @c pexecute.txh:142 |
014a8caf DD |
1043 | @deftypefn Extension {const char *} pex_run_in_environment (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{executable}, char * const *@var{argv}, char * const *@var{env}, int @var{env_size}, const char *@var{outname}, const char *@var{errname}, int *@var{err}) |
1044 | ||
1045 | Execute one program in a pipeline, permitting the environment for the | |
1046 | program to be specified. Behaviour and parameters not listed below are | |
1047 | as for @code{pex_run}. | |
1048 | ||
1049 | @var{env} is the environment for the child process, specified as an array of | |
1050 | character pointers. Each element of the array should point to a string of the | |
1051 | form @code{VAR=VALUE}, with the exception of the last element that must be | |
1052 | @code{NULL}. | |
1053 | ||
1054 | @end deftypefn | |
1055 | ||
f562800d | 1056 | @c pexecute.txh:286 |
53d7966f | 1057 | @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 @var{flags}) |
b109e79a ILT |
1058 | |
1059 | This is the old interface to execute one or more programs. It is | |
1060 | still supported for compatibility purposes, but is no longer | |
1061 | documented. | |
1062 | ||
1063 | @end deftypefn | |
1064 | ||
f562800d | 1065 | @c strsignal.c:541 |
71f2e6f4 | 1066 | @deftypefn Supplemental void psignal (int @var{signo}, char *@var{message}) |
ba19b94f DD |
1067 | |
1068 | Print @var{message} to the standard error, followed by a colon, | |
1069 | followed by the description of the signal specified by @var{signo}, | |
1070 | followed by a newline. | |
1071 | ||
1072 | @end deftypefn | |
1073 | ||
39423523 DD |
1074 | @c putenv.c:21 |
1075 | @deftypefn Supplemental int putenv (const char *@var{string}) | |
1076 | ||
1077 | Uses @code{setenv} or @code{unsetenv} to put @var{string} into | |
1078 | the environment or remove it. If @var{string} is of the form | |
99b58139 | 1079 | @samp{name=value} the string is added; if no @samp{=} is present the |
39423523 DD |
1080 | name is unset/removed. |
1081 | ||
1082 | @end deftypefn | |
1083 | ||
f562800d | 1084 | @c pexecute.txh:294 |
ba19b94f DD |
1085 | @deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags}) |
1086 | ||
b109e79a | 1087 | Another part of the old execution interface. |
ba19b94f DD |
1088 | |
1089 | @end deftypefn | |
1090 | ||
1091 | @c random.c:39 | |
5d852400 | 1092 | @deftypefn Supplement {long int} random (void) |
ba19b94f DD |
1093 | @deftypefnx Supplement void srandom (unsigned int @var{seed}) |
1094 | @deftypefnx Supplement void* initstate (unsigned int @var{seed}, void *@var{arg_state}, unsigned long @var{n}) | |
1095 | @deftypefnx Supplement void* setstate (void *@var{arg_state}) | |
1096 | ||
1097 | Random number functions. @code{random} returns a random number in the | |
5d852400 | 1098 | range 0 to @code{LONG_MAX}. @code{srandom} initializes the random |
ba19b94f DD |
1099 | number generator to some starting point determined by @var{seed} |
1100 | (else, the values returned by @code{random} are always the same for each | |
5d852400 | 1101 | run of the program). @code{initstate} and @code{setstate} allow fine-grained |
ba19b94f DD |
1102 | control over the state of the random number generator. |
1103 | ||
1104 | @end deftypefn | |
1105 | ||
67f3cb05 | 1106 | @c concat.c:173 |
5d852400 | 1107 | @deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @dots{}, @code{NULL}) |
ba19b94f DD |
1108 | |
1109 | Same as @code{concat}, except that if @var{optr} is not @code{NULL} it | |
1110 | is freed after the string is created. This is intended to be useful | |
1111 | when you're extending an existing string or building up a string in a | |
1112 | loop: | |
1113 | ||
1114 | @example | |
1115 | str = reconcat (str, "pre-", str, NULL); | |
1116 | @end example | |
1117 | ||
1118 | @end deftypefn | |
1119 | ||
39423523 DD |
1120 | @c rename.c:6 |
1121 | @deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new}) | |
1122 | ||
1123 | Renames a file from @var{old} to @var{new}. If @var{new} already | |
1124 | exists, it is removed. | |
1125 | ||
1126 | @end deftypefn | |
1127 | ||
1128 | @c rindex.c:5 | |
1129 | @deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c}) | |
1130 | ||
fa9f0e33 | 1131 | Returns a pointer to the last occurrence of the character @var{c} in |
99b58139 | 1132 | the string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is |
39423523 DD |
1133 | deprecated in new programs in favor of @code{strrchr}. |
1134 | ||
1135 | @end deftypefn | |
1136 | ||
1137 | @c setenv.c:22 | |
1138 | @deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite}) | |
1139 | @deftypefnx Supplemental void unsetenv (const char *@var{name}) | |
1140 | ||
1141 | @code{setenv} adds @var{name} to the environment with value | |
1142 | @var{value}. If the name was already present in the environment, | |
56056af5 | 1143 | the new value will be stored only if @var{overwrite} is nonzero. |
39423523 DD |
1144 | The companion @code{unsetenv} function removes @var{name} from the |
1145 | environment. This implementation is not safe for multithreaded code. | |
1146 | ||
1147 | @end deftypefn | |
1148 | ||
b109e79a | 1149 | @c strsignal.c:348 |
5d852400 | 1150 | @deftypefn Extension int signo_max (void) |
ba19b94f DD |
1151 | |
1152 | Returns the maximum signal value for which a corresponding symbolic | |
1153 | name or message is available. Note that in the case where we use the | |
1154 | @code{sys_siglist} supplied by the system, it is possible for there to | |
1155 | be more symbolic names than messages, or vice versa. In fact, the | |
1156 | manual page for @code{psignal(3b)} explicitly warns that one should | |
1157 | check the size of the table (@code{NSIG}) before indexing it, since | |
1158 | new signal codes may be added to the system before they are added to | |
1159 | the table. Thus @code{NSIG} might be smaller than value implied by | |
1160 | the largest signo value defined in @code{<signal.h>}. | |
1161 | ||
1162 | We return the maximum value that can be used to obtain a meaningful | |
1163 | symbolic name or message. | |
1164 | ||
1165 | @end deftypefn | |
1166 | ||
39423523 DD |
1167 | @c sigsetmask.c:8 |
1168 | @deftypefn Supplemental int sigsetmask (int @var{set}) | |
1169 | ||
1170 | Sets the signal mask to the one provided in @var{set} and returns | |
1171 | the old mask (which, for libiberty's implementation, will always | |
1172 | be the value @code{1}). | |
1173 | ||
1174 | @end deftypefn | |
1175 | ||
2ed1e5cc DD |
1176 | @c snprintf.c:28 |
1177 | @deftypefn Supplemental int snprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, ...) | |
1178 | ||
6e881691 DD |
1179 | This function is similar to @code{sprintf}, but it will write to |
1180 | @var{buf} at most @code{@var{n}-1} bytes of text, followed by a | |
1181 | terminating null byte, for a total of @var{n} bytes. | |
1182 | On error the return value is -1, otherwise it returns the number of | |
1183 | bytes, not including the terminating null byte, that would have been | |
1184 | written had @var{n} been sufficiently large, regardless of the actual | |
1185 | value of @var{n}. Note some pre-C99 system libraries do not implement | |
1186 | this correctly so users cannot generally rely on the return value if | |
1187 | the system version of this function is used. | |
2ed1e5cc DD |
1188 | |
1189 | @end deftypefn | |
1190 | ||
ba19b94f DD |
1191 | @c spaces.c:22 |
1192 | @deftypefn Extension char* spaces (int @var{count}) | |
1193 | ||
1194 | Returns a pointer to a memory region filled with the specified | |
1195 | number of spaces and null terminated. The returned pointer is | |
1196 | valid until at least the next call. | |
1197 | ||
1198 | @end deftypefn | |
1199 | ||
10b57b38 DD |
1200 | @c stpcpy.c:23 |
1201 | @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) | |
1202 | ||
1203 | Copies the string @var{src} into @var{dst}. Returns a pointer to | |
1204 | @var{dst} + strlen(@var{src}). | |
1205 | ||
1206 | @end deftypefn | |
1207 | ||
1208 | @c stpncpy.c:23 | |
1209 | @deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len}) | |
1210 | ||
1211 | Copies the string @var{src} into @var{dst}, copying exactly @var{len} | |
1212 | and padding with zeros if necessary. If @var{len} < strlen(@var{src}) | |
1213 | then return @var{dst} + @var{len}, otherwise returns @var{dst} + | |
1214 | strlen(@var{src}). | |
1215 | ||
1216 | @end deftypefn | |
1217 | ||
39423523 DD |
1218 | @c strcasecmp.c:15 |
1219 | @deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) | |
1220 | ||
1221 | A case-insensitive @code{strcmp}. | |
1222 | ||
1223 | @end deftypefn | |
1224 | ||
1225 | @c strchr.c:6 | |
1226 | @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c}) | |
1227 | ||
fa9f0e33 | 1228 | Returns a pointer to the first occurrence of the character @var{c} in |
99b58139 | 1229 | the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the |
39423523 DD |
1230 | null character, the results are undefined. |
1231 | ||
1232 | @end deftypefn | |
1233 | ||
1234 | @c strdup.c:3 | |
1235 | @deftypefn Supplemental char* strdup (const char *@var{s}) | |
1236 | ||
1237 | Returns a pointer to a copy of @var{s} in memory obtained from | |
99b58139 | 1238 | @code{malloc}, or @code{NULL} if insufficient memory was available. |
39423523 DD |
1239 | |
1240 | @end deftypefn | |
1241 | ||
b109e79a | 1242 | @c strerror.c:670 |
ba19b94f | 1243 | @deftypefn Replacement {const char*} strerrno (int @var{errnum}) |
39423523 DD |
1244 | |
1245 | Given an error number returned from a system call (typically returned | |
1246 | in @code{errno}), returns a pointer to a string containing the | |
99b58139 | 1247 | symbolic name of that error number, as found in @code{<errno.h>}. |
39423523 DD |
1248 | |
1249 | If the supplied error number is within the valid range of indices for | |
1250 | symbolic names, but no name is available for the particular error | |
ba19b94f | 1251 | number, then returns the string @samp{Error @var{num}}, where @var{num} |
fa9f0e33 | 1252 | is the error number. |
39423523 DD |
1253 | |
1254 | If the supplied error number is not within the range of valid | |
99b58139 | 1255 | indices, then returns @code{NULL}. |
39423523 DD |
1256 | |
1257 | The contents of the location pointed to are only guaranteed to be | |
fa9f0e33 | 1258 | valid until the next call to @code{strerrno}. |
39423523 DD |
1259 | |
1260 | @end deftypefn | |
1261 | ||
b5c3b3de | 1262 | @c strerror.c:603 |
ba19b94f | 1263 | @deftypefn Supplemental char* strerror (int @var{errnoval}) |
39423523 DD |
1264 | |
1265 | Maps an @code{errno} number to an error message string, the contents | |
1266 | of which are implementation defined. On systems which have the | |
1267 | external variables @code{sys_nerr} and @code{sys_errlist}, these | |
1268 | strings will be the same as the ones used by @code{perror}. | |
1269 | ||
1270 | If the supplied error number is within the valid range of indices for | |
1271 | the @code{sys_errlist}, but no message is available for the particular | |
ba19b94f | 1272 | error number, then returns the string @samp{Error @var{num}}, where |
fa9f0e33 | 1273 | @var{num} is the error number. |
39423523 DD |
1274 | |
1275 | If the supplied error number is not a valid index into | |
99b58139 | 1276 | @code{sys_errlist}, returns @code{NULL}. |
39423523 DD |
1277 | |
1278 | The returned string is only guaranteed to be valid only until the | |
1279 | next call to @code{strerror}. | |
1280 | ||
1281 | @end deftypefn | |
1282 | ||
1283 | @c strncasecmp.c:15 | |
1284 | @deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2}) | |
1285 | ||
1286 | A case-insensitive @code{strncmp}. | |
1287 | ||
1288 | @end deftypefn | |
1289 | ||
1290 | @c strncmp.c:6 | |
1291 | @deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n}) | |
1292 | ||
1293 | Compares the first @var{n} bytes of two strings, returning a value as | |
1294 | @code{strcmp}. | |
1295 | ||
1296 | @end deftypefn | |
1297 | ||
0fad4bdb DD |
1298 | @c strndup.c:23 |
1299 | @deftypefn Extension char* strndup (const char *@var{s}, size_t @var{n}) | |
1300 | ||
1301 | Returns a pointer to a copy of @var{s} with at most @var{n} characters | |
1302 | in memory obtained from @code{malloc}, or @code{NULL} if insufficient | |
1303 | memory was available. The result is always NUL terminated. | |
1304 | ||
1305 | @end deftypefn | |
1306 | ||
39423523 DD |
1307 | @c strrchr.c:6 |
1308 | @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c}) | |
1309 | ||
fa9f0e33 | 1310 | Returns a pointer to the last occurrence of the character @var{c} in |
99b58139 | 1311 | the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the |
39423523 DD |
1312 | null character, the results are undefined. |
1313 | ||
1314 | @end deftypefn | |
1315 | ||
b109e79a | 1316 | @c strsignal.c:383 |
ba19b94f DD |
1317 | @deftypefn Supplemental {const char *} strsignal (int @var{signo}) |
1318 | ||
1319 | Maps an signal number to an signal message string, the contents of | |
1320 | which are implementation defined. On systems which have the external | |
1321 | variable @code{sys_siglist}, these strings will be the same as the | |
1322 | ones used by @code{psignal()}. | |
1323 | ||
1324 | If the supplied signal number is within the valid range of indices for | |
1325 | the @code{sys_siglist}, but no message is available for the particular | |
1326 | signal number, then returns the string @samp{Signal @var{num}}, where | |
1327 | @var{num} is the signal number. | |
1328 | ||
1329 | If the supplied signal number is not a valid index into | |
1330 | @code{sys_siglist}, returns @code{NULL}. | |
1331 | ||
1332 | The returned string is only guaranteed to be valid only until the next | |
1333 | call to @code{strsignal}. | |
1334 | ||
1335 | @end deftypefn | |
1336 | ||
f562800d | 1337 | @c strsignal.c:448 |
ba19b94f DD |
1338 | @deftypefn Extension {const char*} strsigno (int @var{signo}) |
1339 | ||
1340 | Given an signal number, returns a pointer to a string containing the | |
1341 | symbolic name of that signal number, as found in @code{<signal.h>}. | |
1342 | ||
1343 | If the supplied signal number is within the valid range of indices for | |
1344 | symbolic names, but no name is available for the particular signal | |
1345 | number, then returns the string @samp{Signal @var{num}}, where | |
1346 | @var{num} is the signal number. | |
1347 | ||
1348 | If the supplied signal number is not within the range of valid | |
1349 | indices, then returns @code{NULL}. | |
1350 | ||
1351 | The contents of the location pointed to are only guaranteed to be | |
1352 | valid until the next call to @code{strsigno}. | |
1353 | ||
1354 | @end deftypefn | |
1355 | ||
39423523 DD |
1356 | @c strstr.c:6 |
1357 | @deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub}) | |
1358 | ||
1359 | This function searches for the substring @var{sub} in the string | |
fa9f0e33 | 1360 | @var{string}, not including the terminating null characters. A pointer |
99b58139 | 1361 | to the first occurrence of @var{sub} is returned, or @code{NULL} if the |
39423523 DD |
1362 | substring is absent. If @var{sub} points to a string with zero |
1363 | length, the function returns @var{string}. | |
1364 | ||
1365 | @end deftypefn | |
1366 | ||
1367 | @c strtod.c:27 | |
1368 | @deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr}) | |
1369 | ||
56056af5 | 1370 | This ISO C function converts the initial portion of @var{string} to a |
99b58139 | 1371 | @code{double}. If @var{endptr} is not @code{NULL}, a pointer to the |
39423523 DD |
1372 | character after the last character used in the conversion is stored in |
1373 | the location referenced by @var{endptr}. If no conversion is | |
1374 | performed, zero is returned and the value of @var{string} is stored in | |
1375 | the location referenced by @var{endptr}. | |
1376 | ||
1377 | @end deftypefn | |
1378 | ||
b109e79a | 1379 | @c strerror.c:729 |
ba19b94f | 1380 | @deftypefn Extension int strtoerrno (const char *@var{name}) |
39423523 | 1381 | |
99b58139 | 1382 | Given the symbolic name of a error number (e.g., @code{EACCES}), map it |
39423523 DD |
1383 | to an errno value. If no translation is found, returns 0. |
1384 | ||
1385 | @end deftypefn | |
1386 | ||
1387 | @c strtol.c:33 | |
1388 | @deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base}) | |
ba19b94f | 1389 | @deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base}) |
39423523 DD |
1390 | |
1391 | The @code{strtol} function converts the string in @var{string} to a | |
1392 | long integer value according to the given @var{base}, which must be | |
1393 | between 2 and 36 inclusive, or be the special value 0. If @var{base} | |
1394 | is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x} | |
1395 | to indicate bases 8 and 16, respectively, else default to base 10. | |
1396 | When the base is 16 (either explicitly or implicitly), a prefix of | |
fa9f0e33 | 1397 | @code{0x} is allowed. The handling of @var{endptr} is as that of |
ba19b94f DD |
1398 | @code{strtod} above. The @code{strtoul} function is the same, except |
1399 | that the converted value is unsigned. | |
1400 | ||
1401 | @end deftypefn | |
1402 | ||
f562800d | 1403 | @c strsignal.c:502 |
ba19b94f DD |
1404 | @deftypefn Extension int strtosigno (const char *@var{name}) |
1405 | ||
1406 | Given the symbolic name of a signal, map it to a signal number. If no | |
1407 | translation is found, returns 0. | |
39423523 DD |
1408 | |
1409 | @end deftypefn | |
1410 | ||
9223c945 | 1411 | @c strverscmp.c:25 |
67f3cb05 GK |
1412 | @deftypefun int strverscmp (const char *@var{s1}, const char *@var{s2}) |
1413 | The @code{strverscmp} function compares the string @var{s1} against | |
1414 | @var{s2}, considering them as holding indices/version numbers. Return | |
1415 | value follows the same conventions as found in the @code{strverscmp} | |
1416 | function. In fact, if @var{s1} and @var{s2} contain no digits, | |
1417 | @code{strverscmp} behaves like @code{strcmp}. | |
1418 | ||
1419 | Basically, we compare strings normally (character by character), until | |
1420 | we find a digit in each string - then we enter a special comparison | |
1421 | mode, where each sequence of digits is taken as a whole. If we reach the | |
1422 | end of these two parts without noticing a difference, we return to the | |
1423 | standard comparison mode. There are two types of numeric parts: | |
1424 | "integral" and "fractional" (those begin with a '0'). The types | |
1425 | of the numeric parts affect the way we sort them: | |
1426 | ||
1427 | @itemize @bullet | |
1428 | @item | |
1429 | integral/integral: we compare values as you would expect. | |
1430 | ||
1431 | @item | |
1432 | fractional/integral: the fractional part is less than the integral one. | |
1433 | Again, no surprise. | |
1434 | ||
1435 | @item | |
1436 | fractional/fractional: the things become a bit more complex. | |
1437 | If the common prefix contains only leading zeroes, the longest part is less | |
1438 | than the other one; else the comparison behaves normally. | |
1439 | @end itemize | |
1440 | ||
1441 | @smallexample | |
1442 | strverscmp ("no digit", "no digit") | |
1443 | @result{} 0 // @r{same behavior as strcmp.} | |
1444 | strverscmp ("item#99", "item#100") | |
1445 | @result{} <0 // @r{same prefix, but 99 < 100.} | |
1446 | strverscmp ("alpha1", "alpha001") | |
1447 | @result{} >0 // @r{fractional part inferior to integral one.} | |
1448 | strverscmp ("part1_f012", "part1_f01") | |
1449 | @result{} >0 // @r{two fractional parts.} | |
1450 | strverscmp ("foo.009", "foo.0") | |
1451 | @result{} <0 // @r{idem, but with leading zeroes only.} | |
1452 | @end smallexample | |
1453 | ||
1454 | This function is especially useful when dealing with filename sorting, | |
1455 | because filenames frequently hold indices/version numbers. | |
1456 | @end deftypefun | |
1457 | ||
39423523 DD |
1458 | @c tmpnam.c:3 |
1459 | @deftypefn Supplemental char* tmpnam (char *@var{s}) | |
1460 | ||
1461 | This function attempts to create a name for a temporary file, which | |
1462 | will be a valid file name yet not exist when @code{tmpnam} checks for | |
1463 | it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes, | |
99b58139 | 1464 | or be @code{NULL}. Use of this function creates a security risk, and it must |
39423523 DD |
1465 | not be used in new projects. Use @code{mkstemp} instead. |
1466 | ||
1467 | @end deftypefn | |
1468 | ||
0fad4bdb DD |
1469 | @c unlink-if-ordinary.c:27 |
1470 | @deftypefn Supplemental int unlink_if_ordinary (const char*) | |
1471 | ||
1472 | Unlinks the named file, unless it is special (e.g. a device file). | |
1473 | Returns 0 when the file was unlinked, a negative value (and errno set) when | |
1474 | there was an error deleting the file, and a positive value if no attempt | |
1475 | was made to unlink the file because it is special. | |
1476 | ||
1477 | @end deftypefn | |
1478 | ||
c631edf1 DD |
1479 | @c fopen_unlocked.c:31 |
1480 | @deftypefn Extension void unlock_std_streams (void) | |
1481 | ||
1482 | If the OS supports it, ensure that the standard I/O streams, | |
1483 | @code{stdin}, @code{stdout} and @code{stderr} are setup to avoid any | |
1484 | multi-threaded locking. Otherwise do nothing. | |
1485 | ||
1486 | @end deftypefn | |
1487 | ||
7b6f6286 DD |
1488 | @c fopen_unlocked.c:23 |
1489 | @deftypefn Extension void unlock_stream (FILE * @var{stream}) | |
1490 | ||
1491 | If the OS supports it, ensure that the supplied stream is setup to | |
1492 | avoid any multi-threaded locking. Otherwise leave the @code{FILE} | |
1493 | pointer unchanged. If the @var{stream} is @code{NULL} do nothing. | |
1494 | ||
1495 | @end deftypefn | |
1496 | ||
b109e79a | 1497 | @c vasprintf.c:47 |
5d852400 | 1498 | @deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args}) |
ba19b94f DD |
1499 | |
1500 | Like @code{vsprintf}, but instead of passing a pointer to a buffer, | |
1501 | you pass a pointer to a pointer. This function will compute the size | |
1502 | of the buffer needed, allocate memory with @code{malloc}, and store a | |
1503 | pointer to the allocated memory in @code{*@var{resptr}}. The value | |
1504 | returned is the same as @code{vsprintf} would return. If memory could | |
5a4e47bd | 1505 | not be allocated, minus one is returned and @code{NULL} is stored in |
ba19b94f DD |
1506 | @code{*@var{resptr}}. |
1507 | ||
1508 | @end deftypefn | |
1509 | ||
39423523 | 1510 | @c vfork.c:6 |
99b58139 | 1511 | @deftypefn Supplemental int vfork (void) |
39423523 DD |
1512 | |
1513 | Emulates @code{vfork} by calling @code{fork} and returning its value. | |
1514 | ||
1515 | @end deftypefn | |
1516 | ||
1517 | @c vprintf.c:3 | |
1518 | @deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap}) | |
1519 | @deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap}) | |
1520 | @deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap}) | |
1521 | ||
1522 | These functions are the same as @code{printf}, @code{fprintf}, and | |
1523 | @code{sprintf}, respectively, except that they are called with a | |
1524 | @code{va_list} instead of a variable number of arguments. Note that | |
1525 | they do not call @code{va_end}; this is the application's | |
1526 | responsibility. In @libib{} they are implemented in terms of the | |
1527 | nonstandard but common function @code{_doprnt}. | |
1528 | ||
1529 | @end deftypefn | |
1530 | ||
2ed1e5cc DD |
1531 | @c vsnprintf.c:28 |
1532 | @deftypefn Supplemental int vsnprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, va_list @var{ap}) | |
1533 | ||
6e881691 DD |
1534 | This function is similar to @code{vsprintf}, but it will write to |
1535 | @var{buf} at most @code{@var{n}-1} bytes of text, followed by a | |
1536 | terminating null byte, for a total of @var{n} bytes. On error the | |
1537 | return value is -1, otherwise it returns the number of characters that | |
1538 | would have been printed had @var{n} been sufficiently large, | |
1539 | regardless of the actual value of @var{n}. Note some pre-C99 system | |
1540 | libraries do not implement this correctly so users cannot generally | |
1541 | rely on the return value if the system version of this function is | |
1542 | used. | |
2ed1e5cc DD |
1543 | |
1544 | @end deftypefn | |
1545 | ||
39423523 DD |
1546 | @c waitpid.c:3 |
1547 | @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int) | |
1548 | ||
1549 | This is a wrapper around the @code{wait} function. Any ``special'' | |
1550 | values of @var{pid} depend on your implementation of @code{wait}, as | |
1551 | does the return value. The third argument is unused in @libib{}. | |
1552 | ||
1553 | @end deftypefn | |
1554 | ||
cf89a94a | 1555 | @c argv.c:306 |
acf3a813 DD |
1556 | @deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file}) |
1557 | ||
1558 | Write each member of ARGV, handling all necessary quoting, to the file | |
1559 | named by FILE, separated by whitespace. Return 0 on success, non-zero | |
1560 | if an error occurred while writing to FILE. | |
1561 | ||
1562 | @end deftypefn | |
1563 | ||
39423523 DD |
1564 | @c xatexit.c:11 |
1565 | @deftypefun int xatexit (void (*@var{fn}) (void)) | |
1566 | ||
1567 | Behaves as the standard @code{atexit} function, but with no limit on | |
99b58139 | 1568 | the number of registered functions. Returns 0 on success, or @minus{}1 on |
39423523 DD |
1569 | failure. If you use @code{xatexit} to register functions, you must use |
1570 | @code{xexit} to terminate your program. | |
1571 | ||
1572 | @end deftypefun | |
1573 | ||
fa9f0e33 | 1574 | @c xmalloc.c:38 |
99b58139 | 1575 | @deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize}) |
39423523 DD |
1576 | |
1577 | Allocate memory without fail, and set it to zero. This routine functions | |
1578 | like @code{calloc}, but will behave the same as @code{xmalloc} if memory | |
1579 | cannot be found. | |
1580 | ||
1581 | @end deftypefn | |
1582 | ||
1583 | @c xexit.c:22 | |
1584 | @deftypefn Replacement void xexit (int @var{code}) | |
1585 | ||
1586 | Terminates the program. If any functions have been registered with | |
fa9f0e33 | 1587 | the @code{xatexit} replacement function, they will be called first. |
39423523 DD |
1588 | Termination is handled via the system's normal @code{exit} call. |
1589 | ||
1590 | @end deftypefn | |
1591 | ||
1592 | @c xmalloc.c:22 | |
1593 | @deftypefn Replacement void* xmalloc (size_t) | |
1594 | ||
1595 | Allocate memory without fail. If @code{malloc} fails, this will print | |
fa9f0e33 DD |
1596 | a message to @code{stderr} (using the name set by |
1597 | @code{xmalloc_set_program_name}, | |
39423523 DD |
1598 | if any) and then call @code{xexit}. Note that it is therefore safe for |
1599 | a program to contain @code{#define malloc xmalloc} in its source. | |
1600 | ||
1601 | @end deftypefn | |
1602 | ||
fa9f0e33 | 1603 | @c xmalloc.c:53 |
39423523 DD |
1604 | @deftypefn Replacement void xmalloc_failed (size_t) |
1605 | ||
1606 | This function is not meant to be called by client code, and is listed | |
1607 | here for completeness only. If any of the allocation routines fail, this | |
1608 | function will be called to print an error message and terminate execution. | |
1609 | ||
1610 | @end deftypefn | |
1611 | ||
fa9f0e33 | 1612 | @c xmalloc.c:46 |
39423523 DD |
1613 | @deftypefn Replacement void xmalloc_set_program_name (const char *@var{name}) |
1614 | ||
1615 | You can use this to set the name of the program used by | |
1616 | @code{xmalloc_failed} when printing a failure message. | |
1617 | ||
1618 | @end deftypefn | |
1619 | ||
1620 | @c xmemdup.c:7 | |
1621 | @deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size}) | |
1622 | ||
1623 | Duplicates a region of memory without fail. First, @var{alloc_size} bytes | |
1624 | are allocated, then @var{copy_size} bytes from @var{input} are copied into | |
1625 | it, and the new memory is returned. If fewer bytes are copied than were | |
1626 | allocated, the remaining memory is zeroed. | |
1627 | ||
1628 | @end deftypefn | |
1629 | ||
fa9f0e33 | 1630 | @c xmalloc.c:32 |
99b58139 | 1631 | @deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size}) |
39423523 DD |
1632 | Reallocate memory without fail. This routine functions like @code{realloc}, |
1633 | but will behave the same as @code{xmalloc} if memory cannot be found. | |
1634 | ||
1635 | @end deftypefn | |
1636 | ||
1637 | @c xstrdup.c:7 | |
1638 | @deftypefn Replacement char* xstrdup (const char *@var{s}) | |
1639 | ||
1640 | Duplicates a character string without fail, using @code{xmalloc} to | |
1641 | obtain memory. | |
1642 | ||
1643 | @end deftypefn | |
1644 | ||
1645 | @c xstrerror.c:7 | |
1646 | @deftypefn Replacement char* xstrerror (int @var{errnum}) | |
1647 | ||
1648 | Behaves exactly like the standard @code{strerror} function, but | |
99b58139 | 1649 | will never return a @code{NULL} pointer. |
39423523 DD |
1650 | |
1651 | @end deftypefn | |
1652 | ||
0fad4bdb DD |
1653 | @c xstrndup.c:23 |
1654 | @deftypefn Replacement char* xstrndup (const char *@var{s}, size_t @var{n}) | |
1655 | ||
1656 | Returns a pointer to a copy of @var{s} with at most @var{n} characters | |
1657 | without fail, using @code{xmalloc} to obtain memory. The result is | |
1658 | always NUL terminated. | |
1659 | ||
1660 | @end deftypefn | |
1661 | ||
39423523 | 1662 |