r1624 - in dev/concept/moongoo: . libalfs syntaxes

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Fri Dec 3 14:27:07 PST 2004


Author: neocool
Date: 2004-12-03 15:27:05 -0700 (Fri, 03 Dec 2004)
New Revision: 1624

Added:
   dev/concept/moongoo/libalfs/
   dev/concept/moongoo/libalfs/alfs.c
   dev/concept/moongoo/libalfs/alfs.h
   dev/concept/moongoo/libalfs/devel.c
   dev/concept/moongoo/libalfs/devel.h
   dev/concept/moongoo/libalfs/repl.c
   dev/concept/moongoo/libalfs/util.c
   dev/concept/moongoo/libalfs/util.h
   dev/concept/moongoo/syntaxes/
   dev/concept/moongoo/syntaxes/ass.c
   dev/concept/moongoo/syntaxes/book.c
   dev/concept/moongoo/syntaxes/nalfs.c
   dev/concept/moongoo/syntaxes/syn.c
Removed:
   dev/concept/moongoo/alfs.c
   dev/concept/moongoo/alfs.h
   dev/concept/moongoo/ass.c
   dev/concept/moongoo/ass.h
   dev/concept/moongoo/book.c
   dev/concept/moongoo/book.h
   dev/concept/moongoo/devel.c
   dev/concept/moongoo/devel.h
   dev/concept/moongoo/nalfs.c
   dev/concept/moongoo/nalfs.h
   dev/concept/moongoo/repl.c
   dev/concept/moongoo/syn.c
   dev/concept/moongoo/syn.h
   dev/concept/moongoo/util.c
   dev/concept/moongoo/util.h
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/repl.h
Log:
Restrucutring underway ...


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/Makefile	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,49 +1,16 @@
-CC=gcc
-CFLAGS=-std=c99 -D_BSD_SOURCE -I. 
-
-CFLAGS+=`xml2-config --cflags`
-LDLIBS+=`xml2-config --libs`
-
-CFLAGS+=-Wall -Werror -g3
-
 BIN=moongoo
-OBJS=alfs.o book.o util.o repl.o syn.o nalfs.o ass.o devel.o build.o
+OBJS=alfs.o util.o repl.o devel.o build.o plugin.o
 
-BOOK=~/projects/alfs/book/index.xml
-#BOOK=~/projects/alfs/lfs-profile/LFS.xml
-#BOOK=~/projects/alfs/ass/index.xml
-#BOOK=~/projects/hive/unstable/profile.xml
-
+ifeq ($(OPTS),)
 OPTS=
+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
+endif
 
-.PHONY: all clean compile run memcheck debug todo
+.PHONY: all
 
 all: run
 
-clean:
-	rm -f $(BIN) $(OBJS)
-	
-compile: $(BIN)
-
-run: compile
-	./$(BIN) $(OPTS) $(BOOK)
-
-memcheck: compile
-	valgrind -q --tool=memcheck $(BIN) $(OPTS) $(BOOK)
-
-debug: compile
-	@echo "Book: $(OPTS) $(BOOK)"
-	gdb ./$(BIN)
-
-todo:
-	@grep "TODO:" *.c *.h|cut -d" " -f3-|sort
-
-$(BIN): $(OBJS)
-alfs.o: alfs.h
-util.o: util.h
-book.o: book.h
-repl.o: repl.h
-nalfs.o: nalfs.h
-ass.o: ass.h
-devel.o: devel.h
-build.o: build.h
+include inc.mak

Deleted: dev/concept/moongoo/alfs.c
===================================================================
--- dev/concept/moongoo/alfs.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/alfs.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,331 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-
-#include <alfs.h>
-#include <util.h>
-
-xmlDocPtr doc;
-role *filter = NULL;
-
-void print_cmd (command cmd)
-{
-	int i=0;
-
-	if (filtered(cmd.role))
-		return;
-	
-	printf("%s ", cmd.cmd);
-	for (i=0;i<cmd.n;i++)
-		printf("%s ", cmd.arg[i]);
-	if (cmd.role!=ROLE_NONE)
-		printf("(%s)", role2str(cmd.role));
-	printf("\n");
-}
-
-void print_pkg (package pkg)
-{
-	int i;
-	
-	term_set(RESET, GREEN, BLACK);
-	if (!pkg.vers)
-		printf("%s\n\n", pkg.name);
-	else
-		printf("%s-%s\n\n", pkg.name, pkg.vers);
-	term_reset();
-	
-	for (i=0;i<pkg.n;i++)
-		print_cmd(pkg.build[i]);
-	printf("\n");
-}		
-
-void print_chapter (chapter ch)
-{
-	int i;
-
-	if (!ch.n)
-		return;
-
-	term_set(RESET, RED, BLACK);
-	printf("%s\n", ch.name);
-	term_reset();
-	for (i=0;i<ch.n;i++)
-		print_pkg(ch.pkg[i]);
-}
-
-void print_profile (profile prof)
-{
-	int i;
-
-	term_set(RESET, BLUE, BLACK);
-	printf("%s %s\n", prof.name, prof.vers);
-	term_reset();
-	for (i=0;i<prof.n;i++)
-		print_chapter(prof.ch[i]);
-}
-
-void print_subtree (xmlNodePtr node)
-{
-	while (node)
-	{
-		printf("%s(%s): %s\n", node->name, type2str(node->type), 
-			xmlNodeGetContent(node));
-		print_subtree(node->children);
-		printf("\n");
-		node=node->next;
-	}
-}
-
-void foreach (xmlNodePtr node, char *str, xml_handler_t func, void *data)
-{
-	if (!str)
-		return;
-	
-	while (node)
-	{
-		if (!strcmp(node->name, str))
-			func(node, data);
-		foreach(node->children, str, func, data);
-		node=node->next;
-	}
-}
-
-xmlNodePtr find_node (xmlNodePtr root, char *str)
-{
-	if (!str)
-		return NULL;
-
-	while (root)
-	{
-		xmlNodePtr tmp = NULL;;
-		
-		if (!strcmp(root->name, str))
-			return root;
-		tmp=find_node(root->children, str);
-		if (tmp)
-			return tmp;
-		root=root->next;
-	}
-	
-	return NULL;
-}
-
-char *find_values (xmlNodePtr node, char *str)
-{
-	char *ret;
-
-	if ((!node)||(!str))
-		return "";
-
-	ret = (char *)malloc(1);
-	strcpy(ret, "");
-
-	while (node)
-	{
-		if (!strcmp(node->name, str))
-			ret = strdog2(ret, xmlNodeGetContent(node));
-		node = node->next;
-	}
-
-	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);
-	if (!moo)
-		return "";
-	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)
-	{
-		case (ROLE_NONE):
-			return "none";
-		case (NOEXECUTE):
-			return "noexecute";
-		case (INTERACTIVE):
-			return "interactive";
-		case (TESTSUITE):
-			return "testsuite";
-		case (INSTALL):
-			return "install";
-		case (CHROOT):
-			return "chroot";
-		default:
-			return "unknown";
-	}
-}
-
-role parse_role (xmlNodePtr node)
-{
-	char *prop = xmlGetProp(node, "role");
-
-	if (!prop)
-		return ROLE_NONE;
-	if (!strcmp(prop, "noexecute"))
-		return NOEXECUTE;
-	if (!strcmp(prop, "interactive"))
-		return INTERACTIVE;
-	if (!strcmp(prop, "testsuite"))
-		return TESTSUITE;
-	if (!strcmp(prop, "install"))
-		return INSTALL;
-	if (!strcmp(prop, "chroot"))
-		return CHROOT;
-
-	fprintf(stderr, "%s is an unknown role-attribute.\n", prop);
-	
-	return ROLE_NONE;
-}
-
-char *type2str (xmlElementType type)
-{
-	switch (type)
-	{
-    	case (XML_ELEMENT_NODE):
-			return "element";
-		case (XML_ATTRIBUTE_NODE):
-			return "attribute";
-    	case (XML_TEXT_NODE):
-			return "text";
-		case (XML_CDATA_SECTION_NODE):
-			return "cdata section";
-    	case (XML_ENTITY_REF_NODE):
-			return "entity ref";
-    	case (XML_ENTITY_NODE):
-			return "entity";
-    	case (XML_PI_NODE):
-			return "pi";
-    	case (XML_COMMENT_NODE):
-			return "comment";
-    	case (XML_DOCUMENT_NODE):
-			return "document";
-    	case (XML_DOCUMENT_TYPE_NODE):
-			return "document type";
-   		case (XML_DOCUMENT_FRAG_NODE):
-			return "document frag";
-    	case (XML_NOTATION_NODE):
-			return "notation";
-    	case (XML_HTML_DOCUMENT_NODE):
-			return "HTML document";
-    	case (XML_DTD_NODE):
-			return "DTD";
-    	case (XML_ELEMENT_DECL):
-			return "element declaration";
-    	case (XML_ATTRIBUTE_DECL):
-			return "attribute declaration";
-    	case (XML_ENTITY_DECL):
-			return "entity declaration";
-    	case (XML_NAMESPACE_DECL):
-			return "namespace declaration";
-    	case (XML_XINCLUDE_START):
-			return "xinclude start";
-    	case (XML_XINCLUDE_END):
-			return "xinclude end";
-   		case (XML_DOCB_DOCUMENT_NODE):
-			return "docbook";
-		default:
-			return "unknown";
-	}
-}
-
-void set_filter (role *role)
-{
-	filter = role;
-}
-
-void unset_filter ()
-{
-	filter = NULL;
-}
-
-bool filtered (role role)
-{
-	int i=0;
-
-	if (!filter)
-		return false;
-
-	while (filter[i])
-	{
-		if (role==filter[i])
-			return true;
-		i++;
-	}
-	return false;
-}
-
-package *search_pkg (profile *prof, char *name, char *ch)
-{
-	int i, j;
-
-	for (i=0;i<prof->n;i++)
-	{
-		if (strcmp(ch, prof->ch[i].ref))
-			continue;
-		
-		for (j=0;j<prof->ch[i].n;j++)
-			if (!strcmp(name, prof->ch[i].pkg[j].name))
-				return &prof->ch[i].pkg[j];
-	}
-
-	return NULL;
-}

