int sqlite3_key(sqlite3 *db, const void *zKey, int nKey) { /* The key is only set for the main database, not the temp database */ return sqlite3_key_v2(db, "main", zKey, nKey); }
int sqlite3_key(sqlite3 *db, const void *pKey, int nKey) { CODEC_TRACE(("sqlite3_key entered: db=%p pKey=%s nKey=%d\n", db, (char *)pKey, nKey)); return sqlite3_key_v2(db, "main", pKey, nKey); }
int main(int argc, char **argv){ int rc; int i, j; int seeFlag = 0; char *zArchive = 0; char *zMountPoint = 0; char *azNewArg[5]; for(i=1; i<argc; i++){ if( argv[i][0]=='-' ){ for(j=1; argv[i][j]; j++){ switch( argv[i][j] ){ case 'e': seeFlag++; break; case '-': break; default: showHelp(argv[0]); } } }else if( zArchive==0 ){ zArchive = argv[i]; }else if( zMountPoint==0 ){ zMountPoint = argv[i]; }else{ showHelp(argv[0]); } } if( zMountPoint==0 ) showHelp(argv[0]); rc = sqlite3_open(zArchive, &g.db); if( rc!=SQLITE_OK ){ fprintf(stderr, "Cannot open sqlar file [%s]\n", argv[1]); exit(1); } if( seeFlag ){ char zPassPhrase[MX_PASSPHRASE+1]; #ifndef SQLITE_HAS_CODEC printf("WARNING: The passphrase is a no-op because this build of\n" "sqlar is compiled without encryption capabilities.\n"); #endif memset(zPassPhrase, 0, sizeof(zPassPhrase)); prompt_for_passphrase("passphrase: ", seeFlag>1, zPassPhrase); #ifdef SQLITE_HAS_CODEC sqlite3_key_v2(g.db, "main", zPassPhrase, -1); #endif } rc = sqlite3_exec(g.db, "SELECT 1 FROM sqlar LIMIT 1", 0, 0, 0); if( rc!=SQLITE_OK ){ fprintf(stderr, "File [%s] is not an SQLite archive\n", argv[1]); exit(1); } g.uid = getuid(); g.gid = getgid(); azNewArg[0] = argv[0]; azNewArg[1] = "-f"; azNewArg[2] = "-s"; azNewArg[3] = zMountPoint; azNewArg[4] = 0; rc = fuse_main(4, azNewArg, &sqlarfs_methods, NULL); sqlite3_finalize(g.pStat); sqlite3_finalize(g.pFList); sqlite3_finalize(g.pExists); sqlite3_finalize(g.pRead); sqlite3_free(g.zCacheName); sqlite3_free(g.zCacheData); sqlite3_close(g.db); return rc; }