import fulltext index records
authorArt Cancro <ajc@citadel.org>
Mon, 24 Jul 2023 19:15:58 +0000 (10:15 -0900)
committerArt Cancro <ajc@citadel.org>
Mon, 24 Jul 2023 19:15:58 +0000 (10:15 -0900)
citadel/utils/ctdlload.c

index fd06f0838eb1cfe812dd4b5a73c918265d4ef70a..38083b880622d57b5512298fdb70e61c301bcd6c 100644 (file)
@@ -482,19 +482,54 @@ int import_usetable(char *line, DBT *out_key, DBT *out_data) {
 }
 
 
+// Import a full text search index record.
+// It's just like a msglists record: a key and a list of message numbers, but the key is "int" instead of "long"
 int import_fulltext(char *line, DBT *out_key, DBT *out_data) {
-       return(0);
+       int indexnum;
+       char *token, *mtoken;
+       char *p = line;
+       char *q = NULL;
+       int num_msgs = 0;
+       long *msglist = NULL;
+
+       for (int i=0; (token = strsep(&p, "|")); ++i) {
+               switch(i) {
+                       case 1:
+                               indexnum = atoi(token);
+                               break;
+                       case 2:
+                               q = token;
+                               for (int j=0; (mtoken = strsep(&q, ",")); ++j) {
+                                       msglist = realloc(msglist, (num_msgs+1) * sizeof(long));
+                                       msglist[num_msgs++] = atol(mtoken);
+                               }
+                               break;
+               }
+       }
+
+       out_key->size = sizeof(int);
+       out_key->data = malloc(out_key->size);
+       memcpy(out_key->data, &indexnum, out_key->size);
+
+       out_data->size = num_msgs * sizeof(long);
+       out_data->data = msglist;
+
+       return(1);
 }
+
+
+// Import an EUID Index record
 int import_euidindex(char *line, DBT *out_key, DBT *out_data) {
        return(0);
 }
+
+
+// Import a "users by number" (secondary index) record
 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