aboutsummaryrefslogtreecommitdiff
path: root/src/espik_irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/espik_irc.c')
-rw-r--r--src/espik_irc.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/espik_irc.c b/src/espik_irc.c
index 479b014..a87f904 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -27,28 +27,38 @@ typedef struct
} buf_t;
cmd_t cmd_tab[] = {
- { "JOIN", irc_join },
- { "PART", irc_part },
- { "PRIVMSG", irc_privmsg },
- { "QUIT", irc_quit },
- { "RAW", irc_raw },
- { "NICK", irc_nick },
-/* { "ACTION", irc_action }, */
+ { "JOIN", irc_join },
+ { "PART", irc_part },
+ { "PRIVMSG", irc_privmsg },
+ { "QUIT", irc_quit },
+ { "RAW", irc_raw },
+ { "NICK", irc_nick },
+/* { "ACTION", irc_action }, */
{ 0, 0 }
};
+/* Cut the commandline in two string
+ * 1: The first word
+ * 2: The rest (without any trailer whitespace between firt and rest).
+ */
char** separate_commandline (char *msg)
{
unsigned int len;
char** two_words;
/* Yes, do nothing, just get len ! */
- for (len = 0; msg[len] != ' '; len++);
- two_words = malloc (sizeof(char*) * 2);
+ for (len = 0 ; msg[len] != ' ' && msg[len] != '\t' ; len++);
+
+ two_words = malloc (2 * sizeof(char*));
msg[len] = '\0';
two_words[0] = msg;
- two_words[1] = msg + len + 1;
+
+ do
+ {
+ two_words[1] = msg + ++len;
+ }
+ while (*two_words[1] == ' ' || *two_words[1] == '\t');
return (two_words);
}