src/include/posix/base/posixadapter.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol, Inc
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00016  * 02111-1307  USA
00017  */
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 BOOL int
00052 #define TRUE 1
00053 #define FALSE 0
00054 
00055 // Enable the fix for encoding when building for posix
00056 #define VOCL_ENCODING_FIX
00057 
00058 
00059 #ifdef USE_WCHAR
00060 
00061 #undef WCHAR
00062 #include <wchar.h>
00063 #include <wctype.h>
00064 
00065 #define WCHAR wchar_t
00066 #define WCHAR_PRINTF "s"
00067 #define TEXT(_x) L##_x
00068 
00069 // FIXME: remove this and adapt VOCL.
00070 WCHAR *wcstok(WCHAR *s, const WCHAR *delim);
00071 
00072 inline int _wtoi(const WCHAR *s) { return (int)wcstol(s, NULL, 10); }
00073 
00074 #define _wcsicmp wcscasecmp
00075 #define wcsicmp wcscasecmp
00076 #define snwprintf swprintf
00077 
00078 #else
00079 
00080 /* map WCHAR and its functions back to standard functions */
00081 #       undef WCHAR
00082 #       define WCHAR char
00083 #       define WCHAR_PRINTF "s"
00084 #       define TEXT(_x) _x
00085 
00086 #       define SYNC4J_LINEBREAK "\n"
00087 
00088 #       define wsprintf sprintf
00089 #       define _wfopen fopen
00090 #       define wprintf printf
00091 #       define fwprintf fprintf
00092 #       define wsprintf sprintf
00093 #       define swprintf snprintf
00094 #       define snwprintf snprintf
00095 #       define wcscpy strcpy
00096 #       define wcsncpy strncpy
00097 #       define wcsncmp strncmp
00098 #       define wcslen strlen
00099 #       define wcstol strtol
00100 #       define wcstoul strtoul
00101 #       define wcsstr strstr
00102 #       define wcscmp strcmp
00103 #       define wcstok strtok
00104         inline char towlower(char x) { return tolower(x); }
00105         inline char towupper(char x) { return toupper(x); }
00106 #       define wmemmove memmove
00107 #       define wmemcpy memcpy
00108 #       define wmemcmp memcmp
00109 #       define wmemset memset
00110 #       define wcschr strchr
00111 #       define wcsrchr strrchr
00112 #       define wcscat strcat
00113 #       define wcsncat strncat
00114 #       define _wtoi atoi
00115 #       define wcstod strtod
00116 #       define wcsicmp strcasecmp
00117 #       define _wcsicmp strcasecmp
00118 #       define _stricmp strcasecmp
00119 
00120 #endif
00121 
00122 /* some of the code compares NULL against integers, which
00123    fails if NULL is defined as (void *)0 */
00124 #undef NULL
00125 #define NULL 0
00126 
00127 #define min(x,y) ( (x) < (y) ? (x) : (y) )
00128 #define max(x,y) ( (x) > (y) ? (x) : (y) )
00129 
00131 #endif
00132 

Generated on Tue Oct 30 15:11:27 2007 for Funambol C++ Client Library by  doxygen 1.5.2