annotate sqlite/os.c @ 1694:02d3d6d7f223 trunk

[svn] - enforce support of our file extensions through use of the .SUFFIXES target
author nenolod
date Thu, 14 Sep 2006 14:06:45 -0700
parents b6b61becdf4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1434
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
1 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
2 ** 2005 November 29
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
3 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
4 ** The author disclaims copyright to this source code. In place of
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
5 ** a legal notice, here is a blessing:
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
6 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
7 ** May you do good and not evil.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
8 ** May you find forgiveness for yourself and forgive others.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
9 ** May you share freely, never taking more than you give.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
10 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
11 ******************************************************************************
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
12 **
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
13 ** This file contains OS interface code that is common to all
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
14 ** architectures.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
15 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
16 #define _SQLITE_OS_C_ 1
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
17 #include "sqliteInt.h"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
18 #include "os.h"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
19
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
20 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
21 ** The following routines are convenience wrappers around methods
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
22 ** of the OsFile object. This is mostly just syntactic sugar. All
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
23 ** of this would be completely automatic if SQLite were coded using
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
24 ** C++ instead of plain old C.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
25 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
26 int sqlite3OsClose(OsFile **pId){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
27 OsFile *id;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
28 if( pId!=0 && (id = *pId)!=0 ){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
29 return id->pMethod->xClose(pId);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
30 }else{
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
31 return SQLITE_OK;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
32 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
33 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
34 int sqlite3OsOpenDirectory(OsFile *id, const char *zName){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
35 return id->pMethod->xOpenDirectory(id, zName);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
36 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
37 int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
38 return id->pMethod->xRead(id, pBuf, amt);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
39 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
40 int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
41 return id->pMethod->xWrite(id, pBuf, amt);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
42 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
43 int sqlite3OsSeek(OsFile *id, i64 offset){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
44 return id->pMethod->xSeek(id, offset);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
45 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
46 int sqlite3OsTruncate(OsFile *id, i64 size){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
47 return id->pMethod->xTruncate(id, size);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
48 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
49 int sqlite3OsSync(OsFile *id, int fullsync){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
50 return id->pMethod->xSync(id, fullsync);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
51 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
52 void sqlite3OsSetFullSync(OsFile *id, int value){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
53 id->pMethod->xSetFullSync(id, value);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
54 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
55 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
56 /* This method is currently only used while interactively debugging the
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
57 ** pager. More specificly, it can only be used when sqlite3DebugPrintf() is
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
58 ** included in the build. */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
59 int sqlite3OsFileHandle(OsFile *id){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
60 return id->pMethod->xFileHandle(id);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
61 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
62 #endif
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
63 int sqlite3OsFileSize(OsFile *id, i64 *pSize){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
64 return id->pMethod->xFileSize(id, pSize);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
65 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
66 int sqlite3OsLock(OsFile *id, int lockType){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
67 return id->pMethod->xLock(id, lockType);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
68 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
69 int sqlite3OsUnlock(OsFile *id, int lockType){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
70 return id->pMethod->xUnlock(id, lockType);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
71 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
72 int sqlite3OsLockState(OsFile *id){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
73 return id->pMethod->xLockState(id);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
74 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
75 int sqlite3OsCheckReservedLock(OsFile *id){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
76 return id->pMethod->xCheckReservedLock(id);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
77 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
78
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
79 #ifdef SQLITE_ENABLE_REDEF_IO
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
80 /*
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
81 ** A function to return a pointer to the virtual function table.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
82 ** This routine really does not accomplish very much since the
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
83 ** virtual function table is a global variable and anybody who
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
84 ** can call this function can just as easily access the variable
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
85 ** for themselves. Nevertheless, we include this routine for
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
86 ** backwards compatibility with an earlier redefinable I/O
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
87 ** interface design.
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
88 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
89 struct sqlite3OsVtbl *sqlite3_os_switch(void){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
90 return &sqlite3Os;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
91 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
92 #endif