blob: ca14bc7853a96a5c30ae3f2eaea41710aa8570b4 [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 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 Prijonoc5784c12006-02-21 23:40:16 +000075#define pj_ansi_snprintf snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000076#define pj_ansi_vsprintf vsprintf
77#define pj_ansi_vsnprintf vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +000078
79#define pj_unicode_strcmp wcscmp
80#define pj_unicode_strncmp wcsncmp
81#define pj_unicode_strlen wcslen
82#define pj_unicode_strcpy wcscpy
Benny Prijonoed811d72006-03-10 12:57:12 +000083#define pj_unicode_strncpy wcsncpy
Benny Prijonoace00932006-02-14 21:04:47 +000084#define pj_unicode_strcat wcscat
85#define pj_unicode_strstr wcsstr
86#define pj_unicode_strchr wcschr
87#define pj_unicode_strcasecmp wcsicmp
88#define pj_unicode_stricmp wcsicmp
89#define pj_unicode_strncasecmp wcsnicmp
90#define pj_unicode_strnicmp wcsnicmp
91#define pj_unicode_sprintf swprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +000092#define pj_unicode_snprintf snwprintf
Benny Prijonoed811d72006-03-10 12:57:12 +000093#define pj_unicode_vsprintf vswprintf
94#define pj_unicode_vsnprintf vsnwprintf
Benny Prijonoace00932006-02-14 21:04:47 +000095
96#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
97# define pj_native_strcmp pj_unicode_strcmp
98# define pj_native_strncmp pj_unicode_strncmp
99# define pj_native_strlen pj_unicode_strlen
100# define pj_native_strcpy pj_unicode_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000101# define pj_native_strncpy pj_unicode_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000102# define pj_native_strcat pj_unicode_strcat
103# define pj_native_strstr pj_unicode_strstr
104# define pj_native_strchr pj_unicode_strchr
105# define pj_native_strcasecmp pj_unicode_strcasecmp
106# define pj_native_stricmp pj_unicode_stricmp
107# define pj_native_strncasecmp pj_unicode_strncasecmp
108# define pj_native_strnicmp pj_unicode_strnicmp
109# define pj_native_sprintf pj_unicode_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000110# define pj_native_snprintf pj_unicode_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000111# define pj_native_vsprintf pj_unicode_vsprintf
112# define pj_native_vsnprintf pj_unicode_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000113#else
114# define pj_native_strcmp pj_ansi_strcmp
115# define pj_native_strncmp pj_ansi_strncmp
116# define pj_native_strlen pj_ansi_strlen
117# define pj_native_strcpy pj_ansi_strcpy
Benny Prijonoed811d72006-03-10 12:57:12 +0000118# define pj_native_strncpy pj_ansi_strncpy
Benny Prijonoace00932006-02-14 21:04:47 +0000119# define pj_native_strcat pj_ansi_strcat
120# define pj_native_strstr pj_ansi_strstr
121# define pj_native_strchr pj_ansi_strchr
122# define pj_native_strcasecmp pj_ansi_strcasecmp
123# define pj_native_stricmp pj_ansi_stricmp
124# define pj_native_strncasecmp pj_ansi_strncasecmp
125# define pj_native_strnicmp pj_ansi_strnicmp
126# define pj_native_sprintf pj_ansi_sprintf
Benny Prijonoc5784c12006-02-21 23:40:16 +0000127# define pj_native_snprintf pj_ansi_snprintf
Benny Prijonoed811d72006-03-10 12:57:12 +0000128# define pj_native_vsprintf pj_ansi_vsprintf
129# define pj_native_vsnprintf pj_ansi_vsnprintf
Benny Prijonoace00932006-02-14 21:04:47 +0000130#endif
131
Benny Prijono5dcb38d2005-11-21 01:55:47 +0000132
133#endif /* __PJ_COMPAT_STRING_H__ */