Moved makeuserkey() into its own file because we need it in ctdlload
authorArt Cancro <ajc@citadel.org>
Fri, 14 Jul 2023 03:23:55 +0000 (18:23 -0900)
committerArt Cancro <ajc@citadel.org>
Fri, 14 Jul 2023 03:23:55 +0000 (18:23 -0900)
citadel/server/makeuserkey.c [new file with mode: 0644]
citadel/server/user_ops.c

diff --git a/citadel/server/makeuserkey.c b/citadel/server/makeuserkey.c
new file mode 100644 (file)
index 0000000..5729034
--- /dev/null
@@ -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 <stdlib.h>
+#include <unistd.h>
+#include "sysdep.h"
+#include <stdio.h>
+#include <sys/stat.h>
+#include <libcitadel.h>
+#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<USERNAME_SIZE-1)); ++i) {
+               if (isalnum((username[i]))) {
+                       key[keylen++] = tolower(username[i]);
+               }
+       }
+       key[keylen++] = 0;
+}
+
+
index 62e62f49297b19ccfeb97821aca5ad0ec58d5c9e..fc87a03d96d6ba9198de7dff8210de45b7405727 100644 (file)
@@ -25,28 +25,6 @@ int chkpwd_write_pipe[2];
 int chkpwd_read_pipe[2];
 
 
-// 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<USERNAME_SIZE-1)); ++i) {
-               if (isalnum((username[i]))) {
-                       key[keylen++] = tolower(username[i]);
-               }
-       }
-       key[keylen++] = 0;
-}
-
-
 // Compare two usernames to see if they are the same user after being keyed for the database
 // Usage is identical to strcmp()
 int CtdlUserCmp(char *s1, char *s2) {