aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeber <beber>2005-12-02 11:15:47 +0000
committerbeber <beber>2005-12-02 11:15:47 +0000
commiteaed0a8a6575675675c5b12212d693f85ac41763 (patch)
tree32355cc8051685af6227d74cf3eb37cdcbc39fd0 /src
parentSome work on debug (diff)
downloadespik-eaed0a8a6575675675c5b12212d693f85ac41763.tar.xz
Have a better input parser
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/espik_irc.c30
2 files changed, 21 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 29c0992..5fcdbbd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
AM_CFLAGS = \
- -W -Wall -g3 -O0 -ggdb \
+ -W -Wall \
@ecore_cflags@
ESPIKHEADERS = \
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);
}