@@ -54,6 +54,10 @@ sqlite3mc_config(sqlite3* db, const char* paramName, int newValue)
5454 int hasMaxPrefix = 0 ;
5555 CipherParams * param ;
5656
57+ #ifndef SQLITE_OMIT_AUTOINIT
58+ if (sqlite3_initialize ()) return value ;
59+ #endif
60+
5761 if (paramName == NULL || (db == NULL && newValue >= 0 ))
5862 {
5963 return value ;
@@ -134,14 +138,22 @@ sqlite3mc_config(sqlite3* db, const char* paramName, int newValue)
134138SQLITE_API int
135139sqlite3mc_cipher_count ()
136140{
141+ #ifndef SQLITE_OMIT_AUTOINIT
142+ if (sqlite3_initialize ()) return 0 ;
143+ #endif
137144 return sqlite3mcGetGlobalCipherCount ();
138145}
139146
140147SQLITE_API int
141148sqlite3mc_cipher_index (const char * cipherName )
142149{
143- int count = sqlite3mcGetGlobalCipherCount ();
144- int j = 0 ;
150+ int count ;
151+ int j ;
152+ #ifndef SQLITE_OMIT_AUTOINIT
153+ if (sqlite3_initialize ()) return -1 ;
154+ #endif
155+ count = sqlite3mcGetGlobalCipherCount ();
156+ j = 0 ;
145157 for (j = 0 ; j < count && globalCodecDescriptorTable [j ].m_name [0 ] != 0 ; ++ j )
146158 {
147159 if (sqlite3_stricmp (cipherName , globalCodecDescriptorTable [j ].m_name ) == 0 ) break ;
@@ -153,8 +165,13 @@ SQLITE_API const char*
153165sqlite3mc_cipher_name (int cipherIndex )
154166{
155167 static char cipherName [CIPHER_NAME_MAXLEN ] = "" ;
156- int count = sqlite3mcGetGlobalCipherCount ();
157- int j = 0 ;
168+ int count ;
169+ int j ;
170+ #ifndef SQLITE_OMIT_AUTOINIT
171+ if ( sqlite3_initialize () ) return cipherName ;
172+ #endif
173+ count = sqlite3mcGetGlobalCipherCount ();
174+ j = 0 ;
158175 cipherName [0 ] = '\0' ;
159176 if (cipherIndex > 0 && cipherIndex <= count )
160177 {
@@ -179,6 +196,10 @@ sqlite3mc_config_cipher(sqlite3* db, const char* cipherName, const char* paramNa
179196 CipherParams * cipherParamTable = NULL ;
180197 int j = 0 ;
181198
199+ #ifndef SQLITE_OMIT_AUTOINIT
200+ if (sqlite3_initialize ()) return value ;
201+ #endif
202+
182203 if (cipherName == NULL || paramName == NULL )
183204 {
184205 sqlite3_log (SQLITE_WARNING ,
@@ -246,7 +267,7 @@ sqlite3mc_config_cipher(sqlite3* db, const char* cipherName, const char* paramNa
246267 {
247268 sqlite3mcConfigureSQLCipherVersion (db , hasDefaultPrefix , newValue );
248269 }
249- else
270+ else if ( newValue != -1 )
250271 {
251272 sqlite3_log (SQLITE_WARNING ,
252273 "sqlite3mc_config_cipher: SQLCipher legacy version %d out of range [%d..%d]" ,
@@ -282,7 +303,7 @@ sqlite3mc_config_cipher(sqlite3* db, const char* cipherName, const char* paramNa
282303 param -> m_value = newValue ;
283304 value = newValue ;
284305 }
285- else
306+ else if ( newValue != -1 )
286307 {
287308 sqlite3_log (SQLITE_WARNING ,
288309 "sqlite3mc_config_cipher: Value %d for parameter '%s' of cipher '%s' out of range [%d..%d]" ,
@@ -306,6 +327,9 @@ SQLITE_API unsigned char*
306327sqlite3mc_codec_data (sqlite3 * db , const char * zDbName , const char * paramName )
307328{
308329 unsigned char * result = NULL ;
330+ #ifndef SQLITE_OMIT_AUTOINIT
331+ if (sqlite3_initialize ()) return NULL ;
332+ #endif
309333 if (db != NULL && paramName != NULL )
310334 {
311335 int iDb = (zDbName != NULL ) ? sqlite3FindDbName (db , zDbName ) : 0 ;
0 commit comments