r1631 - in dev/concept/moongoo: . libalfs syntax

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Sat Dec 4 18:54:54 PST 2004


Author: neocool
Date: 2004-12-04 19:54:52 -0700 (Sat, 04 Dec 2004)
New Revision: 1631

Added:
   dev/concept/moongoo/libalfs/libalfs.h
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/build.c
   dev/concept/moongoo/build.h
   dev/concept/moongoo/inc.mak
   dev/concept/moongoo/libalfs/Makefile
   dev/concept/moongoo/libalfs/alfs.c
   dev/concept/moongoo/libalfs/alfs.h
   dev/concept/moongoo/libalfs/repl.c
   dev/concept/moongoo/libalfs/repl.h
   dev/concept/moongoo/libalfs/util.c
   dev/concept/moongoo/libalfs/util.h
   dev/concept/moongoo/moongoo.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/syn.c
Log:
Update.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/Makefile	2004-12-05 02:54:52 UTC (rev 1631)
@@ -4,7 +4,7 @@
 OBJS=moongoo.o build.o plugin.o
 
 ifeq ($(OPTS),)
-OPTS=-q
+OPTS=
 OPTS+=~/projects/alfs/book/index.xml
 #OPTS+=~/projects/alfs/lfs-profile/LFS.xml
 #OPTS+=~/projects/alfs/ass/index.xml
@@ -23,3 +23,6 @@
 
 run: $(BIN)
 	./$(BIN) $(OPTS)
+
+build.o: build.h
+plugin.o: plugin.h

Modified: dev/concept/moongoo/build.c
===================================================================
--- dev/concept/moongoo/build.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/build.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,18 +1,67 @@
+#include <errno.h>
 #include <string.h>
+#include <unistd.h>
 
 #include <build.h>
-#include <util.h>
-#include <repl.h>
+#include <libalfs.h>
 
