git » fp-git.git » commit 545a09f

source clearing

author ecalot
2005-12-21 11:46:44 UTC
committer ecalot
2005-12-21 11:46:44 UTC
parent 1481ba4bf7d5e2575136a8ebc3692ca17b89be3e

source clearing

PR/src/include/common.h +3 -0
PR/src/include/memory.h +1 -0
PR/src/include/tree.h +6 -16
PR/src/include/unknown.h +6 -16
PR/src/lib/layers/idlist.c +3 -60
PR/src/lib/layers/memory.c +12 -0
PR/src/lib/xml/tree.c +19 -29
PR/src/lib/xml/unknown.c +19 -29

diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index 423582a..219fe81 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -78,6 +78,9 @@ common.h: Princed Resources : Defines and prototypes common to all PR code
 
 #define DEFAULT_BACKUP_EXTENSION "bak"
 
+/* File extensions */
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+
 /***************************************************************\
 |                        L A N G U A G E                        |
 \***************************************************************/
diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h
index 24b28b7..aa99dbe 100644
--- a/PR/src/include/memory.h
+++ b/PR/src/include/memory.h
@@ -50,6 +50,7 @@ char* strallocandcopy(const char* text);
 int equalsIgnoreCase2(const char s1[],const char s2[]);
 #endif
 
+char* toLower(const char* txt);
 void str5lowercpy (char* dst,const char* src);
 int matchesIn(const char *s, const char *p);
 
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index 4d169f7..16c94c5 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -19,7 +19,7 @@
 */
 
 /*
-unknown.h: Princed Resources : Resource Handler headers
+unknown.h: Princed Resources : Unknown.xml generator headers
 \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 24 Aug 2003
@@ -31,13 +31,12 @@ unknown.h: Princed Resources : Resource Handler headers
   DO NOT remove this copyright notice
 */
 
-#ifndef _RESOURCES_H_
-#define _RESOURCES_H_
+#ifndef _UNKNOWN_H_
+#define _UNKNOWN_H_
 
-
-/* File extensions */
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"} /* TODO: move to common.h */
+/* Note:
+ * To use the functions as a library you must include pr.h
+ */
 
 /* Includes */
 #include "parse.h"
@@ -45,14 +44,5 @@ unknown.h: Princed Resources : Resource Handler headers
 
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension,const char* format);
-/*void getUpperFolder(char* aux, char* vFiledat);*/
-
-/* In case there are unknown resources it closes the unknown XML output */
-/*void endUnknownXml();*/
-
-/* Search files for the Import feature * TODO check this prototypes *
-int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
-int isntADatFile(const char* testFile, const char* vResFile);
-*/
 
 #endif
diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h
index 4d169f7..16c94c5 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -19,7 +19,7 @@
 */
 
 /*
-unknown.h: Princed Resources : Resource Handler headers
+unknown.h: Princed Resources : Unknown.xml generator headers
 \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 24 Aug 2003
@@ -31,13 +31,12 @@ unknown.h: Princed Resources : Resource Handler headers
   DO NOT remove this copyright notice
 */
 
-#ifndef _RESOURCES_H_
-#define _RESOURCES_H_
+#ifndef _UNKNOWN_H_
+#define _UNKNOWN_H_
 
-
-/* File extensions */
-
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"} /* TODO: move to common.h */
+/* Note:
+ * To use the functions as a library you must include pr.h
+ */
 
 /* Includes */
 #include "parse.h"
@@ -45,14 +44,5 @@ unknown.h: Princed Resources : Resource Handler headers
 
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension,const char* format);
-/*void getUpperFolder(char* aux, char* vFiledat);*/
-
-/* In case there are unknown resources it closes the unknown XML output */
-/*void endUnknownXml();*/
-
-/* Search files for the Import feature * TODO check this prototypes *
-int importDir(const char* directory, const char* vResFile, int pOption, const char* backupExtension,const char* vDirectory,FILE* output);
-int isntADatFile(const char* testFile, const char* vResFile);
-*/
 
 #endif
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index 9b4b7a8..16e5aea 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -45,18 +45,9 @@ idlist.c: Princed Resources : Partial Id list
 
 /* Id list for partial manipulation. Private type */
 typedef enum {eString,eId,eIdValue,eIdIndex}tResLocationType;
