diff --git a/src/main.c b/src/main.c index 9176ac7b..c3812895 100644 --- a/src/main.c +++ b/src/main.c @@ -268,6 +268,59 @@ static int _tf_command_export(const char* file, int argc, char* argv[]) tf_ssb_destroy(ssb); return EXIT_SUCCESS; } + +static int _tf_command_verify(const char* file, int argc, char* argv[]) +{ + const char* identity = NULL; + const char* db_path = k_db_path_default; + bool show_usage = false; + + while (!show_usage) + { + static const struct option k_options[] = { + { "id", required_argument, NULL, 'u' }, + { "db-path", required_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, + { 0 }, + }; + int c = getopt_long(argc, argv, "i:d:h", k_options, NULL); + if (c == -1) + { + break; + } + + switch (c) + { + case '?': + case 'h': + default: + show_usage = true; + break; + case 'i': + identity = optarg; + break; + case 'd': + db_path = optarg; + break; + } + } + + if (show_usage) + { + tf_printf("\n%s import [options] [paths...]\n\n", file); + tf_printf("options:\n"); + tf_printf(" -i, --identity identity Identity to verify.\n"); + tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", k_db_path_default); + tf_printf(" -h, --help Show this usage information.\n"); + return EXIT_FAILURE; + } + + tf_printf("Verifying %s...\n", identity); + tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL); + bool verified = tf_ssb_db_verify(ssb, identity); + tf_ssb_destroy(ssb); + return verified ? EXIT_SUCCESS : EXIT_FAILURE; +} #endif typedef struct tf_run_args_t @@ -591,59 +644,6 @@ static int _tf_command_sandbox(const char* file, int argc, char* argv[]) return EXIT_SUCCESS; } -static int _tf_command_verify(const char* file, int argc, char* argv[]) -{ - const char* identity = NULL; - const char* db_path = k_db_path_default; - bool show_usage = false; - - while (!show_usage) - { - static const struct option k_options[] = { - { "id", required_argument, NULL, 'u' }, - { "db-path", required_argument, NULL, 'd' }, - { "help", no_argument, NULL, 'h' }, - { 0 }, - }; - int c = getopt_long(argc, argv, "i:d:h", k_options, NULL); - if (c == -1) - { - break; - } - - switch (c) - { - case '?': - case 'h': - default: - show_usage = true; - break; - case 'i': - identity = optarg; - break; - case 'd': - db_path = optarg; - break; - } - } - - if (show_usage) - { - tf_printf("\n%s import [options] [paths...]\n\n", file); - tf_printf("options:\n"); - tf_printf(" -i, --identity identity Identity to verify.\n"); - tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", k_db_path_default); - tf_printf(" -h, --help Show this usage information.\n"); - return EXIT_FAILURE; - } - - tf_printf("Verifying %s...\n", identity); - tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL); - bool verified = tf_ssb_db_verify(ssb, identity); - tf_ssb_destroy(ssb); - return verified ? EXIT_SUCCESS : EXIT_FAILURE; -} - #if !defined(__ANDROID__) static int _tf_command_usage(const char* file) {