Export directory records
authorArt Cancro <ajc@citadel.org>
Tue, 11 Jul 2023 16:20:00 +0000 (07:20 -0900)
committerArt Cancro <ajc@citadel.org>
Tue, 11 Jul 2023 16:20:00 +0000 (07:20 -0900)
citadel/utils/ctdldump.c

index 96c989305ee2233007cf369c6e2bf48fadc69e45..a906a41d1339c0a7641aa2c7426bc8e0a40c8460 100644 (file)
@@ -279,29 +279,18 @@ void export_visit(int which_cdb, DBT *in_key, DBT *in_data) {
 }
 
 
-#if 0
 // export function for a directory record
-void export_dir(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
-
-       // the key is a string
-       out_key->size = in_key->size;
-       out_key->data = realloc(out_key->data, out_key->size + 1);
-       memcpy(out_key->data, in_key->data, in_key->size);
-       char *k = (char *)out_key->data;
-       k[out_key->size] = 0;
-
-       // the data is also a string
-       out_data->size = in_data->size;
-       out_data->data = realloc(out_data->data, out_data->size + 1);
-       memcpy(out_data->data, in_data->data, in_data->size);
-       char *d = (char *)out_data->data;
-       d[out_data->size] = 0;
-
-       // please excuse my friend, he isn't null terminated
-       // printf("\033[32m\033[1mDirectory entry: %s -> %s\033[0m\n", (char *)out_key->data, (char *)out_data->data);
+// (This is a secondary index -- should we just regenerate the data after import?)
+void export_dir(int which_cdb, DBT *in_key, DBT *in_data) {
+       printf("dir|");
+       fwrite(in_key->data, in_key->size, 1, stdout);
+       printf("|");
+       fwrite(in_data->data, in_data->size, 1, stdout);
+       printf("\n");
 }
 
 
+#if 0
 // export function for a use table record
 void export_usetable(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
 
@@ -454,7 +443,7 @@ void (*export_functions[])(int which_cdb, DBT *in_key, DBT *in_data) = {
        export_floor,           // CDB_FLOORTAB
        export_msglist,         // CDB_MSGLISTS
        export_visit,           // CDB_VISIT
-       zero_function,          // CDB_DIRECTORY
+       export_dir,             // CDB_DIRECTORY
        zero_function,          // CDB_USETABLE
        zero_function,          // CDB_BIGMSGS
        zero_function,          // CDB_FULLTEXT