gnome-mud r666 - in trunk: . plugins/automapper plugins/outputwindows plugins/statusbars plugins/test.plugin src



Author: lharris
Date: Sat Jun 21 05:43:09 2008
New Revision: 666
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=666&view=rev

Log:
Les Harris: Updated plugin makefiles. Plugin API changes.



Modified:
   trunk/ChangeLog
   trunk/plugins/automapper/Makefile
   trunk/plugins/automapper/map.c
   trunk/plugins/outputwindows/Makefile
   trunk/plugins/outputwindows/main.c
   trunk/plugins/statusbars/Makefile
   trunk/plugins/statusbars/main.c
   trunk/plugins/test.plugin/Makefile
   trunk/plugins/test.plugin/main.c
   trunk/src/modules-structures.h
   trunk/src/mud-connection-view.c
   trunk/src/mud-parse-alias.c
   trunk/src/mud-parse-trigger.c
   trunk/src/mud-preferences-window.c
   trunk/src/mud-regex.c
   trunk/src/mud-regex.h
   trunk/src/mud-window.c
   trunk/src/mud-window.h

Modified: trunk/plugins/automapper/Makefile
==============================================================================
--- trunk/plugins/automapper/Makefile	(original)
+++ trunk/plugins/automapper/Makefile	Sat Jun 21 05:43:09 2008
@@ -1,7 +1,7 @@
 CC=gcc
 OBJS=map.o map-link.o
 PROG=automapper.plugin
-CFLAGS=-DBUILDING_PLUGIN -g -Wall `pkg-config --cflags glib-2.0 gtk+-2.0 libgnetwork-1.0 libpcre` 
+CFLAGS=-DBUILDING_PLUGIN -g -Wall -fPIC `pkg-config --cflags glib-2.0 gtk+-2.0 gnet-2.0 gconf-2.0 libpcre` 
 LDFLAGS=-shared -fPIC
 
 all:	$(OBJS)

Modified: trunk/plugins/automapper/map.c
==============================================================================
--- trunk/plugins/automapper/map.c	(original)
+++ trunk/plugins/automapper/map.c	Sat Jun 21 05:43:09 2008
@@ -268,12 +268,12 @@
 	dirlist = gconf_client_get_list(client, keyname, GCONF_VALUE_STRING, &error);
 }
 
-void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, MudConnectionView *view)
+void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, guint length, MudConnectionView *view)
 {
 	cd = view;
 }
 
-void data_out_function(PLUGIN_OBJECT *plugin, gchar *data, MudConnectionView *view)
+void data_out_function(PLUGIN_OBJECT *plugin, gchar *data, guint length, MudConnectionView *view)
 {
 	GList *puck;
 	

Modified: trunk/plugins/outputwindows/Makefile
==============================================================================
--- trunk/plugins/outputwindows/Makefile	(original)
+++ trunk/plugins/outputwindows/Makefile	Sat Jun 21 05:43:09 2008
@@ -1,7 +1,7 @@
 CC=gcc
 OBJS=main.o
 PROG=outputwindows.plugin
-CFLAGS=-DBUILDING_PLUGIN -g -Wall `pkg-config --cflags glib-2.0 gtk+-2.0 libgnetwork-1.0 libpcre` 
+CFLAGS=-DBUILDING_PLUGIN -g -Wall -fPIC `pkg-config --cflags glib-2.0 gtk+-2.0 gnet-2.0 gconf-2.0 libpcre` 
 LDFLAGS=-shared -fPIC
 
 all:	$(OBJS)

Modified: trunk/plugins/outputwindows/main.c
==============================================================================
--- trunk/plugins/outputwindows/main.c	(original)
+++ trunk/plugins/outputwindows/main.c	Sat Jun 21 05:43:09 2008
@@ -253,7 +253,7 @@
 	
 }
 
