From a964ba835deacc1e4dc73911a6864bb43dbba96c Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 13 Jul 2023 18:23:55 -0900 Subject: [PATCH] Moved makeuserkey() into its own file because we need it in ctdlload --- citadel/server/makeuserkey.c | 39 ++++++++++++++++++++++++++++++++++++ citadel/server/user_ops.c | 22 -------------------- 2 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 citadel/server/makeuserkey.c diff --git a/citadel/server/makeuserkey.c b/citadel/server/makeuserkey.c new file mode 100644 index 000000000..5729034a5 --- /dev/null +++ b/citadel/server/makeuserkey.c @@ -0,0 +1,39 @@ +// makeuserkey() - convert a username into the format used as a database key +// +// Copyright (c) 1987-2023 by the citadel.org team +// +// This program is open source software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License, version 3. + +#include +#include +#include "sysdep.h" +#include +#include +#include +#include "config.h" +#include "user_ops.h" + + +// makeuserkey() - convert a username into the format used as a database key +// "key" must be a buffer of at least USERNAME_SIZE +// (Key format is the username with all non-alphanumeric characters removed, and converted to lower case.) +void makeuserkey(char *key, const char *username) { + int i; + int keylen = 0; + + if (IsEmptyStr(username)) { + key[0] = 0; + return; + } + + int len = strlen(username); + for (i=0; ((i<=len) && (i