diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd.c | 2 | ||||
| -rw-r--r-- | src/irc.c | 86 | ||||
| -rw-r--r-- | src/irc.h | 1 |
3 files changed, 30 insertions, 59 deletions
@@ -120,7 +120,7 @@ static void err_no_scr_target(void) { "part #channel I'm outta here\0" after nextarg(), arg points to "part\0" only, and ret points to "#channel I'm outta here\0". */ -static char *nextarg(char *arg) { +char *nextarg(char *arg) { /* iterate over the first word */ while(*arg && *arg != ' ') arg++; @@ -35,7 +35,6 @@ char new_scr_status; char need_rejoin; static char msgbuf[MAX_MSG] = { 0 }; -static char *msg; /* with source removed */ static int msgbuf_len = 0; static char regged = 0, hilite = 0; @@ -68,18 +67,6 @@ static void print_reason(void) { scr_eol_active(); } -static void do_pong(void) { - /* - // nobody really needs this except for debugging the client - if(conf->show_ping) - scr_print_server("PING/PONG\n"); - else - scr_activate(scr_current); - */ - txbuf_set_str2("PONG ", msg_args[0]); - txbuf_send(); -} - static void bold(void) { scr_putc_active('\x02'); } @@ -600,39 +587,25 @@ static void dispatch_msg(void) { static void parse_msg(void) { char *p; - msg_cmd = msg_text = msg_src = msg_dest = 0; - msg = msgbuf; - /* ignore empty message */ - if(!*msg) return; + if(!*msgbuf) return; - /* - scr_print_active("RAW: "); - scr_print_active(msg); - scr_eol_active(); - */ - - /* if there's a final multiword arg... */ - /* FIXME: channel names can have colons, which breaks this... */ - p = strstr(msg + 1, " :"); /* +1 to skip leading colon in msg source */ - if(p) { - msg_text = p + 2; - *p = 0; - } + msg_cmd = msg_text = msg_src = msg_dest = 0; + memset(msg_args, 0, sizeof(msg_args)); /* first token is either the source (with a :) or a command (without) */ - p = strtok(msg, " "); + p = nextarg(msgbuf); if(!p) { invalid_msg('1'); return; } - if(*p == ':') { - msg_src = p + 1; /* generally :irc.example.com or :nick!user@host */ - msg_cmd = strtok(0, " "); + if(*msgbuf == ':') { + msg_src = msgbuf + 1; /* generally :irc.example.com or :nick!user@host */ + msg_cmd = p; } else { msg_src = 0; /* no source supplied */ - msg_cmd = p; + msg_cmd = msgbuf; } if(!msg_cmd) { @@ -642,31 +615,28 @@ static void parse_msg(void) { /* special case for ping, treat as 1 arg, even if it has space and no : */ if(streq_i(msg_cmd, "PING")) { - msg_argcount = 1; - msg_args[0] = msg_cmd + 6; - do_pong(); + txbuf_set_str2("PONG ", msg_cmd + 6); + txbuf_send(); return; - } else { - for(msg_argcount = 0; msg_argcount < MAX_MSG_ARGS; msg_argcount++) { - p = strtok(0, " "); - if(p) { - msg_args[msg_argcount] = p; - /* if any arg is a channel name, use it for the dest */ - if(*p == '#') - msg_dest = p; - } else { - break; - } - } } - /* - if(msg_dest) { - scr_print_current("got here, msg_dest is: "); - scr_print_current(msg_dest); - scr_eol_current(); + p = nextarg(msg_cmd); + for(msg_argcount = 0; msg_argcount < MAX_MSG_ARGS; msg_argcount++) { + if(!p) break; + + if(*p == ':') { + msg_text = p + 1; + break; + } + + msg_args[msg_argcount] = p; + + /* if any arg is a channel name, use it for the dest */ + if(*p == '#') + msg_dest = p; + + p = nextarg(p); } - */ if(!msg_dest) { if(msg_argcount) @@ -676,9 +646,9 @@ static void parse_msg(void) { } if(msg_src) { - if((p = strstr(msg_src, "!"))) { + if((p = strchr(msg_src, '!'))) { *p = '\0'; - } else if(strstr(msg_src, ".")) { + } else if(strchr(msg_src, '.')) { msg_src = 0; } } @@ -67,6 +67,7 @@ void __fastcall__ bell(void); /* see src/bell.s */ void start_keystroke(char c); /**** cmd.c */ +char *nextarg(char *arg); void cmd_command(char *cmd); void cmd_execute(void); void cmd_rejoin_chans(void); |
