blob: 896615b465a9c7c80bc08fe3e14d18d991a0516d [file] [log] [blame]
Benny Prijono5dcb38d2005-11-21 01:55:47 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono5dcb38d2005-11-21 01:55:47 +00004 *
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 Prijonoc4c8f242006-08-01 23:01:55 +000040/* On WinCE, string stuffs are declared in stdlib.h */
41#if defined(PJ_HAS_STDLIB_H) && PJ_HAS_STDLIB_H!=0
42# include <stdlib.h>
43#endif
44
Benny Prijono5dcb38d2005-11-21 01:55:47 +000045#if defined(_MSC_VER)
Benny Prijonoed811d72006-03-10 12:57:12 +000046# define strcasecmp _stricmp
Benny Prijono9cf138e2006-01-19 03:58:29 +000047# define strncasecmp _strnicmp
Benny Prijonoed811d72006-03-10 12:57:12 +000048# define snprintf _snprintf
49# define vsnprintf _vsnprintf
50# define snwprintf _snwprintf
51# define wcsicmp _wcsicmp
52# define wcsnicmp _wcsnicmp
Benny Prijono5dcb38d2005-11-21 01:55:47 +000053#else
Benny Prijonoed811d72006-03-10 12:57:12 +000054# define stricmp strcasecmp
55# define strnicmp strncasecmp
Benny Prijonoace00932006-02-14 21:04:47 +000056
Benny Prijonoed811d72006-03-10 12:57:12 +000057# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
58# error "Implement Unicode string functions"
59# endif
Benny Prijono5dcb38d2005-11-21 01:55:47 +000060#endif
61
Benny Prijonoace00932006-02-14 21:04:47 +000062#define pj_ansi_strcmp strcmp
63#define pj_ansi_strncmp strncmp
64#define pj_ansi_strlen strlen
65#define pj_ansi_strcpy strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +000066#define pj_ansi_strncpy strncpy
Benny Prijonoace00932006-02-14 21:04:47 +000067#define pj_ansi_strcat strcat
68#define pj_ansi_strstr strstr
69#define pj_ansi_strchr strchr
70#define pj_ansi_strcasecmp strcasecmp
71#define pj_ansi_stricmp strcasecmp
72#define pj_ansi_strncasecmp strncasecmp
73#define pj_ansi_strnicmp strncasecmp
74#define pj_ansi_sprintf sprintf
Benny Prijonof260e462007-04-30 21:03:32 +000075
76#if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
77# include <pj/types.h>
78# include <pj/compat/stdarg.h>
79 PJ_BEGIN_DECL
80 PJ_DECL(int) snprintf(char*s1, pj_size_t len, const char*s2, ...);
81 PJ_DECL(int) vsnprintf(char*s1, pj_size_t len, const char*s2, va_list arg);
82 PJ_END_DECL
83#endif
84
Benny Prijonoc5784c12006-02-21 23:40:16 +000085#define pj_ansi_snprintf snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000086#define pj_ansi_vsprintf vsprintf
87#define pj_ansi_vsnprintf vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +000088
89#define pj_unicode_strcmp wcscmp
90#define pj_unicode_strncmp wcsncmp
91#define pj_unicode_strlen wcslen
92#define pj_unicode_strcpy wcscpy
Benny Prijonoed811d72006-03-10 12:57:12 +000093#define pj_unicode_strncpy wcsncpy
Benny Prijonoace00932006-02-14 21:04:47 +000094#define pj_unicode_strcat wcscat
95#define pj_unicode_strstr wcsstr
96#define pj_unicode_strchr wcschr
97#define pj_unicode_strcasecmp wcsicmp
98#define pj_unicode_stricmp wcsicmp
99#define pj_unicode_strncasecmp wcsnicmp
100#define pj_unicode_strnicmp wcsnicmp
101#define pj_unicode_sprintf swprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000102#define pj_unicode_snprintf snwprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000103#define pj_unicode_vsprintf vswprintf
104#define pj_unicode_vsnprintf vsnwprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000105
106#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
107# define pj_native_strcmp pj_unicode_strcmp
108# define pj_native_strncmp pj_unicode_strncmp
109# define pj_native_strlen pj_unicode_strlen
110# define pj_native_strcpy pj_unicode_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000111# define pj_native_strncpy pj_unicode_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000112# define pj_native_strcat pj_unicode_strcat
113# define pj_native_strstr pj_unicode_strstr
114# define pj_native_strchr pj_unicode_strchr
115# define pj_native_strcasecmp pj_unicode_strcasecmp
116# define pj_native_stricmp pj_unicode_stricmp
117# define pj_native_strncasecmp pj_unicode_strncasecmp
118# define pj_native_strnicmp pj_unicode_strnicmp
119# define pj_native_sprintf pj_unicode_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000120# define pj_native_snprintf pj_unicode_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000121# define pj_native_vsprintf pj_unicode_vsprintf
122# define pj_native_vsnprintf pj_unicode_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000123#else
124# define pj_native_strcmp pj_ansi_strcmp
125# define pj_native_strncmp pj_ansi_strncmp
126# define pj_native_strlen pj_ansi_strlen
127# define pj_native_strcpy pj_ansi_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000128# define pj_native_strncpy pj_ansi_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000129# define pj_native_strcat pj_ansi_strcat
130# define pj_native_strstr pj_ansi_strstr
131# define pj_native_strchr pj_ansi_strchr
132# define pj_native_strcasecmp pj_ansi_strcasecmp
133# define pj_native_stricmp pj_ansi_stricmp
134# define pj_native_strncasecmp pj_ansi_strncasecmp
135# define pj_native_strnicmp pj_ansi_strnicmp
136# define pj_native_sprintf pj_ansi_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000137# define pj_native_snprintf pj_ansi_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000138# define pj_native_vsprintf pj_ansi_vsprintf
139# define pj_native_vsnprintf pj_ansi_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000140#endif
141
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000142
143#endif /* __PJ_COMPAT_STRING_H__ */