From c672d0e3ecea6fe784250b5099f8126c0ff18ad1 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 14 Feb 2006 21:04:47 +0000 Subject: Changed the unicode string API and ported to ARM/WinCE git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@182 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/include/pj/compat/m_arm.h | 38 ------------------ pjlib/include/pj/compat/m_armv4.h | 38 ++++++++++++++++++ pjlib/include/pj/compat/socket.h | 3 +- pjlib/include/pj/compat/string.h | 81 ++++++++++++++++++++++++++++++++++----- pjlib/include/pj/config.h | 2 +- pjlib/include/pj/types.h | 17 ++++++++ pjlib/include/pjlib.h | 1 + 7 files changed, 130 insertions(+), 50 deletions(-) delete mode 100644 pjlib/include/pj/compat/m_arm.h create mode 100644 pjlib/include/pj/compat/m_armv4.h (limited to 'pjlib/include') diff --git a/pjlib/include/pj/compat/m_arm.h b/pjlib/include/pj/compat/m_arm.h deleted file mode 100644 index b81ce32c..00000000 --- a/pjlib/include/pj/compat/m_arm.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $Id$ */ -/* - * Copyright (C)2003-2006 Benny Prijono - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __PJ_COMPAT_M_ARM_H__ -#define __PJ_COMPAT_M_ARM_H__ - -/** - * @file m_arm.h - * @brief Describes ARM family processor specifics. - */ - -/* - * This file covers PJ_M_ARMV4 etc. - */ - -#define PJ_M_NAME "ARM" - -#define PJ_HAS_PENTIUM 0 -#define PJ_IS_LITTLE_ENDIAN 1 -#define PJ_IS_BIG_ENDIAN 0 - - -#endif /* __PJ_COMPAT_M_ARM_H__ */ diff --git a/pjlib/include/pj/compat/m_armv4.h b/pjlib/include/pj/compat/m_armv4.h new file mode 100644 index 00000000..e43d4156 --- /dev/null +++ b/pjlib/include/pj/compat/m_armv4.h @@ -0,0 +1,38 @@ +/* $Id$ */ +/* + * Copyright (C)2003-2006 Benny Prijono + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJ_COMPAT_M_ARMV4_H__ +#define __PJ_COMPAT_M_ARMV4_H__ + +/** + * @file m_armv4.h + * @brief Describes ARM family processor specifics. + */ + +/* + * This file covers PJ_M_ARMV4 etc. + */ + +#define PJ_M_NAME "armv4" + +#define PJ_HAS_PENTIUM 0 +#define PJ_IS_LITTLE_ENDIAN 1 +#define PJ_IS_BIG_ENDIAN 0 + + +#endif /* __PJ_COMPAT_M_ARMV4_H__ */ diff --git a/pjlib/include/pj/compat/socket.h b/pjlib/include/pj/compat/socket.h index ee4f3a6e..e3f68b5d 100644 --- a/pjlib/include/pj/compat/socket.h +++ b/pjlib/include/pj/compat/socket.h @@ -76,7 +76,8 @@ /* * Define common errors. */ -#ifdef PJ_WIN32 +#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \ + (defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0) # define OSERR_EWOULDBLOCK WSAEWOULDBLOCK # define OSERR_EINPROGRESS WSAEINPROGRESS # define OSERR_ECONNRESET WSAECONNRESET diff --git a/pjlib/include/pj/compat/string.h b/pjlib/include/pj/compat/string.h index fd041230..8fd45286 100644 --- a/pjlib/include/pj/compat/string.h +++ b/pjlib/include/pj/compat/string.h @@ -24,6 +24,16 @@ * @brief Provides string manipulation functions found in ANSI string.h. */ +/** + * Native char type, which will be equal to wchar_t for Unicode + * and char for ANSI. + */ +#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 +typedef wchar_t pj_char_t; +#else +typedef char pj_char_t; +#endif + #if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0 # include #else @@ -41,21 +51,72 @@ # define strncasecmp strnicmp # endif # define snprintf _snprintf +# define wcsicmp _wcsicmp +# define wcsnicmp _wcsnicmp #else # define stricmp strcasecmp # define strnicmp strncasecmp + +# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 +# error "Implement Unicode string functions" +# endif #endif -#define pj_native_strcmp strcmp -#define pj_native_strncmp strncmp -#define pj_native_strlen strlen -#define pj_native_strcpy strcpy -#define pj_native_strstr strstr -#define pj_native_strchr strchr -#define pj_native_strcasecmp strcasecmp -#define pj_native_stricmp strcasecmp -#define pj_native_strncasecmp strncasecmp -#define pj_native_strnicmp strncasecmp +#define pj_ansi_strcmp strcmp +#define pj_ansi_strncmp strncmp +#define pj_ansi_strlen strlen +#define pj_ansi_strcpy strcpy +#define pj_ansi_strcat strcat +#define pj_ansi_strstr strstr +#define pj_ansi_strchr strchr +#define pj_ansi_strcasecmp strcasecmp +#define pj_ansi_stricmp strcasecmp +#define pj_ansi_strncasecmp strncasecmp +#define pj_ansi_strnicmp strncasecmp +#define pj_ansi_sprintf sprintf + +#define pj_unicode_strcmp wcscmp +#define pj_unicode_strncmp wcsncmp +#define pj_unicode_strlen wcslen +#define pj_unicode_strcpy wcscpy +#define pj_unicode_strcat wcscat +#define pj_unicode_strstr wcsstr +#define pj_unicode_strchr wcschr +#define pj_unicode_strcasecmp wcsicmp +#define pj_unicode_stricmp wcsicmp +#define pj_unicode_strncasecmp wcsnicmp +#define pj_unicode_strnicmp wcsnicmp +#define pj_unicode_sprintf swprintf + + +#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 +# define pj_native_strcmp pj_unicode_strcmp +# define pj_native_strncmp pj_unicode_strncmp +# define pj_native_strlen pj_unicode_strlen +# define pj_native_strcpy pj_unicode_strcpy +# define pj_native_strcat pj_unicode_strcat +# define pj_native_strstr pj_unicode_strstr +# define pj_native_strchr pj_unicode_strchr +# define pj_native_strcasecmp pj_unicode_strcasecmp +# define pj_native_stricmp pj_unicode_stricmp +# define pj_native_strncasecmp pj_unicode_strncasecmp +# define pj_native_strnicmp pj_unicode_strnicmp +# define pj_native_sprintf pj_unicode_sprintf +#else +# define pj_native_strcmp pj_ansi_strcmp +# define pj_native_strncmp pj_ansi_strncmp +# define pj_native_strlen pj_ansi_strlen +# define pj_native_strcpy pj_ansi_strcpy +# define pj_native_strcat pj_ansi_strcat +# define pj_native_strstr pj_ansi_strstr +# define pj_native_strchr pj_ansi_strchr +# define pj_native_strcasecmp pj_ansi_strcasecmp +# define pj_native_stricmp pj_ansi_stricmp +# define pj_native_strncasecmp pj_ansi_strncasecmp +# define pj_native_strnicmp pj_ansi_strnicmp +# define pj_native_sprintf pj_ansi_sprintf +#endif + #endif /* __PJ_COMPAT_STRING_H__ */ diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h index b836b53b..d09795a4 100644 --- a/pjlib/include/pj/config.h +++ b/pjlib/include/pj/config.h @@ -68,7 +68,7 @@ #elif defined (PJ_M_SPARC) && PJ_M_SPARC != 0 # include #elif defined (PJ_M_ARMV4) && PJ_M_ARMV4 != 0 -# include +# include #else # error "Please specify target machine." #endif diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h index 5b22f75b..69d440a9 100644 --- a/pjlib/include/pj/types.h +++ b/pjlib/include/pj/types.h @@ -68,6 +68,23 @@ typedef int pj_status_t; /** Boolean. */ typedef int pj_bool_t; +/** Native char type, which will be equal to wchar_t for Unicode + * and char for ANSI. */ +#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 + typedef wchar_t pj_char_t; +#else + typedef char pj_char_t; +#endif + +/** This macro creates Unicode or ANSI literal string depending whether + * native platform string is Unicode or ANSI. */ +#if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 +# define PJ_T(literal_str) L##literal_str +#else +# define PJ_T(literal_str) literal_str +#endif + + /** Status is OK. */ #define PJ_SUCCESS 0 diff --git a/pjlib/include/pjlib.h b/pjlib/include/pjlib.h index 45a9e495..2e2ffd0d 100644 --- a/pjlib/include/pjlib.h +++ b/pjlib/include/pjlib.h @@ -48,6 +48,7 @@ #include #include #include +#include #include -- cgit v1.2.3