source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/string.h@ 1167

Last change on this file since 1167 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 14.3 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _INC_STRING
7#define _INC_STRING
8
9#include <crtdefs.h>
10
11#if defined(__LIBMSVCRT__)
12/* When building mingw-w64, this should be blank. */
13#define _SECIMP
14#else
15#ifndef _SECIMP
16#define _SECIMP __declspec(dllimport)
17#endif /* _SECIMP */
18#endif /* defined(_CRTBLD) || defined(__LIBMSVCRT__) */
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#ifndef _NLSCMP_DEFINED
25#define _NLSCMP_DEFINED
26#define _NLSCMPERROR 2147483647
27#endif
28
29#ifndef NULL
30#ifdef __cplusplus
31#ifndef _WIN64
32#define NULL 0
33#else
34#define NULL 0LL
35#endif /* W64 */
36#else
37#define NULL ((void *)0)
38#endif
39#endif
40
41#define _WConst_return _CONST_RETURN
42
43#ifndef _CRT_MEMORY_DEFINED
44#define _CRT_MEMORY_DEFINED
45 _CRTIMP void *__cdecl _memccpy(void *_Dst,const void *_Src,int _Val,size_t _MaxCount);
46 _CONST_RETURN void *__cdecl memchr(const void *_Buf ,int _Val,size_t _MaxCount);
47 _CRTIMP int __cdecl _memicmp(const void *_Buf1,const void *_Buf2,size_t _Size);
48 _CRTIMP int __cdecl _memicmp_l(const void *_Buf1,const void *_Buf2,size_t _Size,_locale_t _Locale);
49 int __cdecl memcmp(const void *_Buf1,const void *_Buf2,size_t _Size);
50 void * __cdecl memcpy(void * __restrict__ _Dst,const void * __restrict__ _Src,size_t _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
51 _SECIMP errno_t __cdecl memcpy_s (void *_dest,size_t _numberOfElements,const void *_src,size_t _count);
52 void * __cdecl mempcpy (void *_Dst, const void *_Src, size_t _Size);
53 void * __cdecl memset(void *_Dst,int _Val,size_t _Size);
54#ifndef NO_OLDNAMES
55 void * __cdecl memccpy(void *_Dst,const void *_Src,int _Val,size_t _Size) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
56 int __cdecl memicmp(const void *_Buf1,const void *_Buf2,size_t _Size) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
57#endif
58#endif
59 char * __cdecl _strset(char *_Str,int _Val) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
60 char * __cdecl _strset_l(char *_Str,int _Val,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
61 char * __cdecl strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source);
62 char * __cdecl strcat(char * __restrict__ _Dest,const char * __restrict__ _Source);
63 int __cdecl strcmp(const char *_Str1,const char *_Str2);
64 size_t __cdecl strlen(const char *_Str);
65 size_t __cdecl strnlen(const char *_Str,size_t _MaxCount);
66 void *__cdecl memmove(void *_Dst,const void *_Src,size_t _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
67 _CRTIMP char *__cdecl _strdup(const char *_Src);
68 _CONST_RETURN char *__cdecl strchr(const char *_Str,int _Val);
69 _CRTIMP int __cdecl _stricmp(const char *_Str1,const char *_Str2);
70 _CRTIMP int __cdecl _strcmpi(const char *_Str1,const char *_Str2);
71 _CRTIMP int __cdecl _stricmp_l(const char *_Str1,const char *_Str2,_locale_t _Locale);
72 int __cdecl strcoll(const char *_Str1,const char *_Str2);
73 _CRTIMP int __cdecl _strcoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale);
74 _CRTIMP int __cdecl _stricoll(const char *_Str1,const char *_Str2);
75 _CRTIMP int __cdecl _stricoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale);
76 _CRTIMP int __cdecl _strncoll (const char *_Str1,const char *_Str2,size_t _MaxCount);
77 _CRTIMP int __cdecl _strncoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale);
78 _CRTIMP int __cdecl _strnicoll (const char *_Str1,const char *_Str2,size_t _MaxCount);
79 _CRTIMP int __cdecl _strnicoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale);
80 size_t __cdecl strcspn(const char *_Str,const char *_Control);
81 _CRTIMP char *__cdecl _strerror(const char *_ErrMsg) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
82 char *__cdecl strerror(int) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
83 _CRTIMP char *__cdecl _strlwr(char *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
84 char *strlwr_l(char *_String,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
85 char *__cdecl strncat(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
86 int __cdecl strncmp(const char *_Str1,const char *_Str2,size_t _MaxCount);
87 _CRTIMP int __cdecl _strnicmp(const char *_Str1,const char *_Str2,size_t _MaxCount);
88 _CRTIMP int __cdecl _strnicmp_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale);
89 char *strncpy(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
90 _CRTIMP char *__cdecl _strnset(char *_Str,int _Val,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
91 _CRTIMP char *__cdecl _strnset_l(char *str,int c,size_t count,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
92 _CONST_RETURN char *__cdecl strpbrk(const char *_Str,const char *_Control);
93 _CONST_RETURN char *__cdecl strrchr(const char *_Str,int _Ch);
94 _CRTIMP char *__cdecl _strrev(char *_Str);
95 size_t __cdecl strspn(const char *_Str,const char *_Control);
96 _CONST_RETURN char *__cdecl strstr(const char *_Str,const char *_SubStr);
97 char *__cdecl strtok(char * __restrict__ _Str,const char * __restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
98#pragma push_macro("strtok_r")
99#undef strtok_r
100 char *strtok_r(char * __restrict__ _Str, const char * __restrict__ _Delim, char ** __restrict__ __last);
101#pragma pop_macro("strtok_r")
102 _CRTIMP char *__cdecl _strupr(char *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
103 _CRTIMP char *_strupr_l(char *_String,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
104 size_t __cdecl strxfrm(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount);
105 _CRTIMP size_t __cdecl _strxfrm_l(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale);
106
107#ifndef NO_OLDNAMES
108 char *__cdecl strdup(const char *_Src) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
109 int __cdecl strcmpi(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
110 int __cdecl stricmp(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
111 char *__cdecl strlwr(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
112 int __cdecl strnicmp(const char *_Str1,const char *_Str,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
113 int __cdecl strncasecmp (const char *, const char *, size_t);
114 int __cdecl strcasecmp (const char *, const char *);
115#ifndef __CRT__NO_INLINE
116 __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, __sizeMaxCompare); }
117 __CRT_INLINE int __cdecl strcasecmp (const char *__sz1, const char *__sz2) { return _stricmp (__sz1, __sz2); }
118#else
119#define strncasecmp _strnicmp
120#define strcasecmp _stricmp
121#endif /* !__CRT__NO_INLINE */
122 char *__cdecl strnset(char *_Str,int _Val,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
123 char *__cdecl strrev(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
124 char *__cdecl strset(char *_Str,int _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
125 char *__cdecl strupr(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
126#endif
127
128#ifndef _WSTRING_DEFINED
129#define _WSTRING_DEFINED
130
131 _CRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *_Str);
132 wchar_t *__cdecl wcscat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
133 _CONST_RETURN wchar_t *__cdecl wcschr(const wchar_t *_Str,wchar_t _Ch);
134 int __cdecl wcscmp(const wchar_t *_Str1,const wchar_t *_Str2);
135 wchar_t *__cdecl wcscpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
136 size_t __cdecl wcscspn(const wchar_t *_Str,const wchar_t *_Control);
137 size_t __cdecl wcslen(const wchar_t *_Str);
138 size_t __cdecl wcsnlen(const wchar_t *_Src,size_t _MaxCount);
139 wchar_t *wcsncat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
140 int __cdecl wcsncmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount);
141 wchar_t *wcsncpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
142 wchar_t *__cdecl _wcsncpy_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
143 _CONST_RETURN wchar_t *__cdecl wcspbrk(const wchar_t *_Str,const wchar_t *_Control);
144 _CONST_RETURN wchar_t *__cdecl wcsrchr(const wchar_t *_Str,wchar_t _Ch);
145 size_t __cdecl wcsspn(const wchar_t *_Str,const wchar_t *_Control);
146 _CONST_RETURN wchar_t *__cdecl wcsstr(const wchar_t *_Str,const wchar_t *_SubStr);
147 wchar_t *__cdecl wcstok(wchar_t * __restrict__ _Str,const wchar_t * __restrict__ _Delim) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
148 _CRTIMP wchar_t *__cdecl _wcserror(int _ErrNum) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
149 _CRTIMP wchar_t *__cdecl __wcserror(const wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
150 _CRTIMP int __cdecl _wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2);
151 _CRTIMP int __cdecl _wcsicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale);
152 _CRTIMP int __cdecl _wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount);
153 _CRTIMP int __cdecl _wcsnicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale);
154 _CRTIMP wchar_t *__cdecl _wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
155 _CRTIMP wchar_t *__cdecl _wcsrev(wchar_t *_Str);
156 _CRTIMP wchar_t *__cdecl _wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
157 _CRTIMP wchar_t *__cdecl _wcslwr(wchar_t *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
158 _CRTIMP wchar_t *_wcslwr_l(wchar_t *_String,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
159 _CRTIMP wchar_t *__cdecl _wcsupr(wchar_t *_String) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
160 _CRTIMP wchar_t *_wcsupr_l(wchar_t *_String,_locale_t _Locale) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
161 size_t __cdecl wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount);
162 _CRTIMP size_t __cdecl _wcsxfrm_l(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale);
163 int __cdecl wcscoll(const wchar_t *_Str1,const wchar_t *_Str2);
164 _CRTIMP int __cdecl _wcscoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale);
165 _CRTIMP int __cdecl _wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2);
166 _CRTIMP int __cdecl _wcsicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale);
167 _CRTIMP int __cdecl _wcsncoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount);
168 _CRTIMP int __cdecl _wcsncoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale);
169 _CRTIMP int __cdecl _wcsnicoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount);
170 _CRTIMP int __cdecl _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale);
171
172#ifndef NO_OLDNAMES
173 wchar_t *__cdecl wcsdup(const wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
174#define wcswcs wcsstr
175 int __cdecl wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
176 int __cdecl wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
177 wchar_t *__cdecl wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
178 wchar_t *__cdecl wcsrev(wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
179 wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
180 wchar_t *__cdecl wcslwr(wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
181 wchar_t *__cdecl wcsupr(wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
182 int __cdecl wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
183#endif
184#endif
185
186#ifdef __cplusplus
187}
188#endif
189
190#include <sec_api/string_s.h>
191
192#if __MINGW_FORTIFY_LEVEL > 0
193#ifdef __cplusplus
194extern "C" {
195#endif
196
197__mingw_bos_declare;
198
199__mingw_bos_extern_ovr
200void * memcpy(void * __restrict__ __dst, const void * __restrict__ __src, size_t __n)
201{
202 return __builtin___memcpy_chk(__dst, __src, __n, __mingw_bos(__dst, 0));
203}
204
205__mingw_bos_extern_ovr
206void * memset(void * __dst, int __val, size_t __n)
207{
208 return __builtin___memset_chk(__dst, __val, __n, __mingw_bos(__dst, 0));
209}
210
211__mingw_bos_extern_ovr
212void * memmove(void * __dst, const void * __src, size_t __n)
213{
214 return __builtin___memmove_chk(__dst, __src, __n, __mingw_bos(__dst, 0));
215}
216
217#ifdef _GNU_SOURCE
218__mingw_bos_extern_ovr
219void * mempcpy(void * __dst, const void * __src, size_t __n)
220{
221 return __builtin___mempcpy_chk(__dst, __src, __n, __mingw_bos(__dst, 0));
222}
223#endif /* _GNU_SOURCE */
224
225__mingw_bos_extern_ovr
226char * strcpy(char * __restrict__ __dst, const char * __restrict__ __src)
227{
228 return __builtin___strcpy_chk(__dst, __src, __mingw_bos(__dst, 1));
229}
230
231__mingw_bos_extern_ovr
232char * strcat(char * __restrict__ __dst, const char * __restrict__ __src)
233{
234 return __builtin___strcat_chk(__dst, __src, __mingw_bos(__dst, 1));
235}
236
237__mingw_bos_extern_ovr
238char * strncpy(char * __restrict__ __dst, const char * __restrict__ __src, size_t __n)
239{
240 return __builtin___strncpy_chk(__dst, __src, __n, __mingw_bos(__dst, 1));
241}
242
243__mingw_bos_extern_ovr
244char * strncat(char * __restrict__ __dst, const char * __restrict__ __src, size_t __n)
245{
246 return __builtin___strncat_chk(__dst, __src, __n, __mingw_bos(__dst, 1));
247}
248
249_SECIMP errno_t __cdecl __mingw_call_memcpy_s(void *, size_t, const void *, size_t) __MINGW_ASM_CRT_CALL(memcpy_s);
250wchar_t * __cdecl __mingw_call_wcscpy(wchar_t * __restrict__, const wchar_t * __restrict__) __MINGW_ASM_CALL(wcscpy);
251wchar_t * __cdecl __mingw_call_wcscat(wchar_t * __restrict__, const wchar_t * __restrict__) __MINGW_ASM_CALL(wcscat);
252
253__mingw_bos_extern_ovr
254errno_t memcpy_s(void * __dst, size_t __os, const void * __src, size_t __n)
255{
256 __mingw_bos_ptr_chk_warn(__dst, __os, 0);
257 return __mingw_call_memcpy_s(__dst, __os, __src, __n);
258}
259
260__mingw_bos_extern_ovr
261wchar_t * wcscpy(wchar_t * __restrict__ __dst, const wchar_t * __restrict__ __src)
262{
263 if (__mingw_bos_known(__dst)) {
264 __mingw_bos_cond_chk(!wcscpy_s(__dst, __mingw_bos(__dst, 1) / sizeof(wchar_t), __src));
265 return __dst;
266 }
267 return __mingw_call_wcscpy(__dst, __src);
268}
269
270__mingw_bos_extern_ovr
271wchar_t * wcscat(wchar_t * __restrict__ __dst, const wchar_t * __restrict__ __src)
272{
273 if (__mingw_bos_known(__dst)) {
274 __mingw_bos_cond_chk(!wcscat_s(__dst, __mingw_bos(__dst, 1) / sizeof(wchar_t), __src));
275 return __dst;
276 }
277 return __mingw_call_wcscat(__dst, __src);
278}
279
280#ifdef __cplusplus
281}
282#endif
283#endif /* __MINGW_FORTIFY_LEVEL > 0 */
284
285#endif
Note: See TracBrowser for help on using the repository browser.