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