-/*
-typedef struct {
-  tResLocationType type;
-  union {
-    char*        text;
-    tResourceId  id;
-  } field;
-}tResourceMatch;
-*/
+
 typedef struct {
 	int             count;
-	/*tResourceMatch* list;*/
 	tResourceMatch* list;
 }tResIdList;
 
@@ -139,40 +130,6 @@ void parseGivenPath(char* path) {
 	/* Parse values and save them in the list */
 	for(i=separator;j!=partialList.count;i++) {
 		initRM(path+i,partialList.list+j); /* TODO: check for parsing error*/
-/*		unsigned int value;
-		int converted;
-		char index[5];
-		converted=sscanf(path+i,"%u:%5s",&value,index); * TODO: support order *
-		switch (converted) {
-		case 2:
-			partialList.list[j].type=eId;
-			partialList.list[j].field.id.value=value;
-			str5lowercpy(partialList.list[j].field.id.index,index);
-			partialList.list[j].field.id.order=0;
-			break;
-		case 1:
-			partialList.list[j].type=eIdValue;
-			partialList.list[j].field.id.value=value;
-			partialList.list[j].field.id.order=0;
-			break;
-		default:
-			* TODO: test this *
-			if (sscanf(path+i,":%5s",index)) {
-				partialList.list[j].type=eIdIndex;
-				strncpy(partialList.list[j].field.id.index,index,5); * TODO: check str5lowercpy *
-				partialList.list[j].field.id.order=0;
-			} else {
-				char* aux;
-				partialList.list[j].type=eString;
-				aux=malloc(strlen(path+i)+2);
-				aux[0]='/';
-				strcpy(aux+1,path+i);
-				partialList.list[j].field.text=strallocandcopy(repairFolders(aux));
-				free(aux);
-			}
-			break;
-		}
-		*/
 		while (path[i]) i++;
 		j++;
 	}
@@ -191,23 +148,9 @@ int isInThePartialList(const char* vFile, tResourceId id) {
 
 	if (!partialList.count) return 1;
 
-	for (i=0;i<partialList.count;i++) {
-/*		switch (partialList.list[i].type) {
-		case eIdValue:
-			if (id.value==partialList.list[i].field.id.value) return 1;
-			break;
-		case eIdIndex:
-			if (!strncmp(id.index,partialList.list[i].field.id.index,4)) return 1;
-			break;
-		case eString:
-			if (vFile && matchesIn(repairFolders(vFile),partialList.list[i].field.text)) return 1;
-			break;
-		case eId:
-			if (!resIdCmp(id,partialList.list[i].field.id)) return 1;
-			break;
-		}*/
+	for (i=0;i<partialList.count;i++)
 		if (runRM(partialList.list+i,repairFolders(vFile?vFile:""),&id)) return 1;
-	}
+
 	return 0;
 }
 
diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c
index 7601d10..42a339d 100644
--- a/PR/src/lib/layers/memory.c
+++ b/PR/src/lib/layers/memory.c
@@ -54,6 +54,18 @@ void str5lowercpy (char* dst,const char* src) {
 	*dst=0;
 }
 
+char* toLower(const char* txt) {
+	static char ret[5];
+	char* r=ret;
+	while (*txt) {
+		*r=(('A'<=(*txt)) && ((*txt)<='Z'))?(*txt)|0x20:*txt;
+		r++;
+		txt++;
+	}
+	*r=0;
+	return ret;			
+}
+
 int matchesIn(const char *s, const char *p) {
   switch(*p) {
     case 0: return !(*s);
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 2d998a6..f040f1b 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -45,18 +45,6 @@ unknown.c: Princed Resources : Unknown resources handler
 #include "stringformat.h"
 #include "translate.h"
 
-char* toLower(const char* txt) { /* TODO: send to memory.c */
-	static char ret[5];
-	char* r=ret;
-	while (*txt) {
-		*r=(('A'<=(*txt)) && ((*txt)<='Z'))?(*txt)|0x20:*txt;
-		r++;
-		txt++;
-	}
-	*r=0;
-	return ret;			
-}
-
 /***************************************************************\
 |                     Unknown.xml primitives                    |
 \***************************************************************/
@@ -74,29 +62,31 @@ static struct {
 	unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 } unknownFile;
 
-/* syntactic layer */
+/***************************************************************\
+|                        Syntactic Layer                        |
+\***************************************************************/
 
-#define unknown_emptyfile()\
-	fprintf(unknownFile.fd, "<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n\
-<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<resources version=\"generated\" />\n") /* TODO: don't affect this file if empty */
+#define unknown_emptyfile() /* TODO: don't affect this file if empty */  fprintf(unknownFile.fd,\
+	"<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\
+	"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<resources version=\"generated\" />\n") 
 
-#define unknown_folderclose()\
-	fprintf(unknownFile.fd, "\t</folder>\n\n")
+#define unknown_folderclose() fprintf(unknownFile.fd,\
+	"\t</folder>\n\n")
 
-#define unknown_folder(path, file, palette, paletteindex)\
-	fprintf(unknownFile.fd, "\t<folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n",\
-	                                                    path,       file,       palette,       paletteindex)
+#define unknown_folder(path, file, palette, paletteindex) fprintf(unknownFile.fd,\
+	"\t<folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n",\
+	                            path,       file,       palette,       paletteindex)
 
