stub functions for new import routines
authorArt Cancro <ajc@citadel.org>
Mon, 24 Jul 2023 17:56:43 +0000 (08:56 -0900)
committerArt Cancro <ajc@citadel.org>
Mon, 24 Jul 2023 17:56:43 +0000 (08:56 -0900)
citadel/utils/ctdlload.c

index b1990ce6655bd7619ab344ecc9935e6d614b8a1d..fd06f0838eb1cfe812dd4b5a73c918265d4ef70a 100644 (file)
@@ -113,7 +113,7 @@ void close_dbenv(DB_ENV *dbenv) {
 
 // Convert a "msgtext" record to a message on disk.   NOT THREADSAFE
 // This also works for "bigmsg" records.
-int convert_msgtext(char *line, DBT *out_key, DBT *out_data) {
+int import_msgtext(char *line, DBT *out_key, DBT *out_data) {
 
        static char *b64_decoded_msg = NULL;
        static size_t b64_decoded_alloc = 0;
@@ -138,7 +138,7 @@ int convert_msgtext(char *line, DBT *out_key, DBT *out_data) {
 
 
 // Convert a "msgmeta" record to a message metadata record on disk.  NOT THREADSAFE
-int convert_msgmeta(char *line, DBT *out_key, DBT *out_data) {
+int import_msgmeta(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        struct MetaData *m = malloc(sizeof(struct MetaData));
 
@@ -178,7 +178,7 @@ int convert_msgmeta(char *line, DBT *out_key, DBT *out_data) {
 
 
 // Convert a "user" record to a record on disk.  (Source string is unusable after this function is called.)
-int convert_user(char *line, DBT *out_key, DBT *out_data) {
+int import_user(char *line, DBT *out_key, DBT *out_data) {
        char userkey[USERNAME_SIZE];
        char *token;
        struct ctdluser *u = malloc(sizeof(struct ctdluser));
@@ -243,7 +243,7 @@ int convert_user(char *line, DBT *out_key, DBT *out_data) {
 
 
 // Convert a "room" record to a record on disk.  (Source string is unusable after this function is called.)
-int convert_room(char *line, DBT *out_key, DBT *out_data) {
+int import_room(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        struct ctdlroom *r = malloc(sizeof(struct ctdlroom));
 
@@ -321,7 +321,7 @@ int convert_room(char *line, DBT *out_key, DBT *out_data) {
 
 
 // Convert a floor record to a record on disk.
-int convert_floor(char *line, DBT *out_key, DBT *out_data) {
+int import_floor(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        struct floor *f = malloc(sizeof(struct floor));
        int floor_num;
@@ -364,7 +364,7 @@ int convert_floor(char *line, DBT *out_key, DBT *out_data) {
 
 // Import a msglist record
 // msglist|26|32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51|
-int convert_msglist(char *line, DBT *out_key, DBT *out_data) {
+int import_msglist(char *line, DBT *out_key, DBT *out_data) {
        long roomnum;
        char *token, *mtoken;
        char *p = line;
@@ -399,7 +399,7 @@ int convert_msglist(char *line, DBT *out_key, DBT *out_data) {
 
 
 // Convert a "visit" record to a record on disk.
-int convert_visit(char *line, DBT *out_key, DBT *out_data) {
+int import_visit(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        struct visit *v = malloc(sizeof(struct visit));
 
@@ -446,8 +446,14 @@ int convert_visit(char *line, DBT *out_key, DBT *out_data) {
 }
 
 
+// Convert a "dir" record to a record on disk.
+int import_dir(char *line, DBT *out_key, DBT *out_data) {
+       return(0);
+}
+
+
 // Convert a "usetable" record to a record on disk.
-int convert_usetable(char *line, DBT *out_key, DBT *out_data) {
+int import_usetable(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        struct UseTable *u = malloc(sizeof(struct UseTable));
 
@@ -476,10 +482,23 @@ int convert_usetable(char *line, DBT *out_key, DBT *out_data) {
 }
 
 
+int import_fulltext(char *line, DBT *out_key, DBT *out_data) {
+       return(0);
+}
+int import_euidindex(char *line, DBT *out_key, DBT *out_data) {
+       return(0);
+}
+int import_usersbynumber(char *line, DBT *out_key, DBT *out_data) {
+       return(0);
+}
+
+
+
+
 // Import a config record
 // The key is the config key
 // The data is the config key, a null, the value, and another null
-int convert_config(char *line, DBT *out_key, DBT *out_data) {
+int import_config(char *line, DBT *out_key, DBT *out_data) {
        char *token;
        char *p = line;
        char *k, *v;
@@ -584,16 +603,20 @@ void ingest_one(char *line, DB_ENV *dst_dbenv) {
        memset(&out_key, 0, sizeof(DBT));
        memset(&out_data, 0, sizeof(DBT));
        row_was_good = 0;
-       if      (!strcasecmp(record_type, "msgtext"))           row_was_good = convert_msgtext(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "msgmeta"))           row_was_good = convert_msgmeta(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "user"))              row_was_good = convert_user(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "room"))              row_was_good = convert_room(line, &out_key, &out_data);
-       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_usetable(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "bigmsg"))            row_was_good = convert_msgtext(line, &out_key, &out_data);
-       else if (!strcasecmp(record_type, "config"))            row_was_good = convert_config(line, &out_key, &out_data);
+       if      (!strcasecmp(record_type, "msgtext"))           row_was_good = import_msgtext(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "msgmeta"))           row_was_good = import_msgmeta(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "user"))              row_was_good = import_user(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "room"))              row_was_good = import_room(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "floor"))             row_was_good = import_floor(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "msglist"))           row_was_good = import_msglist(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "visit"))             row_was_good = import_visit(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "dir"))               row_was_good = import_dir(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "use"))               row_was_good = import_usetable(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "bigmsg"))            row_was_good = import_msgtext(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "fulltext"))          row_was_good = import_fulltext(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "euidindex"))         row_was_good = import_euidindex(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "usersbynumber"))     row_was_good = import_usersbynumber(line, &out_key, &out_data);
+       else if (!strcasecmp(record_type, "config"))            row_was_good = import_config(line, &out_key, &out_data);
        else                                                    row_was_good = 0;
 
        if (row_was_good) {
@@ -651,7 +674,7 @@ void ingest(DB_ENV *dst_dbenv) {
 int main(int argc, char **argv) {
        char *dst_dir = NULL;
        int confirmed = 0;
-       static DB_ENV *dst_dbenv;               // Source DB environment (global)
+       static DB_ENV *dst_dbenv;               // Target DB environment
 
        // display the greeting
        fprintf(stderr, "\033[44m\033[33m\033[1m \033[K\033[0m\n"
@@ -685,7 +708,8 @@ int main(int argc, char **argv) {
                exit(0);
        }
 
-       char cmd[1024];
+       // Remove any database that is already in the target directory (yes, delete it, be careful)
+       char cmd[PATH_MAX];
        snprintf(cmd, sizeof cmd, "rm -fv %s/cdb.* %s/log.*", dst_dir, dst_dir);
        system(cmd);