1/* Copyright (C) 1991-2014 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#if !defined _STRING_H || !defined __USE_BSD
25
26# include <features.h>
27# define __need_size_t
28# include <stddef.h>
29
30/* Provide correct C++ prototypes, and indicate this to the caller. This
31 requires a compatible C++ standard library. As a heuristic, we provide
32 these when the compiler indicates full conformance with C++98 or later,
33 and for older GCC versions that are known to provide a compatible
34 libstdc++. */
35# if defined __cplusplus && (__cplusplus >= 199711L || __GNUC_PREREQ (4, 4))
36# define __CORRECT_ISO_CPP_STRINGS_H_PROTO
37# endif
38
39__BEGIN_DECLS
40
41# if defined __USE_MISC || !defined __USE_XOPEN2K8
42/* Compare N bytes of S1 and S2 (same as memcmp). */
43extern int bcmp (const void *__s1, const void *__s2, size_t __n)
44 __THROW __attribute_pure__;
45
46/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
47extern void bcopy (const void *__src, void *__dest, size_t __n) __THROW;
48
49/* Set N bytes of S to 0. */
50extern void bzero (void *__s, size_t __n) __THROW;
51
52/* Find the first occurrence of C in S (same as strchr). */
53# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
54extern "C++"
55{
56extern char *index (char *__s, int __c)
57 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
58extern 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 *
63index (char *__s, int __c) __THROW
64{
65 return __builtin_index (__s, __c);
66}
67
68__extern_always_inline const char *
69index (const char *__s, int __c) __THROW
70{
71 return __builtin_index (__s, __c);
72}
73# endif
74}
75# else
76extern 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
82extern "C++"
83{
84extern char *rindex (char *__s, int __c)
85 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
86extern 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 *
91rindex (char *__s, int __c) __THROW
92{
93 return __builtin_rindex (__s, __c);
94}
95
96__extern_always_inline const char *
97rindex (const char *__s, int __c) __THROW
98{
99 return __builtin_rindex (__s, __c);
100}
101# endif
102}
103# else
104extern char *rindex (const char *__s, int __c)
105 __THROW __attribute_pure__ __nonnull ((1));
106# endif
107# endif
108
109#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
110/* Return the position of the first bit set in I, or 0 if none are set.
111 The least-significant bit is position 1, the most-significant 32. */
112extern int ffs (int __i) __THROW __attribute__ ((const));
113#endif
114
115/* Compare S1 and S2, ignoring case. */
116extern int strcasecmp (const char *__s1, const char *__s2)
117 __THROW __attribute_pure__;
118
119/* Compare no more than N chars of S1 and S2, ignoring case. */
120extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
121 __THROW __attribute_pure__;
122
123#ifdef __USE_XOPEN2K8
124/* The following functions are equivalent to the both above but they
125 take the locale they use for the collation as an extra argument.
126 This is not standardsized but something like will come. */
127# include <xlocale.h>
128
129/* Again versions of a few functions which use the given locale instead
130 of the global one. */
131extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc)
132 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
133
134extern int strncasecmp_l (const char *__s1, const char *__s2,
135 size_t __n, __locale_t __loc)
136 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
137#endif
138
139__END_DECLS
140
141#endif /* string.h */
142
143#endif /* strings.h */
144