functions.texi 73 KB

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