📄 functions.texi
字号:
@c Automatically generated from *.c and others (the comments before@c each entry tell you which file and where in that file). DO NOT EDIT!@c Edit the *.c files, configure with --enable-maintainer-mode,@c and let gather-docs build you a new copy.@c safe-ctype.c:25@defvr Extension HOST_CHARSETThis macro indicates the basic character set and encoding used by thehost: more precisely, the encoding used for character constants inpreprocessor @samp{#if} statements (the C "execution character set").It is defined by @file{safe-ctype.h}, and will be an integer constantwith one of the following values:@ftable @code@item HOST_CHARSET_UNKNOWNThe host character set is unknown - that is, not one of the next twopossibilities.@item HOST_CHARSET_ASCIIThe host character set is ASCII.@item HOST_CHARSET_EBCDICThe host character set is some variant of EBCDIC. (Only one of thenineteen EBCDIC varying characters is tested; exercise caution.)@end ftable@end defvr@c alloca.c:26@deftypefn Replacement void* alloca (size_t @var{size})This function allocates memory which will be automatically reclaimedafter the procedure exits. The @libib{} implementation does not freethe memory immediately but will do so eventually during subsequentcalls to this function. Memory is allocated using @code{xmalloc} undernormal circumstances.The header file @file{alloca-conf.h} can be used in conjunction with theGNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly makeavailable this function. The @code{AC_FUNC_ALLOCA} test requires thatclient code use a block of preprocessor code to be safe (see the Autoconfmanual for more); this header incorporates that logic and more, includingthe possibility of a GCC built-in function.@end deftypefn@c asprintf.c:32@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)Like @code{sprintf}, but instead of passing a pointer to a buffer, youpass a pointer to a pointer. This function will compute the size ofthe buffer needed, allocate memory with @code{malloc}, and store apointer to the allocated memory in @code{*@var{resptr}}. The valuereturned is the same as @code{sprintf} would return. If memory couldnot be allocated, minus one is returned and @code{NULL} is stored in@code{*@var{resptr}}.@end deftypefn@c atexit.c:6@deftypefn Supplemental int atexit (void (*@var{f})())Causes function @var{f} to be called at exit. Returns 0.@end deftypefn@c basename.c:6@deftypefn Supplemental char* basename (const char *@var{name})Returns a pointer to the last component of pathname @var{name}.Behavior is undefined if the pathname ends in a directory separator.@end deftypefn@c bcmp.c:6@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})Compares the first @var{count} bytes of two areas of memory. Returnszero if they are the same, nonzero otherwise. Returns zero if@var{count} is zero. A nonzero result only indicates a difference,it does not indicate any sorting order (say, by having a positiveresult mean @var{x} sorts before @var{y}).@end deftypefn@c bcopy.c:3@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})Copies @var{length} bytes from memory region @var{in} to region@var{out}. The use of @code{bcopy} is deprecated in new programs.@end deftypefn@c bsearch.c:33@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 *))Performs a search over an array of @var{nmemb} elements pointed to by@var{base} for a member that matches the object pointed to by @var{key}.The size of each member is specified by @var{size}. The array contentsshould be sorted in ascending order according to the @var{compar}comparison function. This routine should take two arguments pointing tothe @var{key} and to an array member, in that order, and should return aninteger less than, equal to, or greater than zero if the @var{key} objectis respectively less than, matching, or greater than the array member.@end deftypefn@c argv.c:124@deftypefn Extension char** buildargv (char *@var{sp})Given a pointer to a string, parse the string extracting fieldsseparated by whitespace and optionally enclosed within either singleor double quotes (which are stripped off), and build a vector ofpointers to copies of the string for each field. The input stringremains unchanged. The last element of the vector is followed by a@code{NULL} element.All of the memory for the pointer array and copies of the stringis obtained from @code{malloc}. All of the memory can be returned to thesystem with the single function call @code{freeargv}, which takes thereturned result of @code{buildargv}, as it's argument.Returns a pointer to the argument vector if successful. Returns@code{NULL} if @var{sp} is @code{NULL} or if there is insufficientmemory to complete building the argument vector.If the input is a null string (as opposed to a @code{NULL} pointer),then buildarg returns an argument vector that has one arg, a nullstring.@end deftypefn@c bzero.c:6@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})Zeros @var{count} bytes starting at @var{mem}. Use of this functionis deprecated in favor of @code{memset}.@end deftypefn@c calloc.c:6@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})Uses @code{malloc} to allocate storage for @var{nelem} objects of@var{elsize} bytes each, then zeros the memory.@end deftypefn@c choose-temp.c:42@deftypefn Extension char* choose_temp_base (void)Return a prefix for temporary file names or @code{NULL} if unable tofind one. The current directory is chosen if all else fails so theprogram is exited if a temporary directory can't be found (@code{mktemp}fails). The buffer for the result is obtained with @code{xmalloc}.This function is provided for backwards compatibility only. Its use isnot recommended.@end deftypefn@c make-temp-file.c:87@deftypefn Replacement char* choose_tmpdir ()Returns a pointer to a directory path suitable for creating temporaryfiles in.@end deftypefn@c clock.c:27@deftypefn Supplemental long clock (void)Returns an approximation of the CPU time used by the process as a@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get thenumber of seconds used.@end deftypefn@c concat.c:24@deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL})Concatenate zero or more of strings and return the result in freshly@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory isavailable. The argument list is terminated by the first @code{NULL}pointer encountered. Pointers to empty strings are ignored.@end deftypefn@c argv.c:52@deftypefn Extension char** dupargv (char **@var{vector})Duplicate an argument vector. Simply scans through @var{vector},duplicating each argument until the terminating @code{NULL} is found.Returns a pointer to the argument vector if successful. Returns@code{NULL} if there is insufficient memory to complete building theargument vector.@end deftypefn@c strerror.c:567@deftypefn Extension int errno_max (void)Returns the maximum @code{errno} value for which a correspondingsymbolic name or message is available. Note that in the case where weuse the @code{sys_errlist} supplied by the system, it is possible forthere to be more symbolic names than messages, or vice versa. Infact, the manual page for @code{perror(3C)} explicitly warns that oneshould check the size of the table (@code{sys_nerr}) before indexingit, since new error codes may be added to the system before they areadded to the table. Thus @code{sys_nerr} might be smaller than valueimplied by the largest @code{errno} value defined in @code{<errno.h>}.We return the maximum value that can be used to obtain a meaningfulsymbolic name or message.@end deftypefn@c argv.c:348@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})The @var{argcp} and @code{argvp} arguments are pointers to the usual@code{argc} and @code{argv} arguments to @code{main}. This functionlooks for arguments that begin with the character @samp{@@}. Any sucharguments are interpreted as ``response files''. The contents of theresponse file are interpreted as additional command line options. Inparticular, the file is separated into whitespace-separated strings;each such string is taken as a command-line option. The new optionsare inserted in place of the option naming the response file, and@code{*argcp} and @code{*argvp} will be updated. If the value of@code{*argvp} is modified by this function, then the new value hasbeen dynamically allocated and can be deallocated by the caller with@code{freeargv}. However, most callers will simply call@code{expandargv} near the beginning of @code{main} and allow theoperating system to free the memory when the program exits.@end deftypefn@c fdmatch.c:23@deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})Check to see if two open file descriptors refer to the same file.This is useful, for example, when we have an open file descriptor foran unnamed file, and the name of a file that we believe to correspondto that fd. This can happen when we are exec'd with an already openfile (@code{stdout} for example) or from the SVR4 @file{/proc} callsthat return open file descriptors for mapped address spaces. All wehave to do is open the file by name and check the two file descriptorsfor a match, which is done by comparing major and minor device numbersand inode numbers.@end deftypefn@c fopen_unlocked.c:48@deftypefn Extension {FILE *} fdopen_unlocked (int @var{fildes}, const char * @var{mode})Opens and returns a @code{FILE} pointer via @code{fdopen}. If theoperating system supports it, ensure that the stream is setup to avoidany multi-threaded locking. Otherwise return the @code{FILE} pointerunchanged.@end deftypefn@c ffs.c:3@deftypefn Supplemental int ffs (int @var{valu})Find the first (least significant) bit set in @var{valu}. Bits arenumbered from right to left, starting with bit 1 (corresponding to thevalue 1). If @var{valu} is zero, zero is returned.@end deftypefn@c filename_cmp.c:32@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})Return zero if the two file names @var{s1} and @var{s2} are equivalent.If not equivalent, the returned value is similar to what @code{strcmp}would return. In other words, it returns a negative value if @var{s1}is less than @var{s2}, or a positive value if @var{s2} is greater than@var{s2}.This function does not normalize file names. As a result, this functionwill treat filenames that are spelled differently as different even inthe case when the two filenames point to the same underlying file.However, it does handle the fact that on DOS-like file systems, forwardand backward slashes are equal.@end deftypefn@c fnmatch.txh:1@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})Matches @var{string} against @var{pattern}, returning zero if itmatches, @code{FNM_NOMATCH} if not. @var{pattern} may contain thewildcards @code{?} to match any one character, @code{*} to match anyzero or more characters, or a set of alternate characters in squarebrackets, like @samp{[a-gt8]}, which match one character (@code{a}through @code{g}, or @code{t}, or @code{8}, in this example) if that onecharacter is in the set. A set may be inverted (i.e., match anythingexcept what's in the set) by giving @code{^} or @code{!} as the firstcharacter in the set. To include those characters in the set, list themas anything other than the first character of the set. To include adash in the set, list it last in the set. A backslash character makesthe following character not special, so for example you could matchagainst a literal asterisk with @samp{\*}. To match a literalbackslash, use @samp{\\}.@code{flags} controls various aspects of the matching process, and is aboolean OR of zero or more of the following values (defined in@code{<fnmatch.h>}):@table @code@item FNM_PATHNAME@itemx FNM_FILE_NAME@var{string} is assumed to be a path name. No wildcard will ever match@code{/}.@item FNM_NOESCAPEDo not interpret backslashes as quoting the following special character.@item FNM_PERIODA leading period (at the beginning of @var{string}, or if@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or@code{?} but must be matched explicitly.@item FNM_LEADING_DIRMeans that @var{string} also matches @var{pattern} if some initial partof @var{string} matches, and is followed by @code{/} and zero or morecharacters. For example, @samp{foo*} would match either @samp{foobar}or @samp{foobar/grill}.@item FNM_CASEFOLDIgnores case when performing the comparison.@end table@end deftypefn@c fopen_unlocked.c:39@deftypefn Extension {FILE *} fopen_unlocked (const char *@var{path}, const char * @var{mode})Opens and returns a @code{FILE} pointer via @code{fopen}. If theoperating system supports it, ensure that the stream is setup to avoidany multi-threaded locking. Otherwise return the @code{FILE} pointerunchanged.@end deftypefn@c argv.c:97@deftypefn Extension void freeargv (char **@var{vector})Free an argument vector that was built using @code{buildargv}. Simplyscans through @var{vector}, freeing the memory for each argument untilthe terminating @code{NULL} is found, and then frees @var{vector}itself.@end deftypefn@c fopen_unlocked.c:57@deftypefn Extension {FILE *} freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream})Opens and returns a @code{FILE} pointer via @code{freopen}. If theoperating system supports it, ensure that the stream is setup to avoidany multi-threaded locking. Otherwise return the @code{FILE} pointerunchanged.@end deftypefn@c getruntime.c:82@deftypefn Replacement long get_run_time (void)Returns the time used so far, in microseconds. If possible, this isthe time used by this process, else it is the elapsed time since theprocess started.@end deftypefn@c getcwd.c:6@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})Copy the absolute pathname for the current working directory into@var{pathname}, which is assumed to point to a buffer of at least@var{len} bytes, and return a pointer to the buffer. If the currentdirectory's path doesn't fit in @var{len} characters, the result is@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer,@code{getcwd} will obtain @var{len} bytes of space using@code{malloc}.@end deftypefn@c getpagesize.c:5@deftypefn Supplemental int getpagesize (void)Returns the number of bytes in a page of memory. This is thegranularity of many of the system memory management routines. Noguarantee is made as to whether or not it is the same as the basicmemory management hardware page size.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -