cvs: php4(PHP_4_0_5) /ext/ircg config.m4 ircg.c php_ircg.h

From: Date: Sun, 22 Apr 2001 15:17:57 +0000
Subject: cvs: php4(PHP_4_0_5) /ext/ircg config.m4 ircg.c php_ircg.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5191@lists.php.net to get a copy of this message
sas Sun Apr 22 08:17:57 2001 EDT Modified files: (Branch: PHP_4_0_5) /php4/ext/ircg config.m4 ircg.c php_ircg.h Log: MFH allocation-related and thttpd-independence changes Index: php4/ext/ircg/config.m4 diff -u php4/ext/ircg/config.m4:1.5 php4/ext/ircg/config.m4:1.5.2.1 --- php4/ext/ircg/config.m4:1.5 Thu Mar 8 15:13:34 2001 +++ php4/ext/ircg/config.m4 Sun Apr 22 08:17:57 2001 @@ -16,6 +16,9 @@ PHP_EVAL_INCLINE($IRCG_CONFIG --cppflags) AC_ADD_LIBRARY_WITH_PATH(ircg, $PHP_IRCG/lib) AC_ADD_INCLUDE($PHP_IRCG/include) + if test "$PHP_SAPI" = "thttpd"; then + AC_DEFINE(IRCG_WITH_THTTPD, 1, [Whether thttpd is available]) + fi AC_DEFINE(HAVE_IRCG, 1, [Whether you want IRCG support]) PHP_EXTENSION(ircg, $ext_shared) fi Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.53 php4/ext/ircg/ircg.c:1.53.2.1 --- php4/ext/ircg/ircg.c:1.53 Sat Mar 10 15:51:56 2001 +++ php4/ext/ircg/ircg.c Sun Apr 22 08:17:57 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.53 2001/03/10 23:51:56 sas Exp $ */ +/* $Id: ircg.c,v 1.53.2.1 2001/04/22 15:17:57 sas Exp $ */ #include "php.h" #include "php_ini.h" @@ -62,6 +62,8 @@ FMT_MSG_WHOIS_END, FMT_MSG_MODE_VOICE, FMT_MSG_MODE_OP, + FMT_MSG_BANLIST, + FMT_MSG_BANLIST_END, NO_FMTS }; @@ -73,11 +75,15 @@ PHP_FE(ircg_join, NULL) PHP_FE(ircg_part, NULL) PHP_FE(ircg_msg, NULL) + PHP_FE(ircg_notice, NULL) PHP_FE(ircg_nick, NULL) PHP_FE(ircg_topic, NULL) PHP_FE(ircg_channel_mode, NULL) + PHP_FE(ircg_html_encode, NULL) PHP_FE(ircg_whois, NULL) PHP_FE(ircg_kick, NULL) + PHP_FE(ircg_ignore_add, NULL) + PHP_FE(ircg_ignore_del, NULL) PHP_FE(ircg_disconnect, NULL) PHP_FE(ircg_is_conn_alive, NULL) PHP_FE(ircg_lookup_format_messages, NULL) @@ -132,7 +138,9 @@ "%f is on channel %c<br />", "End of whois for %f<br />", "%f sets voice flag of %t to %m on %c<br />", - "%f sets channel operator flag of %t to %m on %c<br />" + "%f sets channel operator flag of %t to %m on %c<br />", + "banned from %c: %m<br />", + "end of ban list for %c<br />" }; #define MSG(conn, type) \ @@ -202,10 +210,10 @@ case '"': case '\\': case '\'': - smart_str_appendc(output, '\\'); + smart_str_appendc_ex(output, '\\', 1); /* fall-through */ default: - smart_str_appendc(output, *p); + smart_str_appendc_ex(output, *p, 1); } } } @@ -243,7 +251,7 @@ smart_str tmp = {0}; \ ircg_js_escape(what, &tmp); \ smart_str_append_ex(result, &tmp, 1); \ - smart_str_free(&tmp); \ + smart_str_free_ex(&tmp, 1); \ } else { \ smart_str_append_ex(result, what, 1); \ } @@ -308,7 +316,7 @@ if (encoded) smart_str_free(&encoded_msg); if (js_encoded) - smart_str_free(&js_encoded_msg); + smart_str_free_ex(&js_encoded_msg, 1); smart_str_0(result); } @@ -505,6 +513,24 @@ msg_send(conn, &m); } +static void banlist_handler(irconn_t *ircc, smart_str *channel, smart_str *mask, void *conn_data) +{ + php_irconn_t *conn = conn_data; + smart_str m = {0}; + + format_msg(MSG(conn, FMT_MSG_BANLIST), channel, NULL, NULL, mask, &m); + msg_send(conn, &m); +} + +static void end_of_banlist_handler(irconn_t *ircc, smart_str *channel, void *conn_data) +{ + php_irconn_t *conn = conn_data; + smart_str m = {0}; + + format_msg(MSG(conn, FMT_MSG_BANLIST_END), channel, NULL, NULL, NULL, &m); + msg_send(conn, &m); +} + static void user_add(irconn_t *ircc, smart_str *channel, smart_str *users, int nr, void *dummy) { @@ -630,6 +656,7 @@ PHP_FUNCTION(ircg_set_current) { +#ifdef IRCG_WITH_THTTPD zval **p1; php_irconn_t *conn; @@ -653,6 +680,7 @@ msg_empty_buffer(conn); RETURN_TRUE; +#endif } PHP_FUNCTION(ircg_new_window) @@ -707,6 +735,50 @@ #endif } +PHP_FUNCTION(ircg_ignore_add) +{ +#if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010402 + zval **args[2]; + php_irconn_t *conn; + smart_str s; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_long_ex(args[0]); + convert_to_string_ex(args[1]); + + conn = lookup_irconn(Z_LVAL_PP(args[0])); + if (!conn) RETURN_FALSE; + + smart_str_setl(&s, Z_STRVAL_PP(args[1]), Z_STRLEN_PP(args[1])); + irc_ignore_add(&conn->conn, &s, 1); +#endif +} + +PHP_FUNCTION(ircg_ignore_del) +{ +#if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010402 + zval **args[2]; + php_irconn_t *conn; + smart_str s; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_long_ex(args[0]); + convert_to_string_ex(args[1]); + + conn = lookup_irconn(Z_LVAL_PP(args[0])); + if (!conn) RETURN_FALSE; + + smart_str_setl(&s, Z_STRVAL_PP(args[1]), Z_STRLEN_PP(args[1])); + if (irc_ignore_del(&conn->conn, &s)) + RETURN_FALSE; + RETURN_TRUE; +#endif +} + PHP_FUNCTION(ircg_channel_mode) { #if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010227 @@ -752,6 +824,21 @@ #endif } +PHP_FUNCTION(ircg_html_encode) +{ + zval **p1; + smart_str res = {0}; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p1) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_string_ex(p1); + + ircg_mirc_color(Z_STRVAL_PP(p1), &res, Z_STRLEN_PP(p1)); + + RETVAL_STRINGL(res.c, res.len, 0); +} + PHP_FUNCTION(ircg_kick) { #if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010226 @@ -911,6 +998,11 @@ #if IRCG_API_VERSION >= 20010310 irc_register_hook(conn, IRCG_IDLE_RECV_QUEUE, idle_recv_queue); #endif + +#if IRCG_API_VERSION >= 20010416 + irc_register_hook(conn, IRCG_BANLIST, banlist_handler); + irc_register_hook(conn, IRCG_ENDOFBANLIST, end_of_banlist_handler); +#endif } static int ircg_copy_ctcp_msgs(zval **array, php_irconn_t *conn) @@ -1048,6 +1140,29 @@ irc_nick(&conn->conn, Z_STRVAL_PP(newnick)); + RETURN_TRUE; +} + +PHP_FUNCTION(ircg_notice) +{ + zval **id, **recipient, **msg; + php_irconn_t *conn; + smart_str l = {0}; + smart_str m = {0}; + smart_str tmp, tmp2; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &id, &recipient, &msg) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_long_ex(id); + convert_to_string_ex(recipient); + convert_to_string_ex(msg); + + conn = lookup_irconn(Z_LVAL_PP(id)); + + if (!conn) RETURN_FALSE; + + irc_handle_command(&conn->conn, "NOTICE", 2, Z_STRVAL_PP(recipient), Z_STRVAL_PP(msg)); RETURN_TRUE; } Index: php4/ext/ircg/php_ircg.h diff -u php4/ext/ircg/php_ircg.h:1.8 php4/ext/ircg/php_ircg.h:1.8.2.1 --- php4/ext/ircg/php_ircg.h:1.8 Wed Mar 7 14:18:50 2001 +++ php4/ext/ircg/php_ircg.h Sun Apr 22 08:17:57 2001 @@ -36,7 +36,11 @@ PHP_FUNCTION(ircg_register_current_conn); PHP_FUNCTION(ircg_whois); PHP_FUNCTION(ircg_msg); +PHP_FUNCTION(ircg_notice); PHP_FUNCTION(ircg_nick); +PHP_FUNCTION(ircg_html_encode); +PHP_FUNCTION(ircg_ignore_add); +PHP_FUNCTION(ircg_ignore_del); PHP_FUNCTION(ircg_kick); PHP_FUNCTION(ircg_topic); PHP_FUNCTION(ircg_channel_mode);

« previous php.cvs (#5191) next »