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