r1628 - in dev/concept/moongoo: . syntax

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Fri Dec 3 17:18:44 PST 2004


Author: neocool
Date: 2004-12-03 18:18:43 -0700 (Fri, 03 Dec 2004)
New Revision: 1628

Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/inc.mak
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/plugin.c
   dev/concept/moongoo/plugin.h
   dev/concept/moongoo/syntax/ass.c
   dev/concept/moongoo/syntax/book.c
   dev/concept/moongoo/syntax/nalfs.c
   dev/concept/moongoo/syntax/sample.c
   dev/concept/moongoo/syntax/syn.c
Log:
Update.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/Makefile	2004-12-04 01:18:43 UTC (rev 1628)
@@ -6,9 +6,9 @@
 
 ifeq ($(OPTS),)
 OPTS=
-#OPTS+=~/projects/alfs/book/index.xml
+OPTS+=~/projects/alfs/book/index.xml
 #OPTS+=~/projects/alfs/lfs-profile/LFS.xml
-OPTS+=~/projects/alfs/ass/index.xml
+#OPTS+=~/projects/alfs/ass/index.xml
 #OPTS+=~/projects/hive/unstable/profile.xml
 endif
 

Modified: dev/concept/moongoo/inc.mak
===================================================================
--- dev/concept/moongoo/inc.mak	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/inc.mak	2004-12-04 01:18:43 UTC (rev 1628)
@@ -21,7 +21,7 @@
 	rm -f $(BIN) $(LIB) $(LIBS) *.o
 	
 todo:
-	@grep "TODO:" *.c *.h|cut -d" " -f3-|sort
+	@find -name '*.c'|xargs grep "TODO:"|cut -d" " -f3-|sort
 
 %.so: %.o
 	$(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/moongoo.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -8,6 +8,7 @@
 #include <build.h>
 #include <plugin.h>
 
+#define DEF_SYN		"book"
 #define	VERSION		"0.0.2"
 
 role default_filter[4] = { NOEXECUTE, INTERACTIVE, TESTSUITE, 0 };
@@ -30,6 +31,7 @@
 		return 1;
 	}
 
+	// TODO: Make the plugin directory configurable
 	plugin = plugscan("syntax");
 
 	if (!plugin)
@@ -51,7 +53,7 @@
 						char *tmp = plugarg(plugin[i].path);
 						if (strcmp(tmp, "sample"))
 							printf("\t%s\t\t%s%s\n", tmp, 
-								plugin[i].info->name, ((i==0) 
+								plugin[i].info->name, ((!strcmp(tmp, DEF_SYN)) 
 								? " (default)" : ""));
 						i++;
 					}
@@ -88,21 +90,20 @@
 	xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT);
 	cur=xmlDocGetRootElement(doc);
 	
-	if (syn)
+	if (!syn)
+		syn = DEF_SYN;
+	
+	while (plugin[i].path)
 	{
-		while (plugin[i].path)
-		{
-			if (!strcmp(syn, plugarg(plugin[i].path)))
-				prof = plugin[i].info->parse(cur);
-			i++;
-		}
+		if (!strcmp(syn, plugarg(plugin[i].path)))
+			prof = plugin[i].info->parse(cur);
+		i++;
 	}
-	else
-		prof = plugin[0].info->parse(cur);
 	
 	if (!prof)
 	{
 		fprintf(stderr, "Document was not parsed correctly.\n");
+		plugunload(plugin);
 		xmlFreeDoc(doc);
 		return 1;
 	}
@@ -111,11 +112,13 @@
 	{
 		build_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
 		set_filter(default_filter);
+		// TODO: Make print_pkg segfault resistant
 		/*print_pkg(*search_pkg(prof, "Glibc-20041115", 
 			"chapter-building-system"));*/
 		print_profile(*prof);
 	}
 	
+	plugunload(plugin);
 	xmlFreeDoc(doc);
 	return 0;
 }