-void build_paralell (profile *prof, char **filter, char **p1, char **p2)
+replaceable *r;
+
+static int core_exec (command build)
+{	
+	if (!strcmp(build.cmd, "cd"))
+		return chdir(build.arg[0]);
+
+	return -1;
+}
+
+int build_pkg (package pkg)
 {
+	int i;
+	
+	for (i=0;i<pkg.n;i++)
+	{
+		command *build = &pkg.build[i];
+		int j;
+		char *argv[3];
+
+		if (!strncmp(build->cmd, "__", 2))
+		{
+			build->cmd+=2;
+			if (core_exec(*build))
+			{
+				fprintf(stderr, "core_exec(): %s: %s\n", build->cmd, 
+					strerror(errno));
+				return -1;
+			}
+			continue;
+		}
+		
+		argv[0] = "sh";
+		argv[1] = "-c";
+		argv[2] = strcut(build->cmd, 0, strlen(build->cmd));
+		for (j=0;j<build->n;j++)
+			argv[2] = strdog2(argv[2], build->arg[j]);
+		
+		if (execvp(argv[0], argv))
+		{
+			perror("shell");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+// TODO: Write shorter code for sed_paralell()
+void sed_paralell (profile *prof, char **filter, char **p1, char **p2)
+{
 	int i, j, k;
 	
 	for (i=0;i<prof->n;i++)
 		for (j=0;j<prof->ch[i].n;j++)
 			for (k=0;k<prof->ch[i].pkg[j].n;k++)
 			{
-				// TODO: Does not seem to work properly anymore.
 				int m = 0, o;
 				bool no = false;
 				package *pkg = &prof->ch[i].pkg[j];
@@ -44,7 +93,7 @@
 							opt = p2[o];
 						o++;
 					}
-					new[0] = strdog(opt, get_option("PARALELL"));
+					new[0] = strdog(opt, get_option(r, "PARALELL"));
 					old = moo->arg;
 					moo->arg = new;
 					free(old);

Modified: dev/concept/moongoo/build.h
===================================================================
--- dev/concept/moongoo/build.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/build.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -3,6 +3,9 @@
 
 #include <alfs.h>
 
-void build_paralell (profile *prof, char **filter, char **p1, char **p2);
+extern replaceable *r;
 
+int build_pkg (package pkg);
+void sed_paralell (profile *prof, char **filter, char **p1, char **p2);
+
 #endif

Modified: dev/concept/moongoo/inc.mak
===================================================================
--- dev/concept/moongoo/inc.mak	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/inc.mak	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS+=-std=c99 -D_BSD_SOURCE
+CFLAGS+=-std=c99 -D_BSD_SOURCE -D_GNU_SOURCE
 CFLAGS+=-Wall -Werror -g3
 
 CFLAGS+=`xml2-config --cflags`

Modified: dev/concept/moongoo/libalfs/Makefile
===================================================================
--- dev/concept/moongoo/libalfs/Makefile	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/Makefile	2004-12-05 02:54:52 UTC (rev 1631)
@@ -10,3 +10,8 @@
 $(LIB): $(OBJS)
 	ar crv $@ $^
 	ranlib $@
+
+alfs.o: alfs.h
+devel.o: devel.h
+repl.o: repl.h
+util.o: util.h

Modified: dev/concept/moongoo/libalfs/alfs.c
===================================================================
--- dev/concept/moongoo/libalfs/alfs.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/alfs.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -4,9 +4,22 @@
 #include <alfs.h>
 #include <util.h>
 
-xmlDocPtr doc;
 role *filter = NULL;
 
+void print_links (profile prof)
+{
+	int i, j, k;
+
+	for (i=0;i<prof.n;i++)
+		for (j=0;j<prof.ch[i].n;j++)
+			for (k=0;k<prof.ch[i].pkg[j].m;k++)
+			{
+				download moo = prof.ch[i].pkg[j].dl[k];
+				printf("%s: %s\n", algo2str(moo.algo), moo.sum);
+				printf("%s://%s\n", proto2str(moo.proto), moo.url);
+			}
+}
+		
 void print_cmd (command cmd)
 {
 	int i=0;
@@ -30,7 +43,7 @@
 	if (!pkg.vers)
 		printf("%s\n\n", pkg.name);
 	else
-		printf("%s-%s\n\n", pkg.name, pkg.vers);
+		printf("%s\nVersion: %s\n\n", pkg.name, pkg.vers);
 	term_reset();
 	
 	for (i=0;i<pkg.n;i++)
@@ -57,7 +70,7 @@
 	int i;
 
 	term_set(RESET, BLUE, BLACK);
-	printf("%s %s\n", prof.name, prof.vers);
+	printf("%s %s\n", prof.name, ((prof.vers) ? (prof.vers) : ""));
 	term_reset();
 	for (i=0;i<prof.n;i++)
 		print_chapter(prof.ch[i]);
@@ -180,19 +193,6 @@
 	return xmlNodeGetContent(moo);
 }
 
-char *entity_val (char *name)
-{
-	xmlEntityPtr ent = xmlGetDocEntity(doc, name);
-	char *ret;
-	
-	if (!ent)
-		return NULL;
-	ret=(char *)malloc(ent->length+1);
-	strncpy(ret, ent->content, ent->length);
-	ret[ent->length]='\0';
-	return ret;
-}
-
 char *role2str (role role)
 {
 	switch (role)
@@ -232,10 +232,24 @@
 		return SPAWN;
 
 	fprintf(stderr, "%s is an unknown role-attribute.\n", prop);
-	
 	return ROLE_NONE;
 }
 
+protocol parse_proto (xmlNodePtr node)
+{
+	char *prop = xmlGetProp(node, "type");
+
+	if (!prop)
+		return PROTO_NONE;
+	if (!strcmp(prop, "ftp"))
+		return FTP;
+	if (!strcmp(prop, "http"))
+		return HTTP;
+
+	fprintf(stderr, "%s is an unknown protocol.\n", prop);
+	return PROTO_NONE;
+}
+
 char *type2str (xmlElementType type)
 {
 	switch (type)
@@ -329,3 +343,33 @@
 
 	return NULL;
 }
+
+char *algo2str (hash_algo algo)
+{
+	switch (algo)
+	{
+		case (ALGO_NONE):
+			return "none";
+		case (MD5):
+			return "md5";
+		case (SHA1):
+			return "sha1";
+		default:
+			return "unknown";
+	}
+}
+
+char *proto2str (protocol proto)
+{
+	switch (proto)
+	{
+		case (PROTO_NONE):
+			return "none";
+		case (HTTP):
+			return "http";
+		case (FTP):
+			return "ftp";
+		default:
+			return "unknown";
+	}
+}

Modified: dev/concept/moongoo/libalfs/alfs.h
===================================================================
--- dev/concept/moongoo/libalfs/alfs.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/alfs.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -19,7 +19,7 @@
 
 typedef enum
 {
-	HASH_NONE = 1,
+	ALGO_NONE = 1,
 	MD5,
 	SHA1
 } hash_algo;
@@ -50,6 +50,8 @@
 	char *name, *vers;
 	command *build;
 	int n;
+	download *dl;
+	int m;
 } package;
 
 typedef struct
@@ -71,8 +73,6 @@
 	char *orig, *repl;
 } replaceable;
 
-extern xmlDocPtr doc;
-
 typedef void (*xml_handler_t) (xmlNodePtr node, void *data);
 
 void print_subtree (xmlNodePtr node);
@@ -80,6 +80,8 @@
 void print_cmd (command cmd);
 void print_chapter (chapter ch);
 void print_profile (profile prof);
+void print_links (profile prof);
+
 void set_filter (role *role);
 void unset_filter ();
 bool filtered (role role);
@@ -89,11 +91,13 @@
 char *find_value (xmlNodePtr node, char *str);
 char *find_values (xmlNodePtr node, char *str);
 char *find_values_repl (xmlNodePtr node, char *str, char **orig, char **repl);
-char *entity_val (char *name);
+
 package *search_pkg (profile *prof, char *name, char *ch);
-
 char *role2str (role role);
 char *type2str (xmlElementType type);
+char *algo2str (hash_algo algo);
+char *proto2str (protocol proto);
 role parse_role (xmlNodePtr node);
+protocol parse_proto (xmlNodePtr node);
 	
 #endif

Added: dev/concept/moongoo/libalfs/libalfs.h
===================================================================
--- dev/concept/moongoo/libalfs/libalfs.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/libalfs.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -0,0 +1,9 @@
+#ifndef __LIBALFS_H__
+#define __LIBALFS_H__
+
+#include <alfs.h>
+#include <devel.h>
+#include <repl.h>
+#include <util.h>
+
+#endif

Modified: dev/concept/moongoo/libalfs/repl.c
===================================================================
--- dev/concept/moongoo/libalfs/repl.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/repl.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -3,13 +3,15 @@
 #include <repl.h>
 #include <alfs.h>
 
-replaceable *r = NULL;
-
 void t_repl (xmlNodePtr node, void *data)
 {
+	replaceable *r = (replaceable *)data;
 	xmlNodePtr text = find_node(node->children, "text");
 	char *repl = xmlNodeGetContent(text);
-	char *opt = get_option(repl);
+	char *opt = get_option(r, repl);
+
+	if (!opt)
+		return;
 	
 	if (!strcmp(opt, ""))
 	{
@@ -20,7 +22,7 @@
 	xmlNodeSetContent(node, opt);
 }
 
-char *get_option (char *key)
+char *get_option (replaceable *r, char *key)
 {
 	int i=0;
 	
@@ -39,10 +41,14 @@
 
 replaceable *init_repl (char *fname)
 {
+	replaceable *r = NULL;
 	xmlDocPtr doc;
 	xmlNodePtr node;
 	int count=0;
 
+	if (!fname)
+		return NULL;
+	
 	doc=xmlParseFile(fname);
 	if (!doc)
 		return NULL;

Modified: dev/concept/moongoo/libalfs/repl.h
===================================================================
--- dev/concept/moongoo/libalfs/repl.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/repl.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -3,11 +3,8 @@
 
 #include <alfs.h>
 
-// TODO: Make moo.xml configurable
-#define MOO_XML		"moo.xml"
-
 void t_repl (xmlNodePtr node, void *data);
 replaceable *init_repl (char *fname);
-char *get_option (char *key);
+char *get_option (replaceable *r, char *key);
 
 #endif

Modified: dev/concept/moongoo/libalfs/util.c
===================================================================
--- dev/concept/moongoo/libalfs/util.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/util.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -372,3 +372,29 @@
 
 	return ret;
 }
+	
+char *extonly (char *url)
+{
+#define NUM_COMPR	2
+	
+	const char *compr[NUM_COMPR] = { ".bz2", ".gz" };
+	char *foo=strrchr(url, '.');
+	int i;
+
+	if (!foo)
+		return url;
+	
+	for (i=0;i<NUM_COMPR;i++)
+		if (!strcmp(foo, compr[i]))
+		{
+			char *tmp;
+			foo=strrchr(strcut(url, 0, strlen(url)-strlen(compr[i])), '.');
+			if (!foo)
+				return (char *)compr[i];
+			tmp=foo;
+			foo=(char *)malloc(strlen(tmp)+strlen(compr[i])+1);
+			sprintf(foo, "%s%s", tmp, compr[i]);
+		}
+		
+	return foo;
+}

Modified: dev/concept/moongoo/libalfs/util.h
===================================================================
--- dev/concept/moongoo/libalfs/util.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/libalfs/util.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -42,5 +42,6 @@
 char *strnstr (char *haystack, char *needle, int n);
 char *cut_trail (char *str, char *delim);
 char *strdog_path (char *str1, char *str2);
+char *extonly (char *url);
 
 #endif

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/moongoo.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,16 +1,18 @@
+#include <getopt.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <getopt.h>
 
-#include <alfs.h>
-#include <repl.h>
-#include <util.h>
 #include <build.h>
+#include <libalfs.h>
 #include <plugin.h>
 
 #define DEF_SYN		"book"
+#define MOO_XML		"/.nALFS/answers.xml"
+#define PLUG_DIR	"syntax"
 #define	VERSION		"0.0.2"
 
+/* Some default settings, those should be configurable in the final tool */
 role default_filter[4] = { NOEXECUTE, INTERACTIVE, TESTSUITE, 0 };
 char *paralell_filter[4] = { "configure-host", "clean", "mrproper", NULL };
 char *popt_pkg[2] = { "Glibc-20041115", NULL };
@@ -18,9 +20,10 @@
 
 int main (int argc, char **argv)
 {
-	char c, *syn = NULL, *moo_xml = NULL;
-	bool quiet = false;
+	char c, *syn = DEF_SYN, *moo_xml = MOO_XML, *plug_dir = PLUG_DIR;
+	bool quiet = false, build = false;
 	int i = 0;
+	xmlDocPtr doc;
 	xmlNodePtr cur;
 	plug_info *plugin;
 	profile *prof = NULL;
@@ -31,8 +34,9 @@
 		return 1;
 	}
 
-	// TODO: Make the plugin directory configurable
-	plugin = plugscan("syntax");
+	if (getenv("NALFS_PLUGIN_DIR"))
+		plug_dir = getenv("NALFS_PLUGIN_DIR");
+	plugin = plugscan(plug_dir);
 
 	if (!plugin)
 	{
@@ -40,7 +44,7 @@
 		return 2;
 	}
 
-	while ((c = getopt(argc, argv, "s:qVhc:")) != EOF)
+	while ((c = getopt(argc, argv, "s:qVhc:b")) != EOF)
 	{
 		switch (c)
 		{
@@ -70,16 +74,21 @@
 				return 0;
 			case 'h':
 				printf("moongoo [OPTIONS] BOOK\n");
-				printf("\t-s SYNTAX\tChoose syntax (help shows them)\n");
+				printf("\t-b\t\tBuild\n");
 				printf("\t-c CONF.XML\tXML configuration file.\n");
+				printf("\t-h\t\tPrint this fluff\n");
 				printf("\t-q\t\tNo output\n");
+				printf("\t-s SYNTAX\tChoose syntax (help shows them)\n");
 				printf("\t-V\t\tVersion information\n");
-				printf("\t-h\t\tPrint this fluff\n");
 				return 0;
 			case 'c':
 				moo_xml = (char *)malloc(strlen(optarg)+1);
 				strcpy(moo_xml, optarg);
 				break;
+			case 'b':
+				build = true;
+				quiet = true;
+				break;
 		}
 	}
 
@@ -89,14 +98,19 @@
 		return 2;
 	xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT);
 	cur=xmlDocGetRootElement(doc);
+
+	r = init_repl(strdog(getenv("HOME"), MOO_XML));
+	if (!r)
+	{
+		r = init_repl("moo.xml");
+		if (!r)
+			fprintf(stderr, "Configuration file could not be opened.\n");
+	}
 	
-	if (!syn)
-		syn = DEF_SYN;
-	
 	while (plugin[i].path)
 	{
 		if (!strcmp(syn, plugarg(plugin[i].path)))
-			prof = plugin[i].info->parse(cur);
+			prof = plugin[i].info->parse(cur, r);
 		i++;
 	}
 	
@@ -108,16 +122,23 @@
 		return 1;
 	}
 
+	if (build)
+	{
+		//print_profile(*prof);
+		build_pkg(prof->ch[0].pkg[0]);
+	}
+
 	if (!quiet)
 	{
-		/*package *glibc = search_pkg(prof, "Glibc-20041115", 
-			"chapter-building-system");*/
-		build_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
+		package *glibc = search_pkg(prof, "Glibc-20041115", 
+			"chapter-building-system");
+		sed_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
 		set_filter(default_filter);
 		
-		/*if (glibc)
-			print_pkg(*glibc);*/
-		print_profile(*prof);
+		if (glibc)
+			print_pkg(*glibc);
+		//print_profile(*prof);
+		//print_links(*prof);
 	}
 	
 	plugunload(plugin);

Modified: dev/concept/moongoo/plugin.h
===================================================================
--- dev/concept/moongoo/plugin.h	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/plugin.h	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,16 +1,16 @@
 #ifndef __PLUGIN_H__
 #define __PLUGIN_H__
 
-#include <alfs.h>
+#include <libalfs.h>
 
-#define PLUG_VER	2
+#define PLUG_VER	3
 #define PLUG_EXT	"so"
 
 typedef struct
 {
 	char *name;
 	int vers;
-	profile *(* parse) (xmlNodePtr node);
+	profile *(* parse) (xmlNodePtr node, replaceable *r);
 } t_plug;
 
 typedef struct

Modified: dev/concept/moongoo/syntax/ass.c
===================================================================
--- dev/concept/moongoo/syntax/ass.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/syntax/ass.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,12 +1,12 @@
+#include <libgen.h>
 #include <string.h>
 
-#include <alfs.h>
-#include <util.h>
+#include <libalfs.h>
 #include <plugin.h>
 
 profile *prof;
 
-profile *ass_profile (xmlNodePtr node);
+profile *ass_profile (xmlNodePtr node, replaceable *r);
 
 static t_plug ass_plugin =
 {
@@ -20,8 +20,8 @@
 	return &ass_plugin;
 }
 
-// TODO: Support download/directory in the ASS parser
-void process_cmd3 (char *line, xmlNodePtr node)
+
+static void process_cmd (char *line)
 {
 	int i, j, k;
 
@@ -47,7 +47,7 @@
 	}
 }
 
-void t_shell2 (xmlNodePtr node, void *data)
+static  void t_shell (xmlNodePtr node, void *data)
 {
 	char *line = squeeze(xmlNodeGetContent(node));
 	line = strkill(line, "\\\n");
@@ -59,16 +59,75 @@
 		while ((line) && (strlen(line)))
 		{
 			tmp = strsep(&line, "\n");
-			process_cmd3(tmp, node);
+			process_cmd(tmp);
 		}
 	}
 	else
-		process_cmd3(line, node);
+		process_cmd(line);
 }
 
