⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os.h

📁 sqlite嵌入式数据库源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*** 2001 September 16**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.************************************************************************************ This header file (together with is companion C source-code file** "os.c") attempt to abstract the underlying operating system so that** the SQLite library will work on both POSIX and windows systems.*/#ifndef _SQLITE_OS_H_#define _SQLITE_OS_H_/*** Figure out if we are dealing with Unix, Windows, or some other** operating system.*/#if !defined(OS_UNIX) && !defined(OS_OTHER)# define OS_OTHER 0# ifndef OS_WIN#   if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)#     define OS_WIN 1#     define OS_UNIX 0#     define OS_OS2 0#   elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__)#     define OS_WIN 0#     define OS_UNIX 0#     define OS_OS2 1#   else#     define OS_WIN 0#     define OS_UNIX 1#     define OS_OS2 0#  endif# else#  define OS_UNIX 0#  define OS_OS2 0# endif#else# ifndef OS_WIN#  define OS_WIN 0# endif#endif/*** Define the maximum size of a temporary filename*/#if OS_WIN# include <windows.h># define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)#elif OS_OS2# define INCL_DOSDATETIME# define INCL_DOSFILEMGR# define INCL_DOSERRORS# define INCL_DOSMISC# define INCL_DOSPROCESS# include <os2.h># define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP)#else# define SQLITE_TEMPNAME_SIZE 200#endif/* If the SET_FULLSYNC macro is not defined above, then make it** a no-op*/#ifndef SET_FULLSYNC# define SET_FULLSYNC(x,y)#endif/*** Temporary files are named starting with this prefix followed by 16 random** alphanumeric characters, and no file extension. They are stored in the** OS's standard temporary file directory, and are deleted prior to exit.** If sqlite is being embedded in another program, you may wish to change the** prefix to reflect your program's name, so that if your program exits** prematurely, old temporary files can be easily identified. This can be done** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line.*/#ifndef TEMP_FILE_PREFIX# define TEMP_FILE_PREFIX "sqlite_"#endif/*** Define the interfaces for Unix, Windows, and OS/2.*/#if OS_UNIX#define sqlite3OsOpenReadWrite      sqlite3UnixOpenReadWrite#define sqlite3OsOpenExclusive      sqlite3UnixOpenExclusive#define sqlite3OsOpenReadOnly       sqlite3UnixOpenReadOnly#define sqlite3OsDelete             sqlite3UnixDelete#define sqlite3OsFileExists         sqlite3UnixFileExists#define sqlite3OsFullPathname       sqlite3UnixFullPathname#define sqlite3OsIsDirWritable      sqlite3UnixIsDirWritable#define sqlite3OsSyncDirectory      sqlite3UnixSyncDirectory#define sqlite3OsTempFileName       sqlite3UnixTempFileName#define sqlite3OsRandomSeed         sqlite3UnixRandomSeed#define sqlite3OsSleep              sqlite3UnixSleep#define sqlite3OsCurrentTime        sqlite3UnixCurrentTime#define sqlite3OsEnterMutex         sqlite3UnixEnterMutex#define sqlite3OsLeaveMutex         sqlite3UnixLeaveMutex#define sqlite3OsInMutex            sqlite3UnixInMutex#define sqlite3OsThreadSpecificData sqlite3UnixThreadSpecificData#define sqlite3OsMalloc             sqlite3GenericMalloc#define sqlite3OsRealloc            sqlite3GenericRealloc#define sqlite3OsFree               sqlite3GenericFree#define sqlite3OsAllocationSize     sqlite3GenericAllocationSize#endif#if OS_WIN#define sqlite3OsOpenReadWrite      sqlite3WinOpenReadWrite#define sqlite3OsOpenExclusive      sqlite3WinOpenExclusive#define sqlite3OsOpenReadOnly       sqlite3WinOpenReadOnly#define sqlite3OsDelete             sqlite3WinDelete#define sqlite3OsFileExists         sqlite3WinFileExists#define sqlite3OsFullPathname       sqlite3WinFullPathname#define sqlite3OsIsDirWritable      sqlite3WinIsDirWritable#define sqlite3OsSyncDirectory      sqlite3WinSyncDirectory#define sqlite3OsTempFileName       sqlite3WinTempFileName#define sqlite3OsRandomSeed         sqlite3WinRandomSeed#define sqlite3OsSleep              sqlite3WinSleep#define sqlite3OsCurrentTime        sqlite3WinCurrentTime#define sqlite3OsEnterMutex         sqlite3WinEnterMutex#define sqlite3OsLeaveMutex         sqlite3WinLeaveMutex#define sqlite3OsInMutex            sqlite3WinInMutex#define sqlite3OsThreadSpecificData sqlite3WinThreadSpecificData#define sqlite3OsMalloc             sqlite3GenericMalloc#define sqlite3OsRealloc            sqlite3GenericRealloc#define sqlite3OsFree               sqlite3GenericFree#define sqlite3OsAllocationSize     sqlite3GenericAllocationSize#endif#if OS_OS2#define sqlite3OsOpenReadWrite      sqlite3Os2OpenReadWrite#define sqlite3OsOpenExclusive      sqlite3Os2OpenExclusive#define sqlite3OsOpenReadOnly       sqlite3Os2OpenReadOnly#define sqlite3OsDelete             sqlite3Os2Delete#define sqlite3OsFileExists         sqlite3Os2FileExists#define sqlite3OsFullPathname       sqlite3Os2FullPathname#define sqlite3OsIsDirWritable      sqlite3Os2IsDirWritable#define sqlite3OsSyncDirectory      sqlite3Os2SyncDirectory#define sqlite3OsTempFileName       sqlite3Os2TempFileName#define sqlite3OsRandomSeed         sqlite3Os2RandomSeed#define sqlite3OsSleep              sqlite3Os2Sleep#define sqlite3OsCurrentTime        sqlite3Os2CurrentTime#define sqlite3OsEnterMutex         sqlite3Os2EnterMutex#define sqlite3OsLeaveMutex         sqlite3Os2LeaveMutex#define sqlite3OsInMutex            sqlite3Os2InMutex#define sqlite3OsThreadSpecificData sqlite3Os2ThreadSpecificData#define sqlite3OsMalloc             sqlite3GenericMalloc#define sqlite3OsRealloc            sqlite3GenericRealloc#define sqlite3OsFree               sqlite3GenericFree#define sqlite3OsAllocationSize     sqlite3GenericAllocationSize#endif/*** If using an alternative OS interface, then we must have an "os_other.h"** header file available for that interface.  Presumably the "os_other.h"** header file contains #defines similar to those above.*/#if OS_OTHER# include "os_other.h"#endif/*** Forward declarations*/typedef struct OsFile OsFile;typedef struct IoMethod IoMethod;/*** An instance of the following structure contains pointers to all** methods on an OsFile object.*/struct IoMethod {  int (*xClose)(OsFile**);  int (*xOpenDirectory)(OsFile*, const char*);  int (*xRead)(OsFile*, void*, int amt);  int (*xWrite)(OsFile*, const void*, int amt);  int (*xSeek)(OsFile*, i64 offset);  int (*xTruncate)(OsFile*, i64 size);  int (*xSync)(OsFile*, int);  void (*xSetFullSync)(OsFile *id, int setting);  int (*xFileHandle)(OsFile *id);  int (*xFileSize)(OsFile*, i64 *pSize);  int (*xLock)(OsFile*, int);  int (*xUnlock)(OsFile*, int);  int (*xLockState)(OsFile *id);  int (*xCheckReservedLock)(OsFile *id);};/*** The OsFile object describes an open disk file in an OS-dependent way.** The version of OsFile defined here is a generic version.  Each OS** implementation defines its own subclass of this structure that contains** additional information needed to handle file I/O.  But the pMethod** entry (pointing to the virtual function table) always occurs first** so that we can always find the appropriate methods.*/struct OsFile {  IoMethod const *pMethod;};/*** The following values may be passed as the second argument to** sqlite3OsLock(). The various locks exhibit the following semantics:**** SHARED:    Any number of processes may hold a SHARED lock simultaneously.** RESERVED:  A single process may hold a RESERVED lock on a file at**            any time. Other processes may hold and obtain new SHARED locks.** PENDING:   A single process may hold a PENDING lock on a file at**            any one time. Existing SHARED locks may persist, but no new**            SHARED locks may be obtained by other processes.** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.**** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a** process that requests an EXCLUSIVE lock may actually obtain a PENDING** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to** sqlite3OsLock().*/#define NO_LOCK         0#define SHARED_LOCK     1#define RESERVED_LOCK   2#define PENDING_LOCK    3#define EXCLUSIVE_LOCK  4/*** File Locking Notes:  (Mostly about windows but also some info for Unix)**** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because** those functions are not available.  So we use only LockFile() and** UnlockFile().**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -