]>
Commit | Line | Data |
---|---|---|
d614a753 | 1 | /* Copyright (C) 1991-2020 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) |
be27d08c | 56 | __THROW __nonnull ((1, 2)); |
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) | |
111 | __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)); | |
a784e502 | 112 | extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) |
d8387c7b UD |
113 | __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)); |
114 | # else | |
a784e502 | 115 | extern void *memrchr (const void *__s, int __c, size_t __n) |
be27d08c | 116 | __THROW __attribute_pure__ __nonnull ((1)); |
d8387c7b | 117 | # endif |
482eec0d UD |
118 | #endif |
119 | ||
28f540f4 RM |
120 | |
121 | /* Copy SRC to DEST. */ | |
a784e502 | 122 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src) |
be27d08c | 123 | __THROW __nonnull ((1, 2)); |
28f540f4 | 124 | /* Copy no more than N characters of SRC to DEST. */ |
c1422e5b | 125 | extern char *strncpy (char *__restrict __dest, |
a784e502 | 126 | const char *__restrict __src, size_t __n) |
be27d08c | 127 | __THROW __nonnull ((1, 2)); |
28f540f4 RM |
128 | |
129 | /* Append SRC onto DEST. */ | |
a784e502 | 130 | extern char *strcat (char *__restrict __dest, const char *__restrict __src) |
be27d08c | 131 | __THROW __nonnull ((1, 2)); |
28f540f4 | 132 | /* Append no more than N characters from SRC onto DEST. */ |
a784e502 | 133 | extern char *strncat (char *__restrict __dest, const char *__restrict __src, |
be27d08c | 134 | size_t __n) __THROW __nonnull ((1, 2)); |
28f540f4 RM |
135 | |
136 | /* Compare S1 and S2. */ | |
a784e502 | 137 | extern int strcmp (const char *__s1, const char *__s2) |
be27d08c | 138 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 | 139 | /* Compare N characters of S1 and S2. */ |
a784e502 | 140 | extern int strncmp (const char *__s1, const char *__s2, size_t __n) |
be27d08c | 141 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 RM |
142 | |
143 | /* Compare the collated forms of S1 and S2. */ | |
a784e502 | 144 | extern int strcoll (const char *__s1, const char *__s2) |
be27d08c | 145 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 | 146 | /* Put a transformation of SRC into no more than N bytes of DEST. */ |
c1422e5b | 147 | extern size_t strxfrm (char *__restrict __dest, |
a784e502 | 148 | const char *__restrict __src, size_t __n) |
be27d08c | 149 | __THROW __nonnull ((2)); |
28f540f4 | 150 | |
6cbe890a | 151 | #ifdef __USE_XOPEN2K8 |
f0be25b6 ZW |
152 | /* POSIX.1-2008 extended locale interface (see locale.h). */ |
153 | # include <bits/types/locale_t.h> | |
c84142e8 | 154 | |
7773556d | 155 | /* Compare the collated forms of S1 and S2, using sorting rules from L. */ |
af85385f | 156 | extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l) |
be27d08c | 157 | __THROW __attribute_pure__ __nonnull ((1, 2, 3)); |
7773556d ZW |
158 | /* Put a transformation of SRC into no more than N bytes of DEST, |
159 | using sorting rules from L. */ | |
a784e502 | 160 | extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, |
af85385f | 161 | locale_t __l) __THROW __nonnull ((2, 4)); |
c84142e8 UD |
162 | #endif |
163 | ||
48789000 | 164 | #if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 \ |
a8c2fa98 | 165 | || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X)) |
28f540f4 | 166 | /* Duplicate S, returning an identical malloc'd string. */ |
a784e502 | 167 | extern char *strdup (const char *__s) |
be27d08c | 168 | __THROW __attribute_malloc__ __nonnull ((1)); |
28f540f4 RM |
169 | #endif |
170 | ||
6dbe2837 RM |
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]. */ | |
a8c2fa98 | 174 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) || __GLIBC_USE (ISOC2X) |
a784e502 | 175 | extern char *strndup (const char *__string, size_t __n) |
be27d08c | 176 | __THROW __attribute_malloc__ __nonnull ((1)); |
6d52618b | 177 | #endif |
6dbe2837 | 178 | |
377a515b | 179 | #if defined __USE_GNU && defined __GNUC__ |
036cc82f | 180 | /* Duplicate S, returning an identical alloca'd string. */ |
3996f34b | 181 | # define strdupa(s) \ |
036cc82f RM |
182 | (__extension__ \ |
183 | ({ \ | |
a784e502 | 184 | const char *__old = (s); \ |
036cc82f | 185 | size_t __len = strlen (__old) + 1; \ |
8c8f3704 | 186 | char *__new = (char *) __builtin_alloca (__len); \ |
3996f34b | 187 | (char *) memcpy (__new, __old, __len); \ |
036cc82f RM |
188 | })) |
189 | ||
6dbe2837 | 190 | /* Return an alloca'd copy of at most N bytes of string. */ |
3996f34b | 191 | # define strndupa(s, n) \ |
036cc82f RM |
192 | (__extension__ \ |
193 | ({ \ | |
a784e502 | 194 | const char *__old = (s); \ |
036cc82f | 195 | size_t __len = strnlen (__old, (n)); \ |
8c8f3704 | 196 | char *__new = (char *) __builtin_alloca (__len + 1); \ |
036cc82f | 197 | __new[__len] = '\0'; \ |
3996f34b | 198 | (char *) memcpy (__new, __old, __len); \ |
036cc82f | 199 | })) |
02ac66c5 RM |
200 | #endif |
201 | ||
28f540f4 | 202 | /* Find the first occurrence of C in S. */ |
d8387c7b | 203 | #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
204 | extern "C++" |
205 | { | |
206 | extern char *strchr (char *__s, int __c) | |
d8387c7b | 207 | __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); |
a784e502 | 208 | extern const char *strchr (const char *__s, int __c) |
d8387c7b | 209 | __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); |
8585cb74 UD |
210 | |
211 | # ifdef __OPTIMIZE__ | |
212 | __extern_always_inline char * | |
213 | strchr (char *__s, int __c) __THROW | |
214 | { | |
215 | return __builtin_strchr (__s, __c); | |
216 | } | |
217 | ||
a784e502 UD |
218 | __extern_always_inline const char * |
219 | strchr (const char *__s, int __c) __THROW | |
8585cb74 UD |
220 | { |
221 | return __builtin_strchr (__s, __c); | |
222 | } | |
223 | # endif | |
224 | } | |
d8387c7b | 225 | #else |
a784e502 | 226 | extern char *strchr (const char *__s, int __c) |
be27d08c | 227 | __THROW __attribute_pure__ __nonnull ((1)); |
d8387c7b | 228 | #endif |
28f540f4 | 229 | /* Find the last occurrence of C in S. */ |
d8387c7b | 230 | #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
231 | extern "C++" |
232 | { | |
233 | extern char *strrchr (char *__s, int __c) | |
d8387c7b | 234 | __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); |
a784e502 | 235 | extern const char *strrchr (const char *__s, int __c) |
d8387c7b | 236 | __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); |
8585cb74 UD |
237 | |
238 | # ifdef __OPTIMIZE__ | |
239 | __extern_always_inline char * | |
240 | strrchr (char *__s, int __c) __THROW | |
241 | { | |
242 | return __builtin_strrchr (__s, __c); | |
243 | } | |
244 | ||
a784e502 UD |
245 | __extern_always_inline const char * |
246 | strrchr (const char *__s, int __c) __THROW | |
8585cb74 UD |
247 | { |
248 | return __builtin_strrchr (__s, __c); | |
249 | } | |
250 | # endif | |
251 | } | |
d8387c7b | 252 | #else |
a784e502 | 253 | extern char *strrchr (const char *__s, int __c) |
be27d08c | 254 | __THROW __attribute_pure__ __nonnull ((1)); |
d8387c7b | 255 | #endif |
28f540f4 | 256 | |
c4563d2d | 257 | #ifdef __USE_GNU |
557a9213 | 258 | /* This function is similar to `strchr'. But it returns a pointer to |
c4563d2d | 259 | the closing NUL byte in case C is not found in S. */ |
d8387c7b UD |
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)); | |
a784e502 | 263 | extern "C++" const char *strchrnul (const char *__s, int __c) |
d8387c7b UD |
264 | __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1)); |
265 | # else | |
a784e502 | 266 | extern char *strchrnul (const char *__s, int __c) |
be27d08c | 267 | __THROW __attribute_pure__ __nonnull ((1)); |
d8387c7b | 268 | # endif |
c4563d2d UD |
269 | #endif |
270 | ||
28f540f4 RM |
271 | /* Return the length of the initial segment of S which |
272 | consists entirely of characters not in REJECT. */ | |
a784e502 | 273 | extern size_t strcspn (const char *__s, const char *__reject) |
be27d08c | 274 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 RM |
275 | /* Return the length of the initial segment of S which |
276 | consists entirely of characters in ACCEPT. */ | |
a784e502 | 277 | extern size_t strspn (const char *__s, const char *__accept) |
be27d08c | 278 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
6d52618b | 279 | /* Find the first occurrence in S of any character in ACCEPT. */ |
d8387c7b | 280 | #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
281 | extern "C++" |
282 | { | |
a784e502 | 283 | extern char *strpbrk (char *__s, const char *__accept) |
d8387c7b | 284 | __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); |
a784e502 | 285 | extern const char *strpbrk (const char *__s, const char *__accept) |
d8387c7b | 286 | __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); |
8585cb74 UD |
287 | |
288 | # ifdef __OPTIMIZE__ | |
289 | __extern_always_inline char * | |
a784e502 | 290 | strpbrk (char *__s, const char *__accept) __THROW |
8585cb74 UD |
291 | { |
292 | return __builtin_strpbrk (__s, __accept); | |
293 | } | |
294 | ||
a784e502 UD |
295 | __extern_always_inline const char * |
296 | strpbrk (const char *__s, const char *__accept) __THROW | |
8585cb74 UD |
297 | { |
298 | return __builtin_strpbrk (__s, __accept); | |
299 | } | |
300 | # endif | |
301 | } | |
d8387c7b | 302 | #else |
a784e502 | 303 | extern char *strpbrk (const char *__s, const char *__accept) |
be27d08c | 304 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
d8387c7b | 305 | #endif |
6d52618b | 306 | /* Find the first occurrence of NEEDLE in HAYSTACK. */ |
d8387c7b | 307 | #ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
8585cb74 UD |
308 | extern "C++" |
309 | { | |
a784e502 | 310 | extern char *strstr (char *__haystack, const char *__needle) |
d8387c7b | 311 | __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); |
a784e502 | 312 | extern const char *strstr (const char *__haystack, const char *__needle) |
d8387c7b | 313 | __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); |
8585cb74 UD |
314 | |
315 | # ifdef __OPTIMIZE__ | |
316 | __extern_always_inline char * | |
a784e502 | 317 | strstr (char *__haystack, const char *__needle) __THROW |
8585cb74 UD |
318 | { |
319 | return __builtin_strstr (__haystack, __needle); | |
320 | } | |
321 | ||
a784e502 UD |
322 | __extern_always_inline const char * |
323 | strstr (const char *__haystack, const char *__needle) __THROW | |
8585cb74 UD |
324 | { |
325 | return __builtin_strstr (__haystack, __needle); | |
326 | } | |
327 | # endif | |
328 | } | |
d8387c7b | 329 | #else |
a784e502 | 330 | extern char *strstr (const char *__haystack, const char *__needle) |
be27d08c | 331 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
d8387c7b | 332 | #endif |
f4017d20 | 333 | |
f4017d20 | 334 | |
28f540f4 | 335 | /* Divide S into tokens separated by characters in DELIM. */ |
a784e502 | 336 | extern char *strtok (char *__restrict __s, const char *__restrict __delim) |
be27d08c | 337 | __THROW __nonnull ((2)); |
28f540f4 | 338 | |
59dd8641 RM |
339 | /* Divide S into tokens separated by characters in DELIM. Information |
340 | passed between calls are stored in SAVE_PTR. */ | |
c1422e5b | 341 | extern char *__strtok_r (char *__restrict __s, |
a784e502 | 342 | const char *__restrict __delim, |
be27d08c UD |
343 | char **__restrict __save_ptr) |
344 | __THROW __nonnull ((2, 3)); | |
acd7f096 | 345 | #ifdef __USE_POSIX |
a784e502 | 346 | extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, |
be27d08c UD |
347 | char **__restrict __save_ptr) |
348 | __THROW __nonnull ((2, 3)); | |
9d187dd4 | 349 | #endif |
59dd8641 | 350 | |
7a5affeb UD |
351 | #ifdef __USE_GNU |
352 | /* Similar to `strstr' but this function ignores the case of both strings. */ | |
d8387c7b | 353 | # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
a784e502 | 354 | extern "C++" char *strcasestr (char *__haystack, const char *__needle) |
d8387c7b | 355 | __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); |
a784e502 UD |
356 | extern "C++" const char *strcasestr (const char *__haystack, |
357 | const char *__needle) | |
d8387c7b UD |
358 | __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); |
359 | # else | |
a784e502 | 360 | extern char *strcasestr (const char *__haystack, const char *__needle) |
be27d08c | 361 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
d8387c7b | 362 | # endif |
7a5affeb UD |
363 | #endif |
364 | ||
9d187dd4 | 365 | #ifdef __USE_GNU |
6d52618b | 366 | /* Find the first occurrence of NEEDLE in HAYSTACK. |
28f540f4 RM |
367 | NEEDLE is NEEDLELEN bytes long; |
368 | HAYSTACK is HAYSTACKLEN bytes long. */ | |
a784e502 UD |
369 | extern void *memmem (const void *__haystack, size_t __haystacklen, |
370 | const void *__needle, size_t __needlelen) | |
be27d08c | 371 | __THROW __attribute_pure__ __nonnull ((1, 3)); |
9a0a462c UD |
372 | |
373 | /* Copy N bytes of SRC to DEST, return pointer to bytes after the | |
374 | last written byte. */ | |
c1422e5b | 375 | extern void *__mempcpy (void *__restrict __dest, |
a784e502 | 376 | const void *__restrict __src, size_t __n) |
be27d08c | 377 | __THROW __nonnull ((1, 2)); |
c1422e5b | 378 | extern void *mempcpy (void *__restrict __dest, |
a784e502 | 379 | const void *__restrict __src, size_t __n) |
be27d08c | 380 | __THROW __nonnull ((1, 2)); |
28f540f4 RM |
381 | #endif |
382 | ||
8d71c7b0 | 383 | |
28f540f4 | 384 | /* Return the length of S. */ |
a784e502 | 385 | extern size_t strlen (const char *__s) |
be27d08c | 386 | __THROW __attribute_pure__ __nonnull ((1)); |
28f540f4 | 387 | |
6cbe890a | 388 | #ifdef __USE_XOPEN2K8 |
8d71c7b0 RM |
389 | /* Find the length of STRING, but scan at most MAXLEN characters. |
390 | If no '\0' terminator is found in that many characters, return MAXLEN. */ | |
a784e502 | 391 | extern size_t strnlen (const char *__string, size_t __maxlen) |
be27d08c | 392 | __THROW __attribute_pure__ __nonnull ((1)); |
8d71c7b0 RM |
393 | #endif |
394 | ||
395 | ||
73299943 UD |
396 | /* Return a string describing the meaning of the `errno' code in ERRNUM. */ |
397 | extern char *strerror (int __errnum) __THROW; | |
acd7f096 | 398 | #ifdef __USE_XOPEN2K |
61645263 UD |
399 | /* Reentrant version of `strerror'. |
400 | There are 2 flavors of `strerror_r', GNU which returns the string | |
401 | and may or may not use the supplied temporary buffer and POSIX one | |
402 | which fills the string into the buffer. | |
403 | To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L | |
404 | without -D_GNU_SOURCE is needed, otherwise the GNU version is | |
405 | preferred. */ | |
406 | # if defined __USE_XOPEN2K && !defined __USE_GNU | |
407 | /* Fill BUF with a string describing the meaning of the `errno' code in | |
408 | ERRNUM. */ | |
f377d022 UD |
409 | # ifdef __REDIRECT_NTH |
410 | extern int __REDIRECT_NTH (strerror_r, | |
411 | (int __errnum, char *__buf, size_t __buflen), | |
be27d08c | 412 | __xpg_strerror_r) __nonnull ((2)); |
61645263 UD |
413 | # else |
414 | extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) | |
be27d08c | 415 | __THROW __nonnull ((2)); |
61645263 UD |
416 | # define strerror_r __xpg_strerror_r |
417 | # endif | |
418 | # else | |
419 | /* If a temporary buffer is required, at most BUFLEN bytes of BUF will be | |
420 | used. */ | |
be27d08c | 421 | extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) |
a3aeac40 | 422 | __THROW __nonnull ((2)) __wur; |
61645263 | 423 | # endif |
60478656 | 424 | #endif |
28f540f4 | 425 | |
6cbe890a | 426 | #ifdef __USE_XOPEN2K8 |
4a44ce79 | 427 | /* Translate error number to string according to the locale L. */ |
af85385f | 428 | extern char *strerror_l (int __errnum, locale_t __l) __THROW; |
4a44ce79 UD |
429 | #endif |
430 | ||
498afc54 | 431 | #ifdef __USE_MISC |
7b037c09 | 432 | # include <strings.h> |
28f540f4 | 433 | |
7b037c09 | 434 | /* Set N bytes of S to 0. The compiler will not delete a call to this |
ea1bd74d ZW |
435 | function, even if S is dead after the call. */ |
436 | extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1)); | |
437 | ||
28f540f4 RM |
438 | /* Return the next DELIM-delimited token from *STRINGP, |
439 | terminating it with a '\0', and update *STRINGP to point past it. */ | |
c1422e5b | 440 | extern char *strsep (char **__restrict __stringp, |
a784e502 | 441 | const char *__restrict __delim) |
be27d08c | 442 | __THROW __nonnull ((1, 2)); |
28f540f4 RM |
443 | #endif |
444 | ||
6cbe890a | 445 | #ifdef __USE_XOPEN2K8 |
28f540f4 | 446 | /* Return a string describing the meaning of the signal number in SIG. */ |
c1422e5b | 447 | extern char *strsignal (int __sig) __THROW; |
28f540f4 RM |
448 | |
449 | /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ | |
a784e502 | 450 | extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src) |
be27d08c | 451 | __THROW __nonnull ((1, 2)); |
a784e502 | 452 | extern char *stpcpy (char *__restrict __dest, const char *__restrict __src) |
be27d08c | 453 | __THROW __nonnull ((1, 2)); |
28f540f4 RM |
454 | |
455 | /* Copy no more than N characters of SRC to DEST, returning the address of | |
456 | the last character written into DEST. */ | |
c1422e5b | 457 | extern char *__stpncpy (char *__restrict __dest, |
a784e502 | 458 | const char *__restrict __src, size_t __n) |
be27d08c | 459 | __THROW __nonnull ((1, 2)); |
c1422e5b | 460 | extern char *stpncpy (char *__restrict __dest, |
a784e502 | 461 | const char *__restrict __src, size_t __n) |
be27d08c | 462 | __THROW __nonnull ((1, 2)); |
6cbe890a UD |
463 | #endif |
464 | ||
465 | #ifdef __USE_GNU | |
466 | /* Compare S1 and S2 as strings holding name & indices/version numbers. */ | |
a784e502 | 467 | extern int strverscmp (const char *__s1, const char *__s2) |
6cbe890a | 468 | __THROW __attribute_pure__ __nonnull ((1, 2)); |
28f540f4 | 469 | |
28f540f4 | 470 | /* Sautee STRING briskly. */ |
be27d08c | 471 | extern char *strfry (char *__string) __THROW __nonnull ((1)); |
28f540f4 RM |
472 | |
473 | /* Frobnicate N bytes of S. */ | |
be27d08c | 474 | extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1)); |
28f540f4 | 475 | |
92f1da4d | 476 | # ifndef basename |
dd33e89f UD |
477 | /* Return the file name within directory of FILENAME. We don't |
478 | declare the function if the `basename' macro is available (defined | |
479 | in <libgen.h>) which makes the XPG version of this function | |
480 | available. */ | |
d8387c7b UD |
481 | # ifdef __CORRECT_ISO_CPP_STRING_H_PROTO |
482 | extern "C++" char *basename (char *__filename) | |
483 | __THROW __asm ("basename") __nonnull ((1)); | |
a784e502 | 484 | extern "C++" const char *basename (const char *__filename) |
d8387c7b UD |
485 | __THROW __asm ("basename") __nonnull ((1)); |
486 | # else | |
a784e502 | 487 | extern char *basename (const char *__filename) __THROW __nonnull ((1)); |
d8387c7b | 488 | # endif |
92f1da4d | 489 | # endif |
84724245 RM |
490 | #endif |
491 | ||
155bc2a5 | 492 | #if __GNUC_PREREQ (3,4) |
5ac3ea17 | 493 | # if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function |
b5cc329c | 494 | /* Functions with security checks. */ |
09a596cc | 495 | # include <bits/string_fortified.h> |
b5cc329c | 496 | # endif |
92f1da4d UD |
497 | #endif |
498 | ||
28f540f4 RM |
499 | __END_DECLS |
500 | ||
501 | #endif /* string.h */ |