From: michael Date: Sun, 21 Jun 2015 16:13:25 +0000 (+0000) Subject: - Get rid of command_init() X-Git-Tag: 1.1.0beta1~22 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=74b93a237be648453534dd2d449c28e6ff41ac0e;p=hopm.git - Get rid of command_init() git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6175 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/config.c b/src/config.c index 7655f8f..d893f50 100644 --- a/src/config.c +++ b/src/config.c @@ -116,7 +116,6 @@ config_load(const char *filename) yyparse(); scan_init(); /* Initialize the scanners once we have the configuration */ - command_init(); /* Initialize the command queue */ stats_init(); /* Initialize stats (UPTIME) */ firedns_init(); /* Initialize adns */ diff --git a/src/list.h b/src/list.h index 576690f..9329867 100644 --- a/src/list.h +++ b/src/list.h @@ -24,7 +24,7 @@ #define LIST_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next) #define LIST_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL) #define LIST_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev) -#define LIST_SIZE(list) list->elements +#define LIST_SIZE(list) (list)->elements typedef struct _node node_t; typedef struct _list list_t; diff --git a/src/opercmd.c b/src/opercmd.c index bf02964..b342a9e 100644 --- a/src/opercmd.c +++ b/src/opercmd.c @@ -37,7 +37,7 @@ #include "stats.h" -static list_t *COMMANDS; /* List of active commands */ +static list_t COMMANDS; /* List of active commands */ /* cmd_check @@ -101,21 +101,6 @@ cmd_protocols(char *param, const struct ChannelConf *target) } } -/* command_init - * - * Do command initialization - * - * Parameters: NONE - * Return: NONE - * - */ -void -command_init(void) -{ - if (COMMANDS == NULL) - COMMANDS = list_create(); -} - /* command_create * * Create a Command struct. @@ -199,7 +184,7 @@ command_parse(char *command, const struct ChannelConf *target, source_p->irc_nick, target->name); /* Only allow COMMANDMAX commands in the queue */ - if (LIST_SIZE(COMMANDS) >= COMMANDMAX) + if (LIST_SIZE(&COMMANDS) >= COMMANDMAX) return; /* @@ -240,7 +225,7 @@ command_parse(char *command, const struct ChannelConf *target, /* Queue this command */ struct Command *command = command_create(tab, param, source_p->irc_nick, target); - list_add(COMMANDS, node_create(command)); + list_add(&COMMANDS, node_create(command)); break; } } @@ -272,14 +257,14 @@ command_timer(void) time(&present); - LIST_FOREACH_SAFE(node, node_next, COMMANDS->head) + LIST_FOREACH_SAFE(node, node_next, COMMANDS.head) { struct Command *command = node->data; if ((present - command->added) > COMMANDTIMEOUT) { command_free(command); - list_remove(COMMANDS, node); + list_remove(&COMMANDS, node); node_free(node); } else /* Since the queue is in order, it's also ordered by time, no nodes after this will be timed out */ @@ -323,7 +308,7 @@ command_userhost(const char *reply) *(tmp) = '\0'; /* Find any queued commands that match this user */ - LIST_FOREACH_SAFE(node, node_next, COMMANDS->head) + LIST_FOREACH_SAFE(node, node_next, COMMANDS.head) { struct Command *command = node->data; @@ -334,7 +319,7 @@ command_userhost(const char *reply) /* Cleanup the command */ command_free(command); - list_remove(COMMANDS, node); + list_remove(&COMMANDS, node); node_free(node); } }