Skip to content

Commit aa4a824

Browse files
committed
Add function prototype for sqlite3mcCodecGetKey
1 parent b745e46 commit aa4a824

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

scripts/patchsqlite3.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ die() {
1717
# 1) Intercept VFS pragma handling
1818
# 2) Add handling of KEY parameter in ATTACH statements
1919
sed 's/sqlite3_file_control\(.*SQLITE_FCNTL_PRAGMA\)/sqlite3mcFileControlPragma\1/' "$INPUT" \
20-
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcCheckVfs(const char*);\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);\ntypedef struct Pager PagerMC;\nSQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);\nSQLITE_PRIVATE void sqlite3mcInitMemoryMethods();\nSQLITE_PRIVATE int sqlite3mcIsBackupSupported(sqlite3*, const char*, sqlite3*, const char*);' \
20+
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcCheckVfs(const char*);\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);\ntypedef struct Pager PagerMC;\nSQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);\nSQLITE_PRIVATE void sqlite3mcInitMemoryMethods();\nSQLITE_PRIVATE int sqlite3mcIsBackupSupported(sqlite3*, const char*, sqlite3*, const char*);\nSQLITE_PRIVATE void sqlite3mcCodecGetKey(sqlite3* db, int nDb, void** zKey, int* nKey);' \
2121
| sed '/\#define MAX\_PATHNAME 512/c #if SQLITE3MC\_MAX\_PATHNAME \> 512\n#define MAX_PATHNAME SQLITE3MC\_MAX\_PATHNAME\n#else\n#define MAX_PATHNAME 512\n#endif' \
2222
| sed '/pData = pPage->pData;/c \ if( (pData = sqlite3mcPagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;' \
2323
| sed '/pData = p->pData;/c \ if( (pData = sqlite3mcPagerCodec(p))==0 ) return SQLITE_NOMEM;' \
@@ -28,4 +28,4 @@ sed 's/sqlite3_file_control\(.*SQLITE_FCNTL_PRAGMA\)/sqlite3mcFileControlPragma\
2828
| sed '/^ }else if( USEFETCH(pPager) ){/c \ }else if( USEFETCH(pPager) && sqlite3mcPagerHasCodec(pPager) == 0 ){' \
2929
| sed '/^ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));/a \\n \/\* Initialize wrapper for memory management.\*\/\n if( rc==SQLITE_OK ) {\n sqlite3mcInitMemoryMethods();\n }\n' \
3030
| sed '/Lock the source database handle./i \ \/\* Check whether databases are compatible with backup \*\/\n if (!sqlite3mcIsBackupSupported(pSrcDb, zSrcDb, pDestDb, zDestDb)){\n sqlite3ErrorWithMsg(pDestDb, SQLITE_ERROR, \"backup is not supported with incompatible source and target databases\");\n return NULL;\n }\n' \
31-
| sed '/nRes = sqlite3BtreeGetRequestedReserve(pMain)/a \\n \/\* A VACUUM cannot change the pagesize of an encrypted database. \*\/\n if( db->nextPagesize ){\n static void sqlite3mcCodecGetKey(sqlite3*, int, void**, int*);\n int nKey;\n char *zKey;\n sqlite3mcCodecGetKey(db, iDb, (void**)&zKey, &nKey);\n if( nKey ) db->nextPagesize = 0;\n }' \
31+
| sed '/nRes = sqlite3BtreeGetRequestedReserve(pMain)/a \\n \/\* A VACUUM cannot change the pagesize of an encrypted database. \*\/\n if( db->nextPagesize ){\n extern void sqlite3mcCodecGetKey(sqlite3*, int, void**, int*);\n int nKey;\n char *zKey;\n sqlite3mcCodecGetKey(db, iDb, (void**)&zKey, &nKey);\n if( nKey ) db->nextPagesize = 0;\n }' \

src/sqlite3patched.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11218,6 +11218,7 @@ typedef struct Pager PagerMC;
1121811218
SQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);
1121911219
SQLITE_PRIVATE void sqlite3mcInitMemoryMethods();
1122011220
SQLITE_PRIVATE int sqlite3mcIsBackupSupported(sqlite3*, const char*, sqlite3*, const char*);
11221+
SQLITE_PRIVATE void sqlite3mcCodecGetKey(sqlite3* db, int nDb, void** zKey, int* nKey);
1122111222

1122211223
/******** Begin file sqlite3rtree.h *********/
1122311224
/*
@@ -156218,7 +156219,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum(
156218156219

156219156220
/* A VACUUM cannot change the pagesize of an encrypted database. */
156220156221
if( db->nextPagesize ){
156221-
static void sqlite3mcCodecGetKey(sqlite3*, int, void**, int*);
156222+
extern void sqlite3mcCodecGetKey(sqlite3*, int, void**, int*);
156222156223
int nKey;
156223156224
char *zKey;
156224156225
sqlite3mcCodecGetKey(db, iDb, (void**)&zKey, &nKey);

0 commit comments

Comments
 (0)