irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit b914bb239869bf18bb10e01e91f18466d93547a6
parent dcd18b50396912a2aa5bc8c43d7091898e11e7a7
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 11 Jul 2012 22:42:51 +0200

clean exits, clean error handling

Diffstat:
irctk.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -1038,6 +1038,7 @@ char* consume_word(char **from) } /* Send a message or do a command */ +/* Return value is 0 if OK, >0 if error, -1 if correctly exited */ int do_cmd_msg(irc_session_t *s, char* chan, char* line) { int rsl = -1; @@ -1080,8 +1081,12 @@ int do_cmd_msg(irc_session_t *s, char* chan, char* line) // TODO notify main thread that is is over if (IS_END(*arg)) { rsl = irc_cmd_quit(s, NULL); + if (!rsl) + rsl = -1; } else if (*arg == ' ') { rsl = irc_cmd_quit(s, arg); + if (!rsl) + rsl = -1; } } else if ((arg = MATCH_CMD(line, "invite"))) { char *inick = consume_word(&arg); @@ -1673,10 +1678,14 @@ int start (int max_wait) debug("[main] manage line %s %s, pointer %p", results[i].destination, results[i].line, results[i].full_line ); rsl = do_cmd_msg(s, results[i].destination, results[i].line); - if (rsl) { + if (rsl > 0) { error = irc_errno(s); - info("Interpreting \"%s\" returned %d, error %d: %s", results[i].line, - rsl, error, irc_strerror(error)); + info("(%d) %s when interpreting: %s", + error, irc_strerror(error), results[i].line); + } + if (rsl < 0) { + // successful exit + cont = 0; } } }