| 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 | void swab(const void *, void *, size_t);
|
|---|
| 123 | #endif
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 | /* bird: EMX stuff - start */
|
|---|
| 127 |
|
|---|
| 128 | #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
|
|---|
| 129 | #if !defined (_MEMDIF_EQ)
|
|---|
| 130 | #define _MEMDIF_EQ 0xffffffff
|
|---|
| 131 | #endif
|
|---|
| 132 | int memicmp(__const__ void *, __const__ void *, size_t);
|
|---|
| 133 | int stricmp(__const__ char *, __const__ char *);
|
|---|
| 134 | char * strlwr(char *);
|
|---|
| 135 | int strnicmp(__const__ char *, __const__ char *, size_t);
|
|---|
| 136 | char * strnset(char *, int, size_t);
|
|---|
| 137 | char * strrev(char *);
|
|---|
| 138 | char * strset(char *, int);
|
|---|
| 139 | char * strupr(char *);
|
|---|
| 140 | #endif
|
|---|
| 141 |
|
|---|
| 142 | #if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
|
|---|
| 143 | size_t _memcount (__const__ void *, int, size_t);
|
|---|
| 144 | size_t _memdif (__const__ void *, __const__ void *, size_t);
|
|---|
| 145 | void *_memrchr (const void *, int, size_t);
|
|---|
| 146 | void _memswap (void *, void *, size_t);
|
|---|
| 147 | char *_strncpy (char *, __const__ char *, size_t);
|
|---|
| 148 | void *_memccpy (void *, __const__ void *, int, size_t);
|
|---|
| 149 | int _memicmp (__const__ void *, __const__ void *, size_t);
|
|---|
| 150 | char *_strdup (__const__ char *);
|
|---|
| 151 | int _stricmp (__const__ char *, __const__ char *);
|
|---|
| 152 | char *_strlwr (char *);
|
|---|
| 153 | int _strnicmp (__const__ char *, __const__ char *, size_t);
|
|---|
| 154 | char *_strnset (char *, int, size_t);
|
|---|
| 155 | char *_strrev (char *);
|
|---|
| 156 | char *_strset (char *, int);
|
|---|
| 157 | char *_strupr (char *);
|
|---|
| 158 | char *_strsep (char **, __const__ char *);
|
|---|
| 159 | #endif
|
|---|
| 160 |
|
|---|
| 161 | /* bird: EMX stuff - end */
|
|---|
| 162 |
|
|---|
| 163 | /* bird: LIBC extensions - start */
|
|---|
| 164 | #ifdef __USE_EMX
|
|---|
| 165 | void *_memcpy_amd(void *, const void *, size_t);
|
|---|
| 166 | #endif
|
|---|
| 167 |
|
|---|
| 168 | /* bird: LIBC extensions - end */
|
|---|
| 169 |
|
|---|
| 170 | /* bird: GNU stuff - start */
|
|---|
| 171 | #ifdef __USE_GNU
|
|---|
| 172 | char *basename(const char *);
|
|---|
| 173 | size_t strnlen(const char *, size_t);
|
|---|
| 174 | void *mempcpy(void *, const void *, size_t);
|
|---|
| 175 | char *strndup(const char *, size_t);
|
|---|
| 176 | void *memrchr(const void *, int, size_t);
|
|---|
| 177 | #define memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
|
|---|
| 178 | int strverscmp(const char *, const char *);
|
|---|
| 179 | char *strchrnul(const char *, int);
|
|---|
| 180 | void *rawmemchr(const void *, int);
|
|---|
| 181 | char *stpncpy(char *, const char *, int);
|
|---|
| 182 |
|
|---|
| 183 | size_t __strnlen(const char *, size_t);
|
|---|
| 184 | void *__mempcpy(void *, const void *, size_t);
|
|---|
| 185 | char *__strndup(const char *, size_t);
|
|---|
| 186 | void *_memrchr(const void *, int, size_t);
|
|---|
| 187 | void *__memrchr(const void *, int, size_t);
|
|---|
| 188 | #define __memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
|
|---|
| 189 | int __strverscmp(const char *, const char *);
|
|---|
| 190 | char *__strchrnul(const char *, int);
|
|---|
| 191 | void *__rawmemchr(const void *, int);
|
|---|
| 192 | char *__stpncpy(char *, const char *, int);
|
|---|
| 193 |
|
|---|
| 194 | #define strdupa(psz) \
|
|---|
| 195 | (__extension__({ \
|
|---|
| 196 | __const__ char *__pszInput = (psz); \
|
|---|
| 197 | size_t __cchInput = strlen(__pszInput) + 1; \
|
|---|
| 198 | char *__pszReturn = __builtin_alloca(__cchInput); \
|
|---|
| 199 | (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
|
|---|
| 200 | }))
|
|---|
| 201 |
|
|---|
| 202 | #define strndupa(psz, cch) \
|
|---|
| 203 | (__extension__({ \
|
|---|
| 204 | __const__ char *__pszInput = (psz); \
|
|---|
| 205 | size_t __cchInput = strnlen(__pszInput, (cch)); \
|
|---|
| 206 | char *__pszReturn = __builtin_alloca(__cchInput + 1); \
|
|---|
| 207 | __pszReturn[__cchInput] = '\0'; \
|
|---|
| 208 | (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
|
|---|
| 209 | }))
|
|---|
| 210 |
|
|---|
| 211 | #endif
|
|---|
| 212 | /* bird: GNU stuff - end */
|
|---|
| 213 |
|
|---|
| 214 | __END_DECLS
|
|---|
| 215 |
|
|---|
| 216 | #endif /* _STRING_H_ */
|
|---|
| 217 |
|
|---|