Debian Codegraph @

Xpjproject/pjlib/include/pj/compat/string.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJ_COMPAT_STRING_H__
20 #define __PJ_COMPAT_STRING_H__
21
22 /**
23 * @file string.h
24 * @brief Provides string manipulation functions found in ANSI string.h.
25 */
26
27
28 #if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
29 # include <string.h>
30 #else
31
32 PJ_DECL(int) strcasecmp(const char *s1, const char *s2);
33 PJ_DECL(int) strncasecmp(const char *s1, const char *s2, int len);
34
35 #endif
36
37 /* For sprintf family */
38 #include <stdio.h>
39
40 /* On WinCE, string stuffs are declared in stdlib.h */
41 #if defined(PJ_HAS_STDLIB_H) && PJ_HAS_STDLIB_H!=0
42 # include <stdlib.h>
43 #endif
44
45 #if defined(_MSC_VER)
46 # define strcasecmp _stricmp
47 # define strncasecmp _strnicmp
48
49 /* snprintf() and vsnprintf() are available since Visual Studio 2015 */
50 #if _MSC_VER < 1900
51 # define snprintf _snprintf
52 # define vsnprintf _vsnprintf
53 #endif
54
55 # define snwprintf _snwprintf
56 # define wcsicmp _wcsicmp
57 # define wcsnicmp _wcsnicmp
58 #else
59 # define stricmp strcasecmp
60 # define strnicmp strncasecmp
61
62 # if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
63 # error "Implement Unicode string functions"
64 # endif
65 #endif
66
67 #define pj_ansi_strcmp strcmp
68 #define pj_ansi_strncmp strncmp
69 #define pj_ansi_strlen strlen
70 #if defined(PJ_BAN_STRCPY) && PJ_BAN_STRCPY
71 /* Use pj_ansi_strxcpy() instead */
72 # define strcpy error__strcpy_is_banned
73 # define pj_ansi_strcpy error__strcpy_is_banned
74 #else
75 # define pj_ansi_strcpy strcpy
76 #endif
77 #if defined(PJ_BAN_STRNCPY) && PJ_BAN_STRNCPY
78 /* Use pj_ansi_strxcpy() instead */
79 # define strncpy error__strncpy_is_banned
80 # define pj_ansi_strncpy error__strncpy_is_banned
81 #else
82 # define pj_ansi_strncpy strncpy
83 #endif
84 #if defined(PJ_BAN_STRCAT) && PJ_BAN_STRCAT
85 /* Use pj_ansi_strxcat() instead */
86 # define strcat error__strcat_is_banned
87 # define pj_ansi_strcat error__strcat_is_banned
88 #else
89 # define pj_ansi_strcat strcat
90 #endif
91 #define pj_ansi_strstr strstr
92 #define pj_ansi_strchr strchr
93 #define pj_ansi_strcasecmp strcasecmp
94 #define pj_ansi_stricmp strcasecmp
95 #define pj_ansi_strncasecmp strncasecmp
96 #define pj_ansi_strnicmp strncasecmp
97 #if defined(PJ_BAN_SPRINTF) && PJ_BAN_SPRINTF
98 /* Use pj_ansi_snprintf() instead */
99 # define sprintf error__sprintf_is_banned
100 # define pj_ansi_sprintf error__sprintf_is_banned
101 #else
102 # define pj_ansi_sprintf sprintf
103 #endif
104
105 #if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
106 # include <pj/types.h>
107 # include <pj/compat/stdarg.h>
108 PJ_BEGIN_DECL
109 PJ_DECL(int) snprintf(char*s1, pj_size_t len, const char*s2, ...);
110 PJ_DECL(int) vsnprintf(char*s1, pj_size_t len, const char*s2, va_list arg);
111 PJ_END_DECL
112 #endif
113
114 #define pj_ansi_snprintf snprintf
115 #if defined(PJ_BAN_VSPRINTF) && PJ_BAN_VSPRINTF
116 /* Use pj_ansi_vsnprintf() instead */
117 # define vsprintf error__vsprintf_is_banned
118 # define pj_ansi_vsprintf error__vsprintf_is_banned
119 #else
120 # define pj_ansi_vsprintf vsprintf
121 #endif
122 #define pj_ansi_vsnprintf vsnprintf
123
124 #define pj_unicode_strcmp wcscmp
125 #define pj_unicode_strncmp wcsncmp
126 #define pj_unicode_strlen wcslen
127 #define pj_unicode_strcpy wcscpy
128 #define pj_unicode_strncpy wcsncpy
129 #define pj_unicode_strcat wcscat
130 #define pj_unicode_strstr wcsstr
131 #define pj_unicode_strchr wcschr
132 #define pj_unicode_strcasecmp wcsicmp
133 #define pj_unicode_stricmp wcsicmp
134 #define pj_unicode_strncasecmp wcsnicmp
135 #define pj_unicode_strnicmp wcsnicmp
136 #define pj_unicode_sprintf swprintf
137 #define pj_unicode_snprintf snwprintf
138 #define pj_unicode_vsprintf vswprintf
139 #define pj_unicode_vsnprintf vsnwprintf
140
141 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
142 # define pj_native_strcmp pj_unicode_strcmp
143 # define pj_native_strncmp pj_unicode_strncmp
144 # define pj_native_strlen pj_unicode_strlen
145 # define pj_native_strcpy pj_unicode_strcpy
146 # define pj_native_strncpy pj_unicode_strncpy
147 # define pj_native_strcat pj_unicode_strcat
148 # define pj_native_strstr pj_unicode_strstr
149 # define pj_native_strchr pj_unicode_strchr
150 # define pj_native_strcasecmp pj_unicode_strcasecmp
151 # define pj_native_stricmp pj_unicode_stricmp
152 # define pj_native_strncasecmp pj_unicode_strncasecmp
153 # define pj_native_strnicmp pj_unicode_strnicmp
154 # define pj_native_sprintf pj_unicode_sprintf
155 # define pj_native_snprintf pj_unicode_snprintf
156 # define pj_native_vsprintf pj_unicode_vsprintf
157 # define pj_native_vsnprintf pj_unicode_vsnprintf
158 #else
159 # define pj_native_strcmp pj_ansi_strcmp
160 # define pj_native_strncmp pj_ansi_strncmp
161 # define pj_native_strlen pj_ansi_strlen
162 # define pj_native_strcpy pj_ansi_strcpy
163 # define pj_native_strncpy pj_ansi_strncpy
164 # define pj_native_strcat pj_ansi_strcat
165 # define pj_native_strstr pj_ansi_strstr
166 # define pj_native_strchr pj_ansi_strchr
167 # define pj_native_strcasecmp pj_ansi_strcasecmp
168 # define pj_native_stricmp pj_ansi_stricmp
169 # define pj_native_strncasecmp pj_ansi_strncasecmp
170 # define pj_native_strnicmp pj_ansi_strnicmp
171 # define pj_native_sprintf pj_ansi_sprintf
172 # define pj_native_snprintf pj_ansi_snprintf
173 # define pj_native_vsprintf pj_ansi_vsprintf
174 # define pj_native_vsnprintf pj_ansi_vsnprintf
175 #endif
176
177
178 #endif /* __PJ_COMPAT_STRING_H__ */