r1617 - dev/concept/moongoo

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Wed Dec 1 16:26:33 PST 2004


Author: neocool
Date: 2004-12-01 17:26:32 -0700 (Wed, 01 Dec 2004)
New Revision: 1617

Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/alfs.c
   dev/concept/moongoo/alfs.h
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/nalfs.c
   dev/concept/moongoo/util.c
   dev/concept/moongoo/util.h
Log:
Update.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/Makefile	2004-12-02 00:26:32 UTC (rev 1617)
@@ -14,7 +14,7 @@
 #BOOK=~/projects/alfs/ass/index.xml
 #BOOK=~/projects/hive/unstable/profile.xml
 
-.PHONY: all clean compile run memcheck debug todo upload bug
+.PHONY: all clean compile run memcheck debug todo
 
 all: run
 
@@ -36,14 +36,6 @@
 todo:
 	@grep "TODO:" *.c *.h|cut -d" " -f3-|sort
 
-upload: clean
-	@release_snap
-	@scp moongoo-*.tar.bz2 l14h.org:~/public_html/nALFS2/snap/
-	@rm -f moongoo-*.tar.bz2
-
-bug: 
-	@grep "BUG:" *.c *.h|cut -d" " -f3-|sort
-
 $(BIN): $(OBJS)
 alfs.o: alfs.h
 util.o: util.h

Modified: dev/concept/moongoo/alfs.c
===================================================================
--- dev/concept/moongoo/alfs.c	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/alfs.c	2004-12-02 00:26:32 UTC (rev 1617)
@@ -129,6 +129,49 @@
 	return ret;
 }			
 
+char *find_values_repl (xmlNodePtr node, char *str, char **orig, char **repl)
+{
+	char *ret;
+
+	if ((!node)||(!str))
+		return "";
+
+	if ((!orig)||(!repl))
+		return find_values(node, str);
+
+	ret = (char *)malloc(1);
+	strcpy(ret, "");
+
+	while (node)
+	{
+		if (!strcmp(node->name, str))
+		{
+			int i=0;
+			bool rep = false;
+			char *tmp = xmlNodeGetContent(node);
+			
+			while ((orig[i])&&(repl[i]))
+			{
+				if (!strcmp(tmp, orig[i]))
+				{
+					tmp = repl[i];
+					rep = true;
+					break;
+				}
+				i++;
+			}
+
+			if (!rep)
+				fprintf(stderr, "No replacement for '%s'.\n", tmp);
+
+			ret = strdog2(ret, tmp);
+		}
+		node = node->next;
+	}
+
+	return ret;
+}
+
 char *find_value (xmlNodePtr node, char *str)
 {
 	xmlNodePtr moo = find_node(node, str);
@@ -244,26 +287,6 @@
 	}
 }
 
-void resolve_entities (xmlNodePtr node)
-{
-	while (node)
-	{
-		if (node->type==XML_ENTITY_REF_NODE)
-		{
-			// BUG: Does not resolve entities which are outside text nodes
-			if ((node->prev) && (node->prev->type==XML_TEXT_NODE) &&
-				(strcmp(node->prev->parent->name, "title")))
-			{
-				char *text = entity_val((char *)node->name);
-				if (text)
-					xmlNodeAddContent(node->prev, text);
-			}
-		}
-		resolve_entities(node->children);
-		node=node->next;
-	}
-}
-
 void set_filter (role *role)
 {
 	filter = role;

Modified: dev/concept/moongoo/alfs.h
===================================================================
--- dev/concept/moongoo/alfs.h	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/alfs.h	2004-12-02 00:26:32 UTC (rev 1617)
@@ -84,11 +84,11 @@
 void unset_filter ();
 bool filtered (role role);
 
-void resolve_entities (xmlNodePtr node);
 void foreach (xmlNodePtr node, char *str, xml_handler_t func, void *data);
 xmlNodePtr find_node (xmlNodePtr root, char *str);
 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);
 
 char *role2str (role role);

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/moongoo.c	2004-12-02 00:26:32 UTC (rev 1617)
@@ -26,9 +26,8 @@
 	doc=xmlParseFile(argv[1]);
 	if (!doc)
 		return 2;
-	xmlXIncludeProcessFlags(doc, XML_PARSE_NONET);
+	xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT);
 	cur=xmlDocGetRootElement(doc);
-	resolve_entities(cur);
 	
 	//prof=bookasprofile(cur);
 	//prof=syn_profile(cur);

Modified: dev/concept/moongoo/nalfs.c
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/nalfs.c	2004-12-02 00:26:32 UTC (rev 1617)
@@ -13,7 +13,7 @@
 
 void parse_remove (xmlNodePtr node)
 {
-	// TODO: Handle <remove>
+	//printf("rm -rf %s\n", xmlNodeGetContent(node));
 }
 
 void parse_make (xmlNodePtr node)
