sas Tue Apr 1 03:00:42 2003 EDT Modified files: /php4/ext/ircg ircg.c Log: Intermediate commit of relocation map integration Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.166 php4/ext/ircg/ircg.c:1.167 --- php4/ext/ircg/ircg.c:1.166 Mon Mar 17 08:02:50 2003 +++ php4/ext/ircg/ircg.c Tue Apr 1 03:00:42 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.166 2003/03/17 13:02:50 hholzgra Exp $ */ +/* $Id: ircg.c,v 1.167 2003/04/01 08:00:42 sas Exp $ */ /* {{{ includes */ @@ -78,6 +78,9 @@ struct php_ircg_global *php_ircg; +static void *php_ircg_cb_msg_handle; +static void *php_ircg_cb_wbuf_handle; + /* initialized in the IRCG control process, so that we can avoid locking */ struct cache_entry *php_ircg_cache_entries; @@ -215,7 +218,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("ircg.work_dir", "/tmp/ircg", PHP_INI_ALL, OnUpdateString, work_dir, zend_ircg_globals, ircg_globals) - STD_PHP_INI_ENTRY("ircg.shared_mem_size", "10000000", PHP_INI_ALL, OnUpdateLong, shared_mem_size, zend_ircg_globals, ircg_globals) + STD_PHP_INI_ENTRY("ircg.shared_mem_size", "10000000", PHP_INI_ALL, OnUpdateInt, shared_mem_size, zend_ircg_globals, ircg_globals) STD_PHP_INI_ENTRY("ircg.control_user", "nobody", PHP_INI_ALL, OnUpdateString, control_user, zend_ircg_globals, ircg_globals) PHP_INI_END() @@ -1022,8 +1025,14 @@ put_irconn(data); } +IRCG_CB_MAP_START(php_ircg_cb_wbuf) + IRCG_CB_MAP_ENTRY(wbuf_closed_conn) + IRCG_CB_MAP_ENTRY(wbuf_add_complete) +IRCG_CB_MAP_END() + static void wbuf_hooks(irc_write_buf *p, void *data) { + irc_write_buf_reg(p, WB_MAP_HANDLE, (irc_hook) php_ircg_cb_wbuf_handle); irc_write_buf_reg(p, WB_CLOSED_CONN, wbuf_closed_conn); irc_write_buf_reg(p, WB_ADD_COMPLETE, wbuf_add_complete); } @@ -1548,7 +1557,6 @@ php_ircg_token_compiler("", &fmt_msgs.fmt_msgs[i]); } - IRCG_LOCK_GET(php_ircg->fmt_msgs_lock); ircg_hash_update(&php_ircg->h_fmt_msgs, Z_STRVAL_PP(p1), Z_STRLEN_PP(p1), &fmt_msgs, sizeof(fmt_msgs), NULL); @@ -1558,6 +1566,37 @@ } /* }}} */ +IRCG_CB_MAP_START(php_ircg_cb_msg) + IRCG_CB_MAP_ENTRY(msg_handler) + IRCG_CB_MAP_ENTRY(quit_handler) + IRCG_CB_MAP_ENTRY(error_handler) + IRCG_CB_MAP_ENTRY(nick_handler) + IRCG_CB_MAP_ENTRY(part_handler) + IRCG_CB_MAP_ENTRY(user_leave) + IRCG_CB_MAP_ENTRY(user_kick) + IRCG_CB_MAP_ENTRY(user_quit) + IRCG_CB_MAP_ENTRY(new_topic) + IRCG_CB_MAP_ENTRY(whois_user_handler) + IRCG_CB_MAP_ENTRY(whois_server_handler) + IRCG_CB_MAP_ENTRY(whois_idle_handler) + IRCG_CB_MAP_ENTRY(whois_channels_handler) + IRCG_CB_MAP_ENTRY(end_of_whois_handler) + IRCG_CB_MAP_ENTRY(mode_channel_handler) + IRCG_CB_MAP_ENTRY(idle_recv_queue) + IRCG_CB_MAP_ENTRY(banlist_handler) + IRCG_CB_MAP_ENTRY(end_of_banlist_handler) + IRCG_CB_MAP_ENTRY(list_handler) + IRCG_CB_MAP_ENTRY(listend_handler) +#if IRCG_API_VERSION >= 20021109 + IRCG_CB_MAP_ENTRY(user_add_ex) +#else + IRCG_CB_MAP_ENTRY(user_add) +#endif + IRCG_CB_MAP_ENTRY(whoreply_handler) + IRCG_CB_MAP_ENTRY(endofwho_handler) + IRCG_CB_MAP_ENTRY(invite_handler) +IRCG_CB_MAP_END() + /* {{{ register_hooks */ static void register_hooks(irconn_t *conn, void *dummy) { @@ -1644,6 +1683,8 @@ #if IRCG_API_VERSION >= 20021117 IFMSG(FMT_MSG_INVITE, IRCG_INVITE, invite_handler); #endif + + irc_set_map_handle(conn, php_ircg_cb_msg_handle); } /* }}} */ @@ -2104,20 +2145,8 @@ } return 0; } - -static void setup(int stage) -{ - if (stage == 0) { - ircg_fetch_area("php-ircg-main", &php_ircg, sizeof *php_ircg, init); - } else if (stage == 1) { - php_ircg_cache_entries = malloc(sizeof(struct cache_entry) * NR_CACHE_ENTRIES); - memset(php_ircg_cache_entries, 0, sizeof(struct cache_entry) * NR_CACHE_ENTRIES); - } else if (stage == -1) { - memset(php_ircg, 0x78, sizeof *php_ircg); - IRCG_SHARED_FREE(php_ircg); - php_ircg = NULL; - } -} + +static void setup(int stage); static int initialized; @@ -2230,6 +2259,25 @@ DISPLAY_INI_ENTRIES(); } /* }}} */ + + +static void setup(int stage) +{ + if (stage == 0) { + ircg_fetch_area("php-ircg-main", &php_ircg, sizeof *php_ircg, init); + + ircg_register_relocation_map("php_ircg_msg_handler", php_ircg_cb_msg); + ircg_register_relocation_map("php_ircg_wbuf_handler", php_ircg_cb_wbuf); + + } else if (stage == 1) { + php_ircg_cache_entries = malloc(sizeof(struct cache_entry) * NR_CACHE_ENTRIES); + memset(php_ircg_cache_entries, 0, sizeof(struct cache_entry) * NR_CACHE_ENTRIES); + } else if (stage == -1) { + memset(php_ircg, 0x78, sizeof *php_ircg); + IRCG_SHARED_FREE(php_ircg); + php_ircg = NULL; + } +} /* * Local variables:
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php