author | ecalot
<ecalot> 2005-12-30 02:01:40 UTC |
committer | ecalot
<ecalot> 2005-12-30 02:01:40 UTC |
parent | 608ffebba8e9b545c40bc15476fdf4f2fd129956 |
PR/src/include/tree.h | +8 | -2 |
PR/src/include/unknown.h | +11 | -0 |
PR/src/lib/xml/tree.c | +14 | -23 |
PR/src/lib/xml/unknown.c | +8 | -18 |
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h index ee5360d..6924ef1 100644 --- a/PR/src/include/tree.h +++ b/PR/src/include/tree.h @@ -37,8 +37,14 @@ unknown.h: Princed Resources : Unknown.xml generator headers /* Includes */ #include "reslist.h" -void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex); -void unknown_item(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count); +typedef struct { + tTag* folderCursor; + tTag* folderFirst; + tTag* itemCursor; +} tTreeStatus; + +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); diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h index 16c94c5..d9313fd 100644 --- a/PR/src/include/unknown.h +++ b/PR/src/include/unknown.h @@ -41,6 +41,17 @@ unknown.h: Princed Resources : Unknown.xml generator headers /* Includes */ #include "parse.h" #include "reslist.h" +#include "tree.h" /* tTreeStatus */ + +typedef struct { + char* backupExtension; + char* currentDat; + FILE* fd; + tTreeStatus status; + tTag* tree; + unsigned int optionflag; + unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */ +} tUnknownFile; /* 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); diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c index 9a763ae..54989b4 100644 --- a/PR/src/lib/xml/tree.c +++ b/PR/src/lib/xml/tree.c @@ -40,6 +40,7 @@ tree.c: Princed Resources : Tree handling routines #include <stdio.h> #include "common.h" #include "memory.h" +#include "unknown.h" /* typedef tUnknownFile */ #include "parse.h" /* RES_TYPECOUNT */ /***************************************************************\ @@ -52,17 +53,7 @@ tree.c: Princed Resources : Tree handling routines "<!DOCTYPE resources SYSTEM \"http://www.princed.com.ar/standards/xml/resources/std1.dtd\">\n"\ "<?xml version=\"1.0\" ?>\n" -extern struct { - char* backupExtension; - char* currentDat; - FILE* fd; - tTag* folderCursor; - tTag* folderFirst; - tTag* itemCursor; - tTag* tree; - unsigned int optionflag; - unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */ -} unknownFile; +extern tUnknownFile unknownFile; /***************************************************************\ | Tree Layer | @@ -75,7 +66,7 @@ extern struct { /* TODO */ /* Tag generation routines */ -void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex) { +void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status) { char number[10]; tTag* folder=malloc(sizeof(tTag)); @@ -88,16 +79,16 @@ void unknown_folder(const char* path, const char* file, int palette, const char* folder->palette=strallocandcopy(number); folder->paletteindex=strallocandcopy(paletteindex); - if (!unknownFile.folderFirst) { - unknownFile.folderFirst=folder; + if (!status->folderFirst) { + status->folderFirst=folder; } else { - unknownFile.folderCursor->next=folder; + status->folderCursor->next=folder; } - unknownFile.folderCursor=folder; - unknownFile.itemCursor=NULL; + status->folderCursor=folder; + status->itemCursor=NULL; } -void unknown_item(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count) { +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) { char aux[100]; tTag* item=malloc(sizeof(tTag)); @@ -113,16 +104,16 @@ void unknown_item(int value,const char* index,const char* path,const char* type, sprintf(aux,"Unknown %s %d",typedesc, count); item->desc=strallocandcopy(aux); - if (!unknownFile.itemCursor) { - unknownFile.folderCursor->child=item; + if (!status->itemCursor) { + status->folderCursor->child=item; } else { - unknownFile.itemCursor->next=item; + status->itemCursor->next=item; } - unknownFile.itemCursor=item; + status->itemCursor=item; } /* memory tree --> xml */ -#define outputStream unknownFile.fd +#define outputStream unknownFile.fd /**/ void generateXML(int n,tTag* t) { int a; diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c index 743f072..4782ab2 100644 --- a/PR/src/lib/xml/unknown.c +++ b/PR/src/lib/xml/unknown.c @@ -56,17 +56,7 @@ unknown.c: Princed Resources : Unknown resources handler #define XML_TAG_RESOURCES "resources" #define XML_ATTRV_VERSION "generated" -struct { - char* backupExtension; - char* currentDat; - FILE* fd; - tTag* folderCursor; - tTag* folderFirst; - tTag* itemCursor; - tTag* tree; - unsigned int optionflag; - unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */ -} unknownFile; +tUnknownFile unknownFile; /***************************************************************\ | Logging Layer | @@ -87,8 +77,8 @@ int unknownLogStart (const char* file,int optionflag, const char* backupExtensio { int error; - unknownFile.folderFirst=NULL; - unknownFile.folderCursor=NULL; + unknownFile.status.folderFirst=NULL; + unknownFile.status.folderCursor=NULL; unknownFile.tree=parseXmlFile(file,&error); if (error) { unknownFile.tree=malloc(sizeof(tTag)); @@ -117,9 +107,9 @@ int unknownLogStop () { if (unknownFile.tree) { if (unknownFile.tree->child) { for (t=unknownFile.tree->child;t->next;t=t->next); - t->next=unknownFile.folderFirst; /* the first folder of the new tree */ + t->next=unknownFile.status.folderFirst; /* the first folder of the new tree */ } else { - unknownFile.tree->child=unknownFile.folderFirst; /* the first folder of the new tree */ + unknownFile.tree->child=unknownFile.status.folderFirst; /* the first folder of the new tree */ } } @@ -148,20 +138,20 @@ int unknownLogAppend(const char* vFiledat,tResourceId id,const char* ext,tResour if (!unknownFile.fd) return PR_RESULT_ERR_XML_NOT_OPEN; /* File not open, logging is off, just a warning */ if (!unknownFile.currentDat) { /* this is the beginning of the file */ - unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index))); + 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); } else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) { int i; - unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index))); + unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index)),&unknownFile.status); freeAllocation(unknownFile.currentDat); unknownFile.currentDat=strallocandcopy(vFiledat); unknown_deletetreefile(vFiledat); for (i=0;i<RES_TYPECOUNT;i++) unknownFile.typeCount[i]=0; /* re-initialize in 0 for next file processing */ } - unknown_item(id.value,translateInt2Ext(toLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count); + unknown_item(id.value,translateInt2Ext(toLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count,&unknownFile.status); return PR_RESULT_SUCCESS; }