コード例 #1
0
ファイル: c_perf_key.c プロジェクト: abeluck/libsqlfs
int main(int argc, char *argv[])
{
    char *database_filename = "c_perf_key.db";
    int rc;
    sqlfs_t *sqlfs = 0;

    if(argc > 1)
      database_filename = argv[1];
    if(exists(database_filename))
       printf("%s exists.\n", database_filename);
    printf("Opening %s\n", database_filename);
    sqlfs_init(database_filename);
    printf("Running tests:\n");

    rc = sqlfs_open_key(database_filename, "mysupersafepassword", &sqlfs);
    printf("Opening database...");
    assert(rc);
    printf("passed\n");

    run_perf_tests(sqlfs, WRITESZ);

    printf("Closing database...");
    sqlfs_close(sqlfs);
    printf("done\n");
    return 0;
}
コード例 #2
0
ファイル: c_perf.c プロジェクト: abeluck/libsqlfs
int main(int argc, char *argv[])
{
    char *database_filename = "c_perf.db";
    int rc;
    sqlfs_t *sqlfs = 0;

    if(argc > 1)
      database_filename = argv[1];
    if(exists(database_filename))
       printf("%s exists.\n", database_filename);
    printf("Opening %s\n", database_filename);
    sqlfs_init(database_filename);
    printf("Running tests:\n");

    rc = sqlfs_open(database_filename, &sqlfs);
    printf("Opening database...");
    assert(rc);
    printf("passed\n");

    run_perf_tests(sqlfs, WRITESZ);

    printf("Closing database...");
    sqlfs_close(sqlfs);
    printf("done\n");

    printf("\n------------------------------------------------------------------------\n");
    printf("Running tests using the thread API, i.e. sqlfs == 0:\n");
    run_perf_tests(0, WRITESZ);

    return 0;
}
static void VirtualFileSystem_mount(JNIEnv *env, jobject, jstring javaKey) {
    char buf[256];
    snprintf(buf, 255, "Could not mount filesystem in %s, bad key given?", databaseFileName);

    sqlfs_t *sqlfs = 0;
    char const * key = env->GetStringUTFChars(javaKey, 0);
    jsize keyLen = env->GetStringUTFLength(javaKey);

    /* 
     * attempt to open the database with the key
     * if it fails, then the key is likely wrong
     */
    if(!sqlfs_open_key(databaseFileName, key, &sqlfs)) {
        LOGI("sqlfs_open_key FAILED");
        jniThrowException(env, "java/lang/IllegalArgumentException", buf);
    }
    sqlfs_close(sqlfs);

    /*
     * init the vfs by storing the key in memory
     * sqlfs_init_key returns 0 for success in the unix fashion
     */
    if(sqlfs_init_key(databaseFileName, key) != 0) {
        LOGI("sqlfs_init_key FAILED");
        jniThrowException(env, "java/lang/IllegalArgumentException", "Initializing VFS failed.");
    }
    env->ReleaseStringUTFChars(javaKey, key);
}
コード例 #4
0
ファイル: c_perf_key.c プロジェクト: ChatSecure/libsqlfs
int main(int argc, char *argv[])
{
    char *database_filename = "c_perf_key.db";
    int rc;
    sqlfs_t *sqlfs = 0;

    if(argc > 1)
      database_filename = argv[1];
    if(exists(database_filename))
       printf("%s exists.\n", database_filename);

    printf("Opening %s...", database_filename);
    rc = sqlfs_open_password(database_filename, "mysupersafepassword", &sqlfs);
    assert(rc);
    printf("passed\n");

    run_perf_tests(sqlfs, WRITESZ);

    printf("Closing database...");
    rc = sqlfs_close(sqlfs);
    assert(rc);
    printf("done\n");


    printf("\n------------------------------------------------------------------------\n");
    printf("Running tests using the thread API, i.e. sqlfs == 0:\n");

    printf("Initing %s\n", database_filename);
    rc = sqlfs_init_password(database_filename, "mysupersafepassword");
    assert(rc == 0);

    run_perf_tests(0, WRITESZ);

    printf("Destroying:\n");
    rc = sqlfs_destroy();
    assert(rc == 0);

    rc++; // silence ccpcheck

    return 0;
}