Deleted: dev/concept/moongoo/alfs.h
===================================================================
--- dev/concept/moongoo/alfs.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/alfs.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,99 +0,0 @@
-#ifndef __ALFS_H__
-#define __ALFS_H__
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include <libxml/xinclude.h>
-#include <libxml/tree.h>
-
-typedef enum
-{
-	ROLE_NONE = 1,
-	NOEXECUTE,
-	INTERACTIVE,
-	TESTSUITE,
-	INSTALL,
-	CHROOT
-} role;
-
-typedef enum
-{
-	HASH_NONE = 1,
-	MD5,
-	SHA1
-} hash_algo;
-
-typedef enum
-{
-	PROTO_NONE = 1,
-	HTTP,
-	FTP
-} protocol;
-
-typedef struct
-{
-	hash_algo algo;
-	protocol proto;
-	char *url, *sum;
-} download;
-
-typedef struct
-{
-	char *cmd, **arg;
-	int n;
-	role role;
-} command;
-
-typedef struct
-{
-	char *name, *vers;
-	command *build;
-	int n;
-} package;
-
-typedef struct
-{
-	char *name, *ref;
-	package *pkg;
-	int n;
-} chapter;
-
-typedef struct
-{
-	char *name, *vers;
-	chapter *ch;
-	int n;
-} profile;
-
-typedef struct
-{
-	char *orig, *repl;
-} replaceable;
-
-extern xmlDocPtr doc;
-
-typedef void (*xml_handler_t) (xmlNodePtr node, void *data);
-
-void print_subtree (xmlNodePtr node);
-void print_pkg (package pkg);
-void print_cmd (command cmd);
-void print_chapter (chapter ch);
-void print_profile (profile prof);
-void set_filter (role *role);
-void unset_filter ();
-bool filtered (role role);
-
-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);
-package *search_pkg (profile *prof, char *name, char *ch);
-
-char *role2str (role role);
-char *type2str (xmlElementType type);
-role parse_role (xmlNodePtr node);
-	
-#endif

Deleted: dev/concept/moongoo/ass.c
===================================================================
--- dev/concept/moongoo/ass.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/ass.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,97 +0,0 @@
-#include <string.h>
-
-#include <ass.h>
-#include <util.h>
-
-profile *prof;
-
-// TODO: Support download/directory in the ASS parser
-void process_cmd3 (char *line, xmlNodePtr node)
-{
-	int i, j, k;
-
-	i = prof->n-1;
-	j = prof->ch[i].n-1;
-	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build,
-			(++prof->ch[i].pkg[j].n)*sizeof(command));
-	k = prof->ch[i].pkg[j].n-1;
-	
-	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
-
-	if (strcnt(line, " "))
-	{
-		prof->ch[i].pkg[j].build[k].cmd = strcut(line, 0, whereis(line, ' '));
-		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(line, " "), 
-				" "), " ", &prof->ch[i].pkg[j].build[k].n);
-	}
-	else
-	{
-		prof->ch[i].pkg[j].build[k].cmd = line;
-		prof->ch[i].pkg[j].build[k].arg = NULL;
-		prof->ch[i].pkg[j].build[k].n = 0;
-	}
-}
-
-void t_shell2 (xmlNodePtr node, void *data)
-{
-	char *line = squeeze(xmlNodeGetContent(node));
-	line = strkill(line, "\\\n");
-
-	if (strcnt(line, "\n"))
-	{
-		char *tmp;
-
-		while ((line) && (strlen(line)))
-		{
-			tmp = strsep(&line, "\n");
-			process_cmd3(tmp, node);
-		}
-	}
-	else
-		process_cmd3(line, node);
-}
-
-void t_page (xmlNodePtr node, void *data)
-{
-	int i, j;
-
-	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;
-
-	prof->ch[i].pkg[j].name = find_value(node, "title");
-	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);
-}
-
-void t_chapter2 (xmlNodePtr node, void *data)
-{
-	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
-	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
-	prof->ch[prof->n-1].ref = xmlGetProp(node, "ref");
-	prof->ch[prof->n-1].pkg = NULL;
-	prof->ch[prof->n-1].n = 0;
-	foreach(node->children, "page", (xml_handler_t)t_page, NULL);
-}
-
-profile *ass_profile (xmlNodePtr node)
-{
-	node = find_node(node, "ass");
-
-	if (!node)
-	{
-		fprintf(stderr, "XML document is not a valid ASS profile.\n");
-		return NULL;
-	}
-	
-	prof = (profile *)malloc(sizeof(profile));
-	prof->name = find_value(node, "title");
-	prof->vers = find_value(node, "version");
-	prof->ch = NULL;
-	prof->n = 0;
-	foreach(node->children, "chapter", (xml_handler_t)t_chapter2, NULL);
-	return prof;
-}

Deleted: dev/concept/moongoo/ass.h
===================================================================
--- dev/concept/moongoo/ass.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/ass.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,8 +0,0 @@
-#ifndef __ASS_H__
-#define __ASS_H__
-
-#include <alfs.h>
-
-profile *ass_profile (xmlNodePtr node);
-
-#endif

