git » fp-git.git » commit 96ca80b

o Solved bugs

author ecalot
2003-12-22 03:38:50 UTC
committer ecalot
2003-12-22 03:38:50 UTC
parent 0e5337d386245d213e424e9c2434c8778cb586e1

o Solved bugs

PR/src/include/autodetect.h +11 -4
PR/src/include/bitmap.h +1 -2
PR/src/include/bmp.h +1 -2
PR/src/include/common.h +186 -60
PR/src/include/compress.h +1 -1
PR/src/include/disk.h +5 -3
PR/src/include/export.h +1 -1
PR/src/include/filedir.h +15 -1
PR/src/include/idlist.h +11 -4
PR/src/include/image.h +1 -1
PR/src/include/import.h +1 -1
PR/src/include/memory.h +1 -0
PR/src/include/pal.h +1 -1
PR/src/include/plv.h +4 -3
PR/src/include/png.h +1 -2
PR/src/include/pr.h +186 -60
PR/src/include/search.h +15 -1
PR/src/include/tree.h +11 -4
PR/src/include/unknown.h +11 -4
PR/src/include/wav.h +2 -2
PR/src/ports/dirent.c +1 -1

diff --git a/PR/src/include/autodetect.h b/PR/src/include/autodetect.h
index 228a429..a5478dc 100644
--- a/PR/src/include/autodetect.h
+++ b/PR/src/include/autodetect.h
@@ -25,8 +25,10 @@ typedef struct {
 	char*     desc;
 }tResource;
 
+#include <stdio.h>
+
 //Verify  header
-char verifyHeader(char* array, int size);
+int verifyHeader(unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -46,17 +48,22 @@ char verifyHeader(char* array, int size);
 //Empty resource table
 void emptyTable(tResource* r[]);
 
-//parse file
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
 
 //Resources extras
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat);
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
+//parse file and free parsed structure
+char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+void freeParsedStructure();
+
 //In case there are unknown resources it closes the unknown XML output
 void endUnknownXml();
 
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+
 #endif
diff --git a/PR/src/include/bitmap.h b/PR/src/include/bitmap.h
index d727520..a870771 100644
--- a/PR/src/include/bitmap.h
+++ b/PR/src/include/bitmap.h
@@ -5,10 +5,9 @@
 #include "resources.h"
 #include "compress.h"
 
-
 char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
 char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
 char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,char* data, int size); //Note: this will ignore the palette
+char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
 
 #endif
diff --git a/PR/src/include/bmp.h b/PR/src/include/bmp.h
index d727520..a870771 100644
--- a/PR/src/include/bmp.h
+++ b/PR/src/include/bmp.h
@@ -5,10 +5,9 @@
 #include "resources.h"
 #include "compress.h"
 
-
 char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
 char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
 char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,char* data, int size); //Note: this will ignore the palette
+char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
 
 #endif
diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index 530bc38..f251681 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -1,7 +1,47 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    The authors of this program may be contacted at http://forum.princed.com.ar
+*/
+
+/*
+pr.h: Princed Resources : Main header prototypes and definitions
+\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.00 (2003-Aug-24)
+
+  Modified by: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.10 (2003-Dec-03)
+  
+  Language: English
+
+ Note:
+  DO NOT remove this copyright notice
+*/
+
 #ifndef _PR_H_
 #define _PR_H_
 
-//princed resource library
+/***************************************************************\
+|                Princed Resource Library Functions             |
+\***************************************************************/
 
 #include <stdio.h>
 
@@ -10,7 +50,7 @@
  #define UNIX
 #endif
 
-/* #define DLL --> use -DDLL as a precompiler option */
+/* do not #define DLL, use -DDLL as a precompiler option instead */
 #ifdef DLL
  #ifdef UNIX
   #define SO
@@ -29,23 +69,83 @@
 #define DEB_FLAG
 
 #ifdef DEB_FLAG
- #define fld(a) printf(a);
+ #define fld(a) printf(a "\n");
 #else
  #define fld(a)
 #endif
 
-//Main program defines
-#define PR_ABOUT             "Princed resources (PR) V0.9 "OS"\r\n(c) Copyright 2003 - Princed Development Team\r\n"\
-                             "http://www.princed.com.ar\r\n\r\n"
+/***************************************************************\
+|             M A I N   P R O G R A M   D E F I N E S           |
+\***************************************************************/
+
+
+/***************************************************************\
+|                           Text Defines                        |
+\***************************************************************/
+
+
+#define PR_ABOUT                  "Princed resources (PR) V0.9 "OS"\n(c) Copyright 2003 - Princed Development Team\n\
+http://www.princed.com.ar\n\n"
 
