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