Deleted: dev/concept/moongoo/book.c
===================================================================
--- dev/concept/moongoo/book.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/book.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,157 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-
-#include <book.h>
-#include <repl.h>
-#include <util.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);
-
-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)
-{
-	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;
-	}
-}
-
-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);
-}
-
-command *t_userinput (xmlNodePtr node, int *n)
-{
-	cmd = NULL;
-	num = 0;
-	foreach(node, "userinput", (xml_handler_t)__t_userinput, NULL);
-	*n = num;
-	return cmd;
-}
-
-void t_chapter (xmlNodePtr node)
-{
-	int 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, "sect1", (xml_handler_t)t_sect1, NULL);
-}
-
-profile *bookasprofile (xmlNodePtr node)
-{
-	xmlNodePtr info = find_node(node, "bookinfo");
-	__r = init_repl(MOO_XML);
-
-	if (!info)
-	{
-		fprintf(stderr, "XML document is not a valid LFS book.\n");
-		return NULL;
-	}
-	
-	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;
-	
-	node = node->children;
-	while (node)
-	{
-		if (!strcmp(node->name, "part"))
-		{
-			xmlNodePtr cur = node->children;
-			while (cur)
-			{
-				if (!strcmp(cur->name, "chapter"))
-				{
-					prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
-					t_chapter(cur);
-				}
-				cur=cur->next;
-			}
-		}
-		node=node->next;
-	}
-	
-	return prof;
-}

Deleted: dev/concept/moongoo/book.h
===================================================================
--- dev/concept/moongoo/book.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/book.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,10 +0,0 @@
-#ifndef __BOOK_H__
-#define __BOOK_H__
-
-#include <alfs.h>
-
-void t_sect1 (xmlNodePtr node, void *data);
-command *t_userinput (xmlNodePtr node, int *n);
-profile *bookasprofile (xmlNodePtr node);
-
-#endif

Deleted: dev/concept/moongoo/devel.c
===================================================================
--- dev/concept/moongoo/devel.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/devel.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,43 +0,0 @@
-#include <string.h>
-#include <stdbool.h>
-
-#include <devel.h>
-
-void dbg_print (xmlNodePtr node, char **known)
-{
-	node = node->children;
-	while (node)
-	{
-		if ((node->type!=XML_TEXT_NODE) && (node->type!=XML_COMMENT_NODE) &&
-			(node->type!=XML_XINCLUDE_START) && 
-			(node->type!=XML_XINCLUDE_END))
-		{
-			bool k = false;
-			if (known)
-			{
-				int i=0;
-				while (known[i])
-				{
-					if (!strcmp(node->name, known[i]))
-						k = true;
-					i++;
-				}
-			}
-			
-			if (!k)
-				printf("%s\n", node->name);
-		}
-		node=node->next;
-	}
-}
-
-void dbg_print2 (xmlNodePtr node, char *name)
-{
-	node = node->children;
-	while (node)
-	{
-		if (!strcmp(node->name, name))
-			printf("%s\n", xmlNodeGetContent(node));
-		node = node->next;
-	}
-}

Deleted: dev/concept/moongoo/devel.h
===================================================================
--- dev/concept/moongoo/devel.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/devel.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,9 +0,0 @@
-#ifndef __DEVEL_H__
-#define __DEVEL_H__
-
-#include <alfs.h>
-
-void dbg_print (xmlNodePtr node, char **known);
-void dbg_print2 (xmlNodePtr node, char *name);
-
-#endif

Copied: dev/concept/moongoo/libalfs/alfs.c (from rev 1622, dev/concept/moongoo/alfs.c)

Copied: dev/concept/moongoo/libalfs/alfs.h (from rev 1622, dev/concept/moongoo/alfs.h)

Copied: dev/concept/moongoo/libalfs/devel.c (from rev 1619, dev/concept/moongoo/devel.c)

Copied: dev/concept/moongoo/libalfs/devel.h (from rev 1619, dev/concept/moongoo/devel.h)

Copied: dev/concept/moongoo/libalfs/repl.c (from rev 1622, dev/concept/moongoo/repl.c)

Copied: dev/concept/moongoo/libalfs/util.c (from rev 1621, dev/concept/moongoo/util.c)

Copied: dev/concept/moongoo/libalfs/util.h (from rev 1619, dev/concept/moongoo/util.h)

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/moongoo.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -3,11 +3,7 @@
 #include <getopt.h>
 
 #include <alfs.h>
-#include <book.h>
-#include <syn.h>
 #include <repl.h>
-#include <nalfs.h>
-#include <ass.h>
 #include <util.h>
 #include <build.h>
 
