00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __STDTP_H__
00012 #define __STDTP_H__
00013
00014 #ifdef __SYMBIAN32__
00015 #include <e32std.h>
00016 #include <e32cmn.h>
00017 #include <e32err.h>
00018 #include <f32file.h>
00019 #undef UNICODE
00020 #endif
00021
00022 #include "config.h"
00023
00024 #ifdef GIGABASE_DLL
00025 #ifdef INSIDE_GIGABASE
00026 #define GIGABASE_DLL_ENTRY __declspec(dllexport)
00027 #else
00028 #define GIGABASE_DLL_ENTRY __declspec(dllimport)
00029 #endif
00030 #else
00031 #define GIGABASE_DLL_ENTRY
00032 #endif
00033
00034 #ifdef USE_NAMESPACES
00035 #define BEGIN_GIGABASE_NAMESPACE namespace gigabase {
00036 #define END_GIGABASE_NAMESPACE }
00037 #define USE_GIGABASE_NAMESPACE using namespace gigabase;
00038 #define GB_NS gigabase
00039 #else
00040 #define BEGIN_GIGABASE_NAMESPACE
00041 #define END_GIGABASE_NAMESPACE
00042 #define USE_GIGABASE_NAMESPACE
00043 #define GB_NS
00044 #endif
00045
00046 #define GNUC_BEFORE(major,minor) (defined(__GNUC__) && (major > __GNUC__ || (major == __GNUC__ && minor > __GNUC_MINOR__)))
00047
00048 #if defined(__MINGW32__) && !defined(_WIN32) && !defined(__SYMBIAN32__)
00049 #define _WIN32
00050 #endif
00051
00052 #if defined(_WIN32_WCE) && !defined(_WINCE)
00053 #define _WINCE
00054 #endif
00055
00056 #if defined(__APPLE__) && !defined(__FreeBSD__)
00057
00058 #define __FreeBSD__ 5
00059 #endif
00060
00061 #ifdef __SYMBIAN32__
00062 #include <unistd.h>
00063 #undef remove
00064 typedef long ssize_t;
00065 #endif
00066
00067
00068 #if defined(USE_MFC_STRING) && !defined(USE_MFC) && !defined(USE_ATL)
00069 #define USE_ATL 1
00070 #endif
00071
00072 #if defined(USE_MFC_STRING)
00073 #ifndef MFC_STRING
00074 #define MFC_STRING CString
00075 #endif
00076 #endif
00077
00078 #ifdef USE_STD_STRING
00079 #include <string>
00080 #endif
00081
00082 #if defined(_WIN32) && !defined(__SYMBIAN32__)
00083
00084 #ifdef USE_MFC
00085 #include <afx.h>
00086 #include <winsock2.h>
00087 #else
00088 #include <windows.h>
00089 #if defined(USE_ATL) && defined(USE_MFC_STRING)
00090 #include <atlstr.h>
00091 #endif
00092 #endif
00093
00094 #ifdef _MSC_VER
00095 #pragma warning(disable:4800 4355 4146 4251 4996 4324)
00096 #endif
00097 #else
00098 #ifdef _AIX
00099 #define INT8_IS_DEFINED
00100 #endif
00101 #ifndef NO_PTHREADS
00102 #ifndef _REENTRANT
00103 #define _REENTRANT
00104 #endif
00105 #endif
00106 #endif
00107
00108
00109
00110 #if defined(__VACPP_MULTI__) // IBM compiler produce a lot of stupid warnings
00111 #pragma report(disable, "CPPC1608")
00112 #pragma report(disable, "CPPC1281")
00113 #endif
00114
00115
00116 #ifdef _WINCE
00117 #include <stdio.h>
00118 #include <stdlib.h>
00119 #include <string.h>
00120 #include <limits.h>
00121 #include <stdarg.h>
00122 #include <tchar.h>
00123 #include "wince.h"
00124
00125 #else
00126
00127 #include <stdio.h>
00128 #include <stddef.h>
00129 #include <stdlib.h>
00130 #include <string.h>
00131 #include <limits.h>
00132 #include <assert.h>
00133 #include <stdarg.h>
00134 #include <time.h>
00135 #if defined(UNICODE)
00136 #include <wchar.h>
00137 #include <wctype.h>
00138 #else
00139 #include <ctype.h>
00140 #endif
00141
00142 #endif
00143
00144 #ifndef __IBMCPP__
00145 BEGIN_GIGABASE_NAMESPACE
00146 #endif
00147
00148
00149 #if !defined(_WIN32) && !defined(__cdecl)
00150 #define __cdecl
00151 #endif
00152
00153
00154
00155 #define DOALIGN(x,b) (((x) + (b) - 1) & ~((b) - 1))
00156
00157 #ifdef UNICODE
00158 typedef wchar_t char_t;
00159 #define STRING_FORMAT "ls"
00160 #define STRLEN(x) wcslen(x)
00161 #define STRCMP(x, y) wcscmp(x, y)
00162 #define STRCOLL(x, y) wcscoll(x, y)
00163 #define STRCHR(x, y) wcschr(x, y)
00164 #define STRCPY(x, y) wcscpy(x, y)
00165 #define STRNCPY(x,y,z) wcsncpy(x, y, z)
00166 #define STRNCMP(x,y,z) wcsncmp(x, y, z)
00167 #define STRLITERAL(x) (wchar_t*)L##x
00168 #define PRINTF wprintf
00169 #define FPRINTF fwprintf
00170 #if defined(_WIN32)
00171 #define mbstowcs(_dst, _src, _size) (MultiByteToWideChar(CP_UTF8, 0, (_src), -1, (_dst), (_size))-1)
00172 #define wcstombs(_dst, _src, _size) (WideCharToMultiByte(CP_UTF8, 0, (_src), -1, (_dst), (_size), NULL, NULL)-1)
00173 #ifdef _SWPRINTFS_DEPRECATED
00174 #define SPRINTF _swprintf
00175 #else
00176 #define SPRINTF swprintf
00177 #endif
00178 #define SPRINTF_BUFFER(buf) buf
00179 #else
00180 #define SPRINTF swprintf
00181 #define SPRINTF_BUFFER(buf) buf, 0x1000000
00182 #endif
00183 #define VSPRINTF vswprintf
00184 #define FSCANF fwscanf
00185 #define SSCANF swscanf
00186 #define GETC(x) getwc(x)
00187 #define UNGETC(x, y) ungetwc(x, y)
00188 #define TOLOWER(x) towlower((x) & 0xFFFF)
00189 #define TOUPPER(x) towlower((x) & 0xFFFF)
00190 #define ISALNUM(x) iswalnum((x) & 0xFFFF)
00191 #define STRSTR(x, y) wcsstr(x, y)
00192 #define STRXFRM(x,y,z) wcsxfrm(x, y, z)
00193 #define STRFTIME(a,b,c,d) wcsftime(a,b,c,d)
00194 #ifdef _WINCE
00195 #define REMOVE_FILE(s) DeleteFile(s)
00196 #define RENAME_FILE(p, q) MoveFile(p, q)
00197 #else
00198 #define REMOVE_FILE(s) _wremove(s)
00199 #define RENAME_FILE(p, q) _wrename(p, q)
00200 #endif
00201 #define GETENV(x) _wgetenv(x)
00202 #define T_EOF WEOF
00203 #ifndef STD_STRING
00204 #define STD_STRING std::wstring
00205 #endif
00206 #ifndef _T
00207 #define _T(x) L##x
00208 #endif
00209 #else
00210 typedef char char_t;
00211 #define STRING_FORMAT "s"
00212 #define STRLEN(x) strlen(x)
00213 #define STRCHR(x, y) strchr(x, y)
00214 #define STRCMP(x, y) strcmp(x, y)
00215 #define STRCPY(x, y) strcpy(x, y)
00216 #define STRNCPY(x,y,z) strncpy(x, y, z)
00217 #define STRCOLL(x, y) strcoll(x, y)
00218 #define STRNCMP(x,y,z) strncmp(x, y, z)
00219 #define STRLITERAL(x) (char*)x
00220 #define PRINTF printf
00221 #define FPRINTF fprintf
00222 #define SPRINTF sprintf
00223 #define SPRINTF_BUFFER(buf) buf
00224 #define VSPRINTF vsprintf
00225 #define FSCANF fscanf
00226 #define SSCANF sscanf
00227 #define GETC(x) getc(x)
00228 #define UNGETC(x, y) ungetc(x, y)
00229 #define TOLOWER(x) tolower((x) & 0xFF)
00230 #define TOUPPER(x) toupper((x) & 0xFF)
00231 #define ISALNUM(x) isalnum((x) & 0xFF)
00232 #define STRSTR(x, y) strstr(x, y)
00233 #define STRXFRM(x,y,z) strxfrm(x, y, z)
00234 #define STRFTIME(a,b,c,d) strftime(a,b,c,d)
00235 #if defined(_WIN32) && !defined(__SYMBIAN32__)
00236 #define REMOVE_FILE(s) remove(s)
00237 #else
00238 #define REMOVE_FILE(s) unlink(s)
00239 #endif
00240 #define RENAME_FILE(p, q) rename(p, q)
00241 #define GETENV(x) getenv(x)
00242 #ifndef STD_STRING
00243 #define STD_STRING std::string
00244 #endif
00245 #define T_EOF EOF
00246 #ifdef _T
00247 #undef _T
00248 #endif
00249 #define _T(x) x
00250 #endif
00251
00252 inline void strlower(char_t* dst, const char_t* src)
00253 {
00254 int ch;
00255 do {
00256 ch = *src++;
00257 *dst++ = TOLOWER(ch);
00258 } while (ch != 0);
00259 }
00260
00261 typedef signed char db_int1;
00262 typedef unsigned char db_nat1;
00263
00264 typedef signed short db_int2;
00265 typedef unsigned short db_nat2;
00266
00267 typedef unsigned char db_byte;
00268
00269 typedef float db_real4;
00270 typedef double db_real8;
00271
00272 #if !defined(SIZEOF_LONG) && (defined(_L64) || defined(_LP64) || defined(__osf__))
00273 #define SIZEOF_LONG 8
00274 #endif
00275
00276 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__SYMBIAN32__)
00277 #if defined(_MSC_VER) || _MSC_VER < 1300
00278 typedef signed int db_int4;
00279 typedef unsigned int db_nat4;
00280 #else
00281 typedef signed __int32 db_int4;
00282 typedef unsigned __int32 db_nat4;
00283 #endif
00284 typedef unsigned __int64 db_nat8;
00285 typedef signed __int64 db_int8;
00286 #if defined(__IBMCPP__)
00287 #define INT8_FORMAT_PREFIX "%ll"
00288 #define T_INT8_FORMAT_PREFIX _T("%ll")
00289 #else
00290 #define INT8_FORMAT_PREFIX "%I64"
00291 #define T_INT8_FORMAT_PREFIX _T("%I64")
00292 #endif
00293 #define CONST64(c) c
00294 #else
00295 typedef signed int db_int4;
00296 typedef unsigned int db_nat4;
00297 #if SIZEOF_LONG == 8
00298 typedef unsigned long db_nat8;
00299 typedef signed long db_int8;
00300 #define INT8_FORMAT_PREFIX "%l"
00301 #define T_INT8_FORMAT_PREFIX _T("%l")
00302 #define CONST64(c) c##L
00303 #else
00304 typedef unsigned long long db_nat8;
00305 typedef signed long long db_int8;
00306 #ifdef __MINGW32__
00307 #define INT8_FORMAT_PREFIX "%I64"
00308 #define T_INT8_FORMAT_PREFIX _T("%I64")
00309 #else
00310 #define INT8_FORMAT_PREFIX "%ll"
00311 #define T_INT8_FORMAT_PREFIX _T("%ll")
00312 #endif
00313 #define CONST64(c) c##LL
00314 #endif
00315 #endif
00316
00317 #define INT8_FORMAT INT8_FORMAT_PREFIX "d"
00318 #define T_INT8_FORMAT T_INT8_FORMAT_PREFIX _T("d")
00319
00320
00321
00322 typedef db_int1 int1;
00323 typedef db_nat1 nat1;
00324 typedef db_int2 int2;
00325 typedef db_nat2 nat2;
00326 typedef db_int4 int4;
00327 typedef db_nat4 nat4;
00328
00329 typedef db_byte byte;
00330
00331 typedef db_real4 real4;
00332 typedef db_real8 real8;
00333
00334 typedef db_nat8 nat8;
00335
00336 #ifndef INT8_IS_DEFINED
00337 typedef db_int8 int8;
00338 #endif
00339
00340
00341
00342
00343 #if !defined(bool) && (defined(__SUNPRO_CC) && __SUNPRO_CC_COMPAT < 5)
00344 #define bool char
00345 #define true (1)
00346 #define false (0)
00347 #endif
00348
00349 #define nat8_low_part(x) ((db_nat4)(x))
00350 #define int8_low_part(x) ((db_int4)(x))
00351 #if defined(_MSC_VER) && _MSC_VER < 1300 // bug in MVC 6.0
00352 #define nat8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_nat4)((db_nat8)(x)>>32)))
00353 #define int8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_int4)((db_int8)(x)>>32)))
00354 #else
00355 #define nat8_high_part(x) ((db_nat4)((db_nat8)(x)>>32))
00356 #define int8_high_part(x) ((db_int4)((db_int8)(x)>>32))
00357 #endif
00358
00359 #define cons_nat8(hi, lo) ((((db_nat8)(hi)) << 32) | (db_nat4)(lo))
00360 #define cons_int8(hi, lo) ((((db_int8)(hi)) << 32) | (db_nat4)(lo))
00361
00362 #define MAX_NAT8 db_nat8(-1)
00363
00364 #ifndef BIG_ENDIAN
00365 #define BIG_ENDIAN 4321
00366 #endif
00367 #ifndef LITTLE_ENDIAN
00368 #define LITTLE_ENDIAN 1234
00369 #endif
00370
00371 #ifndef BYTE_ORDER
00372 #if defined(__sparc__) || defined(__m68k__)
00373 #define BYTE_ORDER BIG_ENDIAN
00374 #else
00375 #define BYTE_ORDER LITTLE_ENDIAN
00376 #endif
00377 #endif
00378
00379 #if defined(_WIN32) && !defined(__SYMBIAN32__)
00380 typedef HANDLE descriptor_t;
00381 #else
00382 typedef int descriptor_t;
00383 #endif
00384
00385 #if !defined(_fastcall) && (!defined(_WIN32) || defined(__IBMCPP__) || defined(__MINGW32__) || defined(__SYMBIAN32__))
00386 #define _fastcall
00387 #endif
00388
00389 #if defined(_WIN32) || !defined(NO_PTHREADS)
00390 #define THREADS_SUPPORTED 1
00391 #else
00392 #define THREADS_SUPPORTED 0
00393 #endif
00394
00395 #define itemsof(array) (sizeof(array)/sizeof*(array))
00396
00397 #define DEBUG_NONE 0
00398 #define DEBUG_CHECK 1
00399 #define DEBUG_TRACE 2
00400
00401 #if GIGABASE_DEBUG == DEBUG_TRACE
00402 #define TRACE_MSG(x) dbTrace x
00403 #else
00404 #define TRACE_MSG(x)
00405 #endif
00406
00407
00408 typedef void (*dbTraceFunctionPtr)(char_t* message);
00409
00410
00411 extern dbTraceFunctionPtr dbTraceFunction;
00412
00413
00414 extern bool dbTraceEnable;
00415
00416 extern GIGABASE_DLL_ENTRY void dbTrace(char_t* message, ...);
00417
00418 extern GIGABASE_DLL_ENTRY byte* dbMalloc(size_t size);
00419 extern GIGABASE_DLL_ENTRY void dbFree(void* ptr);
00420
00421 #if defined(__BCPLUSPLUS__)
00422 #define qsort(arr, n, s, cmp) std::qsort(arr, n, s, cmp)
00423 #endif
00424
00425 #ifndef __IBMCPP__
00426 END_GIGABASE_NAMESPACE
00427 #endif
00428
00429 #endif
00430
00431