cvs: php4 /ext/ircg ircg.c php_ircg.h

From: Date: Mon, 05 Nov 2001 14:38:49 +0000
Subject: cvs: php4 /ext/ircg ircg.c php_ircg.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8084@lists.php.net to get a copy of this message
sas Mon Nov 5 09:38:49 2001 EDT Modified files: /php4/ext/ircg ircg.c php_ircg.h Log: Support requesting a resource upon the irc connection end Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.111 php4/ext/ircg/ircg.c:1.112 --- php4/ext/ircg/ircg.c:1.111 Thu Oct 11 19:32:59 2001 +++ php4/ext/ircg/ircg.c Mon Nov 5 09:38:49 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.111 2001/10/11 23:32:59 ssb Exp $ */ +/* $Id: ircg.c,v 1.112 2001/11/05 14:38:49 sas Exp $ */ #include <time.h> @@ -81,6 +81,7 @@ /* {{{ ircg_functions[] */ function_entry ircg_functions[] = { + PHP_FE(ircg_set_on_die, NULL) PHP_FE(ircg_pconnect, NULL) PHP_FE(ircg_set_current, NULL) PHP_FE(ircg_join, NULL) @@ -141,7 +142,14 @@ php_fmt_msgs_t *fmt_msgs; irc_write_buf wb; HashTable ctcp_msgs; + + char *od_data; /* On_Die */ + size_t od_len; + struct in_addr od_ip; + short od_port; + char bailout_on_trivial; /* Whether to handle trivial errors as fatal */ + char *ident; /* NOT available outside of ircg_pconnect or register_hooks */ char *password; /* dito */ char *realname; /* dito */ @@ -276,6 +284,14 @@ zend_hash_destroy(&conn->ctcp_msgs); if (conn->buffer.c) smart_str_free_ex(&conn->buffer, 1); + + if (conn->od_port) { +#ifdef IRCG_PENDING_URL + irc_add_pending_url(conn->od_ip, conn->od_port, conn->od_data, conn->od_len); +#endif + free(conn->od_data); + } + free(conn); } @@ -1027,6 +1043,35 @@ zend_hash_index_del(&h_irconn, stored_id); } +PHP_FUNCTION(ircg_set_on_die) +{ + zval **p1, **p2, **p3, **p4; + php_irconn_t *conn; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p1, &p2, &p3, &p4) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_long_ex(p1); + + conn = lookup_irconn(Z_LVAL_PP(p1)); + + if (!conn) RETURN_FALSE; + + convert_to_string_ex(p2); + convert_to_long_ex(p3); + convert_to_string_ex(p4); + + if (inet_aton(Z_STRVAL_PP(p2), &conn->od_ip) == 0) + RETURN_FALSE; + + conn->od_port = Z_LVAL_PP(p3); + conn->od_data = malloc(Z_STRLEN_PP(p4)); + memcpy(conn->od_data, Z_STRVAL_PP(p4), Z_STRLEN_PP(p4)); + conn->od_len = Z_STRLEN_PP(p4); + + RETURN_TRUE; +} + PHP_FUNCTION(ircg_get_username) { zval **p1; @@ -1041,7 +1086,7 @@ if (!conn) RETURN_FALSE; - RETVAL_STRINGL(conn->conn.username, conn->conn.username_len, 1); + RETVAL_STRINGL((char *) conn->conn.username, conn->conn.username_len, 1); } PHP_FUNCTION(ircg_set_current) @@ -1631,6 +1676,7 @@ } } + conn->od_port = 0; conn->fmt_msgs = fmt_msgs; if (irc_connect(username, register_hooks, conn, server, port, &conn->conn)) { @@ -1638,7 +1684,7 @@ RETURN_FALSE; } irc_connects++; - zend_hash_init(&conn->ctcp_msgs, 10, NULL, ctcp_msgs_dtor, 1); + zend_hash_init(&conn->ctcp_msgs, 10, NULL, (dtor_func_t) ctcp_msgs_dtor, 1); if (p5 && Z_TYPE_PP(p5) == IS_ARRAY) { ircg_copy_ctcp_msgs(p5, conn); } Index: php4/ext/ircg/php_ircg.h diff -u php4/ext/ircg/php_ircg.h:1.15 php4/ext/ircg/php_ircg.h:1.16 --- php4/ext/ircg/php_ircg.h:1.15 Fri Aug 10 10:42:01 2001 +++ php4/ext/ircg/php_ircg.h Mon Nov 5 09:38:49 2001 @@ -29,6 +29,7 @@ #define PHP_IRCG_API #endif +PHP_FUNCTION(ircg_set_on_die); PHP_FUNCTION(ircg_pconnect); PHP_FUNCTION(ircg_join); PHP_FUNCTION(ircg_set_current);

« previous php.cvs (#8084) next »