sas Wed Aug 13 14:59:13 2003 EDT
Modified files:
/php-src/ext/ircg ircg.c
Log:
MFH Fix CTCP handling so that commands without parameters are processed
MFH Use %ld for time_t's
MFH Provide a warning when irc_connect fails
Index: php-src/ext/ircg/ircg.c
diff -u php-src/ext/ircg/ircg.c:1.194 php-src/ext/ircg/ircg.c:1.195
--- php-src/ext/ircg/ircg.c:1.194 Tue Jul 8 17:46:19 2003
+++ php-src/ext/ircg/ircg.c Wed Aug 13 14:59:13 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.194 2003/07/08 21:46:19 sas Exp $ */
+/* $Id: ircg.c,v 1.195 2003/08/13 18:59:13 sas Exp $ */
/* {{{ includes */
@@ -517,36 +517,42 @@
static void handle_ctcp(php_irconn_t *conn, smart_str *chan, smart_str *from,
smart_str *to, smart_str *msg, smart_str *result)
{
+ char *token;
char *token_end;
- char *real_msg;
- char *real_msg_end;
+ char *ctcp_arg;
+ char *ctcp_arg_end;
+ format_msg_t **fmt_msg_p;
+ smart_str tmp = {0};
+ int status = 0;
- for (token_end = msg->c + 1; *token_end; token_end++)
- if (!isalpha(*token_end)) break;
+ token = msg->c + 1;
+ token_end = strchr(token, 1);
- if (*token_end != '\001') {
- real_msg = token_end + 1;
+ if (!token_end) return;
- real_msg_end = strchr(real_msg, '\001');
- if (real_msg_end) {
- format_msg_t **fmt_msg_p;
- smart_str tmp;
- int status = 0;
-
- *real_msg_end = '\0';
- *token_end = '\0';
-
- if (ircg_hash_find(&conn->ctcp_msgs, msg->c + 1, token_end -
msg->c - 1, (void **) &fmt_msg_p) != SUCCESS) {
- return;
- }
-
- smart_str_setl(&tmp, real_msg, real_msg_end - real_msg);
-
- format_msg(*fmt_msg_p, chan, to, from, &tmp, result,
conn->conn.username, conn->conn.username_len, &status);
+ *token_end = 0;
+
+ ctcp_arg = strchr(token, ' ');
+
+ if (ctcp_arg) {
+ ctcp_arg_end = token_end;
+ token_end = ctcp_arg;
+ *token_end = 0;
+ ctcp_arg++;
+ smart_str_setl(&tmp, ctcp_arg, ctcp_arg_end - ctcp_arg);
+ }
+
+ if (ircg_hash_find(&conn->ctcp_msgs, token, token_end - token,
+ (void **) &fmt_msg_p) != SUCCESS) {
+ return;
+ }
+
+ format_msg(*fmt_msg_p, chan, to, from, &tmp, result,
+ conn->conn.username, conn->conn.username_len, &status);
- if (status == 1)
- irc_disconnect(&conn->conn, "Connection terminated by
authenticated CTCP message");
- }
+ if (status == 1) {
+ irc_disconnect(&conn->conn, "Connection terminated by "
+ "authenticated CTCP message");
}
}
@@ -949,7 +955,7 @@
} else if ((php_ircg_now() - conn->login) > WINDOW_TIMEOUT) {
char buf[1024];
- sprintf(buf, "timeout after %d seconds (%d, %d)",
+ sprintf(buf, "timeout after %ld seconds (%ld, %ld)",
php_ircg_now()-conn->login,
php_ircg_now(), conn->login);
irc_disconnect(ircc, buf);
@@ -2158,6 +2164,7 @@
if (drop_ref)
fmt_msgs_drop_ref(fmt_msgs);
IRCG_SHARED_FREE(conn);
+ php_error(E_WARNING, "%s(): irc_connect() failed prematurely",
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php