sas Sat Feb 24 12:37:20 2001 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Replace the sixth and seventh parameter of ircg_pconnect()
with a connection-detail array. Currently, you can set
realname, password, ident. Those information are used
during the connection setup process.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.35 php4/ext/ircg/ircg.c:1.36
--- php4/ext/ircg/ircg.c:1.35 Sat Feb 24 04:37:18 2001
+++ php4/ext/ircg/ircg.c Sat Feb 24 12:37:19 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.35 2001/02/24 12:37:18 sas Exp $ */
+/* $Id: ircg.c,v 1.36 2001/02/24 20:37:19 sas Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -87,7 +87,8 @@
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 */
+ char *password; /* dito */
+ char *realname; /* dito */
} php_irconn_t;
static char *fmt_msgs_default[] = {
@@ -597,6 +598,14 @@
smart_str_sets(&m, irconn->password);
irc_set_password(conn, &m);
}
+
+#if defined(IRCG_API_VERSION) && IRCG_API_VERSION >= 20010225
+ if (irconn->realname) {
+ smart_str m;
+ smart_str_sets(&m, irconn->realname);
+ irc_set_realname(conn, &m);
+ }
+#endif
irc_register_hook(conn, IRCG_MSG, msg_handler);
irc_register_hook(conn, IRCG_QUIT, quit_handler);
@@ -636,26 +645,19 @@
PHP_FUNCTION(ircg_pconnect)
{
/* This should become an array very soon */
- zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL, **p6, **p7;
+ zval **p1, **p2, **p3, **p4 = NULL, **p5 = NULL, **p6;
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() > 7
- || zend_get_parameters_ex(ZEND_NUM_ARGS(), &p1, &p2, &p3, &p4,
&p5, &p6, &p7) == 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 7:
- convert_to_string_ex(p7);
- password = Z_STRVAL_PP(p7);
case 6:
- convert_to_string_ex(p6);
- ident = Z_STRVAL_PP(p6);
case 5:
case 4:
convert_to_string_ex(p4);
@@ -677,8 +679,28 @@
*/
conn = malloc(sizeof(*conn));
conn->fd = -1;
- conn->ident = ident;
- conn->password = password;
+ conn->ident = conn->password = conn->realname = NULL;
+ if (ZEND_NUM_ARGS() > 5 && Z_TYPE_PP(p6) == IS_ARRAY) {
+ zval **val;
+
+ if (zend_hash_find(Z_ARRVAL_PP(p6), "ident", sizeof("ident"),
+ (void **) &val) == SUCCESS) {
+ convert_to_string_ex(val);
+ conn->ident = Z_STRVAL_PP(val);
+ }
+
+ if (zend_hash_find(Z_ARRVAL_PP(p6), "password", sizeof("password"),
+ (void **) &val) == SUCCESS) {
+ convert_to_string_ex(val);
+ conn->password = Z_STRVAL_PP(val);
+ }
+
+ if (zend_hash_find(Z_ARRVAL_PP(p6), "realname", sizeof("realname"),
+ (void **) &val) == SUCCESS) {
+ convert_to_string_ex(val);
+ conn->realname = Z_STRVAL_PP(val);
+ }
+ }
zend_hash_init(&conn->ctcp_msgs, 10, NULL, NULL, 1);
if (irc_connect(username, register_hooks,
--
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]