blob: a941e9a30216ee4b185132df66dd7642ca4a22f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#include "netcosm.h"
#include "auth.h"
struct userdata_t {
char username[MAX_NAME_LEN + 1];
char salt[SALT_LEN + 1];
/* in hex + NULL terminator */
char passhash[AUTH_HASHLEN * 2 + 1];
int priv;
room_id room;
};
/*** functions for the master process ONLY ***/
/* 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);
bool 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*);
/*** child-only functions ***/
struct userdata_t *userdb_request_lookup(const char *name);
bool userdb_request_add(struct userdata_t *data);
bool userdb_request_remove(const char *name);
|