00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _SQLITE_OS_H_
00018 #define _SQLITE_OS_H_
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef SQLITE_DISABLE_LFS
00041 # define _LARGE_FILE 1
00042 # ifndef _FILE_OFFSET_BITS
00043 # define _FILE_OFFSET_BITS 64
00044 # endif
00045 # define _LARGEFILE_SOURCE 1
00046 #endif
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef TEMP_FILE_PREFIX
00058 # define TEMP_FILE_PREFIX "sqlite_"
00059 #endif
00060
00061
00062
00063
00064
00065
00066
00067 #ifndef OS_UNIX
00068 # ifndef OS_WIN
00069 # ifndef OS_MAC
00070 # if defined(__MACOS__)
00071 # define OS_MAC 1
00072 # define OS_WIN 0
00073 # define OS_UNIX 0
00074 # elif defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
00075 # define OS_MAC 0
00076 # define OS_WIN 1
00077 # define OS_UNIX 0
00078 # else
00079 # define OS_MAC 0
00080 # define OS_WIN 0
00081 # define OS_UNIX 1
00082 # endif
00083 # else
00084 # define OS_WIN 0
00085 # define OS_UNIX 0
00086 # endif
00087 # else
00088 # define OS_MAC 0
00089 # define OS_UNIX 0
00090 # endif
00091 #else
00092 # define OS_MAC 0
00093 # ifndef OS_WIN
00094 # define OS_WIN 0
00095 # endif
00096 #endif
00097
00098
00099
00100
00101 #if OS_UNIX
00102 # include <sys/types.h>
00103 # include <sys/stat.h>
00104 # include <fcntl.h>
00105 # include <unistd.h>
00106 typedef struct OsFile OsFile;
00107 struct OsFile {
00108 struct openCnt *pOpen;
00109 struct lockInfo *pLock;
00110 int fd;
00111 int locked;
00112 int dirfd;
00113 };
00114 # define SQLITE_TEMPNAME_SIZE 200
00115 # if defined(HAVE_USLEEP) && HAVE_USLEEP
00116 # define SQLITE_MIN_SLEEP_MS 1
00117 # else
00118 # define SQLITE_MIN_SLEEP_MS 1000
00119 # endif
00120 #endif
00121
00122 #if OS_WIN
00123 #include <windows.h>
00124 #include <winbase.h>
00125 typedef struct OsFile OsFile;
00126 struct OsFile {
00127 HANDLE h;
00128 int locked;
00129 };
00130 # if defined(_MSC_VER) || defined(__BORLANDC__)
00131 typedef __int64 off_t;
00132 # else
00133 # if !defined(_CYGWIN_TYPES_H)
00134 typedef long long off_t;
00135 # if defined(__MINGW32__)
00136 # define _OFF_T_
00137 # endif
00138 # endif
00139 # endif
00140 # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)
00141 # define SQLITE_MIN_SLEEP_MS 1
00142 #endif
00143
00144 #if OS_MAC
00145 # include <unistd.h>
00146 # include <Files.h>
00147 typedef struct OsFile OsFile;
00148 struct OsFile {
00149 SInt16 refNum;
00150 SInt16 refNumRF;
00151 int locked;
00152 int delOnClose;
00153 char *pathToDel;
00154 };
00155 # ifdef _LARGE_FILE
00156 typedef SInt64 off_t;
00157 # else
00158 typedef SInt32 off_t;
00159 # endif
00160 # define SQLITE_TEMPNAME_SIZE _MAX_PATH
00161 # define SQLITE_MIN_SLEEP_MS 17
00162 #endif
00163
00164 int sqliteOsDelete(const char*);
00165 int sqliteOsFileExists(const char*);
00166 int sqliteOsFileRename(const char*, const char*);
00167 int sqliteOsOpenReadWrite(const char*, OsFile*, int*);
00168 int sqliteOsOpenExclusive(const char*, OsFile*, int);
00169 int sqliteOsOpenReadOnly(const char*, OsFile*);
00170 int sqliteOsOpenDirectory(const char*, OsFile*);
00171 int sqliteOsTempFileName(char*);
00172 int sqliteOsClose(OsFile*);
00173 int sqliteOsRead(OsFile*, void*, int amt);
00174 int sqliteOsWrite(OsFile*, const void*, int amt);
00175 int sqliteOsSeek(OsFile*, off_t offset);
00176 int sqliteOsSync(OsFile*);
00177 int sqliteOsTruncate(OsFile*, off_t size);
00178 int sqliteOsFileSize(OsFile*, off_t *pSize);
00179 int sqliteOsReadLock(OsFile*);
00180 int sqliteOsWriteLock(OsFile*);
00181 int sqliteOsUnlock(OsFile*);
00182 int sqliteOsRandomSeed(char*);
00183 int sqliteOsSleep(int ms);
00184 int sqliteOsCurrentTime(double*);
00185 void sqliteOsEnterMutex(void);
00186 void sqliteOsLeaveMutex(void);
00187 char *sqliteOsFullPathname(const char*);
00188
00189
00190
00191 #endif