cvs: php4 /ext/ircg ircg.c

From: Date: Sat, 24 Feb 2001 12:37:19 +0000
Subject: cvs: php4 /ext/ircg ircg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4247@lists.php.net to get a copy of this message
sas Sat Feb 24 04:37:19 2001 EDT Modified files: /php4/ext/ircg ircg.c Log: Add the ability to set a connection password Index: php4/ext/ircg/ircg.c diff -u php4/ext/ircg/ircg.c:1.34 php4/ext/ircg/ircg.c:1.35 --- php4/ext/ircg/ircg.c:1.34 Wed Feb 21 11:58:32 2001 +++ php4/ext/ircg/ircg.c Sat Feb 24 04:37:18 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ircg.c,v 1.34 2001/02/21 19:58:32 sas Exp $ */ +/* $Id: ircg.c,v 1.35 2001/02/24 12:37:18 sas Exp $ */ #include "php.h" #include "php_ini.h" @@ -87,6 +87,7 @@ irc_write_buf wb; HashTable ctcp_msgs; char *ident; /* NOT available outside of ircg_pconnect or register_hooks */ + char *password; /* NOT available outside of ircg_pconnect or register_hooks */ } php_irconn_t; static char *fmt_msgs_default[] = { @@ -589,6 +590,13 @@ smart_str_sets(&m, irconn->ident); irc_set_ident(conn, &m); } + + if (irconn->password) { + smart_str m; + + smart_str_sets(&m, irconn->password); + irc_set_password(conn, &m); + } irc_register_hook(conn, IRCG_MSG, msg_handler); irc_register_hook(conn, IRCG_QUIT, quit_handler); @@ -627,19 +635,24 @@ PHP_FUNCTION(ircg_pconnect) { - zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL, **p6; + /* This should become an array very soon */ + zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL, **p6, **p7; const char *username; const char *server = "0"; const char *ident = NULL; + const char *password = NULL; int port = 6667; php_fmt_msgs_t *fmt_msgs = NULL; php_irconn_t *conn; - if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 6 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &p1, &p2, &p3, &p4, &p5, &p6) == FAILURE) + if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 7 + || zend_get_parameters_ex(ZEND_NUM_ARGS(), &p1, &p2, &p3, &p4, &p5, &p6, &p7) == FAILURE) WRONG_PARAM_COUNT; switch (ZEND_NUM_ARGS()) { + case 7: + convert_to_string_ex(p7); + password = Z_STRVAL_PP(p7); case 6: convert_to_string_ex(p6); ident = Z_STRVAL_PP(p6); @@ -665,6 +678,7 @@ conn = malloc(sizeof(*conn)); conn->fd = -1; conn->ident = ident; + conn->password = password; zend_hash_init(&conn->ctcp_msgs, 10, NULL, NULL, 1); if (irc_connect(username, register_hooks, @@ -675,7 +689,7 @@ if (p5 && Z_TYPE_PP(p5) == IS_ARRAY) { ircg_copy_ctcp_msgs(p5, conn); } - conn->ident = NULL; + conn->password = conn->ident = NULL; conn->fmt_msgs = fmt_msgs; irconn_id++; conn->irconn_id = irconn_id;

« previous php.cvs (#4247) next »