From 787cbae31a70b04f82f4bf7c74a0abfc81d68922 Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Wed, 17 Oct 2018 20:31:23 -0400 Subject: [PATCH] adjustments to version reporting --- src/crypto.c | 12 +++++++----- src/crypto.h | 11 +++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/crypto.c b/src/crypto.c index 51255e8b..13d7eb8c 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -39,10 +39,6 @@ #include "sqlcipher-license.h" #endif -static const char* codec_get_cipher_version() { - return CIPHER_VERSION; -} - /* Generate code to return a string value */ static void codec_vdbe_return_static_string(Parse *pParse, const char *zLabel, const char *value){ Vdbe *v = sqlite3GetVdbe(pParse); @@ -166,7 +162,13 @@ int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLef } } else if( sqlite3StrICmp(zLeft, "cipher_version")==0 && !zRight ){ - codec_vdbe_return_static_string(pParse, "cipher_version", codec_get_cipher_version()); +#ifdef CIPHER_VERSION_QUALIFIER + char *version = sqlite3_mprintf("%s %s %s", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_QUALIFIER), CIPHER_XSTR(CIPHER_VERSION_BUILD)); +#else + char *version = sqlite3_mprintf("%s %s", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_BUILD)); +#endif + codec_vdbe_return_static_string(pParse, "cipher_version", version); + sqlite3_free(version); }else if( sqlite3StrICmp(zLeft, "cipher")==0 ){ if(ctx) { diff --git a/src/crypto.h b/src/crypto.h index 05cb64c5..7f91c4d2 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -54,8 +54,15 @@ void sqlite3pager_reset(Pager *pPager); #define FILE_HEADER_SZ 16 -#ifndef CIPHER_VERSION -#define CIPHER_VERSION "4.0.0 community" +#define CIPHER_XSTR(s) CIPHER_STR(s) +#define CIPHER_STR(s) #s + +#ifndef CIPHER_VERSION_NUMBER +#define CIPHER_VERSION_NUMBER 4.0.0 +#endif + +#ifndef CIPHER_VERSION_BUILD +#define CIPHER_VERSION_BUILD community #endif #define CIPHER_DECRYPT 0