Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org> |
| 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 | |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 27 | |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 28 | #if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0 |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 29 | # include <string.h> |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 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 | |
Benny Prijono | b8f63d6 | 2006-03-17 17:59:16 +0000 | [diff] [blame] | 37 | /* For sprintf family */ |
| 38 | #include <stdio.h> |
| 39 | |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 40 | #if defined(_MSC_VER) |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 41 | # define strcasecmp _stricmp |
Benny Prijono | 9cf138e | 2006-01-19 03:58:29 +0000 | [diff] [blame] | 42 | # define strncasecmp _strnicmp |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 43 | # define snprintf _snprintf |
| 44 | # define vsnprintf _vsnprintf |
| 45 | # define snwprintf _snwprintf |
| 46 | # define wcsicmp _wcsicmp |
| 47 | # define wcsnicmp _wcsnicmp |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 48 | #else |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 49 | # define stricmp strcasecmp |
| 50 | # define strnicmp strncasecmp |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 51 | |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 52 | # if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 |
| 53 | # error "Implement Unicode string functions" |
| 54 | # endif |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 55 | #endif |
| 56 | |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 57 | #define pj_ansi_strcmp strcmp |
| 58 | #define pj_ansi_strncmp strncmp |
| 59 | #define pj_ansi_strlen strlen |
| 60 | #define pj_ansi_strcpy strcpy |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 61 | #define pj_ansi_strncpy strncpy |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 62 | #define pj_ansi_strcat strcat |
| 63 | #define pj_ansi_strstr strstr |
| 64 | #define pj_ansi_strchr strchr |
| 65 | #define pj_ansi_strcasecmp strcasecmp |
| 66 | #define pj_ansi_stricmp strcasecmp |
| 67 | #define pj_ansi_strncasecmp strncasecmp |
| 68 | #define pj_ansi_strnicmp strncasecmp |
| 69 | #define pj_ansi_sprintf sprintf |
Benny Prijono | c5784c1 | 2006-02-21 23:40:16 +0000 | [diff] [blame] | 70 | #define pj_ansi_snprintf snprintf |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 71 | #define pj_ansi_vsprintf vsprintf |
| 72 | #define pj_ansi_vsnprintf vsnprintf |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 73 | |
| 74 | #define pj_unicode_strcmp wcscmp |
| 75 | #define pj_unicode_strncmp wcsncmp |
| 76 | #define pj_unicode_strlen wcslen |
| 77 | #define pj_unicode_strcpy wcscpy |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 78 | #define pj_unicode_strncpy wcsncpy |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 79 | #define pj_unicode_strcat wcscat |
| 80 | #define pj_unicode_strstr wcsstr |
| 81 | #define pj_unicode_strchr wcschr |
| 82 | #define pj_unicode_strcasecmp wcsicmp |
| 83 | #define pj_unicode_stricmp wcsicmp |
| 84 | #define pj_unicode_strncasecmp wcsnicmp |
| 85 | #define pj_unicode_strnicmp wcsnicmp |
| 86 | #define pj_unicode_sprintf swprintf |
Benny Prijono | c5784c1 | 2006-02-21 23:40:16 +0000 | [diff] [blame] | 87 | #define pj_unicode_snprintf snwprintf |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 88 | #define pj_unicode_vsprintf vswprintf |
| 89 | #define pj_unicode_vsnprintf vsnwprintf |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 90 | |
| 91 | #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 |
| 92 | # define pj_native_strcmp pj_unicode_strcmp |
| 93 | # define pj_native_strncmp pj_unicode_strncmp |
| 94 | # define pj_native_strlen pj_unicode_strlen |
| 95 | # define pj_native_strcpy pj_unicode_strcpy |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 96 | # define pj_native_strncpy pj_unicode_strncpy |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 97 | # define pj_native_strcat pj_unicode_strcat |
| 98 | # define pj_native_strstr pj_unicode_strstr |
| 99 | # define pj_native_strchr pj_unicode_strchr |
| 100 | # define pj_native_strcasecmp pj_unicode_strcasecmp |
| 101 | # define pj_native_stricmp pj_unicode_stricmp |
| 102 | # define pj_native_strncasecmp pj_unicode_strncasecmp |
| 103 | # define pj_native_strnicmp pj_unicode_strnicmp |
| 104 | # define pj_native_sprintf pj_unicode_sprintf |
Benny Prijono | c5784c1 | 2006-02-21 23:40:16 +0000 | [diff] [blame] | 105 | # define pj_native_snprintf pj_unicode_snprintf |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 106 | # define pj_native_vsprintf pj_unicode_vsprintf |
| 107 | # define pj_native_vsnprintf pj_unicode_vsnprintf |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 108 | #else |
| 109 | # define pj_native_strcmp pj_ansi_strcmp |
| 110 | # define pj_native_strncmp pj_ansi_strncmp |
| 111 | # define pj_native_strlen pj_ansi_strlen |
| 112 | # define pj_native_strcpy pj_ansi_strcpy |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 113 | # define pj_native_strncpy pj_ansi_strncpy |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 114 | # define pj_native_strcat pj_ansi_strcat |
| 115 | # define pj_native_strstr pj_ansi_strstr |
| 116 | # define pj_native_strchr pj_ansi_strchr |
| 117 | # define pj_native_strcasecmp pj_ansi_strcasecmp |
| 118 | # define pj_native_stricmp pj_ansi_stricmp |
| 119 | # define pj_native_strncasecmp pj_ansi_strncasecmp |
| 120 | # define pj_native_strnicmp pj_ansi_strnicmp |
| 121 | # define pj_native_sprintf pj_ansi_sprintf |
Benny Prijono | c5784c1 | 2006-02-21 23:40:16 +0000 | [diff] [blame] | 122 | # define pj_native_snprintf pj_ansi_snprintf |
Benny Prijono | ed811d7 | 2006-03-10 12:57:12 +0000 | [diff] [blame] | 123 | # define pj_native_vsprintf pj_ansi_vsprintf |
| 124 | # define pj_native_vsnprintf pj_ansi_vsnprintf |
Benny Prijono | ace0093 | 2006-02-14 21:04:47 +0000 | [diff] [blame] | 125 | #endif |
| 126 | |
Benny Prijono | 5dcb38d | 2005-11-21 01:55:47 +0000 | [diff] [blame] | 127 | |
| 128 | #endif /* __PJ_COMPAT_STRING_H__ */ |