- Get rid of command_init()
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Sun, 21 Jun 2015 16:13:25 +0000 (16:13 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Sun, 21 Jun 2015 16:13:25 +0000 (16:13 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6175 82007160-df01-0410-b94d-b575c5fd34c7

src/config.c
src/list.h
src/opercmd.c

index 7655f8fc0b717d93e3d653eda35e682f3aaf9537..d893f500f1e2740e6e5b15c9d9b9308fb497aff5 100644 (file)
@@ -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 */
 
index 576690f240f9b27a62d61f783a8329c2cc7e92d6..93298679770c142d6cefce6abdee34467dc2a1a9 100644 (file)
@@ -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;
index bf029640f356a75602a61cfaa77bcea8e55eee71..b342a9eaf621de1cb56aa775a883185447e02fa4 100644 (file)
@@ -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);
     }
   }