added simple queue system to WHOHandler.c
authorpk910 <philipp@zoelle1.de>
Thu, 11 Aug 2011 05:29:50 +0000 (07:29 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 11 Aug 2011 05:29:50 +0000 (07:29 +0200)
WHOHandler.c

index 1aeca95375cbad8f19e1a8e3edfcf28e8e5fe0cd..a5bbb80fdd93d48bde9e978b45b7a31927dcaddc 100644 (file)
@@ -1,14 +1,53 @@
 
 #include "WHOHandler.h"
+#include "ChanNode.h"
+#include "UserNode.h"
+
+struct WHOQueueEntry {
+    char type;
+    struct ChanNode *chan;
+    struct UserNode *user;
+    struct WHOQueueEntry *next;
+}
+
+static struct WHOQueueEntry *first_entry = NULL, *last_entry = NULL;
+
+static struct WHOQueueEntry* addWHOQueueEntry() {
+    struct WHOQueueEntry *entry = malloc(sizeof(*entry));
+    if (!entry)
+    {
+        perror("malloc() failed");
+        return NULL;
+    }
+    entry->next = NULL;
+    if(last_entry)
+        last_entry->next = entry;
+    if(!first_entry)
+        first_entry = entry;
+}
+
+static struct WHOQueueEntry* getNextWHOQueueEntry(int remove) {
+    if(!first_entry) return NULL;
+    struct WHOQueueEntry *entry = first_entry;
+    if(remove) {
+        first_entry = first_entry->next;
+        if(last_entry == first_entry)
+            last_entry = NULL;
+    }
+    return entry;
+}
 
 void get_userlist(struct ChanNode *chan, userlist_callback_t callback) {
     
 }
 
 void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int argc) {
+    struct WHOQueueEntry* entry = getNextWHOQueueEntry(0);
     
 }
 
 void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int argc) {
+    struct WHOQueueEntry* entry = getNextWHOQueueEntry(1);
     
+    free(entry);
 }