1 /* Copyright (C) 1991,92,96,97,99,2000,2001,2009 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, write to the Free 16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 02111-1307 USA. */ 18 19 #ifndef _STRINGS_H 20 #define _STRINGS_H 1 21 22 /* We don't need and should not read this file if <string.h> was already 23 read. The one exception being that if __USE_BSD isn't defined, then 24 these aren't defined in string.h, so we need to define them here. */ 25 #if !defined _STRING_H || !defined __USE_BSD 26 27 # include <features.h> 28 # define __need_size_t 29 # include <stddef.h> 30 31 /* Tell the caller that we provide correct C++ prototypes. */ 32 # if defined __cplusplus && __GNUC_PREREQ (4, 4) 33 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO 34 # endif 35 36 __BEGIN_DECLS 37 38 /* Compare N bytes of S1 and S2 (same as memcmp). */ 39 extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) 40 __THROW __attribute_pure__; 41 42 /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ 43 extern void bcopy (__const void *__src, void *__dest, size_t __n) __THROW; 44 45 /* Set N bytes of S to 0. */ 46 extern void bzero (void *__s, size_t __n) __THROW; 47 48 /* Return the position of the first bit set in I, or 0 if none are set. 49 The least-significant bit is position 1, the most-significant 32. */ 50 extern int ffs (int __i) __THROW __attribute__ ((const)); 51 52 /* Find the first occurrence of C in S (same as strchr). */ 53 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO 54 extern "C++" 55 { 56 extern char *index (char *__s, int __c) 57 __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); 58 extern __const char *index (__const char *__s, int __c) 59 __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); 60 61 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO 62 __extern_always_inline char * 63 index (char *__s, int __c) __THROW 64 { 65 return __builtin_index (__s, __c); 66 } 67 68 __extern_always_inline __const char * 69 index (__const char *__s, int __c) __THROW 70 { 71 return __builtin_index (__s, __c); 72 } 73 # endif 74 } 75 # else 76 extern char *index (__const char *__s, int __c) 77 __THROW __attribute_pure__ __nonnull ((1)); 78 # endif 79 80 /* Find the last occurrence of C in S (same as strrchr). */ 81 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO 82 extern "C++" 83 { 84 extern char *rindex (char *__s, int __c) 85 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); 86 extern __const char *rindex (__const char *__s, int __c) 87 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); 88 89 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO 90 __extern_always_inline char * 91 rindex (char *__s, int __c) __THROW 92 { 93 return __builtin_rindex (__s, __c); 94 } 95 96 __extern_always_inline __const char * 97 rindex (__const char *__s, int __c) __THROW 98 { 99 return __builtin_rindex (__s, __c); 100 } 101 #endif 102 } 103 # else 104 extern char *rindex (__const char *__s, int __c) 105 __THROW __attribute_pure__ __nonnull ((1)); 106 # endif 107 108 /* Compare S1 and S2, ignoring case. */ 109 extern int strcasecmp (__const char *__s1, __const char *__s2) 110 __THROW __attribute_pure__; 111 112 /* Compare no more than N chars of S1 and S2, ignoring case. */ 113 extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) 114 __THROW __attribute_pure__; 115 116 #ifdef __USE_XOPEN2K8 117 /* The following functions are equivalent to the both above but they 118 take the locale they use for the collation as an extra argument. 119 This is not standardsized but something like will come. */ 120 # include <xlocale.h> 121 122 /* Again versions of a few functions which use the given locale instead 123 of the global one. */ 124 extern int strcasecmp_l (__const char *__s1, __const char *__s2, 125 __locale_t __loc) 126 __THROW __attribute_pure__ __nonnull ((1, 2, 3)); 127 128 extern int strncasecmp_l (__const char *__s1, __const char *__s2, 129 size_t __n, __locale_t __loc) 130 __THROW __attribute_pure__ __nonnull ((1, 2, 4)); 131 #endif 132 133 __END_DECLS 134 135 #endif /* string.h */ 136 137 #endif /* strings.h */ 138