diff options
Diffstat (limited to 'c_implementation/src/ak_fs_mt.c')
-rw-r--r-- | c_implementation/src/ak_fs_mt.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/c_implementation/src/ak_fs_mt.c b/c_implementation/src/ak_fs_mt.c index e194980..3f638e6 100644 --- a/c_implementation/src/ak_fs_mt.c +++ b/c_implementation/src/ak_fs_mt.c @@ -35,48 +35,3 @@ void ak_fs_mt_branch_print(mt_branch *n) printf("h: %s\n", ak_fs_sha512sum_struct_read_as_string(&n->head)); printf("t: %s\n", ak_fs_sha512sum_struct_read_as_string(&n->tail)); } - -int ak_fs_mt_branch_resolve(mt_branch *node) -{ - const char* leafs_dir = getenv("AK_LEAFSDIR"); - FILE *fd; - char *fullpath; - if ( asprintf(&fullpath, "%s/%s", leafs_dir, ak_fs_sha512sum_struct_read_as_string(&node->head)) == -1 ) return -1; - fd = fopen(fullpath, "r"); - if ( fd == NULL ) - { - perror("fopen"); - return 1; - } - char buffer[258]; - fread(&buffer, sizeof(buffer), 1, fd); - fclose(fd); - free(fullpath); - char h1[129] = {0}; - char h2[129] = {0}; - if ( buffer[128] != '\n' && buffer[257] != '\n' ) - { - ak_log_error(__func__, "Unknown format"); - return 2; - } - mt_branch h0; - ak_fs_sha512sum_init(&h0.root); - ak_fs_sha512sum_init(&h0.head); - ak_fs_sha512sum_init(&h0.tail); - h0.root = node->root; - for( size_t i = 0; i < 128; ++i ) - { - h1[i] = buffer[i]; - } - h1[128] = '\0'; - for( size_t i = 0; i < 128; ++i ) - { - h2[i] = buffer[i+129]; - } - h2[128] = '\0'; - ak_fs_sha512sum_string_to_struct(h1, &h0.head); - ak_fs_sha512sum_string_to_struct(h2, &h0.tail); - ak_fs_mt_branch_print(&h0); - ak_fs_mt_branch_resolve(&h0); - return 0; -} |