irctk

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

commit 7e97056e3e552aa01dd0513336ec79ef5e804efe
parent 36806708f02c487ed012eaa28ae9bf9095796eae
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat, 16 Jun 2012 16:46:05 +0200

Remove warnings

Diffstat:
irctk.c | 55+++++++++++++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -235,6 +235,13 @@ void initialize_args() } +void set_nick_and_names(struct arguments *arguments) { + strncat(arguments->nick, arguments->raw_dest, MAX_NICK_LEN-1); + if (!arguments->username_set) + arguments->username = arguments->raw_dest; + if (!arguments->realname_set) + arguments->realname = arguments->raw_dest; +} static error_t parse_opt (int key, char *arg, struct argp_state *state) @@ -332,20 +339,15 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { if (arguments->raw_dest[i] == ':' && !saw_pass) { arguments->raw_dest[i] = 0; - strncat(arguments->nick, arguments->raw_dest, MAX_NICK_LEN-1); - if (!arguments->username_set) - arguments->username = arguments->raw_dest; - if (!arguments->realname_set) - arguments->realname = arguments->raw_dest; + set_nick_and_names(arguments); arguments->password = arguments->raw_dest + i + 1; saw_pass = i; } if (arguments->raw_dest[i] == '@') { arguments->raw_dest[i] = 0; - if (saw_pass) { - // nick was already set - } else { + if (!saw_pass) { + // nick wasn't already set strncat(arguments->nick, arguments->raw_dest, MAX_NICK_LEN-1); if (!arguments->username_set) arguments->username = arguments->raw_dest; @@ -460,7 +462,7 @@ int join_channel(irc_session_t *s, char* chan) { return ret; } -int do_cmd_msg(irc_session_t *s, const char* chan, const char* line) +int do_cmd_msg(irc_session_t *s, char* chan, char* line) { int rsl = -1; @@ -522,7 +524,7 @@ int do_cmd_msg(irc_session_t *s, const char* chan, const char* line) return 0; } -int cmd_msg_chan(irc_session_t *s, char *target, const char* line) +int cmd_msg_chan(irc_session_t *s, char *target, char* line) { int i = 0; int cont = 1; @@ -551,7 +553,7 @@ int cmd_msg_chan(irc_session_t *s, char *target, const char* line) return rsl; } -int cmd_msg(irc_session_t *s, char* target, const char* line) +int cmd_msg(irc_session_t *s, char* target, char* line) { int i = 0; char *msg[2*MAX_LEN+2]; @@ -570,10 +572,10 @@ int cmd_msg(irc_session_t *s, char* target, const char* line) if (line[0] != '\n') { msg[0] = 0; - strncat(msg, args.last_nick_in, MAX_LEN-1); - strcat(msg, ": "); - strncat(msg, line, MAX_LEN-1); - line = msg; + strncat((char*) msg, args.last_nick_in, MAX_LEN-1); + strcat((char*) msg, ": "); + strncat((char*) msg, line, MAX_LEN-1); + line = (char*) msg; } else { args.last_nick_in[0] = 0; } @@ -637,7 +639,7 @@ void dump_event (irc_session_t * session, const char * event, const char * origi die(E_BADNAME, "No available nickname found."); } else { args.nick[len] = '_'; - args.nick[len+1] = NULL; + args.nick[len+1] = 0; rsl = irc_cmd_nick (session, args.nick); info("Requested nick is taken, try %s\n", args.nick, args.nick); } @@ -736,15 +738,6 @@ void event_connect (irc_session_t * session, const char * event, const char * or } -void event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) -{ - dump_event (session, event, origin, params, count); - - /* TODO sure? */ - event_channel (session, event, origin, params, count); -} - - void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) { static int count = 1; @@ -808,7 +801,7 @@ void event_channel (irc_session_t * session, const char * event, const char * or int i=0; int ok = 1, ok2; - char* pruned; + const char* pruned; if ( count != 2 ) return; @@ -899,6 +892,16 @@ void event_channel (irc_session_t * session, const char * event, const char * or } +void event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) +{ + dump_event (session, event, origin, params, count); + + /* TODO sure? */ + event_channel (session, event, origin, params, count); +} + + + void irc_event_dcc_chat (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid) { printf ("DCC chat [%d] requested from '%s' (%s)\n", dccid, nick, addr);