From 8319ae00014eb2d9171b7f5540b5474549f69c29 Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Tue, 24 Sep 2019 09:19:19 -0400 Subject: [PATCH] fix extension points --- src/crypto.c | 4 ---- src/crypto_impl.c | 9 +++++++++ src/func.c | 2 +- src/main.c | 7 +++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/crypto.c b/src/crypto.c index 0b7c6c9..64d1eae 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -1151,9 +1151,5 @@ end_of_export: #endif -#ifdef SQLCIPHER_FUNCS -#include "sqlcipher_funcs_impl.h" -#endif - /* END SQLCIPHER */ #endif diff --git a/src/crypto_impl.c b/src/crypto_impl.c index 112e2fc..ee4da66 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -43,6 +43,9 @@ #include #endif #endif +#ifdef SQLCIPHER_EXT +#include "sqlcipher_ext.h" +#endif static volatile unsigned int default_flags = DEFAULT_CIPHER_FLAGS; static volatile unsigned char hmac_salt_mask = HMAC_SALT_MASK; @@ -212,6 +215,9 @@ void sqlcipher_activate() { #error "NO DEFAULT SQLCIPHER CRYPTO PROVIDER DEFINED" #endif CODEC_TRACE("sqlcipher_activate: calling sqlcipher_register_provider(%p)\n", p); +#ifdef SQLCIPHER_EXT + sqlcipher_ext_provider_setup(p); +#endif sqlcipher_register_provider(p); CODEC_TRACE("sqlcipher_activate: called sqlcipher_register_provider(%p)\n",p); } @@ -252,6 +258,9 @@ void sqlcipher_deactivate() { sqlcipher_provider_mutex = NULL; sqlcipher_activate_count = 0; /* reset activation count */ +#ifdef SQLCIPHER_EXT + sqlcipher_ext_provider_destroy(); +#endif } CODEC_TRACE_MUTEX("sqlcipher_deactivate: leaving static master mutex\n"); diff --git a/src/func.c b/src/func.c index 31967bd..574618b 100644 --- a/src/func.c +++ b/src/func.c @@ -1803,7 +1803,7 @@ void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){ sqlite3CreateFunc(db, "sqlcipher_export", -1, SQLITE_TEXT, 0, sqlcipher_exportFunc, 0, 0, 0, 0, 0); } #endif -#ifdef SQLCIPHER_FUNCS +#ifdef SQLCIPHER_EXT #include "sqlcipher_funcs_init.h" #endif #endif diff --git a/src/main.c b/src/main.c index 24f7f20..7cc9ced 100644 --- a/src/main.c +++ b/src/main.c @@ -3282,6 +3282,13 @@ static int openDatabase( } #endif +#ifdef SQLCIPHER_EXT + if( !db->mallocFailed && rc==SQLITE_OK ){ + extern int sqlcipherVtabInit(sqlite3 *); + rc = sqlcipherVtabInit(db); + } +#endif + /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking ** mode. Doing nothing at all also makes NORMAL the default.