Back to index

nagios-plugins  1.4.16
string.in.h
Go to the documentation of this file.
00001 /* A GNU-like <string.h>.
00002 
00003    Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 #ifndef _GL_STRING_H
00020 
00021 #if __GNUC__ >= 3
00022 @PRAGMA_SYSTEM_HEADER@
00023 #endif
00024 
00025 /* The include_next requires a split double-inclusion guard.  */
00026 #@INCLUDE_NEXT@ @NEXT_STRING_H@
00027 
00028 #ifndef _GL_STRING_H
00029 #define _GL_STRING_H
00030 
00031 /* NetBSD 5.0 mis-defines NULL.  */
00032 #include <stddef.h>
00033 
00034 /* MirBSD defines mbslen as a macro.  */
00035 #if @GNULIB_MBSLEN@ && defined __MirBSD__
00036 # include <wchar.h>
00037 #endif
00038 
00039 #ifndef __attribute__
00040 /* This feature is available in gcc versions 2.5 and later.  */
00041 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
00042 #  define __attribute__(Spec) /* empty */
00043 # endif
00044 /* The attribute __pure__ was added in gcc 2.96.  */
00045 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
00046 #  define __pure__ /* empty */
00047 # endif
00048 #endif
00049 
00050 
00051 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
00052 
00053 /* The definition of _GL_ARG_NONNULL is copied here.  */
00054 
00055 /* The definition of _GL_WARN_ON_USE is copied here.  */
00056 
00057 
00058 /* Return the first instance of C within N bytes of S, or NULL.  */
00059 #if @GNULIB_MEMCHR@
00060 # if @REPLACE_MEMCHR@
00061 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00062 #   define memchr rpl_memchr
00063 #  endif
00064 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
00065                                   __attribute__ ((__pure__))
00066                                   _GL_ARG_NONNULL ((1)));
00067 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
00068 # else
00069 #  if ! @HAVE_MEMCHR@
00070 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
00071                                   __attribute__ ((__pure__))
00072                                   _GL_ARG_NONNULL ((1)));
00073 #  endif
00074   /* On some systems, this function is defined as an overloaded function:
00075        extern "C" { const void * std::memchr (const void *, int, size_t); }
00076        extern "C++" { void * std::memchr (void *, int, size_t); }  */
00077 _GL_CXXALIAS_SYS_CAST2 (memchr,
00078                         void *, (void const *__s, int __c, size_t __n),
00079                         void const *, (void const *__s, int __c, size_t __n));
00080 # endif
00081 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00082      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00083 _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
00084 _GL_CXXALIASWARN1 (memchr, void const *,
00085                    (void const *__s, int __c, size_t __n));
00086 # else
00087 _GL_CXXALIASWARN (memchr);
00088 # endif
00089 #elif defined GNULIB_POSIXCHECK
00090 # undef memchr
00091 /* Assume memchr is always declared.  */
00092 _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
00093                  "use gnulib module memchr for portability" );
00094 #endif
00095 
00096 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
00097 #if @GNULIB_MEMMEM@
00098 # if @REPLACE_MEMMEM@
00099 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00100 #   define memmem rpl_memmem
00101 #  endif
00102 _GL_FUNCDECL_RPL (memmem, void *,
00103                   (void const *__haystack, size_t __haystack_len,
00104                    void const *__needle, size_t __needle_len)
00105                   __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
00106 _GL_CXXALIAS_RPL (memmem, void *,
00107                   (void const *__haystack, size_t __haystack_len,
00108                    void const *__needle, size_t __needle_len));
00109 # else
00110 #  if ! @HAVE_DECL_MEMMEM@
00111 _GL_FUNCDECL_SYS (memmem, void *,
00112                   (void const *__haystack, size_t __haystack_len,
00113                    void const *__needle, size_t __needle_len)
00114                   __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
00115 #  endif
00116 _GL_CXXALIAS_SYS (memmem, void *,
00117                   (void const *__haystack, size_t __haystack_len,
00118                    void const *__needle, size_t __needle_len));
00119 # endif
00120 _GL_CXXALIASWARN (memmem);
00121 #elif defined GNULIB_POSIXCHECK
00122 # undef memmem
00123 # if HAVE_RAW_DECL_MEMMEM
00124 _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
00125                  "use gnulib module memmem-simple for portability, "
00126                  "and module memmem for speed" );
00127 # endif
00128 #endif
00129 
00130 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
00131    last written byte.  */
00132 #if @GNULIB_MEMPCPY@
00133 # if ! @HAVE_MEMPCPY@
00134 _GL_FUNCDECL_SYS (mempcpy, void *,
00135                   (void *restrict __dest, void const *restrict __src,
00136                    size_t __n)
00137                   _GL_ARG_NONNULL ((1, 2)));
00138 # endif
00139 _GL_CXXALIAS_SYS (mempcpy, void *,
00140                   (void *restrict __dest, void const *restrict __src,
00141                    size_t __n));
00142 _GL_CXXALIASWARN (mempcpy);
00143 #elif defined GNULIB_POSIXCHECK
00144 # undef mempcpy
00145 # if HAVE_RAW_DECL_MEMPCPY
00146 _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
00147                  "use gnulib module mempcpy for portability");
00148 # endif
00149 #endif
00150 
00151 /* Search backwards through a block for a byte (specified as an int).  */
00152 #if @GNULIB_MEMRCHR@
00153 # if ! @HAVE_DECL_MEMRCHR@
00154 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
00155                                    __attribute__ ((__pure__))
00156                                    _GL_ARG_NONNULL ((1)));
00157 # endif
00158   /* On some systems, this function is defined as an overloaded function:
00159        extern "C++" { const void * std::memrchr (const void *, int, size_t); }
00160        extern "C++" { void * std::memrchr (void *, int, size_t); }  */
00161 _GL_CXXALIAS_SYS_CAST2 (memrchr,
00162                         void *, (void const *, int, size_t),
00163                         void const *, (void const *, int, size_t));
00164 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00165      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00166 _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
00167 _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
00168 # else
00169 _GL_CXXALIASWARN (memrchr);
00170 # endif
00171 #elif defined GNULIB_POSIXCHECK
00172 # undef memrchr
00173 # if HAVE_RAW_DECL_MEMRCHR
00174 _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
00175                  "use gnulib module memrchr for portability");
00176 # endif
00177 #endif
00178 
00179 /* Find the first occurrence of C in S.  More efficient than
00180    memchr(S,C,N), at the expense of undefined behavior if C does not
00181    occur within N bytes.  */
00182 #if @GNULIB_RAWMEMCHR@
00183 # if ! @HAVE_RAWMEMCHR@
00184 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
00185                                      __attribute__ ((__pure__))
00186                                      _GL_ARG_NONNULL ((1)));
00187 # endif
00188   /* On some systems, this function is defined as an overloaded function:
00189        extern "C++" { const void * std::rawmemchr (const void *, int); }
00190        extern "C++" { void * std::rawmemchr (void *, int); }  */
00191 _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
00192                         void *, (void const *__s, int __c_in),
00193                         void const *, (void const *__s, int __c_in));
00194 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00195      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00196 _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
00197 _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
00198 # else
00199 _GL_CXXALIASWARN (rawmemchr);
00200 # endif
00201 #elif defined GNULIB_POSIXCHECK
00202 # undef rawmemchr
00203 # if HAVE_RAW_DECL_RAWMEMCHR
00204 _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
00205                  "use gnulib module rawmemchr for portability");
00206 # endif
00207 #endif
00208 
00209 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
00210 #if @GNULIB_STPCPY@
00211 # if ! @HAVE_STPCPY@
00212 _GL_FUNCDECL_SYS (stpcpy, char *,
00213                   (char *restrict __dst, char const *restrict __src)
00214                   _GL_ARG_NONNULL ((1, 2)));
00215 # endif
00216 _GL_CXXALIAS_SYS (stpcpy, char *,
00217                   (char *restrict __dst, char const *restrict __src));
00218 _GL_CXXALIASWARN (stpcpy);
00219 #elif defined GNULIB_POSIXCHECK
00220 # undef stpcpy
00221 # if HAVE_RAW_DECL_STPCPY
00222 _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
00223                  "use gnulib module stpcpy for portability");
00224 # endif
00225 #endif
00226 
00227 /* Copy no more than N bytes of SRC to DST, returning a pointer past the
00228    last non-NUL byte written into DST.  */
00229 #if @GNULIB_STPNCPY@
00230 # if @REPLACE_STPNCPY@
00231 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00232 #   define stpncpy rpl_stpncpy
00233 #  endif
00234 _GL_FUNCDECL_RPL (stpncpy, char *,
00235                   (char *restrict __dst, char const *restrict __src,
00236                    size_t __n)
00237                   _GL_ARG_NONNULL ((1, 2)));
00238 _GL_CXXALIAS_RPL (stpncpy, char *,
00239                   (char *restrict __dst, char const *restrict __src,
00240                    size_t __n));
00241 # else
00242 #  if ! @HAVE_STPNCPY@
00243 _GL_FUNCDECL_SYS (stpncpy, char *,
00244                   (char *restrict __dst, char const *restrict __src,
00245                    size_t __n)
00246                   _GL_ARG_NONNULL ((1, 2)));
00247 #  endif
00248 _GL_CXXALIAS_SYS (stpncpy, char *,
00249                   (char *restrict __dst, char const *restrict __src,
00250                    size_t __n));
00251 # endif
00252 _GL_CXXALIASWARN (stpncpy);
00253 #elif defined GNULIB_POSIXCHECK
00254 # undef stpncpy
00255 # if HAVE_RAW_DECL_STPNCPY
00256 _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
00257                  "use gnulib module stpncpy for portability");
00258 # endif
00259 #endif
00260 
00261 #if defined GNULIB_POSIXCHECK
00262 /* strchr() does not work with multibyte strings if the locale encoding is
00263    GB18030 and the character to be searched is a digit.  */
00264 # undef strchr
00265 /* Assume strchr is always declared.  */
00266 _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
00267                  "in some multibyte locales - "
00268                  "use mbschr if you care about internationalization");
00269 #endif
00270 
00271 /* Find the first occurrence of C in S or the final NUL byte.  */
00272 #if @GNULIB_STRCHRNUL@
00273 # if ! @HAVE_STRCHRNUL@
00274 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
00275                                      __attribute__ ((__pure__))
00276                                      _GL_ARG_NONNULL ((1)));
00277 # endif
00278   /* On some systems, this function is defined as an overloaded function:
00279        extern "C++" { const char * std::strchrnul (const char *, int); }
00280        extern "C++" { char * std::strchrnul (char *, int); }  */
00281 _GL_CXXALIAS_SYS_CAST2 (strchrnul,
00282                         char *, (char const *__s, int __c_in),
00283                         char const *, (char const *__s, int __c_in));
00284 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00285      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00286 _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
00287 _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
00288 # else
00289 _GL_CXXALIASWARN (strchrnul);
00290 # endif
00291 #elif defined GNULIB_POSIXCHECK
00292 # undef strchrnul
00293 # if HAVE_RAW_DECL_STRCHRNUL
00294 _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
00295                  "use gnulib module strchrnul for portability");
00296 # endif
00297 #endif
00298 
00299 /* Duplicate S, returning an identical malloc'd string.  */
00300 #if @GNULIB_STRDUP@
00301 # if @REPLACE_STRDUP@
00302 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00303 #   undef strdup
00304 #   define strdup rpl_strdup
00305 #  endif
00306 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
00307 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
00308 # else
00309 #  if !(@HAVE_DECL_STRDUP@ || defined strdup)
00310 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
00311 #  endif
00312 _GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
00313 # endif
00314 _GL_CXXALIASWARN (strdup);
00315 #elif defined GNULIB_POSIXCHECK
00316 # undef strdup
00317 # if HAVE_RAW_DECL_STRDUP
00318 _GL_WARN_ON_USE (strdup, "strdup is unportable - "
00319                  "use gnulib module strdup for portability");
00320 # endif
00321 #endif
00322 
00323 /* Append no more than N characters from SRC onto DEST.  */
00324 #if @GNULIB_STRNCAT@
00325 # if @REPLACE_STRNCAT@
00326 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00327 #   undef strncat
00328 #   define strncat rpl_strncat
00329 #  endif
00330 _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
00331                                    _GL_ARG_NONNULL ((1, 2)));
00332 _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
00333 # else
00334 _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
00335 # endif
00336 _GL_CXXALIASWARN (strncat);
00337 #elif defined GNULIB_POSIXCHECK
00338 # undef strncat
00339 # if HAVE_RAW_DECL_STRNCAT
00340 _GL_WARN_ON_USE (strncat, "strncat is unportable - "
00341                  "use gnulib module strncat for portability");
00342 # endif
00343 #endif
00344 
00345 /* Return a newly allocated copy of at most N bytes of STRING.  */
00346 #if @GNULIB_STRNDUP@
00347 # if @REPLACE_STRNDUP@
00348 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00349 #   undef strndup
00350 #   define strndup rpl_strndup
00351 #  endif
00352 _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
00353                                    _GL_ARG_NONNULL ((1)));
00354 _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
00355 # else
00356 #  if ! @HAVE_DECL_STRNDUP@
00357 _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
00358                                    _GL_ARG_NONNULL ((1)));
00359 #  endif
00360 _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
00361 # endif
00362 _GL_CXXALIASWARN (strndup);
00363 #elif defined GNULIB_POSIXCHECK
00364 # undef strndup
00365 # if HAVE_RAW_DECL_STRNDUP
00366 _GL_WARN_ON_USE (strndup, "strndup is unportable - "
00367                  "use gnulib module strndup for portability");
00368 # endif
00369 #endif
00370 
00371 /* Find the length (number of bytes) of STRING, but scan at most
00372    MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
00373    return MAXLEN.  */
00374 #if @GNULIB_STRNLEN@
00375 # if @REPLACE_STRNLEN@
00376 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00377 #   undef strnlen
00378 #   define strnlen rpl_strnlen
00379 #  endif
00380 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
00381                                    __attribute__ ((__pure__))
00382                                    _GL_ARG_NONNULL ((1)));
00383 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
00384 # else
00385 #  if ! @HAVE_DECL_STRNLEN@
00386 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
00387                                    __attribute__ ((__pure__))
00388                                    _GL_ARG_NONNULL ((1)));
00389 #  endif
00390 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
00391 # endif
00392 _GL_CXXALIASWARN (strnlen);
00393 #elif defined GNULIB_POSIXCHECK
00394 # undef strnlen
00395 # if HAVE_RAW_DECL_STRNLEN
00396 _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
00397                  "use gnulib module strnlen for portability");
00398 # endif
00399 #endif
00400 
00401 #if defined GNULIB_POSIXCHECK
00402 /* strcspn() assumes the second argument is a list of single-byte characters.
00403    Even in this simple case, it does not work with multibyte strings if the
00404    locale encoding is GB18030 and one of the characters to be searched is a
00405    digit.  */
00406 # undef strcspn
00407 /* Assume strcspn is always declared.  */
00408 _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
00409                  "in multibyte locales - "
00410                  "use mbscspn if you care about internationalization");
00411 #endif
00412 
00413 /* Find the first occurrence in S of any character in ACCEPT.  */
00414 #if @GNULIB_STRPBRK@
00415 # if ! @HAVE_STRPBRK@
00416 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
00417                                    __attribute__ ((__pure__))
00418                                    _GL_ARG_NONNULL ((1, 2)));
00419 # endif
00420   /* On some systems, this function is defined as an overloaded function:
00421        extern "C" { const char * strpbrk (const char *, const char *); }
00422        extern "C++" { char * strpbrk (char *, const char *); }  */
00423 _GL_CXXALIAS_SYS_CAST2 (strpbrk,
00424                         char *, (char const *__s, char const *__accept),
00425                         const char *, (char const *__s, char const *__accept));
00426 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00427      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00428 _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
00429 _GL_CXXALIASWARN1 (strpbrk, char const *,
00430                    (char const *__s, char const *__accept));
00431 # else
00432 _GL_CXXALIASWARN (strpbrk);
00433 # endif
00434 # if defined GNULIB_POSIXCHECK
00435 /* strpbrk() assumes the second argument is a list of single-byte characters.
00436    Even in this simple case, it does not work with multibyte strings if the
00437    locale encoding is GB18030 and one of the characters to be searched is a
00438    digit.  */
00439 #  undef strpbrk
00440 _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
00441                  "in multibyte locales - "
00442                  "use mbspbrk if you care about internationalization");
00443 # endif
00444 #elif defined GNULIB_POSIXCHECK
00445 # undef strpbrk
00446 # if HAVE_RAW_DECL_STRPBRK
00447 _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
00448                  "use gnulib module strpbrk for portability");
00449 # endif
00450 #endif
00451 
00452 #if defined GNULIB_POSIXCHECK
00453 /* strspn() assumes the second argument is a list of single-byte characters.
00454    Even in this simple case, it cannot work with multibyte strings.  */
00455 # undef strspn
00456 /* Assume strspn is always declared.  */
00457 _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
00458                  "in multibyte locales - "
00459                  "use mbsspn if you care about internationalization");
00460 #endif
00461 
00462 #if defined GNULIB_POSIXCHECK
00463 /* strrchr() does not work with multibyte strings if the locale encoding is
00464    GB18030 and the character to be searched is a digit.  */
00465 # undef strrchr
00466 /* Assume strrchr is always declared.  */
00467 _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
00468                  "in some multibyte locales - "
00469                  "use mbsrchr if you care about internationalization");
00470 #endif
00471 
00472 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
00473    If one is found, overwrite it with a NUL, and advance *STRINGP
00474    to point to the next char after it.  Otherwise, set *STRINGP to NULL.
00475    If *STRINGP was already NULL, nothing happens.
00476    Return the old value of *STRINGP.
00477 
00478    This is a variant of strtok() that is multithread-safe and supports
00479    empty fields.
00480 
00481    Caveat: It modifies the original string.
00482    Caveat: These functions cannot be used on constant strings.
00483    Caveat: The identity of the delimiting character is lost.
00484    Caveat: It doesn't work with multibyte strings unless all of the delimiter
00485            characters are ASCII characters < 0x30.
00486 
00487    See also strtok_r().  */
00488 #if @GNULIB_STRSEP@
00489 # if ! @HAVE_STRSEP@
00490 _GL_FUNCDECL_SYS (strsep, char *,
00491                   (char **restrict __stringp, char const *restrict __delim)
00492                   _GL_ARG_NONNULL ((1, 2)));
00493 # endif
00494 _GL_CXXALIAS_SYS (strsep, char *,
00495                   (char **restrict __stringp, char const *restrict __delim));
00496 _GL_CXXALIASWARN (strsep);
00497 # if defined GNULIB_POSIXCHECK
00498 #  undef strsep
00499 _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
00500                  "in multibyte locales - "
00501                  "use mbssep if you care about internationalization");
00502 # endif
00503 #elif defined GNULIB_POSIXCHECK
00504 # undef strsep
00505 # if HAVE_RAW_DECL_STRSEP
00506 _GL_WARN_ON_USE (strsep, "strsep is unportable - "
00507                  "use gnulib module strsep for portability");
00508 # endif
00509 #endif
00510 
00511 #if @GNULIB_STRSTR@
00512 # if @REPLACE_STRSTR@
00513 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00514 #   define strstr rpl_strstr
00515 #  endif
00516 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
00517                                   __attribute__ ((__pure__))
00518                                   _GL_ARG_NONNULL ((1, 2)));
00519 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
00520 # else
00521   /* On some systems, this function is defined as an overloaded function:
00522        extern "C++" { const char * strstr (const char *, const char *); }
00523        extern "C++" { char * strstr (char *, const char *); }  */
00524 _GL_CXXALIAS_SYS_CAST2 (strstr,
00525                         char *, (const char *haystack, const char *needle),
00526                         const char *, (const char *haystack, const char *needle));
00527 # endif
00528 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00529      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00530 _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
00531 _GL_CXXALIASWARN1 (strstr, const char *,
00532                    (const char *haystack, const char *needle));
00533 # else
00534 _GL_CXXALIASWARN (strstr);
00535 # endif
00536 #elif defined GNULIB_POSIXCHECK
00537 /* strstr() does not work with multibyte strings if the locale encoding is
00538    different from UTF-8:
00539    POSIX says that it operates on "strings", and "string" in POSIX is defined
00540    as a sequence of bytes, not of characters.  */
00541 # undef strstr
00542 /* Assume strstr is always declared.  */
00543 _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
00544                  "work correctly on character strings in most "
00545                  "multibyte locales - "
00546                  "use mbsstr if you care about internationalization, "
00547                  "or use strstr if you care about speed");
00548 #endif
00549 
00550 /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
00551    comparison.  */
00552 #if @GNULIB_STRCASESTR@
00553 # if @REPLACE_STRCASESTR@
00554 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00555 #   define strcasestr rpl_strcasestr
00556 #  endif
00557 _GL_FUNCDECL_RPL (strcasestr, char *,
00558                   (const char *haystack, const char *needle)
00559                   __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
00560 _GL_CXXALIAS_RPL (strcasestr, char *,
00561                   (const char *haystack, const char *needle));
00562 # else
00563 #  if ! @HAVE_STRCASESTR@
00564 _GL_FUNCDECL_SYS (strcasestr, char *,
00565                   (const char *haystack, const char *needle)
00566                   __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
00567 #  endif
00568   /* On some systems, this function is defined as an overloaded function:
00569        extern "C++" { const char * strcasestr (const char *, const char *); }
00570        extern "C++" { char * strcasestr (char *, const char *); }  */
00571 _GL_CXXALIAS_SYS_CAST2 (strcasestr,
00572                         char *, (const char *haystack, const char *needle),
00573                         const char *, (const char *haystack, const char *needle));
00574 # endif
00575 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
00576      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
00577 _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
00578 _GL_CXXALIASWARN1 (strcasestr, const char *,
00579                    (const char *haystack, const char *needle));
00580 # else
00581 _GL_CXXALIASWARN (strcasestr);
00582 # endif
00583 #elif defined GNULIB_POSIXCHECK
00584 /* strcasestr() does not work with multibyte strings:
00585    It is a glibc extension, and glibc implements it only for unibyte
00586    locales.  */
00587 # undef strcasestr
00588 # if HAVE_RAW_DECL_STRCASESTR
00589 _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
00590                  "strings in multibyte locales - "
00591                  "use mbscasestr if you care about "
00592                  "internationalization, or use c-strcasestr if you want "
00593                  "a locale independent function");
00594 # endif
00595 #endif
00596 
00597 /* Parse S into tokens separated by characters in DELIM.
00598    If S is NULL, the saved pointer in SAVE_PTR is used as
00599    the next starting point.  For example:
00600         char s[] = "-abc-=-def";
00601         char *sp;
00602         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
00603         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
00604         x = strtok_r(NULL, "=", &sp);   // x = NULL
00605                 // s = "abc\0-def\0"
00606 
00607    This is a variant of strtok() that is multithread-safe.
00608 
00609    For the POSIX documentation for this function, see:
00610    http://www.opengroup.org/susv3xsh/strtok.html
00611 
00612    Caveat: It modifies the original string.
00613    Caveat: These functions cannot be used on constant strings.
00614    Caveat: The identity of the delimiting character is lost.
00615    Caveat: It doesn't work with multibyte strings unless all of the delimiter
00616            characters are ASCII characters < 0x30.
00617 
00618    See also strsep().  */
00619 #if @GNULIB_STRTOK_R@
00620 # if @REPLACE_STRTOK_R@
00621 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00622 #   undef strtok_r
00623 #   define strtok_r rpl_strtok_r
00624 #  endif
00625 _GL_FUNCDECL_RPL (strtok_r, char *,
00626                   (char *restrict s, char const *restrict delim,
00627                    char **restrict save_ptr)
00628                   _GL_ARG_NONNULL ((2, 3)));
00629 _GL_CXXALIAS_RPL (strtok_r, char *,
00630                   (char *restrict s, char const *restrict delim,
00631                    char **restrict save_ptr));
00632 # else
00633 #  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
00634 #   undef strtok_r
00635 #  endif
00636 #  if ! @HAVE_DECL_STRTOK_R@
00637 _GL_FUNCDECL_SYS (strtok_r, char *,
00638                   (char *restrict s, char const *restrict delim,
00639                    char **restrict save_ptr)
00640                   _GL_ARG_NONNULL ((2, 3)));
00641 #  endif
00642 _GL_CXXALIAS_SYS (strtok_r, char *,
00643                   (char *restrict s, char const *restrict delim,
00644                    char **restrict save_ptr));
00645 # endif
00646 _GL_CXXALIASWARN (strtok_r);
00647 # if defined GNULIB_POSIXCHECK
00648 _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
00649                  "strings in multibyte locales - "
00650                  "use mbstok_r if you care about internationalization");
00651 # endif
00652 #elif defined GNULIB_POSIXCHECK
00653 # undef strtok_r
00654 # if HAVE_RAW_DECL_STRTOK_R
00655 _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
00656                  "use gnulib module strtok_r for portability");
00657 # endif
00658 #endif
00659 
00660 
00661 /* The following functions are not specified by POSIX.  They are gnulib
00662    extensions.  */
00663 
00664 #if @GNULIB_MBSLEN@
00665 /* Return the number of multibyte characters in the character string STRING.
00666    This considers multibyte characters, unlike strlen, which counts bytes.  */
00667 # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
00668 #  undef mbslen
00669 # endif
00670 # if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
00671 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00672 #   define mbslen rpl_mbslen
00673 #  endif
00674 _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
00675 _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
00676 # else
00677 _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
00678 _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
00679 # endif
00680 _GL_CXXALIASWARN (mbslen);
00681 #endif
00682 
00683 #if @GNULIB_MBSNLEN@
00684 /* Return the number of multibyte characters in the character string starting
00685    at STRING and ending at STRING + LEN.  */
00686 _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
00687      _GL_ARG_NONNULL ((1));
00688 #endif
00689 
00690 #if @GNULIB_MBSCHR@
00691 /* Locate the first single-byte character C in the character string STRING,
00692    and return a pointer to it.  Return NULL if C is not found in STRING.
00693    Unlike strchr(), this function works correctly in multibyte locales with
00694    encodings such as GB18030.  */
00695 # if defined __hpux
00696 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00697 #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
00698 #  endif
00699 _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
00700                                   _GL_ARG_NONNULL ((1)));
00701 _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
00702 # else
00703 _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
00704                                   _GL_ARG_NONNULL ((1)));
00705 _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
00706 # endif
00707 _GL_CXXALIASWARN (mbschr);
00708 #endif
00709 
00710 #if @GNULIB_MBSRCHR@
00711 /* Locate the last single-byte character C in the character string STRING,
00712    and return a pointer to it.  Return NULL if C is not found in STRING.
00713    Unlike strrchr(), this function works correctly in multibyte locales with
00714    encodings such as GB18030.  */
00715 # if defined __hpux
00716 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00717 #   define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
00718 #  endif
00719 _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
00720                                    _GL_ARG_NONNULL ((1)));
00721 _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
00722 # else
00723 _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
00724                                    _GL_ARG_NONNULL ((1)));
00725 _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
00726 # endif
00727 _GL_CXXALIASWARN (mbsrchr);
00728 #endif
00729 
00730 #if @GNULIB_MBSSTR@
00731 /* Find the first occurrence of the character string NEEDLE in the character
00732    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
00733    Unlike strstr(), this function works correctly in multibyte locales with
00734    encodings different from UTF-8.  */
00735 _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
00736      _GL_ARG_NONNULL ((1, 2));
00737 #endif
00738 
00739 #if @GNULIB_MBSCASECMP@
00740 /* Compare the character strings S1 and S2, ignoring case, returning less than,
00741    equal to or greater than zero if S1 is lexicographically less than, equal to
00742    or greater than S2.
00743    Note: This function may, in multibyte locales, return 0 for strings of
00744    different lengths!
00745    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
00746 _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
00747      _GL_ARG_NONNULL ((1, 2));
00748 #endif
00749 
00750 #if @GNULIB_MBSNCASECMP@
00751 /* Compare the initial segment of the character string S1 consisting of at most
00752    N characters with the initial segment of the character string S2 consisting
00753    of at most N characters, ignoring case, returning less than, equal to or
00754    greater than zero if the initial segment of S1 is lexicographically less
00755    than, equal to or greater than the initial segment of S2.
00756    Note: This function may, in multibyte locales, return 0 for initial segments
00757    of different lengths!
00758    Unlike strncasecmp(), this function works correctly in multibyte locales.
00759    But beware that N is not a byte count but a character count!  */
00760 _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
00761      _GL_ARG_NONNULL ((1, 2));
00762 #endif
00763 
00764 #if @GNULIB_MBSPCASECMP@
00765 /* Compare the initial segment of the character string STRING consisting of
00766    at most mbslen (PREFIX) characters with the character string PREFIX,
00767    ignoring case, returning less than, equal to or greater than zero if this
00768    initial segment is lexicographically less than, equal to or greater than
00769    PREFIX.
00770    Note: This function may, in multibyte locales, return 0 if STRING is of
00771    smaller length than PREFIX!
00772    Unlike strncasecmp(), this function works correctly in multibyte
00773    locales.  */
00774 _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
00775      _GL_ARG_NONNULL ((1, 2));
00776 #endif
00777 
00778 #if @GNULIB_MBSCASESTR@
00779 /* Find the first occurrence of the character string NEEDLE in the character
00780    string HAYSTACK, using case-insensitive comparison.
00781    Note: This function may, in multibyte locales, return success even if
00782    strlen (haystack) < strlen (needle) !
00783    Unlike strcasestr(), this function works correctly in multibyte locales.  */
00784 _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
00785      _GL_ARG_NONNULL ((1, 2));
00786 #endif
00787 
00788 #if @GNULIB_MBSCSPN@
00789 /* Find the first occurrence in the character string STRING of any character
00790    in the character string ACCEPT.  Return the number of bytes from the
00791    beginning of the string to this occurrence, or to the end of the string
00792    if none exists.
00793    Unlike strcspn(), this function works correctly in multibyte locales.  */
00794 _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
00795      _GL_ARG_NONNULL ((1, 2));
00796 #endif
00797 
00798 #if @GNULIB_MBSPBRK@
00799 /* Find the first occurrence in the character string STRING of any character
00800    in the character string ACCEPT.  Return the pointer to it, or NULL if none
00801    exists.
00802    Unlike strpbrk(), this function works correctly in multibyte locales.  */
00803 # if defined __hpux
00804 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00805 #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
00806 #  endif
00807 _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
00808                                    _GL_ARG_NONNULL ((1, 2)));
00809 _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
00810 # else
00811 _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
00812                                    _GL_ARG_NONNULL ((1, 2)));
00813 _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
00814 # endif
00815 _GL_CXXALIASWARN (mbspbrk);
00816 #endif
00817 
00818 #if @GNULIB_MBSSPN@
00819 /* Find the first occurrence in the character string STRING of any character
00820    not in the character string REJECT.  Return the number of bytes from the
00821    beginning of the string to this occurrence, or to the end of the string
00822    if none exists.
00823    Unlike strspn(), this function works correctly in multibyte locales.  */
00824 _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
00825      _GL_ARG_NONNULL ((1, 2));
00826 #endif
00827 
00828 #if @GNULIB_MBSSEP@
00829 /* Search the next delimiter (multibyte character listed in the character
00830    string DELIM) starting at the character string *STRINGP.
00831    If one is found, overwrite it with a NUL, and advance *STRINGP to point
00832    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
00833    If *STRINGP was already NULL, nothing happens.
00834    Return the old value of *STRINGP.
00835 
00836    This is a variant of mbstok_r() that supports empty fields.
00837 
00838    Caveat: It modifies the original string.
00839    Caveat: These functions cannot be used on constant strings.
00840    Caveat: The identity of the delimiting character is lost.
00841 
00842    See also mbstok_r().  */
00843 _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
00844      _GL_ARG_NONNULL ((1, 2));
00845 #endif
00846 
00847 #if @GNULIB_MBSTOK_R@
00848 /* Parse the character string STRING into tokens separated by characters in
00849    the character string DELIM.
00850    If STRING is NULL, the saved pointer in SAVE_PTR is used as
00851    the next starting point.  For example:
00852         char s[] = "-abc-=-def";
00853         char *sp;
00854         x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
00855         x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
00856         x = mbstok_r(NULL, "=", &sp);   // x = NULL
00857                 // s = "abc\0-def\0"
00858 
00859    Caveat: It modifies the original string.
00860    Caveat: These functions cannot be used on constant strings.
00861    Caveat: The identity of the delimiting character is lost.
00862 
00863    See also mbssep().  */
00864 _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
00865      _GL_ARG_NONNULL ((2, 3));
00866 #endif
00867 
00868 /* Map any int, typically from errno, into an error message.  */
00869 #if @GNULIB_STRERROR@
00870 # if @REPLACE_STRERROR@
00871 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00872 #   undef strerror
00873 #   define strerror rpl_strerror
00874 #  endif
00875 _GL_FUNCDECL_RPL (strerror, char *, (int));
00876 _GL_CXXALIAS_RPL (strerror, char *, (int));
00877 # else
00878 _GL_CXXALIAS_SYS (strerror, char *, (int));
00879 # endif
00880 _GL_CXXALIASWARN (strerror);
00881 #elif defined GNULIB_POSIXCHECK
00882 # undef strerror
00883 /* Assume strerror is always declared.  */
00884 _GL_WARN_ON_USE (strerror, "strerror is unportable - "
00885                  "use gnulib module strerror to guarantee non-NULL result");
00886 #endif
00887 
00888 #if @GNULIB_STRSIGNAL@
00889 # if @REPLACE_STRSIGNAL@
00890 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00891 #   define strsignal rpl_strsignal
00892 #  endif
00893 _GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
00894 _GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
00895 # else
00896 #  if ! @HAVE_DECL_STRSIGNAL@
00897 _GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
00898 #  endif
00899 /* Need to cast, because on Cygwin 1.5.x systems, the return type is
00900    'const char *'.  */
00901 _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
00902 # endif
00903 _GL_CXXALIASWARN (strsignal);
00904 #elif defined GNULIB_POSIXCHECK
00905 # undef strsignal
00906 # if HAVE_RAW_DECL_STRSIGNAL
00907 _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
00908                  "use gnulib module strsignal for portability");
00909 # endif
00910 #endif
00911 
00912 #if @GNULIB_STRVERSCMP@
00913 # if !@HAVE_STRVERSCMP@
00914 _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
00915                                    _GL_ARG_NONNULL ((1, 2)));
00916 # endif
00917 _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
00918 _GL_CXXALIASWARN (strverscmp);
00919 #elif defined GNULIB_POSIXCHECK
00920 # undef strverscmp
00921 # if HAVE_RAW_DECL_STRVERSCMP
00922 _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
00923                  "use gnulib module strverscmp for portability");
00924 # endif
00925 #endif
00926 
00927 
00928 #endif /* _GL_STRING_H */
00929 #endif /* _GL_STRING_H */