-#define PR_CGI_TEXT1         "Content-Type:text/html\n\nRunning as a cgi\n"
-#define PR_CGI_TEXT2         "Result: %02d type\r\n"
+#define PR_CGI_TEXT1              "Content-Type:text/html\n\nRunning as a cgi\n"
+#define PR_CGI_TEXT2              "Result: %02d type\n"
 
-#define PR_TEXT_SKIPING      "Found invalid option '%c', skiping . . .\r\n"
-#define PR_TEXT_RESULT       "Result: %s (%d)\r\n"
-#define PR_TEXT_RESULT_ERR   "Result: %d files with errors\r\n"
+#define PR_TEXT_SKIPING           "Found invalid option '%c', skiping . . .\n"
+#define PR_TEXT_RESULT            "Result: %s (%d)\n"
+#define PR_TEXT_RESULT_ERR        "Result: %d files with errors\n"
+
+#define PR_TEXT_FILE_NOT_FOUND    "Result: File or directory '%s' not found\n"
+
+#define PR_TEXT_SCANNING_CURRENT  "Scanning dat files in current directory\n"
+#define PR_TEXT_SCANNING_GIVEN    "Scanning dat files in given directory\n"
+
+#define PR_TEXT_IMPORTING_CURRENT "Importing all valid dat files from the currect directory\n"
+#define PR_TEXT_IMPORTING_GIVEN   "Importing all valid files from given directory\n"
+
+#define PR_TEXT_TASK_COMPILE      "Compiling '%s' from '%s' with %04x\n"
+#define PR_TEXT_TASK_CLASSIFY     "Classifing '%s'\n"
+#define PR_TEXT_TASK_EXTRACT      "Extracting '%s' to '%s' with %04x\n"
+
+/***************************************************************\
+|                        Text Output Arrays                     |
+\***************************************************************/
+
+#define PR_TEXT_EXPORT_ARRAY {\
+"Ok",\
+"Error accessing the file DAT", /* DAT or extracted */\
+"Memory error in extraction",\
+"Invalid DAT file",\
+"XML Parse error",\
+"Memory error in parsing",\
+"XML Attribute not recognized",\
+"XML File not found"}
+
+#define PR_TEXT_CLASSIFY_ARRAY {\
+"Memory error",\
+"File not found or no access error",\
+"Not a valid POP1 DAT file",\
+"Levels file",\
+"Graphic file with an image in the first valid entry (not common)",\
+"Waves/Digital sound file",\
+"Midis file",\
+"Valid DAT file with Undefined content",\
+"Graphic file with a palette in the first valid entry (common)",\
+"PC Speaker dat file",\
+"","","",\
+"Pop2 dat files"}
+
+#define PR_TEXT_IMPORT_ARRAY {\
+"File succesfully compiled",\
+"DAT File couldn't be open for writing",\
+"XML Parse error",\
+"No memory",\
+"XML Attribute not recognized",\
+"XML File not found"}
+
+/***************************************************************\
+|                         Other defines                         |
+\***************************************************************/
 
-#define PR_TEXT_SYNTAX       "Usage: pr [datFilePath] [-x [extractDir]|-c [compileDir]|-d] [-n filename]\r\n\r\nValid options:\r\n -x[rn] for extract\r\n  r: raw extraction\r\n  n: don't extract\r\n -c[r] for compile\r\n  r: raw compiling\r\n -d for type\r\n"
 
 //Default Files
 #define RES_XML_UNKNOWN_XML  "unknown.xml"
@@ -67,6 +167,10 @@
  #define DIR_SEPARATOR       '\\'
 #endif
 
+/***************************************************************\
+|                            Prototypes                         |
+\***************************************************************/
+
 //Main functions
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prImportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
@@ -76,59 +180,81 @@ int prVerifyDatType(const char* vFiledat);
 int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char * vDatFileName,const char* datAuthor, const char* backupExtension);
 int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName, const char* backupExtension);
 
