1*53ee8cc1Swenshuai.xi /* Copyright (C) 1991-1993, 1995-2004, 2007 Free Software Foundation, Inc. 2*53ee8cc1Swenshuai.xi This file is part of the GNU C Library. 3*53ee8cc1Swenshuai.xi 4*53ee8cc1Swenshuai.xi The GNU C Library is free software; you can redistribute it and/or 5*53ee8cc1Swenshuai.xi modify it under the terms of the GNU Lesser General Public 6*53ee8cc1Swenshuai.xi License as published by the Free Software Foundation; either 7*53ee8cc1Swenshuai.xi version 2.1 of the License, or (at your option) any later version. 8*53ee8cc1Swenshuai.xi 9*53ee8cc1Swenshuai.xi The GNU C Library is distributed in the hope that it will be useful, 10*53ee8cc1Swenshuai.xi but WITHOUT ANY WARRANTY; without even the implied warranty of 11*53ee8cc1Swenshuai.xi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*53ee8cc1Swenshuai.xi Lesser General Public License for more details. 13*53ee8cc1Swenshuai.xi 14*53ee8cc1Swenshuai.xi You should have received a copy of the GNU Lesser General Public 15*53ee8cc1Swenshuai.xi License along with the GNU C Library; if not, write to the Free 16*53ee8cc1Swenshuai.xi Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17*53ee8cc1Swenshuai.xi 02111-1307 USA. */ 18*53ee8cc1Swenshuai.xi 19*53ee8cc1Swenshuai.xi /* 20*53ee8cc1Swenshuai.xi * ISO C99 Standard: 7.21 String handling <string.h> 21*53ee8cc1Swenshuai.xi */ 22*53ee8cc1Swenshuai.xi 23*53ee8cc1Swenshuai.xi #ifndef _STRING_H 24*53ee8cc1Swenshuai.xi #define _STRING_H 1 25*53ee8cc1Swenshuai.xi 26*53ee8cc1Swenshuai.xi #include <features.h> 27*53ee8cc1Swenshuai.xi 28*53ee8cc1Swenshuai.xi __BEGIN_DECLS 29*53ee8cc1Swenshuai.xi 30*53ee8cc1Swenshuai.xi /* Get size_t and NULL from <stddef.h>. */ 31*53ee8cc1Swenshuai.xi #define __need_size_t 32*53ee8cc1Swenshuai.xi #define __need_NULL 33*53ee8cc1Swenshuai.xi #include <stddef.h> 34*53ee8cc1Swenshuai.xi 35*53ee8cc1Swenshuai.xi 36*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 37*53ee8cc1Swenshuai.xi /* Copy N bytes of SRC to DEST. */ 38*53ee8cc1Swenshuai.xi extern void *memcpy (void *__restrict __dest, 39*53ee8cc1Swenshuai.xi __const void *__restrict __src, size_t __n) 40*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 41*53ee8cc1Swenshuai.xi /* Copy N bytes of SRC to DEST, guaranteeing 42*53ee8cc1Swenshuai.xi correct behavior for overlapping strings. */ 43*53ee8cc1Swenshuai.xi extern void *memmove (void *__dest, __const void *__src, size_t __n) 44*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 45*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 46*53ee8cc1Swenshuai.xi 47*53ee8cc1Swenshuai.xi /* Copy no more than N bytes of SRC to DEST, stopping when C is found. 48*53ee8cc1Swenshuai.xi Return the position in DEST one byte past where C was copied, 49*53ee8cc1Swenshuai.xi or NULL if C was not found in the first N bytes of SRC. */ 50*53ee8cc1Swenshuai.xi #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN 51*53ee8cc1Swenshuai.xi extern void *memccpy (void *__restrict __dest, __const void *__restrict __src, 52*53ee8cc1Swenshuai.xi int __c, size_t __n) 53*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 54*53ee8cc1Swenshuai.xi #endif /* SVID. */ 55*53ee8cc1Swenshuai.xi 56*53ee8cc1Swenshuai.xi 57*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 58*53ee8cc1Swenshuai.xi /* Set N bytes of S to C. */ 59*53ee8cc1Swenshuai.xi extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); 60*53ee8cc1Swenshuai.xi 61*53ee8cc1Swenshuai.xi /* Compare N bytes of S1 and S2. */ 62*53ee8cc1Swenshuai.xi extern int memcmp (__const void *__s1, __const void *__s2, size_t __n) 63*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 64*53ee8cc1Swenshuai.xi 65*53ee8cc1Swenshuai.xi /* Search N bytes of S for C. */ 66*53ee8cc1Swenshuai.xi extern void *memchr (__const void *__s, int __c, size_t __n) 67*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 68*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 69*53ee8cc1Swenshuai.xi 70*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 71*53ee8cc1Swenshuai.xi /* Search in S for C. This is similar to `memchr' but there is no 72*53ee8cc1Swenshuai.xi length limit. */ 73*53ee8cc1Swenshuai.xi extern void *rawmemchr (__const void *__s, int __c) 74*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 75*53ee8cc1Swenshuai.xi 76*53ee8cc1Swenshuai.xi /* Search N bytes of S for the final occurrence of C. */ 77*53ee8cc1Swenshuai.xi extern void *memrchr (__const void *__s, int __c, size_t __n) 78*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 79*53ee8cc1Swenshuai.xi #endif 80*53ee8cc1Swenshuai.xi 81*53ee8cc1Swenshuai.xi 82*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 83*53ee8cc1Swenshuai.xi /* Copy SRC to DEST. */ 84*53ee8cc1Swenshuai.xi extern char *strcpy (char *__restrict __dest, __const char *__restrict __src) 85*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 86*53ee8cc1Swenshuai.xi /* Copy no more than N characters of SRC to DEST. */ 87*53ee8cc1Swenshuai.xi extern char *strncpy (char *__restrict __dest, 88*53ee8cc1Swenshuai.xi __const char *__restrict __src, size_t __n) 89*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 90*53ee8cc1Swenshuai.xi 91*53ee8cc1Swenshuai.xi /* Append SRC onto DEST. */ 92*53ee8cc1Swenshuai.xi extern char *strcat (char *__restrict __dest, __const char *__restrict __src) 93*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 94*53ee8cc1Swenshuai.xi /* Append no more than N characters from SRC onto DEST. */ 95*53ee8cc1Swenshuai.xi extern char *strncat (char *__restrict __dest, __const char *__restrict __src, 96*53ee8cc1Swenshuai.xi size_t __n) __THROW __nonnull ((1, 2)); 97*53ee8cc1Swenshuai.xi 98*53ee8cc1Swenshuai.xi /* Compare S1 and S2. */ 99*53ee8cc1Swenshuai.xi extern int strcmp (__const char *__s1, __const char *__s2) 100*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 101*53ee8cc1Swenshuai.xi /* Compare N characters of S1 and S2. */ 102*53ee8cc1Swenshuai.xi extern int strncmp (__const char *__s1, __const char *__s2, size_t __n) 103*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 104*53ee8cc1Swenshuai.xi 105*53ee8cc1Swenshuai.xi /* Compare the collated forms of S1 and S2. */ 106*53ee8cc1Swenshuai.xi extern int strcoll (__const char *__s1, __const char *__s2) 107*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 108*53ee8cc1Swenshuai.xi /* Put a transformation of SRC into no more than N bytes of DEST. */ 109*53ee8cc1Swenshuai.xi extern size_t strxfrm (char *__restrict __dest, 110*53ee8cc1Swenshuai.xi __const char *__restrict __src, size_t __n) 111*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 112*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 113*53ee8cc1Swenshuai.xi 114*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 115*53ee8cc1Swenshuai.xi /* The following functions are equivalent to the both above but they 116*53ee8cc1Swenshuai.xi take the locale they use for the collation as an extra argument. 117*53ee8cc1Swenshuai.xi This is not standardsized but something like will come. */ 118*53ee8cc1Swenshuai.xi # include <xlocale.h> 119*53ee8cc1Swenshuai.xi 120*53ee8cc1Swenshuai.xi /* Compare the collated forms of S1 and S2 using rules from L. */ 121*53ee8cc1Swenshuai.xi extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) 122*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2, 3)); 123*53ee8cc1Swenshuai.xi /* Put a transformation of SRC into no more than N bytes of DEST. */ 124*53ee8cc1Swenshuai.xi extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n, 125*53ee8cc1Swenshuai.xi __locale_t __l) __THROW __nonnull ((2, 4)); 126*53ee8cc1Swenshuai.xi #endif 127*53ee8cc1Swenshuai.xi 128*53ee8cc1Swenshuai.xi #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED 129*53ee8cc1Swenshuai.xi /* Duplicate S, returning an identical malloc'd string. */ 130*53ee8cc1Swenshuai.xi extern char *strdup (__const char *__s) 131*53ee8cc1Swenshuai.xi __THROW __attribute_malloc__ __nonnull ((1)); 132*53ee8cc1Swenshuai.xi #endif 133*53ee8cc1Swenshuai.xi 134*53ee8cc1Swenshuai.xi /* Return a malloc'd copy of at most N bytes of STRING. The 135*53ee8cc1Swenshuai.xi resultant string is terminated even if no null terminator 136*53ee8cc1Swenshuai.xi appears before STRING[N]. */ 137*53ee8cc1Swenshuai.xi #if defined __USE_GNU 138*53ee8cc1Swenshuai.xi extern char *strndup (__const char *__string, size_t __n) 139*53ee8cc1Swenshuai.xi __THROW __attribute_malloc__ __nonnull ((1)); 140*53ee8cc1Swenshuai.xi #endif 141*53ee8cc1Swenshuai.xi 142*53ee8cc1Swenshuai.xi #if defined __USE_GNU && defined __GNUC__ 143*53ee8cc1Swenshuai.xi /* Duplicate S, returning an identical alloca'd string. */ 144*53ee8cc1Swenshuai.xi # define strdupa(s) \ 145*53ee8cc1Swenshuai.xi (__extension__ \ 146*53ee8cc1Swenshuai.xi ({ \ 147*53ee8cc1Swenshuai.xi __const char *__old = (s); \ 148*53ee8cc1Swenshuai.xi size_t __len = strlen (__old) + 1; \ 149*53ee8cc1Swenshuai.xi char *__new = (char *) __builtin_alloca (__len); \ 150*53ee8cc1Swenshuai.xi (char *) memcpy (__new, __old, __len); \ 151*53ee8cc1Swenshuai.xi })) 152*53ee8cc1Swenshuai.xi 153*53ee8cc1Swenshuai.xi /* Return an alloca'd copy of at most N bytes of string. */ 154*53ee8cc1Swenshuai.xi # define strndupa(s, n) \ 155*53ee8cc1Swenshuai.xi (__extension__ \ 156*53ee8cc1Swenshuai.xi ({ \ 157*53ee8cc1Swenshuai.xi __const char *__old = (s); \ 158*53ee8cc1Swenshuai.xi size_t __len = strnlen (__old, (n)); \ 159*53ee8cc1Swenshuai.xi char *__new = (char *) __builtin_alloca (__len + 1); \ 160*53ee8cc1Swenshuai.xi __new[__len] = '\0'; \ 161*53ee8cc1Swenshuai.xi (char *) memcpy (__new, __old, __len); \ 162*53ee8cc1Swenshuai.xi })) 163*53ee8cc1Swenshuai.xi #endif 164*53ee8cc1Swenshuai.xi 165*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 166*53ee8cc1Swenshuai.xi /* Find the first occurrence of C in S. */ 167*53ee8cc1Swenshuai.xi extern char *strchr (__const char *__s, int __c) 168*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 169*53ee8cc1Swenshuai.xi /* Find the last occurrence of C in S. */ 170*53ee8cc1Swenshuai.xi extern char *strrchr (__const char *__s, int __c) 171*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 172*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 173*53ee8cc1Swenshuai.xi 174*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 175*53ee8cc1Swenshuai.xi /* This function is similar to `strchr'. But it returns a pointer to 176*53ee8cc1Swenshuai.xi the closing NUL byte in case C is not found in S. */ 177*53ee8cc1Swenshuai.xi extern char *strchrnul (__const char *__s, int __c) 178*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 179*53ee8cc1Swenshuai.xi #endif 180*53ee8cc1Swenshuai.xi 181*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 182*53ee8cc1Swenshuai.xi /* Return the length of the initial segment of S which 183*53ee8cc1Swenshuai.xi consists entirely of characters not in REJECT. */ 184*53ee8cc1Swenshuai.xi extern size_t strcspn (__const char *__s, __const char *__reject) 185*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 186*53ee8cc1Swenshuai.xi /* Return the length of the initial segment of S which 187*53ee8cc1Swenshuai.xi consists entirely of characters in ACCEPT. */ 188*53ee8cc1Swenshuai.xi extern size_t strspn (__const char *__s, __const char *__accept) 189*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 190*53ee8cc1Swenshuai.xi /* Find the first occurrence in S of any character in ACCEPT. */ 191*53ee8cc1Swenshuai.xi extern char *strpbrk (__const char *__s, __const char *__accept) 192*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 193*53ee8cc1Swenshuai.xi /* Find the first occurrence of NEEDLE in HAYSTACK. */ 194*53ee8cc1Swenshuai.xi extern char *strstr (__const char *__haystack, __const char *__needle) 195*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 196*53ee8cc1Swenshuai.xi 197*53ee8cc1Swenshuai.xi 198*53ee8cc1Swenshuai.xi /* Divide S into tokens separated by characters in DELIM. */ 199*53ee8cc1Swenshuai.xi extern char *strtok (char *__restrict __s, __const char *__restrict __delim) 200*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 201*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 202*53ee8cc1Swenshuai.xi 203*53ee8cc1Swenshuai.xi /* Divide S into tokens separated by characters in DELIM. Information 204*53ee8cc1Swenshuai.xi passed between calls are stored in SAVE_PTR. */ 205*53ee8cc1Swenshuai.xi extern char *__strtok_r (char *__restrict __s, 206*53ee8cc1Swenshuai.xi __const char *__restrict __delim, 207*53ee8cc1Swenshuai.xi char **__restrict __save_ptr) 208*53ee8cc1Swenshuai.xi __THROW __nonnull ((2, 3)); 209*53ee8cc1Swenshuai.xi #if defined __USE_POSIX || defined __USE_MISC 210*53ee8cc1Swenshuai.xi extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim, 211*53ee8cc1Swenshuai.xi char **__restrict __save_ptr) 212*53ee8cc1Swenshuai.xi __THROW __nonnull ((2, 3)); 213*53ee8cc1Swenshuai.xi #endif 214*53ee8cc1Swenshuai.xi 215*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 216*53ee8cc1Swenshuai.xi /* Similar to `strstr' but this function ignores the case of both strings. */ 217*53ee8cc1Swenshuai.xi extern char *strcasestr (__const char *__haystack, __const char *__needle) 218*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 219*53ee8cc1Swenshuai.xi #endif 220*53ee8cc1Swenshuai.xi 221*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 222*53ee8cc1Swenshuai.xi /* Find the first occurrence of NEEDLE in HAYSTACK. 223*53ee8cc1Swenshuai.xi NEEDLE is NEEDLELEN bytes long; 224*53ee8cc1Swenshuai.xi HAYSTACK is HAYSTACKLEN bytes long. */ 225*53ee8cc1Swenshuai.xi extern void *memmem (__const void *__haystack, size_t __haystacklen, 226*53ee8cc1Swenshuai.xi __const void *__needle, size_t __needlelen) 227*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 3)); 228*53ee8cc1Swenshuai.xi 229*53ee8cc1Swenshuai.xi /* Copy N bytes of SRC to DEST, return pointer to bytes after the 230*53ee8cc1Swenshuai.xi last written byte. */ 231*53ee8cc1Swenshuai.xi extern void *__mempcpy (void *__restrict __dest, 232*53ee8cc1Swenshuai.xi __const void *__restrict __src, size_t __n) 233*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 234*53ee8cc1Swenshuai.xi extern void *mempcpy (void *__restrict __dest, 235*53ee8cc1Swenshuai.xi __const void *__restrict __src, size_t __n) 236*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 237*53ee8cc1Swenshuai.xi #endif 238*53ee8cc1Swenshuai.xi 239*53ee8cc1Swenshuai.xi 240*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 241*53ee8cc1Swenshuai.xi /* Return the length of S. */ 242*53ee8cc1Swenshuai.xi extern size_t strlen (__const char *__s) 243*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 244*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 245*53ee8cc1Swenshuai.xi 246*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 247*53ee8cc1Swenshuai.xi /* Find the length of STRING, but scan at most MAXLEN characters. 248*53ee8cc1Swenshuai.xi If no '\0' terminator is found in that many characters, return MAXLEN. */ 249*53ee8cc1Swenshuai.xi extern size_t strnlen (__const char *__string, size_t __maxlen) 250*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 251*53ee8cc1Swenshuai.xi #endif 252*53ee8cc1Swenshuai.xi 253*53ee8cc1Swenshuai.xi 254*53ee8cc1Swenshuai.xi __BEGIN_NAMESPACE_STD 255*53ee8cc1Swenshuai.xi /* Return a string describing the meaning of the `errno' code in ERRNUM. */ 256*53ee8cc1Swenshuai.xi extern char *strerror (int __errnum) __THROW; 257*53ee8cc1Swenshuai.xi __END_NAMESPACE_STD 258*53ee8cc1Swenshuai.xi #if defined __USE_XOPEN2K || defined __USE_MISC 259*53ee8cc1Swenshuai.xi /* Reentrant version of `strerror'. 260*53ee8cc1Swenshuai.xi There are 2 flavors of `strerror_r', GNU which returns the string 261*53ee8cc1Swenshuai.xi and may or may not use the supplied temporary buffer and POSIX one 262*53ee8cc1Swenshuai.xi which fills the string into the buffer. 263*53ee8cc1Swenshuai.xi To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L 264*53ee8cc1Swenshuai.xi without -D_GNU_SOURCE is needed, otherwise the GNU version is 265*53ee8cc1Swenshuai.xi preferred. */ 266*53ee8cc1Swenshuai.xi # if defined __USE_XOPEN2K && !defined __USE_GNU 267*53ee8cc1Swenshuai.xi /* Fill BUF with a string describing the meaning of the `errno' code in 268*53ee8cc1Swenshuai.xi ERRNUM. */ 269*53ee8cc1Swenshuai.xi # ifdef __REDIRECT_NTH 270*53ee8cc1Swenshuai.xi extern int __REDIRECT_NTH (strerror_r, 271*53ee8cc1Swenshuai.xi (int __errnum, char *__buf, size_t __buflen), 272*53ee8cc1Swenshuai.xi __xpg_strerror_r) __nonnull ((2)); 273*53ee8cc1Swenshuai.xi # else 274*53ee8cc1Swenshuai.xi extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) 275*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 276*53ee8cc1Swenshuai.xi # define strerror_r __xpg_strerror_r 277*53ee8cc1Swenshuai.xi # endif 278*53ee8cc1Swenshuai.xi # else 279*53ee8cc1Swenshuai.xi /* If a temporary buffer is required, at most BUFLEN bytes of BUF will be 280*53ee8cc1Swenshuai.xi used. */ 281*53ee8cc1Swenshuai.xi extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) 282*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 283*53ee8cc1Swenshuai.xi # endif 284*53ee8cc1Swenshuai.xi #endif 285*53ee8cc1Swenshuai.xi 286*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 287*53ee8cc1Swenshuai.xi /* Translate error number to string according to the locale L. */ 288*53ee8cc1Swenshuai.xi extern char *strerror_l (int __errnum, __locale_t __l) __THROW; 289*53ee8cc1Swenshuai.xi #endif 290*53ee8cc1Swenshuai.xi 291*53ee8cc1Swenshuai.xi 292*53ee8cc1Swenshuai.xi /* We define this function always since `bzero' is sometimes needed when 293*53ee8cc1Swenshuai.xi the namespace rules does not allow this. */ 294*53ee8cc1Swenshuai.xi extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1)); 295*53ee8cc1Swenshuai.xi 296*53ee8cc1Swenshuai.xi #ifdef __USE_BSD 297*53ee8cc1Swenshuai.xi /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ 298*53ee8cc1Swenshuai.xi extern void bcopy (__const void *__src, void *__dest, size_t __n) 299*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 300*53ee8cc1Swenshuai.xi 301*53ee8cc1Swenshuai.xi /* Set N bytes of S to 0. */ 302*53ee8cc1Swenshuai.xi extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); 303*53ee8cc1Swenshuai.xi 304*53ee8cc1Swenshuai.xi /* Compare N bytes of S1 and S2 (same as memcmp). */ 305*53ee8cc1Swenshuai.xi extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) 306*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 307*53ee8cc1Swenshuai.xi 308*53ee8cc1Swenshuai.xi /* Find the first occurrence of C in S (same as strchr). */ 309*53ee8cc1Swenshuai.xi extern char *index (__const char *__s, int __c) 310*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 311*53ee8cc1Swenshuai.xi 312*53ee8cc1Swenshuai.xi /* Find the last occurrence of C in S (same as strrchr). */ 313*53ee8cc1Swenshuai.xi extern char *rindex (__const char *__s, int __c) 314*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1)); 315*53ee8cc1Swenshuai.xi 316*53ee8cc1Swenshuai.xi /* Return the position of the first bit set in I, or 0 if none are set. 317*53ee8cc1Swenshuai.xi The least-significant bit is position 1, the most-significant 32. */ 318*53ee8cc1Swenshuai.xi extern int ffs (int __i) __THROW __attribute__ ((__const__)); 319*53ee8cc1Swenshuai.xi 320*53ee8cc1Swenshuai.xi /* The following two functions are non-standard but necessary for non-32 bit 321*53ee8cc1Swenshuai.xi platforms. */ 322*53ee8cc1Swenshuai.xi # ifdef __USE_GNU 323*53ee8cc1Swenshuai.xi extern int ffsl (long int __l) __THROW __attribute__ ((__const__)); 324*53ee8cc1Swenshuai.xi # ifdef __GNUC__ 325*53ee8cc1Swenshuai.xi __extension__ extern int ffsll (long long int __ll) 326*53ee8cc1Swenshuai.xi __THROW __attribute__ ((__const__)); 327*53ee8cc1Swenshuai.xi # endif 328*53ee8cc1Swenshuai.xi # endif 329*53ee8cc1Swenshuai.xi 330*53ee8cc1Swenshuai.xi /* Compare S1 and S2, ignoring case. */ 331*53ee8cc1Swenshuai.xi extern int strcasecmp (__const char *__s1, __const char *__s2) 332*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 333*53ee8cc1Swenshuai.xi 334*53ee8cc1Swenshuai.xi /* Compare no more than N chars of S1 and S2, ignoring case. */ 335*53ee8cc1Swenshuai.xi extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) 336*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 337*53ee8cc1Swenshuai.xi #endif /* Use BSD. */ 338*53ee8cc1Swenshuai.xi 339*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 340*53ee8cc1Swenshuai.xi /* Again versions of a few functions which use the given locale instead 341*53ee8cc1Swenshuai.xi of the global one. */ 342*53ee8cc1Swenshuai.xi extern int strcasecmp_l (__const char *__s1, __const char *__s2, 343*53ee8cc1Swenshuai.xi __locale_t __loc) 344*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2, 3)); 345*53ee8cc1Swenshuai.xi 346*53ee8cc1Swenshuai.xi extern int strncasecmp_l (__const char *__s1, __const char *__s2, 347*53ee8cc1Swenshuai.xi size_t __n, __locale_t __loc) 348*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2, 4)); 349*53ee8cc1Swenshuai.xi #endif 350*53ee8cc1Swenshuai.xi 351*53ee8cc1Swenshuai.xi #ifdef __USE_BSD 352*53ee8cc1Swenshuai.xi /* Return the next DELIM-delimited token from *STRINGP, 353*53ee8cc1Swenshuai.xi terminating it with a '\0', and update *STRINGP to point past it. */ 354*53ee8cc1Swenshuai.xi extern char *strsep (char **__restrict __stringp, 355*53ee8cc1Swenshuai.xi __const char *__restrict __delim) 356*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 357*53ee8cc1Swenshuai.xi #endif 358*53ee8cc1Swenshuai.xi 359*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 360*53ee8cc1Swenshuai.xi /* Compare S1 and S2 as strings holding name & indices/version numbers. */ 361*53ee8cc1Swenshuai.xi extern int strverscmp (__const char *__s1, __const char *__s2) 362*53ee8cc1Swenshuai.xi __THROW __attribute_pure__ __nonnull ((1, 2)); 363*53ee8cc1Swenshuai.xi 364*53ee8cc1Swenshuai.xi /* Return a string describing the meaning of the signal number in SIG. */ 365*53ee8cc1Swenshuai.xi extern char *strsignal (int __sig) __THROW; 366*53ee8cc1Swenshuai.xi 367*53ee8cc1Swenshuai.xi /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ 368*53ee8cc1Swenshuai.xi extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src) 369*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 370*53ee8cc1Swenshuai.xi extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src) 371*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 372*53ee8cc1Swenshuai.xi 373*53ee8cc1Swenshuai.xi /* Copy no more than N characters of SRC to DEST, returning the address of 374*53ee8cc1Swenshuai.xi the last character written into DEST. */ 375*53ee8cc1Swenshuai.xi extern char *__stpncpy (char *__restrict __dest, 376*53ee8cc1Swenshuai.xi __const char *__restrict __src, size_t __n) 377*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 378*53ee8cc1Swenshuai.xi extern char *stpncpy (char *__restrict __dest, 379*53ee8cc1Swenshuai.xi __const char *__restrict __src, size_t __n) 380*53ee8cc1Swenshuai.xi __THROW __nonnull ((1, 2)); 381*53ee8cc1Swenshuai.xi 382*53ee8cc1Swenshuai.xi /* Sautee STRING briskly. */ 383*53ee8cc1Swenshuai.xi extern char *strfry (char *__string) __THROW __nonnull ((1)); 384*53ee8cc1Swenshuai.xi 385*53ee8cc1Swenshuai.xi /* Frobnicate N bytes of S. */ 386*53ee8cc1Swenshuai.xi extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1)); 387*53ee8cc1Swenshuai.xi 388*53ee8cc1Swenshuai.xi # ifndef basename 389*53ee8cc1Swenshuai.xi /* Return the file name within directory of FILENAME. We don't 390*53ee8cc1Swenshuai.xi declare the function if the `basename' macro is available (defined 391*53ee8cc1Swenshuai.xi in <libgen.h>) which makes the XPG version of this function 392*53ee8cc1Swenshuai.xi available. */ 393*53ee8cc1Swenshuai.xi extern char *basename (__const char *__filename) __THROW __nonnull ((1)); 394*53ee8cc1Swenshuai.xi # endif 395*53ee8cc1Swenshuai.xi #endif 396*53ee8cc1Swenshuai.xi 397*53ee8cc1Swenshuai.xi 398*53ee8cc1Swenshuai.xi #if defined __GNUC__ && __GNUC__ >= 2 399*53ee8cc1Swenshuai.xi # if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \ 400*53ee8cc1Swenshuai.xi && !defined __NO_INLINE__ && !defined __cplusplus 401*53ee8cc1Swenshuai.xi /* When using GNU CC we provide some optimized versions of selected 402*53ee8cc1Swenshuai.xi functions from this header. There are two kinds of optimizations: 403*53ee8cc1Swenshuai.xi 404*53ee8cc1Swenshuai.xi - machine-dependent optimizations, most probably using inline 405*53ee8cc1Swenshuai.xi assembler code; these might be quite expensive since the code 406*53ee8cc1Swenshuai.xi size can increase significantly. 407*53ee8cc1Swenshuai.xi These optimizations are not used unless the symbol 408*53ee8cc1Swenshuai.xi __USE_STRING_INLINES 409*53ee8cc1Swenshuai.xi is defined before including this header. 410*53ee8cc1Swenshuai.xi 411*53ee8cc1Swenshuai.xi - machine-independent optimizations which do not increase the 412*53ee8cc1Swenshuai.xi code size significantly and which optimize mainly situations 413*53ee8cc1Swenshuai.xi where one or more arguments are compile-time constants. 414*53ee8cc1Swenshuai.xi These optimizations are used always when the compiler is 415*53ee8cc1Swenshuai.xi taught to optimize. 416*53ee8cc1Swenshuai.xi 417*53ee8cc1Swenshuai.xi One can inhibit all optimizations by defining __NO_STRING_INLINES. */ 418*53ee8cc1Swenshuai.xi 419*53ee8cc1Swenshuai.xi /* Get the machine-dependent optimizations (if any). */ 420*53ee8cc1Swenshuai.xi # include <bits/string.h> 421*53ee8cc1Swenshuai.xi 422*53ee8cc1Swenshuai.xi /* These are generic optimizations which do not add too much inline code. */ 423*53ee8cc1Swenshuai.xi # include <bits/string2.h> 424*53ee8cc1Swenshuai.xi # endif 425*53ee8cc1Swenshuai.xi 426*53ee8cc1Swenshuai.xi # if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline 427*53ee8cc1Swenshuai.xi /* Functions with security checks. */ 428*53ee8cc1Swenshuai.xi # include <bits/string3.h> 429*53ee8cc1Swenshuai.xi # endif 430*53ee8cc1Swenshuai.xi #endif 431*53ee8cc1Swenshuai.xi 432*53ee8cc1Swenshuai.xi __END_DECLS 433*53ee8cc1Swenshuai.xi 434*53ee8cc1Swenshuai.xi #endif /* string.h */ 435