aboutsummaryrefslogtreecommitdiff
path: root/c_implementation/src/ak_fs_maps_v3.c
diff options
context:
space:
mode:
Diffstat (limited to 'c_implementation/src/ak_fs_maps_v3.c')
-rw-r--r--c_implementation/src/ak_fs_maps_v3.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/c_implementation/src/ak_fs_maps_v3.c b/c_implementation/src/ak_fs_maps_v3.c
new file mode 100644
index 0000000..a5060b2
--- /dev/null
+++ b/c_implementation/src/ak_fs_maps_v3.c
@@ -0,0 +1,98 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include "libakfs.h"
+
+const char* ak_fs_maps_v3_get_dir()
+{
+ return getenv("AK_MAPSDIR");
+}
+
+void ak_fs_maps_v3_init(akfs_map_v3** ms, size_t l)
+{
+ akfs_map_v3 *m = NULL;
+ for (m = *ms; m < *ms+l; ++m)
+ {
+ ak_fs_map_v3_init(m);
+ }
+}
+
+void ak_fs_maps_v3_print_map_hashes(akfs_map_v3** m, size_t s)
+{
+ akfs_map_v3 *ptr = NULL;
+ for (ptr = *m; ptr < *m+s; ++ptr)
+ {
+ if ( !ak_fs_map_v3_is_null(ptr) ) ak_fs_map_v3_print_map_hash(ptr);
+ }
+}
+
+void ak_fs_maps_v3_print_filenames(akfs_map_v3** m, size_t s)
+{
+ akfs_map_v3 *ptr = NULL;
+ for (ptr = *m; ptr < *m+s; ++ptr)
+ {
+ if ( ptr != NULL )
+ {
+ ak_fs_map_v3_print_filename(ptr);
+ printf("\n");
+ }
+ }
+}
+
+void ak_fs_maps_v3_print(akfs_map_v3 **map_store, size_t length)
+{
+ akfs_map_v3 *ptr = NULL;
+ for ( ptr = *map_store; ptr < *map_store + length; ++ptr)
+ {
+ ak_fs_map_v3_print(ptr);
+ printf("\n");
+ }
+}
+
+void ak_fs_maps_v3_print_as_json(akfs_map_v3 **map_store, size_t length)
+{
+ akfs_map_v3 *ptr = NULL;
+ for ( ptr = *map_store; ptr < *map_store + length; ++ptr)
+ {
+ ak_fs_map_v3_print_as_json(ptr);
+ }
+}
+
+void ak_fs_maps_v3_print_bif(akfs_map_v3 **map_store, size_t length)
+{
+ akfs_map_v3 *ptr = NULL;
+ for ( ptr = *map_store; ptr < *map_store + length; ++ptr)
+ {
+ ak_fs_map_v3_print_bif(ptr);
+ printf("\n");
+ }
+}
+
+size_t ak_fs_maps_v3_found_in_fs()
+{
+ DIR *d;
+ size_t counter = 0;
+ d = opendir(ak_fs_maps_v3_get_dir());
+ if (d)
+ {
+ const struct dirent *dir;
+ while ((dir = readdir(d)) != NULL )
+ {
+ if (ak_fs_verify_input_is_hash(dir->d_name, strlen(dir->d_name))) counter++;
+ }
+ }
+ closedir(d);
+ return counter;
+}
+
+int ak_fs_maps_v3_resolve(akfs_map_v3 **ms, size_t ms_len)
+{
+ akfs_map_v3 *ptr = NULL;
+ for ( ptr = *ms; ptr < *ms+ms_len; ++ptr)
+ {
+ if ( ak_fs_sha512sum_is_null(&(ptr->mh)) ) continue;
+ ak_fs_map_v3_open_from_file(ptr);
+ }
+ return 0;
+}