+//Recursive function
 int prMain(int* option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
 
-//Command Line specific options
-
-#define PARSING_HELP "Usage: \n"\
-"  pr [-x [EXTRACTDIR]|-c [COMPILEDIR]|-d] [DATFILEPATH]\n"\
-"  pr [OPTIONS] [DATFILEPATH]\n"\
-"\n"\
-"  Mandatory arguments to long options are mandatory for short options too.\n"\
-"\n"\
-"   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n"\
-"   -d, --classify             returns the DAT file type\n"\
-"   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n"\
-"\n"\
-"   -b, --backup[=EXTENSION]   backup your files\n"\
-"   -f, --force                default option, you cannot disable it,\n"\
-"                              so please make a backup of your files\n"\
-"   -g, --cgi                  run as CGI and output mime headers\n"\
-"   -h, --help                 display this help and exit\n"\
-"   -m, --resource=RESFILE     uses an user-specific resource xml file\n"\
-"   -r, --raw                  uses raw format\n"\
-"   -R, --recursive            searches for all dat files (only if DATFILEPATH\n"\
-"                              is not a dat file)\n"\
-"   -t, --datfile=DATFILE      specifies a dat file to read resources\n"\
-"                              different that the original file\n"\
-"       --unknown              generate the unknown file without performing\n"\
-"                              any extraction\n"\
-"   -v, --verbose              explain what is being done\n"\
-"       --version              output version information and exit\n"\
-"\n"
-
-//Add -a, --author for PLV format
+/***************************************************************\
+|                   Command Line specific options               |
+\***************************************************************/
+
+#define PARSING_HELP "Usage: \n\
+  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]\n\
+  pr [OPTIONS] [DATFILEPATH]\n\
+\n\
+  Mandatory arguments to long options are mandatory for short options too.\n\
+\n\
+   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n\
+   -d, --classify             returns the DAT file type\n\
+   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n\
+\n\
+   -a, --setauthor=NAME       sets your name in extracted PLV files\n\
+   -b, --backup[=EXTENSION]   backup your files\n\
+   -f, --force                default option, you cannot disable it,\n\
+                              so please make a backup of your files\n\
+   -g, --cgi                  run as CGI and output mime headers\n\
+   -h, -?, --help             display this help and exit\n\
+   -m, --resource=RESFILE     uses an user-specific resource xml file\n\
+   -r, --raw                  uses raw format\n\
+   -R, --recursive            searches for all dat files (only if DATFILEPATH\n\
+                              is not a dat file)\n\
+   -t, --datfile=DATFILE      specifies a dat file to read resources\n\
+                              different that the original file\n\
+       --unknown              generate the unknown file without performing\n\
+                              any extraction\n\
+   -v, --verbose              explain what is being done\n\
+       --version              output version information and exit\n\
+\n"
+
+#define PARSING_ABOUT "Authors: \n\
+   Coding & main routines\n\
+    Enrique Calot\n\
+\n\
+   Graphic compression algorithms\n\
+    Tammo Jan Dijkema\n\
+    Enrique Calot\n\
+\n\
+   Graphic format development\n\
+    Tammo Jan Dijkema\n\
+    Anke Balderer\n\
+\n\
+   MID Sound format development\n\
+    Christian Lundheim\n\
+\n\
+   Resources.xml edition\n\
+    Steven Fayers\n\
+\n"
 
 #define PARSING_OPTIONS {\
-			{"import",optional_argument,0,'c'},\
-			{"classify",no_argument,0,'d'},\
-			{"export",optional_argument,0,'x'},\
+{"import",      optional_argument, 0,'c'},\
+{"classify",    no_argument,       0,'d'},\
+{"export",      optional_argument, 0,'x'},\
 \
-			{"backup",optional_argument,0,'b'},\
-			{"force",no_argument,0,'f'},\
-			{"cgi",no_argument,0,'g'},\
-			{"help",no_argument,0,'?'},\
-			{"resource",required_argument,0,'m'},\
-			{"raw",no_argument,0,'r'},\
-			{"recursive",no_argument,0,'R'},\
-			{"datfile",required_argument,0,'t'},\
-			{"unknown",no_argument,0,2},\
-			{"verbose",no_argument,0,'v'},\
-			{"version",no_argument,0,1},\
-			{0, 0, 0, 0}\
-		}
-
-#define PARSING_CHARS "c::dx::e::b::fgm:t:rRv"
+{"setauthor",   required_argument, 0,'a'},\
+{"backup",      optional_argument, 0,'b'},\
+{"force",       no_argument,       0,'f'},\
+{"cgi",         no_argument,       0,'g'},\
+{"help",        no_argument,       0,'?'},\
+{"resource",    required_argument, 0,'m'},\
+{"raw",         no_argument,       0,'r'},\
+{"recursive",   no_argument,       0,'R'},\
+{"datfile",     required_argument, 0,'t'},\
+{"unknown",     no_argument,       0,2},\
+{"verbose",     no_argument,       0,'v'},\
+{"version",     no_argument,       0,1},\
+{0, 0, 0, 0}\
+}
+
+#define PARSING_CHARS    "c::dx::e::b::a:fgm:t:rRv"
 
 /* Flags */
 #define import_flag      0x0001
