aboutsummaryrefslogtreecommitdiff
path: root/src/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc.c')
-rw-r--r--src/irc.c86
1 files changed, 28 insertions, 58 deletions
diff --git a/src/irc.c b/src/irc.c
index dd1f9ae..58e421f 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -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;
}
}