cvs: php4 /ext/ircg ircg.c

From: Date: Wed, 07 Mar 2001 20:45:02 +0000
Subject: cvs: php4 /ext/ircg ircg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4431@lists.php.net to get a copy of this message
sas Wed Mar 7 12:45:02 2001 EDT Modified files: /php4/ext/ircg ircg.c Log: Move binary compat check to the module init function; Add initial support for channel modes. Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.45 php4/ext/ircg/ircg.c:1.46 --- php4/ext/ircg/ircg.c:1.45 Wed Mar 7 12:24:28 2001 +++ php4/ext/ircg/ircg.c Wed Mar 7 12:45:02 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.45 2001/03/07 20:24:28 sas Exp $ */ +/* $Id: ircg.c,v 1.46 2001/03/07 20:45:02 sas Exp $ */ #include "php.h" #include "php_ini.h" @@ -64,6 +64,8 @@ FMT_MSG_WHOIS_IDLE, FMT_MSG_WHOIS_CHANNEL, FMT_MSG_WHOIS_END, + FMT_MSG_MODE_VOICE, + FMT_MSG_MODE_OP, NO_FMTS }; @@ -518,6 +520,32 @@ msg_send(conn, &m); } +#if IRCG_API_VERSION >= 20010307 +static void mode_channel_handler(irconn_t *ircc, smart_str *nick, + smart_str *channel, smart_str *who, int mode, int give, void *dummy, + void *dummy2) +{ + php_irconn_t *conn = dummy; + smart_str m = {0}; + smart_str what; + + if (give) + smart_str_setl(&what, "1", 1); + else + smart_str_setl(&what, "0", 1); + + if (mode & IRCG_MODE_VOICE) { + format_msg(MSG(conn, FMT_MSG_MODE_VOICE), channel, nick, who, &what, + &m); + msg_send(conn, &m); + } + if (mode & IRCG_MODE_OP) { + format_msg(MSG(conn, FMT_MSG_MODE_OP), channel, nick, who, &what, &m); + msg_send(conn, &m); + } +} +#endif + static void http_closed_connection(int fd) { int *id, stored_id; @@ -741,15 +769,6 @@ static void register_hooks(irconn_t *conn, void *dummy) { php_irconn_t *irconn = dummy; - -#if IRCG_API_VERSION >= 20010307 - if (irc_sizeof_irconn() != sizeof(irconn_t)) { - printf("FATAL: The size of the irconn_t structure has grown " - "since you compiled PHP. Please rebuild PHP against " - "the correct IRCG header files.\n"); - exit(1); - } -#endif if (irconn->ident) { smart_str m; @@ -792,6 +811,10 @@ irc_register_hook(conn, IRCG_WHOISCHANNELS, whois_channels_handler); irc_register_hook(conn, IRCG_ENDOFWHOIS, end_of_whois_handler); #endif + +#if IRCG_API_VERSION >= 20010307 + irc_register_hook(conn, IRCG_MODE_CHANNEL, mode_channel_handler); +#endif } static int ircg_copy_ctcp_msgs(zval **array, php_irconn_t *conn) @@ -1000,6 +1023,15 @@ /* Remove comments if you have entries in php.ini REGISTER_INI_ENTRIES(); */ + +#if IRCG_API_VERSION >= 20010307 + if (irc_sizeof_irconn() != sizeof(irconn_t)) { + printf("FATAL: The size of the irconn_t structure has grown " + "since you compiled PHP. Please rebuild PHP against " + "the correct IRCG header files.\n"); + exit(1); + } +#endif zend_hash_init(&h_fmt_msgs, 0, NULL, fmt_msgs_dtor, 1); zend_hash_init(&h_fd2irconn, 0, NULL, NULL, 1);

« previous php.cvs (#4431) next »