@@ -18,10 +14,10 @@
 
 int main (int argc, char **argv)
 {
-	char c, *syn = NULL;
+	char c, *syn = NULL, *moo_xml = NULL;
 	bool quiet = false;
 	xmlNodePtr cur;
-	profile *prof;
+	//profile *prof;
 	
 	if (argc<2)
 	{
@@ -29,11 +25,20 @@
 		return 1;
 	}
 
-	while ((c = getopt(argc, argv, "s:qVh")) != EOF)
+	while ((c = getopt(argc, argv, "s:qVhc:")) != EOF)
 	{
 		switch (c)
 		{
 			case 's':
+				if (!strcmp(optarg, "help"))
+				{
+					printf("Available syntaxes:\n");
+					printf("\tbook\t\tBook as profile (default)\n");
+					printf("\tnalfs\t\tnALFS legacy syntax\n");
+					printf("\tass\t\tALFS simple syntax\n");
+					printf("\tsyn\t\tHive profile syntax\n");
+					return 0;
+				}
 				syn = (char *)malloc(strlen(optarg)+1);
 				strcpy(syn, optarg);
 				break;
@@ -45,11 +50,16 @@
 				return 0;
 			case 'h':
 				printf("moongoo [OPTIONS] BOOK\n");
-				printf("\t-s SYNTAX\tChoose syntax\n");
+				printf("\t-s SYNTAX\tChoose syntax (help shows them)\n");
+				printf("\t-c CONF.XML\tXML configuration file.\n");
 				printf("\t-q\t\tNo output\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;
 		}
 	}
 
@@ -60,7 +70,7 @@
 	xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT);
 	cur=xmlDocGetRootElement(doc);
 	
-	if ((!syn)||(!strcmp(syn, "book")))
+	/*if ((!syn)||(!strcmp(syn, "book")))
 		prof=bookasprofile(cur);
 	else
 	if (!strcmp(syn, "syn"))
@@ -84,7 +94,7 @@
 		print_pkg(*search_pkg(prof, "Glibc-20041115", 
 			"chapter-building-system"));
 		//print_profile(*prof);
-	}
+	}*/
 	
 	xmlFreeDoc(doc);
 	return 0;

Deleted: dev/concept/moongoo/nalfs.c
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/nalfs.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,319 +0,0 @@
-#include <string.h>
-
-#include <nalfs.h>
-#include <util.h>
-#include <devel.h>
-
-// TODO: Having a big static buffer sucks
-#define BUF_LEN		3000
-
-profile *prof;
-char commando[BUF_LEN];
-
-void parse_unpack (xmlNodePtr node)
-{
-	node=node->children;
-	snprintf(commando, BUF_LEN, "tar -C %s %s\n", find_value(node, 
-		"destination"), find_value(node, "archive"));
-	
-	// TODO: Handle <digest>
-	// find_value(node, "digest");
-}
-
-void parse_remove (xmlNodePtr node)
-{
-	snprintf(commando, BUF_LEN, "rm -rf %s\n", xmlNodeGetContent(node));
-}
-
-void parse_make (xmlNodePtr node)
-{
-	node=node->children;
-	snprintf(commando, BUF_LEN, "%s make %s\n", find_value(node, "prefix"), 
-		find_values(node, "param"));
-}
-
-void parse_configure (xmlNodePtr node)
-{
-	node = node->children;
-	snprintf(commando, BUF_LEN, "%s ./configure %s\n", find_value(node, 
-		"prefix"), find_values(node, "param"));
-}
-
-void parse_copy (xmlNodePtr node)
-{
-	char *orig[4] = { "force", "archive", "recursive", NULL };
-	char *repl[4] = { "-f", "-a", "-r", NULL };
-	node = node->children;
-	snprintf(commando, BUF_LEN, "cp %s %s %s\n", find_values_repl(node, "option",
-		orig, repl), find_value(node, "source"), find_value(node, 
-		"destination"));
-}
-
-void __parse_env (xmlNodePtr node, void *data)
-{
-	snprintf(commando, BUF_LEN, "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)
-{
-	snprintf(commando, BUF_LEN, "cd %s\n", xmlNodeGetContent(node));
-}
-
-void parse_stageinfo (xmlNodePtr node)
-{
-	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)
-{
-	node=node->children;
-	snprintf(commando, BUF_LEN, "cat >%s << EOF\n%s\nEOF\n", find_value(node,
-		"file"), cut_trail(find_value(node, "content"), "="));
-}
-
-void parse_execute (xmlNodePtr node)
-{
-	snprintf(commando, BUF_LEN, "%s %s\n", xmlGetProp(node, "command"), 
-		find_values(node->children, "param"));
-}
-
-void parse_mkdir (xmlNodePtr node)
-{
-	char *orig[2] = { "parents", NULL };
-	char *repl[2] = { "-p", NULL };
-	node=node->children;
-	snprintf(commando, BUF_LEN, "mkdir %s %s\n", find_values_repl(node, "option",
-		orig, repl), find_value(node, "name"));
-}
-
-void parse_search_replace (xmlNodePtr node)
-{
-	node = node->children;
-	snprintf(commando, BUF_LEN, "sed -i 's%%%s%%%s%%g' %s\n", find_value(node,
-		"find"), find_value(node, "replace"), find_value(node, "file"));
-}
-
-void parse_permissions (xmlNodePtr node)
-{
-	char *orig[2] = { "recursive", NULL };
-	char *repl[2] = { "-R", NULL };
-	snprintf(commando, BUF_LEN, "chmod %s %s %s\n", find_values_repl(node->children,
-		"option", orig, repl), xmlGetProp(node, "mode"), 
-		find_value(node->children, "name"));
-}
-
-void parse_ownership (xmlNodePtr node)
-{
-	char *orig[2] = { "recursive", NULL };
-	char *repl[2] = { "-R", NULL };
-	snprintf(commando, BUF_LEN, "chown %s %s:%s %s\n", 
-		find_values_repl(node->children, "option", orig, repl), 
-		xmlGetProp(node, "user"), xmlGetProp(node, "group"),
-		find_value(node->children, "name"));
-}
-
-void parse_patch (xmlNodePtr node)
-{
-	snprintf(commando, BUF_LEN, "patch %s\n", find_values(node->children, "param"));
-}
-
-void parse_move (xmlNodePtr node)
-{
-	snprintf(commando, BUF_LEN, "mv %s %s\n", find_value(node->children, "source"), 
-		find_value(node->children, "destination"));
-}
-
-void parse_link (xmlNodePtr node)
-{
-	char *orig[2] = { "force", NULL };
-	char *repl[2] = { "f", NULL };
-	snprintf(commando, BUF_LEN, "ln -s%s %s %s\n", find_values_repl(node->children,
-		"option", orig, repl), find_value(node->children, "target"),
-		find_value(node->children, "name"));
-}
-
-void process_cmd4 (char *cmd)
-{
-	int i, j, k;
-	
-	i = prof->n-1;
-	j = prof->ch[i].n-1;
-	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build, 
-		(++prof->ch[i].pkg[j].n)*sizeof(command));
-	k = prof->ch[i].pkg[j].n-1;
-
-	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
-	
-	if (strcnt(cmd, " "))
-	{
-		prof->ch[i].pkg[j].build[k].cmd = strcut(cmd, 0, whereis(cmd, ' '));
-		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(cmd, " "), 
-			" "),  " ", &prof->ch[i].pkg[j].build[k].n);
-	}
-	else
-	{
-		prof->ch[i].pkg[j].build[k].cmd = cmd;
-		prof->ch[i].pkg[j].build[k].arg = NULL;
-		prof->ch[i].pkg[j].build[k].n = 0;
-	}
-}
-
-void t_stage2 (xmlNodePtr node, void *data)
-{
-	//printf("%s\n", xmlGetProp(node, "name"));
-
-	node=node->children;
-	while (node)
-	{
-		if ((node->type!=XML_TEXT_NODE)&&(node->type!=XML_COMMENT_NODE)&&
-			(node->type!=XML_XINCLUDE_START)&&(node->type!=XML_XINCLUDE_END))
-		{
-			char *temp;
-			
-			strcpy(commando, "");
-			
-			if (!strcmp(node->name, "unpack"))
-				parse_unpack(node);
-			else
-			if (!strcmp(node->name, "remove"))
-				parse_remove(node);
-			else
-			if (!strcmp(node->name, "make"))
-				parse_make(node);
-			else
-			if (!strcmp(node->name, "configure"))
-				parse_configure(node);
-			else
-			if (!strcmp(node->name, "copy"))
-				parse_copy(node);
-			else
-			if (!strcmp(node->name, "stageinfo"))
-				parse_stageinfo(node);
-			else
-			if (!strcmp(node->name, "textdump"))
-				parse_textdump(node);
-			else
-			if (!strcmp(node->name, "execute"))
-				parse_execute(node);
-			else
-			if (!strcmp(node->name, "mkdir"))
-				parse_mkdir(node);
-			else
-			if (!strcmp(node->name, "search_replace"))
-				parse_search_replace(node);
-			else
-			if (!strcmp(node->name, "permissions"))
-				parse_permissions(node);
-			else
-			if (!strcmp(node->name, "ownership"))
-				parse_ownership(node);
-			else
-			if (!strcmp(node->name, "patch"))
-				parse_patch(node);
-			else
-			if (!strcmp(node->name, "move"))
-				parse_move(node);
-			else
-			if (!strcmp(node->name, "link"))
-				parse_link(node);
-			else
-			if (!strcmp(node->name, "alfs"))
-			// TODO: Do recursive parsing
-				;
-			else
-				fprintf(stderr, "The tag '%s' is not handled yet.\n", 
-					node->name);
-
-			strcpy(commando, squeeze(commando));
-			strcpy(commando, strkill(commando, "\\\n"));
-
-			temp = (char *)malloc(strlen(commando)+1);
-			strcpy(temp, commando);
-			
-			if (strcnt(temp, "\n"))
-			{
-				char *tmp;
-		
-				while ((temp) && (strlen(temp)))
-				{
-					if (!strncmp(temp, "cat >", 5))
-					{
-						char *t;
-						t = strnstr(temp, "EOF", 2);
-						process_cmd4(strcut(temp, 0, t-temp+3));
-						t+=2;
-						strcpy(temp, t);
-						continue;
-					}
-			
-					tmp = strsep(&temp, "\n");
-					process_cmd4(tmp);
-				}
-			}
-			else
-				process_cmd4(temp);
-			
-		}
-		node=node->next;
-	}
-}
-
-void t_pkg2 (xmlNodePtr node, void *data)
-{
-	int i, j;
-
-	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;
-
-	prof->ch[i].pkg[j].name = xmlGetProp(node, "name");
-	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);
-}
-
-void t_alfs (xmlNodePtr node, void *data)
-{
-	// TODO: Handle <stage> node only pages, like chapter07/network.xml 
-	foreach(node->children, "package", (xml_handler_t)t_pkg2, NULL);
-}
-
-void t_stage (xmlNodePtr node, void *data)
-{
-	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
-	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
-	prof->ch[prof->n-1].name = prof->ch[prof->n-1].name;
-	prof->ch[prof->n-1].pkg = NULL;
-	prof->ch[prof->n-1].n = 0;
-	foreach(node->children, "alfs", (xml_handler_t)t_alfs, NULL);
-}
-
-profile *nalfs_profile (xmlNodePtr node)
-{
-	node = find_node(node, "alfs");
-
-	if (!node)
-	{
-		fprintf(stderr, "XML document is not a valid nALFS profile.\n");
-		return NULL;
-	}
-	
-	prof = (profile *)malloc(sizeof(profile));
-	prof->name = "nALFS legacy profile";
-	prof->vers = entity_val("LFS-version");
-	prof->ch = NULL;
-	prof->n = 0;
-	foreach(node->children, "stage", (xml_handler_t)t_stage, NULL);
-	return prof;
-}