-void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, MudConnectionView *view)
+void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, guint length, MudConnectionView *view)
 {
 	GError *error = NULL;
 	gchar **groups;
@@ -312,7 +312,7 @@
 							const gchar *errors;
 							gint rc, errorcode, erroroffset;
 						
-							substrings = mud_regex_test((const gchar *)stripped_data, (const gchar *)regex, &rc, &errors, &errorcode, &erroroffset);
+							substrings = mud_regex_test((const gchar *)stripped_data, strlen(stripped_data),(const gchar *)regex, &rc, &errors, &errorcode, &erroroffset);
 							g_free(regex);
 						
 							if(rc > 0)

Modified: trunk/plugins/statusbars/Makefile
==============================================================================
--- trunk/plugins/statusbars/Makefile	(original)
+++ trunk/plugins/statusbars/Makefile	Sat Jun 21 05:43:09 2008
@@ -1,7 +1,7 @@
 CC=gcc
 OBJS=main.o
 PROG=statusbars.plugin
-CFLAGS=-DBUILDING_PLUGIN -g -Wall `pkg-config --cflags glib-2.0 gtk+-2.0 libgnetwork-1.0 libpcre` 
+CFLAGS=-DBUILDING_PLUGIN -g -Wall -fPIC `pkg-config --cflags glib-2.0 gtk+-2.0 gnet-2.0 gconf-2.0  libpcre` 
 LDFLAGS=-shared -fPIC
 
 all:	$(OBJS)

Modified: trunk/plugins/statusbars/main.c
==============================================================================
--- trunk/plugins/statusbars/main.c	(original)
+++ trunk/plugins/statusbars/main.c	Sat Jun 21 05:43:09 2008
@@ -161,7 +161,7 @@
 	}
 }
 
-void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, MudConnectionView *view)
+void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, guint length, MudConnectionView *view)
 {
 	gint hp;
 	gint sp;
@@ -183,6 +183,7 @@
 	groups = g_key_file_get_groups(sb_info.keyfile, &group_count);
 	stripped_data = strip_ansi((const gchar *)data);
 	
+	
 	for(i = 0; i < group_count; i++)
 	{
 		enabled = g_key_file_get_integer(sb_info.keyfile, (const gchar *)groups[i], "enabled", &error);
@@ -190,7 +191,7 @@
   		if(enabled)
   		{
   			regex = g_key_file_get_string(sb_info.keyfile, (const gchar *)groups[i], "regex", &error);
-			substrings = mud_regex_test((const gchar *)stripped_data, (const gchar *)regex, &rc, &errors, &errorcode, &erroroffset);
+			substrings = mud_regex_test((const gchar *)stripped_data, (guint)strlen(stripped_data), (const gchar *)regex, &rc, &errors, &errorcode, &erroroffset);
 			g_free(regex);
 
 			if(rc > 0)

Modified: trunk/plugins/test.plugin/Makefile
==============================================================================
--- trunk/plugins/test.plugin/Makefile	(original)
+++ trunk/plugins/test.plugin/Makefile	Sat Jun 21 05:43:09 2008
@@ -1,8 +1,8 @@
 CC=gcc
 OBJS=main.o
 PROG=test.plugin
-CFLAGS=-DBUILDING_PLUGIN -g -Wall `pkg-config --cflags glib-2.0 gtk+-2.0 libgnetwork-1.0 libpcre` 
-LDFLAGS=-shared -fPIC
+CFLAGS=-DBUILDING_PLUGIN -g -Wall -fPIC `pkg-config --cflags glib-2.0 gtk+-2.0 gnet-2.0 gconf-2.0 libpcre` 
+LDFLAGS=-fPIC -shared
 
 all:	$(OBJS)
 	$(CC) $(OBJS) -o $(PROG) $(LDFLAGS)

Modified: trunk/plugins/test.plugin/main.c
==============================================================================
--- trunk/plugins/test.plugin/main.c	(original)
+++ trunk/plugins/test.plugin/main.c	Sat Jun 21 05:43:09 2008
@@ -43,9 +43,9 @@
   plugin_register_data_incoming(context, "data_in_function");
 }
 
-void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, MudConnectionView *view)
+void data_in_function(PLUGIN_OBJECT *plugin, gchar *data, guint length, MudConnectionView *view)
 {
-  g_message("Received (%d) bytes.", strlen(data));
+  g_message("Received (%d) bytes.", length);
   plugin_add_connection_text("Plugin Called!", 0, view);
 }
 

Modified: trunk/src/modules-structures.h
==============================================================================
--- trunk/src/modules-structures.h	(original)
+++ trunk/src/modules-structures.h	Sat Jun 21 05:43:09 2008
@@ -13,7 +13,7 @@
 
 typedef void      (*plugin_initfunc) (PLUGIN_OBJECT *,   GModule *   );
 typedef void      (*plugin_menufunc) (GtkWidget *,       GModule *   );
-typedef void      (*plugin_datafunc) (PLUGIN_OBJECT *, gchar *, MudConnectionView *);
+typedef void      (*plugin_datafunc) (PLUGIN_OBJECT *, gchar *, guint, MudConnectionView *);
 
 typedef enum { PLUGIN_DATA_IN, PLUGIN_DATA_OUT } PLUGIN_DATA_DIRECTION;
 

Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c	(original)
+++ trunk/src/mud-connection-view.c	Sat Jun 21 05:43:09 2008
@@ -536,7 +536,7 @@
 		
 		// Give plugins first crack at it.
 		mud_window_handle_plugins(view->priv->window, view->priv->id, 
-		    (gchar *)text, 0);
+		    (gchar *)text, strlen(text), 0);
 		    
 		gnet_conn_write(view->connection, text, strlen(text));
 		
