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