| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef __PJ_COMPAT_STRING_H__ |
| 20 |
#define __PJ_COMPAT_STRING_H__ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 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 |
|
| 38 |
#include <stdio.h> |
| 39 |
|
| 40 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |