[ekg2-commit] r3881 - in trunk: ekg plugins/gg plugins/ruby: trunk/ekg/plugins.h trunk/ekg/scripts.c trunk/ekg/scripts.h trunk/plugins/gg/dcc.c trunk/plugins/ruby/ruby_ekg.c

SVN commit svn w toxygen.net
Nie, 9 Mar 2008, 18:07:28 CET


Author: peres
Date: 2008-03-09 18:07:28 +0100 (Sun, 09 Mar 2008)
New Revision: 3881

Modified:
   trunk/ekg/plugins.h
   trunk/ekg/scripts.c
   trunk/ekg/scripts.h
   trunk/plugins/gg/dcc.c
   trunk/plugins/ruby/ruby_ekg.c
Log:

Scripts into lists3.



Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h	2008-03-09 16:59:46 UTC (rev 3880)
+++ trunk/ekg/plugins.h	2008-03-09 17:07:28 UTC (rev 3881)
@@ -26,7 +26,7 @@
 #include "dynstuff.h"
 #include "sessions.h"
 
-#define EKG_ABI_VER 3873
+#define EKG_ABI_VER 3881
 
 #define EXPORT __attribute__ ((visibility("default")))
 

Modified: trunk/ekg/scripts.c
===================================================================
--- trunk/ekg/scripts.c	2008-03-09 16:59:46 UTC (rev 3880)
+++ trunk/ekg/scripts.c	2008-03-09 17:07:28 UTC (rev 3881)
@@ -30,8 +30,8 @@
  * - memleaks ?
  */
 
-list_t	scripts;
-list_t	scriptlang;
+script_t	*scripts;
+scriptlang_t	*scriptlang;
 
 static list_t script_timers;
 static list_t script_plugins;
