diff options
-rw-r--r-- | c_implementation/src/akfs.c | 38 | ||||
-rw-r--r-- | c_implementation/src/akfs_main.c | 43 | ||||
-rw-r--r-- | c_implementation/src/akfs_map_v3.c | 7 |
3 files changed, 50 insertions, 38 deletions
diff --git a/c_implementation/src/akfs.c b/c_implementation/src/akfs.c index f9abc34..0e362aa 100644 --- a/c_implementation/src/akfs.c +++ b/c_implementation/src/akfs.c @@ -305,13 +305,6 @@ bool ak_fs_map_v3_compare(akfs_map_v3* a, akfs_map_v3* b) ); } -bool ak_fs_map_v3_is_null(akfs_map_v3* m) -{ - akfs_map_v3 n; - ak_fs_map_v3_init(&n); - return ak_fs_map_v3_compare(m, &n); -} - void ak_fs_print_available_maps(sha512sum **ma, size_t ma_len) { sha512sum *ptr = NULL; @@ -393,34 +386,3 @@ int ak_fs_ls() ak_fs_print_filenames_from_map_store(&mps_ptr, ms_len); return 0; } - -int ak_fs_usage() -{ - ak_log_debug(__func__, "Available commands:"); - ak_log_debug(__func__, "ak fs --list"); - return 1; -} - -int ak_fs_main(int c, char** v) -{ - (void)c; - (void)v; - int option; - while ( (option = getopt(c, v, ":h|:help")) != -1 ) - { - printf("%d\n", option); - switch(option) - { - case 'h': - return ak_fs_usage(); - case ':': - printf("kek\n"); - return 1; - case '?': - printf("lol\n"); - return 2; - } - } - return 0; -} - diff --git a/c_implementation/src/akfs_main.c b/c_implementation/src/akfs_main.c new file mode 100644 index 0000000..f1660cf --- /dev/null +++ b/c_implementation/src/akfs_main.c @@ -0,0 +1,43 @@ +#include <getopt.h> +#include <stdio.h> +#include <libaklog.h> +#include <libakfs.h> + +static int ak_fs_usage() +{ + ak_log_debug(__func__, "Available commands:"); + ak_log_debug(__func__, "ak fs --list"); + return 1; +} + +int ak_fs_main(int argc, char** argv) +{ + int option; + int logind = 0; + static struct option long_options[] = { + {"help", no_argument, 0, 'h'}, + {"list", no_argument, 0, 'l'}, + {0,0,0,0} + }; + while(1) + { + option = getopt_long(argc, argv, "hl", long_options, &logind); + if ( option == -1 ) return ak_fs_usage(); + switch(option) + { + case 'h': + return ak_fs_usage(); + case 'l': + return ak_fs_ls(); + default: + printf("double lol\n"); + return 4; + } + } + return 0; +} + +int main(int argc, char **argv) +{ + return ak_fs_main(argc, argv); +} diff --git a/c_implementation/src/akfs_map_v3.c b/c_implementation/src/akfs_map_v3.c index 0eb1ea1..a422b6c 100644 --- a/c_implementation/src/akfs_map_v3.c +++ b/c_implementation/src/akfs_map_v3.c @@ -23,6 +23,13 @@ void ak_fs_map_v3_init_store(akfs_map_v3** ms, size_t l) } } +bool ak_fs_map_v3_is_null(akfs_map_v3* m) +{ + akfs_map_v3 n; + ak_fs_map_v3_init(&n); + return ak_fs_map_v3_compare(m, &n); +} + void ak_fs_map_v3_print_original_hash(akfs_map_v3 *map) { if (!ak_fs_map_v3_is_null(map)) |