Deleted: dev/concept/moongoo/nalfs.h
===================================================================
--- dev/concept/moongoo/nalfs.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/nalfs.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,8 +0,0 @@
-#ifndef __NALFS_H__
-#define __NALFS_H__
-
-#include <alfs.h>
-
-profile *nalfs_profile (xmlNodePtr node);
-
-#endif

Deleted: dev/concept/moongoo/repl.c
===================================================================
--- dev/concept/moongoo/repl.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/repl.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,66 +0,0 @@
-#include <string.h>
-
-#include <repl.h>
-#include <alfs.h>
-
-replaceable *r = NULL;
-
-void t_repl (xmlNodePtr node, void *data)
-{
-	xmlNodePtr text = find_node(node->children, "text");
-	char *repl = xmlNodeGetContent(text);
-	char *opt = get_option(repl);
-	
-	if (!strcmp(opt, ""))
-	{
-		fprintf(stderr, "Unconfigured replaceable: %s\n", repl);
-		return;
-	}
-	
-	xmlNodeSetContent(node, opt);
-}
-
-char *get_option (char *key)
-{
-	int i=0;
-	
-	if (!r)
-		return NULL;
-	
-	while (r[i].orig)
-	{
-		if (!strcmp(key, r[i].orig))
-			return r[i].repl;
-		i++;
-	}
-
-	return "";
-}
-
-replaceable *init_repl (char *fname)
-{
-	xmlDocPtr doc;
-	xmlNodePtr node;
-	int count=0;
-
-	doc=xmlParseFile(fname);
-	if (!doc)
-		return NULL;
-	node=xmlDocGetRootElement(doc)->children;
-
-	while (node)
-	{
-		if (!strcmp(node->name, "answer"))
-		{
-			r = realloc(r, (++count)*sizeof(replaceable));
-			r[count-1].orig = xmlGetProp(node, "name");
-			r[count-1].repl = xmlNodeGetContent(node);
-		}
-		node=node->next;
-	}
-
-	r = realloc(r, (++count)*sizeof(replaceable));
-	r[count-1].orig = NULL;
-	r[count-1].repl = NULL;
-	return r;
-}	

Modified: dev/concept/moongoo/repl.h
===================================================================
--- dev/concept/moongoo/repl.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/repl.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -3,8 +3,7 @@
 
 #include <alfs.h>
 
-// TODO: Make moo.xml location configurable
-#define MOO_XML		"moo.xml"
+#define MOO_XML		"/.nALFS/answers.xml"
 
 void t_repl (xmlNodePtr node, void *data);
 replaceable *init_repl (char *fname);

Deleted: dev/concept/moongoo/syn.c
===================================================================
--- dev/concept/moongoo/syn.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/syn.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,115 +0,0 @@
-#include <string.h>
-
-#include <util.h>
-#include <syn.h>
-
-profile *prof;
-
-// TODO: Complete syn support
-void process_cmd2 (char *line, xmlNodePtr node)
-{
-	int i, j, k;
-
-	i = prof->n-1;
-	j = prof->ch[i].n-1;
-
-	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build,
-			(++prof->ch[i].pkg[j].n)*sizeof(command));
-	k = prof->ch[i].pkg[j].n-1;
-
-	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
-
-	if (strcnt(line, " "))
-	{
-		prof->ch[i].pkg[j].build[k].cmd = strcut(line, 0, whereis(line, ' '));
-		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(line, " "), 
-				" "), " ", &prof->ch[i].pkg[j].build[k].n);
-	}
-	else
-	{
-		prof->ch[i].pkg[j].build[k].cmd = line;
-		prof->ch[i].pkg[j].build[k].arg = NULL;
-		prof->ch[i].pkg[j].build[k].n = 0;
-	}
-}
-
-void t_shell (xmlNodePtr node, void *data)
-{
-	char *line = squeeze(xmlNodeGetContent(node));
-	line = strkill(line, "\\\n");
-	
-	if (strcnt(line, "\n"))
-	{
-		char *tmp;
-
-		while ((line) && (strlen(line)))
-		{
-			tmp = strsep(&line, "\n");
-			process_cmd2(tmp, node);
-		}
-	}
-	else
-		process_cmd2(line, node);
-}
-
-void t_pkg (xmlNodePtr node, void *data)
-{
-	int i, j;
-	char *tmp;
-
-	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 = find_value(node, "title");
-	prof->ch[i].pkg[j].name = strcut(tmp, 0, whereis(tmp, ' '));
-	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_shell, NULL);
-
-	if (!prof->ch[i].pkg[j].n)
-		prof->ch[i].n--;
-}
-
-void t_section (xmlNodePtr node)
-{	
-	int i = prof->n-1;
-	prof->ch[i].name = xmlGetProp(node, "title");
-	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);
-}
-
-profile *syn_profile (xmlNodePtr node)
-{
-	node = find_node(node, "hive");
-
-	if (!node)
-	{
-		fprintf(stderr, "XML document is not a valid Hive profile.\n");
-		return NULL;
-	}
-
-	prof = (profile *)malloc(sizeof(profile));
-	prof->name = find_value(node, "title");
-	prof->vers = find_value(node, "version");
-	prof->ch = NULL;
-	prof->n = 0;
-
-	node = node->children;
-	while (node)
-	{
-		if (!strcmp(node->name, "section"))
-		{
-			printf("%s\n", xmlGetProp(node, "title"));
-			prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
-			t_section(node);
-		}
-		node = node->next;
-	}
-
-	return prof;
-}

Deleted: dev/concept/moongoo/syn.h
===================================================================
--- dev/concept/moongoo/syn.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/syn.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,8 +0,0 @@
-#ifndef __SYN_H__
-#define __SYN_H__
-
-#include <alfs.h>
-
-profile *syn_profile (xmlNodePtr node);
-
-#endif

Copied: dev/concept/moongoo/syntaxes/ass.c (from rev 1619, dev/concept/moongoo/ass.c)
===================================================================
--- dev/concept/moongoo/ass.c	2004-12-02 13:44:58 UTC (rev 1619)
+++ dev/concept/moongoo/syntaxes/ass.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -0,0 +1,97 @@
+#include <string.h>
+
+#include <alfs.h>
+#include <util.h>
+
+profile *prof;
+
+// TODO: Support download/directory in the ASS parser
+void process_cmd3 (char *line, xmlNodePtr node)
+{
+	int i, j, k;
+
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build,
+			(++prof->ch[i].pkg[j].n)*sizeof(command));
+	k = prof->ch[i].pkg[j].n-1;
+	
+	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
+
+	if (strcnt(line, " "))
+	{
+		prof->ch[i].pkg[j].build[k].cmd = strcut(line, 0, whereis(line, ' '));
+		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(line, " "), 
+				" "), " ", &prof->ch[i].pkg[j].build[k].n);
+	}
+	else
+	{
+		prof->ch[i].pkg[j].build[k].cmd = line;
+		prof->ch[i].pkg[j].build[k].arg = NULL;
+		prof->ch[i].pkg[j].build[k].n = 0;
+	}
+}
+
+void t_shell2 (xmlNodePtr node, void *data)
+{
+	char *line = squeeze(xmlNodeGetContent(node));
+	line = strkill(line, "\\\n");
+
+	if (strcnt(line, "\n"))
+	{
+		char *tmp;
+
+		while ((line) && (strlen(line)))
+		{
+			tmp = strsep(&line, "\n");
+			process_cmd3(tmp, node);
+		}
+	}
+	else
+		process_cmd3(line, node);
+}
+
+void t_page (xmlNodePtr node, void *data)
+{
+	int i, j;
+
+	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;
+
+	prof->ch[i].pkg[j].name = find_value(node, "title");
+	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);
+}
+
+void t_chapter2 (xmlNodePtr node, void *data)
+{
+	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
+	prof->ch[prof->n-1].ref = xmlGetProp(node, "ref");
+	prof->ch[prof->n-1].pkg = NULL;
+	prof->ch[prof->n-1].n = 0;
+	foreach(node->children, "page", (xml_handler_t)t_page, NULL);
+}
+
+profile *ass_profile (xmlNodePtr node)
+{
+	node = find_node(node, "ass");
+
+	if (!node)
+	{
+		fprintf(stderr, "XML document is not a valid ASS profile.\n");
+		return NULL;
+	}
+	
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = find_value(node, "title");
+	prof->vers = find_value(node, "version");
+	prof->ch = NULL;
+	prof->n = 0;
+	foreach(node->children, "chapter", (xml_handler_t)t_chapter2, NULL);
+	return prof;
+}

