Back to index

lightning-sunbird  0.9+nobinonly
os.c
Go to the documentation of this file.
00001 /*
00002 ** 2005 November 29
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 file contains OS interface code that is common to all
00014 ** architectures.
00015 */
00016 #define _SQLITE_OS_C_ 1
00017 #include "sqliteInt.h"
00018 #include "os.h"
00019 
00020 /*
00021 ** The following routines are convenience wrappers around methods
00022 ** of the OsFile object.  This is mostly just syntactic sugar.  All
00023 ** of this would be completely automatic if SQLite were coded using
00024 ** C++ instead of plain old C.
00025 */
00026 int sqlite3OsClose(OsFile **pId){
00027   OsFile *id;
00028   if( pId!=0 && (id = *pId)!=0 ){
00029     return id->pMethod->xClose(pId);
00030   }else{
00031     return SQLITE_OK;
00032   }
00033 }
00034 int sqlite3OsOpenDirectory(OsFile *id, const char *zName){
00035   return id->pMethod->xOpenDirectory(id, zName);
00036 }
00037 int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
00038   return id->pMethod->xRead(id, pBuf, amt);
00039 }
00040 int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
00041   return id->pMethod->xWrite(id, pBuf, amt);
00042 }
00043 int sqlite3OsSeek(OsFile *id, i64 offset){
00044   return id->pMethod->xSeek(id, offset);
00045 }
00046 int sqlite3OsTruncate(OsFile *id, i64 size){
00047   return id->pMethod->xTruncate(id, size);
00048 }
00049 int sqlite3OsSync(OsFile *id, int fullsync){
00050   return id->pMethod->xSync(id, fullsync);
00051 }
00052 void sqlite3OsSetFullSync(OsFile *id, int value){
00053   id->pMethod->xSetFullSync(id, value);
00054 }
00055 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
00056 /* This method is currently only used while interactively debugging the 
00057 ** pager. More specificly, it can only be used when sqlite3DebugPrintf() is
00058 ** included in the build. */
00059 int sqlite3OsFileHandle(OsFile *id){
00060   return id->pMethod->xFileHandle(id);
00061 }
00062 #endif
00063 int sqlite3OsFileSize(OsFile *id, i64 *pSize){
00064   return id->pMethod->xFileSize(id, pSize);
00065 }
00066 int sqlite3OsLock(OsFile *id, int lockType){
00067   return id->pMethod->xLock(id, lockType);
00068 }
00069 int sqlite3OsUnlock(OsFile *id, int lockType){
00070   return id->pMethod->xUnlock(id, lockType);
00071 }
00072 int sqlite3OsLockState(OsFile *id){
00073   return id->pMethod->xLockState(id);
00074 }
00075 int sqlite3OsCheckReservedLock(OsFile *id){
00076   return id->pMethod->xCheckReservedLock(id);
00077 }
00078 
00079 #ifdef SQLITE_ENABLE_REDEF_IO
00080 /*
00081 ** A function to return a pointer to the virtual function table.
00082 ** This routine really does not accomplish very much since the
00083 ** virtual function table is a global variable and anybody who
00084 ** can call this function can just as easily access the variable
00085 ** for themselves.  Nevertheless, we include this routine for
00086 ** backwards compatibility with an earlier redefinable I/O
00087 ** interface design.
00088 */
00089 struct sqlite3OsVtbl *sqlite3_os_switch(void){
00090   return &sqlite3Os;
00091 }
00092 #endif