OSDN Git Service

Make strings.h mostly POSIX.1-2008 compliant.
[mingw/mingw-org-wsl.git] / mingwrt / include / string.h
1 /*
2  * string.h
3  *
4  * ISO-C standard header, with MSVC compatible extensions.
5  *
6  * $Id$
7  *
8  * Written by Rob Savoye <rob@cygnus.com>
9  * Copyright (C) 1997-2000, 2002-2004, 2007, 2009, 2015, MinGW.org Project.
10  *
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice, this permission notice, and the following
20  * disclaimer shall be included in all copies or substantial portions of
21  * the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  *
31  */
32 #ifndef _STRING_H
33 #define _STRING_H
34
35 /* All MinGW system headers must include this...
36  */
37 #include <_mingw.h>
38
39 #ifndef RC_INVOKED
40 /* ISO-C requires this header to expose definitions for NULL and size_t,
41  * retaining compatiblity with their fundamental <stddef.h> definitions.
42  */
43 #define __need_NULL
44 #define __need_size_t
45 #ifndef __STRICT_ANSI__
46  /* MSVC extends this requirement to include a definition of wchar_t,
47   * (which contravenes strict ISO-C standards conformity).
48   */
49 # define __need_wchar_t
50 #endif
51 #include <stddef.h>
52
53 _BEGIN_C_DECLS
54
55 /* Prototypes for the ISO-C Standard library string functions.
56  */
57 _CRTIMP void * __cdecl __MINGW_NOTHROW  memchr (const void*, int, size_t) __MINGW_ATTRIB_PURE;
58 _CRTIMP int    __cdecl __MINGW_NOTHROW  memcmp (const void*, const void*, size_t) __MINGW_ATTRIB_PURE;
59 _CRTIMP void * __cdecl __MINGW_NOTHROW  memcpy (void*, const void*, size_t);
60 _CRTIMP void * __cdecl __MINGW_NOTHROW  memmove (void*, const void*, size_t);
61 _CRTIMP void * __cdecl __MINGW_NOTHROW  memset (void*, int, size_t);
62 _CRTIMP char * __cdecl __MINGW_NOTHROW  strcat (char*, const char*);
63 _CRTIMP char * __cdecl __MINGW_NOTHROW  strchr (const char*, int)  __MINGW_ATTRIB_PURE;
64 _CRTIMP int    __cdecl __MINGW_NOTHROW  strcmp (const char*, const char*)  __MINGW_ATTRIB_PURE;
65 _CRTIMP int    __cdecl __MINGW_NOTHROW  strcoll (const char*, const char*);     /* Compare using locale */
66 _CRTIMP char * __cdecl __MINGW_NOTHROW  strcpy (char*, const char*);
67 _CRTIMP size_t __cdecl __MINGW_NOTHROW  strcspn (const char*, const char*)  __MINGW_ATTRIB_PURE;
68 _CRTIMP char * __cdecl __MINGW_NOTHROW  strerror (int); /* NOTE: NOT an old name wrapper. */
69
70 _CRTIMP size_t __cdecl __MINGW_NOTHROW  strlen (const char*)  __MINGW_ATTRIB_PURE;
71 _CRTIMP char * __cdecl __MINGW_NOTHROW  strncat (char*, const char*, size_t);
72 _CRTIMP int    __cdecl __MINGW_NOTHROW  strncmp (const char*, const char*, size_t)  __MINGW_ATTRIB_PURE;
73 _CRTIMP char * __cdecl __MINGW_NOTHROW  strncpy (char*, const char*, size_t);
74 _CRTIMP char * __cdecl __MINGW_NOTHROW  strpbrk (const char*, const char*)  __MINGW_ATTRIB_PURE;
75 _CRTIMP char * __cdecl __MINGW_NOTHROW  strrchr (const char*, int)  __MINGW_ATTRIB_PURE;
76 _CRTIMP size_t __cdecl __MINGW_NOTHROW  strspn (const char*, const char*)  __MINGW_ATTRIB_PURE;
77 _CRTIMP char * __cdecl __MINGW_NOTHROW  strstr (const char*, const char*)  __MINGW_ATTRIB_PURE;
78 _CRTIMP char * __cdecl __MINGW_NOTHROW  strtok (char*, const char*);
79 _CRTIMP size_t __cdecl __MINGW_NOTHROW  strxfrm (char*, const char*, size_t);
80
81 #ifndef __STRICT_ANSI__
82 /*
83  * Extra non-ANSI functions provided by the CRTDLL library
84  */
85 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strerror (const char *);
86 _CRTIMP void * __cdecl __MINGW_NOTHROW  _memccpy (void*, const void*, int, size_t);
87 _CRTIMP int    __cdecl __MINGW_NOTHROW  _memicmp (const void*, const void*, size_t);
88 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strdup (const char*) __MINGW_ATTRIB_MALLOC;
89 _CRTIMP int    __cdecl __MINGW_NOTHROW  _strcmpi (const char*, const char*);
90 _CRTIMP int    __cdecl __MINGW_NOTHROW  _stricoll (const char*, const char*);
91 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strlwr (char*);
92 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strnset (char*, int, size_t);
93 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strrev (char*);
94 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strset (char*, int);
95 _CRTIMP char * __cdecl __MINGW_NOTHROW  _strupr (char*);
96 _CRTIMP void   __cdecl __MINGW_NOTHROW  _swab (const char*, char*, size_t);
97
98 /* MSVC's non-ANSI _stricmp() and _strnicmp() functions must also be
99  * prototyped here, but we need to share them with <strings.h>, where
100  * we declare their POSIX strcasecmp() and strncasecmp() equivalents.
101  */
102 #define _FAKE_STRINGS_H_SOURCED 1
103 #include <parts/strings.h>
104
105 # ifdef __MSVCRT__
106  /* These were not present in the CRTDLL prior to the first release of
107   * MSVCRT.DLL, but are available in all versions of that library.
108   */
109 _CRTIMP int    __cdecl __MINGW_NOTHROW  _strncoll(const char*, const char*, size_t);
110 _CRTIMP int    __cdecl __MINGW_NOTHROW  _strnicoll(const char*, const char*, size_t);
111 # endif
112
113 # ifndef _NO_OLDNAMES
114  /* Non-underscore decorated versions of non-ANSI functions. They live in the
115   * OLDNAMES libraries, whence they provide a little extra portability.
116   */
117 _CRTIMP void * __cdecl __MINGW_NOTHROW  memccpy (void*, const void*, int, size_t);
118 _CRTIMP int    __cdecl __MINGW_NOTHROW  memicmp (const void*, const void*, size_t);
119 _CRTIMP char * __cdecl __MINGW_NOTHROW  strdup (const char*) __MINGW_ATTRIB_MALLOC;
120 _CRTIMP int    __cdecl __MINGW_NOTHROW  strcmpi (const char*, const char*);
121 _CRTIMP int    __cdecl __MINGW_NOTHROW  stricmp (const char*, const char*);
122 _CRTIMP int    __cdecl __MINGW_NOTHROW  stricoll (const char*, const char*);
123 _CRTIMP char * __cdecl __MINGW_NOTHROW  strlwr (char*);
124 _CRTIMP int    __cdecl __MINGW_NOTHROW  strnicmp (const char*, const char*, size_t);
125 _CRTIMP char * __cdecl __MINGW_NOTHROW  strnset (char*, int, size_t);
126 _CRTIMP char * __cdecl __MINGW_NOTHROW  strrev (char*);
127 _CRTIMP char * __cdecl __MINGW_NOTHROW  strset (char*, int);
128 _CRTIMP char * __cdecl __MINGW_NOTHROW  strupr (char*);
129
130 #  ifndef _UWIN
131   /* FIXME: Do we really care that UWin doesn't support this?  We are
132    * under no obligation to support UWin.
133    */
134 _CRTIMP void   __cdecl __MINGW_NOTHROW  swab (const char*, char*, size_t);
135
136 #  endif /* ! _UWIN */
137 # endif /* ! _NO_OLDNAMES */
138
139 # define _FAKE_WCHAR_H_SOURCED 1
140 # define __need_wstring_function_prototypes
141  /* This inclusion of <wchar.h> string function prototypes is required for
142   * MSVC <string.h> compatibility.  Strictly conforming ISO-C applications
143   * should include <wchar.h>; they should not rely on this anomaly.
144   */
145 # include <parts/wchar.h>
146
147 #endif /* ! __STRICT_ANSI__ */
148
149 _END_C_DECLS
150
151 #endif /* ! RC_INVOKED */
152 #endif /* ! _STRING_H: $RCSfile$: end of file */