Copied: dev/concept/moongoo/syntaxes/book.c (from rev 1622, dev/concept/moongoo/book.c)
===================================================================
--- dev/concept/moongoo/book.c	2004-12-03 17:01:48 UTC (rev 1622)
+++ dev/concept/moongoo/syntaxes/book.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -0,0 +1,157 @@
+#include <string.h>
+#include <stdlib.h>
+
+#include <alfs.h>
+#include <repl.h>
+#include <util.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);
+
+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)
+{
+	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;
+	}
+}
+
+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);
+}
+
+command *t_userinput (xmlNodePtr node, int *n)
+{
+	cmd = NULL;
+	num = 0;
+	foreach(node, "userinput", (xml_handler_t)__t_userinput, NULL);
+	*n = num;
+	return cmd;
+}
+
+void t_chapter (xmlNodePtr node)
+{
+	int 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, "sect1", (xml_handler_t)t_sect1, NULL);
+}
+
+profile *bookasprofile (xmlNodePtr node)
+{
+	xmlNodePtr info = find_node(node, "bookinfo");
+	__r = init_repl(MOO_XML);
+
+	if (!info)
+	{
+		fprintf(stderr, "XML document is not a valid LFS book.\n");
+		return NULL;
+	}
+	
+	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;
+	
+	node = node->children;
+	while (node)
+	{
+		if (!strcmp(node->name, "part"))
+		{
+			xmlNodePtr cur = node->children;
+			while (cur)
+			{
+				if (!strcmp(cur->name, "chapter"))
+				{
+					prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+					t_chapter(cur);
+				}
+				cur=cur->next;
+			}
+		}
+		node=node->next;
+	}
+	
+	return prof;
+}

Copied: dev/concept/moongoo/syntaxes/nalfs.c (from rev 1622, dev/concept/moongoo/nalfs.c)
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-03 17:01:48 UTC (rev 1622)
+++ dev/concept/moongoo/syntaxes/nalfs.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -0,0 +1,319 @@
+#include <string.h>
+
+#include <alfs.h>
+#include <devel.h>
+#include <util.h>
+
+// TODO: Having a big static buffer sucks
+#define BUF_LEN		3000
+
+profile *prof;
+char commando[BUF_LEN];
+
+void parse_unpack (xmlNodePtr node)
+{
+	node=node->children;
+	snprintf(commando, BUF_LEN, "tar -C %s %s\n", find_value(node, 
+		"destination"), find_value(node, "archive"));
+	
+	// TODO: Handle <digest>
+	// find_value(node, "digest");
+}
+
+void parse_remove (xmlNodePtr node)
+{
+	snprintf(commando, BUF_LEN, "rm -rf %s\n", xmlNodeGetContent(node));
+}
+
+void parse_make (xmlNodePtr node)
+{
+	node=node->children;
+	snprintf(commando, BUF_LEN, "%s make %s\n", find_value(node, "prefix"), 
+		find_values(node, "param"));
+}
+
+void parse_configure (xmlNodePtr node)
+{
+	node = node->children;
+	snprintf(commando, BUF_LEN, "%s ./configure %s\n", find_value(node, 
+		"prefix"), find_values(node, "param"));
+}
+
+void parse_copy (xmlNodePtr node)
+{
+	char *orig[4] = { "force", "archive", "recursive", NULL };
+	char *repl[4] = { "-f", "-a", "-r", NULL };
+	node = node->children;
+	snprintf(commando, BUF_LEN, "cp %s %s %s\n", find_values_repl(node, "option",
+		orig, repl), find_value(node, "source"), find_value(node, 
+		"destination"));
+}
+
+void __parse_env (xmlNodePtr node, void *data)
+{
+	snprintf(commando, BUF_LEN, "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)
+{
+	snprintf(commando, BUF_LEN, "cd %s\n", xmlNodeGetContent(node));
+}
+
+void parse_stageinfo (xmlNodePtr node)
+{
+	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)
+{
+	node=node->children;
+	snprintf(commando, BUF_LEN, "cat >%s << EOF\n%s\nEOF\n", find_value(node,
+		"file"), cut_trail(find_value(node, "content"), "="));
+}
+
+void parse_execute (xmlNodePtr node)
+{
+	snprintf(commando, BUF_LEN, "%s %s\n", xmlGetProp(node, "command"), 
+		find_values(node->children, "param"));
+}
+
+void parse_mkdir (xmlNodePtr node)
+{
+	char *orig[2] = { "parents", NULL };
+	char *repl[2] = { "-p", NULL };
+	node=node->children;
+	snprintf(commando, BUF_LEN, "mkdir %s %s\n", find_values_repl(node, "option",
+		orig, repl), find_value(node, "name"));
+}
+
+void parse_search_replace (xmlNodePtr node)
+{
+	node = node->children;
+	snprintf(commando, BUF_LEN, "sed -i 's%%%s%%%s%%g' %s\n", find_value(node,
+		"find"), find_value(node, "replace"), find_value(node, "file"));
+}
+
+void parse_permissions (xmlNodePtr node)
+{
+	char *orig[2] = { "recursive", NULL };
+	char *repl[2] = { "-R", NULL };
+	snprintf(commando, BUF_LEN, "chmod %s %s %s\n", find_values_repl(node->children,
+		"option", orig, repl), xmlGetProp(node, "mode"), 
+		find_value(node->children, "name"));
+}
+
+void parse_ownership (xmlNodePtr node)
+{
+	char *orig[2] = { "recursive", NULL };
+	char *repl[2] = { "-R", NULL };
+	snprintf(commando, BUF_LEN, "chown %s %s:%s %s\n", 
+		find_values_repl(node->children, "option", orig, repl), 
+		xmlGetProp(node, "user"), xmlGetProp(node, "group"),
+		find_value(node->children, "name"));
+}
+
+void parse_patch (xmlNodePtr node)
+{
+	snprintf(commando, BUF_LEN, "patch %s\n", find_values(node->children, "param"));
+}
+
+void parse_move (xmlNodePtr node)
+{
+	snprintf(commando, BUF_LEN, "mv %s %s\n", find_value(node->children, "source"), 
+		find_value(node->children, "destination"));
+}
+
+void parse_link (xmlNodePtr node)
+{
+	char *orig[2] = { "force", NULL };
+	char *repl[2] = { "f", NULL };
+	snprintf(commando, BUF_LEN, "ln -s%s %s %s\n", find_values_repl(node->children,
+		"option", orig, repl), find_value(node->children, "target"),
+		find_value(node->children, "name"));
+}
+
+void process_cmd4 (char *cmd)
+{
+	int i, j, k;
+	
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build, 
+		(++prof->ch[i].pkg[j].n)*sizeof(command));
+	k = prof->ch[i].pkg[j].n-1;
+
+	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
+	
+	if (strcnt(cmd, " "))
+	{
+		prof->ch[i].pkg[j].build[k].cmd = strcut(cmd, 0, whereis(cmd, ' '));
+		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(cmd, " "), 
+			" "),  " ", &prof->ch[i].pkg[j].build[k].n);
+	}
+	else
+	{
+		prof->ch[i].pkg[j].build[k].cmd = cmd;
+		prof->ch[i].pkg[j].build[k].arg = NULL;
+		prof->ch[i].pkg[j].build[k].n = 0;
+	}
+}
+
+void t_stage2 (xmlNodePtr node, void *data)
+{
+	//printf("%s\n", xmlGetProp(node, "name"));
+
+	node=node->children;
+	while (node)
+	{
+		if ((node->type!=XML_TEXT_NODE)&&(node->type!=XML_COMMENT_NODE)&&
+			(node->type!=XML_XINCLUDE_START)&&(node->type!=XML_XINCLUDE_END))
+		{
+			char *temp;
+			
+			strcpy(commando, "");
+			
+			if (!strcmp(node->name, "unpack"))
+				parse_unpack(node);
+			else
+			if (!strcmp(node->name, "remove"))
+				parse_remove(node);
+			else
+			if (!strcmp(node->name, "make"))
+				parse_make(node);
+			else
+			if (!strcmp(node->name, "configure"))
+				parse_configure(node);
+			else
+			if (!strcmp(node->name, "copy"))
+				parse_copy(node);
+			else
+			if (!strcmp(node->name, "stageinfo"))
+				parse_stageinfo(node);
+			else
+			if (!strcmp(node->name, "textdump"))
+				parse_textdump(node);
+			else
+			if (!strcmp(node->name, "execute"))
+				parse_execute(node);
+			else
+			if (!strcmp(node->name, "mkdir"))
+				parse_mkdir(node);
+			else
+			if (!strcmp(node->name, "search_replace"))
+				parse_search_replace(node);
+			else
+			if (!strcmp(node->name, "permissions"))
+				parse_permissions(node);
+			else
+			if (!strcmp(node->name, "ownership"))
+				parse_ownership(node);
+			else
+			if (!strcmp(node->name, "patch"))
+				parse_patch(node);
+			else
+			if (!strcmp(node->name, "move"))
+				parse_move(node);
+			else
+			if (!strcmp(node->name, "link"))
+				parse_link(node);
+			else
+			if (!strcmp(node->name, "alfs"))
+			// TODO: Do recursive parsing
+				;
+			else
+				fprintf(stderr, "The tag '%s' is not handled yet.\n", 
+					node->name);
+
+			strcpy(commando, squeeze(commando));
+			strcpy(commando, strkill(commando, "\\\n"));
+
+			temp = (char *)malloc(strlen(commando)+1);
+			strcpy(temp, commando);
+			
+			if (strcnt(temp, "\n"))
+			{
+				char *tmp;
+		
+				while ((temp) && (strlen(temp)))
+				{
+					if (!strncmp(temp, "cat >", 5))
+					{
+						char *t;
+						t = strnstr(temp, "EOF", 2);
+						process_cmd4(strcut(temp, 0, t-temp+3));
+						t+=2;
+						strcpy(temp, t);
+						continue;
+					}
+			
+					tmp = strsep(&temp, "\n");
+					process_cmd4(tmp);
+				}
+			}
+			else
+				process_cmd4(temp);
+			
+		}
+		node=node->next;
+	}
+}
+
+void t_pkg2 (xmlNodePtr node, void *data)
+{
+	int i, j;
+
+	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;
+
+	prof->ch[i].pkg[j].name = xmlGetProp(node, "name");
+	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);
+}
+
+void t_alfs (xmlNodePtr node, void *data)
+{
+	// TODO: Handle <stage> node only pages, like chapter07/network.xml 
+	foreach(node->children, "package", (xml_handler_t)t_pkg2, NULL);
+}
+
+void t_stage (xmlNodePtr node, void *data)
+{
+	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
+	prof->ch[prof->n-1].name = prof->ch[prof->n-1].name;
+	prof->ch[prof->n-1].pkg = NULL;
+	prof->ch[prof->n-1].n = 0;
+	foreach(node->children, "alfs", (xml_handler_t)t_alfs, NULL);
+}
+
+profile *nalfs_profile (xmlNodePtr node)
+{
+	node = find_node(node, "alfs");
+
+	if (!node)
+	{
+		fprintf(stderr, "XML document is not a valid nALFS profile.\n");
+		return NULL;
+	}
+	
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = "nALFS legacy profile";
+	prof->vers = entity_val("LFS-version");
+	prof->ch = NULL;
+	prof->n = 0;
+	foreach(node->children, "stage", (xml_handler_t)t_stage, NULL);
+	return prof;
+}

