1 | /* string.h,v 1.13 2004/09/14 22:27:36 bird Exp */
|
---|
2 | /** @file
|
---|
3 | * FreeBSD 5.1
|
---|
4 | * @changed bird: EMXifications.
|
---|
5 | * @changed bird: GNU extension(s).
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*-
|
---|
9 | * Copyright (c) 1990, 1993
|
---|
10 | * The Regents of the University of California. All rights reserved.
|
---|
11 | *
|
---|
12 | * Redistribution and use in source and binary forms, with or without
|
---|
13 | * modification, are permitted provided that the following conditions
|
---|
14 | * are met:
|
---|
15 | * 1. Redistributions of source code must retain the above copyright
|
---|
16 | * notice, this list of conditions and the following disclaimer.
|
---|
17 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
18 | * notice, this list of conditions and the following disclaimer in the
|
---|
19 | * documentation and/or other materials provided with the distribution.
|
---|
20 | * 3. All advertising materials mentioning features or use of this software
|
---|
21 | * must display the following acknowledgement:
|
---|
22 | * This product includes software developed by the University of
|
---|
23 | * California, Berkeley and its contributors.
|
---|
24 | * 4. Neither the name of the University nor the names of its contributors
|
---|
25 | * may be used to endorse or promote products derived from this software
|
---|
26 | * without specific prior written permission.
|
---|
27 | *
|
---|
28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
38 | * SUCH DAMAGE.
|
---|
39 | *
|
---|
40 | * @(#)string.h 8.1 (Berkeley) 6/2/93
|
---|
41 | * $FreeBSD: src/include/string.h,v 1.18 2002/10/14 20:38:40 mike Exp $
|
---|
42 | */
|
---|
43 |
|
---|
44 | #ifndef _STRING_H_
|
---|
45 | #define _STRING_H_
|
---|
46 |
|
---|
47 | #include <sys/cdefs.h>
|
---|
48 | #include <sys/_types.h>
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Prototype functions which were historically defined in <string.h>, but
|
---|
52 | * are required by POSIX to be prototyped in <strings.h>.
|
---|
53 | */
|
---|
54 | #if __BSD_VISIBLE
|
---|
55 | #include <strings.h>
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: EMX */
|
---|
59 | typedef __size_t size_t;
|
---|
60 | #define _SIZE_T_DECLARED
|
---|
61 | #define _SIZE_T /* bird: EMX */
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #ifndef NULL
|
---|
65 | #define NULL 0
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | __BEGIN_DECLS
|
---|
69 | #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
|
---|
70 | void *memccpy(void * __restrict, const void * __restrict, int, size_t);
|
---|
71 | #endif
|
---|
72 | void *memchr(const void *, int, size_t);
|
---|
73 | int memcmp(const void *, const void *, size_t);
|
---|
74 | void *memcpy(void * __restrict, const void * __restrict, size_t);
|
---|
75 | void *memmove(void *, const void *, size_t);
|
---|
76 | void *memset(void *, int, size_t);
|
---|
77 | #if __BSD_VISIBLE
|
---|
78 | char *stpcpy(char *, const char *);
|
---|
79 | char *strcasestr(const char *, const char *);
|
---|
80 | #endif
|
---|
81 | char *strcat(char * __restrict, const char * __restrict);
|
---|
82 | char *strchr(const char *, int);
|
---|
83 | int strcmp(const char *, const char *);
|
---|
84 | int strcoll(const char *, const char *);
|
---|
85 | char *strcpy(char * __restrict, const char * __restrict);
|
---|
86 | size_t strcspn(const char *, const char *);
|
---|
87 | #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
|
---|
88 | char *strdup(const char *);
|
---|
89 | #endif
|
---|
90 | char *strerror(int);
|
---|
91 | #if __POSIX_VISIBLE >= 200112
|
---|
92 | int strerror_r(int, char *, size_t);
|
---|
93 | #endif
|
---|
94 | #if __BSD_VISIBLE
|
---|
95 | size_t strlcat(char *, const char *, size_t);
|
---|
96 | size_t strlcpy(char *, const char *, size_t);
|
---|
97 | #endif
|
---|
98 | size_t strlen(const char *);
|
---|
99 | #if __BSD_VISIBLE
|
---|
100 | void strmode(int, char *);
|
---|
101 | #endif
|
---|
102 | char *strncat(char * __restrict, const char * __restrict, size_t);
|
---|
103 | int strncmp(const char *, const char *, size_t);
|
---|
104 | char *strncpy(char * __restrict, const char * __restrict, size_t);
|
---|
105 | #if __BSD_VISIBLE
|
---|
106 | char *strnstr(const char *, const char *, size_t);
|
---|
107 | #endif
|
---|
108 | char *strpbrk(const char *, const char *);
|
---|
109 | char *strrchr(const char *, int);
|
---|
110 | #if __BSD_VISIBLE
|
---|
111 | char *strsep(char **, const char *);
|
---|
112 | char *strsignal(int);
|
---|
113 | #endif
|
---|
114 | size_t strspn(const char *, const char *);
|
---|
115 | char *strstr(const char *, const char *);
|
---|
116 | char *strtok(char * __restrict, const char * __restrict);
|
---|
117 | #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
|
---|
118 | char *strtok_r(char *, const char *, char **);
|
---|
119 | #endif
|
---|
120 | size_t strxfrm(char * __restrict, const char * __restrict, size_t);
|
---|
121 | #if __BSD_VISIBLE
|
---|
122 | # ifndef _SWAB_DECLARED /* bird: also in unistd.h */
|
---|
123 | # define _SWAB_DECLARED /* bird: also in unistd.h */
|
---|
124 | # if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T)
|
---|
125 | typedef __ssize_t ssize_t;
|
---|
126 | # define _SSIZE_T_DECLARED
|
---|
127 | # define _SSIZE_T
|
---|
128 | # endif
|
---|
129 | void swab(const void * __restrict, void * __restrict, ssize_t);
|
---|
130 | # endif /* !_SWAB_DECLARED */ /* bird: also in unistd.h */
|
---|
131 | #endif
|
---|
132 |
|
---|
133 |
|
---|
134 | /* bird: EMX stuff - start */
|
---|
135 |
|
---|
136 | #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
|
---|
137 | #if !defined (_MEMDIF_EQ)
|
---|
138 | #define _MEMDIF_EQ 0xffffffff
|
---|
139 | #endif
|
---|
140 | int memicmp(const void *, const void *, size_t);
|
---|
141 | int stricmp(const char *, const char *);
|
---|
142 | char * strlwr(char *);
|
---|
143 | int strnicmp(const char *, const char *, size_t);
|
---|
144 | char * strnset(char *, int, size_t);
|
---|
145 | char * strrev(char *);
|
---|
146 | char * strset(char *, int);
|
---|
147 | char * strupr(char *);
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | #if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
|
---|
151 | size_t _memcount (const void *, int, size_t);
|
---|
152 | size_t _memdif (const void *, const void *, size_t);
|
---|
153 | void *_memrchr (const void *, int, size_t);
|
---|
154 | void _memswap (void *, void *, size_t);
|
---|
155 | char *_strncpy (char *, const char *, size_t);
|
---|
156 | void *_memccpy (void *, const void *, int, size_t);
|
---|
157 | int _memicmp (const void *, const void *, size_t);
|
---|
158 | char *_strdup (const char *);
|
---|
159 | int _stricmp (const char *, const char *);
|
---|
160 | char *_strlwr (char *);
|
---|
161 | int _strnicmp (const char *, const char *, size_t);
|
---|
162 | char *_strnset (char *, int, size_t);
|
---|
163 | char *_strrev (char *);
|
---|
164 | char *_strset (char *, int);
|
---|
165 | char *_strupr (char *);
|
---|
166 | char *_strsep (char **, const char *);
|
---|
167 | #endif
|
---|
168 |
|
---|
169 | /* bird: EMX stuff - end */
|
---|
170 |
|
---|
171 | /* bird: LIBC extensions - start */
|
---|
172 | #ifdef __USE_EMX
|
---|
173 | void *_memcpy_amd(void *, const void *, size_t);
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | /* bird: LIBC extensions - end */
|
---|
177 |
|
---|
178 | /* bird: GNU stuff - start */
|
---|
179 | #ifdef __USE_GNU
|
---|
180 | char *basename(const char *);
|
---|
181 | size_t strnlen(const char *, size_t);
|
---|
182 | void *mempcpy(void *, const void *, size_t);
|
---|
183 | char *strndup(const char *, size_t);
|
---|
184 | void *memrchr(const void *, int, size_t);
|
---|
185 | #define memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
|
---|
186 | int strverscmp(const char *, const char *);
|
---|
187 | char *strchrnul(const char *, int);
|
---|
188 | void *rawmemchr(const void *, int);
|
---|
189 | char *stpncpy(char *, const char *, int);
|
---|
190 |
|
---|
191 | size_t __strnlen(const char *, size_t);
|
---|
192 | void *__mempcpy(void *, const void *, size_t);
|
---|
193 | char *__strndup(const char *, size_t);
|
---|
194 | void *_memrchr(const void *, int, size_t);
|
---|
195 | void *__memrchr(const void *, int, size_t);
|
---|
196 | #define __memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
|
---|
197 | int __strverscmp(const char *, const char *);
|
---|
198 | char *__strchrnul(const char *, int);
|
---|
199 | void *__rawmemchr(const void *, int);
|
---|
200 | char *__stpncpy(char *, const char *, int);
|
---|
201 |
|
---|
202 | #define strdupa(psz) \
|
---|
203 | (__extension__({ \
|
---|
204 | const char *__pszInput = (psz); \
|
---|
205 | size_t __cchInput = strlen(__pszInput) + 1; \
|
---|
206 | char *__pszReturn = __builtin_alloca(__cchInput); \
|
---|
207 | (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
|
---|
208 | }))
|
---|
209 |
|
---|
210 | #define strndupa(psz, cch) \
|
---|
211 | (__extension__({ \
|
---|
212 | const char *__pszInput = (psz); \
|
---|
213 | size_t __cchInput = strnlen(__pszInput, (cch)); \
|
---|
214 | char *__pszReturn = __builtin_alloca(__cchInput + 1); \
|
---|
215 | __pszReturn[__cchInput] = '\0'; \
|
---|
216 | (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
|
---|
217 | }))
|
---|
218 |
|
---|
219 | #endif
|
---|
220 | /* bird: GNU stuff - end */
|
---|
221 |
|
---|
222 | __END_DECLS
|
---|
223 |
|
---|
224 | #endif /* _STRING_H_ */
|
---|
225 |
|
---|