src/include/posix/base/posixadapter.h

00001 /*
00002  * Copyright (C) 2005-2006 Funambol
00003  * Author Patrick Ohly
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef INCL_AUTOTOOLS_ADAPTER
00021 #define INCL_AUTOTOOLS_ADAPTER
00022 
00025 /*
00026  * POSIX environment, configured and compiled with automake/autoconf
00027  */
00028 
00029 #include <config.h>
00030 #include <string.h>
00031 #include <stdlib.h>
00032 #include <ctype.h>
00033 #include <stdio.h>
00034 #include <time.h>
00035 #include <stdarg.h>
00036 #include <unistd.h>
00037 
00038 // For ntoh functions
00039 #include <netinet/in.h>
00040 
00041 // Workaround for wchar defines below: unit testing may depend
00042 // on standard header files. Include its header file first.
00043 #include <base/test.h>
00044 
00045 // Cygwin version of gcc does have these builtin
00046 #ifndef __CYGWIN__
00047 # define __declspec(x)
00048 # define __cdecl
00049 #endif
00050 
00051 #define EXTRA_SECTION_00
00052 #define EXTRA_SECTION_01
00053 #define EXTRA_SECTION_02
00054 #define EXTRA_SECTION_03
00055 #define EXTRA_SECTION_04
00056 #define EXTRA_SECTION_05
00057 #define EXTRA_SECTION_06
00058 
00059 #define BOOL int
00060 #define TRUE 1
00061 #define FALSE 0
00062 
00063 // Enable the fix for encoding when building for posix
00064 #define VOCL_ENCODING_FIX
00065 
00066 
00067 #ifdef USE_WCHAR
00068 
00069 #undef WCHAR
00070 #include <wchar.h>
00071 #include <wctype.h>
00072 
00073 #define WCHAR wchar_t
00074 #define WCHAR_PRINTF "s"
00075 #define TEXT(_x) L##_x
00076 
00077 // FIXME: remove this and adapt VOCL.
00078 WCHAR *wcstok(WCHAR *s, const WCHAR *delim);
00079 
00080 inline int _wtoi(const WCHAR *s) { return (int)wcstol(s, NULL, 10); }
00081 
00082 #define _wcsicmp wcscasecmp
00083 #define wcsicmp wcscasecmp
00084 #define snwprintf swprintf
00085 
00086 #else
00087 
00088 /* map WCHAR and its functions back to standard functions */
00089 #       undef WCHAR
00090 #       define WCHAR char
00091 #       define WCHAR_PRINTF "s"
00092 #       define TEXT(_x) _x
00093 
00094 #       define SYNC4J_LINEBREAK "\n"
00095 
00096 #       define wsprintf sprintf
00097 #       define _wfopen fopen
00098 #       define wprintf printf
00099 #       define fwprintf fprintf
00100 #       define wsprintf sprintf
00101 #       define swprintf snprintf
00102 #       define snwprintf snprintf
00103 #       define wcscpy strcpy
00104 #       define wcsncpy strncpy
00105 #       define wcsncmp strncmp
00106 #       define wcslen strlen
00107 #       define wcstol strtol
00108 #       define wcstoul strtoul
00109 #       define wcsstr strstr
00110 #       define wcscmp strcmp
00111 #       define wcstok strtok
00112         inline char towlower(char x) { return tolower(x); }
00113         inline char towupper(char x) { return toupper(x); }
00114 #       define wmemmove memmove
00115 #       define wmemcpy memcpy
00116 #       define wmemcmp memcmp
00117 #       define wmemset memset
00118 #       define wcschr strchr
00119 #       define wcsrchr strrchr
00120 #       define wcscat strcat
00121 #       define wcsncat strncat
00122 #       define _wtoi atoi
00123 #       define wcstod strtod
00124 #       define wcsicmp strcasecmp
00125 #       define _wcsicmp strcasecmp
00126 #       define _stricmp strcasecmp
00127 
00128 #endif
00129 
00130 /* some of the code compares NULL against integers, which
00131    fails if NULL is defined as (void *)0 */
00132 #undef NULL
00133 #define NULL 0
00134 
00135 #define min(x,y) ( (x) < (y) ? (x) : (y) )
00136 #define max(x,y) ( (x) > (y) ? (x) : (y) )
00137 
00139 #endif
00140 

Generated on Fri Apr 27 12:29:19 2007 for Funambol C++ Client Library by  doxygen 1.5.2