Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

win_db.h

00001 /*-
00002  * $Id: win_db.h,v 12.77 2005/11/12 17:43:39 bostic Exp $
00003  *
00004  * The following provides the information necessary to build Berkeley
00005  * DB on native Windows, and other Windows environments such as MinGW.
00006  */
00007 
00008 /*
00009  * Avoid warnings with Visual Studio 8.
00010  */
00011 #define _CRT_SECURE_NO_DEPRECATE 1
00012 
00013 #include <sys/types.h>
00014 #include <sys/stat.h>
00015 
00016 #include <direct.h>
00017 #include <fcntl.h>
00018 #include <io.h>
00019 #include <limits.h>
00020 #include <memory.h>
00021 #include <process.h>
00022 #include <signal.h>
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <tchar.h>
00026 #include <time.h>
00027 #include <errno.h>
00028 
00029 /*
00030  * To build Tcl interface libraries, the include path must be configured to
00031  * use the directory containing <tcl.h>, usually the include directory in
00032  * the Tcl distribution.
00033  */
00034 #ifdef DB_TCL_SUPPORT
00035 #include <tcl.h>
00036 #endif
00037 
00038 #define WIN32_LEAN_AND_MEAN
00039 #include <windows.h>
00040 
00041 /*
00042  * All of the necessary includes have been included, ignore the #includes
00043  * in the Berkeley DB source files.
00044  */
00045 #define NO_SYSTEM_INCLUDES
00046 
00047 /*
00048  * Microsoft's C runtime library has fsync, getcwd, getpid, snprintf and
00049  * vsnprintf, but under different names.
00050  */
00051 #define fsync                   _commit
00052 #define getcwd(buf, size)       _getcwd(buf, size)
00053 #define getpid                  _getpid
00054 #define snprintf                _snprintf
00055 #define vsnprintf               _vsnprintf
00056 
00057 /*
00058  * Windows defines off_t to long (i.e., 32 bits).
00059  */
00060 #define off_t   __db_off_t
00061 typedef __int64 off_t;
00062 
00063 /*
00064  * Win32 does not define getopt and friends in any header file, so we must.
00065  */
00066 #if defined(__cplusplus)
00067 extern "C" {
00068 #endif
00069 extern int optind;
00070 extern char *optarg;
00071 extern int getopt(int, char * const *, const char *);
00072 #if defined(__cplusplus)
00073 }
00074 #endif
00075 
00076 #ifdef _UNICODE
00077 #define TO_TSTRING(dbenv, s, ts, ret) do {                              \
00078                 int __len = (int)strlen(s) + 1;                         \
00079                 ts = NULL;                                              \
00080                 if ((ret = __os_malloc((dbenv),                         \
00081                     __len * sizeof (_TCHAR), &(ts))) == 0 &&            \
00082                     MultiByteToWideChar(CP_UTF8, 0,                     \
00083                     (s), -1, (ts), __len) == 0)                         \
00084                         ret = __os_get_errno();                         \
00085         } while (0)
00086 
00087 #define FROM_TSTRING(dbenv, ts, s, ret) {                               \
00088                 int __len = WideCharToMultiByte(CP_UTF8, 0, ts, -1,     \
00089                     NULL, 0, NULL, NULL);                               \
00090                 s = NULL;                                               \
00091                 if ((ret = __os_malloc((dbenv), __len, &(s))) == 0 &&   \
00092                     WideCharToMultiByte(CP_UTF8, 0,                     \
00093                     (ts), -1, (s), __len, NULL, NULL) == 0)             \
00094                         ret = __os_get_errno();                         \
00095         } while (0)
00096 
00097 #define FREE_STRING(dbenv, s) do {                                      \
00098                 if ((s) != NULL) {                                      \
00099                         __os_free((dbenv), (s));                        \
00100                         (s) = NULL;                                     \
00101                 }                                                       \
00102         } while (0)
00103 
00104 #else
00105 #define TO_TSTRING(dbenv, s, ts, ret) (ret) = 0, (ts) = (_TCHAR *)(s)
00106 #define FROM_TSTRING(dbenv, ts, s, ret) (ret) = 0, (s) = (char *)(ts)
00107 #define FREE_STRING(dbenv, ts)
00108 #endif
00109 
00110 #ifndef INVALID_HANDLE_VALUE
00111 #define INVALID_HANDLE_VALUE ((HANDLE)-1)
00112 #endif
00113 
00114 #ifndef INVALID_FILE_ATTRIBUTES
00115 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
00116 #endif
00117 
00118 #ifndef INVALID_SET_FILE_POINTER
00119 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
00120 #endif

Generated on Sun Dec 25 12:14:17 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2