cvs: php4 /ext/ircg ircg.c
| From: | Sascha Schumann | Date: | Wed, 15 Nov 2000 23:38:46 +0000 |
| Subject: | cvs: php4 /ext/ircg ircg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2629@lists.php.net to get a copy of this message | ||
sas Wed Nov 15 15:38:46 2000 EDT
Modified files:
/php4/ext/ircg ircg.c
Log:
Fix bug with handling multiple users in user_add and add new_topic handler.
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.3 php4/ext/ircg/ircg.c:1.4
--- php4/ext/ircg/ircg.c:1.3 Tue Nov 14 08:19:31 2000
+++ php4/ext/ircg/ircg.c Wed Nov 15 15:38:46 2000
@@ -41,6 +41,7 @@
FMT_MSG_LEAVE,
FMT_MSG_JOIN,
FMT_MSG_KICK,
+ FMT_MSG_TOPIC,
NO_FMTS
};
@@ -68,12 +69,13 @@
} php_irconn_t;
static char *fmt_msgs_default[] = {
- "%f@%c: %m<br>\n",
- "%f: %m<br>\n",
- "To %t: %m<br>\n",
- "%f leaves %c<br>\n",
- "%f joins %c<br>\n",
- "%t was kicked by %f from %c (%m)<br>\n"
+ "%f@%c: %m<br>",
+ "%f: %m<br>",
+ "To %t: %m<br>",
+ "%f leaves %c<br>",
+ "%f joins %c<br>",
+ "%t was kicked by %f from %c (%m)<br>",
+ "%f changes topic on %c to %m<br>"
};
#define MSG(conn, type) \
@@ -207,6 +209,7 @@
smart_str m = {0};
for (i = 0; i < nr; i++) {
+ m.len = 0;
format_msg(MSG(conn, FMT_MSG_JOIN), channel, NULL, users[i].c,
"", &m);
msg_send(conn, &m);
@@ -214,6 +217,16 @@
smart_str_free_ex(&m, 1);
}
+static void new_topic(irconn_t *ircc, const char *channel, smart_str *who, smart_str *topic, void
*dummy)
+{
+ php_irconn_t *conn = dummy;
+ smart_str m = {0};
+
+ format_msg(MSG(conn, FMT_MSG_TOPIC), channel, NULL, who->c, topic->c, &m);
+ msg_send(conn, &m);
+ smart_str_free_ex(&m, 1);
+}
+
static void user_leave(irconn_t *ircc, const char *channel, smart_str *user, void *dummy)
{
php_irconn_t *conn = dummy;
@@ -295,7 +308,7 @@
if (!conn) RETURN_FALSE;
- irc_join(&conn->conn, Z_STRVAL_PP(p2), NULL, NULL, user_add, user_leave, user_kick, conn);
+ irc_join(&conn->conn, Z_STRVAL_PP(p2), NULL, NULL, user_add, user_leave, user_kick,
new_topic, conn);
RETVAL_TRUE;
}
@@ -358,7 +371,7 @@
h = HASH_OF(*p4);
for (i = 0; i < NO_FMTS; i++) {
- if (zend_hash_index_find(h, i, &arg) == SUCCESS
+ if (zend_hash_index_find(h, i, (void **) &arg) == SUCCESS
&& Z_STRLEN_PP(arg)) {
conn->fmt_msgs[i] = strdup(Z_STRVAL_PP(arg));
} else