sas Wed Aug 13 14:53:43 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/ircg ircg.c
Log:
Fix CTCP handling so that commands without parameters are processed
Use %ld for time_t's
Provide a warning when irc_connect fails
Index: php-src/ext/ircg/ircg.c
diff -u php-src/ext/ircg/ircg.c:1.137.2.15 php-src/ext/ircg/ircg.c:1.137.2.16
--- php-src/ext/ircg/ircg.c:1.137.2.15 Tue Jul 8 00:25:40 2003
+++ php-src/ext/ircg/ircg.c Wed Aug 13 14:53:42 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ircg.c,v 1.137.2.15 2003/07/08 04:25:40 sas Exp $ */
+/* $Id: ircg.c,v 1.137.2.16 2003/08/13 18:53:42 sas Exp $ */
/* {{{ includes */
@@ -867,35 +867,42 @@
static void handle_ctcp(php_irconn_t *conn, smart_str *chan, smart_str *from,
smart_str *msg, smart_str *result, smart_str *recipient)
{
+ char *token;
char *token_end;
- char *real_msg;
- char *real_msg_end;
-
- for (token_end = msg->c + 1; *token_end; token_end++)
- if (!isalpha(*token_end)) break;
+ char *ctcp_arg;
+ char *ctcp_arg_end;
+ format_msg_t *fmt_msg;
+ smart_str tmp = {0};
+ int status = 0;
- if (*token_end != '\001') {
- real_msg = token_end + 1;
+ token = msg->c + 1;
+ token_end = strchr(token, 1);
- real_msg_end = strchr(real_msg, '\001');
- if (real_msg_end) {
- format_msg_t *fmt_msg;
- smart_str tmp;
- int status = 0;
-
- *real_msg_end = '\0';
- *token_end = '\0';
-
- if (zend_hash_find(&conn->ctcp_msgs, msg->c + 1, token_end -
msg->c - 1, (void **) &fmt_msg) != SUCCESS) {
- return;
- }
+ if (!token_end) return;
- smart_str_setl(&tmp, real_msg, real_msg_end - real_msg);
- format_msg(fmt_msg, chan, recipient, 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 (zend_hash_find(&conn->ctcp_msgs, token, token_end - token,
+ (void **) &fmt_msg) != SUCCESS) {
+ return;
+ }
+
+ format_msg(fmt_msg, chan, recipient, 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");
}
}
@@ -1390,7 +1397,7 @@
else if (conn->file_fd < 0 && (ircg_now() - conn->login) > WINDOW_TIMEOUT) {
char buf[1024];
- sprintf(buf, "timeout after %d seconds (%d, %d)",
ircg_now()-conn->login,
+ sprintf(buf, "timeout after %ld seconds (%ld, %ld)",
ircg_now()-conn->login,
ircg_now(), conn->login);
irc_disconnect(ircc, buf);
}
@@ -2314,6 +2321,7 @@
if (irc_connect(username, register_hooks,
conn, server, port, &conn->conn)) {
free(conn);
+ php_error(E_WARNING, "%s(): irc_connect() failed prematurely",
get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
irc_connects++;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php