From: pk910 Date: Thu, 11 Aug 2011 05:29:50 +0000 (+0200) Subject: added simple queue system to WHOHandler.c X-Git-Tag: v5.3~614 X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=52eaee5dc863775b9e7c5997a8943d02748fb27b;p=NeonServV5.git added simple queue system to WHOHandler.c --- 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); }