Copied: dev/concept/moongoo/syntaxes/syn.c (from rev 1619, dev/concept/moongoo/syn.c)
===================================================================
--- dev/concept/moongoo/syn.c	2004-12-02 13:44:58 UTC (rev 1619)
+++ dev/concept/moongoo/syntaxes/syn.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -0,0 +1,115 @@
+#include <string.h>
+
+#include <alfs.h>
+#include <util.h>
+
+profile *prof;
+
+// TODO: Complete syn support
+void process_cmd2 (char *line, xmlNodePtr node)
+{
+	int i, j, k;
+
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+
+	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build,
+			(++prof->ch[i].pkg[j].n)*sizeof(command));
+	k = prof->ch[i].pkg[j].n-1;
+
+	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
+
+	if (strcnt(line, " "))
+	{
+		prof->ch[i].pkg[j].build[k].cmd = strcut(line, 0, whereis(line, ' '));
+		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(line, " "), 
+				" "), " ", &prof->ch[i].pkg[j].build[k].n);
+	}
+	else
+	{
+		prof->ch[i].pkg[j].build[k].cmd = line;
+		prof->ch[i].pkg[j].build[k].arg = NULL;
+		prof->ch[i].pkg[j].build[k].n = 0;
+	}
+}
+
+void t_shell (xmlNodePtr node, void *data)
+{
+	char *line = squeeze(xmlNodeGetContent(node));
+	line = strkill(line, "\\\n");
+	
+	if (strcnt(line, "\n"))
+	{
+		char *tmp;
+
+		while ((line) && (strlen(line)))
+		{
+			tmp = strsep(&line, "\n");
+			process_cmd2(tmp, node);
+		}
+	}
+	else
+		process_cmd2(line, node);
+}
+
+void t_pkg (xmlNodePtr node, void *data)
+{
+	int i, j;
+	char *tmp;
+
+	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 = find_value(node, "title");
+	prof->ch[i].pkg[j].name = strcut(tmp, 0, whereis(tmp, ' '));
+	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_shell, NULL);
+
+	if (!prof->ch[i].pkg[j].n)
+		prof->ch[i].n--;
+}
+
+void t_section (xmlNodePtr node)
+{	
+	int i = prof->n-1;
+	prof->ch[i].name = xmlGetProp(node, "title");
+	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);
+}
+
+profile *syn_profile (xmlNodePtr node)
+{
+	node = find_node(node, "hive");
+
+	if (!node)
+	{
+		fprintf(stderr, "XML document is not a valid Hive profile.\n");
+		return NULL;
+	}
+
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = find_value(node, "title");
+	prof->vers = find_value(node, "version");
+	prof->ch = NULL;
+	prof->n = 0;
+
+	node = node->children;
+	while (node)
+	{
+		if (!strcmp(node->name, "section"))
+		{
+			printf("%s\n", xmlGetProp(node, "title"));
+			prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+			t_section(node);
+		}
+		node = node->next;
+	}
+
+	return prof;
+}

