Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 787cbae

Browse files
committed
adjustments to version reporting
1 parent 7e805e5 commit 787cbae

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/crypto.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
#include "sqlcipher-license.h"
4040
#endif
4141

42-
static const char* codec_get_cipher_version() {
43-
return CIPHER_VERSION;
44-
}
45-
4642
/* Generate code to return a string value */
4743
static void codec_vdbe_return_static_string(Parse *pParse, const char *zLabel, const char *value){
4844
Vdbe *v = sqlite3GetVdbe(pParse);
@@ -166,7 +162,13 @@ int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLef
166162
}
167163
} else
168164
if( sqlite3StrICmp(zLeft, "cipher_version")==0 && !zRight ){
169-
codec_vdbe_return_static_string(pParse, "cipher_version", codec_get_cipher_version());
165+
#ifdef CIPHER_VERSION_QUALIFIER
166+
char *version = sqlite3_mprintf("%s %s %s", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_QUALIFIER), CIPHER_XSTR(CIPHER_VERSION_BUILD));
167+
#else
168+
char *version = sqlite3_mprintf("%s %s", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_BUILD));
169+
#endif
170+
codec_vdbe_return_static_string(pParse, "cipher_version", version);
171+
sqlite3_free(version);
170172
}else
171173
if( sqlite3StrICmp(zLeft, "cipher")==0 ){
172174
if(ctx) {

src/crypto.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@ void sqlite3pager_reset(Pager *pPager);
5454

5555
#define FILE_HEADER_SZ 16
5656

57-
#ifndef CIPHER_VERSION
58-
#define CIPHER_VERSION "4.0.0 community"
57+
#define CIPHER_XSTR(s) CIPHER_STR(s)
58+
#define CIPHER_STR(s) #s
59+
60+
#ifndef CIPHER_VERSION_NUMBER
61+
#define CIPHER_VERSION_NUMBER 4.0.0
62+
#endif
63+
64+
#ifndef CIPHER_VERSION_BUILD
65+
#define CIPHER_VERSION_BUILD community
5966
#endif
6067

6168
#define CIPHER_DECRYPT 0

0 commit comments

Comments
 (0)