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