diff --git a/PR/src/include/compress.h b/PR/src/include/compress.h
index f64551d..c57241e 100644
--- a/PR/src/include/compress.h
+++ b/PR/src/include/compress.h
@@ -22,7 +22,7 @@ typedef struct {
 //Prototypes:
 
 int mCompressGraphic(unsigned char* a,tImage* i, int* size);
-int mExpandGraphic(char* array,tImage *image, int size);
+int mExpandGraphic(unsigned char* array,tImage *image, int size);
 
 /*
 	Class future definitions
diff --git a/PR/src/include/disk.h b/PR/src/include/disk.h
index ab582b5..8549541 100644
--- a/PR/src/include/disk.h
+++ b/PR/src/include/disk.h
@@ -5,7 +5,9 @@
 #include <stdio.h>
 
 /* 64 Kb */
-#define SIZE_OF_FILE    64*1024
+#define SIZE_OF_FILE    256*1024
+
+typedef enum {eFile,eDirectory,eNotFound}whatIs;
 
 char mDiskVealidateFileHeader(unsigned char* text, int size, FILE* fp);
 char mSaveRaw      (const char* vFile,const unsigned char* output, int size);
@@ -15,6 +17,6 @@ int  mLoadFileArray(const char* vFile,unsigned char** array);
 int  makebase      (const char* p);
 const char *repairFolders(const char* a);
 const char* getFileNameFromPath(const char* path);
-int recurseDirectory(const char* path,int* pOption, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
-int isDir(const char *nombre);
+int recurseDirectory(const char* path,int* pOption, const char* extension,const char* dirName,const char* resFile, const char* datfilename,const char* datAuthor,FILE* output);
+whatIs isDir(const char *nombre);
 #endif
diff --git a/PR/src/include/export.h b/PR/src/include/export.h
index a7fd77e..bba9158 100644
--- a/PR/src/include/export.h
+++ b/PR/src/include/export.h
@@ -17,6 +17,6 @@
 		8 - rebuild resources list
 */
 
-int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task, const char* vDatFileName);
+int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task, const char* vDatFileName, const char* vDatAuthor);
 
 #endif
diff --git a/PR/src/include/filedir.h b/PR/src/include/filedir.h
index c83e51f..f8dcc3b 100644
--- a/PR/src/include/filedir.h
+++ b/PR/src/include/filedir.h
@@ -47,10 +47,24 @@ xml.h: Princed Resources : xml handling functions header file
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-
 tTag* searchTree(tTag* t,const char* datFile, const char* id);
 void workTag(const tTag* t, tResource* r[]);
 void workTree(const tTag* t,const char* datFile, tResource* r[]);
 
+//Searching Structures
+
+//File List Structure
+typedef struct tListNode {
+ char* file;
+ struct tListNode* next;
+}tListNode;
+
+//File List Functions
+void addFileToList(const char* file);
+void getFiles(const tTag* t);
+char* getFileFromList();
+
+
+
 #endif
 
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h
index 228a429..a5478dc 100644
--- a/PR/src/include/idlist.h
+++ b/PR/src/include/idlist.h
@@ -25,8 +25,10 @@ typedef struct {
 	char*     desc;
 }tResource;
 
+#include <stdio.h>
+
 //Verify  header
-char verifyHeader(char* array, int size);
+int verifyHeader(unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -46,17 +48,22 @@ char verifyHeader(char* array, int size);
 //Empty resource table
 void emptyTable(tResource* r[]);
 
-//parse file
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
 
 //Resources extras
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat);
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
+//parse file and free parsed structure
+char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+void freeParsedStructure();
+
 //In case there are unknown resources it closes the unknown XML output
 void endUnknownXml();
 
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+
 #endif