@@ -912,22 +912,26 @@
         break;
         
         case GNET_CONN_READ:
+        
+            g_message("Buffer: %s\n", event->buffer);
+            
 	        if(!view->priv->connected)
 	        {
 		        view->priv->connected = TRUE;
 		        mud_tray_update_icon(view->priv->tray, online);
 	        }
 	
-	           gag = mud_parse_base_do_triggers(view->priv->parse, 
+	       gag = mud_parse_base_do_triggers(view->priv->parse, 
 	                event->buffer);
-	           mud_window_handle_plugins(view->priv->window, view->priv->id, 
-	                event->buffer, 1);
+	       mud_window_handle_plugins(view->priv->window, view->priv->id, 
+	                event->buffer, event->length, 1);
 	                
-	           pluggag = PluginGag;
-	           PluginGag = FALSE;
+	       pluggag = PluginGag;
+	       PluginGag = FALSE;
 	
 	        if(!gag && !pluggag)
 	        {
+	            
 		        vte_terminal_feed(VTE_TERMINAL(view->priv->terminal), 
 		            event->buffer, event->length);
 		        mud_log_write_hook(view->priv->log, event->buffer, event->length);

Modified: trunk/src/mud-parse-alias.c
==============================================================================
--- trunk/src/mud-parse-alias.c	(original)
+++ trunk/src/mud-parse-alias.c	Sat Jun 21 05:43:09 2008
@@ -22,6 +22,7 @@
 
 #include <glib-object.h>
 #include <glib/gi18n.h>
+#include <string.h>
 
 #include "mud-parse-base.h"
 #include "mud-parse-alias.h"
@@ -122,7 +123,7 @@
 			g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/aliases/%s/regex", profile_name, (gchar *)entry->data);
 			regexstr = gconf_client_get_string(client, keyname, &error);
 			
-			if(mud_regex_check((const gchar *)data, regexstr, ovector, regex))
+			if(mud_regex_check((const gchar *)data, strlen(data), regexstr, ovector, regex))
 			{		
 				g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/aliases/%s/actions", profile_name, (gchar *)entry->data);
 				actions = gconf_client_get_string(client, keyname, &error);

Modified: trunk/src/mud-parse-trigger.c
==============================================================================
--- trunk/src/mud-parse-trigger.c	(original)
+++ trunk/src/mud-parse-trigger.c	Sat Jun 21 05:43:09 2008
@@ -136,7 +136,7 @@
 			
 			stripped_data = strip_ansi((const gchar *) data);
 			
-			if(mud_regex_check((const gchar *)stripped_data, (const gchar *)regexstr, ovector, regex))
+			if(mud_regex_check((const gchar *)stripped_data, strlen(stripped_data), (const gchar *)regexstr, ovector, regex))
 			{
 				g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/triggers/%s/gag", profile_name, (gchar *)entry->data);
 				gag = gconf_client_get_int(client, keyname, &error);

Modified: trunk/src/mud-preferences-window.c
==============================================================================
--- trunk/src/mud-preferences-window.c	(original)
+++ trunk/src/mud-preferences-window.c	Sat Jun 21 05:43:09 2008
@@ -1560,7 +1560,7 @@
 	gtk_text_buffer_get_end_iter(buffer, &end);
 	regex = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
-	matched_strings = mud_regex_test(test_string, regex, &rc, &error, &errorcode, &erroroffset);
+	matched_strings = mud_regex_test(test_string, strlen(test_string),regex, &rc, &error, &errorcode, &erroroffset);
 
 	if(errorcode)
 	{
@@ -1665,7 +1665,7 @@
 	gtk_text_buffer_get_end_iter(buffer, &end);
 	regex = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
-	matched_strings = mud_regex_test(test_string, regex, &rc, &error, &errorcode, &erroroffset);
+	matched_strings = mud_regex_test(test_string, strlen(test_string), regex, &rc, &error, &errorcode, &erroroffset);
 
 	if(errorcode)
 	{

Modified: trunk/src/mud-regex.c
==============================================================================
--- trunk/src/mud-regex.c	(original)
+++ trunk/src/mud-regex.c	Sat Jun 21 05:43:09 2008
@@ -102,7 +102,7 @@
 // MudRegex Methods
 
 gboolean 
-mud_regex_check(const gchar *data, const gchar *rx, gint ovector[1020], MudRegex *regex)
+mud_regex_check(const gchar *data, guint length, const gchar *rx, gint ovector[1020], MudRegex *regex)
 {
 	pcre *re = NULL;
 	const gchar *error = NULL;
@@ -133,7 +133,7 @@
 		
 	}
 
-	rc = pcre_exec(re, NULL, data, strlen(data), 0, 0, ovector, 1020);
+	rc = pcre_exec(re, NULL, data, length, 0, 0, ovector, 1020);
 
 	if(rc < 0)
 		return FALSE;
@@ -148,18 +148,21 @@
 }
 
 const gchar **
-mud_regex_test(const gchar *data, const gchar *rx, gint *rc, const gchar **error, gint *errorcode, gint *erroroffset)
+mud_regex_test(const gchar *data, guint length, const gchar *rx, gint *rc, const gchar **error, gint *errorcode, gint *erroroffset)
 {
 	pcre *re = NULL;
 	gint ovector[1020];
 	const gchar **sub_list;
 	
+	if(!data)
+	    return NULL;
+	    
 	re = pcre_compile2(rx, 0, errorcode, error, erroroffset, NULL);
 
 	if(!re)
 		return NULL;
 	
-	*rc = pcre_exec(re, NULL, data, strlen(data), 0, 0, ovector, 1020);
+	*rc = pcre_exec(re, NULL, data, length, 0, 0, ovector, 1020);
 	
 	pcre_get_substring_list(data, ovector, *rc, &sub_list);
 	

Modified: trunk/src/mud-regex.h
==============================================================================
--- trunk/src/mud-regex.h	(original)
+++ trunk/src/mud-regex.h	Sat Jun 21 05:43:09 2008
@@ -30,8 +30,8 @@
 
 MudRegex *mud_regex_new(void);
 
-gboolean mud_regex_check(const gchar *data, const gchar *rx, gint ovector[1020], MudRegex *regex);
-const gchar **mud_regex_test(const gchar *data, const gchar *rx, gint *rc, const gchar **error, gint *errorcode, gint *erroroffset);
+gboolean mud_regex_check(const gchar *data, guint length, const gchar *rx, gint ovector[1020], MudRegex *regex);
+const gchar **mud_regex_test(const gchar *data, guint length, const gchar *rx, gint *rc, const gchar **error, gint *errorcode, gint *erroroffset);
 void mud_regex_substring_clear(const gchar **substring_list);
 const gchar **mud_regex_get_substring_list(gint *count, MudRegex *regex);
 

Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c	(original)
+++ trunk/src/mud-window.c	Sat Jun 21 05:43:09 2008
@@ -39,6 +39,7 @@
 #include <gtk/gtktextiter.h>
 #include <gtk/gtkimagemenuitem.h>
 #include <vte/vte.h>
+#include <glib/gstring.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -824,7 +825,7 @@
 }
 
 void
-mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, gint dir)
+mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, guint length, gint dir)
 {
 	GSList *entry, *viewlist;
 	MudViewEntry *mudview;
@@ -849,7 +850,13 @@
 			
 						if(pd->plugin && pd->plugin->enabled && (pd->dir == PLUGIN_DATA_IN))
 						{
-							(*pd->datafunc)(pd->plugin, (gchar *)data, mudview->view);
+						    GString *buf = g_string_new(NULL);
+						    int i;
+						    
+						    for(i = 0; i < length; i++)
+						        g_string_append_c(buf, data[i]);
+						        
+							(*pd->datafunc)(pd->plugin, buf->str, length, mudview->view);
 						}
 					}
 				}
@@ -865,7 +872,13 @@
 			
 						if(pd->plugin && pd->plugin->enabled && (pd->dir == PLUGIN_DATA_OUT))
 						{
-							(*pd->datafunc)(pd->plugin, (gchar *)data, mudview->view);
+							GString *buf = g_string_new(NULL);
+						    int i;
+						    
+						    for(i = 0; i < length; i++)
+						        g_string_append_c(buf, data[i]);
+						        
+							(*pd->datafunc)(pd->plugin, buf->str, length, mudview->view);
 						}
 					}
 				}

Modified: trunk/src/mud-window.h
==============================================================================
--- trunk/src/mud-window.h	(original)
+++ trunk/src/mud-window.h	Sat Jun 21 05:43:09 2008
@@ -34,7 +34,7 @@
 #include "mud-connection-view.h"
 MudWindow* mud_window_new (GConfClient *client);
 void mud_window_add_connection_view(MudWindow *window, MudConnectionView *view, gchar *tabLbl);
-void mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, gint dir);
+void mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, guint length, gint dir);
 void mud_window_populate_profiles_menu(MudWindow *window);
 void mud_window_profile_menu_set_active(gchar *name, MudWindow *window);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]