r1644 - in dev/concept/moongoo: . syntax

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Sat Dec 11 15:26:23 PST 2004


Author: neocool
Date: 2004-12-11 16:26:22 -0700 (Sat, 11 Dec 2004)
New Revision: 1644

Added:
   dev/concept/moongoo/syntax/rng.c
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/syntax/Makefile
Log:
Parser for the Relax-NG branch added.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-11 22:42:21 UTC (rev 1643)
+++ dev/concept/moongoo/Makefile	2004-12-11 23:26:22 UTC (rev 1644)
@@ -4,12 +4,13 @@
 OBJS=build.o moongoo.o plugin.o url.o
 
 ifeq ($(OPTS),)
-OPTS=-s blfs
+OPTS=-s rng
 #OPTS+=~/projects/alfs/book/index.xml
 #OPTS+=~/projects/alfs/lfs-profile/LFS.xml
 #OPTS+=~/projects/alfs/ass/index.xml
 #OPTS+=~/projects/hive/unstable/profile.xml
-OPTS+=~/projects/alfs/blfs/index.xml
+#OPTS+=~/projects/alfs/blfs/index.xml
+OPTS+=~/projects/alfs/book-rng/index.xml
 endif
 
 SUBDIRS=libalfs syntax

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-11 22:42:21 UTC (rev 1643)
+++ dev/concept/moongoo/moongoo.c	2004-12-11 23:26:22 UTC (rev 1644)
@@ -129,20 +129,20 @@
 	{
 		/*package *glibc = search_pkg(prof, "glibc", 
 			"chapter-building-system");*/
-		package *gtk2 = search_pkg(prof, "gtk+",
-			"x-lib");
+		/*package *gtk2 = search_pkg(prof, "gtk+",
+			"x-lib");*/
 		
 		sed_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
 		set_filter(default_filter);
 		
-		if (gtk2)
+		/*if (gtk2)
 		{
 			//print_pkg(*gtk2);
 			print_deptree(*prof, *gtk2);
-		}
+		}*/
 		/*if (glibc)
 			print_pkg(*glibc);*/
-		//print_profile(*prof);
+		print_profile(*prof);
 		//print_links(*prof);
 	}
 

Modified: dev/concept/moongoo/syntax/Makefile
===================================================================
--- dev/concept/moongoo/syntax/Makefile	2004-12-11 22:42:21 UTC (rev 1643)
+++ dev/concept/moongoo/syntax/Makefile	2004-12-11 23:26:22 UTC (rev 1644)
@@ -1,6 +1,6 @@
 CFLAGS=-I../libalfs -I..
 
-LIBS=ass.so blfs.so book.so nalfs.so syn.so
+LIBS=ass.so blfs.so book.so nalfs.so rng.so syn.so
 #LIBS+=sample.so
 
 all: $(LIBS)
@@ -11,4 +11,5 @@
 blfs.so: ../libalfs/libalfs.a
 book.so: ../libalfs/libalfs.a
 nalfs.so: ../libalfs/libalfs.a
+rng.so: ../libalfs/libalfs.a
 syn.so: ../libalfs/libalfs.a