diff --git a/PR/src/include/image.h b/PR/src/include/image.h
index f64551d..c57241e 100644
--- a/PR/src/include/image.h
+++ b/PR/src/include/image.h
@@ -22,7 +22,7 @@ typedef struct {
 //Prototypes:
 
 int mCompressGraphic(unsigned char* a,tImage* i, int* size);
-int mExpandGraphic(char* array,tImage *image, int size);
+int mExpandGraphic(unsigned char* array,tImage *image, int size);
 
 /*
 	Class future definitions
diff --git a/PR/src/include/import.h b/PR/src/include/import.h
index 36eb954..6e5820f 100644
--- a/PR/src/include/import.h
+++ b/PR/src/include/import.h
@@ -8,7 +8,7 @@
 #include <stdio.h>
 #include "resources.h"
 
-void mAddFileToDatFile(FILE* fp, char* data, int size);
+void mAddFileToDatFile(FILE* fp, unsigned char* data, int size);
 int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int opt, const char* vDatFileName);
 
 #endif
diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h
index 20c0883..47c1902 100644
--- a/PR/src/include/memory.h
+++ b/PR/src/include/memory.h
@@ -7,6 +7,7 @@
 //Reserves a memory space to allocate an image
 //TODO change "unsigned char*" for "unsigned char" in sizeof
 #define getMemory(size) ((unsigned char*)malloc(sizeof(unsigned char*)*(size)))
+char* strallocandcopy(const char* text);
 
 #endif
 
diff --git a/PR/src/include/pal.h b/PR/src/include/pal.h
index 68b1316..d18f729 100644
--- a/PR/src/include/pal.h
+++ b/PR/src/include/pal.h
@@ -16,6 +16,6 @@ char mImportPalette(unsigned char** data, unsigned short *size);
 void mExportPalette(unsigned char** data, unsigned long int *size);
 
 //This function will be obsolete
-void mLoadPalette(char* array,tImage *image);
+void mLoadPalette(unsigned char* array,tImage *image);
 
 #endif
diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h
index 49569fb..ce52257 100644
--- a/PR/src/include/plv.h
+++ b/PR/src/include/plv.h
@@ -6,7 +6,7 @@
 #include "resources.h"
 
 char mFormatCompilePlv(unsigned char* data, FILE* fp, tResource *res);
-char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title);
+char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long int size,unsigned char level, const char* filename, const char* desc, const char* title, const char* vDatAuthor);
 
 //Dias de la semana y meses del anio
 #define DATE_WEEKDAYS "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat"
@@ -16,12 +16,13 @@ char mFormatExtractPlv(unsigned char* data, const char *vFileext,unsigned long i
 #define PLV_HEADER_A_SIZE      sizeof(PLV_HEADER_A)-1
 #define PLV_HEADER_B           ":)"
 #define PLV_HEADER_B_SIZE      sizeof(PLV_HEADER_B)-1
-#define PLV_FOOT               "EDITORNAME\0PR\0EDITORVERS\0\x30.9\0AUTHOR\0Pr User\0TITLE"
+#define PLV_FOOT_EDITOR        "EDITORNAME\0PR\0EDITORVERS\0\x30.9\0AUTHOR"
+#define PLV_FOOT_TITLE         "TITLE"
 #define PLV_FOOT_DESC          "DESCRIPTION"
 #define PLV_FOOT_TCREAT        "TIMECREATED"
 #define PLV_FOOT_TMODIF        "TIMELASTMODIF"
 #define PLV_FOOT_ORIG_FILE     "ORIGINALFILENAME"
-#define PLV_HEADER_SIZE_OFFSET 1
+#define PLV_HEADER_SIZE_OFFSET PLV_HEADER_A_SIZE+PLV_HEADER_B_SIZE
 
 
 #endif
diff --git a/PR/src/include/png.h b/PR/src/include/png.h
index d727520..a870771 100644
--- a/PR/src/include/png.h
+++ b/PR/src/include/png.h
@@ -5,10 +5,9 @@
 #include "resources.h"
 #include "compress.h"
 
-
 char mFormatExtractBmp(unsigned char* data, const char *vFileext,unsigned long int size,tImage image);
 char mFormatCompileBmp(unsigned char* data, FILE* fp, tResource *res);
 char mWriteBitMap(tImage img,const char* vFile);
-char mReadBitMap(tImage* img,char* data, int size); //Note: this will ignore the palette
+char mReadBitMap(tImage* img,unsigned char* data, int size); //Note: this will ignore the palette
 
 #endif
diff --git a/PR/src/include/pr.h b/PR/src/include/pr.h
index 530bc38..f251681 100644
--- a/PR/src/include/pr.h
+++ b/PR/src/include/pr.h
@@ -1,7 +1,47 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    The authors of this program may be contacted at http://forum.princed.com.ar
+*/
+
+/*
+pr.h: Princed Resources : Main header prototypes and definitions
+\xaf\xaf\xaf\xaf
+ Copyright 2003 Princed Development Team
+  Created: 24 Aug 2003
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.00 (2003-Aug-24)
+
+  Modified by: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.10 (2003-Dec-03)
+  
+  Language: English
+
+ Note:
+  DO NOT remove this copyright notice
+*/
+
 #ifndef _PR_H_
 #define _PR_H_
 
-//princed resource library
+/***************************************************************\
+|                Princed Resource Library Functions             |
+\***************************************************************/
 
 #include <stdio.h>
 
@@ -10,7 +50,7 @@
  #define UNIX
 #endif
 
-/* #define DLL --> use -DDLL as a precompiler option */
+/* do not #define DLL, use -DDLL as a precompiler option instead */
 #ifdef DLL
  #ifdef UNIX
   #define SO
@@ -29,23 +69,83 @@
 #define DEB_FLAG
 
 #ifdef DEB_FLAG
- #define fld(a) printf(a);
+ #define fld(a) printf(a "\n");
 #else
  #define fld(a)
 #endif
 
-//Main program defines
-#define PR_ABOUT             "Princed resources (PR) V0.9 "OS"\r\n(c) Copyright 2003 - Princed Development Team\r\n"\
-                             "http://www.princed.com.ar\r\n\r\n"
+/***************************************************************\
+|             M A I N   P R O G R A M   D E F I N E S           |
+\***************************************************************/
+
+
+/***************************************************************\
+|                           Text Defines                        |
+\***************************************************************/
+
+
+#define PR_ABOUT                  "Princed resources (PR) V0.9 "OS"\n(c) Copyright 2003 - Princed Development Team\n\
+http://www.princed.com.ar\n\n"
 
-#define PR_CGI_TEXT1         "Content-Type:text/html\n\nRunning as a cgi\n"
-#define PR_CGI_TEXT2         "Result: %02d type\r\n"
+#define PR_CGI_TEXT1              "Content-Type:text/html\n\nRunning as a cgi\n"
+#define PR_CGI_TEXT2              "Result: %02d type\n"
 
-#define PR_TEXT_SKIPING      "Found invalid option '%c', skiping . . .\r\n"
-#define PR_TEXT_RESULT       "Result: %s (%d)\r\n"
-#define PR_TEXT_RESULT_ERR   "Result: %d files with errors\r\n"
+#define PR_TEXT_SKIPING           "Found invalid option '%c', skiping . . .\n"
+#define PR_TEXT_RESULT            "Result: %s (%d)\n"
+#define PR_TEXT_RESULT_ERR        "Result: %d files with errors\n"
+
+#define PR_TEXT_FILE_NOT_FOUND    "Result: File or directory '%s' not found\n"
+
+#define PR_TEXT_SCANNING_CURRENT  "Scanning dat files in current directory\n"
+#define PR_TEXT_SCANNING_GIVEN    "Scanning dat files in given directory\n"
+
+#define PR_TEXT_IMPORTING_CURRENT "Importing all valid dat files from the currect directory\n"
+#define PR_TEXT_IMPORTING_GIVEN   "Importing all valid files from given directory\n"
+
+#define PR_TEXT_TASK_COMPILE      "Compiling '%s' from '%s' with %04x\n"
+#define PR_TEXT_TASK_CLASSIFY     "Classifing '%s'\n"
+#define PR_TEXT_TASK_EXTRACT      "Extracting '%s' to '%s' with %04x\n"
+
+/***************************************************************\
+|                        Text Output Arrays                     |
+\***************************************************************/
+
+#define PR_TEXT_EXPORT_ARRAY {\
+"Ok",\
+"Error accessing the file DAT", /* DAT or extracted */\
+"Memory error in extraction",\
+"Invalid DAT file",\
+"XML Parse error",\
+"Memory error in parsing",\
+"XML Attribute not recognized",\
+"XML File not found"}
+
+#define PR_TEXT_CLASSIFY_ARRAY {\
+"Memory error",\
+"File not found or no access error",\
+"Not a valid POP1 DAT file",\
+"Levels file",\
+"Graphic file with an image in the first valid entry (not common)",\
+"Waves/Digital sound file",\
+"Midis file",\
+"Valid DAT file with Undefined content",\
+"Graphic file with a palette in the first valid entry (common)",\
+"PC Speaker dat file",\
+"","","",\
+"Pop2 dat files"}
+
+#define PR_TEXT_IMPORT_ARRAY {\
+"File succesfully compiled",\
+"DAT File couldn't be open for writing",\
+"XML Parse error",\
+"No memory",\
+"XML Attribute not recognized",\
+"XML File not found"}
+
+/***************************************************************\
+|                         Other defines                         |
+\***************************************************************/
 
