From: Art Cancro Date: Tue, 25 Jul 2023 15:17:47 +0000 (-0900) Subject: ctdlload: usersbynumber X-Git-Tag: v987~5 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=0824b3306dc0bf3decc91244bdb5ba7d34ccfd80;p=citadel.git ctdlload: usersbynumber --- 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 }