From 41c833077744054a1f5ccbf779c4819508f1ff41 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 25 Jul 2023 06:28:32 -0900 Subject: [PATCH] ctdlload: euidindex --- citadel/utils/ctdlload.c | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/citadel/utils/ctdlload.c b/citadel/utils/ctdlload.c index 80aa53eeb..89b1ce5a6 100644 --- a/citadel/utils/ctdlload.c +++ b/citadel/utils/ctdlload.c @@ -520,9 +520,46 @@ int import_fulltext(char *line, DBT *out_key, DBT *out_data) { // Import an EUID Index record +// euidindex|msgnum|roomnum|euid| int import_euidindex(char *line, DBT *out_key, DBT *out_data) { - // FIXME - return(0); + char euid[SIZ]; + long msgnum; + long roomnum; + char *token; + + char *p = line; + for (int i=0; (token = strsep(&p, "|")); ++i) { + switch(i) { + case 1: + msgnum = atol(token); + break; + case 2: + roomnum = atol(token); + break; + case 3: + strncpy(euid, token, sizeof(euid)); + break; + } + } + + // The structure of an euidindex record *key* is: + // |----room_number----|----------EUID-------------| + // (sizeof long) (actual length of euid) + out_key->size = sizeof(long) + strlen(euid) + 1; + out_key->data = reallok(NULL, out_key->size); + memcpy(out_key->data, &roomnum, sizeof(long)); + strcpy(out_key->data + sizeof(long), euid); + + // The structure of an euidindex record *value* is: + // |-----msg_number----|----room_number----|----------EUID-------------| + // (sizeof long) (sizeof long) (actual length of euid) + out_data->size = sizeof(long) + sizeof(long) + strlen(euid) + 1; + out_data->data = reallok(NULL, out_data->size); + memcpy(out_data->data, &msgnum, sizeof(long)); + memcpy(out_data->data + sizeof(long), &roomnum, sizeof(long)); + strcpy(out_data->data + sizeof(long) + sizeof(long), euid); + + return(1); } -- 2.39.2