ctdlload: import use table records
authorArt Cancro <ajc@citadel.org>
Tue, 18 Jul 2023 02:50:17 +0000 (17:50 -0900)
committerArt Cancro <ajc@citadel.org>
Tue, 18 Jul 2023 02:50:17 +0000 (17:50 -0900)
citadel/utils/ctdlload.c

index 409741a920a018209ca7a913e727c1f7e6012a2b..5cf735b5ed92f1effc5506ab6beed7b60d1a32fe 100644 (file)
@@ -436,6 +436,36 @@ int convert_visit(char *line, DBT *out_key, DBT *out_data) {
 }
 
 
+// Convert a "usetable" record to a record on disk.
+int convert_usetable(char *line, DBT *out_key, DBT *out_data) {
+       char *token;
+       struct UseTable *u = malloc(sizeof(struct UseTable));
+
+       memset(u, 0, sizeof(struct UseTable));
+       char *p = line;
+
+       for (int i=0; (token = strsep(&p, "|")); ++i) {
+               switch(i) {
+                       case 1:
+                               u->hash = atoi(token);
+                               break;
+                       case 2:
+                               u->timestamp = atol(token);
+                               break;
+               }
+       }
+
+       // the key is just an int (the hash)
+       out_key->size = sizeof(int);
+       out_key->data = reallok(NULL, out_key->size);
+       memcpy(out_key->data, &u->hash, out_key->size);
+
+       out_data->size = sizeof(struct UseTable);
+       out_data->data = u;
+       return(1);
+}
+
+
 #if 0
 // Convert a "foo" record to a record on disk.
 int convert_foo(char *line, DBT *out_key, DBT *out_data) {
@@ -545,7 +575,7 @@ void ingest_one(char *line, DB_ENV *dst_dbenv) {
        else if (!strcasecmp(record_type, "floor"))             row_was_good = convert_floor(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "msglist"))           row_was_good = convert_msglist(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "visit"))             row_was_good = convert_visit(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "use"))               row_was_good = convert_foo(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "use"))               row_was_good = convert_usetable(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "bigmsg"))            row_was_good = convert_foo(line, &out_key, &out_data);
        else if (!strcasecmp(record_type, "config"))            row_was_good = convert_foo(line, &out_key, &out_data);
        else                                                    row_was_good = 0;