-#define PR_TEXT_SYNTAX       "Usage: pr [datFilePath] [-x [extractDir]|-c [compileDir]|-d] [-n filename]\r\n\r\nValid options:\r\n -x[rn] for extract\r\n  r: raw extraction\r\n  n: don't extract\r\n -c[r] for compile\r\n  r: raw compiling\r\n -d for type\r\n"
 
 //Default Files
 #define RES_XML_UNKNOWN_XML  "unknown.xml"
@@ -67,6 +167,10 @@
  #define DIR_SEPARATOR       '\\'
 #endif
 
+/***************************************************************\
+|                            Prototypes                         |
+\***************************************************************/
+
 //Main functions
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
 int prImportDat(const char* vDatFile, const char* vDirName, const char* vResFile);
@@ -76,59 +180,81 @@ int prVerifyDatType(const char* vFiledat);
 int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char * vDatFileName,const char* datAuthor, const char* backupExtension);
 int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResFile,int opt,const char* vDatFileName, const char* backupExtension);
 
+//Recursive function
 int prMain(int* option, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output);
 
-//Command Line specific options
-
-#define PARSING_HELP "Usage: \n"\
-"  pr [-x [EXTRACTDIR]|-c [COMPILEDIR]|-d] [DATFILEPATH]\n"\
-"  pr [OPTIONS] [DATFILEPATH]\n"\
-"\n"\
-"  Mandatory arguments to long options are mandatory for short options too.\n"\
-"\n"\
-"   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n"\
-"   -d, --classify             returns the DAT file type\n"\
-"   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n"\
-"\n"\
-"   -b, --backup[=EXTENSION]   backup your files\n"\
-"   -f, --force                default option, you cannot disable it,\n"\
-"                              so please make a backup of your files\n"\
-"   -g, --cgi                  run as CGI and output mime headers\n"\
-"   -h, --help                 display this help and exit\n"\
-"   -m, --resource=RESFILE     uses an user-specific resource xml file\n"\
-"   -r, --raw                  uses raw format\n"\
-"   -R, --recursive            searches for all dat files (only if DATFILEPATH\n"\
-"                              is not a dat file)\n"\
-"   -t, --datfile=DATFILE      specifies a dat file to read resources\n"\
-"                              different that the original file\n"\
-"       --unknown              generate the unknown file without performing\n"\
-"                              any extraction\n"\
-"   -v, --verbose              explain what is being done\n"\
-"       --version              output version information and exit\n"\
-"\n"
-
-//Add -a, --author for PLV format
+/***************************************************************\
+|                   Command Line specific options               |
+\***************************************************************/
+
+#define PARSING_HELP "Usage: \n\
+  pr [-x[EXTRACTDIR]|-c[COMPILEDIR]|-d] [DATFILEPATH]\n\
+  pr [OPTIONS] [DATFILEPATH]\n\
+\n\
+  Mandatory arguments to long options are mandatory for short options too.\n\
+\n\
+   -c, --import[=DIRNAME]     imports from DIRNAME into given dat file\n\
+   -d, --classify             returns the DAT file type\n\
+   -x, -e, --export[=DIRNAME] extracts given dat file into DIRNAME\n\
+\n\
+   -a, --setauthor=NAME       sets your name in extracted PLV files\n\
+   -b, --backup[=EXTENSION]   backup your files\n\
+   -f, --force                default option, you cannot disable it,\n\
+                              so please make a backup of your files\n\
+   -g, --cgi                  run as CGI and output mime headers\n\
+   -h, -?, --help             display this help and exit\n\
+   -m, --resource=RESFILE     uses an user-specific resource xml file\n\
+   -r, --raw                  uses raw format\n\
+   -R, --recursive            searches for all dat files (only if DATFILEPATH\n\
+                              is not a dat file)\n\
+   -t, --datfile=DATFILE      specifies a dat file to read resources\n\
+                              different that the original file\n\
+       --unknown              generate the unknown file without performing\n\
+                              any extraction\n\
+   -v, --verbose              explain what is being done\n\
+       --version              output version information and exit\n\
+\n"
+
+#define PARSING_ABOUT "Authors: \n\
+   Coding & main routines\n\
+    Enrique Calot\n\
+\n\
+   Graphic compression algorithms\n\
+    Tammo Jan Dijkema\n\
+    Enrique Calot\n\
+\n\
+   Graphic format development\n\
+    Tammo Jan Dijkema\n\
+    Anke Balderer\n\
+\n\
+   MID Sound format development\n\
+    Christian Lundheim\n\
+\n\
+   Resources.xml edition\n\
+    Steven Fayers\n\
+\n"
 
 #define PARSING_OPTIONS {\
