git » fp-git.git » commit 6ae3625

addapted the new defines for the generated tags in unknown.xml

author ecalot
2005-12-21 11:26:33 UTC
committer ecalot
2005-12-21 11:26:33 UTC
parent dfaf3832e11f55b4b0d0a2b8075cc0249e2d2a1f

addapted the new defines for the generated tags in unknown.xml

PR/src/console/main.c +2 -4
PR/src/include/tree.h +3 -9
PR/src/include/unknown.h +3 -9
PR/src/lib/xml/tree.c +35 -25
PR/src/lib/xml/unknown.c +35 -25

diff --git a/PR/src/console/main.c b/PR/src/console/main.c
index 0cc301e..5ea64ee 100644
--- a/PR/src/console/main.c
+++ b/PR/src/console/main.c
@@ -189,6 +189,7 @@ int main (int argc, char **argv) {
 			fprintf(stderr,"No files selected\n");
 			break;
 		case 0:
+			unknownLogStart(NULL,optionflag,extension);
 			while ((file=fileDirGetFile(&files,&datfile))) {
 				const char* dat;
 				if (datFileName)
@@ -199,9 +200,7 @@ int main (int argc, char **argv) {
 				if (hasFlag(import_flag)) {
 					/* import */
 					fprintf(outputStream,PR_TEXT_TASK_COMPILE,file,dirName);
-					unknownLogStart(NULL,optionflag,extension);
 					result=prImportDatOpt(file,dirName,resFile,optionflag,dat,extension);
-					unknownLogStop();
 					if (result>0) {
 						fprintf(outputStream,PR_TEXT_RESULT_ERR,result,result);
 					} else {
@@ -210,9 +209,7 @@ int main (int argc, char **argv) {
 				} else if (hasFlag(export_flag)) {
 					/* export */
 					fprintf(outputStream,PR_TEXT_TASK_EXTRACT,file,dirName);
-					unknownLogStart(NULL,optionflag,extension);
 					result=prExportDatOpt(file,dirName,resFile,optionflag,dat,datAuthor,extension,format);
-					unknownLogStop();
 					if (result>0) {
 						fprintf(outputStream,PR_TEXT_EXPORT_OK,result,result);
 					} else {
@@ -232,6 +229,7 @@ int main (int argc, char **argv) {
 				free(datfile);
 			}
 			fprintf(outputStream,"\n");
+			unknownLogStop();
 			break;
 		default:
 			fprintf(stderr,"Error, check the xml file\n");
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index 19eb3fc..9958a46 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -34,17 +34,10 @@ unknown.h: Princed Resources : Resource Handler headers
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-/* XML generation defines */
-
-#define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "%t%03n.%e"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
 
 /* File extensions */
 
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"} /* TODO: move to common.h */
 
 /* Includes */
 #include "parse.h"
@@ -57,8 +50,9 @@ 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 */
+/* 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 19eb3fc..9958a46 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -34,17 +34,10 @@ unknown.h: Princed Resources : Resource Handler headers
 #ifndef _RESOURCES_H_
 #define _RESOURCES_H_
 
-/* XML generation defines */
-
-#define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
-#define RES_XML_UNKNOWN_FILES "%t%03n.%e"
-#define RES_XML_UNKNOWN_START "<?xml version=\"1.0\" ?>\n<resources version=\"generated\">\n <folder name=\"unknown\" path=\"%s\" file=\"%s\" palette=\"%d\" paletteindex=\"%s\">\n"
-#define RES_XML_UNKNOWN_ITEM  "  <item value=\"%d\" index=\"%s\" path=\"%s\" type=\"%s\" flags=\"0x%lx\">Unknown %s %d</item>\n"
-#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
 
 /* File extensions */
 
-#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
+#define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"} /* TODO: move to common.h */
 
 /* Includes */
 #include "parse.h"
@@ -57,8 +50,9 @@ 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 */
+/* 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/xml/tree.c b/PR/src/lib/xml/tree.c
index 371ad7b..aa4cf82 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -45,10 +45,29 @@ 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                    |
 \***************************************************************/
 
+/* XML generation defines */
+
+#define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
+#define RES_XML_UNKNOWN_FILES "%t%03n.%e"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
 unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 
 static struct {
@@ -64,22 +83,26 @@ static struct {
 /* fwrite(RES_XML_UNKNOWN_END,1,sizeof(RES_XML_UNKNOWN_END)-1,unknownXmlFile);*/
 
 #define unknown_emptyfile()\
-	fprintf(unknownFile.fd, "<?xml version=\"1.0\" ?>\n<resources />\n")
+	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_folderclose()\
 	fprintf(unknownFile.fd, "\t</folder>\n\n")
 
-#define unknown_folder(file)\
-	fprintf(unknownFile.fd, "\t<folder file=\"%s\">\n", file)
+#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_head()\
-	fprintf(unknownFile.fd, "<?xml version=\"1.0\" ?>\n<resources>\n")
+	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(path)\
-	fprintf(unknownFile.fd, "\t\t<item path=\"%s\" />\n", path)
+#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 */
@@ -132,34 +155,21 @@ int unknownLogAppend(const char* vFiledatWithPath,tResourceId id,const char* ext
 
 	if (!unknownFile.currentDat) { /* this is the beginning of the file */
 		unknown_head();
-		unknown_folder(vFiledat); 
+		unknown_folder(vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)));
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		unknown_folderclose(); 
-		unknown_folder(vFiledat); 
+		unknown_folder(vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)));
 		freeAllocation(unknownFile.currentDat);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 	}
 
-	unknown_item(ext);
+	unknown_item(id.value,translateInt2Ext(toLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count);
 
 	return 0;
 }
 
 
-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;			
-}
-
-
 
 /* Resources output to xml functions. Private+abstract variable */
 /*static FILE* unknownXmlFile=NULL;*/
@@ -214,14 +224,14 @@ void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const cha
 
 	if (r->path==NULL) {
 		pos=((r->type<RES_TYPECOUNT)&&(r->type>=0))?r->type:eResTypeBinary;
-		typeCount[pos]++;
+		unknownFile.typeCount[pos]++;
 
 		/* set filename */
 		if (!format) format=RES_XML_UNKNOWN_FILES;
-		filename=parseformat(format,r->id.value,r->id.index,getExtDesc(pos),extarray[pos],typeCount[pos],r->id.order,r->desc);
+		filename=parseformat(format,r->id.value,r->id.index,getExtDesc(pos),extarray[pos],unknownFile.typeCount[pos],r->id.order,r->desc);
 
 		sprintf(vFileext,RES_XML_UNKNOWN_PATH"%s",vDirExt,vDatFileName,filename);
-		AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags,filename);
+		AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,unknownFile.typeCount[pos],r->flags,filename);
 	} else {
 		/* set filename */
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 371ad7b..aa4cf82 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -45,10 +45,29 @@ 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                    |
 \***************************************************************/
 
+/* XML generation defines */
+
+#define RES_XML_UNKNOWN_PATH  "%s/unknown/%s/"
+#define RES_XML_UNKNOWN_FILES "%t%03n.%e"
+#define RES_XML_UNKNOWN_END   " </folder>\n</resources>\n"
+
 unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 
 static struct {
@@ -64,22 +83,26 @@ static struct {
 /* fwrite(RES_XML_UNKNOWN_END,1,sizeof(RES_XML_UNKNOWN_END)-1,unknownXmlFile);*/
 
 #define unknown_emptyfile()\
-	fprintf(unknownFile.fd, "<?xml version=\"1.0\" ?>\n<resources />\n")
+	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_folderclose()\
 	fprintf(unknownFile.fd, "\t</folder>\n\n")
 
-#define unknown_folder(file)\
-	fprintf(unknownFile.fd, "\t<folder file=\"%s\">\n", file)
+#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_head()\
-	fprintf(unknownFile.fd, "<?xml version=\"1.0\" ?>\n<resources>\n")
+	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(path)\
-	fprintf(unknownFile.fd, "\t\t<item path=\"%s\" />\n", path)
+#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 */
@@ -132,34 +155,21 @@ int unknownLogAppend(const char* vFiledatWithPath,tResourceId id,const char* ext
 
 	if (!unknownFile.currentDat) { /* this is the beginning of the file */
 		unknown_head();
-		unknown_folder(vFiledat); 
+		unknown_folder(vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)));
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		unknown_folderclose(); 
-		unknown_folder(vFiledat); 
+		unknown_folder(vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)));
 		freeAllocation(unknownFile.currentDat);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 	}
 
-	unknown_item(ext);
+	unknown_item(id.value,translateInt2Ext(toLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count);
 
 	return 0;
 }
 
 
-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;			
-}
-
-
 
 /* Resources output to xml functions. Private+abstract variable */
 /*static FILE* unknownXmlFile=NULL;*/
@@ -214,14 +224,14 @@ void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const cha
 
 	if (r->path==NULL) {
 		pos=((r->type<RES_TYPECOUNT)&&(r->type>=0))?r->type:eResTypeBinary;
-		typeCount[pos]++;
+		unknownFile.typeCount[pos]++;
 
 		/* set filename */
 		if (!format) format=RES_XML_UNKNOWN_FILES;
-		filename=parseformat(format,r->id.value,r->id.index,getExtDesc(pos),extarray[pos],typeCount[pos],r->id.order,r->desc);
+		filename=parseformat(format,r->id.value,r->id.index,getExtDesc(pos),extarray[pos],unknownFile.typeCount[pos],r->id.order,r->desc);
 
 		sprintf(vFileext,RES_XML_UNKNOWN_PATH"%s",vDirExt,vDatFileName,filename);
-		AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags,filename);
+		AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,unknownFile.typeCount[pos],r->flags,filename);
 	} else {
 		/* set filename */
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);