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