-void t_page (xmlNodePtr node, void *data)
+static  void t_item (xmlNodePtr node, void *data)
 {
+	int i, j, k;
+	download *moo;
+
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+	prof->ch[i].pkg[j].dl = realloc(prof->ch[i].pkg[j].dl,
+		(++prof->ch[i].pkg[j].m)*sizeof(download));
+	k = prof->ch[i].pkg[j].m-1;
+	moo = &prof->ch[i].pkg[j].dl[k];
+
+	if (xmlGetProp(node, "sha1"))
+	{
+		moo->algo = SHA1;
+		moo->sum = xmlGetProp(node, "sha1");
+	}
+	else
+	if (xmlGetProp(node, "md5"))
+	{
+		moo->algo = MD5;
+		moo->sum = xmlGetProp(node, "md5");
+	}
+	else
+	{
+		moo->algo = ALGO_NONE;
+		moo->sum = NULL;
+	}
+	
+	moo->proto = parse_proto(node);
+	moo->url = xmlNodeGetContent(node);
+}
+
+static  void t_down (xmlNodePtr node, void *data)
+{
+	foreach(node->children, "item", (xml_handler_t)t_item, NULL);
+}
+
+static  void t_unpack (char *url)
+{
+	char *ext = extonly(url), *ret = NULL;
+
+	if (!strcmp(ext, ".tar.gz"))
+		ret = "tar xfz ";
+	if (!strcmp(ext, ".tar.bz2"))
+		ret = "tar xfj ";
+
+	if (!ret)
+	{
+		fprintf(stderr, "Archive extension '%s' is unknown.\n", ext);
+		return;
+	}
+
+	ret = strdog(ret, basename(url));
+	process_cmd(ret);
+	free(ret);
+}
+
+static  void t_page (xmlNodePtr node, void *data)
+{
 	int i, j;
+	xmlNodePtr dir = find_node(node->children, "directory");
 
 	i = prof->n-1;
 	prof->ch[i].pkg = realloc(prof->ch[i].pkg,
@@ -79,10 +138,16 @@
 	prof->ch[i].pkg[j].vers = find_value(node, "version");
 	prof->ch[i].pkg[j].build = NULL;
 	prof->ch[i].pkg[j].n = 0;
-	foreach(node->children, "shell", (xml_handler_t)t_shell2, NULL);
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+
+	foreach(node->children, "download", (xml_handler_t)t_down, NULL);
+	t_unpack(prof->ch[i].pkg[j].dl[0].url);
+	process_cmd(strdog("__cd ", xmlNodeGetContent(dir)));
+	foreach(node->children, "shell", (xml_handler_t)t_shell, NULL);
 }
 
-void t_chapter2 (xmlNodePtr node, void *data)
+static  void t_chapter (xmlNodePtr node, void *data)
 {
 	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
 	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
@@ -92,7 +157,7 @@
 	foreach(node->children, "page", (xml_handler_t)t_page, NULL);
 }
 
-profile *ass_profile (xmlNodePtr node)
+profile *ass_profile (xmlNodePtr node, replaceable *r)
 {
 	node = find_node(node, "ass");
 
@@ -107,6 +172,6 @@
 	prof->vers = find_value(node, "version");
 	prof->ch = NULL;
 	prof->n = 0;
-	foreach(node->children, "chapter", (xml_handler_t)t_chapter2, NULL);
+	foreach(node->children, "chapter", (xml_handler_t)t_chapter, NULL);
 	return prof;
 }

Modified: dev/concept/moongoo/syntax/book.c
===================================================================
--- dev/concept/moongoo/syntax/book.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/syntax/book.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -1,22 +1,14 @@
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 
-#include <alfs.h>
-#include <repl.h>
-#include <util.h>
+#include <libalfs.h>
 #include <plugin.h>
 
 command *cmd;
 int num;
 profile *prof;
-replaceable *__r;
 
-void t_sect1 (xmlNodePtr node, void *data);
-void process_cmd (char *line, xmlNodePtr node);
-void __t_userinput (xmlNodePtr node, void *data);
-command *t_userinput (xmlNodePtr node, int *n);
-void t_chapter (xmlNodePtr node);
-profile *bookasprofile (xmlNodePtr node);
+profile *bookasprofile (xmlNodePtr node, replaceable *r);
 
 static t_plug book_plugin =
 {
@@ -30,38 +22,8 @@
 	return &book_plugin;
 }
 
-void t_sect1 (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 = strdog(lower_case(title), "version");
-	// TODO: Name and version are not correctly separated
-	prof->ch[i].pkg[j].vers = entity_val(tmp);
-	prof->ch[i].pkg[j].name = strcut(title, 0, strlen(title)-
-		((prof->ch[i].pkg[j].vers) ? 1 : 0));
-	prof->ch[i].pkg[j].build = t_userinput(node->children, 
-		&prof->ch[i].pkg[j].n);
-	free(tmp);
-
-	if (!prof->ch[i].pkg[j].n)
-		prof->ch[i].n--;
-}
-
-void process_cmd (char *line, xmlNodePtr node)
+static void process_cmd (char *line, xmlNodePtr node)
 {
 	cmd = realloc(cmd, (++num)*sizeof(command));
 	cmd[num-1].role = parse_role(node);
@@ -80,11 +42,11 @@
 	}
 }
 
