functions.texi 74 KB

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