diff options
author | Marius Halden <marius.h@lden.org> | 2016-03-29 14:32:51 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-05-07 14:31:03 +0200 |
commit | 20152af8648494fa7cc73c56c3a09c22ff6e85fe (patch) | |
tree | 7d9bea3a93f6c4278510fbfa7ae43ee476f58b62 | |
parent | c3d242a4552aff7e56e8dfc91d9677b81d245150 (diff) |
Rename irc_send_msg*_tagged to irc_send_tagged_msg* and remove some code
duplication
-rw-r--r-- | irc.h | 9 | ||||
-rw-r--r-- | irc_im.c | 4 | ||||
-rw-r--r-- | irc_send.c | 29 |
3 files changed, 24 insertions, 18 deletions
@@ -357,11 +357,14 @@ void irc_send_topic(irc_channel_t *ic, gboolean topic_change); void irc_send_whois(irc_user_t *iu); void irc_send_who(irc_t *irc, GSList *l, const char *channel); void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix); -void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags); void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg); -void irc_send_msg_raw_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags); void irc_send_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *format, ...) G_GNUC_PRINTF(4, 5); -void irc_send_msg_f_tagged(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...) G_GNUC_PRINTF(5, 6); + +void irc_send_tagged_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags); +void irc_send_tagged_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags); +void irc_send_tagged_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...) G_GNUC_PRINTF(5, 6); +void irc_send_tagged_msg_vf(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, va_list params); + void irc_send_nick(irc_user_t *iu, const char *new_nick); void irc_send_channel_user_mode_diff(irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t old_flags, irc_channel_user_flags_t new_flags); @@ -306,7 +306,7 @@ static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, g } wrapped = word_wrap(msg, 425); - irc_send_msg_tagged(src_iu, message_type, dst, wrapped, prefix, tags); + irc_send_tagged_msg(src_iu, message_type, dst, wrapped, prefix, tags); g_free(wrapped); cleanup: @@ -688,7 +688,7 @@ static gboolean bee_irc_chat_msg(bee_t *bee, struct groupchat *c, bee_user_t *bu } wrapped = word_wrap(msg, 425); - irc_send_msg_tagged(iu, "PRIVMSG", ic->name, wrapped, ts, tags); + irc_send_tagged_msg(iu, "PRIVMSG", ic->name, wrapped, ts, tags); g_free(ts); g_free(wrapped); g_free(tags); @@ -366,10 +366,10 @@ void irc_send_who(irc_t *irc, GSList *l, const char *channel) void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix) { - irc_send_msg_tagged(iu, type, dst, msg, prefix, NULL); + irc_send_tagged_msg(iu, type, dst, msg, prefix, NULL); } -void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags) +void irc_send_tagged_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags) { char last = 0; const char *s = msg, *line = msg; @@ -390,14 +390,14 @@ void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, cons strcpy(raw_msg, "\001ACTION "); strncat(raw_msg, line + 4, s - line - 4); strcat(raw_msg, "\001"); - irc_send_msg_raw_tagged(iu, type, dst, raw_msg, tags); + irc_send_tagged_msg_raw(iu, type, dst, raw_msg, tags); } else { *raw_msg = '\0'; if (prefix && *prefix) { strcpy(raw_msg, prefix); } strncat(raw_msg, line, s - line); - irc_send_msg_raw_tagged(iu, type, dst, raw_msg, tags); + irc_send_tagged_msg_raw(iu, type, dst, raw_msg, tags); } line = s + 1; } @@ -407,10 +407,10 @@ void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, cons void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg) { - irc_send_msg_raw_tagged(iu, type, dst, msg, NULL); + irc_send_tagged_msg_raw(iu, type, dst, msg, NULL); } -void irc_send_msg_raw_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags) +void irc_send_tagged_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags) { if (!tags || !*tags) { irc_write(iu->irc, ":%s!%s@%s %s %s :%s", @@ -425,25 +425,28 @@ void irc_send_msg_raw_tagged(irc_user_t *iu, const char *type, const char *dst, void irc_send_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *format, ...) { - char text[IRC_MAX_LINE]; va_list params; va_start(params, format); - g_vsnprintf(text, IRC_MAX_LINE, format, params); + irc_send_tagged_msg_vf(iu, type, dst, NULL, format, params); va_end(params); - irc_write(iu->irc, ":%s!%s@%s %s %s :%s", - iu->nick, iu->user, iu->host, type, dst, text); } -void irc_send_msg_f_tagged(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...) +void irc_send_tagged_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...) { - char text[IRC_MAX_LINE]; va_list params; va_start(params, format); - g_vsnprintf(text, IRC_MAX_LINE, format, params); + irc_send_tagged_msg_vf(iu, type, dst, tags, format, params); va_end(params); +} + +void irc_send_tagged_msg_vf(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, va_list params) +{ + char text[IRC_MAX_LINE]; + + g_vsnprintf(text, IRC_MAX_LINE, format, params); if (!tags || !*tags) { irc_write(iu->irc, ":%s!%s@%s %s %s :%s", |