aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-01-28 15:50:38 -0500
committerCara Salter <cara@devcara.com>2022-01-28 15:50:38 -0500
commit4585ec623286900898a09b1714b3b5de38be4fec (patch)
treecd08eef867164c3c998485063e2af1ec55c51c5a /src/util.c
parentaa80bc22117d385474c8593560368adf6b57f074 (diff)
downloadcmud-4585ec623286900898a09b1714b3b5de38be4fec.tar.gz
cmud-4585ec623286900898a09b1714b3b5de38be4fec.zip
login: Add password authentication for registrations
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..328a9cc
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,38 @@
+/*
+ * =====================================================================================
+ *
+ * Filename: util.c
+ *
+ * Description:
+ *
+ * Version: 1.0
+ * Created: 01/28/2022 03:47:07 PM
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: YOUR NAME (),
+ * Organization:
+ *
+ * =====================================================================================
+ */
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+
+char* trimwhitespace(char* str) {
+ char* end;
+
+ // Trim leading spaces
+ while(isspace((unsigned char) *str)) str++;
+
+ if (*str == 0) // All spaces?
+ return str;
+
+ // trailing spaces
+ end = str + strlen(str) -1;
+ while (end > str && isspace((unsigned char)* end)) end--;
+
+ end[1] = '\0';
+
+ return str;
+}