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, see 16 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _STRINGS_H 19 #define _STRINGS_H 1 20 21 /* We don't need and should not read this file if <string.h> was already 22 read. The one exception being that if __USE_BSD isn't defined, then 23 these aren't defined in string.h, so we need to define them here. */ 24 25 /* keep this file in sync w/ string.h, the glibc version is out of date */ 26 27 #if !defined _STRING_H || !defined __USE_BSD 28 29 # include <features.h> 30 # define __need_size_t 31 # include <stddef.h> 32 33 __BEGIN_DECLS 34 35 # ifdef __UCLIBC_SUSV3_LEGACY__ 36 /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ 37 extern void bcopy (const void *__src, void *__dest, size_t __n) 38 __THROW __nonnull ((1, 2)); 39 40 /* Set N bytes of S to 0. */ 41 extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); 42 43 /* Compare N bytes of S1 and S2 (same as memcmp). */ 44 extern int bcmp (const void *__s1, const void *__s2, size_t __n) 45 __THROW __attribute_pure__ __nonnull ((1, 2)); 46 47 /* Find the first occurrence of C in S (same as strchr). */ 48 extern char *index (const char *__s, int __c) 49 __THROW __attribute_pure__ __nonnull ((1)); 50 51 /* Find the last occurrence of C in S (same as strrchr). */ 52 extern char *rindex (const char *__s, int __c) 53 __THROW __attribute_pure__ __nonnull ((1)); 54 # else 55 # ifdef __UCLIBC_SUSV3_LEGACY_MACROS__ 56 /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3. 57 * They are replaced as proposed by SuSv3. Don't sync this part 58 * with glibc and keep it in sync with string.h. */ 59 60 # define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0) 61 # define bzero(s,n) (memset((s), '\0', (n)), (void) 0) 62 # define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n)) 63 # define index(s,c) strchr((s), (c)) 64 # define rindex(s,c) strrchr((s), (c)) 65 # endif 66 # endif 67 68 /* Return the position of the first bit set in I, or 0 if none are set. 69 The least-significant bit is position 1, the most-significant 32. */ 70 extern int ffs (int __i) __THROW __attribute__ ((__const__)); 71 libc_hidden_proto(ffs) 72 73 /* The following two functions are non-standard but necessary for non-32 bit 74 platforms. */ 75 # ifdef __USE_GNU 76 extern int ffsl (long int __l) __THROW __attribute__ ((__const__)); 77 # ifdef __GNUC__ 78 __extension__ extern int ffsll (long long int __ll) 79 __THROW __attribute__ ((__const__)); 80 # endif 81 # endif 82 83 /* Compare S1 and S2, ignoring case. */ 84 extern int strcasecmp (const char *__s1, const char *__s2) 85 __THROW __attribute_pure__ __nonnull ((1, 2)); 86 libc_hidden_proto(strcasecmp) 87 88 /* Compare no more than N chars of S1 and S2, ignoring case. */ 89 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) 90 __THROW __attribute_pure__ __nonnull ((1, 2)); 91 libc_hidden_proto(strncasecmp) 92 93 #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__ 94 /* The following functions are equivalent to the both above but they 95 take the locale they use for the collation as an extra argument. 96 This is not standardsized but something like will come. */ 97 # include <xlocale.h> 98 99 /* Again versions of a few functions which use the given locale instead 100 of the global one. */ 101 extern int strcasecmp_l (const char *__s1, const char *__s2, 102 __locale_t __loc) 103 __THROW __attribute_pure__ __nonnull ((1, 2, 3)); 104 libc_hidden_proto(strcasecmp_l) 105 106 extern int strncasecmp_l (const char *__s1, const char *__s2, 107 size_t __n, __locale_t __loc) 108 __THROW __attribute_pure__ __nonnull ((1, 2, 4)); 109 libc_hidden_proto(strncasecmp_l) 110 #endif 111 __END_DECLS 112 113 114 #ifdef _LIBC 115 /* comment is wrong and will face this, when HAS_GNU option will be added 116 * header is SuSv standard */ 117 #error "<strings.h> should not be included from libc." 118 #endif 119 120 121 #endif /* string.h */ 122 123 #endif /* strings.h */ 124