string.h 21 KB

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