cvs: embed /php-irssi ext-irssi.c

[email protected] ("Tal Peer") Tue, 01 Apr 2003 16:16:03 -0000
Newsgroups php.embed.cvs
Message-ID <cvstal1049213763@cvsserver>
tal		Tue Apr  1 11:16:03 2003 EDT

  Modified files:              
    /embed/php-irssi	ext-irssi.c 
  Log:
  Added server finding functions
  
  
Index: embed/php-irssi/ext-irssi.c
diff -u embed/php-irssi/ext-irssi.c:1.28 embed/php-irssi/ext-irssi.c:1.29
--- embed/php-irssi/ext-irssi.c:1.28	Tue Apr  1 11:06:37 2003
+++ embed/php-irssi/ext-irssi.c	Tue Apr  1 11:16:03 2003
@@ -14,7 +14,7 @@
   +----------------------------------------------------------------------+
   | Author: Wez Furlong <[email protected]>                                    |
   +----------------------------------------------------------------------+
-  $Id: ext-irssi.c,v 1.28 2003/04/01 16:06:37 wez Exp $
+  $Id: ext-irssi.c,v 1.29 2003/04/01 16:16:03 tal Exp $
 */
 #include "php-irssi.h"
 #include "php-signals-list.h" /* generated by php during make */
@@ -320,6 +320,48 @@
 	}
 }
 
+/* proto object irssi_server_find_tag(string tag)
+   Returns the SERVER object of the server with the given tag */
+PHP_FUNCTION(irssi_server_find_tag)
+{
+	char *tag;
+	long tag_len;
+	SERVER_REC *server;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tag, &tag_len) == FAILURE) {
+		return;
+	}
+
+	server = server_find_tag(tag);
+
+	if (server) {
+		php_irssi_export_SERVER(return_value, server TSRMLS_CC);
+	} else {
+		RETVAL_NULL();
+	}
+}
+
+/* proto object irssi_server_find_chatnet(string chatnet)
+   Returns the SERVER object of the server with the given chatnet */
+PHP_FUNCTION(irssi_server_find_chatnet)
+{
+	char *chatnet;
+	long chatnet_len;
+	SERVER_REC *server;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &chatnet, &chatnet_len) == FAILURE) {
+		return;
+	}
+
+	server = server_find_chatnet(chatnet);
+	
+	if (server) {
+		php_irssi_export_SERVER(return_value, server TSRMLS_CC);
+	} else {
+		RETVAL_NULL();
+	}													
+}
+
 /* event source for timeout events */
 static int php_source_event(struct sig_record *rec)
 {
@@ -1173,6 +1215,8 @@
 static function_entry php_irssi_functions[] = {
 	PHP_FE(irssi_channel_list, NULL)
 	PHP_FE(irssi_server_list, NULL)
+	PHP_FE(irssi_server_find_tag, NULL)
+	PHP_FE(irssi_server_find_chatnet, NULL)
 	PHP_FE(irssi_signal_add, NULL)
 	PHP_FE(irssi_signal_emit, NULL)
 	PHP_FE(irssi_signal_remove, NULL)