add circular buffer logic and fix makefile bug
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#ifndef IRC_EVENTS_H
|
||||
#define IRC_EVENTS_H
|
||||
|
||||
#define QUEUE_FAILURE -1
|
||||
#define QUEUE_SUCCESS 0
|
||||
#define QUEUE_FULL 1
|
||||
#define QUEUE_EMPTY 2
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IRC_EVENT_PRIVMSG,
|
||||
|
||||
@@ -41,9 +41,13 @@ PUBLIC void IRC_Close(irc_client_t *irc);
|
||||
// init
|
||||
PUBLIC int IRC_Init(irc_client_t *irc);
|
||||
PUBLIC void IRC_Free(irc_client_t *irc);
|
||||
int IRC_InitQueue(irc_client_t *irc, int size);
|
||||
|
||||
PUBLIC int IRC_PollEvent(irc_event_t *event, irc_client_t *irc);
|
||||
// PUBLIC int IRC_PollEvent(irc_event_t *event, irc_client_t *irc);
|
||||
|
||||
void IRC_PushEvent(irc_event_t *event, irc_client_t *irc);
|
||||
int IRC_Enqueue(irc_event_t *data, irc_client_t *irc);
|
||||
int IRC_Dequeue(irc_event_t *data, irc_client_t *irc);
|
||||
|
||||
int IRC_PeekQueue(irc_event_t *data, irc_client_t *irc);
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
irc_event_type_t type;
|
||||
irc_message_t orig_msg;
|
||||
char line[513];
|
||||
} irc_event_t;
|
||||
|
||||
typedef struct
|
||||
@@ -96,6 +96,14 @@ typedef struct
|
||||
irc_connection_type_t connType;
|
||||
} irc_connection_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
irc_event_t *events;
|
||||
int eventsSize;
|
||||
int front;
|
||||
int rear;
|
||||
} irc_event_queue_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
irc_connection_info_t connectionInfo;
|
||||
@@ -111,13 +119,13 @@ typedef struct
|
||||
/* Identity */
|
||||
irc_identity_t identity;
|
||||
|
||||
irc_event_t* eventQueue; // lives on the heap
|
||||
int eventQueuePtr;
|
||||
/* Event queues */
|
||||
irc_event_queue_t evtQueue;
|
||||
} irc_client_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void (*handler)(irc_message_t *msg, irc_client_t *irc);
|
||||
} command_t;
|
||||
} irc_command_t;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user