1 /*
2  * string.h
3  *
4  * Definitions for memory and string functions.
5  */
6 
7 #ifndef _STRING_H_
8 #define	_STRING_H_
9 
10 #include "_ansi.h"
11 #include <sys/cdefs.h>
12 #include <sys/features.h>
13 
14 #define __need_size_t
15 #define __need_NULL
16 #include <stddef.h>
17 
18 #if __POSIX_VISIBLE >= 200809
19 #include <sys/_locale.h>
20 #endif
21 
22 #if __BSD_VISIBLE
23 #include <strings.h>
24 #endif
25 
26 _BEGIN_STD_C
27 
28 void *	 memchr (const void *, int, size_t);
29 int 	 memcmp (const void *, const void *, size_t);
30 void *	 memcpy (void *__restrict, const void *__restrict, size_t);
31 void *	 memmove (void *, const void *, size_t);
32 void *	 memset (void *, int, size_t);
33 char 	*strcat (char *__restrict, const char *__restrict);
34 char 	*strchr (const char *, int);
35 int	 strcmp (const char *, const char *);
36 int	 strcoll (const char *, const char *);
37 char 	*strcpy (char *__restrict, const char *__restrict);
38 size_t	 strcspn (const char *, const char *);
39 char 	*strerror (int);
40 size_t	 strlen (const char *);
41 char 	*strncat (char *__restrict, const char *__restrict, size_t);
42 int	 strncmp (const char *, const char *, size_t);
43 char 	*strncpy (char *__restrict, const char *__restrict, size_t);
44 char 	*strpbrk (const char *, const char *);
45 char 	*strrchr (const char *, int);
46 size_t	 strspn (const char *, const char *);
47 char 	*strstr (const char *, const char *);
48 #ifndef _REENT_ONLY
49 char 	*strtok (char *__restrict, const char *__restrict);
50 #endif
51 size_t	 strxfrm (char *__restrict, const char *__restrict, size_t);
52 
53 #if __POSIX_VISIBLE >= 200809
54 int	 strcoll_l (const char *, const char *, locale_t);
55 char	*strerror_l (int, locale_t);
56 size_t	 strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
57 #endif
58 #if __MISC_VISIBLE || __POSIX_VISIBLE
59 char 	*strtok_r (char *__restrict, const char *__restrict, char **__restrict);
60 #endif
61 #if __BSD_VISIBLE
62 int	 timingsafe_bcmp (const void *, const void *, size_t);
63 int	 timingsafe_memcmp (const void *, const void *, size_t);
64 #endif
65 #if __MISC_VISIBLE || __POSIX_VISIBLE
66 void *	 memccpy (void *__restrict, const void *__restrict, int, size_t);
67 #endif
68 #if __GNU_VISIBLE
69 void *	 mempcpy (void *, const void *, size_t);
70 void *	 memmem (const void *, size_t, const void *, size_t);
71 void *	 memrchr (const void *, int, size_t);
72 void *	 rawmemchr (const void *, int);
73 #endif
74 #if __POSIX_VISIBLE >= 200809
75 char 	*stpcpy (char *__restrict, const char *__restrict);
76 char 	*stpncpy (char *__restrict, const char *__restrict, size_t);
77 #endif
78 #if __GNU_VISIBLE
79 char	*strcasestr (const char *, const char *);
80 char 	*strchrnul (const char *, int);
81 #endif
82 #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
83 char 	*strdup (const char *) __malloc_like __result_use_check;
84 #endif
85 #if __POSIX_VISIBLE >= 200809
86 char 	*strndup (const char *, size_t) __malloc_like __result_use_check;
87 #endif
88 
89 /* There are two common strerror_r variants.  If you request
90    _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
91    version.  POSIX requires that #undef strerror_r will still let you
92    invoke the underlying function, but that requires gcc support.  */
93 #if __GNU_VISIBLE
94 char	*strerror_r (int, char *, size_t);
95 #elif __POSIX_VISIBLE >= 200112
96 # ifdef __GNUC__
97 int	strerror_r (int, char *, size_t)
98 #ifdef __ASMNAME
99              __asm__ (__ASMNAME ("__xpg_strerror_r"))
100 #endif
101   ;
102 # else
103 int	__xpg_strerror_r (int, char *, size_t);
104 #  define strerror_r __xpg_strerror_r
105 # endif
106 #endif
107 
108 /* Reentrant version of strerror.  */
109 char *	_strerror_r (int, int, int *);
110 
111 #if __BSD_VISIBLE
112 size_t	strlcat (char *, const char *, size_t);
113 size_t	strlcpy (char *, const char *, size_t);
114 #endif
115 #if __POSIX_VISIBLE >= 200809
116 size_t	 strnlen (const char *, size_t);
117 #endif
118 #if __BSD_VISIBLE
119 char 	*strsep (char **, const char *);
120 #endif
121 #if __BSD_VISIBLE
122 char    *strnstr(const char *, const char *, size_t) __pure;
123 #endif
124 
125 #if __MISC_VISIBLE
126 char	*strlwr (char *);
127 char	*strupr (char *);
128 #endif
129 
130 #ifndef DEFS_H	/* Kludge to work around problem compiling in gdb */
131 char	*strsignal (int __signo);
132 #endif
133 
134 #ifdef __CYGWIN__
135 int	strtosigno (const char *__name);
136 #endif
137 
138 #if __GNU_VISIBLE
139 int	 strverscmp (const char *, const char *);
140 #endif
141 
142 #if __GNU_VISIBLE && defined(__GNUC__)
143 #define strdupa(__s) \
144 	(__extension__ ({const char *__sin = (__s); \
145 			 size_t __len = strlen (__sin) + 1; \
146 			 char * __sout = (char *) __builtin_alloca (__len); \
147 			 (char *) memcpy (__sout, __sin, __len);}))
148 #define strndupa(__s, __n) \
149 	(__extension__ ({const char *__sin = (__s); \
150 			 size_t __len = strnlen (__sin, (__n)) + 1; \
151 			 char *__sout = (char *) __builtin_alloca (__len); \
152 			 __sout[__len-1] = '\0'; \
153 			 (char *) memcpy (__sout, __sin, __len-1);}))
154 #endif /* __GNU_VISIBLE && __GNUC__ */
155 
156 /* There are two common basename variants.  If you do NOT #include <libgen.h>
157    and you do
158 
159      #define _GNU_SOURCE
160      #include <string.h>
161 
162    you get the GNU version.  Otherwise you get the POSIX versionfor which you
163    should #include <libgen.h>i for the function prototype.  POSIX requires that
164    #undef basename will still let you invoke the underlying function.  However,
165    this also implies that the POSIX version is used in this case.  That's made
166    sure here. */
167 #if __GNU_VISIBLE && !defined(basename)
168 # define basename basename
169 char	*__nonnull ((1)) basename (const char *) __asm__(__ASMNAME("__gnu_basename"));
170 #endif
171 
172 #include <sys/string.h>
173 
174 _END_STD_C
175 
176 #if __SSP_FORTIFY_LEVEL > 0
177 #include <ssp/string.h>
178 #endif
179 
180 #endif /* _STRING_H_ */
181