From 0e77cc8dacf384b692e7cfbe05413fa545438827 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sat, 13 Aug 2011 01:52:23 +0200 Subject: [PATCH] some fixes --- IRCParser.h | 2 -- main.h | 1 + modcmd.c | 12 +++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/IRCParser.h b/IRCParser.h index 1425f57..ef3600a 100644 --- a/IRCParser.h +++ b/IRCParser.h @@ -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 0af7289..7efb1cd 100644 --- 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{|}~[\\]^_`" diff --git a/modcmd.c b/modcmd.c index ead1efd..d7fff2f 100644 --- 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; -- 2.20.1