sas Wed Jan 22 04:14:57 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/ircg ircg.c Log: Fix for treating a NAMES list as single join Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.137.2.1 php4/ext/ircg/ircg.c:1.137.2.2 --- php4/ext/ircg/ircg.c:1.137.2.1 Tue Dec 31 11:34:47 2002 +++ php4/ext/ircg/ircg.c Wed Jan 22 04:14:57 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.137.2.1 2002/12/31 16:34:47 sebastian Exp $ */ +/* $Id: ircg.c,v 1.137.2.2 2003/01/22 09:14:57 sas Exp $ */ /* {{{ includes */ @@ -1128,32 +1128,61 @@ msg_send(conn, &m); } -static void user_add(irconn_t *ircc, smart_str *channel, smart_str *users, - int nr, void *dummy) +static void user_add_single(php_irconn_t *conn, smart_str *channel, smart_str *users) +{ + smart_str m = {0}; + FORMAT_MSG(conn, FMT_MSG_JOIN, channel, NULL, &users[0], + NULL, &m, conn->conn.username, conn->conn.username_len); + FORMAT_MSG(conn, FMT_MSG_JOIN_LIST_END, channel, NULL, NULL, + NULL, &m, conn->conn.username, conn->conn.username_len); + msg_send(conn, &m); +} + +static void user_add_multiple(php_irconn_t *conn, smart_str *channel, smart_str +*users, int nr) { - php_irconn_t *conn = dummy; int i; smart_str m = {0}; - if (nr > 1) { - 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(conn, FMT_MSG_MASS_JOIN_ELEMENT, channel, NULL, - &users[i], NULL, &m, conn->conn.username, conn->conn.username_len); - } - - 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], - NULL, &m, conn->conn.username, conn->conn.username_len); - FORMAT_MSG(conn, FMT_MSG_JOIN_LIST_END, 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(conn, FMT_MSG_MASS_JOIN_ELEMENT, channel, NULL, + &users[i], NULL, &m, conn->conn.username, +conn->conn.username_len); } + + FORMAT_MSG(conn, FMT_MSG_MASS_JOIN_END, channel, NULL, NULL, + NULL, &m, conn->conn.username, conn->conn.username_len); + + msg_send(conn, &m); } +#if IRCG_API_VERSION >= 20021109 + +static void user_add_ex(irconn_t *ircc, smart_str *channel, smart_str *users, + int nr, int namelist, void *dummy) +{ + if (namelist) { + user_add_multiple(dummy, channel, users, nr); + } else { + user_add_single(dummy, channel, users); + } +} + +#else + +static void user_add(irconn_t *ircc, smart_str *channel, smart_str *users, + int nr, void *dummy) +{ + if (nr > 1) { + user_add_multiple(dummy, channel, users, nr); + } else { + user_add_single(dummy, channel, users); + } +} + +#endif + static void new_topic(irconn_t *ircc, smart_str *channel, smart_str *who, smart_str *topic, void *dummy) { php_irconn_t *conn = dummy; @@ -1388,6 +1417,7 @@ conn->fd = thttpd_get_fd(); if (fcntl(conn->fd, F_GETFL) == -1) { zend_hash_index_del(&h_irconn, Z_LVAL_PP(p1)); + php_error(E_WARNING, "current fd is not valid"); RETURN_FALSE; } zend_hash_index_update(&h_fd2irconn, conn->fd, &Z_LVAL_PP(p1), sizeof(int), NULL); @@ -1818,7 +1848,6 @@ IFMSG(FMT_MSG_NICK, IRCG_NICK, nick_handler); IFMSG(FMT_MSG_SELF_PART, IRCG_PART, part_handler); - IFMSG(FMT_MSG_MASS_JOIN_ELEMENT, IRCG_USER_ADD, user_add); IFMSG(FMT_MSG_LEAVE, IRCG_USER_LEAVE, user_leave); IFMSG(FMT_MSG_KICK, IRCG_USER_KICK, user_kick); IFMSG(FMT_MSG_QUIT, IRCG_USER_QUIT, user_quit); @@ -1849,6 +1878,12 @@ /* RPL_LIST/RPL_LISTEND */ irc_register_hook(conn, IRCG_LIST, list_handler); irc_register_hook(conn, IRCG_LISTEND, listend_handler); +#endif + +#if IRCG_API_VERSION >= 20021109 + IFMSG(FMT_MSG_MASS_JOIN_ELEMENT, IRCG_USER_ADD_EX, user_add_ex); +#else + IFMSG(FMT_MSG_MASS_JOIN_ELEMENT, IRCG_USER_ADD, user_add); #endif }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php