blob: ea01d39bb15d87fb1dfc7d27f428131fa20d2974 [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJ_COMPAT_STRING_H__
21#define __PJ_COMPAT_STRING_H__
22
23/**
24 * @file string.h
25 * @brief Provides string manipulation functions found in ANSI string.h.
26 */
27
Benny Prijonoace00932006-02-14 21:04:47 +000028
Benny Prijono5dcb38d2005-11-21 01:55:47 +000029#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
Benny Prijonoed811d72006-03-10 12:57:12 +000030# include <string.h>
Benny Prijono5dcb38d2005-11-21 01:55:47 +000031#else
32
33 PJ_DECL(int) strcasecmp(const char *s1, const char *s2);
34 PJ_DECL(int) strncasecmp(const char *s1, const char *s2, int len);
35
36#endif
37
Benny Prijonob8f63d62006-03-17 17:59:16 +000038/* For sprintf family */
39#include <stdio.h>
40
Benny Prijonoc4c8f242006-08-01 23:01:55 +000041/* On WinCE, string stuffs are declared in stdlib.h */
42#if defined(PJ_HAS_STDLIB_H) && PJ_HAS_STDLIB_H!=0
43# include <stdlib.h>
44#endif
45
Benny Prijono5dcb38d2005-11-21 01:55:47 +000046#if defined(_MSC_VER)
Benny Prijonoed811d72006-03-10 12:57:12 +000047# define strcasecmp _stricmp
Benny Prijono9cf138e2006-01-19 03:58:29 +000048# define strncasecmp _strnicmp
Benny Prijonoed811d72006-03-10 12:57:12 +000049# define snprintf _snprintf
50# define vsnprintf _vsnprintf
51# define snwprintf _snwprintf
52# define wcsicmp _wcsicmp
53# define wcsnicmp _wcsnicmp
Benny Prijono5dcb38d2005-11-21 01:55:47 +000054#else
Benny Prijonoed811d72006-03-10 12:57:12 +000055# define stricmp strcasecmp
56# define strnicmp strncasecmp
Benny Prijonoace00932006-02-14 21:04:47 +000057
Benny Prijonoed811d72006-03-10 12:57:12 +000058# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
59# error "Implement Unicode string functions"
60# endif
Benny Prijono5dcb38d2005-11-21 01:55:47 +000061#endif
62
Benny Prijonoace00932006-02-14 21:04:47 +000063#define pj_ansi_strcmp strcmp
64#define pj_ansi_strncmp strncmp
65#define pj_ansi_strlen strlen
66#define pj_ansi_strcpy strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +000067#define pj_ansi_strncpy strncpy
Benny Prijonoace00932006-02-14 21:04:47 +000068#define pj_ansi_strcat strcat
69#define pj_ansi_strstr strstr
70#define pj_ansi_strchr strchr
71#define pj_ansi_strcasecmp strcasecmp
72#define pj_ansi_stricmp strcasecmp
73#define pj_ansi_strncasecmp strncasecmp
74#define pj_ansi_strnicmp strncasecmp
75#define pj_ansi_sprintf sprintf
Benny Prijonof260e462007-04-30 21:03:32 +000076
77#if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
78# include <pj/types.h>
79# include <pj/compat/stdarg.h>
80 PJ_BEGIN_DECL
81 PJ_DECL(int) snprintf(char*s1, pj_size_t len, const char*s2, ...);
82 PJ_DECL(int) vsnprintf(char*s1, pj_size_t len, const char*s2, va_list arg);
83 PJ_END_DECL
84#endif
85
Benny Prijonoc5784c12006-02-21 23:40:16 +000086#define pj_ansi_snprintf snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000087#define pj_ansi_vsprintf vsprintf
88#define pj_ansi_vsnprintf vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +000089
90#define pj_unicode_strcmp wcscmp
91#define pj_unicode_strncmp wcsncmp
92#define pj_unicode_strlen wcslen
93#define pj_unicode_strcpy wcscpy
Benny Prijonoed811d72006-03-10 12:57:12 +000094#define pj_unicode_strncpy wcsncpy
Benny Prijonoace00932006-02-14 21:04:47 +000095#define pj_unicode_strcat wcscat
96#define pj_unicode_strstr wcsstr
97#define pj_unicode_strchr wcschr
98#define pj_unicode_strcasecmp wcsicmp
99#define pj_unicode_stricmp wcsicmp
100#define pj_unicode_strncasecmp wcsnicmp
101#define pj_unicode_strnicmp wcsnicmp
102#define pj_unicode_sprintf swprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000103#define pj_unicode_snprintf snwprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000104#define pj_unicode_vsprintf vswprintf
105#define pj_unicode_vsnprintf vsnwprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000106
107#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
108# define pj_native_strcmp pj_unicode_strcmp
109# define pj_native_strncmp pj_unicode_strncmp
110# define pj_native_strlen pj_unicode_strlen
111# define pj_native_strcpy pj_unicode_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000112# define pj_native_strncpy pj_unicode_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000113# define pj_native_strcat pj_unicode_strcat
114# define pj_native_strstr pj_unicode_strstr
115# define pj_native_strchr pj_unicode_strchr
116# define pj_native_strcasecmp pj_unicode_strcasecmp
117# define pj_native_stricmp pj_unicode_stricmp
118# define pj_native_strncasecmp pj_unicode_strncasecmp
119# define pj_native_strnicmp pj_unicode_strnicmp
120# define pj_native_sprintf pj_unicode_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000121# define pj_native_snprintf pj_unicode_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000122# define pj_native_vsprintf pj_unicode_vsprintf
123# define pj_native_vsnprintf pj_unicode_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000124#else
125# define pj_native_strcmp pj_ansi_strcmp
126# define pj_native_strncmp pj_ansi_strncmp
127# define pj_native_strlen pj_ansi_strlen
128# define pj_native_strcpy pj_ansi_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000129# define pj_native_strncpy pj_ansi_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000130# define pj_native_strcat pj_ansi_strcat
131# define pj_native_strstr pj_ansi_strstr
132# define pj_native_strchr pj_ansi_strchr
133# define pj_native_strcasecmp pj_ansi_strcasecmp
134# define pj_native_stricmp pj_ansi_stricmp
135# define pj_native_strncasecmp pj_ansi_strncasecmp
136# define pj_native_strnicmp pj_ansi_strnicmp
137# define pj_native_sprintf pj_ansi_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000138# define pj_native_snprintf pj_ansi_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000139# define pj_native_vsprintf pj_ansi_vsprintf
140# define pj_native_vsnprintf pj_ansi_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000141#endif
142
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000143
144#endif /* __PJ_COMPAT_STRING_H__ */