From 52eaee5dc863775b9e7c5997a8943d02748fb27b Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 11 Aug 2011 07:29:50 +0200 Subject: [PATCH] added simple queue system to WHOHandler.c --- WHOHandler.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/WHOHandler.c b/WHOHandler.c index 1aeca95..a5bbb80 100644 --- a/WHOHandler.c +++ b/WHOHandler.c @@ -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); } -- 2.20.1