Modified: dev/concept/moongoo/plugin.c
===================================================================
--- dev/concept/moongoo/plugin.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/plugin.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -65,11 +65,19 @@
 	if (!ret->info)
 	{
 		fprintf(stderr, "No plugin info in %s.\n", fname);
-		dlclose(hand);
+		dlclose(hand->hand);
 		return NULL;
 	}
 
-	dlclose(hand);
+	if (ret->info->vers!=PLUG_VER)
+	{
+		fprintf(stderr, "Incompatible plugin version %d.\n", 
+			ret->info->vers);
+		dlclose(hand->hand);
+		return NULL;
+	}
+
+	ret->hand = hand->hand;
 	return ret;
 }
 
@@ -90,7 +98,7 @@
 		plugerr(fname);
 		return NULL;
 	}
-	
+
 	return ret;
 }
 
@@ -116,3 +124,14 @@
 {
 	return strkill(basename(path), "." PLUG_EXT);
 }
+
+void plugunload (plug_info *plug)
+{
+	int i = 0;
+
+	while (plug[i].path)
+	{
+		dlclose(plug[i].hand);
+		i++;
+	}
+}

Modified: dev/concept/moongoo/plugin.h
===================================================================
--- dev/concept/moongoo/plugin.h	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/plugin.h	2004-12-04 01:18:43 UTC (rev 1628)
@@ -3,6 +3,7 @@
 
 #include <alfs.h>
 
+#define PLUG_VER	2
 #define PLUG_EXT	"so"
 
 typedef struct
@@ -16,6 +17,7 @@
 {
 	t_plug *info;
 	char *path;
+	void *hand;
 } plug_info;
 
 typedef struct
@@ -30,5 +32,6 @@
 void plugerr (char *fname);
 void print_plug (plug_info plug);
 char *plugarg (char *path);
+void plugunload (plug_info *plug);
 
 #endif

Modified: dev/concept/moongoo/syntax/ass.c
===================================================================
--- dev/concept/moongoo/syntax/ass.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/syntax/ass.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -11,7 +11,7 @@
 static t_plug ass_plugin =
 {
 	name:	"ALFS simple syntax",
-	vers:	1,
+	vers:	PLUG_VER,
 	parse:	ass_profile
 };
 

Modified: dev/concept/moongoo/syntax/book.c
===================================================================
--- dev/concept/moongoo/syntax/book.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/syntax/book.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -21,7 +21,7 @@
 static t_plug book_plugin =
 {
 	name:	"Book as profile",
-	vers:	1,
+	vers:	PLUG_VER,
 	parse:	bookasprofile
 };
 

Modified: dev/concept/moongoo/syntax/nalfs.c
===================================================================
--- dev/concept/moongoo/syntax/nalfs.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/syntax/nalfs.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -16,7 +16,7 @@
 static t_plug nalfs_plugin =
 {
 	name:	"nALFS legacy syntax",
-	vers:	1,
+	vers:	PLUG_VER,
 	parse:	nalfs_profile
 };
 

Modified: dev/concept/moongoo/syntax/sample.c
===================================================================
--- dev/concept/moongoo/syntax/sample.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/syntax/sample.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -15,7 +15,7 @@
 static t_plug sample_plugin =
 {
 	name:	"Example plugin",
-	vers:	1,
+	vers:	PLUG_VER,
 	parse:	parse_example
 };
 

Modified: dev/concept/moongoo/syntax/syn.c
===================================================================
--- dev/concept/moongoo/syntax/syn.c	2004-12-04 00:08:21 UTC (rev 1627)
+++ dev/concept/moongoo/syntax/syn.c	2004-12-04 01:18:43 UTC (rev 1628)
@@ -11,7 +11,7 @@
 static t_plug syn_plugin =
 {
 	name:	"Hive profile syntax",
-	vers:	1,
+	vers:	PLUG_VER,
 	parse:	syn_profile
 };
 




More information about the alfs-log mailing list