From 0824b3306dc0bf3decc91244bdb5ba7d34ccfd80 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 25 Jul 2023 06:17:47 -0900 Subject: [PATCH] ctdlload: usersbynumber --- citadel/utils/ctdlload.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/citadel/utils/ctdlload.c b/citadel/utils/ctdlload.c index 1dec33878..80aa53eeb 100644 --- a/citadel/utils/ctdlload.c +++ b/citadel/utils/ctdlload.c @@ -529,8 +529,26 @@ int import_euidindex(char *line, DBT *out_key, DBT *out_data) { // Import a "users by number" (secondary index) record // The key is a "long" int import_usersbynumber(char *line, DBT *out_key, DBT *out_data) { - // FIXME - return(0); + char *token; + long usernum; + + char *p = line; + for (int i=0; (token = strsep(&p, "|")); ++i) { + switch(i) { + case 1: + usernum = atol(token); + break; + case 2: + out_key->size = sizeof(long); + out_key->data = reallok(NULL, sizeof(long)); + memcpy(out_key->data, &usernum, out_key->size); + out_data->data = strdup(token); + out_data->size = strlen(out_data->data) + 1; + return(1); + } + } + + return(0); // should never get here unless it's a bad record } -- 2.39.2