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