diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 46 | ||||
-rw-r--r-- | src/os_win.c | 2 | ||||
-rw-r--r-- | src/sqlite.h.in | 2 |
3 files changed, 46 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 18ec65870..c5261bb11 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -376,7 +376,9 @@ static struct unix_syscall { /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the -** "unix" VFSes. +** "unix" VFSes. Return SQLITE_OK opon successfully updating the +** system call pointer, or SQLITE_NOTFOUND if there is no configurable +** system call named zName. */ static int unixSetSystemCall( sqlite3_vfs *pNotUsed, /* The VFS pointer. Not used */ @@ -384,7 +386,7 @@ static int unixSetSystemCall( void *pNewFunc /* Pointer to new system call value */ ){ int i; - int rc = 0; + int rc = SQLITE_NOTFOUND; if( zName==0 ){ /* If no zName is given, restore all system calls to their default ** settings and return NULL @@ -392,7 +394,7 @@ static int unixSetSystemCall( for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){ if( aSyscall[i].pDefault ){ aSyscall[i].pCurrent = aSyscall[i].pDefault; - rc = 1; + rc = SQLITE_OK; } } }else{ @@ -404,7 +406,7 @@ static int unixSetSystemCall( if( aSyscall[i].pDefault==0 ){ aSyscall[i].pDefault = aSyscall[i].pCurrent; } - rc = 1; + rc = SQLITE_OK; if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault; aSyscall[i].pCurrent = pNewFunc; break; @@ -414,6 +416,40 @@ static int unixSetSystemCall( return rc; } +/* +** Return the value of a system call. Return NULL if zName is not a +** recognized system call name. NULL is also returned if the system call +** is currently undefined. +*/ +static void *unixGetSystemCall(sqlite3_vfs *pNotUsed, const char *zName){ + int i; + for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){ + if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent; + } + return 0; +} + +/* +** Return the name of the first system call after zName. If zName==NULL +** then return the name of the first system call. Return NULL if zName +** is the last system call or if zName is not the name of a valid +** system call. +*/ +static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){ + int i; + if( zName==0 ){ + i = -1; + }else{ + for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0])-1; i++){ + if( strcmp(zName, aSyscall[0].zName)==0 ) break; + } + } + for(i++; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){ + if( aSyscall[0].pCurrent!=0 ) return aSyscall[0].zName; + } + return 0; +} + /* ** Helper functions to obtain and relinquish the global mutex. The @@ -6497,6 +6533,8 @@ int sqlite3_os_init(void){ unixGetLastError, /* xGetLastError */ \ unixCurrentTimeInt64, /* xCurrentTimeInt64 */ \ unixSetSystemCall, /* xSetSystemCall */ \ + unixGetSystemCall, /* xGetSystemCall */ \ + unixNextSystemCall, /* xNextSystemCall */ \ } /* diff --git a/src/os_win.c b/src/os_win.c index 4d19e57a3..c8768339c 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2766,6 +2766,8 @@ int sqlite3_os_init(void){ winGetLastError, /* xGetLastError */ winCurrentTimeInt64, /* xCurrentTimeInt64 */ 0, /* xSetSystemCall */ + 0, /* xGetSystemCall */ + 0, /* xNextSystemCall */ }; #ifndef SQLITE_OMIT_WAL diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5c07b8d96..e2332466f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -925,6 +925,8 @@ struct sqlite3_vfs { ** Those below are for version 3 and greater. */ int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, void *pFunc); + void *(*xGetSystemCall)(sqlite3_vfs*, const char *zName); + const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); /* ** The methods above are in versions 1 through 3 of the sqlite_vfs object. ** New fields may be appended in figure versions. The iVersion |