-#define unknown_foot()\
-	fprintf(unknownFile.fd, "</resources>\n")
+#define unknown_foot() fprintf(unknownFile.fd,\
+	"</resources>\n")
 
-#define unknown_head()\
-	fprintf(unknownFile.fd, "<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n\
-<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n")
+#define unknown_head() fprintf(unknownFile.fd,\
+	"<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\
+	"<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n")
 
-#define unknown_item(value,index,path,type,flags,typedesc,count)\
-	fprintf(unknownFile.fd, "\t\t<item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n",\
-	                                   value,       index,       path,       type,       flags,          typedesc, count)
+#define unknown_item(value,index,path,type,flags,typedesc,count) fprintf(unknownFile.fd,\
+	"\t\t<item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n",\
+	           value,       index,       path,       type,       flags,          typedesc, count)
 
 /***************************************************************\
 |                          Semantic Layer                       |
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 2d998a6..f040f1b 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -45,18 +45,6 @@ unknown.c: Princed Resources : Unknown resources handler
 #include "stringformat.h"
 #include "translate.h"
 
-char* toLower(const char* txt) { /* TODO: send to memory.c */
-	static char ret[5];
-	char* r=ret;
-	while (*txt) {
-		*r=(('A'<=(*txt)) && ((*txt)<='Z'))?(*txt)|0x20:*txt;
-		r++;
-		txt++;
-	}
-	*r=0;
-	return ret;			
-}
-
 /***************************************************************\
 |                     Unknown.xml primitives                    |
 \***************************************************************/
@@ -74,29 +62,31 @@ static struct {
 	unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 } unknownFile;
 
-/* syntactic layer */
+/***************************************************************\
+|                        Syntactic Layer                        |
+\***************************************************************/
 
-#define unknown_emptyfile()\
-	fprintf(unknownFile.fd, "<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n\
-<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<resources version=\"generated\" />\n") /* TODO: don't affect this file if empty */
+#define unknown_emptyfile() /* TODO: don't affect this file if empty */  fprintf(unknownFile.fd,\
+	"<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\
+	"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<resources version=\"generated\" />\n") 
 
-#define unknown_folderclose()\
-	fprintf(unknownFile.fd, "\t</folder>\n\n")
+#define unknown_folderclose() fprintf(unknownFile.fd,\
+	"\t</folder>\n\n")
 
-#define unknown_folder(path, file, palette, paletteindex)\
-	fprintf(unknownFile.fd, "\t<folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n",\
-	                                                    path,       file,       palette,       paletteindex)
+#define unknown_folder(path, file, palette, paletteindex) fprintf(unknownFile.fd,\
+	"\t<folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n",\
+	                            path,       file,       palette,       paletteindex)
 
-#define unknown_foot()\
-	fprintf(unknownFile.fd, "</resources>\n")
+#define unknown_foot() fprintf(unknownFile.fd,\
+	"</resources>\n")
 
-#define unknown_head()\
-	fprintf(unknownFile.fd, "<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n\
-<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n")
+#define unknown_head() fprintf(unknownFile.fd,\
+	"<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\
+	"<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n")
 
-#define unknown_item(value,index,path,type,flags,typedesc,count)\
-	fprintf(unknownFile.fd, "\t\t<item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n",\
-	                                   value,       index,       path,       type,       flags,          typedesc, count)
+#define unknown_item(value,index,path,type,flags,typedesc,count) fprintf(unknownFile.fd,\
+	"\t\t<item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n",\
+	           value,       index,       path,       type,       flags,          typedesc, count)
 
 /***************************************************************\
 |                          Semantic Layer                       |