aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-03-02 19:06:42 +0000
committerdrh <drh@noemail.net>2011-03-02 19:06:42 +0000
commit1df30967af1a3e2c63d7863b26f544b44bd750ae (patch)
tree7dc98c4bbba4da84f24999a1131953a0971018e6 /src
parente562be52cf0dae1e3e3f204159860001abdd03d1 (diff)
downloadsqlite-1df30967af1a3e2c63d7863b26f544b44bd750ae.tar.gz
sqlite-1df30967af1a3e2c63d7863b26f544b44bd750ae.zip
Add additional VFS methods to retrieve system call pointers and to get a
list of all changeable system calls. FossilOrigin-Name: 38558363494e3a736dcb091dd859e76b7ccd78b0
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c46
-rw-r--r--src/os_win.c2
-rw-r--r--src/sqlite.h.in2
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