-			{"import",optional_argument,0,'c'},\
-			{"classify",no_argument,0,'d'},\
-			{"export",optional_argument,0,'x'},\
+{"import",      optional_argument, 0,'c'},\
+{"classify",    no_argument,       0,'d'},\
+{"export",      optional_argument, 0,'x'},\
 \
-			{"backup",optional_argument,0,'b'},\
-			{"force",no_argument,0,'f'},\
-			{"cgi",no_argument,0,'g'},\
-			{"help",no_argument,0,'?'},\
-			{"resource",required_argument,0,'m'},\
-			{"raw",no_argument,0,'r'},\
-			{"recursive",no_argument,0,'R'},\
-			{"datfile",required_argument,0,'t'},\
-			{"unknown",no_argument,0,2},\
-			{"verbose",no_argument,0,'v'},\
-			{"version",no_argument,0,1},\
-			{0, 0, 0, 0}\
-		}
-
-#define PARSING_CHARS "c::dx::e::b::fgm:t:rRv"
+{"setauthor",   required_argument, 0,'a'},\
+{"backup",      optional_argument, 0,'b'},\
+{"force",       no_argument,       0,'f'},\
+{"cgi",         no_argument,       0,'g'},\
+{"help",        no_argument,       0,'?'},\
+{"resource",    required_argument, 0,'m'},\
+{"raw",         no_argument,       0,'r'},\
+{"recursive",   no_argument,       0,'R'},\
+{"datfile",     required_argument, 0,'t'},\
+{"unknown",     no_argument,       0,2},\
+{"verbose",     no_argument,       0,'v'},\
+{"version",     no_argument,       0,1},\
+{0, 0, 0, 0}\
+}
+
+#define PARSING_CHARS    "c::dx::e::b::a:fgm:t:rRv"
 
 /* Flags */
 #define import_flag      0x0001
