string.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /* Copyright (C) 1991-1993,1995-2004,2007,2009,2010
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /*
  17. * ISO C99 Standard: 7.21 String handling <string.h>
  18. */
  19. #ifndef _STRING_H
  20. #define _STRING_H 1
  21. #include <features.h>
  22. __BEGIN_DECLS
  23. /* Get size_t and NULL from <stddef.h>. */
  24. #define __need_size_t
  25. #define __need_NULL
  26. #include <stddef.h>
  27. /* Tell the caller that we provide correct C++ prototypes. */
  28. #if defined __cplusplus && __GNUC_PREREQ (4, 4)
  29. # define __CORRECT_ISO_CPP_STRING_H_PROTO
  30. #endif
  31. __BEGIN_NAMESPACE_STD
  32. /* Copy N bytes of SRC to DEST. */
  33. extern void *memcpy (void *__restrict __dest,
  34. __const void *__restrict __src, size_t __n)
  35. __THROW __nonnull ((1, 2));
  36. /* Copy N bytes of SRC to DEST, guaranteeing
  37. correct behavior for overlapping strings. */
  38. extern void *memmove (void *__dest, __const void *__src, size_t __n)
  39. __THROW __nonnull ((1, 2));
  40. __END_NAMESPACE_STD
  41. /* Copy no more than N bytes of SRC to DEST, stopping when C is found.
  42. Return the position in DEST one byte past where C was copied,
  43. or NULL if C was not found in the first N bytes of SRC. */
  44. #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
  45. extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
  46. int __c, size_t __n)
  47. __THROW __nonnull ((1, 2));
  48. #endif /* SVID. */
  49. __BEGIN_NAMESPACE_STD
  50. /* Set N bytes of S to C. */
  51. extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
  52. /* Compare N bytes of S1 and S2. */
  53. extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
  54. __THROW __attribute_pure__ __nonnull ((1, 2));
  55. /* Search N bytes of S for C. */
  56. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  57. extern "C++"
  58. {
  59. extern void *memchr (void *__s, int __c, size_t __n)
  60. __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
  61. extern __const void *memchr (__const void *__s, int __c, size_t __n)
  62. __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
  63. # ifdef __OPTIMIZE__
  64. __extern_always_inline void *
  65. memchr (void *__s, int __c, size_t __n) __THROW
  66. {
  67. return __builtin_memchr (__s, __c, __n);
  68. }
  69. __extern_always_inline __const void *
  70. memchr (__const void *__s, int __c, size_t __n) __THROW
  71. {
  72. return __builtin_memchr (__s, __c, __n);
  73. }
  74. # endif
  75. }
  76. #else
  77. extern void *memchr (__const void *__s, int __c, size_t __n)
  78. __THROW __attribute_pure__ __nonnull ((1));
  79. #endif
  80. __END_NAMESPACE_STD
  81. #ifdef __USE_GNU
  82. /* Search in S for C. This is similar to `memchr' but there is no
  83. length limit. */
  84. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  85. extern "C++" void *rawmemchr (void *__s, int __c)
  86. __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
  87. extern "C++" __const void *rawmemchr (__const void *__s, int __c)
  88. __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
  89. # else
  90. extern void *rawmemchr (__const void *__s, int __c)
  91. __THROW __attribute_pure__ __nonnull ((1));
  92. # endif
  93. /* Search N bytes of S for the final occurrence of C. */
  94. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  95. extern "C++" void *memrchr (void *__s, int __c, size_t __n)
  96. __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
  97. extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n)
  98. __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
  99. # else
  100. extern void *memrchr (__const void *__s, int __c, size_t __n)
  101. __THROW __attribute_pure__ __nonnull ((1));
  102. # endif
  103. #endif
  104. __BEGIN_NAMESPACE_STD
  105. /* Copy SRC to DEST. */
  106. extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
  107. __THROW __nonnull ((1, 2));
  108. /* Copy no more than N characters of SRC to DEST. */
  109. extern char *strncpy (char *__restrict __dest,
  110. __const char *__restrict __src, size_t __n)
  111. __THROW __nonnull ((1, 2));
  112. /* Append SRC onto DEST. */
  113. extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
  114. __THROW __nonnull ((1, 2));
  115. /* Append no more than N characters from SRC onto DEST. */
  116. extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
  117. size_t __n) __THROW __nonnull ((1, 2));
  118. /* Compare S1 and S2. */
  119. extern int strcmp (__const char *__s1, __const char *__s2)
  120. __THROW __attribute_pure__ __nonnull ((1, 2));
  121. /* Compare N characters of S1 and S2. */
  122. extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
  123. __THROW __attribute_pure__ __nonnull ((1, 2));
  124. /* Compare the collated forms of S1 and S2. */
  125. extern int strcoll (__const char *__s1, __const char *__s2)
  126. __THROW __attribute_pure__ __nonnull ((1, 2));
  127. /* Put a transformation of SRC into no more than N bytes of DEST. */
  128. extern size_t strxfrm (char *__restrict __dest,
  129. __const char *__restrict __src, size_t __n)
  130. __THROW __nonnull ((2));
  131. __END_NAMESPACE_STD
  132. #ifdef __USE_XOPEN2K8
  133. /* The following functions are equivalent to the both above but they
  134. take the locale they use for the collation as an extra argument.
  135. This is not standardsized but something like will come. */
  136. # include <xlocale.h>
  137. /* Compare the collated forms of S1 and S2 using rules from L. */
  138. extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
  139. __THROW __attribute_pure__ __nonnull ((1, 2, 3));
  140. /* Put a transformation of SRC into no more than N bytes of DEST. */
  141. extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
  142. __locale_t __l) __THROW __nonnull ((2, 4));
  143. #endif
  144. #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
  145. || defined __USE_XOPEN2K8
  146. /* Duplicate S, returning an identical malloc'd string. */
  147. extern char *strdup (__const char *__s)
  148. __THROW __attribute_malloc__ __nonnull ((1));
  149. #endif
  150. /* Return a malloc'd copy of at most N bytes of STRING. The
  151. resultant string is terminated even if no null terminator
  152. appears before STRING[N]. */
  153. #if defined __USE_XOPEN2K8
  154. extern char *strndup (__const char *__string, size_t __n)
  155. __THROW __attribute_malloc__ __nonnull ((1));
  156. #endif
  157. #if defined __USE_GNU && defined __GNUC__
  158. /* Duplicate S, returning an identical alloca'd string. */
  159. # define strdupa(s) \
  160. (__extension__ \
  161. ({ \
  162. __const char *__old = (s); \
  163. size_t __len = strlen (__old) + 1; \
  164. char *__new = (char *) __builtin_alloca (__len); \
  165. (char *) memcpy (__new, __old, __len); \
  166. }))
  167. /* Return an alloca'd copy of at most N bytes of string. */
  168. # define strndupa(s, n) \
  169. (__extension__ \
  170. ({ \
  171. __const char *__old = (s); \
  172. size_t __len = strnlen (__old, (n)); \
  173. char *__new = (char *) __builtin_alloca (__len + 1); \
  174. __new[__len] = '\0'; \
  175. (char *) memcpy (__new, __old, __len); \
  176. }))
  177. #endif
  178. __BEGIN_NAMESPACE_STD
  179. /* Find the first occurrence of C in S. */
  180. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  181. extern "C++"
  182. {
  183. extern char *strchr (char *__s, int __c)
  184. __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
  185. extern __const char *strchr (__const char *__s, int __c)
  186. __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
  187. # ifdef __OPTIMIZE__
  188. __extern_always_inline char *
  189. strchr (char *__s, int __c) __THROW
  190. {
  191. return __builtin_strchr (__s, __c);
  192. }
  193. __extern_always_inline __const char *
  194. strchr (__const char *__s, int __c) __THROW
  195. {
  196. return __builtin_strchr (__s, __c);
  197. }
  198. # endif
  199. }
  200. #else
  201. extern char *strchr (__const char *__s, int __c)
  202. __THROW __attribute_pure__ __nonnull ((1));
  203. #endif
  204. /* Find the last occurrence of C in S. */
  205. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  206. extern "C++"
  207. {
  208. extern char *strrchr (char *__s, int __c)
  209. __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
  210. extern __const char *strrchr (__const char *__s, int __c)
  211. __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
  212. # ifdef __OPTIMIZE__
  213. __extern_always_inline char *
  214. strrchr (char *__s, int __c) __THROW
  215. {
  216. return __builtin_strrchr (__s, __c);
  217. }
  218. __extern_always_inline __const char *
  219. strrchr (__const char *__s, int __c) __THROW
  220. {
  221. return __builtin_strrchr (__s, __c);
  222. }
  223. # endif
  224. }
  225. #else
  226. extern char *strrchr (__const char *__s, int __c)
  227. __THROW __attribute_pure__ __nonnull ((1));
  228. #endif
  229. __END_NAMESPACE_STD
  230. #ifdef __USE_GNU
  231. /* This function is similar to `strchr'. But it returns a pointer to
  232. the closing NUL byte in case C is not found in S. */
  233. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  234. extern "C++" char *strchrnul (char *__s, int __c)
  235. __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
  236. extern "C++" __const char *strchrnul (__const char *__s, int __c)
  237. __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
  238. # else
  239. extern char *strchrnul (__const char *__s, int __c)
  240. __THROW __attribute_pure__ __nonnull ((1));
  241. # endif
  242. #endif
  243. __BEGIN_NAMESPACE_STD
  244. /* Return the length of the initial segment of S which
  245. consists entirely of characters not in REJECT. */
  246. extern size_t strcspn (__const char *__s, __const char *__reject)
  247. __THROW __attribute_pure__ __nonnull ((1, 2));
  248. /* Return the length of the initial segment of S which
  249. consists entirely of characters in ACCEPT. */
  250. extern size_t strspn (__const char *__s, __const char *__accept)
  251. __THROW __attribute_pure__ __nonnull ((1, 2));
  252. /* Find the first occurrence in S of any character in ACCEPT. */
  253. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  254. extern "C++"
  255. {
  256. extern char *strpbrk (char *__s, __const char *__accept)
  257. __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
  258. extern __const char *strpbrk (__const char *__s, __const char *__accept)
  259. __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
  260. # ifdef __OPTIMIZE__
  261. __extern_always_inline char *
  262. strpbrk (char *__s, __const char *__accept) __THROW
  263. {
  264. return __builtin_strpbrk (__s, __accept);
  265. }
  266. __extern_always_inline __const char *
  267. strpbrk (__const char *__s, __const char *__accept) __THROW
  268. {
  269. return __builtin_strpbrk (__s, __accept);
  270. }
  271. # endif
  272. }
  273. #else
  274. extern char *strpbrk (__const char *__s, __const char *__accept)
  275. __THROW __attribute_pure__ __nonnull ((1, 2));
  276. #endif
  277. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  278. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  279. extern "C++"
  280. {
  281. extern char *strstr (char *__haystack, __const char *__needle)
  282. __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
  283. extern __const char *strstr (__const char *__haystack,
  284. __const char *__needle)
  285. __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
  286. # ifdef __OPTIMIZE__
  287. __extern_always_inline char *
  288. strstr (char *__haystack, __const char *__needle) __THROW
  289. {
  290. return __builtin_strstr (__haystack, __needle);
  291. }
  292. __extern_always_inline __const char *
  293. strstr (__const char *__haystack, __const char *__needle) __THROW
  294. {
  295. return __builtin_strstr (__haystack, __needle);
  296. }
  297. # endif
  298. }
  299. #else
  300. extern char *strstr (__const char *__haystack, __const char *__needle)
  301. __THROW __attribute_pure__ __nonnull ((1, 2));
  302. #endif
  303. /* Divide S into tokens separated by characters in DELIM. */
  304. extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
  305. __THROW __nonnull ((2));
  306. __END_NAMESPACE_STD
  307. /* Divide S into tokens separated by characters in DELIM. Information
  308. passed between calls are stored in SAVE_PTR. */
  309. extern char *__strtok_r (char *__restrict __s,
  310. __const char *__restrict __delim,
  311. char **__restrict __save_ptr)
  312. __THROW __nonnull ((2, 3));
  313. #if defined __USE_POSIX || defined __USE_MISC
  314. extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
  315. char **__restrict __save_ptr)
  316. __THROW __nonnull ((2, 3));
  317. #endif
  318. #ifdef __USE_GNU
  319. /* Similar to `strstr' but this function ignores the case of both strings. */
  320. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  321. extern "C++" char *strcasestr (char *__haystack, __const char *__needle)
  322. __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
  323. extern "C++" __const char *strcasestr (__const char *__haystack,
  324. __const char *__needle)
  325. __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
  326. # else
  327. extern char *strcasestr (__const char *__haystack, __const char *__needle)
  328. __THROW __attribute_pure__ __nonnull ((1, 2));
  329. # endif
  330. #endif
  331. #ifdef __USE_GNU
  332. /* Find the first occurrence of NEEDLE in HAYSTACK.
  333. NEEDLE is NEEDLELEN bytes long;
  334. HAYSTACK is HAYSTACKLEN bytes long. */
  335. extern void *memmem (__const void *__haystack, size_t __haystacklen,
  336. __const void *__needle, size_t __needlelen)
  337. __THROW __attribute_pure__ __nonnull ((1, 3));
  338. /* Copy N bytes of SRC to DEST, return pointer to bytes after the
  339. last written byte. */
  340. extern void *__mempcpy (void *__restrict __dest,
  341. __const void *__restrict __src, size_t __n)
  342. __THROW __nonnull ((1, 2));
  343. extern void *mempcpy (void *__restrict __dest,
  344. __const void *__restrict __src, size_t __n)
  345. __THROW __nonnull ((1, 2));
  346. #endif
  347. __BEGIN_NAMESPACE_STD
  348. /* Return the length of S. */
  349. extern size_t strlen (__const char *__s)
  350. __THROW __attribute_pure__ __nonnull ((1));
  351. __END_NAMESPACE_STD
  352. #ifdef __USE_XOPEN2K8
  353. /* Find the length of STRING, but scan at most MAXLEN characters.
  354. If no '\0' terminator is found in that many characters, return MAXLEN. */
  355. extern size_t strnlen (__const char *__string, size_t __maxlen)
  356. __THROW __attribute_pure__ __nonnull ((1));
  357. #endif
  358. __BEGIN_NAMESPACE_STD
  359. /* Return a string describing the meaning of the `errno' code in ERRNUM. */
  360. extern char *strerror (int __errnum) __THROW;
  361. __END_NAMESPACE_STD
  362. #if defined __USE_XOPEN2K || defined __USE_MISC
  363. /* Reentrant version of `strerror'.
  364. There are 2 flavors of `strerror_r', GNU which returns the string
  365. and may or may not use the supplied temporary buffer and POSIX one
  366. which fills the string into the buffer.
  367. To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
  368. without -D_GNU_SOURCE is needed, otherwise the GNU version is
  369. preferred. */
  370. # if defined __USE_XOPEN2K && !defined __USE_GNU
  371. /* Fill BUF with a string describing the meaning of the `errno' code in
  372. ERRNUM. */
  373. # ifdef __REDIRECT_NTH
  374. extern int __REDIRECT_NTH (strerror_r,
  375. (int __errnum, char *__buf, size_t __buflen),
  376. __xpg_strerror_r) __nonnull ((2));
  377. # else
  378. extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
  379. __THROW __nonnull ((2));
  380. # define strerror_r __xpg_strerror_r
  381. # endif
  382. # else
  383. /* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
  384. used. */
  385. extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
  386. __THROW __nonnull ((2));
  387. # endif
  388. #endif
  389. #ifdef __USE_XOPEN2K8
  390. /* Translate error number to string according to the locale L. */
  391. extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
  392. #endif
  393. /* We define this function always since `bzero' is sometimes needed when
  394. the namespace rules does not allow this. */
  395. extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
  396. #ifdef __USE_BSD
  397. /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
  398. extern void bcopy (__const void *__src, void *__dest, size_t __n)
  399. __THROW __nonnull ((1, 2));
  400. /* Set N bytes of S to 0. */
  401. extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
  402. /* Compare N bytes of S1 and S2 (same as memcmp). */
  403. extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
  404. __THROW __attribute_pure__ __nonnull ((1, 2));
  405. /* Find the first occurrence of C in S (same as strchr). */
  406. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  407. extern "C++"
  408. {
  409. extern char *index (char *__s, int __c)
  410. __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
  411. extern __const char *index (__const char *__s, int __c)
  412. __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
  413. # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
  414. __extern_always_inline char *
  415. index (char *__s, int __c) __THROW
  416. {
  417. return __builtin_index (__s, __c);
  418. }
  419. __extern_always_inline __const char *
  420. index (__const char *__s, int __c) __THROW
  421. {
  422. return __builtin_index (__s, __c);
  423. }
  424. # endif
  425. }
  426. # else
  427. extern char *index (__const char *__s, int __c)
  428. __THROW __attribute_pure__ __nonnull ((1));
  429. # endif
  430. /* Find the last occurrence of C in S (same as strrchr). */
  431. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  432. extern "C++"
  433. {
  434. extern char *rindex (char *__s, int __c)
  435. __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
  436. extern __const char *rindex (__const char *__s, int __c)
  437. __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
  438. # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO
  439. __extern_always_inline char *
  440. rindex (char *__s, int __c) __THROW
  441. {
  442. return __builtin_rindex (__s, __c);
  443. }
  444. __extern_always_inline __const char *
  445. rindex (__const char *__s, int __c) __THROW
  446. {
  447. return __builtin_rindex (__s, __c);
  448. }
  449. #endif
  450. }
  451. # else
  452. extern char *rindex (__const char *__s, int __c)
  453. __THROW __attribute_pure__ __nonnull ((1));
  454. # endif
  455. /* Return the position of the first bit set in I, or 0 if none are set.
  456. The least-significant bit is position 1, the most-significant 32. */
  457. extern int ffs (int __i) __THROW __attribute__ ((__const__));
  458. /* The following two functions are non-standard but necessary for non-32 bit
  459. platforms. */
  460. # ifdef __USE_GNU
  461. extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
  462. # ifdef __GNUC__
  463. __extension__ extern int ffsll (long long int __ll)
  464. __THROW __attribute__ ((__const__));
  465. # endif
  466. # endif
  467. /* Compare S1 and S2, ignoring case. */
  468. extern int strcasecmp (__const char *__s1, __const char *__s2)
  469. __THROW __attribute_pure__ __nonnull ((1, 2));
  470. /* Compare no more than N chars of S1 and S2, ignoring case. */
  471. extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
  472. __THROW __attribute_pure__ __nonnull ((1, 2));
  473. #endif /* Use BSD. */
  474. #ifdef __USE_GNU
  475. /* Again versions of a few functions which use the given locale instead
  476. of the global one. */
  477. extern int strcasecmp_l (__const char *__s1, __const char *__s2,
  478. __locale_t __loc)
  479. __THROW __attribute_pure__ __nonnull ((1, 2, 3));
  480. extern int strncasecmp_l (__const char *__s1, __const char *__s2,
  481. size_t __n, __locale_t __loc)
  482. __THROW __attribute_pure__ __nonnull ((1, 2, 4));
  483. #endif
  484. #ifdef __USE_BSD
  485. /* Return the next DELIM-delimited token from *STRINGP,
  486. terminating it with a '\0', and update *STRINGP to point past it. */
  487. extern char *strsep (char **__restrict __stringp,
  488. __const char *__restrict __delim)
  489. __THROW __nonnull ((1, 2));
  490. #endif
  491. #ifdef __USE_XOPEN2K8
  492. /* Return a string describing the meaning of the signal number in SIG. */
  493. extern char *strsignal (int __sig) __THROW;
  494. /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
  495. extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
  496. __THROW __nonnull ((1, 2));
  497. extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
  498. __THROW __nonnull ((1, 2));
  499. /* Copy no more than N characters of SRC to DEST, returning the address of
  500. the last character written into DEST. */
  501. extern char *__stpncpy (char *__restrict __dest,
  502. __const char *__restrict __src, size_t __n)
  503. __THROW __nonnull ((1, 2));
  504. extern char *stpncpy (char *__restrict __dest,
  505. __const char *__restrict __src, size_t __n)
  506. __THROW __nonnull ((1, 2));
  507. #endif
  508. #ifdef __USE_GNU
  509. /* Compare S1 and S2 as strings holding name & indices/version numbers. */
  510. extern int strverscmp (__const char *__s1, __const char *__s2)
  511. __THROW __attribute_pure__ __nonnull ((1, 2));
  512. /* Sautee STRING briskly. */
  513. extern char *strfry (char *__string) __THROW __nonnull ((1));
  514. /* Frobnicate N bytes of S. */
  515. extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
  516. # ifndef basename
  517. /* Return the file name within directory of FILENAME. We don't
  518. declare the function if the `basename' macro is available (defined
  519. in <libgen.h>) which makes the XPG version of this function
  520. available. */
  521. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  522. extern "C++" char *basename (char *__filename)
  523. __THROW __asm ("basename") __nonnull ((1));
  524. extern "C++" __const char *basename (__const char *__filename)
  525. __THROW __asm ("basename") __nonnull ((1));
  526. # else
  527. extern char *basename (__const char *__filename) __THROW __nonnull ((1));
  528. # endif
  529. # endif
  530. #endif
  531. #if defined __GNUC__ && __GNUC__ >= 2
  532. # if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
  533. && !defined __NO_INLINE__ && !defined __cplusplus
  534. /* When using GNU CC we provide some optimized versions of selected
  535. functions from this header. There are two kinds of optimizations:
  536. - machine-dependent optimizations, most probably using inline
  537. assembler code; these might be quite expensive since the code
  538. size can increase significantly.
  539. These optimizations are not used unless the symbol
  540. __USE_STRING_INLINES
  541. is defined before including this header.
  542. - machine-independent optimizations which do not increase the
  543. code size significantly and which optimize mainly situations
  544. where one or more arguments are compile-time constants.
  545. These optimizations are used always when the compiler is
  546. taught to optimize.
  547. One can inhibit all optimizations by defining __NO_STRING_INLINES. */
  548. /* Get the machine-dependent optimizations (if any). */
  549. # include <bits/string.h>
  550. /* These are generic optimizations which do not add too much inline code. */
  551. # include <bits/string2.h>
  552. # endif
  553. # if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
  554. /* Functions with security checks. */
  555. # include <bits/string3.h>
  556. # endif
  557. #endif
  558. __END_DECLS
  559. #endif /* string.h */