| 1 | /* | 
 
 
 
 
 | 2 | * string.h | 
 
 
 
 
 | 3 | * | 
 
 
 
 
 | 4 | * ISO-C standard header, with MSVC compatible extensions. | 
 
 
 
 
 | 5 | * | 
 
 
 
 
 | 6 | * $Id: string.h,v 7c13c3b4989e 2016/05/12 12:51:37 keithmarshall $ | 
 
 
 
 
 | 7 | * | 
 
 
 
 
 | 8 | * Written by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> | 
 
 
 
 
 | 9 | * Copyright (C) 1997-2000, 2002-2004, 2007, 2009, 2015, 2016, | 
 
 
 
 
 | 10 | *  MinGW.org Project. | 
 
 
 
 
 | 11 | * | 
 
 
 
 
 | 12 | * | 
 
 
 
 
 | 13 | * Permission is hereby granted, free of charge, to any person obtaining a | 
 
 
 
 
 | 14 | * copy of this software and associated documentation files (the "Software"), | 
 
 
 
 
 | 15 | * to deal in the Software without restriction, including without limitation | 
 
 
 
 
 | 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
 
 
 
 
 | 17 | * and/or sell copies of the Software, and to permit persons to whom the | 
 
 
 
 
 | 18 | * Software is furnished to do so, subject to the following conditions: | 
 
 
 
 
 | 19 | * | 
 
 
 
 
 | 20 | * The above copyright notice, this permission notice, and the following | 
 
 
 
 
 | 21 | * disclaimer shall be included in all copies or substantial portions of | 
 
 
 
 
 | 22 | * the Software. | 
 
 
 
 
 | 23 | * | 
 
 
 
 
 | 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 
 
 
 
 
 | 25 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
 
 
 
 
 | 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL | 
 
 
 
 
 | 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
 
 
 
 
 | 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 
 
 
 
 
 | 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER | 
 
 
 
 
 | 30 | * DEALINGS IN THE SOFTWARE. | 
 
 
 
 
 | 31 | * | 
 
 
 
 
 | 32 | */ | 
 
 
 
 
 | 33 | #ifndef _STRING_H | 
 
 
 
 
 | 34 | #pragma GCC system_header | 
 
 
 
 
 | 35 | #define _STRING_H | 
 
 
 
 
 | 36 |  | 
 
 
 
 
 | 37 | /* All MinGW system headers must include this... | 
 
 
 
 
 | 38 | */ | 
 
 
 
 
 | 39 | #include <_mingw.h> | 
 
 
 
 
 | 40 |  | 
 
 
 
 
 | 41 | #ifndef RC_INVOKED | 
 
 
 
 
 | 42 | /* ISO-C requires this header to expose definitions for NULL and size_t, | 
 
 
 
 
 | 43 | * retaining compatiblity with their fundamental <stddef.h> definitions. | 
 
 
 
 
 | 44 | */ | 
 
 
 
 
 | 45 | #define __need_NULL | 
 
 
 
 
 | 46 | #define __need_size_t | 
 
 
 
 
 | 47 | #ifndef __STRICT_ANSI__ | 
 
 
 
 
 | 48 | /* MSVC extends this requirement to include a definition of wchar_t, | 
 
 
 
 
 | 49 | * (which contravenes strict ISO-C standards conformity). | 
 
 
 
 
 | 50 | */ | 
 
 
 
 
 | 51 | # define __need_wchar_t | 
 
 
 
 
 | 52 | #endif | 
 
 
 
 
 | 53 | #include <stddef.h> | 
 
 
 
 
 | 54 |  | 
 
 
 
 
 | 55 | _BEGIN_C_DECLS | 
 
 
 
 
 | 56 |  | 
 
 
 
 
 | 57 | #define __STRING_H_SOURCED__ | 
 
 
 
 
 | 58 | /* Prototypes for the ISO-C Standard library string functions. | 
 
 
 
 
 | 59 | */ | 
 
 
 
 
 | 60 | _CRTIMP __cdecl __MINGW_NOTHROW  void *memchr (const void *, int, size_t) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 61 | _CRTIMP __cdecl __MINGW_NOTHROW  int memcmp (const void *, const void *, size_t) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 62 | _CRTIMP __cdecl __MINGW_NOTHROW  void *memcpy (void *, const void *, size_t); | 
 
 
 
 
 | 63 | _CRTIMP __cdecl __MINGW_NOTHROW  void *memmove (void *, const void *, size_t); | 
 
 
 
 
 | 64 | _CRTIMP __cdecl __MINGW_NOTHROW  void *memset (void *, int, size_t); | 
 
 
 
 
 | 65 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strcat (char *, const char *); | 
 
 
 
 
 | 66 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strchr (const char *, int) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 67 | _CRTIMP __cdecl __MINGW_NOTHROW  int strcmp (const char *, const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 68 | _CRTIMP __cdecl __MINGW_NOTHROW  int strcoll (const char *, const char *); /* Compare using locale */ | 
 
 
 
 
 | 69 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strcpy (char *, const char *); | 
 
 
 
 
 | 70 | _CRTIMP __cdecl __MINGW_NOTHROW  size_t strcspn (const char *, const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 71 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strerror (int); /* NOTE: NOT an old name wrapper. */ | 
 
 
 
 
 | 72 |  | 
 
 
 
 
 | 73 | _CRTIMP __cdecl __MINGW_NOTHROW  size_t strlen (const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 74 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strncat (char *, const char *, size_t); | 
 
 
 
 
 | 75 | _CRTIMP __cdecl __MINGW_NOTHROW  int strncmp (const char *, const char *, size_t) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 76 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strncpy (char *, const char *, size_t); | 
 
 
 
 
 | 77 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strpbrk (const char *, const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 78 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strrchr (const char *, int) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 79 | _CRTIMP __cdecl __MINGW_NOTHROW  size_t strspn (const char *, const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 80 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strstr (const char *, const char *) __MINGW_ATTRIB_PURE; | 
 
 
 
 
 | 81 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strtok (char *, const char *); | 
 
 
 
 
 | 82 | _CRTIMP __cdecl __MINGW_NOTHROW  size_t strxfrm (char *, const char *, size_t); | 
 
 
 
 
 | 83 |  | 
 
 
 
 
 | 84 | #ifndef __STRICT_ANSI__ | 
 
 
 
 
 | 85 | /* | 
 
 
 
 
 | 86 | * Extra non-ANSI functions provided by the CRTDLL library | 
 
 
 
 
 | 87 | */ | 
 
 
 
 
 | 88 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strerror (const char *); | 
 
 
 
 
 | 89 | _CRTIMP __cdecl __MINGW_NOTHROW  void *_memccpy (void *, const void *, int, size_t); | 
 
 
 
 
 | 90 | _CRTIMP __cdecl __MINGW_NOTHROW  int _memicmp (const void *, const void *, size_t); | 
 
 
 
 
 | 91 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strdup (const char *) __MINGW_ATTRIB_MALLOC; | 
 
 
 
 
 | 92 | _CRTIMP __cdecl __MINGW_NOTHROW  int _strcmpi (const char *, const char *); | 
 
 
 
 
 | 93 | _CRTIMP __cdecl __MINGW_NOTHROW  int _stricoll (const char *, const char *); | 
 
 
 
 
 | 94 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strlwr (char *); | 
 
 
 
 
 | 95 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strnset (char *, int, size_t); | 
 
 
 
 
 | 96 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strrev (char *); | 
 
 
 
 
 | 97 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strset (char *, int); | 
 
 
 
 
 | 98 | _CRTIMP __cdecl __MINGW_NOTHROW  char *_strupr (char *); | 
 
 
 
 
 | 99 | _CRTIMP __cdecl __MINGW_NOTHROW  void _swab (const char *, char *, size_t); | 
 
 
 
 
 | 100 |  | 
 
 
 
 
 | 101 | /* MSVC's non-ANSI _stricmp() and _strnicmp() functions must also be | 
 
 
 
 
 | 102 | * prototyped here, but we need to share them with <strings.h>, where | 
 
 
 
 
 | 103 | * we declare their POSIX strcasecmp() and strncasecmp() equivalents; | 
 
 
 
 
 | 104 | * get the requisite prototypes by selective <strings.h> inclusion. | 
 
 
 
 
 | 105 | */ | 
 
 
 
 
 | 106 | #include <strings.h> | 
 
 
 
 
 | 107 |  | 
 
 
 
 
 | 108 | # ifdef __MSVCRT__ | 
 
 
 
 
 | 109 | /* These were not present in the CRTDLL prior to the first release of | 
 
 
 
 
 | 110 | * MSVCRT.DLL, but are available in all versions of that library. | 
 
 
 
 
 | 111 | */ | 
 
 
 
 
 | 112 | _CRTIMP __cdecl __MINGW_NOTHROW  int _strncoll(const char *, const char *, size_t); | 
 
 
 
 
 | 113 | _CRTIMP __cdecl __MINGW_NOTHROW  int _strnicoll(const char *, const char *, size_t); | 
 
 
 
 
 | 114 | # endif | 
 
 
 
 
 | 115 |  | 
 
 
 
 
 | 116 | # ifndef _NO_OLDNAMES | 
 
 
 
 
 | 117 | /* Non-underscore decorated versions of non-ANSI functions. They live in the | 
 
 
 
 
 | 118 | * OLDNAMES libraries, whence they provide a little extra portability. | 
 
 
 
 
 | 119 | */ | 
 
 
 
 
 | 120 | _CRTIMP __cdecl __MINGW_NOTHROW  void *memccpy (void *, const void *, int, size_t); | 
 
 
 
 
 | 121 | _CRTIMP __cdecl __MINGW_NOTHROW  int memicmp (const void *, const void *, size_t); | 
 
 
 
 
 | 122 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strdup (const char *) __MINGW_ATTRIB_MALLOC; | 
 
 
 
 
 | 123 | _CRTIMP __cdecl __MINGW_NOTHROW  int strcmpi (const char *, const char *); | 
 
 
 
 
 | 124 | _CRTIMP __cdecl __MINGW_NOTHROW  int stricmp (const char *, const char *); | 
 
 
 
 
 | 125 | _CRTIMP __cdecl __MINGW_NOTHROW  int stricoll (const char *, const char *); | 
 
 
 
 
 | 126 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strlwr (char *); | 
 
 
 
 
 | 127 | _CRTIMP __cdecl __MINGW_NOTHROW  int strnicmp (const char *, const char *, size_t); | 
 
 
 
 
 | 128 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strnset (char *, int, size_t); | 
 
 
 
 
 | 129 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strrev (char *); | 
 
 
 
 
 | 130 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strset (char *, int); | 
 
 
 
 
 | 131 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strupr (char *); | 
 
 
 
 
 | 132 |  | 
 
 
 
 
 | 133 | #  ifndef _UWIN | 
 
 
 
 
 | 134 | /* FIXME: Do we really care that UWin doesn't support this?  We are | 
 
 
 
 
 | 135 | * under no obligation to support UWin. | 
 
 
 
 
 | 136 | */ | 
 
 
 
 
 | 137 | _CRTIMP __cdecl __MINGW_NOTHROW  void swab (const char *, char *, size_t); | 
 
 
 
 
 | 138 |  | 
 
 
 
 
 | 139 | #  endif /* ! _UWIN */ | 
 
 
 
 
 | 140 | # endif /* ! _NO_OLDNAMES */ | 
 
 
 
 
 | 141 |  | 
 
 
 
 
 | 142 | /* MSVC also expects <string.h> to declare duplicates of the wchar_t | 
 
 
 
 
 | 143 | * string functions which are nominally declared in <wchar.h>, (which | 
 
 
 
 
 | 144 | * is where ISO-C specifies that they should be declared).  For the | 
 
 
 
 
 | 145 | * convenience of applications which rely on this Microsoft anomaly, | 
 
 
 
 
 | 146 | * inclusion of <wchar.h>, within the current __STRING_H_SOURCED__ | 
 
 
 
 
 | 147 | * scope, will selectively expose the required function prototypes; | 
 
 
 
 
 | 148 | * however, strictly ISO-C conforming applications should include | 
 
 
 
 
 | 149 | * <wchar.h> directly; they should not rely on this MSVC specific | 
 
 
 
 
 | 150 | * anomalous behaviour. | 
 
 
 
 
 | 151 | */ | 
 
 
 
 
 | 152 | #include <wchar.h> | 
 
 
 
 
 | 153 |  | 
 
 
 
 
 | 154 | #endif /* ! __STRICT_ANSI__ */ | 
 
 
 
 
 | 155 |  | 
 
 
 
 
 | 156 | #if __MSVCRT_VERSION__ >= __MSVCR80_DLL | 
 
 
 
 
 | 157 | /* MSVCR80.DLL adds a (mostly) POSIX.1-2008 conforming strnlen(); (it's | 
 
 
 
 
 | 158 | * also available in MSVCRT.DLL from _WIN32_WINNT_VISTA onwards, but we | 
 
 
 
 
 | 159 | * pretend otherwise, since recent GCC will try to use the function when | 
 
 
 
 
 | 160 | * it can be found in libmsvcrt.a, so breaking it for use on WinXP and | 
 
 
 
 
 | 161 | * earlier). | 
 
 
 
 
 | 162 | */ | 
 
 
 
 
 | 163 | _CRTIMP __cdecl __MINGW_NOTHROW  char *strnlen (const char *, size_t); | 
 
 
 
 
 | 164 |  | 
 
 
 
 
 | 165 | #elif _POSIX_C_SOURCE >= 200809L | 
 
 
 
 
 | 166 | /* Emulation, to support recent POSIX.1; we prefer this for ALL versions | 
 
 
 
 
 | 167 | * of MSVCRT.DLL, (even those which already provide strnlen()); to avoid | 
 
 
 
 
 | 168 | * the GCC breakage noted above.  (Note that we implement strnlen() with | 
 
 
 
 
 | 169 | * the alternative external name, __mingw_strnlen() in libmingwex.a, to | 
 
 
 
 
 | 170 | * avoid possible link time collision with MSVCR80.DLL's implementation, | 
 
 
 
 
 | 171 | * then map this to strnlen() via a __CRT_ALIAS, with stubs designated | 
 
 
 
 
 | 172 | * for linking from within the appropriate oldname libraries. | 
 
 
 
 
 | 173 | */ | 
 
 
 
 
 | 174 | extern size_t __mingw_strnlen (const char *, size_t); | 
 
 
 
 
 | 175 |  | 
 
 
 
 
 | 176 | __JMPSTUB__(( LIB=coldname; FUNCTION=strnlen )) | 
 
 
 
 
 | 177 | __CRT_ALIAS size_t strnlen (const char *__text, size_t __maxlen) | 
 
 
 
 
 | 178 | { return __mingw_strnlen (__text, __maxlen); } | 
 
 
 
 
 | 179 |  | 
 
 
 
 
 | 180 | #endif  /* _POSIX_C_SOURCE >= 200809L */ | 
 
 
 
 
 | 181 |  | 
 
 
 
 
 | 182 | #undef __STRING_H_SOURCED__ | 
 
 
 
 
 | 183 |  | 
 
 
 
 
 | 184 | _END_C_DECLS | 
 
 
 
 
 | 185 |  | 
 
 
 
 
 | 186 | #endif  /* ! RC_INVOKED */ | 
 
 
 
 
 | 187 | #endif  /* !_STRING_H: $RCSfile: string.h,v $: end of file */ |