aboutsummaryrefslogtreecommitdiff
path: root/src/userdb.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2016-01-02 18:40:29 -0500
committerFranklin Wei <git@fwei.tk>2016-01-02 18:40:29 -0500
commit2819d11ceeb1ac739ed5f17ccb0abab63f494299 (patch)
tree9041b1aa1212df0208f8f49b78101933ce7d4a3a /src/userdb.h
parent66cdb3d4f427a1978dad56a66c1bf1085939601c (diff)
downloadnetcosm-2819d11ceeb1ac739ed5f17ccb0abab63f494299.zip
netcosm-2819d11ceeb1ac739ed5f17ccb0abab63f494299.tar.gz
netcosm-2819d11ceeb1ac739ed5f17ccb0abab63f494299.tar.bz2
netcosm-2819d11ceeb1ac739ed5f17ccb0abab63f494299.tar.xz
preliminary refactor of user data management
Diffstat (limited to 'src/userdb.h')
-rw-r--r--src/userdb.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/userdb.h b/src/userdb.h
new file mode 100644
index 0000000..89e2566
--- /dev/null
+++ b/src/userdb.h
@@ -0,0 +1,43 @@
+#include "netcosm.h"
+
+/*
+ * on-disk database for storing user data
+ *
+ * child processes MUST go through the master to use this
+ */
+
+struct userdata_t {
+ char *username;
+
+ char salt[SALT_LEN + 1];
+
+ /* in hex + NULL terminator */
+ char passhash[AUTH_HASHLEN * 2 + 1];
+
+ int priv;
+};
+
+/* call before using anything else */
+void userdb_init(const char *dbfile);
+
+/* looks up a username in the DB, returns NULL upon failure */
+struct userdata_t *userdb_lookup(const char *username);
+
+void userdb_remove(const char *username);
+
+/* is it empty? */
+size_t userdb_size(void);
+
+/*
+ * adds an entry to the DB
+ * if it already exists, OVERWRITE
+ * returns a pointer to the added entry, NULL on failure
+ *
+ * a DUPLICATE of the entry will be inserted
+ */
+struct userdata_t *userdb_add(struct userdata_t*);
+
+void userdb_shutdown(void);
+
+/* save the DB to disk */
+void userdb_write(const char*);