sas             Sun Nov 17 00:29:18 2002 EDT

  Modified files:              
    /php4/ext/ircg      ircg.c php_ircg.h 
  Log:
  add invite handling
  
  
Index: php4/ext/ircg/ircg.c
diff -u php4/ext/ircg/ircg.c:1.142 php4/ext/ircg/ircg.c:1.143
--- php4/ext/ircg/ircg.c:1.142  Sat Nov 16 08:51:37 2002
+++ php4/ext/ircg/ircg.c        Sun Nov 17 00:29:17 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: ircg.c,v 1.142 2002/11/16 13:51:37 sas Exp $ */
+/* $Id: ircg.c,v 1.143 2002/11/17 05:29:17 sas Exp $ */
 
 /* {{{ includes */
 
@@ -106,6 +106,7 @@
        FMT_MSG_WHOREPLY1,
        FMT_MSG_WHOREPLY2,
        FMT_MSG_ENDOFWHO,
+       FMT_MSG_INVITE,
        NO_FMTS
 };
 /* }}} */
@@ -152,6 +153,9 @@
 #if IRCG_API_VERSION >= 20021115
        PHP_FE(ircg_who, NULL)
 #endif
+#if IRCG_API_VERSION >= 20021117
+       PHP_FE(ircg_invite, NULL)
+#endif
        {NULL, NULL, NULL}      /* Must be the last line in ircg_functions[] */
 };
 /* }}} */
@@ -277,6 +281,7 @@
        "Nickname %t has ident %f, realname '%m', hostname %c, ",
        "is on server %t, has flag %f, hopcount %m, and channel %c.<br />",
        "end of who<br />",
+       "%f is inviting %t to %c<br />",
 };
 
 /* }}} */
@@ -1035,6 +1040,30 @@
 
 #endif
 
+#if IRCG_API_VERSION >= 20021117
+
+static void invite_handler(irconn_t *c, smart_str *nick, smart_str *chan, int mode, 
+void *dummy)
+{
+       php_irconn_t *conn = dummy;
+       smart_str m = {0};
+       smart_str *from, *to, tmp = {0};
+       
+       smart_str_setl(&tmp, conn->conn.username, conn->conn.username_len);
+       if (mode == 1) {
+               from = &tmp;
+               to = nick;
+       } else {
+               from = nick;
+               to = &tmp;
+       }
+               
+       FORMAT_MSG(conn, FMT_MSG_INVITE, chan, to, from, NULL, &m,
+                       conn->conn.username, conn->conn.username_len);
+       msg_send(conn, &m);
+}
+
+#endif
+
 /* }}} */
 
 /* {{{ Post-connection error-storage */
@@ -1781,6 +1810,34 @@
 #endif
 /* }}} */
 
+/* {{{ proto bool ircg_invite(int connection, string channel, string nickname)
+   INVITEs nickname to channel */
+#if IRCG_API_VERSION >= 20021117
+PHP_FUNCTION(ircg_invite)
+{
+       zval **p1, **p2, **p3;
+       php_irconn_t *conn;
+       
+       if (ZEND_NUM_ARGS() != 3
+                       || zend_get_parameters_ex(3, &p1, &p2, &p3) == FAILURE)
+               WRONG_PARAM_COUNT;
+
+       convert_to_long_ex(p1);
+       convert_to_string_ex(p2);
+       convert_to_string_ex(p3);
+       
+       conn = lookup_irconn(Z_LVAL_PP(p1));
+
+       if (!conn) RETURN_FALSE;
+
+       irc_handle_command(&conn->conn, "INVITE", 2, Z_STRVAL_PP(p3),
+                       Z_STRVAL_PP(p2));
+       
+       RETVAL_TRUE;
+}
+#endif
+/* }}} */
+
 /* {{{ proto bool ircg_kick(int connection, string channel, string nick, string 
reason)
    Kicks user from channel */
 #if IRCG_API_VERSION - 0 >= 20010226
@@ -1983,6 +2040,10 @@
                irc_register_hook(conn, IRCG_WHOREPLY, whoreply_handler);
        }
        IFMSG(FMT_MSG_ENDOFWHO, IRCG_ENDOFWHO, endofwho_handler);
+#endif
+
+#if IRCG_API_VERSION >= 20021117
+       IFMSG(FMT_MSG_INVITE, IRCG_INVITE, invite_handler);
 #endif
 }
 /* }}} */
Index: php4/ext/ircg/php_ircg.h
diff -u php4/ext/ircg/php_ircg.h:1.21 php4/ext/ircg/php_ircg.h:1.22
--- php4/ext/ircg/php_ircg.h:1.21       Sat Nov 16 08:51:37 2002
+++ php4/ext/ircg/php_ircg.h    Sun Nov 17 00:29:17 2002
@@ -55,6 +55,7 @@
 PHP_FUNCTION(ircg_get_username);
 PHP_FUNCTION(ircg_eval_ecmascript_params);
 PHP_FUNCTION(ircg_who);
+PHP_FUNCTION(ircg_invite);
 
 PHP_MINIT_FUNCTION(ircg);
 PHP_MSHUTDOWN_FUNCTION(ircg);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to