@@ -54,13 +54,11 @@
 scriptlang_t *scriptlang_from_ext(char *name)
 {
 	scriptlang_t *s;
-	list_t l;
 	char *ext = xrindex(name, '.');
 	
 	if (!ext) return NULL;
 	
-	for (l = scriptlang; l; l = l->next) {
-		s = l->data;
+	for (s = scriptlang; s; s = s->next) {
 		if (!xstrcmp(ext, s->ext))
 			return s;
 	}
@@ -69,7 +67,7 @@
 
 int scriptlang_register(scriptlang_t *s)
 {
-	list_add(&scriptlang, s);
+	LIST_ADD2(&scriptlang, s);
 
 	s->init();
 	
@@ -82,8 +80,9 @@
 {
 	script_unload_lang(s);
 	s->deinit();
+	LIST_UNLINK2(&scriptlang, s);
 	
-	return list_remove(&scriptlang, s, 0);
+	return 0;
 }
 
 /**************************************************************************************/
@@ -165,12 +164,9 @@
 
 int script_reset(scriptlang_t *scr)
 {
-	list_t l;
 	scriptlang_t *s;
 	
-	for (l = scriptlang; l; l = l->next) {
-		s = l->data;
-
+	for (s = scriptlang; s; s = s->next) {
 		script_unload_lang(s);
     		s->deinit();
 		
@@ -182,13 +178,11 @@
 
 int script_list(scriptlang_t *s)
 {
-	list_t l;
 	script_t *scr;
 	scriptlang_t *lang;
 	int i = 0;
 	
-	for (l = scripts; l; l = l->next) {
-		scr = l->data;
+	for (scr = scripts; scr; scr = scr->next) {
 		lang = scr->lang;
 		if (!s || scr->lang == s) {
 			print("script_list", scr->name, scr->path, lang->name);
@@ -225,11 +219,10 @@
 	char 		*nametmp;
 	char 		*path = NULL;
 
-	scriptlang_t 	*s = NULL;
-	list_t 		l  = scriptlang;
+	scriptlang_t 	*s = scriptlang;
 
 	nametmp = xstrdup(name);
-	while ((ext = xrindex(nametmp, '.')) || l) {
+	while ((ext = xrindex(nametmp, '.')) || s) {
 		if (ext) {
 			if (nametmp[0] == '/' && (fajl = (fopen(nametmp, "r")))) {
 				fclose(fajl);
@@ -254,10 +247,9 @@
 				return path;
 			}
 		}
-		if (!l) return NULL;
-		s = l->data;
+		if (!s) return NULL;
 		nametmp  = saprintf("%s%s", name, s->ext);
-		l = l->next;
+		s = s->next;
 	}
 	return NULL;
 }
@@ -297,7 +289,9 @@
 	
 	xfree(scr->name);
 	xfree(scr->path);
-	return list_remove(&scripts, scr, 1);
+	LIST_REMOVE2(&scripts, scr, NULL);
+
+	return 0;
 }
 
 script_t *script_find(scriptlang_t *s, char *name)
@@ -331,18 +325,16 @@
 {
 	scriptlang_t *lang;
 	script_t *scr;
-	list_t l;
 
-	for (l = scripts; l;) {
-		scr = l->data;
-		l   = l->next;
-		if (!scr) 
-			continue;
+	for (scr = scripts; scr;) {
+		script_t *next	= scr->next;
 		
 		lang = scr->lang;
 		if (!s || scr->lang == s) {
 			script_unload(scr);
 		}
+
+		scr = next;
 	}
 	return 0;
 }
@@ -401,7 +393,7 @@
 		scr->lang = slang;
 		scr->inited = 1;
 		
-		list_add(&scripts, scr); /* BUG: this should be before `script_loaded`...  */
+		LIST_ADD2(&scripts, scr); /* BUG: this should be before `script_loaded`...  */
 
 		ret = slang->script_load(scr);
 

Modified: trunk/ekg/scripts.h
===================================================================
--- trunk/ekg/scripts.h	2008-03-09 16:59:46 UTC (rev 3880)
+++ trunk/ekg/scripts.h	2008-03-09 17:07:28 UTC (rev 3881)
@@ -22,14 +22,16 @@
 	SCRIPT_PLUGINTYPE, 
 } script_type_t;
 
-typedef struct {
+typedef struct script {
+	struct script	*next;
+
 	void 		*lang;
 	char 		*name;
 	char 		*path;
 	void 		*private;
 	int		inited;
 } script_t;
-extern list_t 		scripts;
+extern script_t 	*scripts;
 
 typedef struct {
 	script_t 	*scr;
@@ -88,7 +90,9 @@
 
 typedef int (script_free_bind_t)      (script_t *, void *, int, void *, ...);
 
-typedef struct {
+typedef struct scriptlang {
+	struct scriptlang	*next;
+
 	char  	 *name;		/* perl, python, php *g* and so on. */
 	char 	 *ext;		/*  .pl,    .py, .php ... */
 	plugin_t *plugin;
@@ -108,15 +112,13 @@
 	
 	void *private;
 } scriptlang_t;
-extern list_t scriptlang;
+extern scriptlang_t *scriptlang;
 
 #define SCRIPT_FINDER(bool)\
 	script_t *scr = NULL;\
 	scriptlang_t *slang = NULL;\
-	list_t l;\
 	\
-	for (l = scripts; l; l = l->next) {\
-		scr = l->data;\
+	for (scr = scripts; scr; scr = scr->next) {\
 		slang = scr->lang;\
 		if (bool)\
 			return scr;\

Modified: trunk/plugins/gg/dcc.c
===================================================================
--- trunk/plugins/gg/dcc.c	2008-03-09 16:59:46 UTC (rev 3880)
+++ trunk/plugins/gg/dcc.c	2008-03-09 17:07:28 UTC (rev 3881)
@@ -483,7 +483,6 @@
 		dcc_t *d = NULL, *D;
 		struct gg_common *g;
 		char *path;
-		list_t l;
 
 		int fd;
 		unsigned int offset = 0;

Modified: trunk/plugins/ruby/ruby_ekg.c
===================================================================
--- trunk/plugins/ruby/ruby_ekg.c	2008-03-09 16:59:46 UTC (rev 3880)
+++ trunk/plugins/ruby/ruby_ekg.c	2008-03-09 17:07:28 UTC (rev 3881)
@@ -513,11 +513,9 @@
 }
 
 static int ruby_theme_init() {
-	list_t l;
+	script_t *scr;
 
-	for (l = scripts; l; l = l->next) {
-		script_t *scr = l->data;
-
+	for (scr = scripts; scr; scr = scr->next) {
 		if (scr->lang == &ruby_lang)
 			ruby_script_theme_init(scr);
 	}



Więcej informacji o liście dyskusyjnej ekg2-commit