OSDN Git Service

Correct project name references in mingwrt source files.
[mingw/mingw-org-wsl.git] / mingwrt / include / strings.h
1 /*
2  * strings.h
3  *
4  * API declarations for POSIX.1-2008 string functions supported by MinGW.
5  *
6  * $Id$
7  *
8  * Written by Keith Marshall <keith@users.osdn.me>
9  * Copyright (C) 2015-2017, 2022, MinGW.OSDN 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 _STRINGS_H
33 #pragma GCC system_header
34
35 /* In addition to the POSIX strcasecmp() and strncasecmp() functions,
36  * this header declares the prototypes for the MSVC specific stricmp()
37  * and strincmp() functions, which MSVC expects to find in <string.h>;
38  * thus, we support selective partial inclusion by <string.h>, to make
39  * this pair of function prototypes available as MSVC expects...
40  */
41 #ifndef __STRING_H_SOURCED__
42 /* ...and we define the _STRINGS_H guard macro only when NOT included
43  * in this partial fashion.
44  */
45 #define _STRINGS_H
46
47 /* All MinGW system headers must include <_mingw.h>; if we had been
48  * sourced by <string.h>, we could safely assume that it had already
49  * done this, but since that doesn't apply in this case, we must do
50  * it ourselves.
51  */
52 #include <_mingw.h>
53
54 #ifndef RC_INVOKED
55 /* POSIX.1-2008 requires this header to expose the typedef for size_t; to
56  * ensure consistency, we import this from GCC's own <stddef.h> header.
57  */
58 #define __need_size_t
59 #include <stddef.h>
60
61 _BEGIN_C_DECLS
62
63 int __cdecl __MINGW_NOTHROW strcasecmp( const char *, const char * );
64 int __cdecl __MINGW_NOTHROW strncasecmp( const char *, const char *, size_t );
65
66 #endif  /* ! RC_INVOKED */
67 #endif  /* !__STRING_H_SOURCED__ */
68
69 #if ! (defined __STRICT_ANSI__ && defined __NO_INLINE__)
70 /* These are the MSVCRT.DLL equivalents for POSIX.1's strcasecmp() and
71  * strncasecmp() functions, for which we provide in-line implementations
72  * in <strings.h> respectively; MSVC expects to find these prototypes in
73  * <string.h>, but we also need them here, in <strings.h>, to facilitate
74  * the in-line function implementations; we declare them here, and allow
75  * <string.h> to include them selectively.  Note that <string.h> doesn't
76  * need these if __STRICT_ANSI__ is defined, while <strings.h> doesn't
77  * if __NO_INLINE__ is defined; thus we declare them, unless BOTH of
78  * these conditions for not requiring them are satisfied.
79  */
80 _CRTIMP __cdecl __MINGW_NOTHROW  int _stricmp( const char *, const char * );
81 _CRTIMP __cdecl __MINGW_NOTHROW  int _strnicmp( const char *, const char *, size_t );
82 #endif  /* !(__STRICT_ANSI__ && __NO_INLINE__) */
83
84 #if defined _STRINGS_H && ! defined RC_INVOKED
85 #ifndef __NO_INLINE__
86 /* Provide in-line implementations for strcasecmp(), and strncasecmp(),
87  * effectively aliasing them to the respective MSVCRT.DLL (non-standard)
88  * equivalents, as prototyped above.
89  */
90 __CRT_ALIAS __JMPSTUB__(( FUNCTION = strcasecmp, REMAPPED = _stricmp ))
91   int strcasecmp( const char *__s1, const char *__s2 )
92   { return _stricmp( __s1, __s2 ); }
93
94 __CRT_ALIAS __JMPSTUB__(( FUNCTION = strncasecmp, REMAPPED = _strnicmp ))
95   int strncasecmp( const char *__s1, const char *__s2, size_t __n )
96   { return _strnicmp( __s1, __s2, __n ); }
97
98 #endif  /* !__NO_INLINE__ */
99
100 _END_C_DECLS
101
102 #endif  /* _STRINGS_H && ! RC_INVOKED */
103 #endif  /* !_STRINGS_H: $RCSfile$: end of file */