@@ -32,40 +32,46 @@
 
 void parse_copy (xmlNodePtr node)
 {
-	char *known[4] = { "source", "destination", "option", NULL };
-	dbg_print(node, known);
-	dbg_print2(node, "option");
+	/*char *orig[4] = { "force", "archive", "recursive", NULL };
+	char *repl[4] = { "-f", "-a", "-r", NULL };
+	node = node->children;
+	printf("cp %s %s %s\n", find_values_repl(node, "option", orig, repl),
+			find_value(node, "source"), find_value(node, "destination"));*/
 }
 
-void parse_environment (xmlNodePtr node)
+void __parse_env (xmlNodePtr node, void *data)
 {
+	/*printf("export %s=\"%s\"\n", xmlGetProp(node, "name"), 
+			xmlNodeGetContent(node));*/
 }
 
+void parse_environment (xmlNodePtr node, void *data)
+{
+	foreach(node->children, "variable", (xml_handler_t)__parse_env, NULL);
+}
+
+void parse_base (xmlNodePtr node, void *data)
+{
+	//printf("cd %s\n", xmlNodeGetContent(node));
+}
+
 void parse_stageinfo (xmlNodePtr node)
 {
-	node = node->children;
-	while (node)
-	{
-		if (node->type!=XML_TEXT_NODE)
-		{
-			if (!strcmp(node->name, "environment"))
-				parse_environment(node);
-			else
-			if (!strcmp(node->name, "base"))
-				; //xmlNodeGetContent(node);
-			else
-				fprintf(stderr, "Tag '%s' not handled.\n", node->name);
-		}
-		node = node->next;
-	}
+	foreach(node->children, "environment", (xml_handler_t)parse_environment, 
+		NULL);
+	foreach(node->children, "base", (xml_handler_t)parse_base, NULL);
 }
 
 void parse_textdump (xmlNodePtr node)
 {
+	/*printf("cat >%s << EOF\n%s\nEOF\n", find_value(node->children, "file"),
+		cut_trail(find_value(node->children, "content"), "="));*/
 }
 
 void parse_execute (xmlNodePtr node)
 {
+	/*printf("%s %s\n", xmlGetProp(node, "command"), 
+		find_values(node->children, "param"));*/
 }
 
 void parse_mkdir (xmlNodePtr node)
@@ -157,7 +163,7 @@
 				parse_textdump(node);
 			else
 			if (!strcmp(node->name, "execute"))
-				parse_textdump(node);
+				parse_execute(node);
 			else
 			if (!strcmp(node->name, "mkdir"))
 				parse_mkdir(node);
@@ -202,8 +208,7 @@
 
 	//printf("%s\n", xmlGetProp(node, "name"));
 	prof->ch[i].pkg[j].name = xmlGetProp(node, "name");
-	// TODO: <package version="moo"> cannot be parsed yet
-	prof->ch[i].pkg[j].vers = NULL;
+	prof->ch[i].pkg[j].vers = xmlGetProp(node, "version");
 	prof->ch[i].pkg[j].build = NULL;
 	prof->ch[i].pkg[j].n = 0;
 	foreach(node->children, "stage", (xml_handler_t)t_stage2, NULL);

Modified: dev/concept/moongoo/util.c
===================================================================
--- dev/concept/moongoo/util.c	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/util.c	2004-12-02 00:26:32 UTC (rev 1617)
@@ -324,3 +324,37 @@
 	sprintf(cmd, "%c[m", 0x1B);
 	printf(cmd);
 }
+
+char *cut_trail (char *str, char *delim)
+{
+	char *ret;
+
+	if (!str)
+		return NULL;
+	
+	ret = (char *)malloc(1);
+	strcpy(ret, "");
+		
+	while ((str) && (strlen(str)))
+	{
+		char *t = ret, *tmp = strsep(&str, "\n");
+		tmp = notrail(tmp, "\t");
+		
+		if (!tmp)
+			continue;
+		
+		if (strcmp(tmp, ""))
+		{
+			tmp = strstr(tmp, delim);
+			tmp++;
+		}
+
+		ret = strdog(ret, tmp);
+		free(t);
+		t = ret;
+		ret = strdog(ret, "\n");
+		free(t);
+	}
+
+	return ret;
+}

Modified: dev/concept/moongoo/util.h
===================================================================
--- dev/concept/moongoo/util.h	2004-12-01 21:06:51 UTC (rev 1616)
+++ dev/concept/moongoo/util.h	2004-12-02 00:26:32 UTC (rev 1617)
@@ -40,5 +40,6 @@
 char *squeeze (char *str);
 char *strkill (char *str, char *tokill);
 char *strnstr (char *haystack, char *needle, int n);
+char *cut_trail (char *str, char *delim);
 
 #endif




More information about the alfs-log mailing list