19588ddcfSespie@c Automatically generated from *.c and others (the comments before 29588ddcfSespie@c each entry tell you which file and where in that file). DO NOT EDIT! 39588ddcfSespie@c Edit the *.c files, configure with --enable-maintainer-mode, 49588ddcfSespie@c and let gather-docs build you a new copy. 59588ddcfSespie 6*150b7e42Smiod@c safe-ctype.c:25 7*150b7e42Smiod@defvr Extension HOST_CHARSET 8*150b7e42SmiodThis macro indicates the basic character set and encoding used by the 9*150b7e42Smiodhost: more precisely, the encoding used for character constants in 10*150b7e42Smiodpreprocessor @samp{#if} statements (the C "execution character set"). 11*150b7e42SmiodIt is defined by @file{safe-ctype.h}, and will be an integer constant 12*150b7e42Smiodwith one of the following values: 13*150b7e42Smiod 14*150b7e42Smiod@ftable @code 15*150b7e42Smiod@item HOST_CHARSET_UNKNOWN 16*150b7e42SmiodThe host character set is unknown - that is, not one of the next two 17*150b7e42Smiodpossibilities. 18*150b7e42Smiod 19*150b7e42Smiod@item HOST_CHARSET_ASCII 20*150b7e42SmiodThe host character set is ASCII. 21*150b7e42Smiod 22*150b7e42Smiod@item HOST_CHARSET_EBCDIC 23*150b7e42SmiodThe host character set is some variant of EBCDIC. (Only one of the 24*150b7e42Smiodnineteen EBCDIC varying characters is tested; exercise caution.) 25*150b7e42Smiod@end ftable 26*150b7e42Smiod@end defvr 27*150b7e42Smiod 289588ddcfSespie@c alloca.c:26 299588ddcfSespie@deftypefn Replacement void* alloca (size_t @var{size}) 309588ddcfSespie 319588ddcfSespieThis function allocates memory which will be automatically reclaimed 329588ddcfSespieafter the procedure exits. The @libib{} implementation does not free 339588ddcfSespiethe memory immediately but will do so eventually during subsequent 349588ddcfSespiecalls to this function. Memory is allocated using @code{xmalloc} under 359588ddcfSespienormal circumstances. 369588ddcfSespie 379588ddcfSespieThe header file @file{alloca-conf.h} can be used in conjunction with the 389588ddcfSespieGNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make 399588ddcfSespieavailable this function. The @code{AC_FUNC_ALLOCA} test requires that 409588ddcfSespieclient code use a block of preprocessor code to be safe (see the Autoconf 419588ddcfSespiemanual for more); this header incorporates that logic and more, including 429588ddcfSespiethe possibility of a GCC built-in function. 439588ddcfSespie 449588ddcfSespie@end deftypefn 459588ddcfSespie 46*150b7e42Smiod@c asprintf.c:32 479588ddcfSespie@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...) 489588ddcfSespie 499588ddcfSespieLike @code{sprintf}, but instead of passing a pointer to a buffer, you 509588ddcfSespiepass a pointer to a pointer. This function will compute the size of 519588ddcfSespiethe buffer needed, allocate memory with @code{malloc}, and store a 529588ddcfSespiepointer to the allocated memory in @code{*@var{resptr}}. The value 539588ddcfSespiereturned is the same as @code{sprintf} would return. If memory could 54*150b7e42Smiodnot be allocated, minus one is returned and @code{NULL} is stored in 559588ddcfSespie@code{*@var{resptr}}. 569588ddcfSespie 579588ddcfSespie@end deftypefn 589588ddcfSespie 599588ddcfSespie@c atexit.c:6 609588ddcfSespie@deftypefn Supplemental int atexit (void (*@var{f})()) 619588ddcfSespie 629588ddcfSespieCauses function @var{f} to be called at exit. Returns 0. 639588ddcfSespie 649588ddcfSespie@end deftypefn 659588ddcfSespie 669588ddcfSespie@c basename.c:6 679588ddcfSespie@deftypefn Supplemental char* basename (const char *@var{name}) 689588ddcfSespie 699588ddcfSespieReturns a pointer to the last component of pathname @var{name}. 709588ddcfSespieBehavior is undefined if the pathname ends in a directory separator. 719588ddcfSespie 729588ddcfSespie@end deftypefn 739588ddcfSespie 749588ddcfSespie@c bcmp.c:6 759588ddcfSespie@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count}) 769588ddcfSespie 779588ddcfSespieCompares the first @var{count} bytes of two areas of memory. Returns 789588ddcfSespiezero if they are the same, nonzero otherwise. Returns zero if 799588ddcfSespie@var{count} is zero. A nonzero result only indicates a difference, 809588ddcfSespieit does not indicate any sorting order (say, by having a positive 819588ddcfSespieresult mean @var{x} sorts before @var{y}). 829588ddcfSespie 839588ddcfSespie@end deftypefn 849588ddcfSespie 859588ddcfSespie@c bcopy.c:3 869588ddcfSespie@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length}) 879588ddcfSespie 889588ddcfSespieCopies @var{length} bytes from memory region @var{in} to region 899588ddcfSespie@var{out}. The use of @code{bcopy} is deprecated in new programs. 909588ddcfSespie 919588ddcfSespie@end deftypefn 929588ddcfSespie 939588ddcfSespie@c bsearch.c:33 949588ddcfSespie@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 *)) 959588ddcfSespie 969588ddcfSespiePerforms a search over an array of @var{nmemb} elements pointed to by 979588ddcfSespie@var{base} for a member that matches the object pointed to by @var{key}. 989588ddcfSespieThe size of each member is specified by @var{size}. The array contents 999588ddcfSespieshould be sorted in ascending order according to the @var{compar} 1009588ddcfSespiecomparison function. This routine should take two arguments pointing to 1019588ddcfSespiethe @var{key} and to an array member, in that order, and should return an 1029588ddcfSespieinteger less than, equal to, or greater than zero if the @var{key} object 1039588ddcfSespieis respectively less than, matching, or greater than the array member. 1049588ddcfSespie 1059588ddcfSespie@end deftypefn 1069588ddcfSespie 107*150b7e42Smiod@c argv.c:124 1089588ddcfSespie@deftypefn Extension char** buildargv (char *@var{sp}) 1099588ddcfSespie 1109588ddcfSespieGiven a pointer to a string, parse the string extracting fields 1119588ddcfSespieseparated by whitespace and optionally enclosed within either single 1129588ddcfSespieor double quotes (which are stripped off), and build a vector of 1139588ddcfSespiepointers to copies of the string for each field. The input string 1149588ddcfSespieremains unchanged. The last element of the vector is followed by a 1159588ddcfSespie@code{NULL} element. 1169588ddcfSespie 1179588ddcfSespieAll of the memory for the pointer array and copies of the string 1189588ddcfSespieis obtained from @code{malloc}. All of the memory can be returned to the 1199588ddcfSespiesystem with the single function call @code{freeargv}, which takes the 1209588ddcfSespiereturned result of @code{buildargv}, as it's argument. 1219588ddcfSespie 1229588ddcfSespieReturns a pointer to the argument vector if successful. Returns 1239588ddcfSespie@code{NULL} if @var{sp} is @code{NULL} or if there is insufficient 1249588ddcfSespiememory to complete building the argument vector. 1259588ddcfSespie 1269588ddcfSespieIf the input is a null string (as opposed to a @code{NULL} pointer), 1279588ddcfSespiethen buildarg returns an argument vector that has one arg, a null 1289588ddcfSespiestring. 1299588ddcfSespie 1309588ddcfSespie@end deftypefn 1319588ddcfSespie 1329588ddcfSespie@c bzero.c:6 1339588ddcfSespie@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count}) 1349588ddcfSespie 1359588ddcfSespieZeros @var{count} bytes starting at @var{mem}. Use of this function 1369588ddcfSespieis deprecated in favor of @code{memset}. 1379588ddcfSespie 1389588ddcfSespie@end deftypefn 1399588ddcfSespie 1409588ddcfSespie@c calloc.c:6 1419588ddcfSespie@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize}) 1429588ddcfSespie 1439588ddcfSespieUses @code{malloc} to allocate storage for @var{nelem} objects of 1449588ddcfSespie@var{elsize} bytes each, then zeros the memory. 1459588ddcfSespie 1469588ddcfSespie@end deftypefn 1479588ddcfSespie 1489588ddcfSespie@c choose-temp.c:42 1499588ddcfSespie@deftypefn Extension char* choose_temp_base (void) 1509588ddcfSespie 1519588ddcfSespieReturn a prefix for temporary file names or @code{NULL} if unable to 1529588ddcfSespiefind one. The current directory is chosen if all else fails so the 1539588ddcfSespieprogram is exited if a temporary directory can't be found (@code{mktemp} 1549588ddcfSespiefails). The buffer for the result is obtained with @code{xmalloc}. 1559588ddcfSespie 1569588ddcfSespieThis function is provided for backwards compatability only. Its use is 1579588ddcfSespienot recommended. 1589588ddcfSespie 1599588ddcfSespie@end deftypefn 1609588ddcfSespie 161*150b7e42Smiod@c make-temp-file.c:87 1629588ddcfSespie@deftypefn Replacement char* choose_tmpdir () 1639588ddcfSespie 1649588ddcfSespieReturns a pointer to a directory path suitable for creating temporary 1659588ddcfSespiefiles in. 1669588ddcfSespie 1679588ddcfSespie@end deftypefn 1689588ddcfSespie 1699588ddcfSespie@c clock.c:27 1709588ddcfSespie@deftypefn Supplemental long clock (void) 1719588ddcfSespie 1729588ddcfSespieReturns an approximation of the CPU time used by the process as a 1739588ddcfSespie@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the 1749588ddcfSespienumber of seconds used. 1759588ddcfSespie 1769588ddcfSespie@end deftypefn 1779588ddcfSespie 1789588ddcfSespie@c concat.c:24 1799588ddcfSespie@deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL}) 1809588ddcfSespie 1819588ddcfSespieConcatenate zero or more of strings and return the result in freshly 1829588ddcfSespie@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is 1839588ddcfSespieavailable. The argument list is terminated by the first @code{NULL} 1849588ddcfSespiepointer encountered. Pointers to empty strings are ignored. 1859588ddcfSespie 1869588ddcfSespie@end deftypefn 1879588ddcfSespie 188*150b7e42Smiod@c argv.c:52 1899588ddcfSespie@deftypefn Extension char** dupargv (char **@var{vector}) 1909588ddcfSespie 1919588ddcfSespieDuplicate an argument vector. Simply scans through @var{vector}, 1929588ddcfSespieduplicating each argument until the terminating @code{NULL} is found. 1939588ddcfSespieReturns a pointer to the argument vector if successful. Returns 1949588ddcfSespie@code{NULL} if there is insufficient memory to complete building the 1959588ddcfSespieargument vector. 1969588ddcfSespie 1979588ddcfSespie@end deftypefn 1989588ddcfSespie 199*150b7e42Smiod@c strerror.c:567 2009588ddcfSespie@deftypefn Extension int errno_max (void) 2019588ddcfSespie 2029588ddcfSespieReturns the maximum @code{errno} value for which a corresponding 2039588ddcfSespiesymbolic name or message is available. Note that in the case where we 2049588ddcfSespieuse the @code{sys_errlist} supplied by the system, it is possible for 2059588ddcfSespiethere to be more symbolic names than messages, or vice versa. In 2069588ddcfSespiefact, the manual page for @code{perror(3C)} explicitly warns that one 2079588ddcfSespieshould check the size of the table (@code{sys_nerr}) before indexing 2089588ddcfSespieit, since new error codes may be added to the system before they are 2099588ddcfSespieadded to the table. Thus @code{sys_nerr} might be smaller than value 2109588ddcfSespieimplied by the largest @code{errno} value defined in @code{<errno.h>}. 2119588ddcfSespie 2129588ddcfSespieWe return the maximum value that can be used to obtain a meaningful 2139588ddcfSespiesymbolic name or message. 2149588ddcfSespie 2159588ddcfSespie@end deftypefn 2169588ddcfSespie 217*150b7e42Smiod@c argv.c:293 218*150b7e42Smiod@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) 219*150b7e42Smiod 220*150b7e42SmiodThe @var{argcp} and @code{argvp} arguments are pointers to the usual 221*150b7e42Smiod@code{argc} and @code{argv} arguments to @code{main}. This function 222*150b7e42Smiodlooks for arguments that begin with the character @samp{@@}. Any such 223*150b7e42Smiodarguments are interpreted as ``response files''. The contents of the 224*150b7e42Smiodresponse file are interpreted as additional command line options. In 225*150b7e42Smiodparticular, the file is separated into whitespace-separated strings; 226*150b7e42Smiodeach such string is taken as a command-line option. The new options 227*150b7e42Smiodare inserted in place of the option naming the response file, and 228*150b7e42Smiod@code{*argcp} and @code{*argvp} will be updated. If the value of 229*150b7e42Smiod@code{*argvp} is modified by this function, then the new value has 230*150b7e42Smiodbeen dynamically allocated and can be deallocated by the caller with 231*150b7e42Smiod@code{freeargv}. However, most callers will simply call 232*150b7e42Smiod@code{expandargv} near the beginning of @code{main} and allow the 233*150b7e42Smiodoperating system to free the memory when the program exits. 234*150b7e42Smiod 235*150b7e42Smiod@end deftypefn 236*150b7e42Smiod 2379588ddcfSespie@c fdmatch.c:23 2389588ddcfSespie@deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2}) 2399588ddcfSespie 2409588ddcfSespieCheck to see if two open file descriptors refer to the same file. 2419588ddcfSespieThis is useful, for example, when we have an open file descriptor for 2429588ddcfSespiean unnamed file, and the name of a file that we believe to correspond 2439588ddcfSespieto that fd. This can happen when we are exec'd with an already open 2449588ddcfSespiefile (@code{stdout} for example) or from the SVR4 @file{/proc} calls 2459588ddcfSespiethat return open file descriptors for mapped address spaces. All we 2469588ddcfSespiehave to do is open the file by name and check the two file descriptors 2479588ddcfSespiefor a match, which is done by comparing major and minor device numbers 2489588ddcfSespieand inode numbers. 2499588ddcfSespie 2509588ddcfSespie@end deftypefn 2519588ddcfSespie 252*150b7e42Smiod@c fopen_unlocked.c:48 253*150b7e42Smiod@deftypefn Extension {FILE *} fdopen_unlocked (int @var{fildes}, const char * @var{mode}) 254*150b7e42Smiod 255*150b7e42SmiodOpens and returns a @code{FILE} pointer via @code{fdopen}. If the 256*150b7e42Smiodoperating system supports it, ensure that the stream is setup to avoid 257*150b7e42Smiodany multi-threaded locking. Otherwise return the @code{FILE} pointer 258*150b7e42Smiodunchanged. 259*150b7e42Smiod 260*150b7e42Smiod@end deftypefn 261*150b7e42Smiod 2629588ddcfSespie@c ffs.c:3 2639588ddcfSespie@deftypefn Supplemental int ffs (int @var{valu}) 2649588ddcfSespie 2659588ddcfSespieFind the first (least significant) bit set in @var{valu}. Bits are 2669588ddcfSespienumbered from right to left, starting with bit 1 (corresponding to the 2679588ddcfSespievalue 1). If @var{valu} is zero, zero is returned. 2689588ddcfSespie 2699588ddcfSespie@end deftypefn 2709588ddcfSespie 2719588ddcfSespie@c fnmatch.txh:1 2729588ddcfSespie@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags}) 2739588ddcfSespie 2749588ddcfSespieMatches @var{string} against @var{pattern}, returning zero if it 2759588ddcfSespiematches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the 2769588ddcfSespiewildcards @code{?} to match any one character, @code{*} to match any 2779588ddcfSespiezero or more characters, or a set of alternate characters in square 2789588ddcfSespiebrackets, like @samp{[a-gt8]}, which match one character (@code{a} 2799588ddcfSespiethrough @code{g}, or @code{t}, or @code{8}, in this example) if that one 2809588ddcfSespiecharacter is in the set. A set may be inverted (i.e., match anything 2819588ddcfSespieexcept what's in the set) by giving @code{^} or @code{!} as the first 2829588ddcfSespiecharacter in the set. To include those characters in the set, list them 2839588ddcfSespieas anything other than the first character of the set. To include a 2849588ddcfSespiedash in the set, list it last in the set. A backslash character makes 2859588ddcfSespiethe following character not special, so for example you could match 2869588ddcfSespieagainst a literal asterisk with @samp{\*}. To match a literal 2879588ddcfSespiebackslash, use @samp{\\}. 2889588ddcfSespie 2899588ddcfSespie@code{flags} controls various aspects of the matching process, and is a 2909588ddcfSespieboolean OR of zero or more of the following values (defined in 2919588ddcfSespie@code{<fnmatch.h>}): 2929588ddcfSespie 2939588ddcfSespie@table @code 2949588ddcfSespie 2959588ddcfSespie@item FNM_PATHNAME 2969588ddcfSespie@itemx FNM_FILE_NAME 2979588ddcfSespie@var{string} is assumed to be a path name. No wildcard will ever match 2989588ddcfSespie@code{/}. 2999588ddcfSespie 3009588ddcfSespie@item FNM_NOESCAPE 3019588ddcfSespieDo not interpret backslashes as quoting the following special character. 3029588ddcfSespie 3039588ddcfSespie@item FNM_PERIOD 3049588ddcfSespieA leading period (at the beginning of @var{string}, or if 3059588ddcfSespie@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or 3069588ddcfSespie@code{?} but must be matched explicitly. 3079588ddcfSespie 3089588ddcfSespie@item FNM_LEADING_DIR 3099588ddcfSespieMeans that @var{string} also matches @var{pattern} if some initial part 3109588ddcfSespieof @var{string} matches, and is followed by @code{/} and zero or more 3119588ddcfSespiecharacters. For example, @samp{foo*} would match either @samp{foobar} 3129588ddcfSespieor @samp{foobar/grill}. 3139588ddcfSespie 3149588ddcfSespie@item FNM_CASEFOLD 3159588ddcfSespieIgnores case when performing the comparison. 3169588ddcfSespie 3179588ddcfSespie@end table 3189588ddcfSespie 3199588ddcfSespie@end deftypefn 3209588ddcfSespie 321*150b7e42Smiod@c fopen_unlocked.c:39 322*150b7e42Smiod@deftypefn Extension {FILE *} fopen_unlocked (const char *@var{path}, const char * @var{mode}) 323*150b7e42Smiod 324*150b7e42SmiodOpens and returns a @code{FILE} pointer via @code{fopen}. If the 325*150b7e42Smiodoperating system supports it, ensure that the stream is setup to avoid 326*150b7e42Smiodany multi-threaded locking. Otherwise return the @code{FILE} pointer 327*150b7e42Smiodunchanged. 328*150b7e42Smiod 329*150b7e42Smiod@end deftypefn 330*150b7e42Smiod 331*150b7e42Smiod@c argv.c:97 3329588ddcfSespie@deftypefn Extension void freeargv (char **@var{vector}) 3339588ddcfSespie 3349588ddcfSespieFree an argument vector that was built using @code{buildargv}. Simply 3359588ddcfSespiescans through @var{vector}, freeing the memory for each argument until 3369588ddcfSespiethe terminating @code{NULL} is found, and then frees @var{vector} 3379588ddcfSespieitself. 3389588ddcfSespie 3399588ddcfSespie@end deftypefn 3409588ddcfSespie 341*150b7e42Smiod@c fopen_unlocked.c:57 342*150b7e42Smiod@deftypefn Extension {FILE *} freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream}) 343*150b7e42Smiod 344*150b7e42SmiodOpens and returns a @code{FILE} pointer via @code{freopen}. If the 345*150b7e42Smiodoperating system supports it, ensure that the stream is setup to avoid 346*150b7e42Smiodany multi-threaded locking. Otherwise return the @code{FILE} pointer 347*150b7e42Smiodunchanged. 348*150b7e42Smiod 349*150b7e42Smiod@end deftypefn 350*150b7e42Smiod 3519588ddcfSespie@c getruntime.c:82 3529588ddcfSespie@deftypefn Replacement long get_run_time (void) 3539588ddcfSespie 3549588ddcfSespieReturns the time used so far, in microseconds. If possible, this is 3559588ddcfSespiethe time used by this process, else it is the elapsed time since the 3569588ddcfSespieprocess started. 3579588ddcfSespie 3589588ddcfSespie@end deftypefn 3599588ddcfSespie 3609588ddcfSespie@c getcwd.c:6 3619588ddcfSespie@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len}) 3629588ddcfSespie 3639588ddcfSespieCopy the absolute pathname for the current working directory into 3649588ddcfSespie@var{pathname}, which is assumed to point to a buffer of at least 3659588ddcfSespie@var{len} bytes, and return a pointer to the buffer. If the current 3669588ddcfSespiedirectory's path doesn't fit in @var{len} characters, the result is 3679588ddcfSespie@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer, 3689588ddcfSespie@code{getcwd} will obtain @var{len} bytes of space using 3699588ddcfSespie@code{malloc}. 3709588ddcfSespie 3719588ddcfSespie@end deftypefn 3729588ddcfSespie 3739588ddcfSespie@c getpagesize.c:5 3749588ddcfSespie@deftypefn Supplemental int getpagesize (void) 3759588ddcfSespie 3769588ddcfSespieReturns the number of bytes in a page of memory. This is the 3779588ddcfSespiegranularity of many of the system memory management routines. No 3789588ddcfSespieguarantee is made as to whether or not it is the same as the basic 3799588ddcfSespiememory management hardware page size. 3809588ddcfSespie 3819588ddcfSespie@end deftypefn 3829588ddcfSespie 3839588ddcfSespie@c getpwd.c:5 3849588ddcfSespie@deftypefn Supplemental char* getpwd (void) 3859588ddcfSespie 3869588ddcfSespieReturns the current working directory. This implementation caches the 3879588ddcfSespieresult on the assumption that the process will not call @code{chdir} 3889588ddcfSespiebetween calls to @code{getpwd}. 3899588ddcfSespie 3909588ddcfSespie@end deftypefn 3919588ddcfSespie 392*150b7e42Smiod@c gettimeofday.c:12 393*150b7e42Smiod@deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz}) 394*150b7e42Smiod 395*150b7e42SmiodWrites the current time to @var{tp}. This implementation requires 396*150b7e42Smiodthat @var{tz} be NULL. Returns 0 on success, -1 on failure. 397*150b7e42Smiod 398*150b7e42Smiod@end deftypefn 399*150b7e42Smiod 400*150b7e42Smiod@c hex.c:33 4019588ddcfSespie@deftypefn Extension void hex_init (void) 4029588ddcfSespie 4039588ddcfSespieInitializes the array mapping the current character set to 4049588ddcfSespiecorresponding hex values. This function must be called before any 4059588ddcfSespiecall to @code{hex_p} or @code{hex_value}. If you fail to call it, a 4069588ddcfSespiedefault ASCII-based table will normally be used on ASCII systems. 4079588ddcfSespie 4089588ddcfSespie@end deftypefn 4099588ddcfSespie 410*150b7e42Smiod@c hex.c:42 4119588ddcfSespie@deftypefn Extension int hex_p (int @var{c}) 4129588ddcfSespie 4139588ddcfSespieEvaluates to non-zero if the given character is a valid hex character, 4149588ddcfSespieor zero if it is not. Note that the value you pass will be cast to 4159588ddcfSespie@code{unsigned char} within the macro. 4169588ddcfSespie 4179588ddcfSespie@end deftypefn 4189588ddcfSespie 419*150b7e42Smiod@c hex.c:50 420*150b7e42Smiod@deftypefn Extension {unsigned int} hex_value (int @var{c}) 4219588ddcfSespie 4229588ddcfSespieReturns the numeric equivalent of the given character when interpreted 4239588ddcfSespieas a hexidecimal digit. The result is undefined if you pass an 4249588ddcfSespieinvalid hex digit. Note that the value you pass will be cast to 4259588ddcfSespie@code{unsigned char} within the macro. 4269588ddcfSespie 427*150b7e42SmiodThe @code{hex_value} macro returns @code{unsigned int}, rather than 428*150b7e42Smiodsigned @code{int}, to make it easier to use in parsing addresses from 429*150b7e42Smiodhex dump files: a signed @code{int} would be sign-extended when 430*150b7e42Smiodconverted to a wider unsigned type --- like @code{bfd_vma}, on some 431*150b7e42Smiodsystems. 432*150b7e42Smiod 4339588ddcfSespie@end deftypefn 4349588ddcfSespie 4359588ddcfSespie@c index.c:5 4369588ddcfSespie@deftypefn Supplemental char* index (char *@var{s}, int @var{c}) 4379588ddcfSespie 4389588ddcfSespieReturns a pointer to the first occurrence of the character @var{c} in 4399588ddcfSespiethe string @var{s}, or @code{NULL} if not found. The use of @code{index} is 4409588ddcfSespiedeprecated in new programs in favor of @code{strchr}. 4419588ddcfSespie 4429588ddcfSespie@end deftypefn 4439588ddcfSespie 4449588ddcfSespie@c insque.c:6 4459588ddcfSespie@deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred}) 4469588ddcfSespie@deftypefnx Supplemental void remque (struct qelem *@var{elem}) 4479588ddcfSespie 4489588ddcfSespieRoutines to manipulate queues built from doubly linked lists. The 4499588ddcfSespie@code{insque} routine inserts @var{elem} in the queue immediately 4509588ddcfSespieafter @var{pred}. The @code{remque} routine removes @var{elem} from 4519588ddcfSespieits containing queue. These routines expect to be passed pointers to 4529588ddcfSespiestructures which have as their first members a forward pointer and a 4539588ddcfSespieback pointer, like this prototype (although no prototype is provided): 4549588ddcfSespie 4559588ddcfSespie@example 4569588ddcfSespiestruct qelem @{ 4579588ddcfSespie struct qelem *q_forw; 4589588ddcfSespie struct qelem *q_back; 4599588ddcfSespie char q_data[]; 4609588ddcfSespie@}; 4619588ddcfSespie@end example 4629588ddcfSespie 4639588ddcfSespie@end deftypefn 4649588ddcfSespie 465*150b7e42Smiod@c safe-ctype.c:46 466*150b7e42Smiod@deffn Extension ISALPHA (@var{c}) 467*150b7e42Smiod@deffnx Extension ISALNUM (@var{c}) 468*150b7e42Smiod@deffnx Extension ISBLANK (@var{c}) 469*150b7e42Smiod@deffnx Extension ISCNTRL (@var{c}) 470*150b7e42Smiod@deffnx Extension ISDIGIT (@var{c}) 471*150b7e42Smiod@deffnx Extension ISGRAPH (@var{c}) 472*150b7e42Smiod@deffnx Extension ISLOWER (@var{c}) 473*150b7e42Smiod@deffnx Extension ISPRINT (@var{c}) 474*150b7e42Smiod@deffnx Extension ISPUNCT (@var{c}) 475*150b7e42Smiod@deffnx Extension ISSPACE (@var{c}) 476*150b7e42Smiod@deffnx Extension ISUPPER (@var{c}) 477*150b7e42Smiod@deffnx Extension ISXDIGIT (@var{c}) 478*150b7e42Smiod 479*150b7e42SmiodThese twelve macros are defined by @file{safe-ctype.h}. Each has the 480*150b7e42Smiodsame meaning as the corresponding macro (with name in lowercase) 481*150b7e42Smioddefined by the standard header @file{ctype.h}. For example, 482*150b7e42Smiod@code{ISALPHA} returns true for alphabetic characters and false for 483*150b7e42Smiodothers. However, there are two differences between these macros and 484*150b7e42Smiodthose provided by @file{ctype.h}: 485*150b7e42Smiod 486*150b7e42Smiod@itemize @bullet 487*150b7e42Smiod@item These macros are guaranteed to have well-defined behavior for all 488*150b7e42Smiodvalues representable by @code{signed char} and @code{unsigned char}, and 489*150b7e42Smiodfor @code{EOF}. 490*150b7e42Smiod 491*150b7e42Smiod@item These macros ignore the current locale; they are true for these 492*150b7e42Smiodfixed sets of characters: 493*150b7e42Smiod@multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada} 494*150b7e42Smiod@item @code{ALPHA} @tab @kbd{A-Za-z} 495*150b7e42Smiod@item @code{ALNUM} @tab @kbd{A-Za-z0-9} 496*150b7e42Smiod@item @code{BLANK} @tab @kbd{space tab} 497*150b7e42Smiod@item @code{CNTRL} @tab @code{!PRINT} 498*150b7e42Smiod@item @code{DIGIT} @tab @kbd{0-9} 499*150b7e42Smiod@item @code{GRAPH} @tab @code{ALNUM || PUNCT} 500*150b7e42Smiod@item @code{LOWER} @tab @kbd{a-z} 501*150b7e42Smiod@item @code{PRINT} @tab @code{GRAPH ||} @kbd{space} 502*150b7e42Smiod@item @code{PUNCT} @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?} 503*150b7e42Smiod@item @code{SPACE} @tab @kbd{space tab \n \r \f \v} 504*150b7e42Smiod@item @code{UPPER} @tab @kbd{A-Z} 505*150b7e42Smiod@item @code{XDIGIT} @tab @kbd{0-9A-Fa-f} 506*150b7e42Smiod@end multitable 507*150b7e42Smiod 508*150b7e42SmiodNote that, if the host character set is ASCII or a superset thereof, 509*150b7e42Smiodall these macros will return false for all values of @code{char} outside 510*150b7e42Smiodthe range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return 511*150b7e42Smiodfalse for characters with numeric values from 128 to 255. 512*150b7e42Smiod@end itemize 513*150b7e42Smiod@end deffn 514*150b7e42Smiod 515*150b7e42Smiod@c safe-ctype.c:95 516*150b7e42Smiod@deffn Extension ISIDNUM (@var{c}) 517*150b7e42Smiod@deffnx Extension ISIDST (@var{c}) 518*150b7e42Smiod@deffnx Extension IS_VSPACE (@var{c}) 519*150b7e42Smiod@deffnx Extension IS_NVSPACE (@var{c}) 520*150b7e42Smiod@deffnx Extension IS_SPACE_OR_NUL (@var{c}) 521*150b7e42Smiod@deffnx Extension IS_ISOBASIC (@var{c}) 522*150b7e42SmiodThese six macros are defined by @file{safe-ctype.h} and provide 523*150b7e42Smiodadditional character classes which are useful when doing lexical 524*150b7e42Smiodanalysis of C or similar languages. They are true for the following 525*150b7e42Smiodsets of characters: 526*150b7e42Smiod 527*150b7e42Smiod@multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada} 528*150b7e42Smiod@item @code{IDNUM} @tab @kbd{A-Za-z0-9_} 529*150b7e42Smiod@item @code{IDST} @tab @kbd{A-Za-z_} 530*150b7e42Smiod@item @code{VSPACE} @tab @kbd{\r \n} 531*150b7e42Smiod@item @code{NVSPACE} @tab @kbd{space tab \f \v \0} 532*150b7e42Smiod@item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE} 533*150b7e42Smiod@item @code{ISOBASIC} @tab @code{VSPACE || NVSPACE || PRINT} 534*150b7e42Smiod@end multitable 535*150b7e42Smiod@end deffn 536*150b7e42Smiod 5379588ddcfSespie@c lbasename.c:23 5389588ddcfSespie@deftypefn Replacement {const char*} lbasename (const char *@var{name}) 5399588ddcfSespie 5409588ddcfSespieGiven a pointer to a string containing a typical pathname 5419588ddcfSespie(@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the 5429588ddcfSespielast component of the pathname (@samp{ls.c} in this case). The 5439588ddcfSespiereturned pointer is guaranteed to lie within the original 5449588ddcfSespiestring. This latter fact is not true of many vendor C 5459588ddcfSespielibraries, which return special strings or modify the passed 5469588ddcfSespiestrings for particular input. 5479588ddcfSespie 5489588ddcfSespieIn particular, the empty string returns the same empty string, 5499588ddcfSespieand a path ending in @code{/} returns the empty string after it. 5509588ddcfSespie 5519588ddcfSespie@end deftypefn 5529588ddcfSespie 55332d62142Sespie@c lrealpath.c:25 55432d62142Sespie@deftypefn Replacement {const char*} lrealpath (const char *@var{name}) 55532d62142Sespie 55632d62142SespieGiven a pointer to a string containing a pathname, returns a canonical 55732d62142Sespieversion of the filename. Symlinks will be resolved, and ``.'' and ``..'' 55832d62142Sespiecomponents will be simplified. The returned value will be allocated using 55932d62142Sespie@code{malloc}, or @code{NULL} will be returned on a memory allocation error. 56032d62142Sespie 56132d62142Sespie@end deftypefn 56232d62142Sespie 5639588ddcfSespie@c make-relative-prefix.c:24 5649588ddcfSespie@deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, const char *@var{bin_prefix}, const char *@var{prefix}) 5659588ddcfSespie 56632d62142SespieGiven three paths @var{progname}, @var{bin_prefix}, @var{prefix}, 56732d62142Sespiereturn the path that is in the same position relative to 56832d62142Sespie@var{progname}'s directory as @var{prefix} is relative to 56932d62142Sespie@var{bin_prefix}. That is, a string starting with the directory 57032d62142Sespieportion of @var{progname}, followed by a relative pathname of the 57132d62142Sespiedifference between @var{bin_prefix} and @var{prefix}. 5729588ddcfSespie 57332d62142SespieIf @var{progname} does not contain any directory separators, 57432d62142Sespie@code{make_relative_prefix} will search @env{PATH} to find a program 57532d62142Sespienamed @var{progname}. Also, if @var{progname} is a symbolic link, 57632d62142Sespiethe symbolic link will be resolved. 5779588ddcfSespie 57832d62142SespieFor example, if @var{bin_prefix} is @code{/alpha/beta/gamma/gcc/delta}, 57932d62142Sespie@var{prefix} is @code{/alpha/beta/gamma/omega/}, and @var{progname} is 58032d62142Sespie@code{/red/green/blue/gcc}, then this function will return 58132d62142Sespie@code{/red/green/blue/../../omega/}. 58232d62142Sespie 58332d62142SespieThe return value is normally allocated via @code{malloc}. If no 58432d62142Sespierelative prefix can be found, return @code{NULL}. 5859588ddcfSespie 5869588ddcfSespie@end deftypefn 5879588ddcfSespie 588*150b7e42Smiod@c make-temp-file.c:137 5899588ddcfSespie@deftypefn Replacement char* make_temp_file (const char *@var{suffix}) 5909588ddcfSespie 5919588ddcfSespieReturn a temporary file name (as a string) or @code{NULL} if unable to 5929588ddcfSespiecreate one. @var{suffix} is a suffix to append to the file name. The 5939588ddcfSespiestring is @code{malloc}ed, and the temporary file has been created. 5949588ddcfSespie 5959588ddcfSespie@end deftypefn 5969588ddcfSespie 5979588ddcfSespie@c memchr.c:3 5989588ddcfSespie@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n}) 5999588ddcfSespie 6009588ddcfSespieThis function searches memory starting at @code{*@var{s}} for the 6019588ddcfSespiecharacter @var{c}. The search only ends with the first occurrence of 6029588ddcfSespie@var{c}, or after @var{length} characters; in particular, a null 6039588ddcfSespiecharacter does not terminate the search. If the character @var{c} is 6049588ddcfSespiefound within @var{length} characters of @code{*@var{s}}, a pointer 6059588ddcfSespieto the character is returned. If @var{c} is not found, then @code{NULL} is 6069588ddcfSespiereturned. 6079588ddcfSespie 6089588ddcfSespie@end deftypefn 6099588ddcfSespie 6109588ddcfSespie@c memcmp.c:6 6119588ddcfSespie@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count}) 6129588ddcfSespie 6139588ddcfSespieCompares the first @var{count} bytes of two areas of memory. Returns 6149588ddcfSespiezero if they are the same, a value less than zero if @var{x} is 6159588ddcfSespielexically less than @var{y}, or a value greater than zero if @var{x} 6169588ddcfSespieis lexically greater than @var{y}. Note that lexical order is determined 6179588ddcfSespieas if comparing unsigned char arrays. 6189588ddcfSespie 6199588ddcfSespie@end deftypefn 6209588ddcfSespie 6219588ddcfSespie@c memcpy.c:6 6229588ddcfSespie@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) 6239588ddcfSespie 6249588ddcfSespieCopies @var{length} bytes from memory region @var{in} to region 6259588ddcfSespie@var{out}. Returns a pointer to @var{out}. 6269588ddcfSespie 6279588ddcfSespie@end deftypefn 6289588ddcfSespie 6299588ddcfSespie@c memmove.c:6 6309588ddcfSespie@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count}) 6319588ddcfSespie 6329588ddcfSespieCopies @var{count} bytes from memory area @var{from} to memory area 6339588ddcfSespie@var{to}, returning a pointer to @var{to}. 6349588ddcfSespie 6359588ddcfSespie@end deftypefn 6369588ddcfSespie 63725e200daSespie@c mempcpy.c:23 63825e200daSespie@deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, size_t @var{length}) 63925e200daSespie 64025e200daSespieCopies @var{length} bytes from memory region @var{in} to region 64125e200daSespie@var{out}. Returns a pointer to @var{out} + @var{length}. 64225e200daSespie 64325e200daSespie@end deftypefn 64425e200daSespie 6459588ddcfSespie@c memset.c:6 6469588ddcfSespie@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count}) 6479588ddcfSespie 6489588ddcfSespieSets the first @var{count} bytes of @var{s} to the constant byte 6499588ddcfSespie@var{c}, returning a pointer to @var{s}. 6509588ddcfSespie 6519588ddcfSespie@end deftypefn 6529588ddcfSespie 6539588ddcfSespie@c mkstemps.c:54 654*150b7e42Smiod@deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len}) 6559588ddcfSespie 656*150b7e42SmiodGenerate a unique temporary file name from @var{pattern}. 657*150b7e42Smiod@var{pattern} has the form: 6589588ddcfSespie 6599588ddcfSespie@example 6609588ddcfSespie @var{path}/ccXXXXXX@var{suffix} 6619588ddcfSespie@end example 6629588ddcfSespie 6639588ddcfSespie@var{suffix_len} tells us how long @var{suffix} is (it can be zero 664*150b7e42Smiodlength). The last six characters of @var{pattern} before @var{suffix} 6659588ddcfSespiemust be @samp{XXXXXX}; they are replaced with a string that makes the 6669588ddcfSespiefilename unique. Returns a file descriptor open on the file for 6679588ddcfSespiereading and writing. 6689588ddcfSespie 6699588ddcfSespie@end deftypefn 6709588ddcfSespie 671*150b7e42Smiod@c pexecute.txh:231 672*150b7e42Smiod@deftypefn Extension void pex_free (struct pex_obj @var{obj}) 6739588ddcfSespie 674*150b7e42SmiodClean up and free all data associated with @var{obj}. 6759588ddcfSespie 6769588ddcfSespie@end deftypefn 6779588ddcfSespie 678*150b7e42Smiod@c pexecute.txh:206 679*150b7e42Smiod@deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, int @var{count}, int *@var{vector}) 680*150b7e42Smiod 681*150b7e42SmiodReturns the exit status of all programs run using @var{obj}. 682*150b7e42Smiod@var{count} is the number of results expected. The results will be 683*150b7e42Smiodplaced into @var{vector}. The results are in the order of the calls 684*150b7e42Smiodto @code{pex_run}. Returns 0 on error, 1 on success. 685*150b7e42Smiod 686*150b7e42Smiod@end deftypefn 687*150b7e42Smiod 688*150b7e42Smiod@c pexecute.txh:215 689*150b7e42Smiod@deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, int @var{count}, struct pex_time *@var{vector}) 690*150b7e42Smiod 691*150b7e42SmiodReturns the process execution times of all programs run using 692*150b7e42Smiod@var{obj}. @var{count} is the number of results expected. The 693*150b7e42Smiodresults will be placed into @var{vector}. The results are in the 694*150b7e42Smiodorder of the calls to @code{pex_run}. Returns 0 on error, 1 on 695*150b7e42Smiodsuccess. 696*150b7e42Smiod 697*150b7e42Smiod@code{struct pex_time} has the following fields of the type 698*150b7e42Smiod@code{unsigned long}: @code{user_seconds}, 699*150b7e42Smiod@code{user_microseconds}, @code{system_seconds}, 700*150b7e42Smiod@code{system_microseconds}. On systems which do not support reporting 701*150b7e42Smiodprocess times, all the fields will be set to @code{0}. 702*150b7e42Smiod 703*150b7e42Smiod@end deftypefn 704*150b7e42Smiod 705*150b7e42Smiod@c pexecute.txh:2 706*150b7e42Smiod@deftypefn Extension {struct pex_obj *} pex_init (int @var{flags}, const char *@var{pname}, const char *@var{tempbase}) 707*150b7e42Smiod 708*150b7e42SmiodPrepare to execute one or more programs, with standard output of each 709*150b7e42Smiodprogram fed to standard input of the next. This is a system 710*150b7e42Smiodindependent interface to execute a pipeline. 711*150b7e42Smiod 712*150b7e42Smiod@var{flags} is a bitwise combination of the following: 713*150b7e42Smiod 714*150b7e42Smiod@table @code 715*150b7e42Smiod 716*150b7e42Smiod@vindex PEX_RECORD_TIMES 717*150b7e42Smiod@item PEX_RECORD_TIMES 718*150b7e42SmiodRecord subprocess times if possible. 719*150b7e42Smiod 720*150b7e42Smiod@vindex PEX_USE_PIPES 721*150b7e42Smiod@item PEX_USE_PIPES 722*150b7e42SmiodUse pipes for communication between processes, if possible. 723*150b7e42Smiod 724*150b7e42Smiod@vindex PEX_SAVE_TEMPS 725*150b7e42Smiod@item PEX_SAVE_TEMPS 726*150b7e42SmiodDon't delete temporary files used for communication between 727*150b7e42Smiodprocesses. 728*150b7e42Smiod 729*150b7e42Smiod@end table 730*150b7e42Smiod 731*150b7e42Smiod@var{pname} is the name of program to be executed, used in error 732*150b7e42Smiodmessages. @var{tempbase} is a base name to use for any required 733*150b7e42Smiodtemporary files; it may be @code{NULL} to use a randomly chosen name. 734*150b7e42Smiod 735*150b7e42Smiod@end deftypefn 736*150b7e42Smiod 737*150b7e42Smiod@c pexecute.txh:133 738*150b7e42Smiod@deftypefn Extension {FILE *} pex_input_file (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{in_name}) 739*150b7e42Smiod 740*150b7e42SmiodReturn a stream for a temporary file to pass to the first program in 741*150b7e42Smiodthe pipeline as input. 742*150b7e42Smiod 743*150b7e42SmiodThe name of the input file is chosen according to the same rules 744*150b7e42Smiod@code{pex_run} uses to choose output file names, based on 745*150b7e42Smiod@var{in_name}, @var{obj} and the @code{PEX_SUFFIX} bit in @var{flags}. 746*150b7e42Smiod 747*150b7e42SmiodDon't call @code{fclose} on the returned stream; the first call to 748*150b7e42Smiod@code{pex_run} closes it automatically. 749*150b7e42Smiod 750*150b7e42SmiodIf @var{flags} includes @code{PEX_BINARY_OUTPUT}, open the stream in 751*150b7e42Smiodbinary mode; otherwise, open it in the default mode. Including 752*150b7e42Smiod@code{PEX_BINARY_OUTPUT} in @var{flags} has no effect on Unix. 753*150b7e42Smiod@end deftypefn 754*150b7e42Smiod 755*150b7e42Smiod@c pexecute.txh:150 756*150b7e42Smiod@deftypefn Extension {FILE *} pex_input_pipe (struct pex_obj *@var{obj}, int @var{binary}) 757*150b7e42Smiod 758*150b7e42SmiodReturn a stream @var{fp} for a pipe connected to the standard input of 759*150b7e42Smiodthe first program in the pipeline; @var{fp} is opened for writing. 760*150b7e42SmiodYou must have passed @code{PEX_USE_PIPES} to the @code{pex_init} call 761*150b7e42Smiodthat returned @var{obj}. 762*150b7e42Smiod 763*150b7e42SmiodYou must close @var{fp} using @code{fclose} yourself when you have 764*150b7e42Smiodfinished writing data to the pipeline. 765*150b7e42Smiod 766*150b7e42SmiodThe file descriptor underlying @var{fp} is marked not to be inherited 767*150b7e42Smiodby child processes. 768*150b7e42Smiod 769*150b7e42SmiodOn systems that do not support pipes, this function returns 770*150b7e42Smiod@code{NULL}, and sets @code{errno} to @code{EINVAL}. If you would 771*150b7e42Smiodlike to write code that is portable to all systems the @code{pex} 772*150b7e42Smiodfunctions support, consider using @code{pex_input_file} instead. 773*150b7e42Smiod 774*150b7e42SmiodThere are two opportunities for deadlock using 775*150b7e42Smiod@code{pex_input_pipe}: 776*150b7e42Smiod 777*150b7e42Smiod@itemize @bullet 778*150b7e42Smiod@item 779*150b7e42SmiodMost systems' pipes can buffer only a fixed amount of data; a process 780*150b7e42Smiodthat writes to a full pipe blocks. Thus, if you write to @file{fp} 781*150b7e42Smiodbefore starting the first process, you run the risk of blocking when 782*150b7e42Smiodthere is no child process yet to read the data and allow you to 783*150b7e42Smiodcontinue. @code{pex_input_pipe} makes no promises about the 784*150b7e42Smiodsize of the pipe's buffer, so if you need to write any data at all 785*150b7e42Smiodbefore starting the first process in the pipeline, consider using 786*150b7e42Smiod@code{pex_input_file} instead. 787*150b7e42Smiod 788*150b7e42Smiod@item 789*150b7e42SmiodUsing @code{pex_input_pipe} and @code{pex_read_output} together 790*150b7e42Smiodmay also cause deadlock. If the output pipe fills up, so that each 791*150b7e42Smiodprogram in the pipeline is waiting for the next to read more data, and 792*150b7e42Smiodyou fill the input pipe by writing more data to @var{fp}, then there 793*150b7e42Smiodis no way to make progress: the only process that could read data from 794*150b7e42Smiodthe output pipe is you, but you are blocked on the input pipe. 795*150b7e42Smiod 796*150b7e42Smiod@end itemize 797*150b7e42Smiod 798*150b7e42Smiod@end deftypefn 799*150b7e42Smiod 800*150b7e42Smiod@c pexecute.txh:237 801*150b7e42Smiod@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}) 802*150b7e42Smiod 803*150b7e42SmiodAn interface to permit the easy execution of a 804*150b7e42Smiodsingle program. The return value and most of the parameters are as 805*150b7e42Smiodfor a call to @code{pex_run}. @var{flags} is restricted to a 806*150b7e42Smiodcombination of @code{PEX_SEARCH}, @code{PEX_STDERR_TO_STDOUT}, and 807*150b7e42Smiod@code{PEX_BINARY_OUTPUT}. @var{outname} is interpreted as if 808*150b7e42Smiod@code{PEX_LAST} were set. On a successful return, @code{*@var{status}} will 809*150b7e42Smiodbe set to the exit status of the program. 810*150b7e42Smiod 811*150b7e42Smiod@end deftypefn 812*150b7e42Smiod 813*150b7e42Smiod@c pexecute.txh:194 814*150b7e42Smiod@deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, int @var{binary}) 815*150b7e42Smiod 816*150b7e42SmiodReturns a @code{FILE} pointer which may be used to read the standard 817*150b7e42Smiodoutput of the last program in the pipeline. When this is used, 818*150b7e42Smiod@code{PEX_LAST} should not be used in a call to @code{pex_run}. After 819*150b7e42Smiodthis is called, @code{pex_run} may no longer be called with the same 820*150b7e42Smiod@var{obj}. @var{binary} should be non-zero if the file should be 821*150b7e42Smiodopened in binary mode. Don't call @code{fclose} on the returned file; 822*150b7e42Smiodit will be closed by @code{pex_free}. 823*150b7e42Smiod 824*150b7e42Smiod@end deftypefn 825*150b7e42Smiod 826*150b7e42Smiod@c pexecute.txh:33 827*150b7e42Smiod@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}) 828*150b7e42Smiod 829*150b7e42SmiodExecute one program in a pipeline. On success this returns 830*150b7e42Smiod@code{NULL}. On failure it returns an error message, a statically 831*150b7e42Smiodallocated string. 832*150b7e42Smiod 833*150b7e42Smiod@var{obj} is returned by a previous call to @code{pex_init}. 834*150b7e42Smiod 835*150b7e42Smiod@var{flags} is a bitwise combination of the following: 836*150b7e42Smiod 837*150b7e42Smiod@table @code 838*150b7e42Smiod 839*150b7e42Smiod@vindex PEX_LAST 840*150b7e42Smiod@item PEX_LAST 841*150b7e42SmiodThis must be set on the last program in the pipeline. In particular, 842*150b7e42Smiodit should be set when executing a single program. The standard output 843*150b7e42Smiodof the program will be sent to @var{outname}, or, if @var{outname} is 844*150b7e42Smiod@code{NULL}, to the standard output of the calling program. Do @emph{not} 845*150b7e42Smiodset this bit if you want to call @code{pex_read_output} 846*150b7e42Smiod(described below). After a call to @code{pex_run} with this bit set, 847*150b7e42Smiod@var{pex_run} may no longer be called with the same @var{obj}. 848*150b7e42Smiod 849*150b7e42Smiod@vindex PEX_SEARCH 850*150b7e42Smiod@item PEX_SEARCH 851*150b7e42SmiodSearch for the program using the user's executable search path. 852*150b7e42Smiod 853*150b7e42Smiod@vindex PEX_SUFFIX 854*150b7e42Smiod@item PEX_SUFFIX 855*150b7e42Smiod@var{outname} is a suffix. See the description of @var{outname}, 856*150b7e42Smiodbelow. 857*150b7e42Smiod 858*150b7e42Smiod@vindex PEX_STDERR_TO_STDOUT 859*150b7e42Smiod@item PEX_STDERR_TO_STDOUT 860*150b7e42SmiodSend the program's standard error to standard output, if possible. 861*150b7e42Smiod 862*150b7e42Smiod@vindex PEX_BINARY_INPUT 863*150b7e42Smiod@vindex PEX_BINARY_OUTPUT 864*150b7e42Smiod@item PEX_BINARY_INPUT 865*150b7e42Smiod@itemx PEX_BINARY_OUTPUT 866*150b7e42SmiodThe standard input (output) of the program should be read (written) in 867*150b7e42Smiodbinary mode rather than text mode. These flags are ignored on systems 868*150b7e42Smiodwhich do not distinguish binary mode and text mode, such as Unix. For 869*150b7e42Smiodproper behavior these flags should match appropriately---a call to 870*150b7e42Smiod@code{pex_run} using @code{PEX_BINARY_OUTPUT} should be followed by a 871*150b7e42Smiodcall using @code{PEX_BINARY_INPUT}. 872*150b7e42Smiod@end table 873*150b7e42Smiod 874*150b7e42Smiod@var{executable} is the program to execute. @var{argv} is the set of 875*150b7e42Smiodarguments to pass to the program; normally @code{@var{argv}[0]} will 876*150b7e42Smiodbe a copy of @var{executable}. 877*150b7e42Smiod 878*150b7e42Smiod@var{outname} is used to set the name of the file to use for standard 879*150b7e42Smiodoutput. There are two cases in which no output file will be used: 880*150b7e42Smiod 881*150b7e42Smiod@enumerate 882*150b7e42Smiod@item 883*150b7e42Smiodif @code{PEX_LAST} is not set in @var{flags}, and @code{PEX_USE_PIPES} 884*150b7e42Smiodwas set in the call to @code{pex_init}, and the system supports pipes 885*150b7e42Smiod 886*150b7e42Smiod@item 887*150b7e42Smiodif @code{PEX_LAST} is set in @var{flags}, and @var{outname} is 888*150b7e42Smiod@code{NULL} 889*150b7e42Smiod@end enumerate 890*150b7e42Smiod 891*150b7e42Smiod@noindent 892*150b7e42SmiodOtherwise the code will use a file to hold standard 893*150b7e42Smiodoutput. If @code{PEX_LAST} is not set, this file is considered to be 894*150b7e42Smioda temporary file, and it will be removed when no longer needed, unless 895*150b7e42Smiod@code{PEX_SAVE_TEMPS} was set in the call to @code{pex_init}. 896*150b7e42Smiod 897*150b7e42SmiodThere are two cases to consider when setting the name of the file to 898*150b7e42Smiodhold standard output. 899*150b7e42Smiod 900*150b7e42Smiod@enumerate 901*150b7e42Smiod@item 902*150b7e42Smiod@code{PEX_SUFFIX} is set in @var{flags}. In this case 903*150b7e42Smiod@var{outname} may not be @code{NULL}. If the @var{tempbase} parameter 904*150b7e42Smiodto @code{pex_init} was not @code{NULL}, then the output file name is 905*150b7e42Smiodthe concatenation of @var{tempbase} and @var{outname}. If 906*150b7e42Smiod@var{tempbase} was @code{NULL}, then the output file name is a random 907*150b7e42Smiodfile name ending in @var{outname}. 908*150b7e42Smiod 909*150b7e42Smiod@item 910*150b7e42Smiod@code{PEX_SUFFIX} was not set in @var{flags}. In this 911*150b7e42Smiodcase, if @var{outname} is not @code{NULL}, it is used as the output 912*150b7e42Smiodfile name. If @var{outname} is @code{NULL}, and @var{tempbase} was 913*150b7e42Smiodnot NULL, the output file name is randomly chosen using 914*150b7e42Smiod@var{tempbase}. Otherwise the output file name is chosen completely 915*150b7e42Smiodat random. 916*150b7e42Smiod@end enumerate 917*150b7e42Smiod 918*150b7e42Smiod@var{errname} is the file name to use for standard error output. If 919*150b7e42Smiodit is @code{NULL}, standard error is the same as the caller's. 920*150b7e42SmiodOtherwise, standard error is written to the named file. 921*150b7e42Smiod 922*150b7e42SmiodOn an error return, the code sets @code{*@var{err}} to an @code{errno} 923*150b7e42Smiodvalue, or to 0 if there is no relevant @code{errno}. 924*150b7e42Smiod 925*150b7e42Smiod@end deftypefn 926*150b7e42Smiod 927*150b7e42Smiod@c pexecute.txh:249 928*150b7e42Smiod@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) 929*150b7e42Smiod 930*150b7e42SmiodThis is the old interface to execute one or more programs. It is 931*150b7e42Smiodstill supported for compatibility purposes, but is no longer 932*150b7e42Smioddocumented. 933*150b7e42Smiod 934*150b7e42Smiod@end deftypefn 935*150b7e42Smiod 936*150b7e42Smiod@c strsignal.c:539 9379588ddcfSespie@deftypefn Supplemental void psignal (unsigned @var{signo}, char *@var{message}) 9389588ddcfSespie 9399588ddcfSespiePrint @var{message} to the standard error, followed by a colon, 9409588ddcfSespiefollowed by the description of the signal specified by @var{signo}, 9419588ddcfSespiefollowed by a newline. 9429588ddcfSespie 9439588ddcfSespie@end deftypefn 9449588ddcfSespie 9459588ddcfSespie@c putenv.c:21 9469588ddcfSespie@deftypefn Supplemental int putenv (const char *@var{string}) 9479588ddcfSespie 9489588ddcfSespieUses @code{setenv} or @code{unsetenv} to put @var{string} into 9499588ddcfSespiethe environment or remove it. If @var{string} is of the form 9509588ddcfSespie@samp{name=value} the string is added; if no @samp{=} is present the 9519588ddcfSespiename is unset/removed. 9529588ddcfSespie 9539588ddcfSespie@end deftypefn 9549588ddcfSespie 955*150b7e42Smiod@c pexecute.txh:257 9569588ddcfSespie@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags}) 9579588ddcfSespie 958*150b7e42SmiodAnother part of the old execution interface. 9599588ddcfSespie 9609588ddcfSespie@end deftypefn 9619588ddcfSespie 9629588ddcfSespie@c random.c:39 9639588ddcfSespie@deftypefn Supplement {long int} random (void) 9649588ddcfSespie@deftypefnx Supplement void srandom (unsigned int @var{seed}) 9659588ddcfSespie@deftypefnx Supplement void* initstate (unsigned int @var{seed}, void *@var{arg_state}, unsigned long @var{n}) 9669588ddcfSespie@deftypefnx Supplement void* setstate (void *@var{arg_state}) 9679588ddcfSespie 9689588ddcfSespieRandom number functions. @code{random} returns a random number in the 9699588ddcfSespierange 0 to @code{LONG_MAX}. @code{srandom} initializes the random 9709588ddcfSespienumber generator to some starting point determined by @var{seed} 9719588ddcfSespie(else, the values returned by @code{random} are always the same for each 9729588ddcfSespierun of the program). @code{initstate} and @code{setstate} allow fine-grained 9739588ddcfSespiecontrol over the state of the random number generator. 9749588ddcfSespie 9759588ddcfSespie@end deftypefn 9769588ddcfSespie 977*150b7e42Smiod@c concat.c:173 9789588ddcfSespie@deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @dots{}, @code{NULL}) 9799588ddcfSespie 9809588ddcfSespieSame as @code{concat}, except that if @var{optr} is not @code{NULL} it 9819588ddcfSespieis freed after the string is created. This is intended to be useful 9829588ddcfSespiewhen you're extending an existing string or building up a string in a 9839588ddcfSespieloop: 9849588ddcfSespie 9859588ddcfSespie@example 9869588ddcfSespie str = reconcat (str, "pre-", str, NULL); 9879588ddcfSespie@end example 9889588ddcfSespie 9899588ddcfSespie@end deftypefn 9909588ddcfSespie 9919588ddcfSespie@c rename.c:6 9929588ddcfSespie@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new}) 9939588ddcfSespie 9949588ddcfSespieRenames a file from @var{old} to @var{new}. If @var{new} already 9959588ddcfSespieexists, it is removed. 9969588ddcfSespie 9979588ddcfSespie@end deftypefn 9989588ddcfSespie 9999588ddcfSespie@c rindex.c:5 10009588ddcfSespie@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c}) 10019588ddcfSespie 10029588ddcfSespieReturns a pointer to the last occurrence of the character @var{c} in 10039588ddcfSespiethe string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is 10049588ddcfSespiedeprecated in new programs in favor of @code{strrchr}. 10059588ddcfSespie 10069588ddcfSespie@end deftypefn 10079588ddcfSespie 10089588ddcfSespie@c setenv.c:22 10099588ddcfSespie@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite}) 10109588ddcfSespie@deftypefnx Supplemental void unsetenv (const char *@var{name}) 10119588ddcfSespie 10129588ddcfSespie@code{setenv} adds @var{name} to the environment with value 10139588ddcfSespie@var{value}. If the name was already present in the environment, 10149588ddcfSespiethe new value will be stored only if @var{overwrite} is nonzero. 10159588ddcfSespieThe companion @code{unsetenv} function removes @var{name} from the 10169588ddcfSespieenvironment. This implementation is not safe for multithreaded code. 10179588ddcfSespie 10189588ddcfSespie@end deftypefn 10199588ddcfSespie 1020*150b7e42Smiod@c strsignal.c:348 10219588ddcfSespie@deftypefn Extension int signo_max (void) 10229588ddcfSespie 10239588ddcfSespieReturns the maximum signal value for which a corresponding symbolic 10249588ddcfSespiename or message is available. Note that in the case where we use the 10259588ddcfSespie@code{sys_siglist} supplied by the system, it is possible for there to 10269588ddcfSespiebe more symbolic names than messages, or vice versa. In fact, the 10279588ddcfSespiemanual page for @code{psignal(3b)} explicitly warns that one should 10289588ddcfSespiecheck the size of the table (@code{NSIG}) before indexing it, since 10299588ddcfSespienew signal codes may be added to the system before they are added to 10309588ddcfSespiethe table. Thus @code{NSIG} might be smaller than value implied by 10319588ddcfSespiethe largest signo value defined in @code{<signal.h>}. 10329588ddcfSespie 10339588ddcfSespieWe return the maximum value that can be used to obtain a meaningful 10349588ddcfSespiesymbolic name or message. 10359588ddcfSespie 10369588ddcfSespie@end deftypefn 10379588ddcfSespie 10389588ddcfSespie@c sigsetmask.c:8 10399588ddcfSespie@deftypefn Supplemental int sigsetmask (int @var{set}) 10409588ddcfSespie 10419588ddcfSespieSets the signal mask to the one provided in @var{set} and returns 10429588ddcfSespiethe old mask (which, for libiberty's implementation, will always 10439588ddcfSespiebe the value @code{1}). 10449588ddcfSespie 10459588ddcfSespie@end deftypefn 10469588ddcfSespie 104725e200daSespie@c snprintf.c:28 104825e200daSespie@deftypefn Supplemental int snprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, ...) 104925e200daSespie 105025e200daSespieThis function is similar to sprintf, but it will print at most @var{n} 105125e200daSespiecharacters. On error the return value is -1, otherwise it returns the 105225e200daSespienumber of characters that would have been printed had @var{n} been 105325e200daSespiesufficiently large, regardless of the actual value of @var{n}. Note 105425e200daSespiesome pre-C99 system libraries do not implement this correctly so users 105525e200daSespiecannot generally rely on the return value if the system version of 105625e200daSespiethis function is used. 105725e200daSespie 105825e200daSespie@end deftypefn 105925e200daSespie 10609588ddcfSespie@c spaces.c:22 10619588ddcfSespie@deftypefn Extension char* spaces (int @var{count}) 10629588ddcfSespie 10639588ddcfSespieReturns a pointer to a memory region filled with the specified 10649588ddcfSespienumber of spaces and null terminated. The returned pointer is 10659588ddcfSespievalid until at least the next call. 10669588ddcfSespie 10679588ddcfSespie@end deftypefn 10689588ddcfSespie 106925e200daSespie@c stpcpy.c:23 107025e200daSespie@deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) 107125e200daSespie 107225e200daSespieCopies the string @var{src} into @var{dst}. Returns a pointer to 107325e200daSespie@var{dst} + strlen(@var{src}). 107425e200daSespie 107525e200daSespie@end deftypefn 107625e200daSespie 107725e200daSespie@c stpncpy.c:23 107825e200daSespie@deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, size_t @var{len}) 107925e200daSespie 108025e200daSespieCopies the string @var{src} into @var{dst}, copying exactly @var{len} 108125e200daSespieand padding with zeros if necessary. If @var{len} < strlen(@var{src}) 108225e200daSespiethen return @var{dst} + @var{len}, otherwise returns @var{dst} + 108325e200daSespiestrlen(@var{src}). 108425e200daSespie 108525e200daSespie@end deftypefn 108625e200daSespie 10879588ddcfSespie@c strcasecmp.c:15 10889588ddcfSespie@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2}) 10899588ddcfSespie 10909588ddcfSespieA case-insensitive @code{strcmp}. 10919588ddcfSespie 10929588ddcfSespie@end deftypefn 10939588ddcfSespie 10949588ddcfSespie@c strchr.c:6 10959588ddcfSespie@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c}) 10969588ddcfSespie 10979588ddcfSespieReturns a pointer to the first occurrence of the character @var{c} in 10989588ddcfSespiethe string @var{s}, or @code{NULL} if not found. If @var{c} is itself the 10999588ddcfSespienull character, the results are undefined. 11009588ddcfSespie 11019588ddcfSespie@end deftypefn 11029588ddcfSespie 11039588ddcfSespie@c strdup.c:3 11049588ddcfSespie@deftypefn Supplemental char* strdup (const char *@var{s}) 11059588ddcfSespie 11069588ddcfSespieReturns a pointer to a copy of @var{s} in memory obtained from 11079588ddcfSespie@code{malloc}, or @code{NULL} if insufficient memory was available. 11089588ddcfSespie 11099588ddcfSespie@end deftypefn 11109588ddcfSespie 11119588ddcfSespie@c strerror.c:670 11129588ddcfSespie@deftypefn Replacement {const char*} strerrno (int @var{errnum}) 11139588ddcfSespie 11149588ddcfSespieGiven an error number returned from a system call (typically returned 11159588ddcfSespiein @code{errno}), returns a pointer to a string containing the 11169588ddcfSespiesymbolic name of that error number, as found in @code{<errno.h>}. 11179588ddcfSespie 11189588ddcfSespieIf the supplied error number is within the valid range of indices for 11199588ddcfSespiesymbolic names, but no name is available for the particular error 11209588ddcfSespienumber, then returns the string @samp{Error @var{num}}, where @var{num} 11219588ddcfSespieis the error number. 11229588ddcfSespie 11239588ddcfSespieIf the supplied error number is not within the range of valid 11249588ddcfSespieindices, then returns @code{NULL}. 11259588ddcfSespie 11269588ddcfSespieThe contents of the location pointed to are only guaranteed to be 11279588ddcfSespievalid until the next call to @code{strerrno}. 11289588ddcfSespie 11299588ddcfSespie@end deftypefn 11309588ddcfSespie 1131*150b7e42Smiod@c strerror.c:603 11329588ddcfSespie@deftypefn Supplemental char* strerror (int @var{errnoval}) 11339588ddcfSespie 11349588ddcfSespieMaps an @code{errno} number to an error message string, the contents 11359588ddcfSespieof which are implementation defined. On systems which have the 11369588ddcfSespieexternal variables @code{sys_nerr} and @code{sys_errlist}, these 11379588ddcfSespiestrings will be the same as the ones used by @code{perror}. 11389588ddcfSespie 11399588ddcfSespieIf the supplied error number is within the valid range of indices for 11409588ddcfSespiethe @code{sys_errlist}, but no message is available for the particular 11419588ddcfSespieerror number, then returns the string @samp{Error @var{num}}, where 11429588ddcfSespie@var{num} is the error number. 11439588ddcfSespie 11449588ddcfSespieIf the supplied error number is not a valid index into 11459588ddcfSespie@code{sys_errlist}, returns @code{NULL}. 11469588ddcfSespie 11479588ddcfSespieThe returned string is only guaranteed to be valid only until the 11489588ddcfSespienext call to @code{strerror}. 11499588ddcfSespie 11509588ddcfSespie@end deftypefn 11519588ddcfSespie 11529588ddcfSespie@c strncasecmp.c:15 11539588ddcfSespie@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2}) 11549588ddcfSespie 11559588ddcfSespieA case-insensitive @code{strncmp}. 11569588ddcfSespie 11579588ddcfSespie@end deftypefn 11589588ddcfSespie 11599588ddcfSespie@c strncmp.c:6 11609588ddcfSespie@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n}) 11619588ddcfSespie 11629588ddcfSespieCompares the first @var{n} bytes of two strings, returning a value as 11639588ddcfSespie@code{strcmp}. 11649588ddcfSespie 11659588ddcfSespie@end deftypefn 11669588ddcfSespie 1167*150b7e42Smiod@c strndup.c:23 1168*150b7e42Smiod@deftypefn Extension char* strndup (const char *@var{s}, size_t @var{n}) 1169*150b7e42Smiod 1170*150b7e42SmiodReturns a pointer to a copy of @var{s} with at most @var{n} characters 1171*150b7e42Smiodin memory obtained from @code{malloc}, or @code{NULL} if insufficient 1172*150b7e42Smiodmemory was available. The result is always NUL terminated. 1173*150b7e42Smiod 1174*150b7e42Smiod@end deftypefn 1175*150b7e42Smiod 11769588ddcfSespie@c strrchr.c:6 11779588ddcfSespie@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c}) 11789588ddcfSespie 11799588ddcfSespieReturns a pointer to the last occurrence of the character @var{c} in 11809588ddcfSespiethe string @var{s}, or @code{NULL} if not found. If @var{c} is itself the 11819588ddcfSespienull character, the results are undefined. 11829588ddcfSespie 11839588ddcfSespie@end deftypefn 11849588ddcfSespie 1185*150b7e42Smiod@c strsignal.c:383 11869588ddcfSespie@deftypefn Supplemental {const char *} strsignal (int @var{signo}) 11879588ddcfSespie 11889588ddcfSespieMaps an signal number to an signal message string, the contents of 11899588ddcfSespiewhich are implementation defined. On systems which have the external 11909588ddcfSespievariable @code{sys_siglist}, these strings will be the same as the 11919588ddcfSespieones used by @code{psignal()}. 11929588ddcfSespie 11939588ddcfSespieIf the supplied signal number is within the valid range of indices for 11949588ddcfSespiethe @code{sys_siglist}, but no message is available for the particular 11959588ddcfSespiesignal number, then returns the string @samp{Signal @var{num}}, where 11969588ddcfSespie@var{num} is the signal number. 11979588ddcfSespie 11989588ddcfSespieIf the supplied signal number is not a valid index into 11999588ddcfSespie@code{sys_siglist}, returns @code{NULL}. 12009588ddcfSespie 12019588ddcfSespieThe returned string is only guaranteed to be valid only until the next 12029588ddcfSespiecall to @code{strsignal}. 12039588ddcfSespie 12049588ddcfSespie@end deftypefn 12059588ddcfSespie 1206*150b7e42Smiod@c strsignal.c:446 12079588ddcfSespie@deftypefn Extension {const char*} strsigno (int @var{signo}) 12089588ddcfSespie 12099588ddcfSespieGiven an signal number, returns a pointer to a string containing the 12109588ddcfSespiesymbolic name of that signal number, as found in @code{<signal.h>}. 12119588ddcfSespie 12129588ddcfSespieIf the supplied signal number is within the valid range of indices for 12139588ddcfSespiesymbolic names, but no name is available for the particular signal 12149588ddcfSespienumber, then returns the string @samp{Signal @var{num}}, where 12159588ddcfSespie@var{num} is the signal number. 12169588ddcfSespie 12179588ddcfSespieIf the supplied signal number is not within the range of valid 12189588ddcfSespieindices, then returns @code{NULL}. 12199588ddcfSespie 12209588ddcfSespieThe contents of the location pointed to are only guaranteed to be 12219588ddcfSespievalid until the next call to @code{strsigno}. 12229588ddcfSespie 12239588ddcfSespie@end deftypefn 12249588ddcfSespie 12259588ddcfSespie@c strstr.c:6 12269588ddcfSespie@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub}) 12279588ddcfSespie 12289588ddcfSespieThis function searches for the substring @var{sub} in the string 12299588ddcfSespie@var{string}, not including the terminating null characters. A pointer 12309588ddcfSespieto the first occurrence of @var{sub} is returned, or @code{NULL} if the 12319588ddcfSespiesubstring is absent. If @var{sub} points to a string with zero 12329588ddcfSespielength, the function returns @var{string}. 12339588ddcfSespie 12349588ddcfSespie@end deftypefn 12359588ddcfSespie 12369588ddcfSespie@c strtod.c:27 12379588ddcfSespie@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr}) 12389588ddcfSespie 12399588ddcfSespieThis ISO C function converts the initial portion of @var{string} to a 12409588ddcfSespie@code{double}. If @var{endptr} is not @code{NULL}, a pointer to the 12419588ddcfSespiecharacter after the last character used in the conversion is stored in 12429588ddcfSespiethe location referenced by @var{endptr}. If no conversion is 12439588ddcfSespieperformed, zero is returned and the value of @var{string} is stored in 12449588ddcfSespiethe location referenced by @var{endptr}. 12459588ddcfSespie 12469588ddcfSespie@end deftypefn 12479588ddcfSespie 1248*150b7e42Smiod@c strerror.c:729 12499588ddcfSespie@deftypefn Extension int strtoerrno (const char *@var{name}) 12509588ddcfSespie 12519588ddcfSespieGiven the symbolic name of a error number (e.g., @code{EACCES}), map it 12529588ddcfSespieto an errno value. If no translation is found, returns 0. 12539588ddcfSespie 12549588ddcfSespie@end deftypefn 12559588ddcfSespie 12569588ddcfSespie@c strtol.c:33 12579588ddcfSespie@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base}) 12589588ddcfSespie@deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base}) 12599588ddcfSespie 12609588ddcfSespieThe @code{strtol} function converts the string in @var{string} to a 12619588ddcfSespielong integer value according to the given @var{base}, which must be 12629588ddcfSespiebetween 2 and 36 inclusive, or be the special value 0. If @var{base} 12639588ddcfSespieis 0, @code{strtol} will look for the prefixes @code{0} and @code{0x} 12649588ddcfSespieto indicate bases 8 and 16, respectively, else default to base 10. 12659588ddcfSespieWhen the base is 16 (either explicitly or implicitly), a prefix of 12669588ddcfSespie@code{0x} is allowed. The handling of @var{endptr} is as that of 12679588ddcfSespie@code{strtod} above. The @code{strtoul} function is the same, except 12689588ddcfSespiethat the converted value is unsigned. 12699588ddcfSespie 12709588ddcfSespie@end deftypefn 12719588ddcfSespie 1272*150b7e42Smiod@c strsignal.c:500 12739588ddcfSespie@deftypefn Extension int strtosigno (const char *@var{name}) 12749588ddcfSespie 12759588ddcfSespieGiven the symbolic name of a signal, map it to a signal number. If no 12769588ddcfSespietranslation is found, returns 0. 12779588ddcfSespie 12789588ddcfSespie@end deftypefn 12799588ddcfSespie 1280*150b7e42Smiod@c strverscmp.c:25 1281*150b7e42Smiod@deftypefun int strverscmp (const char *@var{s1}, const char *@var{s2}) 1282*150b7e42SmiodThe @code{strverscmp} function compares the string @var{s1} against 1283*150b7e42Smiod@var{s2}, considering them as holding indices/version numbers. Return 1284*150b7e42Smiodvalue follows the same conventions as found in the @code{strverscmp} 1285*150b7e42Smiodfunction. In fact, if @var{s1} and @var{s2} contain no digits, 1286*150b7e42Smiod@code{strverscmp} behaves like @code{strcmp}. 1287*150b7e42Smiod 1288*150b7e42SmiodBasically, we compare strings normally (character by character), until 1289*150b7e42Smiodwe find a digit in each string - then we enter a special comparison 1290*150b7e42Smiodmode, where each sequence of digits is taken as a whole. If we reach the 1291*150b7e42Smiodend of these two parts without noticing a difference, we return to the 1292*150b7e42Smiodstandard comparison mode. There are two types of numeric parts: 1293*150b7e42Smiod"integral" and "fractional" (those begin with a '0'). The types 1294*150b7e42Smiodof the numeric parts affect the way we sort them: 1295*150b7e42Smiod 1296*150b7e42Smiod@itemize @bullet 1297*150b7e42Smiod@item 1298*150b7e42Smiodintegral/integral: we compare values as you would expect. 1299*150b7e42Smiod 1300*150b7e42Smiod@item 1301*150b7e42Smiodfractional/integral: the fractional part is less than the integral one. 1302*150b7e42SmiodAgain, no surprise. 1303*150b7e42Smiod 1304*150b7e42Smiod@item 1305*150b7e42Smiodfractional/fractional: the things become a bit more complex. 1306*150b7e42SmiodIf the common prefix contains only leading zeroes, the longest part is less 1307*150b7e42Smiodthan the other one; else the comparison behaves normally. 1308*150b7e42Smiod@end itemize 1309*150b7e42Smiod 1310*150b7e42Smiod@smallexample 1311*150b7e42Smiodstrverscmp ("no digit", "no digit") 1312*150b7e42Smiod @result{} 0 // @r{same behavior as strcmp.} 1313*150b7e42Smiodstrverscmp ("item#99", "item#100") 1314*150b7e42Smiod @result{} <0 // @r{same prefix, but 99 < 100.} 1315*150b7e42Smiodstrverscmp ("alpha1", "alpha001") 1316*150b7e42Smiod @result{} >0 // @r{fractional part inferior to integral one.} 1317*150b7e42Smiodstrverscmp ("part1_f012", "part1_f01") 1318*150b7e42Smiod @result{} >0 // @r{two fractional parts.} 1319*150b7e42Smiodstrverscmp ("foo.009", "foo.0") 1320*150b7e42Smiod @result{} <0 // @r{idem, but with leading zeroes only.} 1321*150b7e42Smiod@end smallexample 1322*150b7e42Smiod 1323*150b7e42SmiodThis function is especially useful when dealing with filename sorting, 1324*150b7e42Smiodbecause filenames frequently hold indices/version numbers. 1325*150b7e42Smiod@end deftypefun 1326*150b7e42Smiod 13279588ddcfSespie@c tmpnam.c:3 13289588ddcfSespie@deftypefn Supplemental char* tmpnam (char *@var{s}) 13299588ddcfSespie 13309588ddcfSespieThis function attempts to create a name for a temporary file, which 13319588ddcfSespiewill be a valid file name yet not exist when @code{tmpnam} checks for 13329588ddcfSespieit. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes, 13339588ddcfSespieor be @code{NULL}. Use of this function creates a security risk, and it must 13349588ddcfSespienot be used in new projects. Use @code{mkstemp} instead. 13359588ddcfSespie 13369588ddcfSespie@end deftypefn 13379588ddcfSespie 1338*150b7e42Smiod@c unlink-if-ordinary.c:27 1339*150b7e42Smiod@deftypefn Supplemental int unlink_if_ordinary (const char*) 1340*150b7e42Smiod 1341*150b7e42SmiodUnlinks the named file, unless it is special (e.g. a device file). 1342*150b7e42SmiodReturns 0 when the file was unlinked, a negative value (and errno set) when 1343*150b7e42Smiodthere was an error deleting the file, and a positive value if no attempt 1344*150b7e42Smiodwas made to unlink the file because it is special. 1345*150b7e42Smiod 1346*150b7e42Smiod@end deftypefn 1347*150b7e42Smiod 1348*150b7e42Smiod@c fopen_unlocked.c:31 1349*150b7e42Smiod@deftypefn Extension void unlock_std_streams (void) 1350*150b7e42Smiod 1351*150b7e42SmiodIf the OS supports it, ensure that the standard I/O streams, 1352*150b7e42Smiod@code{stdin}, @code{stdout} and @code{stderr} are setup to avoid any 1353*150b7e42Smiodmulti-threaded locking. Otherwise do nothing. 1354*150b7e42Smiod 1355*150b7e42Smiod@end deftypefn 1356*150b7e42Smiod 1357*150b7e42Smiod@c fopen_unlocked.c:23 1358*150b7e42Smiod@deftypefn Extension void unlock_stream (FILE * @var{stream}) 1359*150b7e42Smiod 1360*150b7e42SmiodIf the OS supports it, ensure that the supplied stream is setup to 1361*150b7e42Smiodavoid any multi-threaded locking. Otherwise leave the @code{FILE} 1362*150b7e42Smiodpointer unchanged. If the @var{stream} is @code{NULL} do nothing. 1363*150b7e42Smiod 1364*150b7e42Smiod@end deftypefn 1365*150b7e42Smiod 1366*150b7e42Smiod@c vasprintf.c:47 13679588ddcfSespie@deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args}) 13689588ddcfSespie 13699588ddcfSespieLike @code{vsprintf}, but instead of passing a pointer to a buffer, 13709588ddcfSespieyou pass a pointer to a pointer. This function will compute the size 13719588ddcfSespieof the buffer needed, allocate memory with @code{malloc}, and store a 13729588ddcfSespiepointer to the allocated memory in @code{*@var{resptr}}. The value 13739588ddcfSespiereturned is the same as @code{vsprintf} would return. If memory could 1374*150b7e42Smiodnot be allocated, minus one is returned and @code{NULL} is stored in 13759588ddcfSespie@code{*@var{resptr}}. 13769588ddcfSespie 13779588ddcfSespie@end deftypefn 13789588ddcfSespie 13799588ddcfSespie@c vfork.c:6 13809588ddcfSespie@deftypefn Supplemental int vfork (void) 13819588ddcfSespie 13829588ddcfSespieEmulates @code{vfork} by calling @code{fork} and returning its value. 13839588ddcfSespie 13849588ddcfSespie@end deftypefn 13859588ddcfSespie 13869588ddcfSespie@c vprintf.c:3 13879588ddcfSespie@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap}) 13889588ddcfSespie@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap}) 13899588ddcfSespie@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap}) 13909588ddcfSespie 13919588ddcfSespieThese functions are the same as @code{printf}, @code{fprintf}, and 13929588ddcfSespie@code{sprintf}, respectively, except that they are called with a 13939588ddcfSespie@code{va_list} instead of a variable number of arguments. Note that 13949588ddcfSespiethey do not call @code{va_end}; this is the application's 13959588ddcfSespieresponsibility. In @libib{} they are implemented in terms of the 13969588ddcfSespienonstandard but common function @code{_doprnt}. 13979588ddcfSespie 13989588ddcfSespie@end deftypefn 13999588ddcfSespie 140025e200daSespie@c vsnprintf.c:28 140125e200daSespie@deftypefn Supplemental int vsnprintf (char *@var{buf}, size_t @var{n}, const char *@var{format}, va_list @var{ap}) 140225e200daSespie 140325e200daSespieThis function is similar to vsprintf, but it will print at most 140425e200daSespie@var{n} characters. On error the return value is -1, otherwise it 140525e200daSespiereturns the number of characters that would have been printed had 140625e200daSespie@var{n} been sufficiently large, regardless of the actual value of 140725e200daSespie@var{n}. Note some pre-C99 system libraries do not implement this 140825e200daSespiecorrectly so users cannot generally rely on the return value if the 140925e200daSespiesystem version of this function is used. 141025e200daSespie 141125e200daSespie@end deftypefn 141225e200daSespie 14139588ddcfSespie@c waitpid.c:3 14149588ddcfSespie@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int) 14159588ddcfSespie 14169588ddcfSespieThis is a wrapper around the @code{wait} function. Any ``special'' 14179588ddcfSespievalues of @var{pid} depend on your implementation of @code{wait}, as 14189588ddcfSespiedoes the return value. The third argument is unused in @libib{}. 14199588ddcfSespie 14209588ddcfSespie@end deftypefn 14219588ddcfSespie 14229588ddcfSespie@c xatexit.c:11 14239588ddcfSespie@deftypefun int xatexit (void (*@var{fn}) (void)) 14249588ddcfSespie 14259588ddcfSespieBehaves as the standard @code{atexit} function, but with no limit on 14269588ddcfSespiethe number of registered functions. Returns 0 on success, or @minus{}1 on 14279588ddcfSespiefailure. If you use @code{xatexit} to register functions, you must use 14289588ddcfSespie@code{xexit} to terminate your program. 14299588ddcfSespie 14309588ddcfSespie@end deftypefun 14319588ddcfSespie 14329588ddcfSespie@c xmalloc.c:38 14339588ddcfSespie@deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize}) 14349588ddcfSespie 14359588ddcfSespieAllocate memory without fail, and set it to zero. This routine functions 14369588ddcfSespielike @code{calloc}, but will behave the same as @code{xmalloc} if memory 14379588ddcfSespiecannot be found. 14389588ddcfSespie 14399588ddcfSespie@end deftypefn 14409588ddcfSespie 14419588ddcfSespie@c xexit.c:22 14429588ddcfSespie@deftypefn Replacement void xexit (int @var{code}) 14439588ddcfSespie 14449588ddcfSespieTerminates the program. If any functions have been registered with 14459588ddcfSespiethe @code{xatexit} replacement function, they will be called first. 14469588ddcfSespieTermination is handled via the system's normal @code{exit} call. 14479588ddcfSespie 14489588ddcfSespie@end deftypefn 14499588ddcfSespie 14509588ddcfSespie@c xmalloc.c:22 14519588ddcfSespie@deftypefn Replacement void* xmalloc (size_t) 14529588ddcfSespie 14539588ddcfSespieAllocate memory without fail. If @code{malloc} fails, this will print 14549588ddcfSespiea message to @code{stderr} (using the name set by 14559588ddcfSespie@code{xmalloc_set_program_name}, 14569588ddcfSespieif any) and then call @code{xexit}. Note that it is therefore safe for 14579588ddcfSespiea program to contain @code{#define malloc xmalloc} in its source. 14589588ddcfSespie 14599588ddcfSespie@end deftypefn 14609588ddcfSespie 14619588ddcfSespie@c xmalloc.c:53 14629588ddcfSespie@deftypefn Replacement void xmalloc_failed (size_t) 14639588ddcfSespie 14649588ddcfSespieThis function is not meant to be called by client code, and is listed 14659588ddcfSespiehere for completeness only. If any of the allocation routines fail, this 14669588ddcfSespiefunction will be called to print an error message and terminate execution. 14679588ddcfSespie 14689588ddcfSespie@end deftypefn 14699588ddcfSespie 14709588ddcfSespie@c xmalloc.c:46 14719588ddcfSespie@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name}) 14729588ddcfSespie 14739588ddcfSespieYou can use this to set the name of the program used by 14749588ddcfSespie@code{xmalloc_failed} when printing a failure message. 14759588ddcfSespie 14769588ddcfSespie@end deftypefn 14779588ddcfSespie 14789588ddcfSespie@c xmemdup.c:7 14799588ddcfSespie@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size}) 14809588ddcfSespie 14819588ddcfSespieDuplicates a region of memory without fail. First, @var{alloc_size} bytes 14829588ddcfSespieare allocated, then @var{copy_size} bytes from @var{input} are copied into 14839588ddcfSespieit, and the new memory is returned. If fewer bytes are copied than were 14849588ddcfSespieallocated, the remaining memory is zeroed. 14859588ddcfSespie 14869588ddcfSespie@end deftypefn 14879588ddcfSespie 14889588ddcfSespie@c xmalloc.c:32 14899588ddcfSespie@deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size}) 14909588ddcfSespieReallocate memory without fail. This routine functions like @code{realloc}, 14919588ddcfSespiebut will behave the same as @code{xmalloc} if memory cannot be found. 14929588ddcfSespie 14939588ddcfSespie@end deftypefn 14949588ddcfSespie 14959588ddcfSespie@c xstrdup.c:7 14969588ddcfSespie@deftypefn Replacement char* xstrdup (const char *@var{s}) 14979588ddcfSespie 14989588ddcfSespieDuplicates a character string without fail, using @code{xmalloc} to 14999588ddcfSespieobtain memory. 15009588ddcfSespie 15019588ddcfSespie@end deftypefn 15029588ddcfSespie 15039588ddcfSespie@c xstrerror.c:7 15049588ddcfSespie@deftypefn Replacement char* xstrerror (int @var{errnum}) 15059588ddcfSespie 15069588ddcfSespieBehaves exactly like the standard @code{strerror} function, but 15079588ddcfSespiewill never return a @code{NULL} pointer. 15089588ddcfSespie 15099588ddcfSespie@end deftypefn 15109588ddcfSespie 1511*150b7e42Smiod@c xstrndup.c:23 1512*150b7e42Smiod@deftypefn Replacement char* xstrndup (const char *@var{s}, size_t @var{n}) 1513*150b7e42Smiod 1514*150b7e42SmiodReturns a pointer to a copy of @var{s} with at most @var{n} characters 1515*150b7e42Smiodwithout fail, using @code{xmalloc} to obtain memory. The result is 1516*150b7e42Smiodalways NUL terminated. 1517*150b7e42Smiod 1518*150b7e42Smiod@end deftypefn 1519*150b7e42Smiod 15209588ddcfSespie 1521