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