string.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /* Copyright (C) 1991-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 Standard: 7.21 String handling <string.h>
  16. */
  17. #ifndef _STRING_H
  18. #define _STRING_H 1
  19. #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  20. #include <bits/libc-header-start.h>
  21. __BEGIN_DECLS
  22. #if __GLIBC_USE (ISOC23)
  23. # define __STDC_VERSION_STRING_H__ 202311L
  24. #endif
  25. /* Get size_t and NULL from <stddef.h>. */
  26. #define __need_size_t
  27. #define __need_NULL
  28. #include <stddef.h>
  29. /* Tell the caller that we provide correct C++ prototypes. */
  30. #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
  31. || __glibc_clang_prereq (3, 5))
  32. # define __CORRECT_ISO_CPP_STRING_H_PROTO
  33. #endif
  34. /* Copy N bytes of SRC to DEST. */
  35. extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
  36. size_t __n) __THROW __nonnull ((1, 2));
  37. /* Copy N bytes of SRC to DEST, guaranteeing
  38. correct behavior for overlapping strings. */
  39. extern void *memmove (void *__dest, const void *__src, size_t __n)
  40. __THROW __nonnull ((1, 2));
  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_MISC || defined __USE_XOPEN || __GLIBC_USE (ISOC23)
  45. extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
  46. int __c, size_t __n)
  47. __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 4));
  48. #endif /* Misc || X/Open. */
  49. /* Set N bytes of S to C. */
  50. extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
  51. #if defined __USE_MISC || __GLIBC_USE (ISOC23)
  52. /* Like memset, but the compiler will not delete a call to this
  53. function, even if S is dead after the call. */
  54. extern void *memset_explicit (void *__s, int __c, size_t __n)
  55. __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 3);
  56. #endif
  57. /* Compare N bytes of S1 and S2. */
  58. extern int memcmp (const void *__s1, const void *__s2, size_t __n)
  59. __THROW __attribute_pure__ __nonnull ((1, 2));
  60. /* Compare N bytes of S1 and S2. Return zero if S1 and S2 are equal.
  61. Return some non-zero value otherwise.
  62. Essentially __memcmpeq has the exact same semantics as memcmp
  63. except the return value is less constrained. memcmp is always a
  64. correct implementation of __memcmpeq. As well !!memcmp, -memcmp,
  65. or bcmp are correct implementations.
  66. __memcmpeq is meant to be used by compilers when memcmp return is
  67. only used for its boolean value.
  68. __memcmpeq is declared only for use by compilers. Programs should
  69. continue to use memcmp. */
  70. extern int __memcmpeq (const void *__s1, const void *__s2, size_t __n)
  71. __THROW __attribute_pure__ __nonnull ((1, 2));
  72. /* Search N bytes of S for C. */
  73. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  74. extern "C++"
  75. {
  76. extern void *memchr (void *__s, int __c, size_t __n)
  77. __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
  78. extern const void *memchr (const void *__s, int __c, size_t __n)
  79. __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
  80. # ifdef __OPTIMIZE__
  81. __extern_always_inline void *
  82. memchr (void *__s, int __c, size_t __n) __THROW
  83. {
  84. return __builtin_memchr (__s, __c, __n);
  85. }
  86. __extern_always_inline const void *
  87. memchr (const void *__s, int __c, size_t __n) __THROW
  88. {
  89. return __builtin_memchr (__s, __c, __n);
  90. }
  91. # endif
  92. }
  93. #else
  94. extern void *memchr (const void *__s, int __c, size_t __n)
  95. __THROW __attribute_pure__ __nonnull ((1));
  96. # if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
  97. # define memchr(S, C, N) \
  98. __glibc_const_generic (S, const void *, memchr (S, C, N))
  99. # endif
  100. #endif
  101. #ifdef __USE_GNU
  102. /* Search in S for C. This is similar to `memchr' but there is no
  103. length limit. */
  104. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  105. extern "C++" void *rawmemchr (void *__s, int __c)
  106. __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
  107. extern "C++" const void *rawmemchr (const void *__s, int __c)
  108. __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
  109. # else
  110. extern void *rawmemchr (const void *__s, int __c)
  111. __THROW __attribute_pure__ __nonnull ((1));
  112. # endif
  113. /* Search N bytes of S for the final occurrence of C. */
  114. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  115. extern "C++" void *memrchr (void *__s, int __c, size_t __n)
  116. __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1))
  117. __attr_access ((__read_only__, 1, 3));
  118. extern "C++" const void *memrchr (const void *__s, int __c, size_t __n)
  119. __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1))
  120. __attr_access ((__read_only__, 1, 3));
  121. # else
  122. extern void *memrchr (const void *__s, int __c, size_t __n)
  123. __THROW __attribute_pure__ __nonnull ((1))
  124. __attr_access ((__read_only__, 1, 3));
  125. # endif
  126. #endif
  127. /* Copy SRC to DEST. */
  128. extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
  129. __THROW __nonnull ((1, 2));
  130. /* Copy no more than N characters of SRC to DEST. */
  131. extern char *strncpy (char *__restrict __dest,
  132. const char *__restrict __src, size_t __n)
  133. __THROW __nonnull ((1, 2));
  134. /* Append SRC onto DEST. */
  135. extern char *strcat (char *__restrict __dest, const char *__restrict __src)
  136. __THROW __nonnull ((1, 2));
  137. /* Append no more than N characters from SRC onto DEST. */
  138. extern char *strncat (char *__restrict __dest, const char *__restrict __src,
  139. size_t __n) __THROW __nonnull ((1, 2));
  140. /* Compare S1 and S2. */
  141. extern int strcmp (const char *__s1, const char *__s2)
  142. __THROW __attribute_pure__ __nonnull ((1, 2));
  143. /* Compare N characters of S1 and S2. */
  144. extern int strncmp (const char *__s1, const char *__s2, size_t __n)
  145. __THROW __attribute_pure__ __nonnull ((1, 2));
  146. /* Compare the collated forms of S1 and S2. */
  147. extern int strcoll (const char *__s1, const char *__s2)
  148. __THROW __attribute_pure__ __nonnull ((1, 2));
  149. /* Put a transformation of SRC into no more than N bytes of DEST. */
  150. extern size_t strxfrm (char *__restrict __dest,
  151. const char *__restrict __src, size_t __n)
  152. __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3));
  153. #ifdef __USE_XOPEN2K8
  154. /* POSIX.1-2008 extended locale interface (see locale.h). */
  155. # include <bits/types/locale_t.h>
  156. /* Compare the collated forms of S1 and S2, using sorting rules from L. */
  157. extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
  158. __THROW __attribute_pure__ __nonnull ((1, 2, 3));
  159. /* Put a transformation of SRC into no more than N bytes of DEST,
  160. using sorting rules from L. */
  161. extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
  162. locale_t __l) __THROW __nonnull ((2, 4))
  163. __attr_access ((__write_only__, 1, 3));
  164. #endif
  165. #if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \
  166. || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC23))
  167. /* Duplicate S, returning an identical malloc'd string. */
  168. extern char *strdup (const char *__s)
  169. __THROW __attribute_malloc__ __nonnull ((1));
  170. #endif
  171. /* Return a malloc'd copy of at most N bytes of STRING. The
  172. resultant string is terminated even if no null terminator
  173. appears before STRING[N]. */
  174. #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC23)
  175. extern char *strndup (const char *__string, size_t __n)
  176. __THROW __attribute_malloc__ __nonnull ((1));
  177. #endif
  178. #if defined __USE_GNU && defined __GNUC__
  179. /* Duplicate S, returning an identical alloca'd string. */
  180. # define strdupa(s) \
  181. (__extension__ \
  182. ({ \
  183. const char *__old = (s); \
  184. size_t __len = strlen (__old) + 1; \
  185. char *__new = (char *) __builtin_alloca (__len); \
  186. (char *) memcpy (__new, __old, __len); \
  187. }))
  188. /* Return an alloca'd copy of at most N bytes of string. */
  189. # define strndupa(s, n) \
  190. (__extension__ \
  191. ({ \
  192. const char *__old = (s); \
  193. size_t __len = strnlen (__old, (n)); \
  194. char *__new = (char *) __builtin_alloca (__len + 1); \
  195. __new[__len] = '\0'; \
  196. (char *) memcpy (__new, __old, __len); \
  197. }))
  198. #endif
  199. /* Find the first occurrence of C in S. */
  200. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  201. extern "C++"
  202. {
  203. extern char *strchr (char *__s, int __c)
  204. __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
  205. extern const char *strchr (const char *__s, int __c)
  206. __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
  207. # ifdef __OPTIMIZE__
  208. __extern_always_inline char *
  209. strchr (char *__s, int __c) __THROW
  210. {
  211. return __builtin_strchr (__s, __c);
  212. }
  213. __extern_always_inline const char *
  214. strchr (const char *__s, int __c) __THROW
  215. {
  216. return __builtin_strchr (__s, __c);
  217. }
  218. # endif
  219. }
  220. #else
  221. extern char *strchr (const char *__s, int __c)
  222. __THROW __attribute_pure__ __nonnull ((1));
  223. # if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
  224. # define strchr(S, C) \
  225. __glibc_const_generic (S, const char *, strchr (S, C))
  226. # endif
  227. #endif
  228. /* Find the last occurrence of C in S. */
  229. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  230. extern "C++"
  231. {
  232. extern char *strrchr (char *__s, int __c)
  233. __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
  234. extern const char *strrchr (const char *__s, int __c)
  235. __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
  236. # ifdef __OPTIMIZE__
  237. __extern_always_inline char *
  238. strrchr (char *__s, int __c) __THROW
  239. {
  240. return __builtin_strrchr (__s, __c);
  241. }
  242. __extern_always_inline const char *
  243. strrchr (const char *__s, int __c) __THROW
  244. {
  245. return __builtin_strrchr (__s, __c);
  246. }
  247. # endif
  248. }
  249. #else
  250. extern char *strrchr (const char *__s, int __c)
  251. __THROW __attribute_pure__ __nonnull ((1));
  252. # if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
  253. # define strrchr(S, C) \
  254. __glibc_const_generic (S, const char *, strrchr (S, C))
  255. # endif
  256. #endif
  257. #ifdef __USE_MISC
  258. /* This function is similar to `strchr'. But it returns a pointer to
  259. the closing NUL byte in case C is not found in S. */
  260. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  261. extern "C++" char *strchrnul (char *__s, int __c)
  262. __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
  263. extern "C++" const char *strchrnul (const char *__s, int __c)
  264. __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
  265. # else
  266. extern char *strchrnul (const char *__s, int __c)
  267. __THROW __attribute_pure__ __nonnull ((1));
  268. # endif
  269. #endif
  270. /* Return the length of the initial segment of S which
  271. consists entirely of characters not in REJECT. */
  272. extern size_t strcspn (const char *__s, const char *__reject)
  273. __THROW __attribute_pure__ __nonnull ((1, 2));
  274. /* Return the length of the initial segment of S which
  275. consists entirely of characters in ACCEPT. */
  276. extern size_t strspn (const char *__s, const char *__accept)
  277. __THROW __attribute_pure__ __nonnull ((1, 2));
  278. /* Find the first occurrence in S of any character in ACCEPT. */
  279. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  280. extern "C++"
  281. {
  282. extern char *strpbrk (char *__s, const char *__accept)
  283. __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
  284. extern const char *strpbrk (const char *__s, const char *__accept)
  285. __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
  286. # ifdef __OPTIMIZE__
  287. __extern_always_inline char *
  288. strpbrk (char *__s, const char *__accept) __THROW
  289. {
  290. return __builtin_strpbrk (__s, __accept);
  291. }
  292. __extern_always_inline const char *
  293. strpbrk (const char *__s, const char *__accept) __THROW
  294. {
  295. return __builtin_strpbrk (__s, __accept);
  296. }
  297. # endif
  298. }
  299. #else
  300. extern char *strpbrk (const char *__s, const char *__accept)
  301. __THROW __attribute_pure__ __nonnull ((1, 2));
  302. # if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
  303. # define strpbrk(S, ACCEPT) \
  304. __glibc_const_generic (S, const char *, strpbrk (S, ACCEPT))
  305. # endif
  306. #endif
  307. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  308. #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  309. extern "C++"
  310. {
  311. extern char *strstr (char *__haystack, const char *__needle)
  312. __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
  313. extern const char *strstr (const char *__haystack, const char *__needle)
  314. __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
  315. # ifdef __OPTIMIZE__
  316. __extern_always_inline char *
  317. strstr (char *__haystack, const char *__needle) __THROW
  318. {
  319. return __builtin_strstr (__haystack, __needle);
  320. }
  321. __extern_always_inline const char *
  322. strstr (const char *__haystack, const char *__needle) __THROW
  323. {
  324. return __builtin_strstr (__haystack, __needle);
  325. }
  326. # endif
  327. }
  328. #else
  329. extern char *strstr (const char *__haystack, const char *__needle)
  330. __THROW __attribute_pure__ __nonnull ((1, 2));
  331. # if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
  332. # define strstr(HAYSTACK, NEEDLE) \
  333. __glibc_const_generic (HAYSTACK, const char *, \
  334. strstr (HAYSTACK, NEEDLE))
  335. # endif
  336. #endif
  337. /* Divide S into tokens separated by characters in DELIM. */
  338. extern char *strtok (char *__restrict __s, const char *__restrict __delim)
  339. __THROW __nonnull ((2));
  340. /* Divide S into tokens separated by characters in DELIM. Information
  341. passed between calls are stored in SAVE_PTR. */
  342. extern char *__strtok_r (char *__restrict __s,
  343. const char *__restrict __delim,
  344. char **__restrict __save_ptr)
  345. __THROW __nonnull ((2, 3));
  346. #ifdef __USE_POSIX
  347. extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
  348. char **__restrict __save_ptr)
  349. __THROW __nonnull ((2, 3));
  350. #endif
  351. #ifdef __USE_MISC
  352. /* Similar to `strstr' but this function ignores the case of both strings. */
  353. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  354. extern "C++" char *strcasestr (char *__haystack, const char *__needle)
  355. __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
  356. extern "C++" const char *strcasestr (const char *__haystack,
  357. const char *__needle)
  358. __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
  359. # else
  360. extern char *strcasestr (const char *__haystack, const char *__needle)
  361. __THROW __attribute_pure__ __nonnull ((1, 2));
  362. # endif
  363. #endif
  364. #ifdef __USE_MISC
  365. /* Find the first occurrence of NEEDLE in HAYSTACK.
  366. NEEDLE is NEEDLELEN bytes long;
  367. HAYSTACK is HAYSTACKLEN bytes long. */
  368. extern void *memmem (const void *__haystack, size_t __haystacklen,
  369. const void *__needle, size_t __needlelen)
  370. __THROW __attribute_pure__ __nonnull ((1, 3))
  371. __attr_access ((__read_only__, 1, 2))
  372. __attr_access ((__read_only__, 3, 4));
  373. /* Copy N bytes of SRC to DEST, return pointer to bytes after the
  374. last written byte. */
  375. extern void *__mempcpy (void *__restrict __dest,
  376. const void *__restrict __src, size_t __n)
  377. __THROW __nonnull ((1, 2));
  378. extern void *mempcpy (void *__restrict __dest,
  379. const void *__restrict __src, size_t __n)
  380. __THROW __nonnull ((1, 2));
  381. #endif
  382. /* Return the length of S. */
  383. extern size_t strlen (const char *__s)
  384. __THROW __attribute_pure__ __nonnull ((1));
  385. #ifdef __USE_XOPEN2K8
  386. /* Find the length of STRING, but scan at most MAXLEN characters.
  387. If no '\0' terminator is found in that many characters, return MAXLEN. */
  388. extern size_t strnlen (const char *__string, size_t __maxlen)
  389. __THROW __attribute_pure__ __nonnull ((1));
  390. #endif
  391. /* Return a string describing the meaning of the `errno' code in ERRNUM. */
  392. extern char *strerror (int __errnum) __THROW;
  393. #ifdef __USE_XOPEN2K
  394. /* Reentrant version of `strerror'.
  395. There are 2 flavors of `strerror_r', GNU which returns the string
  396. and may or may not use the supplied temporary buffer and POSIX one
  397. which fills the string into the buffer.
  398. To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
  399. without -D_GNU_SOURCE is needed, otherwise the GNU version is
  400. preferred. */
  401. # if defined __USE_XOPEN2K && !defined __USE_GNU
  402. /* Fill BUF with a string describing the meaning of the `errno' code in
  403. ERRNUM. */
  404. # ifdef __REDIRECT_NTH
  405. extern int __REDIRECT_NTH (strerror_r,
  406. (int __errnum, char *__buf, size_t __buflen),
  407. __xpg_strerror_r) __nonnull ((2))
  408. __attr_access ((__write_only__, 2, 3));
  409. # else
  410. extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
  411. __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
  412. # define strerror_r __xpg_strerror_r
  413. # endif
  414. # else
  415. /* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
  416. used. */
  417. extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
  418. __THROW __nonnull ((2)) __wur __attr_access ((__write_only__, 2, 3));
  419. # endif
  420. # ifdef __USE_GNU
  421. /* Return a string describing the meaning of tthe error in ERR. */
  422. extern const char *strerrordesc_np (int __err) __THROW;
  423. /* Return a string with the error name in ERR. */
  424. extern const char *strerrorname_np (int __err) __THROW;
  425. # endif
  426. #endif
  427. #ifdef __USE_XOPEN2K8
  428. /* Translate error number to string according to the locale L. */
  429. extern char *strerror_l (int __errnum, locale_t __l) __THROW;
  430. #endif
  431. #ifdef __USE_MISC
  432. # include <strings.h>
  433. /* Set N bytes of S to 0. The compiler will not delete a call to this
  434. function, even if S is dead after the call. */
  435. extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1))
  436. __fortified_attr_access (__write_only__, 1, 2);
  437. /* Return the next DELIM-delimited token from *STRINGP,
  438. terminating it with a '\0', and update *STRINGP to point past it. */
  439. extern char *strsep (char **__restrict __stringp,
  440. const char *__restrict __delim)
  441. __THROW __nonnull ((1, 2));
  442. #endif
  443. #ifdef __USE_XOPEN2K8
  444. /* Return a string describing the meaning of the signal number in SIG. */
  445. extern char *strsignal (int __sig) __THROW;
  446. # ifdef __USE_GNU
  447. /* Return an abbreviation string for the signal number SIG. */
  448. extern const char *sigabbrev_np (int __sig) __THROW;
  449. /* Return a string describing the meaning of the signal number in SIG,
  450. the result is not translated. */
  451. extern const char *sigdescr_np (int __sig) __THROW;
  452. # endif
  453. /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
  454. extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
  455. __THROW __nonnull ((1, 2));
  456. extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
  457. __THROW __nonnull ((1, 2));
  458. /* Copy no more than N characters of SRC to DEST, returning the address of
  459. the last character written into DEST. */
  460. extern char *__stpncpy (char *__restrict __dest,
  461. const char *__restrict __src, size_t __n)
  462. __THROW __nonnull ((1, 2));
  463. extern char *stpncpy (char *__restrict __dest,
  464. const char *__restrict __src, size_t __n)
  465. __THROW __nonnull ((1, 2));
  466. #endif
  467. #ifdef __USE_MISC
  468. /* Copy at most N - 1 characters from SRC to DEST. */
  469. extern size_t strlcpy (char *__restrict __dest,
  470. const char *__restrict __src, size_t __n)
  471. __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 3));
  472. /* Append SRC to DEST, possibly with truncation to keep the total size
  473. below N. */
  474. extern size_t strlcat (char *__restrict __dest,
  475. const char *__restrict __src, size_t __n)
  476. __THROW __nonnull ((1, 2)) __attr_access ((__read_write__, 1, 3));
  477. #endif
  478. #ifdef __USE_GNU
  479. /* Compare S1 and S2 as strings holding name & indices/version numbers. */
  480. extern int strverscmp (const char *__s1, const char *__s2)
  481. __THROW __attribute_pure__ __nonnull ((1, 2));
  482. /* Sautee STRING briskly. */
  483. extern char *strfry (char *__string) __THROW __nonnull ((1));
  484. /* Frobnicate N bytes of S. */
  485. extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1))
  486. __attr_access ((__read_write__, 1, 2));
  487. # ifndef basename
  488. /* Return the file name within directory of FILENAME. We don't
  489. declare the function if the `basename' macro is available (defined
  490. in <libgen.h>) which makes the XPG version of this function
  491. available. */
  492. # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
  493. extern "C++" char *basename (char *__filename)
  494. __THROW __asm ("basename") __nonnull ((1));
  495. extern "C++" const char *basename (const char *__filename)
  496. __THROW __asm ("basename") __nonnull ((1));
  497. # else
  498. extern char *basename (const char *__filename) __THROW __nonnull ((1));
  499. # endif
  500. # endif
  501. #endif
  502. #if __GNUC_PREREQ (3,4)
  503. # if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
  504. /* Functions with security checks. */
  505. # include <bits/string_fortified.h>
  506. # endif
  507. #endif
  508. __END_DECLS
  509. #endif /* string.h */