git » fp-git.git » commit bc6f4dd

o Solved several bugs

author ecalot
2003-12-14 18:11:54 UTC
committer ecalot
2003-12-14 18:11:54 UTC
parent 8be273e75affa5f98959d41770243f8ed45a48b9

o Solved several bugs

PR/src/Makefile +7 -3
PR/src/console/main.c +119 -92
PR/src/lib/actions/export.c +12 -17
PR/src/lib/actions/import.c +7 -6
PR/src/lib/compression/rle_compress.c +12 -12
PR/src/lib/compression/rle_decompress.c +12 -12
PR/src/lib/compression/rlev_decompress.c +12 -12
PR/src/lib/layers/autodetect.c +84 -18
PR/src/lib/layers/disk.c +10 -9
PR/src/lib/layers/idlist.c +84 -18
PR/src/lib/object/image/image16.c +12 -12
PR/src/lib/object/image/image2.c +12 -12
PR/src/lib/object/image/image256.c +12 -12
PR/src/lib/object/image/image_common.c +12 -12
PR/src/lib/pr.c +119 -92
PR/src/lib/xml/search.c +70 -1
PR/src/lib/xml/tree.c +84 -18
PR/src/lib/xml/unknown.c +84 -18
PR/src/pr.dsp +19 -5

diff --git a/PR/src/Makefile b/PR/src/Makefile
index 94f8d11..ed60033 100644
--- a/PR/src/Makefile
+++ b/PR/src/Makefile
@@ -1,10 +1,10 @@
-bin/pr: compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o prlib.o
+bin/pr: compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o prlib.o memory.o
 	
 	@echo Linking files...
 	@mkdir -p bin
-	@gcc -o bin/pr compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o -s -O2
+	@gcc -o bin/pr compile.o compress.o extract.o pr.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o memory.o -s -O2
 	@echo Making dynamic library...
-	@gcc -o bin/pr.so compile.o compress.o extract.o prlib.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o -O2 -Llibc -shared -dynamic
+	@gcc -o bin/pr.so compile.o compress.o extract.o prlib.o resources.o tasks.o disk.o xml.o xmlsearch.o bmp.o mid.o pal.o wav.o plv.o memory.o -O2 -Llibc -shared -dynamic
 	@echo Program successfully compiled
 	@echo
 	@echo Please read readme.txt for syntax information
@@ -14,6 +14,10 @@ compile.o: compile.c
 	@echo Compiling import module...
 	@gcc -c compile.c -Iinclude/
 
+memory.o: memory.c
+	@echo Compiling memory manager...
+	@gcc -c memory.c -Iinclude/
+
 extract.o: extract.c
 	@echo Compiling export module...
 	@gcc -c extract.c -Iinclude/
diff --git a/PR/src/console/main.c b/PR/src/console/main.c
index 6130aa7..2e44111 100644
--- a/PR/src/console/main.c
+++ b/PR/src/console/main.c
@@ -69,7 +69,9 @@ pr.c: Main source file for Princed Resources
  #endif
 #endif
 
