From 78b46f4c274d24f2b48b2f1f9ca2a8a77cc40a9a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 24 Jul 2023 10:15:58 -0900 Subject: [PATCH] import fulltext index records --- citadel/utils/ctdlload.c | 41 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/citadel/utils/ctdlload.c b/citadel/utils/ctdlload.c index fd06f0838..38083b880 100644 --- a/citadel/utils/ctdlload.c +++ b/citadel/utils/ctdlload.c @@ -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 -- 2.39.2