diff --git a/PR/src/include/search.h b/PR/src/include/search.h
index c83e51f..f8dcc3b 100644
--- a/PR/src/include/search.h
+++ b/PR/src/include/search.h
@@ -47,10 +47,24 @@ xml.h: Princed Resources : xml handling functions header file
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-
 tTag* searchTree(tTag* t,const char* datFile, const char* id);
 void workTag(const tTag* t, tResource* r[]);
 void workTree(const tTag* t,const char* datFile, tResource* r[]);
 
+//Searching Structures
+
+//File List Structure
+typedef struct tListNode {
+ char* file;
+ struct tListNode* next;
+}tListNode;
+
+//File List Functions
+void addFileToList(const char* file);
+void getFiles(const tTag* t);
+char* getFileFromList();
+
+
+
 #endif
 
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index 228a429..a5478dc 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -25,8 +25,10 @@ typedef struct {
 	char*     desc;
 }tResource;
 
+#include <stdio.h>
+
 //Verify  header
-char verifyHeader(char* array, int size);
+int verifyHeader(unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -46,17 +48,22 @@ char verifyHeader(char* array, int size);
 //Empty resource table
 void emptyTable(tResource* r[]);
 
-//parse file
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
 
 //Resources extras
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat);
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
+//parse file and free parsed structure
+char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+void freeParsedStructure();
+
 //In case there are unknown resources it closes the unknown XML output
 void endUnknownXml();
 
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+
 #endif
diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h
index 228a429..a5478dc 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -25,8 +25,10 @@ typedef struct {
 	char*     desc;
 }tResource;
 
+#include <stdio.h>
+
 //Verify  header
-char verifyHeader(char* array, int size);
+int verifyHeader(unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -46,17 +48,22 @@ char verifyHeader(char* array, int size);
 //Empty resource table
 void emptyTable(tResource* r[]);
 
-//parse file
-char parseFile(const char* vFile, const char* datFile, tResource* r[]);
 
 //Resources extras
 
-void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat);
+void getFileName(char* vFileext,const char* vDirExt,tResource* r,short id,const char* vFiledat, const char* vDatFileName);
 void getUpperFolder(char* aux, char* vFiledat);
 
 const char* getExtDesc(int type);
 
+//parse file and free parsed structure
+char parseFile(const char* vFile, const char* datFile, tResource* r[]);
+void freeParsedStructure();
+
 //In case there are unknown resources it closes the unknown XML output
 void endUnknownXml();
 
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDirectory,FILE* output);
+
 #endif
diff --git a/PR/src/include/wav.h b/PR/src/include/wav.h
index 670aca9..f634997 100644
--- a/PR/src/include/wav.h
+++ b/PR/src/include/wav.h
@@ -7,7 +7,7 @@
 
 #define WAVE_HEADER {0x52, 0x49, 0x46, 0x46, 0x12, 0x16, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 0xA3, 0x15, 0x00, 0x00}
 
-char mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size);
-char mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res);
+int mFormatExtractWav(unsigned char* data, char *vFileext,unsigned long int size);
+int mFormatCompileWav(unsigned char* data, FILE* fp, tResource *res);
 
 #endif
diff --git a/PR/src/ports/dirent.c b/PR/src/ports/dirent.c
index 08ea800..f7c51bb 100644
--- a/PR/src/ports/dirent.c
+++ b/PR/src/ports/dirent.c
@@ -8,7 +8,7 @@
 
 */
 
-#include <dirent.h>
+#include "direntwin.h"
 #include <errno.h>
 #include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
 #include <stdlib.h>