-//functions
+/***************************************************************\
+|                      Main working functions                   |
+\***************************************************************/
 
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile) {
 	return prExportDatOpt(vDatFile,vDirName,vResFile,0,NULL,NULL,"");
@@ -88,7 +90,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 			                        No NULL
 			char opt              - program options, see below
 			char * vDatFileName   - name of the file to be extracted
-			                        NULL means predict it from vDatFile
+			                        NULL means predict it from vDatFile (DISABLED!!!)
 			const char* datAuthor - Author's name when extracting PLV's,
 			                        NULL is default
 			const char* backupExtension
@@ -100,7 +102,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
                        any extraction
 			raw_flag       - uses raw format
 			verbose_flag   - explain what is being done
-x			recursive_flag - searches for all dat files (only if vDatFile
+			recursive_flag - searches for all dat files (only if vDatFile
 			                 is not a dat file and vDatFileName is NULL)
 x			force_flag     - default option, you cannot disable it,
 			                 so please make a backup of your files
@@ -122,15 +124,13 @@ x			backup_flag    - backup your files
 	tResource* r[MAX_RES_COUNT];
 	int a;
 	const char defaultXmlFile[]=RES_XML_RESOURC_XML;
-
 	//Set default values
-	if (vResFile==NULL) vResFile=defaultXmlFile;
-	if (vDatFileName==NULL) vDatFileName=getFileNameFromPath(vDatFile);
+	if (vResFile==NULL) vResFile=defaultXmlFile; //TODO: Send to prMain or main
 
-	//Parse XML and extract the file
-	a=parseFile     (vResFile,vDatFileName,r);
+	//Parse XML and extract the file //TODO: XML parser outside the function
+	a=parseFile(vResFile,vDatFileName,r);
 	if (a<0) return a-3; //parsing errors
-	a=extract(vDatFile, vDirName,r,opt,vDatFileName);
+	a=extract(vDatFile,vDirName,r,opt,vDatFileName,datAuthor);
 	return a; //extracting errors/no errors
 }
 
@@ -159,7 +159,7 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 		Options:
 			raw_flag       - uses raw format
 			verbose_flag   - explain what is being done
-x			recursive_flag - searches for all dat files (only if vDatFile
+			recursive_flag - searches for all dat files (only if vDatFile
 			                 is not a dat file and vDatFileName is NULL)
 x			force_flag     - default option, you cannot disable it,
 			                 so please make a backup of your files
@@ -183,9 +183,8 @@ x			backup_flag    - backup your files
 
 	//Set default values
 	if (vResFile==NULL) vResFile=defaultXmlFile;
-	if (vDatFileName==NULL) vDatFileName=getFileNameFromPath(vDatFile);
 
-	//Parser XML and compile files
+	//Parse XML and compile files
 	a=parseFile     (vResFile,vDatFileName,r);
 	if (a<0) return a-1;
 	a=compile (vDatFile, vDirName,r,opt,vDatFileName);
@@ -193,9 +192,9 @@ x			backup_flag    - backup your files
 }
 
 
-/*******************************************************
-                    M A I N   P R O G R A M
-       *******************************************************/
+/***************************************************************\
+|                     M A I N   P R O G R A M                   |
+\***************************************************************/
 
 void syntax(FILE* output) {
 	fprintf(output,PARSING_HELP);
@@ -205,6 +204,54 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 
 	//declare variables
 	int returnValue=1;
+	char* currentDatFileName;
+	const char* aux;
+
+	if (datfilename==NULL) {
+		aux=getFileNameFromPath(datfile);
+	} else {
+		aux=datfilename;
+	}
+
+	currentDatFileName=strallocandcopy(aux);
+
+	//do selected tasks
+	if (optionflag&export_flag) {
+		char* array[]=PR_TEXT_EXPORT_ARRAY;
+		fprintf(output,"Extracting '%s' to '%s' with %04x\r\n",datfile,dirName,optionflag);
+		returnValue=prExportDatOpt(datfile,dirName,resFile,optionflag,currentDatFileName,datAuthor,extension);
+		fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+	}	else if (optionflag&classify_flag) {
+		char* array[]=PR_TEXT_CLASSIFY_ARRAY;
+		fprintf(output,"Classifing '%s'\r\n",datfile);
+		returnValue=prVerifyDatType(datfile);
+		fprintf(output,PR_TEXT_RESULT,array[2+returnValue],returnValue);
+	}	else if (optionflag&import_flag) {
+		char* array[]=PR_TEXT_IMPORT_ARRAY;
+		fprintf(output,"Compiling '%s' from '%s' with %04x\r\n",datfile,dirName,optionflag);
+		returnValue=prImportDatOpt(datfile,dirName,resFile,optionflag,currentDatFileName,extension);
+		if (returnValue<=0) {
+			fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+		} else {
+			fprintf(output,PR_TEXT_RESULT_ERR,returnValue);
+		}
+	} else {
+		syntax(output);
+		returnValue=-1;
+	}
+	if (currentDatFileName) free(currentDatFileName);
+	return returnValue;
+}
+
+//Main program
+#ifndef DLL
+
+/***************************************************************\
+|             Standard executable specific functions            |
+\***************************************************************/
+
+int prStart(int* pOption, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output) {
+	int result=1;
 
 	//Do CGI tasks
 	if (optionflag&cgi_flag) {
@@ -227,18 +274,6 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 		optionflag|=first_flag;
 	}
 
-	//Recursive testing
-	if (datfile==NULL) {
-		fprintf(output,"Scanning dat files in current directory\n");
-		recurseDirectory(".",pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
-		return 1;
-	} else if (isDir(datfile)) {
-		fprintf(output,"Scanning dat files un given directory\n");
-		recurseDirectory(datfile,pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
-		return 1;
-	}
-
-
 	//If bad syntax or help screen requested
 	if (optionflag&help_flag) {
 		syntax(output);
@@ -250,95 +285,79 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 		return -1;
 	}
 
-	//do selected tasks
-	if (optionflag&export_flag) {
-		char* 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"};
-		fprintf(output,"Extracting '%s' to '%s' with %04x\r\n",datfile,dirName,optionflag);
-		returnValue=prExportDatOpt(datfile,dirName,resFile,optionflag,NULL,datAuthor,extension);
-		fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
-	}	else if (optionflag&classify_flag) {
-		char* 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",
-			"\0","\0","\0",
-			"Pop2 dat files"};
-		fprintf(output,"Classifing '%s'\r\n",datfile);
-		returnValue=prVerifyDatType(datfile);
-		fprintf(output,PR_TEXT_RESULT,array[2+returnValue],returnValue);
-	}	else if (optionflag&import_flag) {
-		char* 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"};
-		fprintf(output,"Compiling '%s' from '%s' with %04x\r\n",datfile,dirName,optionflag);
-		returnValue=prImportDatOpt(datfile,dirName,resFile,optionflag,NULL,extension);
-		if (returnValue<=0) {
-			fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+	//Perform tasks depending on the argument
+	if (optionflag&import_flag) {
+		//Check out the xml file to get the files to me compiled
+		if (datfile==NULL) {
+			fprintf(output,"Importing all valid dat files from the currect directory\n");
+			importDir(dirName,resFile,pOption,extension,".",output);
+		} else if (isDir(datfile)!=eFile) {
+			fprintf(output,"Importing all valid files from given directory\n");
+			importDir(dirName,resFile,pOption,extension,datfile,output);
 		} else {
-			fprintf(output,PR_TEXT_RESULT_ERR,returnValue);
+			result=prMain(pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
 		}
 	} else {
-		syntax(output);
-		return -1;
+
+		//Recursive testing for export/classify
+		if (datfile==NULL) {
+			fprintf(output,PR_TEXT_SCANNING_CURRENT);
+			recurseDirectory(".",pOption,extension,dirName,resFile,datfilename,datAuthor,output);
+		} else if (isDir(datfile)==eDirectory) {
+			fprintf(output,PR_TEXT_SCANNING_GIVEN);
+			recurseDirectory(datfile,pOption,extension,dirName,resFile,datfilename,datAuthor,output);
+		} else if (isDir(datfile)==eNotFound) {
+			fprintf(output,PR_TEXT_FILE_NOT_FOUND,datfile);
+			return 0;
+		} else {
+
+			result=prMain(pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
+		}
 	}
-	return returnValue;
+
+	freeParsedStructure();
+	return result;
 }
 
-//Main program
-#ifndef DLL
+/***************************************************************\
+|      Standard executable command line parsing function        |
+\***************************************************************/
 
 int main (int argc, char **argv) {
 	//declare variables
-	char  datFileName[MAX_FILENAME_SIZE]; //TODO add
+	char* datFileName=NULL;
 	char  dirName[MAX_FILENAME_SIZE]=".";
 	char  extension[MAX_EXTENSION_SIZE]=DEFAULT_BACKUP_EXTENSION;
 	char  resFile[MAX_FILENAME_SIZE]=RES_XML_RESOURC_XML;
-	char* datFilePath;
+	char* datFilePath=NULL;
 	char* datAuthor=NULL;
 	int   c;
 	int   flag=0;
 
 	//Parse options
 	while (1) {
-
 		static struct option long_options[] = PARSING_OPTIONS;
 
 		/* getopt_long stores the option index here. */
-		int option_index = 0;
-		c = getopt_long (argc, argv, PARSING_CHARS,long_options,&option_index);
+		int junk = 0;
+		c = getopt_long (argc, argv, PARSING_CHARS,long_options,&junk);
 
 		/* Detect the end of the options. */
 		if (c == -1) break;
 
 		switch (c) {
 				case 'c':
+					if (flag&(classify_flag|export_flag)) flag|=help_flag;
 					flag|=import_flag;
 					if (optarg) strncpy(dirName,optarg,MAX_FILENAME_SIZE);
 					break;
 				case 'd':
-					flag|=force_flag;
+					if (flag&(import_flag|export_flag)) flag|=help_flag;
+					flag|=classify_flag;
 					break;
 				case 'x':
 				case 'e':
+					if (flag&(classify_flag|import_flag)) flag|=help_flag;
 					flag|=export_flag;
 					if (optarg) strncpy(dirName,optarg,MAX_FILENAME_SIZE);
 					break;
@@ -361,12 +380,14 @@ int main (int argc, char **argv) {
 				case 'R':
 					flag|=recursive_flag;
 					break;
-				case 't': {
-					int size;
-					size=strlen(optarg)+1;
-					datAuthor=getMemory(size);
-					memcpy(datAuthor,optarg,size);
-				}	break;
+				case 't':
+					if (datFileName!=NULL) free(datFileName);
+					datFileName=strallocandcopy(optarg);
+					break;
+				case 'a':
+					if (datAuthor!=NULL) free(datAuthor);
+					datAuthor=strallocandcopy(optarg);
+					break;
 				case 'v':
 					flag|=verbose_flag;
 					break;
@@ -383,23 +404,29 @@ int main (int argc, char **argv) {
 
 	if (optind < argc) {
 		datFilePath=argv[optind];
-	} else {
-		datFilePath=NULL;
 	}
 
 	if (!flag) flag=help_flag;
 
 	//Run main program
-	prMain(&flag,extension,dirName,resFile,datFilePath,datFileName,datAuthor,stdout);
-
+fld("a");
+	prStart(&flag,extension,dirName,resFile,datFilePath,datFileName,datAuthor,stdout);
+fld("b");
 	//Free memory and exit
 	if (datAuthor!=NULL) free(datAuthor);
+	if (datFileName!=NULL) free(datFileName);
   return 0;
 }
 
 #endif
 
+/***************************************************************\
+|              Main Library start dummy function                |
+\***************************************************************/
+
 #ifdef SO
 //When compiling in Unix SO libraries
 void start() {}
 #endif
+
+
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index de67bed..a639f82 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -58,21 +58,16 @@ extract.c: Princed Resources : DAT Extractor
 \***************************************************************/
 
 /*
-	Tasks:
-		0 - none
-		1 - extract
-		2 - update resources (rebuild resources list)
-		3 - 1&2
-		4 - use raw file if extraction
-		5 - 1&4
+	Extracts a dat file
+	For parameter documentation, see pr.c
 */
 
-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) {
 
 	//Variables
 	char          vFileext[260];
 	FILE*         fp;
-  char          ok,pop1;
+	int           ok,pop1;
 
 	if (ok=((fp=fopen(vFiledat,"rb"))!=NULL)) {
 		//loop variables
@@ -111,10 +106,8 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task,
 			fclose(fp);
 			return -2; //no memory
 		}
-		ok=fread(index,indexSize-2,1,fp);
 
-		//parse folder and take dat filename in caps
-		//getUpperFolder(aux,vFiledat);
+		ok=fread(index,indexSize-2,1,fp);
 
 		//Initializes the palette list
 		for (id=0;id<MAX_RES_COUNT;id++) {
@@ -125,7 +118,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task,
 
 		//main loop
 		for (k=0;ok&&(k<numberOfItems);k++) {
-			//for each archived file
+			//for each archived file the index is read
 			id=index[ofk+k*recordSize]+256*index[ofk+k*recordSize+1];
 			offset=index[ofk+k*recordSize+2]+256*index[ofk+k*recordSize+3]+256*256*index[ofk+k*recordSize+4]+256*256*256*index[ofk+k*recordSize+5];
 			size=index[ofk+k*recordSize+6]+256*index[ofk+k*recordSize+7]+1;
@@ -136,6 +129,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task,
 			ok=ok&&(!fseek(fp,offset,SEEK_SET));
 			ok=ok&&fread(data,size,1,fp);
 			if (!ok) return -3;
+			//End of index reading
 
 			//set resource information on this index entry
 			if (r[id]==NULL) {
@@ -156,16 +150,16 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task,
 
 			if (!(task&unknown_flag)) { //If unknown flag is set do nothing but generate the unknown.xml file
 				//select type
-				if (task&raw_flag) (*(r[id])).type=0; //If "extract as raw" is set type is 0
-
+				if (task&raw_flag) (*(r[id])).type=0; //If "extract as raw" is set, type is 0
 
 				//save file
-				getFileName(vFileext,vDirExt,r[id],id,vFiledat);
+				getFileName(vFileext,vDirExt,r[id],id,vFiledat,vDatFileName);
+
 				if (task&verbose_flag) printf("Extracting '%s'...\n",getFileNameFromPath(vFileext));
 
 				switch (r[id]->type) {
 					case 1:
-						ok=ok&&mFormatExtractPlv(data,vFileext,size,r[id]->number,vDatFileName,r[id]->title,r[id]->desc);
+						ok=ok&&mFormatExtractPlv(data,vFileext,size,r[id]->number,vDatFileName,r[id]->title,r[id]->desc,vDatAuthor);
 						break;
 					case 5:
 					case 0: //Raw files
@@ -191,6 +185,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int task,
 						break;
 					case 2: //save image
 						//Palette handling
+
 						if (r[id]->palette!=paletteId) { //The palette isn't the already loaded
 							if (r[id]->palette) { //We need a palette
 								/*
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index fd4fff6..cbca841 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -47,7 +47,7 @@ compile.c: Princed Resources : DAT Compiler
 #include "pr.h"
 
 /***************************************************************\
-|                  Dat compiling primitives                     |
+|                     Dat compiling primitives                  |
 \***************************************************************/
 
 char mBeginDatFile(FILE* *fp,const char* vFile) {
@@ -64,7 +64,7 @@ char mBeginDatFile(FILE* *fp,const char* vFile) {
 	}
 }
 
-void mAddFileToDatFile(FILE* fp, char* data, int size) {
+void mAddFileToDatFile(FILE* fp, unsigned char* data, int size) {
 	/*
 		Adds a data resource to a dat file keeping
 		abstratly the checksum verifications
@@ -118,7 +118,7 @@ void mSetEndFile(FILE* fp, tResource* r[]) {
 }
 
 //Format detection function (private function, not in header file)
-char mAddCompiledFileToDatFile(FILE* fp,unsigned char** data, tResource *res) {
+int mAddCompiledFileToDatFile(FILE* fp,unsigned char** data, tResource *res) {
 	//return 1 if ok, 0 if error
 	switch (res->type) {
 		case 1: //compile levels
@@ -170,9 +170,9 @@ int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int opt,
 	for (;i!=MAX_RES_COUNT;i++) {
 		if (r[i]!=NULL) {
 			if (opt&raw_flag) r[i]->type=0; //compile from raw
-			getFileName(vFileext,vDirExt,r[i],i,vDatFileName);
+			getFileName(vFileext,vDirExt,r[i],i,vFiledat,vDatFileName);
 			//the file is in the archive, so I'll add it to the main dat body
-			if (r[i]->size=mLoadFileArray(vFileext,&data)) {
+			if (r[i]->size=(unsigned short)mLoadFileArray(vFileext,&data)) {
 				r[i]->offset=(unsigned short)ftell(fp);
 				if (!mAddCompiledFileToDatFile(fp,&data,r[i])) {
 					if (opt&verbose_flag) printf("'%s' has errors, skipped\n",getFileNameFromPath(vFileext));
@@ -182,12 +182,13 @@ int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int opt,
 				}
 				free(data);
 			} else {
-				if (opt&verbose_flag) printf("'%s' not open, skipped\n",getFileNameFromPath(vFileext));
+				if (opt&verbose_flag) printf("'%s' not open, skipped\n",/*getFileNameFromPath(*/vFileext/*)*/);
 				ok++;
 			}
 		}
 	}
 	mSetEndFile(fp,r);
+	//TODO: if file size if 8, then erase it
 	if (opt&verbose_flag) printf("Compilation done\n");
 	return ok;
 }
diff --git a/PR/src/lib/compression/rle_compress.c b/PR/src/lib/compression/rle_compress.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/compression/rle_compress.c
+++ b/PR/src/lib/compression/rle_compress.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/compression/rle_decompress.c b/PR/src/lib/compression/rle_decompress.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/compression/rle_decompress.c
+++ b/PR/src/lib/compression/rle_decompress.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/compression/rlev_decompress.c b/PR/src/lib/compression/rlev_decompress.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/compression/rlev_decompress.c
+++ b/PR/src/lib/compression/rlev_decompress.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index b980868..c1bcd91 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -50,21 +50,21 @@ resources.c: Princed Resources : Resource Handler
 |                       File format handling                    |
 \***************************************************************/
 
-char verifyLevelHeader(char* array, int size) {
+int verifyLevelHeader(unsigned char* array, int size) {
 	return (((size==2306)||(size==2305))&&!(array[1698]&0x0F)&&!(array[1700]&0x0F)&&!(array[1702]&0x0F));
 }
 
-char verifyImageHeader(char* array, int size) {
+int verifyImageHeader(unsigned char* array, int size) {
 	//return (size>6) && (!(((!array[1])||(array[2])||(!array[3])||(array[4])||(array[5])||(((unsigned char)array[6]&0xF0)!=0xB0))));
 	return (size>7) && (!array[5]) && (((unsigned char)array[6]&0xF0)==0xB0);
 	//TODO: fix the expression
 }
 
-char verifyPaletteHeader(char* array, int size) {
+int verifyPaletteHeader(unsigned char* array, int size) {
 	return ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10));
 }
 
-char verifyMidiHeader(char* array, int size) {
+int verifyMidiHeader(unsigned char* array, int size) {
 	return
 	  (size>6) &&
 		(array[1]==0x02) &&
@@ -75,19 +75,19 @@ char verifyMidiHeader(char* array, int size) {
 	;
 }
 
-char verifyWaveHeader(char* array, int size) {
+int verifyWaveHeader(unsigned char* array, int size) {
 	return
 		(size>1)&&(array[1]==0x01)
 	;
 }
 
-char verifySpeakerHeader(char* array, int size) {
+int verifySpeakerHeader(unsigned char* array, int size) {
 	return
 		(size>2)&&(array[1]==0x00) /* &&!(size%3) */
 	;
 }
 
-char verifyHeader(char* array, int size) {
+int verifyHeader(unsigned char* array, int size) {
 	if (verifyLevelHeader(array,size)) return 1;
 	if (verifyMidiHeader(array,size)) return 4;
 	if (verifyImageHeader(array,size)) return 2;
@@ -112,22 +112,44 @@ void emptyTable(tResource* r[]) {
 	while (i--) *(r++)=NULL;
 }
 
+//TODO: use a static XML tree and two functions: parseFile and freeXmlStructure
+
+//Resources input xml tree. Private+abstract variable
+static tTag* xmlStructure=NULL; /* Keeping the parsed file structure in memory will save a lot of time */
+
+
 //parse file
 char parseFile(const char* vFile, const char* datFile, tResource* r[]) {
+	//Declare error variable
+	int error=0;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
 
-	tTag* tree;
-	int error;
-
-	tree=parseXmlFile(vFile,&error);
-	if (error) return error;
+	//Use the xml structure to Generate the resource structure of the file
 	emptyTable(r);
-	workTree(tree,datFile,r);
-	freeTagStructure(tree);
+	workTree(xmlStructure,datFile,r);
 
+	//All done
 	return 0;
 }
 
-//Resources output to xml functions
+void freeParsedStructure() {
+	//Free if exist
+	if (xmlStructure!=NULL) freeTagStructure(xmlStructure);
+
+	//Reinitializes the veriable
+	xmlStructure=NULL;
+
+	return;
+}
+
+
+//Resources output to xml functions. Private+abstract variable
 static FILE* unknownXmlFile=NULL;
 
 void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char type,const char* vDirExt,unsigned short pal) {
@@ -156,21 +178,65 @@ void endUnknownXml() {
 	if (unknownXmlFile!=NULL) {
 		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
 		fclose(unknownXmlFile);
+		unknownXmlFile=NULL;
 	}
 }
 
 //Resources extra functions
-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) {
 	static const char extarray[8][4]=RES_FILE_EXTENSIONS;
 	const char* ext;
 
 	if (r->path==NULL) {
 		ext=extarray[((r->type<=7)&&(r->type>=0))?r->type:5];
 		//set filename
-		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vFiledat,id,ext);
-		AddToUnknownXml(vFiledat,id,ext,r->type,vDirExt,r->palette);
+		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,id,ext);
+		AddToUnknownXml(vDatFileName,id,ext,r->type,vDirExt,r->palette);
 	} else {
 		//set filename
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);
 	}
 }
+
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDatDirectory, FILE* output) {
+	//TODO send to a function called by parseFile & importDir
+	//Declare error variable
+	int error=0;
+	char* datfile;
+	char* recursive;
+	int sizeOfPath;
+	int sizeOfFile;
+	int result;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vResFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
+
+	//Use the xml structure to Generate the file list
+	getFiles(xmlStructure);
+
+	while(datfile=getFileFromList()) {
+		sizeOfPath=strlen(vDatDirectory);
+		sizeOfFile=strlen(datfile);
+
+		//Generate full vDatDirectory/datfile path
+		recursive=getMemory(sizeOfPath+1+sizeOfFile);
+		memcpy(recursive,vDatDirectory,sizeOfPath);
+		recursive[sizeOfPath]=DIR_SEPARATOR;
+		memcpy(recursive+sizeOfPath+1,datfile,sizeOfFile+1);
+
+		//Run program
+		result=prMain(pOption, backupExtension,directory,vResFile,recursive,datfile,NULL,output);
+		//Free mem
+		free(datfile);
+		free(recursive);
+	}
+
+	//All done
+	return result;
+}
+
diff --git a/PR/src/lib/layers/disk.c b/PR/src/lib/layers/disk.c
index d542016..f26052d 100644
--- a/PR/src/lib/layers/disk.c
+++ b/PR/src/lib/layers/disk.c
@@ -39,6 +39,7 @@ disk.c: Princed Resources : Disk Access & File handling functions
 #include <string.h>
 #include "pr.h"
 #include "disk.h"
+#include "xml.h" /* equalsIgnoreCase */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -48,7 +49,7 @@ disk.c: Princed Resources : Disk Access & File handling functions
 	#include <dirent.h>
 #else
 	#include <direct.h>
-	#include "dirent.h"
+	#include "direntwin.h"
 	#define defmkdir(a) mkdir (a)
 #endif
 
@@ -179,7 +180,7 @@ int mLoadFileArray(const char* vFile,unsigned char** array) {
 		//get file size
 		fseek(fp,0,SEEK_END);
 		aux=ftell(fp);
-		if ( !aux || (aux>SIZE_OF_FILE) || ( ((*array=(char*)malloc(sizeof(char)*aux))==NULL) ) ) {
+		if ( !aux || (aux>SIZE_OF_FILE) || ( ((*array=(unsigned char*)malloc(sizeof(char)*aux))==NULL) ) ) {
 			//if the file was null or bigger than the max size or couldn't allocate the file in memory
 			fclose(fp);
 			return 0;
@@ -261,18 +262,18 @@ const char* getFileNameFromPath(const char* path) {
 	return path;
 }
 
-int isDir(const char *path) {
+whatIs isDir(const char *path) {
 	/*
 		1 if nombre is a directory
 		0 if nombre isn't a directory or doesn't exist
 	*/
 	struct stat buf;
 
-	if(stat(path,&buf)==-1) return 0;
-	return (S_IFDIR&buf.st_mode);
+	if(stat(path,&buf)==-1) return eNotFound;
+	return (S_IFDIR&buf.st_mode)?eDirectory:eFile;
 }
 
-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 recurseDirectory(const char* path,int* pOption, const char* extension,const char* dirName,const char* resFile, const char* datfilename,const char* datAuthor,FILE* output) {
 	/*
 		Searchs for all .dat files in the directory
 		if recursive flag is set searchs over the dubdirectories
@@ -318,14 +319,14 @@ int recurseDirectory(const char* path,int* pOption, const char* extension,const
 				if recursive path is not a directory and is a dat file, do prMain
 				if recursive path is not a directory and is not a dat file, ignore
 			*/
-			if (isDir(recursive)) {
+			if (isDir(recursive)==eDirectory) {
 				if (optionflag&recursive_flag) { //Only recurse if recursive flag is set
-					recurseDirectory(recursive,pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
+					recurseDirectory(recursive,pOption,extension,dirName,resFile,datfilename,datAuthor,output);
 				}
 			} else {
 				char aux[]=".dat";
 				if (sizeOfFile>4) {
-					if (!strcmp(aux,directoryStructure->d_name+sizeOfFile-4)) {
+					if (equalsIgnoreCase(aux,directoryStructure->d_name+sizeOfFile-4)) {
 						prMain(pOption,extension,dirName,resFile,recursive,directoryStructure->d_name,datAuthor,output);
 					}
 				}
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index b980868..c1bcd91 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -50,21 +50,21 @@ resources.c: Princed Resources : Resource Handler
 |                       File format handling                    |
 \***************************************************************/
 
-char verifyLevelHeader(char* array, int size) {
+int verifyLevelHeader(unsigned char* array, int size) {
 	return (((size==2306)||(size==2305))&&!(array[1698]&0x0F)&&!(array[1700]&0x0F)&&!(array[1702]&0x0F));
 }
 
-char verifyImageHeader(char* array, int size) {
+int verifyImageHeader(unsigned char* array, int size) {
 	//return (size>6) && (!(((!array[1])||(array[2])||(!array[3])||(array[4])||(array[5])||(((unsigned char)array[6]&0xF0)!=0xB0))));
 	return (size>7) && (!array[5]) && (((unsigned char)array[6]&0xF0)==0xB0);
 	//TODO: fix the expression
 }
 
-char verifyPaletteHeader(char* array, int size) {
+int verifyPaletteHeader(unsigned char* array, int size) {
 	return ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10));
 }
 
-char verifyMidiHeader(char* array, int size) {
+int verifyMidiHeader(unsigned char* array, int size) {
 	return
 	  (size>6) &&
 		(array[1]==0x02) &&
@@ -75,19 +75,19 @@ char verifyMidiHeader(char* array, int size) {
 	;
 }
 
-char verifyWaveHeader(char* array, int size) {
+int verifyWaveHeader(unsigned char* array, int size) {
 	return
 		(size>1)&&(array[1]==0x01)
 	;
 }
 
-char verifySpeakerHeader(char* array, int size) {
+int verifySpeakerHeader(unsigned char* array, int size) {
 	return
 		(size>2)&&(array[1]==0x00) /* &&!(size%3) */
 	;
 }
 
-char verifyHeader(char* array, int size) {
+int verifyHeader(unsigned char* array, int size) {
 	if (verifyLevelHeader(array,size)) return 1;
 	if (verifyMidiHeader(array,size)) return 4;
 	if (verifyImageHeader(array,size)) return 2;
@@ -112,22 +112,44 @@ void emptyTable(tResource* r[]) {
 	while (i--) *(r++)=NULL;
 }
 
+//TODO: use a static XML tree and two functions: parseFile and freeXmlStructure
+
+//Resources input xml tree. Private+abstract variable
+static tTag* xmlStructure=NULL; /* Keeping the parsed file structure in memory will save a lot of time */
+
+
 //parse file
 char parseFile(const char* vFile, const char* datFile, tResource* r[]) {
+	//Declare error variable
+	int error=0;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
 
-	tTag* tree;
-	int error;
-
-	tree=parseXmlFile(vFile,&error);
-	if (error) return error;
+	//Use the xml structure to Generate the resource structure of the file
 	emptyTable(r);
-	workTree(tree,datFile,r);
-	freeTagStructure(tree);
+	workTree(xmlStructure,datFile,r);
 
+	//All done
 	return 0;
 }
 
-//Resources output to xml functions
+void freeParsedStructure() {
+	//Free if exist
+	if (xmlStructure!=NULL) freeTagStructure(xmlStructure);
+
+	//Reinitializes the veriable
+	xmlStructure=NULL;
+
+	return;
+}
+
+
+//Resources output to xml functions. Private+abstract variable
 static FILE* unknownXmlFile=NULL;
 
 void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char type,const char* vDirExt,unsigned short pal) {
@@ -156,21 +178,65 @@ void endUnknownXml() {
 	if (unknownXmlFile!=NULL) {
 		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
 		fclose(unknownXmlFile);
+		unknownXmlFile=NULL;
 	}
 }
 
 //Resources extra functions
-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) {
 	static const char extarray[8][4]=RES_FILE_EXTENSIONS;
 	const char* ext;
 
 	if (r->path==NULL) {
 		ext=extarray[((r->type<=7)&&(r->type>=0))?r->type:5];
 		//set filename
-		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vFiledat,id,ext);
-		AddToUnknownXml(vFiledat,id,ext,r->type,vDirExt,r->palette);
+		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,id,ext);
+		AddToUnknownXml(vDatFileName,id,ext,r->type,vDirExt,r->palette);
 	} else {
 		//set filename
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);
 	}
 }
+
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDatDirectory, FILE* output) {
+	//TODO send to a function called by parseFile & importDir
+	//Declare error variable
+	int error=0;
+	char* datfile;
+	char* recursive;
+	int sizeOfPath;
+	int sizeOfFile;
+	int result;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vResFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
+
+	//Use the xml structure to Generate the file list
+	getFiles(xmlStructure);
+
+	while(datfile=getFileFromList()) {
+		sizeOfPath=strlen(vDatDirectory);
+		sizeOfFile=strlen(datfile);
+
+		//Generate full vDatDirectory/datfile path
+		recursive=getMemory(sizeOfPath+1+sizeOfFile);
+		memcpy(recursive,vDatDirectory,sizeOfPath);
+		recursive[sizeOfPath]=DIR_SEPARATOR;
+		memcpy(recursive+sizeOfPath+1,datfile,sizeOfFile+1);
+
+		//Run program
+		result=prMain(pOption, backupExtension,directory,vResFile,recursive,datfile,NULL,output);
+		//Free mem
+		free(datfile);
+		free(recursive);
+	}
+
+	//All done
+	return result;
+}
+
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index c57f0a6..10e34a1 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -56,13 +56,13 @@ int transpose(int x,int n,int m) {
 
 //B3 and B4 expansion algorithm sub function
 unsigned char popBit(unsigned char *byte) {
-  unsigned char bit=(*byte)&1;
+  unsigned char bit=(unsigned char)((*byte)&1);
   (*byte)>>=1;
   return bit;
 }
 
 //Expands B3/B4 algorithm
-void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
+void expandLzx(unsigned /* note: if error remove signed */char* array,tImage* img, int *i,int cursor, int virtualSize) {
 	char k;
 	int pos,h;
 	unsigned char maskbyte,rep;
@@ -75,7 +75,7 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 				(*img).pix[cursor]=array[*i];(*i)++;cursor++;
 			} else {
 				pos=66+((0x100)*((rep=array[*i])&3))+(unsigned char)array[(*i)+1];(*i)+=2;
-				rep=(rep>>2)+3;
+				rep=(unsigned char)((rep>>2)+3);
 				while (rep--) { //Be careful in big images
 					h=cursor/MAX_MXD_SIZE_IN_LZX-(pos%MAX_MXD_SIZE_IN_LZX>cursor%MAX_MXD_SIZE_IN_LZX);
 					(*img).pix[cursor]=(*img).pix[((h<0)?0:h)*MAX_MXD_SIZE_IN_LZX+pos%MAX_MXD_SIZE_IN_LZX];cursor++;pos++;
@@ -88,14 +88,14 @@ void expandLzx(char* array,tImage* img, int *i,int cursor, int virtualSize) {
 //Compress B1/B2 algorithm
 void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 	//Declare pointers
-  char* cursorData  = data;
-  char* counter;
-  char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+(*dataSize);
+	unsigned char* cursorData  = data;
+	char*          counter;
+	unsigned char* cursorPix   = (*img).pix;
+	unsigned char* imgEnd      = (*img).pix+(*dataSize);
 
-  while (cursorPix<imgEnd) {
+	while (cursorPix<imgEnd) {
 		//Step 1: Create counter
-		*(counter=(cursorData++))=-1;
+		*(counter=(char*)(cursorData++))=-1;
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while (
@@ -134,7 +134,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 }
 
 //Expands an array into an image
-int mExpandGraphic(char* array,tImage *image, int virtualSize) {
+int mExpandGraphic(unsigned char* array,tImage *image, int virtualSize) {
 	/*
 		Reads array and extracts tImage
 		returns the next image address or -1 in case of error
@@ -173,7 +173,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[(cursor++)]=array[i++];
 				}
 			}
@@ -187,7 +187,7 @@ int mExpandGraphic(char* array,tImage *image, int virtualSize) {
 					i+=2;
 				} else {
 					//Positive
-					char cx=array[i++]+1;
+					signed char cx=(signed char)(array[i++]+1);
 					while (cx--) (*image).pix[transpose(cursor++,(*image).width,(*image).height)]=array[i++];
 				}
 			}
diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c
index 6130aa7..2e44111 100644
--- a/PR/src/lib/pr.c
+++ b/PR/src/lib/pr.c
@@ -69,7 +69,9 @@ pr.c: Main source file for Princed Resources
  #endif
 #endif
 
-//functions
+/***************************************************************\
+|                      Main working functions                   |
+\***************************************************************/
 
 int prExportDat(const char* vDatFile, const char* vDirName, const char* vResFile) {
 	return prExportDatOpt(vDatFile,vDirName,vResFile,0,NULL,NULL,"");
@@ -88,7 +90,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 			                        No NULL
 			char opt              - program options, see below
 			char * vDatFileName   - name of the file to be extracted
-			                        NULL means predict it from vDatFile
+			                        NULL means predict it from vDatFile (DISABLED!!!)
 			const char* datAuthor - Author's name when extracting PLV's,
 			                        NULL is default
 			const char* backupExtension
@@ -100,7 +102,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
                        any extraction
 			raw_flag       - uses raw format
 			verbose_flag   - explain what is being done
-x			recursive_flag - searches for all dat files (only if vDatFile
+			recursive_flag - searches for all dat files (only if vDatFile
 			                 is not a dat file and vDatFileName is NULL)
 x			force_flag     - default option, you cannot disable it,
 			                 so please make a backup of your files
@@ -122,15 +124,13 @@ x			backup_flag    - backup your files
 	tResource* r[MAX_RES_COUNT];
 	int a;
 	const char defaultXmlFile[]=RES_XML_RESOURC_XML;
-
 	//Set default values
-	if (vResFile==NULL) vResFile=defaultXmlFile;
-	if (vDatFileName==NULL) vDatFileName=getFileNameFromPath(vDatFile);
+	if (vResFile==NULL) vResFile=defaultXmlFile; //TODO: Send to prMain or main
 
-	//Parse XML and extract the file
-	a=parseFile     (vResFile,vDatFileName,r);
+	//Parse XML and extract the file //TODO: XML parser outside the function
+	a=parseFile(vResFile,vDatFileName,r);
 	if (a<0) return a-3; //parsing errors
-	a=extract(vDatFile, vDirName,r,opt,vDatFileName);
+	a=extract(vDatFile,vDirName,r,opt,vDatFileName,datAuthor);
 	return a; //extracting errors/no errors
 }
 
@@ -159,7 +159,7 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 		Options:
 			raw_flag       - uses raw format
 			verbose_flag   - explain what is being done
-x			recursive_flag - searches for all dat files (only if vDatFile
+			recursive_flag - searches for all dat files (only if vDatFile
 			                 is not a dat file and vDatFileName is NULL)
 x			force_flag     - default option, you cannot disable it,
 			                 so please make a backup of your files
@@ -183,9 +183,8 @@ x			backup_flag    - backup your files
 
 	//Set default values
 	if (vResFile==NULL) vResFile=defaultXmlFile;
-	if (vDatFileName==NULL) vDatFileName=getFileNameFromPath(vDatFile);
 
-	//Parser XML and compile files
+	//Parse XML and compile files
 	a=parseFile     (vResFile,vDatFileName,r);
 	if (a<0) return a-1;
 	a=compile (vDatFile, vDirName,r,opt,vDatFileName);
@@ -193,9 +192,9 @@ x			backup_flag    - backup your files
 }
 
 
-/*******************************************************
-                    M A I N   P R O G R A M
-       *******************************************************/
+/***************************************************************\
+|                     M A I N   P R O G R A M                   |
+\***************************************************************/
 
 void syntax(FILE* output) {
 	fprintf(output,PARSING_HELP);
@@ -205,6 +204,54 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 
 	//declare variables
 	int returnValue=1;
+	char* currentDatFileName;
+	const char* aux;
+
+	if (datfilename==NULL) {
+		aux=getFileNameFromPath(datfile);
+	} else {
+		aux=datfilename;
+	}
+
+	currentDatFileName=strallocandcopy(aux);
+
+	//do selected tasks
+	if (optionflag&export_flag) {
+		char* array[]=PR_TEXT_EXPORT_ARRAY;
+		fprintf(output,"Extracting '%s' to '%s' with %04x\r\n",datfile,dirName,optionflag);
+		returnValue=prExportDatOpt(datfile,dirName,resFile,optionflag,currentDatFileName,datAuthor,extension);
+		fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+	}	else if (optionflag&classify_flag) {
+		char* array[]=PR_TEXT_CLASSIFY_ARRAY;
+		fprintf(output,"Classifing '%s'\r\n",datfile);
+		returnValue=prVerifyDatType(datfile);
+		fprintf(output,PR_TEXT_RESULT,array[2+returnValue],returnValue);
+	}	else if (optionflag&import_flag) {
+		char* array[]=PR_TEXT_IMPORT_ARRAY;
+		fprintf(output,"Compiling '%s' from '%s' with %04x\r\n",datfile,dirName,optionflag);
+		returnValue=prImportDatOpt(datfile,dirName,resFile,optionflag,currentDatFileName,extension);
+		if (returnValue<=0) {
+			fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+		} else {
+			fprintf(output,PR_TEXT_RESULT_ERR,returnValue);
+		}
+	} else {
+		syntax(output);
+		returnValue=-1;
+	}
+	if (currentDatFileName) free(currentDatFileName);
+	return returnValue;
+}
+
+//Main program
+#ifndef DLL
+
+/***************************************************************\
+|             Standard executable specific functions            |
+\***************************************************************/
+
+int prStart(int* pOption, const char* extension,const char* dirName,const char* resFile,const char* datfile, const char* datfilename,const char* datAuthor,FILE* output) {
+	int result=1;
 
 	//Do CGI tasks
 	if (optionflag&cgi_flag) {
@@ -227,18 +274,6 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 		optionflag|=first_flag;
 	}
 
-	//Recursive testing
-	if (datfile==NULL) {
-		fprintf(output,"Scanning dat files in current directory\n");
-		recurseDirectory(".",pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
-		return 1;
-	} else if (isDir(datfile)) {
-		fprintf(output,"Scanning dat files un given directory\n");
-		recurseDirectory(datfile,pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
-		return 1;
-	}
-
-
 	//If bad syntax or help screen requested
 	if (optionflag&help_flag) {
 		syntax(output);
@@ -250,95 +285,79 @@ int prMain(int* pOption, const char* extension,const char* dirName,const char* r
 		return -1;
 	}
 
-	//do selected tasks
-	if (optionflag&export_flag) {
-		char* 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"};
-		fprintf(output,"Extracting '%s' to '%s' with %04x\r\n",datfile,dirName,optionflag);
-		returnValue=prExportDatOpt(datfile,dirName,resFile,optionflag,NULL,datAuthor,extension);
-		fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
-	}	else if (optionflag&classify_flag) {
-		char* 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",
-			"\0","\0","\0",
-			"Pop2 dat files"};
-		fprintf(output,"Classifing '%s'\r\n",datfile);
-		returnValue=prVerifyDatType(datfile);
-		fprintf(output,PR_TEXT_RESULT,array[2+returnValue],returnValue);
-	}	else if (optionflag&import_flag) {
-		char* 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"};
-		fprintf(output,"Compiling '%s' from '%s' with %04x\r\n",datfile,dirName,optionflag);
-		returnValue=prImportDatOpt(datfile,dirName,resFile,optionflag,NULL,extension);
-		if (returnValue<=0) {
-			fprintf(output,PR_TEXT_RESULT,array[-returnValue],returnValue);
+	//Perform tasks depending on the argument
+	if (optionflag&import_flag) {
+		//Check out the xml file to get the files to me compiled
+		if (datfile==NULL) {
+			fprintf(output,"Importing all valid dat files from the currect directory\n");
+			importDir(dirName,resFile,pOption,extension,".",output);
+		} else if (isDir(datfile)!=eFile) {
+			fprintf(output,"Importing all valid files from given directory\n");
+			importDir(dirName,resFile,pOption,extension,datfile,output);
 		} else {
-			fprintf(output,PR_TEXT_RESULT_ERR,returnValue);
+			result=prMain(pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
 		}
 	} else {
-		syntax(output);
-		return -1;
+
+		//Recursive testing for export/classify
+		if (datfile==NULL) {
+			fprintf(output,PR_TEXT_SCANNING_CURRENT);
+			recurseDirectory(".",pOption,extension,dirName,resFile,datfilename,datAuthor,output);
+		} else if (isDir(datfile)==eDirectory) {
+			fprintf(output,PR_TEXT_SCANNING_GIVEN);
+			recurseDirectory(datfile,pOption,extension,dirName,resFile,datfilename,datAuthor,output);
+		} else if (isDir(datfile)==eNotFound) {
+			fprintf(output,PR_TEXT_FILE_NOT_FOUND,datfile);
+			return 0;
+		} else {
+
+			result=prMain(pOption,extension,dirName,resFile,datfile,datfilename,datAuthor,output);
+		}
 	}
-	return returnValue;
+
+	freeParsedStructure();
+	return result;
 }
 
-//Main program
-#ifndef DLL
+/***************************************************************\
+|      Standard executable command line parsing function        |
+\***************************************************************/
 
 int main (int argc, char **argv) {
 	//declare variables
-	char  datFileName[MAX_FILENAME_SIZE]; //TODO add
+	char* datFileName=NULL;
 	char  dirName[MAX_FILENAME_SIZE]=".";
 	char  extension[MAX_EXTENSION_SIZE]=DEFAULT_BACKUP_EXTENSION;
 	char  resFile[MAX_FILENAME_SIZE]=RES_XML_RESOURC_XML;
-	char* datFilePath;
+	char* datFilePath=NULL;
 	char* datAuthor=NULL;
 	int   c;
 	int   flag=0;
 
 	//Parse options
 	while (1) {
-
 		static struct option long_options[] = PARSING_OPTIONS;
 
 		/* getopt_long stores the option index here. */
-		int option_index = 0;
-		c = getopt_long (argc, argv, PARSING_CHARS,long_options,&option_index);
+		int junk = 0;
+		c = getopt_long (argc, argv, PARSING_CHARS,long_options,&junk);
 
 		/* Detect the end of the options. */
 		if (c == -1) break;
 
 		switch (c) {
 				case 'c':
+					if (flag&(classify_flag|export_flag)) flag|=help_flag;
 					flag|=import_flag;
 					if (optarg) strncpy(dirName,optarg,MAX_FILENAME_SIZE);
 					break;
 				case 'd':
-					flag|=force_flag;
+					if (flag&(import_flag|export_flag)) flag|=help_flag;
+					flag|=classify_flag;
 					break;
 				case 'x':
 				case 'e':
+					if (flag&(classify_flag|import_flag)) flag|=help_flag;
 					flag|=export_flag;
 					if (optarg) strncpy(dirName,optarg,MAX_FILENAME_SIZE);
 					break;
@@ -361,12 +380,14 @@ int main (int argc, char **argv) {
 				case 'R':
 					flag|=recursive_flag;
 					break;
-				case 't': {
-					int size;
-					size=strlen(optarg)+1;
-					datAuthor=getMemory(size);
-					memcpy(datAuthor,optarg,size);
-				}	break;
+				case 't':
+					if (datFileName!=NULL) free(datFileName);
+					datFileName=strallocandcopy(optarg);
+					break;
+				case 'a':
+					if (datAuthor!=NULL) free(datAuthor);
+					datAuthor=strallocandcopy(optarg);
+					break;
 				case 'v':
 					flag|=verbose_flag;
 					break;
@@ -383,23 +404,29 @@ int main (int argc, char **argv) {
 
 	if (optind < argc) {
 		datFilePath=argv[optind];
-	} else {
-		datFilePath=NULL;
 	}
 
 	if (!flag) flag=help_flag;
 
 	//Run main program
-	prMain(&flag,extension,dirName,resFile,datFilePath,datFileName,datAuthor,stdout);
-
+fld("a");
+	prStart(&flag,extension,dirName,resFile,datFilePath,datFileName,datAuthor,stdout);
+fld("b");
 	//Free memory and exit
 	if (datAuthor!=NULL) free(datAuthor);
+	if (datFileName!=NULL) free(datFileName);
   return 0;
 }
 
 #endif
 
+/***************************************************************\
+|              Main Library start dummy function                |
+\***************************************************************/
+
 #ifdef SO
 //When compiling in Unix SO libraries
 void start() {}
 #endif
+
+
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index c40f32d..6423b32 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -40,8 +40,8 @@ xmlsearch.c: Princed Resources : specific xml handling functions
 #include "xml.h"
 #include "resources.h"
 #include "xmlsearch.h"
+#include "memory.h"
 #include <string.h>
-#include <stdlib.h>
 
 /****************************************************************\
 |                   Tag Tree Searching Functions                 |
@@ -150,3 +150,72 @@ void workTree(const tTag* t,const char* datFile, tResource* r[]) {
 	}
 }
 
+void getFiles(const tTag* t) {
+	/*
+		Runs addFileToList for all tags
+	*/
+	tTag* children;
+
+	if (t!=NULL) {
+		if (t->file!=NULL)
+			addFileToList(t->file);
+		children=t->child;
+
+		while (children!=NULL) {
+			getFiles(children);
+			children=children->next;
+		}
+	}
+}
+
+/****************************************************************\
+|                       File List Primitives                     |
+\****************************************************************/
+
+static tListNode* list=NULL;
+
+void addFileToList(const char* file) {
+	/*
+		Adds the file to the list only once
+	*/
+	tListNode* node=list;
+	tListNode* old=NULL;
+	//Verify if the file exists
+	while (node) {
+		if (equalsIgnoreCase(node->file,file)) //If file was in the list, do nothing
+			return;
+		old=node;
+		node=node->next;
+	}
+	//Add new node
+	node=(tListNode*)malloc(sizeof(tListNode));
+
+	if (old!=NULL) {
+		old->next=node;
+	} else {
+		list=node;
+	}
+	node->file=strallocandcopy(file);
+	node->next=NULL;
+}
+
+char* getFileFromList() {
+	/*
+		Returns and removes one random file from the list
+	*/
+	char* result;
+	tListNode* aux;
+	if (list) {
+		//Remember node values
+		aux=list;
+		result=list->file;
+		//move one position
+		list=list->next;
+		//free node
+		free(aux);
+		return result;
+	} else {
+		return NULL;
+	}
+	return result;
+}
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index b980868..c1bcd91 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -50,21 +50,21 @@ resources.c: Princed Resources : Resource Handler
 |                       File format handling                    |
 \***************************************************************/
 
-char verifyLevelHeader(char* array, int size) {
+int verifyLevelHeader(unsigned char* array, int size) {
 	return (((size==2306)||(size==2305))&&!(array[1698]&0x0F)&&!(array[1700]&0x0F)&&!(array[1702]&0x0F));
 }
 
-char verifyImageHeader(char* array, int size) {
+int verifyImageHeader(unsigned char* array, int size) {
 	//return (size>6) && (!(((!array[1])||(array[2])||(!array[3])||(array[4])||(array[5])||(((unsigned char)array[6]&0xF0)!=0xB0))));
 	return (size>7) && (!array[5]) && (((unsigned char)array[6]&0xF0)==0xB0);
 	//TODO: fix the expression
 }
 
-char verifyPaletteHeader(char* array, int size) {
+int verifyPaletteHeader(unsigned char* array, int size) {
 	return ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10));
 }
 
-char verifyMidiHeader(char* array, int size) {
+int verifyMidiHeader(unsigned char* array, int size) {
 	return
 	  (size>6) &&
 		(array[1]==0x02) &&
@@ -75,19 +75,19 @@ char verifyMidiHeader(char* array, int size) {
 	;
 }
 
-char verifyWaveHeader(char* array, int size) {
+int verifyWaveHeader(unsigned char* array, int size) {
 	return
 		(size>1)&&(array[1]==0x01)
 	;
 }
 
-char verifySpeakerHeader(char* array, int size) {
+int verifySpeakerHeader(unsigned char* array, int size) {
 	return
 		(size>2)&&(array[1]==0x00) /* &&!(size%3) */
 	;
 }
 
-char verifyHeader(char* array, int size) {
+int verifyHeader(unsigned char* array, int size) {
 	if (verifyLevelHeader(array,size)) return 1;
 	if (verifyMidiHeader(array,size)) return 4;
 	if (verifyImageHeader(array,size)) return 2;
@@ -112,22 +112,44 @@ void emptyTable(tResource* r[]) {
 	while (i--) *(r++)=NULL;
 }
 
+//TODO: use a static XML tree and two functions: parseFile and freeXmlStructure
+
+//Resources input xml tree. Private+abstract variable
+static tTag* xmlStructure=NULL; /* Keeping the parsed file structure in memory will save a lot of time */
+
+
 //parse file
 char parseFile(const char* vFile, const char* datFile, tResource* r[]) {
+	//Declare error variable
+	int error=0;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
 
-	tTag* tree;
-	int error;
-
-	tree=parseXmlFile(vFile,&error);
-	if (error) return error;
+	//Use the xml structure to Generate the resource structure of the file
 	emptyTable(r);
-	workTree(tree,datFile,r);
-	freeTagStructure(tree);
+	workTree(xmlStructure,datFile,r);
 
+	//All done
 	return 0;
 }
 
-//Resources output to xml functions
+void freeParsedStructure() {
+	//Free if exist
+	if (xmlStructure!=NULL) freeTagStructure(xmlStructure);
+
+	//Reinitializes the veriable
+	xmlStructure=NULL;
+
+	return;
+}
+
+
+//Resources output to xml functions. Private+abstract variable
 static FILE* unknownXmlFile=NULL;
 
 void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char type,const char* vDirExt,unsigned short pal) {
@@ -156,21 +178,65 @@ void endUnknownXml() {
 	if (unknownXmlFile!=NULL) {
 		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
 		fclose(unknownXmlFile);
+		unknownXmlFile=NULL;
 	}
 }
 
 //Resources extra functions
-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) {
 	static const char extarray[8][4]=RES_FILE_EXTENSIONS;
 	const char* ext;
 
 	if (r->path==NULL) {
 		ext=extarray[((r->type<=7)&&(r->type>=0))?r->type:5];
 		//set filename
-		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vFiledat,id,ext);
-		AddToUnknownXml(vFiledat,id,ext,r->type,vDirExt,r->palette);
+		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,id,ext);
+		AddToUnknownXml(vDatFileName,id,ext,r->type,vDirExt,r->palette);
 	} else {
 		//set filename
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);
 	}
 }
+
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDatDirectory, FILE* output) {
+	//TODO send to a function called by parseFile & importDir
+	//Declare error variable
+	int error=0;
+	char* datfile;
+	char* recursive;
+	int sizeOfPath;
+	int sizeOfFile;
+	int result;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vResFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
+
+	//Use the xml structure to Generate the file list
+	getFiles(xmlStructure);
+
+	while(datfile=getFileFromList()) {
+		sizeOfPath=strlen(vDatDirectory);
+		sizeOfFile=strlen(datfile);
+
+		//Generate full vDatDirectory/datfile path
+		recursive=getMemory(sizeOfPath+1+sizeOfFile);
+		memcpy(recursive,vDatDirectory,sizeOfPath);
+		recursive[sizeOfPath]=DIR_SEPARATOR;
+		memcpy(recursive+sizeOfPath+1,datfile,sizeOfFile+1);
+
+		//Run program
+		result=prMain(pOption, backupExtension,directory,vResFile,recursive,datfile,NULL,output);
+		//Free mem
+		free(datfile);
+		free(recursive);
+	}
+
+	//All done
+	return result;
+}
+
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index b980868..c1bcd91 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -50,21 +50,21 @@ resources.c: Princed Resources : Resource Handler
 |                       File format handling                    |
 \***************************************************************/
 
-char verifyLevelHeader(char* array, int size) {
+int verifyLevelHeader(unsigned char* array, int size) {
 	return (((size==2306)||(size==2305))&&!(array[1698]&0x0F)&&!(array[1700]&0x0F)&&!(array[1702]&0x0F));
 }
 
-char verifyImageHeader(char* array, int size) {
+int verifyImageHeader(unsigned char* array, int size) {
 	//return (size>6) && (!(((!array[1])||(array[2])||(!array[3])||(array[4])||(array[5])||(((unsigned char)array[6]&0xF0)!=0xB0))));
 	return (size>7) && (!array[5]) && (((unsigned char)array[6]&0xF0)==0xB0);
 	//TODO: fix the expression
 }
 
-char verifyPaletteHeader(char* array, int size) {
+int verifyPaletteHeader(unsigned char* array, int size) {
 	return ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10));
 }
 
-char verifyMidiHeader(char* array, int size) {
+int verifyMidiHeader(unsigned char* array, int size) {
 	return
 	  (size>6) &&
 		(array[1]==0x02) &&
@@ -75,19 +75,19 @@ char verifyMidiHeader(char* array, int size) {
 	;
 }
 
-char verifyWaveHeader(char* array, int size) {
+int verifyWaveHeader(unsigned char* array, int size) {
 	return
 		(size>1)&&(array[1]==0x01)
 	;
 }
 
-char verifySpeakerHeader(char* array, int size) {
+int verifySpeakerHeader(unsigned char* array, int size) {
 	return
 		(size>2)&&(array[1]==0x00) /* &&!(size%3) */
 	;
 }
 
-char verifyHeader(char* array, int size) {
+int verifyHeader(unsigned char* array, int size) {
 	if (verifyLevelHeader(array,size)) return 1;
 	if (verifyMidiHeader(array,size)) return 4;
 	if (verifyImageHeader(array,size)) return 2;
@@ -112,22 +112,44 @@ void emptyTable(tResource* r[]) {
 	while (i--) *(r++)=NULL;
 }
 
+//TODO: use a static XML tree and two functions: parseFile and freeXmlStructure
+
+//Resources input xml tree. Private+abstract variable
+static tTag* xmlStructure=NULL; /* Keeping the parsed file structure in memory will save a lot of time */
+
+
 //parse file
 char parseFile(const char* vFile, const char* datFile, tResource* r[]) {
+	//Declare error variable
+	int error=0;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
 
-	tTag* tree;
-	int error;
-
-	tree=parseXmlFile(vFile,&error);
-	if (error) return error;
+	//Use the xml structure to Generate the resource structure of the file
 	emptyTable(r);
-	workTree(tree,datFile,r);
-	freeTagStructure(tree);
+	workTree(xmlStructure,datFile,r);
 
+	//All done
 	return 0;
 }
 
-//Resources output to xml functions
+void freeParsedStructure() {
+	//Free if exist
+	if (xmlStructure!=NULL) freeTagStructure(xmlStructure);
+
+	//Reinitializes the veriable
+	xmlStructure=NULL;
+
+	return;
+}
+
+
+//Resources output to xml functions. Private+abstract variable
 static FILE* unknownXmlFile=NULL;
 
 void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char type,const char* vDirExt,unsigned short pal) {
@@ -156,21 +178,65 @@ void endUnknownXml() {
 	if (unknownXmlFile!=NULL) {
 		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
 		fclose(unknownXmlFile);
+		unknownXmlFile=NULL;
 	}
 }
 
 //Resources extra functions
-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) {
 	static const char extarray[8][4]=RES_FILE_EXTENSIONS;
 	const char* ext;
 
 	if (r->path==NULL) {
 		ext=extarray[((r->type<=7)&&(r->type>=0))?r->type:5];
 		//set filename
-		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vFiledat,id,ext);
-		AddToUnknownXml(vFiledat,id,ext,r->type,vDirExt,r->palette);
+		sprintf(vFileext,RES_XML_UNKNOWN_PATH""RES_XML_UNKNOWN_FILES,vDirExt,vDatFileName,id,ext);
+		AddToUnknownXml(vDatFileName,id,ext,r->type,vDirExt,r->palette);
 	} else {
 		//set filename
 		sprintf(vFileext,"%s/%s",vDirExt,r->path);
 	}
 }
+
+//Search files for the Import feature
+int importDir(const char* directory, const char* vResFile, int* pOption, const char* backupExtension,const char* vDatDirectory, FILE* output) {
+	//TODO send to a function called by parseFile & importDir
+	//Declare error variable
+	int error=0;
+	char* datfile;
+	char* recursive;
+	int sizeOfPath;
+	int sizeOfFile;
+	int result;
+
+	//Generate xml structure if doesn't exist
+	if (xmlStructure==NULL)	xmlStructure=parseXmlFile(vResFile,&error);
+	if (error) {
+		xmlStructure=NULL;
+		return error;
+	}
+
+	//Use the xml structure to Generate the file list
+	getFiles(xmlStructure);
+
+	while(datfile=getFileFromList()) {
+		sizeOfPath=strlen(vDatDirectory);
+		sizeOfFile=strlen(datfile);
+
+		//Generate full vDatDirectory/datfile path
+		recursive=getMemory(sizeOfPath+1+sizeOfFile);
+		memcpy(recursive,vDatDirectory,sizeOfPath);
+		recursive[sizeOfPath]=DIR_SEPARATOR;
+		memcpy(recursive+sizeOfPath+1,datfile,sizeOfFile+1);
+
+		//Run program
+		result=prMain(pOption, backupExtension,directory,vResFile,recursive,datfile,NULL,output);
+		//Free mem
+		free(datfile);
+		free(recursive);
+	}
+
+	//All done
+	return result;
+}
+
diff --git a/PR/src/pr.dsp b/PR/src/pr.dsp
index 2b5b3ec..2f39aa3 100644
--- a/PR/src/pr.dsp
+++ b/PR/src/pr.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
+# ADD CPP /nologo /W2 /GX /O2 /I "include\\" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /c
 # ADD BASE RSC /l 0x2c0a /d "NDEBUG"
 # ADD RSC /l 0x2c0a /d "NDEBUG"
 BSC32=bscmake.exe
@@ -71,7 +71,7 @@ PostBuild_Cmds=del winbins\pr.exe	copy bin\pr.exe winbins\pr.exe >nul	scripts\up
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "include\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /I "include\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
 # ADD BASE RSC /l 0x2c0a /d "_DEBUG"
 # ADD RSC /l 0x2c0a /d "_DEBUG"
 BSC32=bscmake.exe
@@ -227,7 +227,7 @@ DEP_CPP_WAV_C=\
 
 SOURCE=.\ports\dirent.c
 DEP_CPP_DIREN=\
-	".\include\dirent.h"\
+	".\include\direntwin.h"\
 	
 
 !IF  "$(CFG)" == "tasks - Win32 Release"
@@ -317,9 +317,10 @@ DEP_CPP_COMPR=\
 
 SOURCE=.\disk.c
 DEP_CPP_DISK_=\
-	".\include\dirent.h"\
+	".\include\direntwin.h"\
 	".\include\disk.h"\
 	".\include\pr.h"\
+	".\include\xml.h"\
 	
 
 !IF  "$(CFG)" == "tasks - Win32 Release"
@@ -347,6 +348,19 @@ DEP_CPP_EXTRA=\
 	".\include\wav.h"\
 	
 
+!IF  "$(CFG)" == "tasks - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
+
+!ELSEIF  "$(CFG)" == "tasks - Win32 Dynamic Link Library"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\memory.c
+
 !IF  "$(CFG)" == "tasks - Win32 Release"
 
 !ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
@@ -486,7 +500,7 @@ SOURCE=.\include\wav.h
 # PROP Default_Filter ""
 # Begin Source File
 
-SOURCE=.\include\dirent.h
+SOURCE=.\include\direntwin.h
 # End Source File
 # Begin Source File