cvs: php4 /ext/ircg ircg.c
| From: | Sascha Schumann | Date: | Fri, 08 Mar 2002 12:43:11 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9831@lists.php.net to get a copy of this message | ||
sas Fri Mar 8 07:43:11 2002 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Add identifier which terminates a connection upon receiving a specific
CTCP message. The message must come from the specified user or will
be ignored. This can be used to disconnect a large number of users
when an event adjourns.
Improve error reporting by notifying the IRC server why a HTTP
connection failed.
Fix a prototype comment
Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.128 php4/ext/ircg/ircg.c:1.129 --- php4/ext/ircg/ircg.c:1.128 Thu Feb 28 03:26:17 2002 +++ php4/ext/ircg/ircg.c Fri Mar 8 07:43:10 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.128 2002/02/28 08:26:17 sebastian Exp $ */ +/* $Id: ircg.c,v 1.129 2002/03/08 12:43:10 sas Exp $ */ /* {{{ includes */ @@ -147,6 +147,7 @@ union { unsigned char v; void *ptr; + smart_str *s; } para; } token_t; @@ -192,7 +193,8 @@ C_TO, C_MESSAGE, C_STRING, - C_PERCENT + C_PERCENT, + C_TERMINATE_1 /* auth by username */ }; enum { @@ -211,7 +213,7 @@ static void format_msg(const format_msg_t *fmt_msg, smart_str *channel, smart_str *to, smart_str *from, smart_str *msg, smart_str *result, - const char *username, int username_len); + const char *username, int username_len, int *status); static void msg_send(php_irconn_t *conn, smart_str *msg); @@ -260,7 +262,7 @@ #define FORMAT_MSG(conn, type, chan, to, from, msg, res, u, ulen) { \ format_msg(MSG(conn, type), chan, \ - to, from, msg, res, u, ulen); \ + to, from, msg, res, u, ulen, NULL); \ } /* }}} */ @@ -337,7 +339,7 @@ if (conn->file_fd != -1) { smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_DISCONNECTED), NULL, NULL, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_DISCONNECTED, NULL, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); @@ -553,6 +555,7 @@ /* associate mode bits with each command where applicable */ case 'c': NEW_TOKEN(C_CHANNEL, v) = mode; break; + case 'd': NEW_TOKEN(C_TERMINATE_1, v) = mode; break; case 't': NEW_TOKEN(C_TO, v) = mode; break; case 'f': NEW_TOKEN(C_FROM, v) = mode; break; case 'r': NEW_TOKEN(C_MESSAGE, v) = mode; break; @@ -576,7 +579,7 @@ /* {{{ format_msg */ static void format_msg(const format_msg_t *fmt_msg, smart_str *channel, smart_str *to, smart_str *from, smart_str *msg, smart_str *result, - const char *username, int username_len) + const char *username, int username_len, int *status) { smart_str encoded_msg = {0}; int encoded = 0; @@ -637,7 +640,7 @@ break; \ } - for (; ntoken -- > 0; i++) { + for (; ntoken-- > 0; i++) { switch (t[i].code) { case C_STRING: smart_str_append_ex(result, t[i].para.ptr, 1); break; case C_FROM: IRCG_APPEND(from); break; @@ -645,6 +648,13 @@ case C_CHANNEL: IRCG_APPEND(channel); break; case C_MESSAGE: IRCG_APPEND(msg); break; case C_PERCENT: smart_str_appendc_ex(result, '%', 1); break; + case C_TERMINATE_1: /* auth by username */ + if (ntoken > 0 && t[i+1].code == C_STRING) { + if (t[i+1].para.s->len == from->len + && strncasecmp(t[i+1].para.s->c, from->c, from->len) == 0) + *status = 1; + } else + *status = 1; } } @@ -687,6 +697,8 @@ /* {{{ Message-delivery */ static void msg_accum_send(php_irconn_t *conn, smart_str *msg) { + int n; + if (msg->c == 0) return; if (conn->file_fd != -1) { @@ -719,8 +731,31 @@ break; default: #if IRCG_API_VERSION - 0 >= 20010601 - if (irc_write_buf_append_ex(&conn->wb, msg, 0)) { - irc_disconnect(&conn->conn, "Write to HTTP client failed"); + if ((n = irc_write_buf_append_ex(&conn->wb, msg, 0))) { + const char *reason; + +#if IRCG_API_VERSION - 0 >= 20020308 + switch (n) { + case D_OVERFLOW: + reason = "Client is too slow, client-specific queue full"; + break; + case D_POLL_ERROR: + reason = "Poll failed. The connection is bad."; + break; + case D_CORRUPT_QUEUE: + reason = "Internal failure: Corrupt queue"; + break; + default: + if (n < 0) + reason = strerror(-n); + else +#else + { +#endif + reason = "Write to HTTP client failed for no reason"; + } + + irc_disconnect(&conn->conn, reason); } #elif IRCG_API_VERSION - 0 >= 20010302 irc_write_buf_append_ex(&conn->wb, msg, 0); @@ -765,6 +800,7 @@ if (real_msg_end) { format_msg_t *fmt_msg; smart_str tmp, tmp2; + int status = 0; *real_msg_end = '\0'; *token_end = '\0'; @@ -775,7 +811,10 @@ smart_str_setl(&tmp, real_msg, real_msg_end - real_msg); smart_str_setl(&tmp2, conn->conn.username, conn->conn.username_len); - format_msg(fmt_msg, chan, &tmp2, from, &tmp, result, conn->conn.username, conn->conn.username_len); + format_msg(fmt_msg, chan, &tmp2, from, &tmp, result, conn->conn.username, conn->conn.username_len, &status); + + if (status == 1) + irc_disconnect(&conn->conn, "Connection terminated by authenticated CTCP message"); } } } @@ -795,7 +834,7 @@ } else if (chan) { FORMAT_MSG(conn, FMT_MSG_CHAN, chan, &s_username, from, msg, &m, conn->conn.username, conn->conn.username_len); } else { - format_msg(MSG(conn, FMT_MSG_PRIV_TO_ME), NULL, &s_username, from, + FORMAT_MSG(conn, FMT_MSG_PRIV_TO_ME, NULL, &s_username, from, msg, &m, conn->conn.username, conn->conn.username_len); } @@ -808,7 +847,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_NICK), NULL, newnick, oldnick, NULL, + FORMAT_MSG(conn, FMT_MSG_NICK, NULL, newnick, oldnick, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -819,7 +858,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_USER), host, user, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_USER, host, user, nick, real_name, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -831,7 +870,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_SERVER), server, NULL, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_SERVER, server, NULL, nick, server_info, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -843,7 +882,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_IDLE), NULL, NULL, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_IDLE, NULL, NULL, nick, idletime, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -853,7 +892,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_END), NULL, NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_WHOIS_END, NULL, NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -866,7 +905,7 @@ int i; for (i = 0; i < nr; i++) { - format_msg(MSG(conn, FMT_MSG_WHOIS_CHANNEL), &channels[i], NULL, + FORMAT_MSG(conn, FMT_MSG_WHOIS_CHANNEL, &channels[i], NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); } msg_send(conn, &m); @@ -988,7 +1027,7 @@ smart_str_setl(&tmp, "IRC SERVER", sizeof("IRC SERVER") - 1); smart_str_setl(&s_username, ircc->username, ircc->username_len); - format_msg(MSG(conn, fatal ? FMT_MSG_FATAL_ERROR : FMT_MSG_ERROR), NULL, + FORMAT_MSG(conn, fatal ? FMT_MSG_FATAL_ERROR : FMT_MSG_ERROR, NULL, &s_username, &tmp, msg, &m, conn->conn.username, conn->conn.username_len); if (fatal) { @@ -1010,7 +1049,7 @@ php_irconn_t *conn = conn_data; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_BANLIST), channel, NULL, NULL, mask, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_BANLIST, channel, NULL, NULL, mask, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1019,7 +1058,7 @@ php_irconn_t *conn = conn_data; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_BANLIST_END), channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_BANLIST_END, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1031,14 +1070,14 @@ smart_str m = {0}; if (nr > 1) { - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_BEGIN), channel, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_BEGIN, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); for (i = 0; i < nr; i++) { - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_ELEMENT), channel, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_ELEMENT, channel, NULL, &users[i], NULL, &m, conn->conn.username, conn->conn.username_len); } - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_END), channel, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_END, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); } else { FORMAT_MSG(conn, FMT_MSG_JOIN, channel, NULL, &users[0], @@ -1054,7 +1093,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_TOPIC), channel, NULL, who, topic, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_TOPIC, channel, NULL, who, topic, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1066,7 +1105,7 @@ smart_str_setl(&s_username, ircc->username, ircc->username_len); - format_msg(MSG(conn, FMT_MSG_SELF_PART), channel, NULL, &s_username, + FORMAT_MSG(conn, FMT_MSG_SELF_PART, channel, NULL, &s_username, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1076,7 +1115,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_LEAVE), channel, NULL, user, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_LEAVE, channel, NULL, user, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1085,7 +1124,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_QUIT), NULL, NULL, user, msg, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_QUIT, NULL, NULL, user, msg, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1105,7 +1144,7 @@ if (conn->bailout_on_trivial && who->len == ircc->username_len && memcmp(who->c, ircc->username, who->len) == 0) { irc_disconnect(ircc, "Bailout on trivial: KICK"); } - format_msg(MSG(conn, FMT_MSG_KICK), channel, who, kicked_by, reason, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_KICK, channel, who, kicked_by, reason, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1124,12 +1163,12 @@ smart_str_setl(&what, "0", 1); if (mode & IRCG_MODE_VOICE) { - format_msg(MSG(conn, FMT_MSG_MODE_VOICE), channel, nick, who, &what, + FORMAT_MSG(conn, FMT_MSG_MODE_VOICE, channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } if (mode & IRCG_MODE_OP) { - format_msg(MSG(conn, FMT_MSG_MODE_OP), channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_MODE_OP, channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } } @@ -1137,7 +1176,7 @@ /* }}} */ /* {{{ proto bool ircg_set_on_die(int connection, string host, int port, string data) - Sets hostaction to be execute when connection dies */ + Sets hostaction to be executed when connection dies */ PHP_FUNCTION(ircg_set_on_die) { #ifdef IRCG_PENDING_URL @@ -1972,7 +2011,7 @@ if (l.c[0] == 1) { handle_ctcp(conn, NULL, &tmp2, &l, &m); } else { - format_msg(MSG(conn, FMT_MSG_PRIV_FROM_ME), NULL, + FORMAT_MSG(conn, FMT_MSG_PRIV_FROM_ME, NULL, &tmp, &tmp2, &l, &m, conn->conn.username, conn->conn.username_len); } }
Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.128 php4/ext/ircg/ircg.c:1.129 --- php4/ext/ircg/ircg.c:1.128 Thu Feb 28 03:26:17 2002 +++ php4/ext/ircg/ircg.c Fri Mar 8 07:43:10 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.128 2002/02/28 08:26:17 sebastian Exp $ */ +/* $Id: ircg.c,v 1.129 2002/03/08 12:43:10 sas Exp $ */ /* {{{ includes */ @@ -147,6 +147,7 @@ union { unsigned char v; void *ptr; + smart_str *s; } para; } token_t; @@ -192,7 +193,8 @@ C_TO, C_MESSAGE, C_STRING, - C_PERCENT + C_PERCENT, + C_TERMINATE_1 /* auth by username */ }; enum { @@ -211,7 +213,7 @@ static void format_msg(const format_msg_t *fmt_msg, smart_str *channel, smart_str *to, smart_str *from, smart_str *msg, smart_str *result, - const char *username, int username_len); + const char *username, int username_len, int *status); static void msg_send(php_irconn_t *conn, smart_str *msg); @@ -260,7 +262,7 @@ #define FORMAT_MSG(conn, type, chan, to, from, msg, res, u, ulen) { \ format_msg(MSG(conn, type), chan, \ - to, from, msg, res, u, ulen); \ + to, from, msg, res, u, ulen, NULL); \ } /* }}} */ @@ -337,7 +339,7 @@ if (conn->file_fd != -1) { smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_DISCONNECTED), NULL, NULL, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_DISCONNECTED, NULL, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); @@ -553,6 +555,7 @@ /* associate mode bits with each command where applicable */ case 'c': NEW_TOKEN(C_CHANNEL, v) = mode; break; + case 'd': NEW_TOKEN(C_TERMINATE_1, v) = mode; break; case 't': NEW_TOKEN(C_TO, v) = mode; break; case 'f': NEW_TOKEN(C_FROM, v) = mode; break; case 'r': NEW_TOKEN(C_MESSAGE, v) = mode; break; @@ -576,7 +579,7 @@ /* {{{ format_msg */ static void format_msg(const format_msg_t *fmt_msg, smart_str *channel, smart_str *to, smart_str *from, smart_str *msg, smart_str *result, - const char *username, int username_len) + const char *username, int username_len, int *status) { smart_str encoded_msg = {0}; int encoded = 0; @@ -637,7 +640,7 @@ break; \ } - for (; ntoken -- > 0; i++) { + for (; ntoken-- > 0; i++) { switch (t[i].code) { case C_STRING: smart_str_append_ex(result, t[i].para.ptr, 1); break; case C_FROM: IRCG_APPEND(from); break; @@ -645,6 +648,13 @@ case C_CHANNEL: IRCG_APPEND(channel); break; case C_MESSAGE: IRCG_APPEND(msg); break; case C_PERCENT: smart_str_appendc_ex(result, '%', 1); break; + case C_TERMINATE_1: /* auth by username */ + if (ntoken > 0 && t[i+1].code == C_STRING) { + if (t[i+1].para.s->len == from->len + && strncasecmp(t[i+1].para.s->c, from->c, from->len) == 0) + *status = 1; + } else + *status = 1; } } @@ -687,6 +697,8 @@ /* {{{ Message-delivery */ static void msg_accum_send(php_irconn_t *conn, smart_str *msg) { + int n; + if (msg->c == 0) return; if (conn->file_fd != -1) { @@ -719,8 +731,31 @@ break; default: #if IRCG_API_VERSION - 0 >= 20010601 - if (irc_write_buf_append_ex(&conn->wb, msg, 0)) { - irc_disconnect(&conn->conn, "Write to HTTP client failed"); + if ((n = irc_write_buf_append_ex(&conn->wb, msg, 0))) { + const char *reason; + +#if IRCG_API_VERSION - 0 >= 20020308 + switch (n) { + case D_OVERFLOW: + reason = "Client is too slow, client-specific queue full"; + break; + case D_POLL_ERROR: + reason = "Poll failed. The connection is bad."; + break; + case D_CORRUPT_QUEUE: + reason = "Internal failure: Corrupt queue"; + break; + default: + if (n < 0) + reason = strerror(-n); + else +#else + { +#endif + reason = "Write to HTTP client failed for no reason"; + } + + irc_disconnect(&conn->conn, reason); } #elif IRCG_API_VERSION - 0 >= 20010302 irc_write_buf_append_ex(&conn->wb, msg, 0); @@ -765,6 +800,7 @@ if (real_msg_end) { format_msg_t *fmt_msg; smart_str tmp, tmp2; + int status = 0; *real_msg_end = '\0'; *token_end = '\0'; @@ -775,7 +811,10 @@ smart_str_setl(&tmp, real_msg, real_msg_end - real_msg); smart_str_setl(&tmp2, conn->conn.username, conn->conn.username_len); - format_msg(fmt_msg, chan, &tmp2, from, &tmp, result, conn->conn.username, conn->conn.username_len); + format_msg(fmt_msg, chan, &tmp2, from, &tmp, result, conn->conn.username, conn->conn.username_len, &status); + + if (status == 1) + irc_disconnect(&conn->conn, "Connection terminated by authenticated CTCP message"); } } } @@ -795,7 +834,7 @@ } else if (chan) { FORMAT_MSG(conn, FMT_MSG_CHAN, chan, &s_username, from, msg, &m, conn->conn.username, conn->conn.username_len); } else { - format_msg(MSG(conn, FMT_MSG_PRIV_TO_ME), NULL, &s_username, from, + FORMAT_MSG(conn, FMT_MSG_PRIV_TO_ME, NULL, &s_username, from, msg, &m, conn->conn.username, conn->conn.username_len); } @@ -808,7 +847,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_NICK), NULL, newnick, oldnick, NULL, + FORMAT_MSG(conn, FMT_MSG_NICK, NULL, newnick, oldnick, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -819,7 +858,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_USER), host, user, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_USER, host, user, nick, real_name, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -831,7 +870,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_SERVER), server, NULL, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_SERVER, server, NULL, nick, server_info, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -843,7 +882,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_IDLE), NULL, NULL, nick, + FORMAT_MSG(conn, FMT_MSG_WHOIS_IDLE, NULL, NULL, nick, idletime, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -853,7 +892,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_WHOIS_END), NULL, NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_WHOIS_END, NULL, NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -866,7 +905,7 @@ int i; for (i = 0; i < nr; i++) { - format_msg(MSG(conn, FMT_MSG_WHOIS_CHANNEL), &channels[i], NULL, + FORMAT_MSG(conn, FMT_MSG_WHOIS_CHANNEL, &channels[i], NULL, nick, NULL, &m, conn->conn.username, conn->conn.username_len); } msg_send(conn, &m); @@ -988,7 +1027,7 @@ smart_str_setl(&tmp, "IRC SERVER", sizeof("IRC SERVER") - 1); smart_str_setl(&s_username, ircc->username, ircc->username_len); - format_msg(MSG(conn, fatal ? FMT_MSG_FATAL_ERROR : FMT_MSG_ERROR), NULL, + FORMAT_MSG(conn, fatal ? FMT_MSG_FATAL_ERROR : FMT_MSG_ERROR, NULL, &s_username, &tmp, msg, &m, conn->conn.username, conn->conn.username_len); if (fatal) { @@ -1010,7 +1049,7 @@ php_irconn_t *conn = conn_data; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_BANLIST), channel, NULL, NULL, mask, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_BANLIST, channel, NULL, NULL, mask, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1019,7 +1058,7 @@ php_irconn_t *conn = conn_data; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_BANLIST_END), channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_BANLIST_END, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1031,14 +1070,14 @@ smart_str m = {0}; if (nr > 1) { - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_BEGIN), channel, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_BEGIN, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); for (i = 0; i < nr; i++) { - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_ELEMENT), channel, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_ELEMENT, channel, NULL, &users[i], NULL, &m, conn->conn.username, conn->conn.username_len); } - format_msg(MSG(conn, FMT_MSG_MASS_JOIN_END), channel, NULL, NULL, + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_END, channel, NULL, NULL, NULL, &m, conn->conn.username, conn->conn.username_len); } else { FORMAT_MSG(conn, FMT_MSG_JOIN, channel, NULL, &users[0], @@ -1054,7 +1093,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_TOPIC), channel, NULL, who, topic, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_TOPIC, channel, NULL, who, topic, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1066,7 +1105,7 @@ smart_str_setl(&s_username, ircc->username, ircc->username_len); - format_msg(MSG(conn, FMT_MSG_SELF_PART), channel, NULL, &s_username, + FORMAT_MSG(conn, FMT_MSG_SELF_PART, channel, NULL, &s_username, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1076,7 +1115,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_LEAVE), channel, NULL, user, NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_LEAVE, channel, NULL, user, NULL, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1085,7 +1124,7 @@ php_irconn_t *conn = dummy; smart_str m = {0}; - format_msg(MSG(conn, FMT_MSG_QUIT), NULL, NULL, user, msg, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_QUIT, NULL, NULL, user, msg, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1105,7 +1144,7 @@ if (conn->bailout_on_trivial && who->len == ircc->username_len && memcmp(who->c, ircc->username, who->len) == 0) { irc_disconnect(ircc, "Bailout on trivial: KICK"); } - format_msg(MSG(conn, FMT_MSG_KICK), channel, who, kicked_by, reason, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_KICK, channel, who, kicked_by, reason, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } @@ -1124,12 +1163,12 @@ smart_str_setl(&what, "0", 1); if (mode & IRCG_MODE_VOICE) { - format_msg(MSG(conn, FMT_MSG_MODE_VOICE), channel, nick, who, &what, + FORMAT_MSG(conn, FMT_MSG_MODE_VOICE, channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } if (mode & IRCG_MODE_OP) { - format_msg(MSG(conn, FMT_MSG_MODE_OP), channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_MODE_OP, channel, nick, who, &what, &m, conn->conn.username, conn->conn.username_len); msg_send(conn, &m); } } @@ -1137,7 +1176,7 @@ /* }}} */ /* {{{ proto bool ircg_set_on_die(int connection, string host, int port, string data) - Sets hostaction to be execute when connection dies */ + Sets hostaction to be executed when connection dies */ PHP_FUNCTION(ircg_set_on_die) { #ifdef IRCG_PENDING_URL @@ -1972,7 +2011,7 @@ if (l.c[0] == 1) { handle_ctcp(conn, NULL, &tmp2, &l, &m); } else { - format_msg(MSG(conn, FMT_MSG_PRIV_FROM_ME), NULL, + FORMAT_MSG(conn, FMT_MSG_PRIV_FROM_ME, NULL, &tmp, &tmp2, &l, &m, conn->conn.username, conn->conn.username_len); } }