blob: a2fcf6ea700df2d503826b2f1dabe6467ee0ea92 (
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
49
50
51
52
53
54
55
56
57
|
#pragma once
#include "global.h"
struct db_name_id{
char *name;
i64 id;
};
struct db_room_list{
i64 count;
struct db_name_id *list;
};
struct db_message{
i64 roomid,userid,timestamp;
char *message;
};
struct db_message_list{
i64 count;
struct db_message *list;
};
struct db_user_list{
i64 count;
struct db_name_id *list;
};
void db_init(void);
void db_close(void);
struct db_name_id db_create_room(void);
bool db_delete_room(i64 roomid);
bool db_add_member(i64 roomid,i64 userid);
bool db_remove_member(i64 roomid,i64 userid);
bool db_is_member(i64 roomid,i64 userid);
struct db_user_list db_list_members(i64 roomid);
i64 db_find_room(const char *name); // -1 if not found
struct db_room_list db_list_rooms(i64 userid);
i64 db_create_user(const char *name,const char *pass);
bool db_set_username(i64 userid,const char *name);
bool db_set_pass(i64 userid,const char *pass);
char* db_get_username(i64 userid);
char* db_get_pass(i64 userid);
bool db_delete_user(i64 userid);
i64 db_find_user(const char *name); // -1 if not found
void db_create_message(i64 roomid,i64 userid,i64 timestamp,const char *message);
struct db_message_list db_get_messages(i64 roomid,i64 timestamp,i64 count); // pass timestamp==-1 for last messages
void db_nullify_name_id(struct db_name_id ni);
void db_nullify_room_list(struct db_room_list rl);
void db_nullify_user_list(struct db_user_list ul);
void db_nullify_message_list(struct db_message_list ml);
|