Deleted: dev/concept/moongoo/util.c
===================================================================
--- dev/concept/moongoo/util.c	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/util.c	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,360 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <util.h>
-
-char *lower_case (char *arg)
-{
-	char *str;
-	int i;
-	
-	if (!arg)
-		return NULL;
-
-	str = (char *)malloc(strlen(arg)+1);
-	strcpy(str, arg);
-
-	for (i=0;i<strlen(str);i++)
-		if (isalpha(str[i]))
-			str[i]=tolower(str[i]);
-
-	return str;
-}
-
-char *strdog (char *str1, char *str2)
-{
-	char *ret;
-
-	if ((!str1)||(!str2))
-		return NULL;
-		
-	ret=(char *)malloc(strlen(str1)+strlen(str2)+1);
-
-	strcpy(ret, str1);
-	strcat(ret, str2);
-	return ret;
-}
-
-char *strdog2 (char *str1, char *str2)
-{
-	char *ret;
-
-	if ((!str1)||(!str2))
-		return NULL;
-	
-	ret=(char *)malloc(strlen(str1)+strlen(str2)+2);
-
-	strcpy(ret, str1);
-	if (strlen(str1)>0)
-		strcat(ret, " ");
-	strcat(ret, str2);
-	free(str1);
-	return ret;
-}
-
-char *chrep (char *str, char old, char new)
-{
-	char *ret;
-	int i;
-
-	if (!str)
-		return NULL;
-	
-	ret=(char *)malloc(strlen(str)+1);
-
-	for (i=0;i<strlen(str);i++)
-		if (str[i]==old)
-			ret[i]=new;
-		else
-			ret[i]=str[i];
-	ret[i]='\0';
-
-	return ret;
-}
-
-char **tokenize (char *arg, char *token, int *i)
-{
-	int n=0;
-	char **ret = NULL, *str;
-
-	if ((!arg)||(!token))
-		return NULL;
-
-	str=(char *)malloc(strlen(arg)+1);
-	strcpy(str, arg);
-
-	while (strcnt(str, " "))
-	{
-		ret = realloc(ret, (++n)*sizeof(char *));
-		ret[n-1] = strcut(str, 0, whereis(str, ' '));
-		str = notrail(strstr(str, token), token);
-	}
-
-	ret = realloc(ret, (++n)*sizeof(char *));
-	ret[n-1] = (char *)malloc(strlen(str)+1);
-	strcpy(ret[n-1], str);
-	*i = n;
-	return ret;
-}
-
-char *strrep (char *str, char *old, char *new)
-{
-	char *ret;
-	int i, j=0, k;
-
-	if ((!str)||(!old)||(!new))
-		return NULL;
-	
-	ret=(char *)malloc(strlen(str)+1+((strlen(new)-strlen(old))*
-			strcnt(str, old)));
-
-	for (i=0;i<strlen(str);i++)
-		if (strstarts(str, i, old))
-		{
-			for (k=j;k<j+strlen(new);k++)
-				ret[k]=new[k-j];
-			i+=strlen(old)-1;
-			j+=strlen(new);
-		}
-		else
-		{
-			ret[j]=str[i];
-			j++;
-		}
-	ret[j]='\0';
-
-	return ret;
-}
-
-int strcnt (char *str, char *sstr)
-{
-	char *t, *t2;
-	int i, ret=0;
-
-	if ((!str)||(!sstr))
-		return 0;
-
-	t=(char *)malloc(strlen(str)+1);
-	strcpy(t, str);
-	t2=t;
-	while (t)
-	{
-		t=strstr(t, sstr);
-		if (t)
-		{
-			ret++;
-			for (i=0;i<strlen(sstr);i++)
-				t++;
-		}
-	}
-
-	free(t2);
-	return ret;
-}
-
-int strstarts (char *str, int begin, char *test)
-{
-	char *tmp;
-	int ret=0;
-
-	if ((!str)||(strlen(str)<begin+strlen(test)))
-		return 0;
-
-	tmp=strcutb(str, begin, strlen(test), false);
-
-	if (!strcmp(tmp, test))
-		ret=1;
-
-	free(tmp);
-	return ret;
-}
-
-char *strcutb (char *str, int begin, int count, bool blanks)
-{
-	int i, j=0, end;
-	char *ret;
-	
-	if (!str)
-		return NULL;
-	if (count<0)
-		count=0;
-	
-	ret=(char *)malloc(count+1);
-
-	if (count<1)
-	{
-		strcpy(ret, "");
-		return ret;
-	}
-
-	if (strlen(str)<begin+count)
-		end=strlen(str);
-	else
-		end=begin+count;
-	
-	for (i=begin;i<end;i++)
-		if (!((j==0)&&(blanks)&&(str[i]==' ')))
-		{
-			ret[j]=str[i];
-			j++;
-		}
-	ret[j]='\0';
-
-	return ret;
-}
-
-char *strcut (char *str, int begin, int count)
-{
-	return strcutb(str, begin, count, true);
-}
-
-int whereis (char *str, char ch)
-{
-	int i;
-
-	if (!str)
-		return -1;
-	
-	for (i=0;i<strlen(str);i++)
-		if (str[i]==ch)
-			return i;
-
-	return -1;
-}
-
-char *notrail (char *str, char *token)
-{
-	char *ret;
-	
-	if ((!str)||(!token))
-		return NULL;
-
-	ret=(char *)malloc(strlen(str)+1);
-	strcpy(ret, str);
-	while (strstarts(ret, 0, token))
-		ret+=strlen(token);
-	return ret;
-}
-
-char *squeeze (char *str)
-{
-	bool blank=false;
-	int i, len=0;
-	char *ret;
-
-	if (!str)
-		return NULL;
-
-	ret=(char *)malloc(strlen(str)+1);
-
-	for (i=0;i<strlen(str);i++)
-	{
-		if (isblank(str[i]))
-		{
-			if (blank)
-				continue;
-			blank=true;
-		}
-		else
-			blank=false;
-		
-		ret[len] = str[i];
-		len++;
-	}
-	
-	ret[len]='\0';
-	return ret;
-}
-
-char *strkill (char *str, char *tokill)
-{
-	char *cpy;
-	int i, j=0;
-
-	if ((!str)||(!tokill))
-		return NULL;
-	
-	cpy=(char *)malloc(strlen(str)+1);
-	
-	for (i=0;i<strlen(str);i++)
-		if (strstarts(str, i, tokill))
-			i+=strlen(tokill)-1;
-		else
-		{
-			cpy[j]=str[i];
-			j++;
-		}
-	cpy[j]='\0';
-
-	return cpy;
-}
-
-char *strnstr (char *haystack, char *needle, int n)
-{
-	int i;
-	char *ret = haystack;
-
-	if ((!haystack)||(!needle))
-		return NULL;
-	
-	for (i=0;i<n;i++)
-	{
-		ret = strstr(ret, needle);
-		if ((ret) && (strcmp(haystack, ret)))
-			ret++;
-	}
-
-	return ret;
-}	
-
-void term_set (int attr, int fg, int bg)
-{
-	char cmd[13];
-
-	sprintf(cmd, "%c[%d;%d;%dm", 0x1B, attr, fg+30, bg+40);
-	printf(cmd);
-}
-
-void term_reset ()
-{
-	char cmd[13];
-
-	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;
-}

Deleted: dev/concept/moongoo/util.h
===================================================================
--- dev/concept/moongoo/util.h	2004-12-03 20:31:18 UTC (rev 1623)
+++ dev/concept/moongoo/util.h	2004-12-03 22:27:05 UTC (rev 1624)
@@ -1,45 +0,0 @@
-#ifndef __UTIL_H__
-#define __UTIL_H__
-
-#include <stdbool.h>
-
-/* Attributes */
-#define RESET           0
-#define BRIGHT          1
-#define DIM             2
-#define UNDERLINE       3
-#define BLINK           4
-#define REVERSE         7
-#define HIDDEN          8
-
-/* Colors */
-#define BLACK           0
-#define RED             1
-#define GREEN           2
-#define YELLOW          3
-#define BLUE            4
-#define MAGENTA         5
-#define CYAN            6
-#define WHITE           7
-
-void term_set (int attr, int fg, int bg);
-void term_reset ();
-
-char *lower_case (char *str);
-char *strdog (char *str1, char *str2);
-char *strdog2 (char *str1, char *str2);
-char *chrep (char *str, char old, char new);
-char **tokenize (char *str, char *token, int *i);
-char *strrep (char *str, char *old, char *new);
-int strcnt (char *str, char *sstr);
-int strstarts (char *str, int begin, char *test);
-char *strcutb (char *str, int begin, int count, bool blanks);
-char *strcut (char *str, int begin, int count);
-int whereis (char *str, char ch);
-char *notrail (char *str, char *token);
-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