added simple queue system to WHOHandler.c
[NeonServV5.git] / WHOHandler.c
1
2 #include "WHOHandler.h"
3 #include "ChanNode.h"
4 #include "UserNode.h"
5
6 struct WHOQueueEntry {
7     char type;
8     struct ChanNode *chan;
9     struct UserNode *user;
10     struct WHOQueueEntry *next;
11 }
12
13 static struct WHOQueueEntry *first_entry = NULL, *last_entry = NULL;
14
15 static struct WHOQueueEntry* addWHOQueueEntry() {
16     struct WHOQueueEntry *entry = malloc(sizeof(*entry));
17     if (!entry)
18     {
19         perror("malloc() failed");
20         return NULL;
21     }
22     entry->next = NULL;
23     if(last_entry)
24         last_entry->next = entry;
25     if(!first_entry)
26         first_entry = entry;
27 }
28
29 static struct WHOQueueEntry* getNextWHOQueueEntry(int remove) {
30     if(!first_entry) return NULL;
31     struct WHOQueueEntry *entry = first_entry;
32     if(remove) {
33         first_entry = first_entry->next;
34         if(last_entry == first_entry)
35             last_entry = NULL;
36     }
37     return entry;
38 }
39
40 void get_userlist(struct ChanNode *chan, userlist_callback_t callback) {
41     
42 }
43
44 void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int argc) {
45     struct WHOQueueEntry* entry = getNextWHOQueueEntry(0);
46     
47 }
48
49 void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int argc) {
50     struct WHOQueueEntry* entry = getNextWHOQueueEntry(1);
51     
52     free(entry);
53 }