source: Daodan/MinGW/include/string.h@ 1111

Last change on this file since 1111 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 8.6 KB
Line 
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 */
174extern 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 */
Note: See TracBrowser for help on using the repository browser.