diff options
Diffstat (limited to 'src/common/inbound.c')
-rw-r--r-- | src/common/inbound.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c index b80553b3..ef26890b 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -33,8 +33,6 @@ #define WANTDNS #include "inet.h" -#include <gio/gio.h> - #include "hexchat.h" #include "util.h" #include "ignore.h" @@ -64,7 +62,7 @@ clear_channel (session *sess) if (sess->current_modes) { - free (sess->current_modes); + g_free (sess->current_modes); sess->current_modes = NULL; } @@ -83,9 +81,17 @@ clear_channel (session *sess) void set_topic (session *sess, char *topic, char *stripped_topic) { - if (sess->topic) - free (sess->topic); - sess->topic = strdup (stripped_topic); + /* The topic of dialogs are the users hostname which is logged is new */ + if (sess->type == SESS_DIALOG && (!sess->topic || strcmp(sess->topic, stripped_topic)) + && sess->logfd != -1) + { + char tbuf[1024]; + g_snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", sess->channel, stripped_topic); + write (sess->logfd, tbuf, strlen (tbuf)); + } + + g_free (sess->topic); + sess->topic = g_strdup (stripped_topic); fe_set_topic (sess, topic, stripped_topic); } @@ -121,7 +127,7 @@ find_session_from_nick (char *nick, server *serv) } list = list->next; } - return 0; + return NULL; } static session * @@ -182,16 +188,7 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, } if (ip && ip[0]) - { - if (prefs.hex_irc_logging && sess->logfd != -1 && - (!sess->topic || strcmp(sess->topic, ip))) - { - char tbuf[1024]; - snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip); - write (sess->logfd, tbuf, strlen (tbuf)); - } set_topic (sess, ip, ip); - } inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data); return; } @@ -558,7 +555,7 @@ find_unused_session (server *serv) } list = list->next; } - return 0; + return NULL; } static session * @@ -576,7 +573,7 @@ find_session_from_waitchannel (char *chan, struct server *serv) } list = list->next; } - return 0; + return NULL; } void @@ -682,7 +679,8 @@ inbound_nameslist (server *serv, char *chan, char *names, char **name_list; char *host, *nopre_name; char name[NICKLEN]; - int i, offset; + int i; + size_t offset; sess = find_channel (serv, chan); if (!sess) @@ -916,7 +914,7 @@ inbound_ping_reply (session *sess, char *timestring, char *from, tags_data->timestamp); } else { - snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000); + g_snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000); EMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, outbuf, NULL, NULL, 0, tags_data->timestamp); } @@ -934,7 +932,7 @@ find_session_from_type (int type, server *serv) return sess; list = list->next; } - return 0; + return NULL; } void @@ -969,14 +967,14 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id, /* guess where chanserv meant to post this -sigh- */ if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) { - char *dest = strdup (msg + 1); + char *dest = g_strdup (msg + 1); char *end = strchr (dest, ']'); if (end) { *end = 0; sess = find_channel (serv, dest); } - free (dest); + g_free (dest); } } if (!sess) @@ -1455,8 +1453,7 @@ inbound_user_info (session *sess, char *chan, char *user, char *host, if (user && host) { - uhost = g_malloc (strlen (user) + strlen (host) + 2); - sprintf (uhost, "%s@%s", user, host); + uhost = g_strdup_printf ("%s@%s", user, host); } if (chan) |