some fixes
authorpk910 <philipp@zoelle1.de>
Fri, 12 Aug 2011 23:52:23 +0000 (01:52 +0200)
committerpk910 <philipp@zoelle1.de>
Fri, 12 Aug 2011 23:58:42 +0000 (01:58 +0200)
IRCParser.h
main.h
modcmd.c

index 1425f57dc86678b8b9bb0852a3b8ac7e34771088..ef3600a778f248caf7ee4bf0f5ca5f3bf5f2a3bc 100644 (file)
@@ -4,8 +4,6 @@
 #include "main.h"
 #include "ClientSocket.h"
 
-#define MAXNUMPARAMS 200 /* maximum number of parameters in one line */
-
 #define IRC_CMD(NAME) int NAME(struct ClientSocket *client, UNUSED_ARG(const char *from), UNUSED_ARG(char **argv), UNUSED_ARG(unsigned int argc))
 typedef IRC_CMD(irc_cmd_t);
 
diff --git a/main.h b/main.h
index 0af72895852f6fba0af2ed39264552b133329b2b..7efb1cd0d8819eaed3755b65d60ba4abf21da4cf 100644 (file)
--- a/main.h
+++ b/main.h
@@ -40,6 +40,7 @@
 #define CHANNELLEN      200
 #define MAXLEN          512
 #define TRIGGERLEN      50
+#define MAXNUMPARAMS    200 /* maximum number of parameters in one line */
 
 //valid nick chars
 #define VALID_NICK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{|}~[\\]^_`"
index ead1efd8029735ddbad468e3f65d5b8e3e2efaa6..d7fff2fe73846c1b94652c16d30c59da954fa7ce 100644 (file)
--- a/modcmd.c
+++ b/modcmd.c
@@ -64,7 +64,7 @@ static char* get_channel_trigger(int botid, struct ChanNode *chan) {
 static void handle_command(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *message) {
     if(message[0] == '#') {
         char *chanName = message;
-        message = strstr(message, ' ');
+        message = strstr(message, " ");
         if(!message) return;
         *message = '\0';
         message++;
@@ -83,20 +83,22 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
         if(cbind->botid == client->botid && strcmp(cbind->cmd, message) == 0) {
             struct cmd_function *cmdfunc = cbind->func;
             //parse the arguments...
-            char *argv[MAXNUMPARAMS];
+            char *arga[MAXNUMPARAMS];
+            char **argv;
             int argc = 0;
             while(*args) {
                 //skip leading spaces
                 while (*args == ' ')
                     *args++ = 0;
-                argv[argc++] = args;
+                arga[argc++] = args;
                 if (argc >= MAXNUMPARAMS)
                     break;
                 while (*args != ' ' && *args)
                     args++;
             }
-            if(argc != 0 && args[0][0] == '#') {
-                struct ChanNode *chan2 = getChanByName(args[0]);
+            argv = arga;
+            if(argc != 0 && argv[0][0] == '#') {
+                struct ChanNode *chan2 = getChanByName(argv[0]);
                 if(chan2) {
                     argv += 1;
                     argc -= 1;