-void __t_userinput (xmlNodePtr node, void *data)
+static void __t_userinput (xmlNodePtr node, void *data)
 {
 	char *line;
 
-	foreach(node->children, "replaceable", (xml_handler_t)t_repl, __r);
+	foreach(node->children, "replaceable", (xml_handler_t)t_repl, NULL);
 	line = squeeze(xmlNodeGetContent(node));
 	line = strkill(line, "\\\n");
 
@@ -111,7 +73,7 @@
 		process_cmd(line, node);
 }
 
-command *t_userinput (xmlNodePtr node, int *n)
+static command *t_userinput (xmlNodePtr node, int *n)
 {
 	cmd = NULL;
 	num = 0;
@@ -120,8 +82,39 @@
 	return cmd;
 }
 
-void t_chapter (xmlNodePtr node)
+static void t_sect1 (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 = strdog(lower_case(title), "version");
+	// TODO: Name and version are not correctly separated
+	prof->ch[i].pkg[j].vers = NULL;
+	prof->ch[i].pkg[j].name = strcut(title, 0, strlen(title)-
+		((prof->ch[i].pkg[j].vers) ? 1 : 0));
+	prof->ch[i].pkg[j].build = t_userinput(node->children, 
+		&prof->ch[i].pkg[j].n);
+	free(tmp);
+
+	if (!prof->ch[i].pkg[j].n)
+		prof->ch[i].n--;
+}
+
+static void t_chapter (xmlNodePtr node)
+{
 	int i = prof->n-1;
 	prof->ch[i].name = xmlGetProp(node, "xreflabel");
 	prof->ch[i].ref = xmlGetProp(node, "id");
@@ -130,10 +123,9 @@
 	foreach(node->children, "sect1", (xml_handler_t)t_sect1, NULL);
 }
 
