Eneboo - Documentación para desarrolladores
src/qt/src/3rdparty/sqlite/os.h
Ir a la documentación de este archivo.
00001 /*
00002 ** 2001 September 16
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 ******************************************************************************
00012 **
00013 ** This header file (together with is companion C source-code file
00014 ** "os.c") attempt to abstract the underlying operating system so that
00015 ** the SQLite library will work on both POSIX and windows systems.
00016 */
00017 #ifndef _SQLITE_OS_H_
00018 #define _SQLITE_OS_H_
00019 
00020 #include "config.h"
00021 /*
00022 ** Helpful hint:  To get this to compile on HP/UX, add -D_INCLUDE_POSIX_SOURCE
00023 ** to the compiler command line.
00024 */
00025 
00026 /*
00027 ** These #defines should enable >2GB file support on Posix if the
00028 ** underlying operating system supports it.  If the OS lacks
00029 ** large file support, or if the OS is windows, these should be no-ops.
00030 **
00031 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
00032 ** on the compiler command line.  This is necessary if you are compiling
00033 ** on a recent machine (ex: RedHat 7.2) but you want your code to work
00034 ** on an older machine (ex: RedHat 6.0).  If you compile on RedHat 7.2
00035 ** without this option, LFS is enable.  But LFS does not exist in the kernel
00036 ** in RedHat 6.0, so the code won't work.  Hence, for maximum binary
00037 ** portability you should omit LFS.
00038 **
00039 ** Similar is true for MacOS.  LFS is only supported on MacOS 9 and later.
00040 */
00041 #ifndef SQLITE_DISABLE_LFS
00042 # define _LARGE_FILE       1
00043 # ifndef _FILE_OFFSET_BITS
00044 #   define _FILE_OFFSET_BITS 64
00045 # endif
00046 # define _LARGEFILE_SOURCE 1
00047 #endif
00048 
00049 /*
00050 ** Temporary files are named starting with this prefix followed by 16 random
00051 ** alphanumeric characters, and no file extension. They are stored in the
00052 ** OS's standard temporary file directory, and are deleted prior to exit.
00053 ** If sqlite is being embedded in another program, you may wish to change the
00054 ** prefix to reflect your program's name, so that if your program exits
00055 ** prematurely, old temporary files can be easily identified. This can be done
00056 ** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line.
00057 */
00058 #ifndef TEMP_FILE_PREFIX
00059 # define TEMP_FILE_PREFIX "sqlite_"
00060 #endif
00061 
00062 /*
00063 ** Figure out if we are dealing with Unix, Windows or MacOS.
00064 **
00065 ** N.B. MacOS means Mac Classic (or Carbon). Treat Darwin (OS X) as Unix.
00066 **      The MacOS build is designed to use CodeWarrior (tested with v8)
00067 */
00068 #ifndef OS_UNIX
00069 # ifndef OS_WIN
00070 #  ifndef OS_MAC
00071 #    if defined(__MACOS__)
00072 #      define OS_MAC 1
00073 #      define OS_WIN 0
00074 #      define OS_UNIX 0
00075 #    elif defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
00076 #      define OS_MAC 0
00077 #      define OS_WIN 1
00078 #      define OS_UNIX 0
00079 #    else
00080 #      define OS_MAC 0
00081 #      define OS_WIN 0
00082 #      define OS_UNIX 1
00083 #    endif
00084 #  else
00085 #    define OS_WIN 0
00086 #    define OS_UNIX 0
00087 #  endif
00088 # else
00089 #  define OS_MAC 0
00090 #  define OS_UNIX 0
00091 # endif
00092 #else
00093 # define OS_MAC 0
00094 # ifndef OS_WIN
00095 #  define OS_WIN 0
00096 # endif
00097 #endif
00098 
00099 /*
00100 ** A handle for an open file is stored in an OsFile object.
00101 */
00102 #if OS_UNIX
00103 # include <sys/types.h>
00104 # include <sys/stat.h>
00105 # include <fcntl.h>
00106 # include <unistd.h>
00107   typedef struct OsFile OsFile;
00108   struct OsFile {
00109     struct openCnt *pOpen;    /* Info about all open fd's on this inode */
00110     struct lockInfo *pLock;   /* Info about locks on this inode */
00111     int fd;                   /* The file descriptor */
00112     int locked;               /* True if this instance holds the lock */
00113     int dirfd;                /* File descriptor for the directory */
00114   };
00115 # define SQLITE_TEMPNAME_SIZE 200
00116 # if defined(HAVE_USLEEP) && HAVE_USLEEP
00117 #  define SQLITE_MIN_SLEEP_MS 1
00118 # else
00119 #  define SQLITE_MIN_SLEEP_MS 1000
00120 # endif
00121 #endif
00122 
00123 #if OS_WIN
00124 #include <windows.h>
00125 #include <winbase.h>
00126   typedef struct OsFile OsFile;
00127   struct OsFile {
00128     HANDLE h;               /* Handle for accessing the file */
00129     int locked;             /* 0: unlocked, <0: write lock, >0: read lock */
00130   };
00131 # if defined(_MSC_VER) || defined(__BORLANDC__)
00132     typedef __int64 off_t;
00133 # else
00134 #  if !defined(_CYGWIN_TYPES_H)
00135      typedef long long off_t;
00136 #    if defined(__MINGW32__)
00137 #      define   _OFF_T_
00138 #    endif
00139 #  endif
00140 # endif
00141 # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)
00142 # define SQLITE_MIN_SLEEP_MS 1
00143 #endif
00144 
00145 #if OS_MAC
00146 # include <unistd.h>
00147 # include <Files.h>
00148   typedef struct OsFile OsFile;
00149   struct OsFile {
00150     SInt16 refNum;           /* Data fork/file reference number */
00151     SInt16 refNumRF;         /* Resource fork reference number (for locking) */
00152     int locked;              /* 0: unlocked, <0: write lock, >0: read lock */
00153     int delOnClose;          /* True if file is to be deleted on close */
00154     char *pathToDel;         /* Name of file to delete on close */
00155   };
00156 # ifdef _LARGE_FILE
00157     typedef SInt64 off_t;
00158 # else
00159     typedef SInt32 off_t;
00160 # endif
00161 # define SQLITE_TEMPNAME_SIZE _MAX_PATH
00162 # define SQLITE_MIN_SLEEP_MS 17
00163 #endif
00164 
00165 int sqliteOsDelete(const char*);
00166 int sqliteOsFileExists(const char*);
00167 int sqliteOsFileRename(const char*, const char*);
00168 int sqliteOsOpenReadWrite(const char*, OsFile*, int*);
00169 int sqliteOsOpenExclusive(const char*, OsFile*, int);
00170 int sqliteOsOpenReadOnly(const char*, OsFile*);
00171 int sqliteOsOpenDirectory(const char*, OsFile*);
00172 int sqliteOsTempFileName(char*);
00173 int sqliteOsClose(OsFile*);
00174 int sqliteOsRead(OsFile*, void*, int amt);
00175 int sqliteOsWrite(OsFile*, const void*, int amt);
00176 int sqliteOsSeek(OsFile*, off_t offset);
00177 int sqliteOsSync(OsFile*);
00178 int sqliteOsTruncate(OsFile*, off_t size);
00179 int sqliteOsFileSize(OsFile*, off_t *pSize);
00180 int sqliteOsReadLock(OsFile*);
00181 int sqliteOsWriteLock(OsFile*);
00182 int sqliteOsUnlock(OsFile*);
00183 int sqliteOsRandomSeed(char*);
00184 int sqliteOsSleep(int ms);
00185 int sqliteOsCurrentTime(double*);
00186 void sqliteOsEnterMutex(void);
00187 void sqliteOsLeaveMutex(void);
00188 char *sqliteOsFullPathname(const char*);
00189 
00190 
00191 
00192 #endif /* _SQLITE_OS_H_ */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'