sas Wed Nov 13 18:01:42 2002 EDT Modified files: /php4/ext/ircg ircg.c Log: always use the mass_join formats, when the server is sending a namelist always use the single join format, when the server is sending a JOIN combining both was originally seen as more convenient, but proved to be difficult when developing frontends. Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.137 php4/ext/ircg/ircg.c:1.138 --- php4/ext/ircg/ircg.c:1.137 Thu Oct 17 06:40:17 2002 +++ php4/ext/ircg/ircg.c Wed Nov 13 18:01:42 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.137 2002/10/17 10:40:17 sas Exp $ */ +/* $Id: ircg.c,v 1.138 2002/11/13 23:01:42 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; @@ -1386,10 +1415,14 @@ thttpd_register_on_close(http_closed_connection); thttpd_set_dont_close(); conn->fd = thttpd_get_fd(); + printf("conn->fd is %d\n", conn->fd); + fflush(stdout); 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; } + ADD_HEADER("Connection: close"); zend_hash_index_update(&h_fd2irconn, conn->fd, &Z_LVAL_PP(p1), sizeof(int), NULL); if (conn->file_fd == -1) { flush_data = conn; @@ -1818,7 +1851,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 +1881,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