-profile *bookasprofile (xmlNodePtr node)
+profile *bookasprofile (xmlNodePtr node, replaceable *r)
 {
 	xmlNodePtr info = find_node(node, "bookinfo");
-	__r = init_repl(MOO_XML);
 
 	if (!info)
 	{

Modified: dev/concept/moongoo/syntax/nalfs.c
===================================================================
--- dev/concept/moongoo/syntax/nalfs.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/syntax/nalfs.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -11,7 +11,7 @@
 profile *prof;
 char commando[BUF_LEN];
 
-profile *nalfs_profile (xmlNodePtr node);
+profile *nalfs_profile (xmlNodePtr node, replaceable *r);
 
 static t_plug nalfs_plugin =
 {
@@ -314,7 +314,7 @@
 	foreach(node->children, "alfs", (xml_handler_t)t_alfs, NULL);
 }
 
-profile *nalfs_profile (xmlNodePtr node)
+profile *nalfs_profile (xmlNodePtr node, replaceable *r)
 {
 	node = find_node(node, "alfs");
 
@@ -326,7 +326,7 @@
 	
 	prof = (profile *)malloc(sizeof(profile));
 	prof->name = "nALFS legacy profile";
-	prof->vers = entity_val("LFS-version");
+	prof->vers = NULL;
 	prof->ch = NULL;
 	prof->n = 0;
 	foreach(node->children, "stage", (xml_handler_t)t_stage, NULL);

Modified: dev/concept/moongoo/syntax/syn.c
===================================================================
--- dev/concept/moongoo/syntax/syn.c	2004-12-04 19:44:22 UTC (rev 1630)
+++ dev/concept/moongoo/syntax/syn.c	2004-12-05 02:54:52 UTC (rev 1631)
@@ -6,7 +6,7 @@
 
 profile *prof;
 
-profile *syn_profile (xmlNodePtr node);
+profile *syn_profile (xmlNodePtr node, replaceable *r);
 
 static t_plug syn_plugin =
 {
@@ -95,10 +95,10 @@
 	prof->ch[i].ref = prof->ch[i].name;
 	prof->ch[i].pkg = NULL;
 	prof->ch[i].n = 0;
-	foreach(node->children, "package", (xml_handler_t)t_pkg, NULL);
+	foreach(node->children, "page", (xml_handler_t)t_pkg, NULL);
 }
 
-profile *syn_profile (xmlNodePtr node)
+profile *syn_profile (xmlNodePtr node, replaceable *r)
 {
 	node = find_node(node, "hive");
 
@@ -119,7 +119,6 @@
 	{
 		if (!strcmp(node->name, "section"))
 		{
-			printf("%s\n", xmlGetProp(node, "title"));
 			prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
 			t_section(node);
 		}




More information about the alfs-log mailing list