blob: fde421a2391fa852d31cab4cc99d5f20c9016fbf [file] [log] [blame]
Tristan Matthews0a329cc2013-07-17 13:20:14 -04001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
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
28
29#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
30# include <string.h>
31#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
38/* For sprintf family */
39#include <stdio.h>
40
41/* 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
46#if defined(_MSC_VER)
47# define strcasecmp _stricmp
48# define strncasecmp _strnicmp
49# define snprintf _snprintf
50# define vsnprintf _vsnprintf
51# define snwprintf _snwprintf
52# define wcsicmp _wcsicmp
53# define wcsnicmp _wcsnicmp
54#else
55# define stricmp strcasecmp
56# define strnicmp strncasecmp
57
58# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
59# error "Implement Unicode string functions"
60# endif
61#endif
62
63#define pj_ansi_strcmp strcmp
64#define pj_ansi_strncmp strncmp
65#define pj_ansi_strlen strlen
66#define pj_ansi_strcpy strcpy
67#define pj_ansi_strncpy strncpy
68#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
76
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
86#define pj_ansi_snprintf snprintf
87#define pj_ansi_vsprintf vsprintf
88#define pj_ansi_vsnprintf vsnprintf
89
90#define pj_unicode_strcmp wcscmp
91#define pj_unicode_strncmp wcsncmp
92#define pj_unicode_strlen wcslen
93#define pj_unicode_strcpy wcscpy
94#define pj_unicode_strncpy wcsncpy
95#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
103#define pj_unicode_snprintf snwprintf
104#define pj_unicode_vsprintf vswprintf
105#define pj_unicode_vsnprintf vsnwprintf
106
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
112# define pj_native_strncpy pj_unicode_strncpy
113# 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
121# define pj_native_snprintf pj_unicode_snprintf
122# define pj_native_vsprintf pj_unicode_vsprintf
123# define pj_native_vsnprintf pj_unicode_vsnprintf
124#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
129# define pj_native_strncpy pj_ansi_strncpy
130# 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
138# define pj_native_snprintf pj_ansi_snprintf
139# define pj_native_vsprintf pj_ansi_vsprintf
140# define pj_native_vsnprintf pj_ansi_vsnprintf
141#endif
142
143
144#endif /* __PJ_COMPAT_STRING_H__ */