git » fp-git.git » commit 09ed598

source clean

author ecalot
2005-12-30 02:21:36 UTC
committer ecalot
2005-12-30 02:21:36 UTC
parent 20815e090c61c1a77960f6e3fae5d56f9f9e6ade

source clean

PR/src/include/tree.h +4 -3
PR/src/lib/xml/tree.c +26 -28
PR/src/lib/xml/unknown.c +4 -4

diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index 6924ef1..be92ae5 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -36,6 +36,7 @@ unknown.h: Princed Resources : Unknown.xml generator headers
 
 /* Includes */
 #include "reslist.h"
+#include <stdio.h> /* FILE* */
 
 typedef struct { 
 	tTag*        folderCursor;
@@ -45,8 +46,8 @@ typedef struct {
 
 void unknown_item(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count, tTreeStatus* status);
 void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status);
-void unknown_deletetreefile(const char* file);
-void unknown_fixtreeinheritances();
-void generateXML(int n,tTag* t);
+void unknown_deletetreefile(const char* file, tTag* tree);
+void unknown_fixtreeinheritances(tTag* *tree);
+void generateXML(int n,tTag* t,FILE* outputStream);
 
 #endif
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 54989b4..e83b21a 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -41,31 +41,25 @@ tree.c: Princed Resources : Tree handling routines
 #include "common.h"
 #include "memory.h"
 #include "unknown.h" /* typedef tUnknownFile */
-#include "parse.h" /* RES_TYPECOUNT */
 
 /***************************************************************\
-|                     Unknown.xml primitives                    |
+|                     XML generation defines                    |
 \***************************************************************/
 
-/* XML generation defines */
-
 #define XML_HEADER \
 	"<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\
 	"<?xml version=\"1.0\" ?>\n"
 
-extern tUnknownFile unknownFile;
-
 /***************************************************************\
-|                           Tree Layer                          |
+|              Common factor tree reducing routines             |
 \***************************************************************/
 
-/* TODO: send this layer to other module */
-
-/* Common factor tree reducing routines */
-
 /* TODO */
 
-/* Tag generation routines */
+/***************************************************************\
+|                     Tag generation routines                   |
+\***************************************************************/
+
 void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status) {
 	char number[10];
 	tTag* folder=malloc(sizeof(tTag));	
@@ -112,10 +106,11 @@ void unknown_item(int value,const char* index,const char* path,const char* type,
 	status->itemCursor=item;
 }
 
-/* memory tree --> xml */
-#define outputStream unknownFile.fd /**/
+/***************************************************************\
+|                       Memory tree --> xml                     |
+\***************************************************************/
 
-void generateXML(int n,tTag* t) {
+void generateXML(int n,tTag* t,FILE* outputStream) {
 	int a;
 	tTag* children;
 
@@ -146,7 +141,7 @@ void generateXML(int n,tTag* t) {
 		if ((children=t->child)) {
 			fprintf(outputStream,">\n");
 			while (children!=NULL) {
-				generateXML(n+1,children);
+				generateXML(n+1,children,outputStream);
 				children=children->next;
 			}
 			for(a=0;a<n;a++) fprintf (outputStream,"\t");
@@ -161,7 +156,9 @@ void generateXML(int n,tTag* t) {
 	}
 }
 
-/* file attribute deletion routines */
+/***************************************************************\
+|                File attribute deletion routines               |
+\***************************************************************/
 
 void rec_tree(tTag* *t,const char* file) {
 	tTag* aux=*t;
@@ -180,7 +177,6 @@ void rec_tree(tTag* *t,const char* file) {
 				*t=aux->next;
 			}
 			aux->next=NULL;
-			/* freeTag(aux); */
 			if (*t) rec_tree(t,file);
 		} else {
 			if ((*t) && (*t)->next) rec_tree(&((*t)->next),file);
@@ -190,13 +186,15 @@ void rec_tree(tTag* *t,const char* file) {
 	if ((*t) && (*t)->child) rec_tree(&((*t)->child),file);
 }
 
-void unknown_deletetreefile(const char* file) {
-	/*printf("deleting file %s from tree\n",file);*/
-	if (unknownFile.tree)
-		rec_tree(&(unknownFile.tree->child),file);
+void unknown_deletetreefile(const char* file, tTag* tree) {
+	if (tree)
+		rec_tree(&(tree->child),file);
 }
 
-/* inheritance fixing routines */
+/***************************************************************\
+|                  Inheritance fixing routines                  |
+\***************************************************************/
+
 #define TotalInheritance(a) if (parent->a&&child->a&&equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;}
 
 void rec_tree_fix(tTag* parent,tTag* child) {
@@ -228,13 +226,13 @@ void rec_tree_fix(tTag* parent,tTag* child) {
 	
 }
 
-void unknown_fixtreeinheritances() {
+void unknown_fixtreeinheritances(tTag* *tree) {
 	/*printf("fixing inheritances in tree\n");*/
-	if (unknownFile.tree) {
-		rec_tree_fix(NULL,unknownFile.tree);
+	if (*tree) {
+		rec_tree_fix(NULL,(*tree));
 		
-		freeAllocation(unknownFile.tree->path);
-		unknownFile.tree->path=NULL;		
+		freeAllocation((*tree)->path);
+		(*tree)->path=NULL;		
 	}
 }
 
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 4782ab2..853895e 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -101,7 +101,7 @@ int unknownLogStop () {
 	if (!unknownFile.fd) return PR_RESULT_ERR_XML_NOT_OPEN; /* File not open */
 
 	/* it is time to fix the inheritances */
-	unknown_fixtreeinheritances();
+	unknown_fixtreeinheritances(&unknownFile.tree);
 	
 	/* now we'll add the new generated part of the tree at the end of the second level (resources id the first) */
 	if (unknownFile.tree) {
@@ -116,7 +116,7 @@ int unknownLogStop () {
 	/* TODO: create common factor tree reducing function */
 	
 	/* generate the xml file */
-	generateXML(0,unknownFile.tree);
+	generateXML(0,unknownFile.tree,unknownFile.fd);
 
 	/* it's time to free the tree */
 	freeParsedStructure (&unknownFile.tree);
@@ -141,13 +141,13 @@ int unknownLogAppend(const char* vFiledat,tResourceId id,const char* ext,tResour
 		unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index)),&unknownFile.status);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 		/* TODO: move here the read-parsing-loading and write-opening */
-		unknown_deletetreefile(vFiledat);
+		unknown_deletetreefile(vFiledat,unknownFile.tree);
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		int i;
 		unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index)),&unknownFile.status);
 		freeAllocation(unknownFile.currentDat);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
-		unknown_deletetreefile(vFiledat);
+		unknown_deletetreefile(vFiledat,unknownFile.tree);
 		for (i=0;i<RES_TYPECOUNT;i++) unknownFile.typeCount[i]=0; /* re-initialize in 0 for next file processing */
 	}