author | ecalot
<ecalot> 2005-12-17 07:07:51 UTC |
committer | ecalot
<ecalot> 2005-12-17 07:07:51 UTC |
parent | e8d598267d1bfc0537acabd103efe7c6742ec5af |
PR/src/console/main.c | +6 | -1 |
PR/src/include/common.h | +1 | -0 |
PR/src/include/en.lang.pr.h | +4 | -2 |
PR/src/include/export.h | +1 | -1 |
PR/src/include/pr.h | +1 | -1 |
PR/src/include/tree.h | +1 | -1 |
PR/src/include/unknown.h | +1 | -1 |
PR/src/lib/actions/export.c | +3 | -3 |
PR/src/lib/actions/import.c | +2 | -2 |
PR/src/lib/pr.c | +6 | -3 |
PR/src/lib/xml/tree.c | +5 | -5 |
PR/src/lib/xml/unknown.c | +5 | -5 |
diff --git a/PR/src/console/main.c b/PR/src/console/main.c index 5be93d1..280eb3e 100644 --- a/PR/src/console/main.c +++ b/PR/src/console/main.c @@ -64,6 +64,7 @@ int main (int argc, char **argv) { char* datFileName =NULL; char* datfile =NULL; char* extension =NULL; + char* format =NULL; char* resFile =NULL; char* file; char* errors[] =PR_TEXT_ERRORS; @@ -101,6 +102,10 @@ int main (int argc, char **argv) { freeAllocation(extension); extension=strallocandcopy(optarg); break; + case 'F': + freeAllocation(format); + format=strallocandcopy(optarg); + break; case 'f': setFlag(force_flag); break; @@ -202,7 +207,7 @@ int main (int argc, char **argv) { } else if (hasFlag(export_flag)) { /* export */ fprintf(outputStream,PR_TEXT_TASK_EXTRACT,file,dirName); - result=prExportDatOpt(file,dirName,resFile,optionflag,dat,datAuthor,extension); + result=prExportDatOpt(file,dirName,resFile,optionflag,dat,datAuthor,extension,format); if (result>0) { fprintf(outputStream,PR_TEXT_EXPORT_OK,result,result); } else { diff --git a/PR/src/include/common.h b/PR/src/include/common.h index 8ed48cb..bbb4439 100644 --- a/PR/src/include/common.h +++ b/PR/src/include/common.h @@ -140,6 +140,7 @@ common.h: Princed Resources : Defines and prototypes common to all PR code {"setauthor", required_argument, 0,'a'},\ {"backup", optional_argument, 0,'b'},\ {"force", no_argument, 0,'f'},\ +{"format", required_argument, 0,'F'},\ {"cgi", no_argument, 0,'g'},\ {"help", no_argument, 0,'?'},\ {"resource", required_argument, 0,'s'},\ diff --git a/PR/src/include/en.lang.pr.h b/PR/src/include/en.lang.pr.h index edeb4a8..be4655c 100644 --- a/PR/src/include/en.lang.pr.h +++ b/PR/src/include/en.lang.pr.h @@ -154,11 +154,13 @@ NULL,NULL,NULL,\ -t, --datfile=DATFILE specifies a dat file to read resources\n\ different than the original file\n\ -z, --compression-level=N a number from 1 to 7 specifying how hard has PR\n\ - to try to reduce the generated dat files.\n" + to try to reduce the generated dat files\n" #define PARSING_HELP_PART4 "\ 1 is high speed, low compression, 7 is high\n\ - compression but low speed.\n\ + compression but low speed\n\ + --format=FORMAT generate the item files in the unknown file using\n\ + the given format\n\ --unknown generate the unknown file without performing\n\ any extraction\n\ -v, --verbose explain what is being done\n\ diff --git a/PR/src/include/export.h b/PR/src/include/export.h index f39b26e..fdefe5a 100644 --- a/PR/src/include/export.h +++ b/PR/src/include/export.h @@ -36,7 +36,7 @@ export.h: Princed Resources : DAT Extractor headers #include "reslist.h" -int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int task, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension); +int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int task, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension,const char* format); #endif diff --git a/PR/src/include/pr.h b/PR/src/include/pr.h index 633cb1e..cd499a5 100644 --- a/PR/src/include/pr.h +++ b/PR/src/include/pr.h @@ -92,7 +92,7 @@ int prClassifyDat(const char* vFiledat); /* Extra featured functions */ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char * vDatFileName, - const char* datAuthor, const char* backupExtension); + const char* datAuthor, const char* backupExtension, const char* format); int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName, const char* backupExtension); diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h index e8e8117..a897cea 100644 --- a/PR/src/include/tree.h +++ b/PR/src/include/tree.h @@ -51,7 +51,7 @@ resources.h: Princed Resources : Resource Handler headers #include "reslist.h" /* Resources extras */ -void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension); +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); const char* getExtDesc(int type); diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h index e8e8117..a897cea 100644 --- a/PR/src/include/unknown.h +++ b/PR/src/include/unknown.h @@ -51,7 +51,7 @@ resources.h: Princed Resources : Resource Handler headers #include "reslist.h" /* Resources extras */ -void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension); +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); const char* getExtDesc(int type); diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c index cc06fe4..cc2bd13 100644 --- a/PR/src/lib/actions/export.c +++ b/PR/src/lib/actions/export.c @@ -68,7 +68,7 @@ extern FILE* outputStream; For parameter documentation, see pr.c */ -int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension) { +int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension,const char* format) { char vFileext[MAX_FILENAME_SIZE]; int indexNumber; int ok; @@ -102,7 +102,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */ /* get save file name (if unknown document is in the xml) */ - getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension); + getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,format); switch (res.type) { case eResTypeLevel: @@ -158,7 +158,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti if (ok) count++; } else { /* if the dat file is unknown, add it in the xml */ - getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension); + getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,format); } } } diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c index c6fcff7..7616403 100644 --- a/PR/src/lib/actions/import.c +++ b/PR/src/lib/actions/import.c @@ -109,7 +109,7 @@ int fullCompile(const char* vFiledat, const char* vDirExt, tResourceList* r, int newRes.flags=res->flags; if (hasFlag(raw_flag)) newRes.type=0; /* compile from raw */ - getFileName(vFileext,vDirExt,res,vFiledat,vDatFileName,optionflag,backupExtension); + getFileName(vFileext,vDirExt,res,vFiledat,vDatFileName,optionflag,backupExtension,NULL); /* the file is in the archive, so i'll add it to the main dat body */ if ((newRes.size=(mLoadFileArray(vFileext,&newRes.data)))>0) { if (!mAddCompiledFileToDatFile(&newRes,vFileext)) { @@ -168,7 +168,7 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r, if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */ /* get save file name (if unknown document is in the xml) */ - getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension); + getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,NULL); /* the file is in the partial list, so i'll import */ if ((newRes.size=mLoadFileArray(vFileext,&newRes.data))>0) { diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c index c3c3614..0b50a87 100644 --- a/PR/src/lib/pr.c +++ b/PR/src/lib/pr.c @@ -75,10 +75,10 @@ void prSetOutput(FILE* output) { int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile) { outputStream=stdout; - return prExportDatOpt(vDatFile,vDirName,vResFile,export_flag,NULL,NULL,NULL); + return prExportDatOpt(vDatFile,vDirName,vResFile,export_flag,NULL,NULL,NULL,NULL); } -int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName,const char* datAuthor, const char* backupExtension) { +int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName,const char* datAuthor, const char* backupExtension,const char* format) { /* Arguments: char* vDatFile - full Path to the dat file @@ -94,6 +94,9 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF const char* backupExtension - If backup_flag is set, the string to attach to the backup files + const char* format + - Sets the format the unknown files will be created. + See stringformat.c documentation. Options: unknown_flag - generate the unknown file without performing @@ -141,7 +144,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF a=parseFile(vResFile,currentDatFileName,&r); if (a==PR_RESULT_SUCCESS) { /* exporting errors/no errors */ - a=extract(currentDatFile,vDirName,&r,opt,currentDatFileName,datAuthor,backupExtension); + a=extract(currentDatFile,vDirName,&r,opt,currentDatFileName,datAuthor,backupExtension,format); } resourceListDrop(&r); free(currentDatFileName); diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c index 48ead30..1f8ffa2 100644 --- a/PR/src/lib/xml/tree.c +++ b/PR/src/lib/xml/tree.c @@ -85,7 +85,7 @@ char* toLower(const char* txt) { return ret; } -void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext,tResourceType type,const char* vDirExt,tResourceId pal,const char* vFiledat,int optionflag,int count, unsigned long int flags) { +void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext,tResourceType type,const char* vDirExt,tResourceId pal,const char* vFiledat,int optionflag,int count, unsigned long int flags,const char* format) { /* Open file if not open */ if (unknownXmlFile==NULL) { char xmlFile[MAX_FILENAME_SIZE]; @@ -96,8 +96,8 @@ void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext /* Save headers */ if (type==eResTypePalette) pal=id; - fprintf(unknownXmlFile,RES_XML_UNKNOWN_START, - vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)) + fprintf(unknownXmlFile,RES_XML_UNKNOWN_START"%s", + vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)),format ); } @@ -119,7 +119,7 @@ void endUnknownXml(int optionflag, const char* backupExtension) { } } -void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag, const char* backupExtension) { +void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag, const char* backupExtension,const char* format) { static const char* extarray[]=RES_FILE_EXTENSIONS; int pos; @@ -129,7 +129,7 @@ void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const cha /* set filename */ sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,getExtDesc(pos),typeCount[pos],extarray[pos]); - AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags); + AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags,format); } 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 48ead30..1f8ffa2 100644 --- a/PR/src/lib/xml/unknown.c +++ b/PR/src/lib/xml/unknown.c @@ -85,7 +85,7 @@ char* toLower(const char* txt) { return ret; } -void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext,tResourceType type,const char* vDirExt,tResourceId pal,const char* vFiledat,int optionflag,int count, unsigned long int flags) { +void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext,tResourceType type,const char* vDirExt,tResourceId pal,const char* vFiledat,int optionflag,int count, unsigned long int flags,const char* format) { /* Open file if not open */ if (unknownXmlFile==NULL) { char xmlFile[MAX_FILENAME_SIZE]; @@ -96,8 +96,8 @@ void AddToUnknownXml(const char* vFiledatWithPath,tResourceId id,const char* ext /* Save headers */ if (type==eResTypePalette) pal=id; - fprintf(unknownXmlFile,RES_XML_UNKNOWN_START, - vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)) + fprintf(unknownXmlFile,RES_XML_UNKNOWN_START"%s", + vFiledat,vFiledatWithPath,pal.value,translateInt2Ext(toLower(pal.index)),format ); } @@ -119,7 +119,7 @@ void endUnknownXml(int optionflag, const char* backupExtension) { } } -void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag, const char* backupExtension) { +void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag, const char* backupExtension,const char* format) { static const char* extarray[]=RES_FILE_EXTENSIONS; int pos; @@ -129,7 +129,7 @@ void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const cha /* set filename */ sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,getExtDesc(pos),typeCount[pos],extarray[pos]); - AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags); + AddToUnknownXml(vDatFileName,r->id,extarray[pos],r->type,vDirExt,r->palette,vFiledat,optionflag,typeCount[pos],r->flags,format); } else { /* set filename */ sprintf(vFileext,"%s/%s",vDirExt,r->path);