Added: dev/concept/moongoo/syntax/rng.c
===================================================================
--- dev/concept/moongoo/syntax/rng.c	2004-12-11 22:42:21 UTC (rev 1643)
+++ dev/concept/moongoo/syntax/rng.c	2004-12-11 23:26:22 UTC (rev 1644)
@@ -0,0 +1,166 @@
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libalfs.h>
+#include <plugin.h>
+
+command *cmd;
+int num;
+profile *prof;
+replaceable *r;
+
+profile *bookasprofile (xmlNodePtr node, replaceable *r);
+
+static t_plug book_plugin =
+{
+	name:	"LFS Relax-NG book as profile",
+	vers:	PLUG_VER,
+	parse:	bookasprofile
+};
+
+t_plug *getplug ()
+{
+	return &book_plugin;
+}
+
+
+static void process_cmd (char *line, xmlNodePtr node)
+{
+	cmd = realloc(cmd, (++num)*sizeof(command));
+	cmd[num-1].role = parse_role(node);
+	
+	if (strcnt(line, " "))
+	{
+		cmd[num-1].cmd = strcut(line, 0, whereis(line, ' '));
+		cmd[num-1].arg = tokenize(notrail(strstr(line, " "), " "), 
+				" ", &cmd[num-1].n);
+	}
+	else
+	{
+		cmd[num-1].cmd = line;
+		cmd[num-1].arg = NULL;
+		cmd[num-1].n = 0;
+	}
+}
+
+static void __t_userinput (xmlNodePtr node, void *data)
+{
+	char *line;
+
+	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);
+	line = squeeze(xmlNodeGetContent(node));
+	line = strkill(line, "\\\n");
+
+	if (strcnt(line, "\n"))
+	{
+		char *tmp;
+		
+		while ((line) && (strlen(line)))
+		{
+			if (!strncmp(line, "cat >", 5))
+			{
+				char *t = strnstr(line, "EOF", 2);
+				process_cmd(strcut(line, 0, t-line+3), node);
+				t+=2;
+				line=t;
+				continue;
+			}
+			
+			tmp = strsep(&line, "\n");
+			process_cmd(tmp, node);
+		}
+	}
+	else
+		process_cmd(line, node);
+}
+
+static command *t_userinput (xmlNodePtr node, int *n)
+{
+	cmd = NULL;
+	num = 0;
+	foreach(node, "userinput", (xml_handler_t)__t_userinput, NULL);
+	*n = num;
+	return cmd;
+}
+
+static void t_section (xmlNodePtr node, void *data)
+{
+	int i, j;
+	char *title, *tmp;
+		
+	title = find_value(node->children, "title");
+
+	if (!title)
+	{
+		fprintf(stderr, "%s: No title found.\n", node->name);
+		return;
+	}
+
+	i = prof->n-1;
+	prof->ch[i].pkg = realloc(prof->ch[i].pkg, 
+			(++prof->ch[i].n)*sizeof(package));
+	j = prof->ch[i].n-1;
+	
+	tmp = strrchr(title, '-');
+	if (tmp)
+	{
+		char *t = strnrchr(title, '-', 2);
+		if ((t) && (isdigit(t[1])))
+			tmp = strdog(t, tmp); 
+	}
+	tmp = chrep(tmp, ' ', '\0');
+	prof->ch[i].pkg[j].vers = tmp ? strcut(tmp, 1, strlen(tmp)) : NULL;
+	prof->ch[i].pkg[j].name = tmp ? strcut(title, 0, 
+		strlen(title)-strlen(tmp)) : title;
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
+	
+	prof->ch[i].pkg[j].build = t_userinput(node->children, 
+		&prof->ch[i].pkg[j].n);
+
+	if (!prof->ch[i].pkg[j].n)
+		prof->ch[i].n--;
+}
+
+static void t_chapter (xmlNodePtr node, void *data)
+{
+	int i;
+
+	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+	i = prof->n-1;
+	prof->ch[i].name = xmlGetProp(node, "xreflabel");
+	prof->ch[i].ref = xmlGetProp(node, "id");
+	prof->ch[i].pkg = NULL;
+	prof->ch[i].n = 0;
+	foreach(node->children, "section", (xml_handler_t)t_section, NULL);
+}
+
+void t_part (xmlNodePtr node, void *data)
+{
+	foreach(node->children, "chapter", (xml_handler_t)t_chapter, NULL);
+}
+
+profile *bookasprofile (xmlNodePtr node, replaceable *_r)
+{
+	xmlNodePtr info = find_node(node, "info");
+
+	if (!info)
+	{
+		fprintf(stderr, "XML document is not a valid LFS RNG book.\n");
+		return NULL;
+	}
+
+	r = _r;
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = find_value(info, "title");
+	prof->vers = find_value(info, "subtitle");
+	prof->vers = strcut(prof->vers, strlen("Version"), strlen(prof->vers));
+	prof->ch = NULL;
+	prof->n = 0;
+	
+	foreach(node->children, "part", (xml_handler_t)t_part, NULL);
+	return prof;
+}




More information about the alfs-log mailing list