blob: 2de20fcc6439d26b721768c67aafc6d8ee236f18 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $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 Prijonoace00932006-02-14 21:04:47 +000027
Benny Prijono5dcb38d2005-11-21 01:55:47 +000028#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
Benny Prijonoed811d72006-03-10 12:57:12 +000029# include <string.h>
Benny Prijono5dcb38d2005-11-21 01:55:47 +000030#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 Prijonob8f63d62006-03-17 17:59:16 +000037/* For sprintf family */
38#include <stdio.h>
39
Benny Prijono5dcb38d2005-11-21 01:55:47 +000040#if defined(_MSC_VER)
Benny Prijonoed811d72006-03-10 12:57:12 +000041# define strcasecmp _stricmp
Benny Prijono9cf138e2006-01-19 03:58:29 +000042# define strncasecmp _strnicmp
Benny Prijonoed811d72006-03-10 12:57:12 +000043# define snprintf _snprintf
44# define vsnprintf _vsnprintf
45# define snwprintf _snwprintf
46# define wcsicmp _wcsicmp
47# define wcsnicmp _wcsnicmp
Benny Prijono5dcb38d2005-11-21 01:55:47 +000048#else
Benny Prijonoed811d72006-03-10 12:57:12 +000049# define stricmp strcasecmp
50# define strnicmp strncasecmp
Benny Prijonoace00932006-02-14 21:04:47 +000051
Benny Prijonoed811d72006-03-10 12:57:12 +000052# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
53# error "Implement Unicode string functions"
54# endif
Benny Prijono5dcb38d2005-11-21 01:55:47 +000055#endif
56
Benny Prijonoace00932006-02-14 21:04:47 +000057#define pj_ansi_strcmp strcmp
58#define pj_ansi_strncmp strncmp
59#define pj_ansi_strlen strlen
60#define pj_ansi_strcpy strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +000061#define pj_ansi_strncpy strncpy
Benny Prijonoace00932006-02-14 21:04:47 +000062#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 Prijonoc5784c12006-02-21 23:40:16 +000070#define pj_ansi_snprintf snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000071#define pj_ansi_vsprintf vsprintf
72#define pj_ansi_vsnprintf vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +000073
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 Prijonoed811d72006-03-10 12:57:12 +000078#define pj_unicode_strncpy wcsncpy
Benny Prijonoace00932006-02-14 21:04:47 +000079#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 Prijonoc5784c12006-02-21 23:40:16 +000087#define pj_unicode_snprintf snwprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000088#define pj_unicode_vsprintf vswprintf
89#define pj_unicode_vsnprintf vsnwprintf
Benny Prijonoace00932006-02-14 21:04:47 +000090
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 Prijonoed811d72006-03-10 12:57:12 +000096# define pj_native_strncpy pj_unicode_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +000097# 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 Prijonoc5784c12006-02-21 23:40:16 +0000105# define pj_native_snprintf pj_unicode_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000106# define pj_native_vsprintf pj_unicode_vsprintf
107# define pj_native_vsnprintf pj_unicode_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000108#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 Prijonoed811d72006-03-10 12:57:12 +0000113# define pj_native_strncpy pj_ansi_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000114# 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 Prijonoc5784c12006-02-21 23:40:16 +0000122# define pj_native_snprintf pj_ansi_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000123# define pj_native_vsprintf pj_ansi_vsprintf
124# define pj_native_vsnprintf pj_ansi_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000125#endif
126
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000127
128#endif /* __PJ_COMPAT_STRING_H__ */