sas Wed Feb 21 11:58:32 2001 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Allow users to set the ident string which we use to register with
the IRC server.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.33 php4/ext/ircg/ircg.c:1.34
--- php4/ext/ircg/ircg.c:1.33 Sun Feb 18 04:44:34 2001
+++ php4/ext/ircg/ircg.c Wed Feb 21 11:58:32 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.33 2001/02/18 12:44:34 sas Exp $ */
+/* $Id: ircg.c,v 1.34 2001/02/21 19:58:32 sas Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -86,6 +86,7 @@
php_fmt_msgs_t *fmt_msgs;
irc_write_buf wb;
HashTable ctcp_msgs;
+ char *ident; /* NOT available outside of ircg_pconnect or register_hooks */
} php_irconn_t;
static char *fmt_msgs_default[] = {
@@ -580,6 +581,15 @@
static void register_hooks(irconn_t *conn, void *dummy)
{
+ php_irconn_t *irconn = dummy;
+
+ if (irconn->ident) {
+ smart_str m;
+
+ smart_str_sets(&m, irconn->ident);
+ irc_set_ident(conn, &m);
+ }
+
irc_register_hook(conn, IRCG_MSG, msg_handler);
irc_register_hook(conn, IRCG_QUIT, quit_handler);
irc_register_hook(conn, IRCG_ERROR, error_handler);
@@ -617,21 +627,23 @@
PHP_FUNCTION(ircg_pconnect)
{
- zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL;
+ zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL, **p6;
const char *username;
const char *server = "0";
+ const char *ident = NULL;
int port = 6667;
php_fmt_msgs_t *fmt_msgs = NULL;
php_irconn_t *conn;
- if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 5
- || zend_get_parameters_ex(ZEND_NUM_ARGS(), &p1, &p2, &p3, &p4,
&p5) == FAILURE)
+ if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 6
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &p1, &p2, &p3, &p4,
+&p5, &p6) == FAILURE)
WRONG_PARAM_COUNT;
switch (ZEND_NUM_ARGS()) {
+ case 6:
+ convert_to_string_ex(p6);
+ ident = Z_STRVAL_PP(p6);
case 5:
- if (Z_TYPE_PP(p5) != IS_ARRAY)
- WRONG_PARAM_COUNT;
case 4:
convert_to_string_ex(p4);
fmt_msgs = lookup_fmt_msgs(p4);
@@ -652,6 +664,7 @@
*/
conn = malloc(sizeof(*conn));
conn->fd = -1;
+ conn->ident = ident;
zend_hash_init(&conn->ctcp_msgs, 10, NULL, NULL, 1);
if (irc_connect(username, register_hooks,
@@ -659,9 +672,10 @@
free(conn);
RETURN_FALSE;
}
- if (p5) {
+ if (p5 && Z_TYPE_PP(p5) == IS_ARRAY) {
ircg_copy_ctcp_msgs(p5, conn);
}
+ conn->ident = NULL;
conn->fmt_msgs = fmt_msgs;
irconn_id++;
conn->irconn_id = irconn_id;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]