git » fp-git.git » commit fe8d8f4

o Improved abstraction in some routines

author ecalot
2003-11-07 20:56:01 UTC
committer ecalot
2003-11-07 20:56:01 UTC
parent 0941ec179f0900065ebd0342b2fa682c3062cae5

o Improved abstraction in some routines

PR/src/console/main.c +24 -39
PR/src/lib/actions/classify.c +1 -1
PR/src/lib/layers/autodetect.c +8 -159
PR/src/lib/layers/idlist.c +8 -159
PR/src/lib/pr.c +24 -39
PR/src/lib/xml/search.c +4 -19
PR/src/lib/xml/tree.c +8 -159
PR/src/lib/xml/unknown.c +8 -159
PR/src/pr.dsp +43 -17
PR/src/xml.c +1 -1

diff --git a/PR/src/console/main.c b/PR/src/console/main.c
index 73bd541..b5eb371 100644
--- a/PR/src/console/main.c
+++ b/PR/src/console/main.c
@@ -29,15 +29,15 @@ pr.c: Main source file for Princed Resources
 	  Enrique Calot
 
 	 Graphic compression algorithms
-    Tammo Jan Dijkema
-    Enrique Calot
+	  Tammo Jan Dijkema
+	  Enrique Calot
 
-   Graphic format development
-    Tammo Jan Dijkema
-    Anke Balderer
+	 Graphic format development
+	  Tammo Jan Dijkema
+	  Anke Balderer
 
-   MID Sound format development
-    Christian Lundheim
+	 MID Sound format development
+	  Christian Lundheim
 
  Note:
   DO NOT remove this copyright notice
@@ -85,13 +85,12 @@ int prExportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) {
 			-6 XML Attribute not recognized
 			-7 XML File not found
 	*/
-	tResource* r[65536];
+	tResource* r[MAX_RES_COUNT];
 	int a;
 
 	a=parseFile     (vResFile,vDatFile,r);
 	if (a<0) return a-3;
 	a=extract(vDatFile, vDirName,r,opt);
-	//if (!(opt&8)) generateFile(vResFile,r);
 	return a;
 }
 
@@ -114,32 +113,18 @@ int prImportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) {
 			00 File succesfully compiled
 			positive number: number of missing files
 	*/
-	tResource*    r[65536];
+	tResource*    r[MAX_RES_COUNT];
 	int a;
 	a=parseFile     (vResFile,vDatFile,r);
 	if (a<0) return a-1;
 	a=compile (vDatFile, vDirName,r,opt);
-	generateFile  (vResFile,r);
 	return a;
 }
 
-int prClearRes(char* vResFile) {
-	/*
-		Return values:
-			01 Ok
-			00 Error
-	*/
-	tResource* r[65536];
-	emptyTable(r);
-	return generateFile(vResFile,r);
-}
-
-
-
 //Main program
 #ifndef DLL
 void syntax() {
-	printf("Syntax:\r\n pr datfile option [extract dir]\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");
+	printf(PR_TEXT_SYNTAX);
 }
 
 int main(int argc, char* argv[]) {
@@ -151,9 +136,9 @@ int main(int argc, char* argv[]) {
 	int i;
 
 #ifdef UNIX
-	if (argc==2) {
-		printf("Content-Type:text/html\n\nRunning as a cgi\n");
-		printf("Result: %02d type\r\n",prVerifyDatType(argv[1]));
+	if (argc==2) { //CGI support
+		printf(PR_CGI_TEXT1);
+		printf(PR_CGI_TEXT2,prVerifyDatType(argv[1]));
 		return 1;
 	}
 #endif
@@ -165,11 +150,11 @@ int main(int argc, char* argv[]) {
 		syntax();
 		return -1;
 	}
-	if (argc==4) {
-		sprintf(dir,argv[3]);
+	if (argc==4 ) {
+		if (strlen(argv[3])<(260-1)) sprintf(dir,argv[3]);
 	}
 
-	//do selected taskbars
+	//do selected tasks
 	switch (argv[2][1]) {
 		case 'e':
 		case 'x': {// file.dat --> extracted files + resource.xml
@@ -187,12 +172,12 @@ int main(int argc, char* argv[]) {
 				switch (argv[2][i]) {
 					case 'n':option&=0xFE;break;
 					case 'r':option|=0x04;break;
-					default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break;
+					default:printf(PR_TEXT_SKIPING,argv[2][i]);break;
 				}
 			}
 			printf("Extracting '%s' to '%s' with %d\r\n",argv[1],dir,option);
-			returnValue=prExportDatOpt(argv[1],dir,"resources.xml",(char)option);
-			printf("Result: %s (%d)\r\n",array[-returnValue],returnValue);
+			returnValue=prExportDatOpt(argv[1],dir,RES_XML_RESOURC_XML,(char)option);
+			printf(PR_TEXT_RESULT,array[-returnValue],returnValue);
 		}	break;
 		case 'd': {// get type of file.dat
 			char array[14][65]={
@@ -210,7 +195,7 @@ int main(int argc, char* argv[]) {
 				"Pop2 dat files"};
 			printf("Classifing '%s'\r\n",argv[1]);
 			returnValue=prVerifyDatType(argv[1]);
-			printf("Result: %s (%d)\r\n",array[2+returnValue],returnValue);
+			printf(PR_TEXT_RESULT,array[2+returnValue],returnValue);
 		}	break;
 		case 'c': { // extracted files + resource.xml --> files.dat
 			char array[6][39]={
@@ -224,15 +209,15 @@ int main(int argc, char* argv[]) {
 				for (i=2;argv[2][i];i++) {
 					switch (argv[2][i]) {
 						case 'r':option&=0xFE;break;
-						default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break;
+						default:printf(PR_TEXT_SKIPING,argv[2][i]);break;
 					}
 				}
 			printf("Compiling '%s' from '%s' with %d\r\n",argv[1],dir,option);
-			returnValue=prImportDatOpt(argv[1],dir,"resources.xml",(char)option);
+			returnValue=prImportDatOpt(argv[1],dir,RES_XML_RESOURC_XML,(char)option);
 			if (returnValue>=0) {
-				printf("Result: %s (%d)\r\n",array[-returnValue],returnValue);
+				printf(PR_TEXT_RESULT,array[-returnValue],returnValue);
 			} else {
-				printf("Result: %d files with errors\r\n",returnValue);
+				printf(PR_TEXT_RESULT_ERR,returnValue);
 			}
 		} break;
 		default:
diff --git a/PR/src/lib/actions/classify.c b/PR/src/lib/actions/classify.c
index d25f8c4..b4acd7b 100644
--- a/PR/src/lib/actions/classify.c
+++ b/PR/src/lib/actions/classify.c
@@ -73,7 +73,7 @@ int prVerifyDatType(char* vFiledat) {
 		if ((numberOfItems*8+2)!=indexSize) {
 			indexOffset+=indexSize;
 			fseek(fp,0,SEEK_END);
-			printf("jaaaj %d %d\r\n",indexOffset,ftell(fp));
+//printf("jaaaj %d %d\r\n",indexOffset,ftell(fp));
 			ok=(((unsigned long)ftell(fp))==indexOffset)?11:0; //see if it is a pop2 file
 			fclose(fp);
 			return ok; //this is a pop2 dat file or invalid
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index 1d7c120..2591faa 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -41,7 +41,6 @@ resources.c: Princed Resources : Resource Handler
 #include "pr.h"
 #include "xml.h"
 #include "xmlsearch.h"
-#include "parser.h"
 #include "disk.h"
 #include "memory.h"
 #include "resources.h"
@@ -84,7 +83,7 @@ char verifyWaveHeader(char* array, int size) {
 
 char verifySpeakerHeader(char* array, int size) {
 	return
-		(size>1)&&(array[1]==0x00)
+		(size>2)&&(array[1]==0x00)
 	;
 }
 
@@ -98,48 +97,19 @@ char verifyHeader(char* array, int size) {
 	return 05;
 }
 
+const char* getExtDesc(int type) {
+	static const char extarraydesc[8][10]={"raw","level","image","wave","midi","unknown","palette","pcspeaker"};
+	return extarraydesc[type];
+}
 
 /***************************************************************\
 |                      Parsing resource file                    |
 \***************************************************************/
 
-#if 0
-//Parse line
-void parseResource(tResource* r[], char* line) {
-	//declare variables
-	int                i=0;
-	int                k=0;
-	unsigned short int id,ty;
-
-	//Begin parsing
-	for (;!(line[k]=='\r'||line[k]=='\n'||(!line[k]));k++);
-	line[k]=0;
-
-	if (getNumberToken(line,&id,' ',&i,6)) {
-		r[id]=(tResource*)malloc(sizeof(tResource));
-		getNumberToken(line,&(*(r[id])).size,' ',&i,6);
-		getNumberToken(line,&(*(r[id])).offset,' ',&i,6);
-		getUpperToken(line,(*(r[id])).file,' ',&i,12);
-		if (getNumberToken(line,&ty,' ',&i,3)) {
-			(*(r[id])).desc=(char*)malloc(255);
-			if (getToken(line,(*(r[id])).desc,'#',&i,255)) {
-				(*(r[id])).coms=(char*)malloc(1023);
-				if (!getToken(line,(*(r[id])).coms,0,&i,1023)) {
-					free ((*(r[id])).coms);
-					(*(r[id])).coms=NULL;
-				}
-			}
-		} else {
-			(*(r[id])).desc=NULL;
-		}
-		(*(r[id])).type=(char)ty;
-	}
-}
-#endif
-
+//Initializes the resource table
 void emptyTable(tResource* r[]) {
 	int i=0;
-	for (;i<65536;i++) r[i]=NULL;
+	for (;i<MAX_RES_COUNT;i++) r[i]=NULL;
 }
 
 //parse file
@@ -155,127 +125,6 @@ char parseFile(char* vFile, char* datFile, tResource* r[]) {
 	freeTagStructure(tree);
 
 	return 0;
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	char parsing=0;
-	char line[MAX_LINE_SIZE];
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	FILE* fp;
-
-	//empty resource array
-	emptyTable(r);
-
-	//parse file
-	if ((fp=fopen(vFile,"rt"))!=NULL) {
-		while (fgets(line,MAX_LINE_SIZE,fp)!=NULL) {
-			if (parsing) {
-				if (equals(line,E)) {
-					parsing=0;
-				} else {
-					parseResource(r,line);
-				}
-			} else {
-				if (equals(line,B)) parsing=1;
-			}
-		}
-		fclose(fp);
-		return 1;
-	} else {
-		return 0;
-	}
-#endif
-}
-
-//generate file
-char generateFile(char* vFile,tResource* r[]) {
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	FILE* fp;
-	FILE* source;
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	char coms[MAX_LINE_SIZE];
-	char line[MAX_LINE_SIZE];
-	char none[]="";
-	char parsing=0;
-	int id=0;
-
-	if ((fp=fopen("res.tmp","wt"))!=NULL) {
-		//insert headers
-		if ((source=fopen(vFile,"rt"))!=NULL) {
-			while ((parsing!=2)&&(fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				if (parsing) {
-					if (equals(line,E)) {
-						parsing=2;
-					}
-				} else {
-					if (equals(line,B)) {
-						parsing=1;
-					} else {
-						fputs(line,fp);
-					}
-				}
-			}
-		}
-
-		//insert main body file
-		fputs(B,fp);
-		fputs("\n",fp);
-
-		for (;id<65536;id++) {
-			if (r[id]!=NULL) {
-				if (1||((*(r[id])).desc==NULL)) { //todo see this line
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms,none);
-					} else {
-						sprintf(coms," #",(*(r[id])).coms);
-					}
-				} else {
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms," %s",(*(r[id])).desc);
-					} else {
-						sprintf(coms," %s#%s",(*(r[id])).desc,(*(r[id])).coms);
-					}
-				}
-				sprintf(line,"<item itemtype=\"%d\" value=\"%d\" file=\"%s\" external=\"res%05d.bmp\">Res %d</item>\n",
-					(*(r[id])).type,
-					id,
-				//(*(r[id])).size,
-				//(*(r[id])).offset,
-				(*(r[id])).file,
-				id,id
-				//,
-				//coms
-				);
-				fputs(line,fp);
-			}
-		}
-		fputs("\n",fp);
-		fputs(E,fp);
-
-		//insert footers
-		if (source!=NULL) {
-			while ((parsing==2) && (fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				fputs(line,fp);
-			}
-			fclose(source);
-		}
-		fclose(fp);
-		remove(vFile);
-		rename("res.tmp",vFile);
-		return 1;
-	} else {
-		return 0;
-	}
-#else
-	//New code ignores this function (resources.xml is read only)
-	return 1;
-#endif
 }
 
 //Resources output to xml functions
@@ -300,7 +149,7 @@ void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char
 	}
 	//TODO: set itemtype in words
 	fprintf(unknownXmlFile,RES_XML_UNKNOWN_ITEM,
-		id,id,ext,type,id
+		id,id,ext,getExtDesc(type),id
 	); //To the xml output
 }
 
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index 1d7c120..2591faa 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -41,7 +41,6 @@ resources.c: Princed Resources : Resource Handler
 #include "pr.h"
 #include "xml.h"
 #include "xmlsearch.h"
-#include "parser.h"
 #include "disk.h"
 #include "memory.h"
 #include "resources.h"
@@ -84,7 +83,7 @@ char verifyWaveHeader(char* array, int size) {
 
 char verifySpeakerHeader(char* array, int size) {
 	return
-		(size>1)&&(array[1]==0x00)
+		(size>2)&&(array[1]==0x00)
 	;
 }
 
@@ -98,48 +97,19 @@ char verifyHeader(char* array, int size) {
 	return 05;
 }
 
+const char* getExtDesc(int type) {
+	static const char extarraydesc[8][10]={"raw","level","image","wave","midi","unknown","palette","pcspeaker"};
+	return extarraydesc[type];
+}
 
 /***************************************************************\
 |                      Parsing resource file                    |
 \***************************************************************/
 
-#if 0
-//Parse line
-void parseResource(tResource* r[], char* line) {
-	//declare variables
-	int                i=0;
-	int                k=0;
-	unsigned short int id,ty;
-
-	//Begin parsing
-	for (;!(line[k]=='\r'||line[k]=='\n'||(!line[k]));k++);
-	line[k]=0;
-
-	if (getNumberToken(line,&id,' ',&i,6)) {
-		r[id]=(tResource*)malloc(sizeof(tResource));
-		getNumberToken(line,&(*(r[id])).size,' ',&i,6);
-		getNumberToken(line,&(*(r[id])).offset,' ',&i,6);
-		getUpperToken(line,(*(r[id])).file,' ',&i,12);
-		if (getNumberToken(line,&ty,' ',&i,3)) {
-			(*(r[id])).desc=(char*)malloc(255);
-			if (getToken(line,(*(r[id])).desc,'#',&i,255)) {
-				(*(r[id])).coms=(char*)malloc(1023);
-				if (!getToken(line,(*(r[id])).coms,0,&i,1023)) {
-					free ((*(r[id])).coms);
-					(*(r[id])).coms=NULL;
-				}
-			}
-		} else {
-			(*(r[id])).desc=NULL;
-		}
-		(*(r[id])).type=(char)ty;
-	}
-}
-#endif
-
+//Initializes the resource table
 void emptyTable(tResource* r[]) {
 	int i=0;
-	for (;i<65536;i++) r[i]=NULL;
+	for (;i<MAX_RES_COUNT;i++) r[i]=NULL;
 }
 
 //parse file
@@ -155,127 +125,6 @@ char parseFile(char* vFile, char* datFile, tResource* r[]) {
 	freeTagStructure(tree);
 
 	return 0;
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	char parsing=0;
-	char line[MAX_LINE_SIZE];
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	FILE* fp;
-
-	//empty resource array
-	emptyTable(r);
-
-	//parse file
-	if ((fp=fopen(vFile,"rt"))!=NULL) {
-		while (fgets(line,MAX_LINE_SIZE,fp)!=NULL) {
-			if (parsing) {
-				if (equals(line,E)) {
-					parsing=0;
-				} else {
-					parseResource(r,line);
-				}
-			} else {
-				if (equals(line,B)) parsing=1;
-			}
-		}
-		fclose(fp);
-		return 1;
-	} else {
-		return 0;
-	}
-#endif
-}
-
-//generate file
-char generateFile(char* vFile,tResource* r[]) {
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	FILE* fp;
-	FILE* source;
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	char coms[MAX_LINE_SIZE];
-	char line[MAX_LINE_SIZE];
-	char none[]="";
-	char parsing=0;
-	int id=0;
-
-	if ((fp=fopen("res.tmp","wt"))!=NULL) {
-		//insert headers
-		if ((source=fopen(vFile,"rt"))!=NULL) {
-			while ((parsing!=2)&&(fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				if (parsing) {
-					if (equals(line,E)) {
-						parsing=2;
-					}
-				} else {
-					if (equals(line,B)) {
-						parsing=1;
-					} else {
-						fputs(line,fp);
-					}
-				}
-			}
-		}
-
-		//insert main body file
-		fputs(B,fp);
-		fputs("\n",fp);
-
-		for (;id<65536;id++) {
-			if (r[id]!=NULL) {
-				if (1||((*(r[id])).desc==NULL)) { //todo see this line
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms,none);
-					} else {
-						sprintf(coms," #",(*(r[id])).coms);
-					}
-				} else {
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms," %s",(*(r[id])).desc);
-					} else {
-						sprintf(coms," %s#%s",(*(r[id])).desc,(*(r[id])).coms);
-					}
-				}
-				sprintf(line,"<item itemtype=\"%d\" value=\"%d\" file=\"%s\" external=\"res%05d.bmp\">Res %d</item>\n",
-					(*(r[id])).type,
-					id,
-				//(*(r[id])).size,
-				//(*(r[id])).offset,
-				(*(r[id])).file,
-				id,id
-				//,
-				//coms
-				);
-				fputs(line,fp);
-			}
-		}
-		fputs("\n",fp);
-		fputs(E,fp);
-
-		//insert footers
-		if (source!=NULL) {
-			while ((parsing==2) && (fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				fputs(line,fp);
-			}
-			fclose(source);
-		}
-		fclose(fp);
-		remove(vFile);
-		rename("res.tmp",vFile);
-		return 1;
-	} else {
-		return 0;
-	}
-#else
-	//New code ignores this function (resources.xml is read only)
-	return 1;
-#endif
 }
 
 //Resources output to xml functions
@@ -300,7 +149,7 @@ void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char
 	}
 	//TODO: set itemtype in words
 	fprintf(unknownXmlFile,RES_XML_UNKNOWN_ITEM,
-		id,id,ext,type,id
+		id,id,ext,getExtDesc(type),id
 	); //To the xml output
 }
 
diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c
index 73bd541..b5eb371 100644
--- a/PR/src/lib/pr.c
+++ b/PR/src/lib/pr.c
@@ -29,15 +29,15 @@ pr.c: Main source file for Princed Resources
 	  Enrique Calot
 
 	 Graphic compression algorithms
-    Tammo Jan Dijkema
-    Enrique Calot
+	  Tammo Jan Dijkema
+	  Enrique Calot
 
-   Graphic format development
-    Tammo Jan Dijkema
-    Anke Balderer
+	 Graphic format development
+	  Tammo Jan Dijkema
+	  Anke Balderer
 
-   MID Sound format development
-    Christian Lundheim
+	 MID Sound format development
+	  Christian Lundheim
 
  Note:
   DO NOT remove this copyright notice
@@ -85,13 +85,12 @@ int prExportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) {
 			-6 XML Attribute not recognized
 			-7 XML File not found
 	*/
-	tResource* r[65536];
+	tResource* r[MAX_RES_COUNT];
 	int a;
 
 	a=parseFile     (vResFile,vDatFile,r);
 	if (a<0) return a-3;
 	a=extract(vDatFile, vDirName,r,opt);
-	//if (!(opt&8)) generateFile(vResFile,r);
 	return a;
 }
 
@@ -114,32 +113,18 @@ int prImportDatOpt(char* vDatFile, char* vDirName, char* vResFile,char opt) {
 			00 File succesfully compiled
 			positive number: number of missing files
 	*/
-	tResource*    r[65536];
+	tResource*    r[MAX_RES_COUNT];
 	int a;
 	a=parseFile     (vResFile,vDatFile,r);
 	if (a<0) return a-1;
 	a=compile (vDatFile, vDirName,r,opt);
-	generateFile  (vResFile,r);
 	return a;
 }
 
-int prClearRes(char* vResFile) {
-	/*
-		Return values:
-			01 Ok
-			00 Error
-	*/
-	tResource* r[65536];
-	emptyTable(r);
-	return generateFile(vResFile,r);
-}
-
-
-
 //Main program
 #ifndef DLL
 void syntax() {
-	printf("Syntax:\r\n pr datfile option [extract dir]\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");
+	printf(PR_TEXT_SYNTAX);
 }
 
 int main(int argc, char* argv[]) {
@@ -151,9 +136,9 @@ int main(int argc, char* argv[]) {
 	int i;
 
 #ifdef UNIX
-	if (argc==2) {
-		printf("Content-Type:text/html\n\nRunning as a cgi\n");
-		printf("Result: %02d type\r\n",prVerifyDatType(argv[1]));
+	if (argc==2) { //CGI support
+		printf(PR_CGI_TEXT1);
+		printf(PR_CGI_TEXT2,prVerifyDatType(argv[1]));
 		return 1;
 	}
 #endif
@@ -165,11 +150,11 @@ int main(int argc, char* argv[]) {
 		syntax();
 		return -1;
 	}
-	if (argc==4) {
-		sprintf(dir,argv[3]);
+	if (argc==4 ) {
+		if (strlen(argv[3])<(260-1)) sprintf(dir,argv[3]);
 	}
 
-	//do selected taskbars
+	//do selected tasks
 	switch (argv[2][1]) {
 		case 'e':
 		case 'x': {// file.dat --> extracted files + resource.xml
@@ -187,12 +172,12 @@ int main(int argc, char* argv[]) {
 				switch (argv[2][i]) {
 					case 'n':option&=0xFE;break;
 					case 'r':option|=0x04;break;
-					default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break;
+					default:printf(PR_TEXT_SKIPING,argv[2][i]);break;
 				}
 			}
 			printf("Extracting '%s' to '%s' with %d\r\n",argv[1],dir,option);
-			returnValue=prExportDatOpt(argv[1],dir,"resources.xml",(char)option);
-			printf("Result: %s (%d)\r\n",array[-returnValue],returnValue);
+			returnValue=prExportDatOpt(argv[1],dir,RES_XML_RESOURC_XML,(char)option);
+			printf(PR_TEXT_RESULT,array[-returnValue],returnValue);
 		}	break;
 		case 'd': {// get type of file.dat
 			char array[14][65]={
@@ -210,7 +195,7 @@ int main(int argc, char* argv[]) {
 				"Pop2 dat files"};
 			printf("Classifing '%s'\r\n",argv[1]);
 			returnValue=prVerifyDatType(argv[1]);
-			printf("Result: %s (%d)\r\n",array[2+returnValue],returnValue);
+			printf(PR_TEXT_RESULT,array[2+returnValue],returnValue);
 		}	break;
 		case 'c': { // extracted files + resource.xml --> files.dat
 			char array[6][39]={
@@ -224,15 +209,15 @@ int main(int argc, char* argv[]) {
 				for (i=2;argv[2][i];i++) {
 					switch (argv[2][i]) {
 						case 'r':option&=0xFE;break;
-						default:printf("Found invalid option '%c', skiping . . .\r\n",argv[2][i]);break;
+						default:printf(PR_TEXT_SKIPING,argv[2][i]);break;
 					}
 				}
 			printf("Compiling '%s' from '%s' with %d\r\n",argv[1],dir,option);
-			returnValue=prImportDatOpt(argv[1],dir,"resources.xml",(char)option);
+			returnValue=prImportDatOpt(argv[1],dir,RES_XML_RESOURC_XML,(char)option);
 			if (returnValue>=0) {
-				printf("Result: %s (%d)\r\n",array[-returnValue],returnValue);
+				printf(PR_TEXT_RESULT,array[-returnValue],returnValue);
 			} else {
-				printf("Result: %d files with errors\r\n",returnValue);
+				printf(PR_TEXT_RESULT_ERR,returnValue);
 			}
 		} break;
 		default:
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index c3c4a0b..b3aa2b5 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -79,6 +79,7 @@ void workTag(const tTag* t, tResource* r[]) {
 	//Declare variables
 	unsigned short id;
 	unsigned short size;
+	int i;
 
 	id=(unsigned short)ptoi(t->value);
 
@@ -89,28 +90,12 @@ void workTag(const tTag* t, tResource* r[]) {
 	if (r[id]==NULL) return;
 
 	//Get type and palette from tag
-	//TODO: send it to a define
 	if (t->itemtype==NULL) {
 		r[id]->type=0;
-	} else if (equalsIgnoreCase(t->itemtype,"image")) {
-		r[id]->type=2;
-	} else if (equalsIgnoreCase(t->itemtype,"palette")) {
-		r[id]->type=6;
-	} else if (equalsIgnoreCase(t->itemtype,"level")) {
-		r[id]->type=1;
-	} else if (equalsIgnoreCase(t->itemtype,"wave")) {
-		r[id]->type=3;
-	} else if (equalsIgnoreCase(t->itemtype,"midi")) {
-		r[id]->type=4;
-	} else if (equalsIgnoreCase(t->itemtype,"unknown")) {
-		r[id]->type=5;
-	} else if (equalsIgnoreCase(t->itemtype,"pcspeaker")) {
-		r[id]->type=7;
-	} else if (equalsIgnoreCase(t->itemtype,"raw")) {
-		r[id]->type=0;
-	}	else {
-		r[id]->type=(char)atoi(t->itemtype); //If error it returns 0 and the verifyHeader will try to detect the type
+	} else {
+		for (i=0;i<8;i++) if (equalsIgnoreCase(t->itemtype,getExtDesc(i))) {r[id]->type=i;break;}
 	}
+	if (i==8) r[id]->type=(char)atoi(t->itemtype); //If error it returns 0 and the verifyHeader will try to detect the type
 	r[id]->palette=(unsigned short)ptoi(t->palette); //Transforms the char* palette into a short ID value, if 0 or error no palette is needed
 
 	//get external and copy it to the resource path
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 1d7c120..2591faa 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -41,7 +41,6 @@ resources.c: Princed Resources : Resource Handler
 #include "pr.h"
 #include "xml.h"
 #include "xmlsearch.h"
-#include "parser.h"
 #include "disk.h"
 #include "memory.h"
 #include "resources.h"
@@ -84,7 +83,7 @@ char verifyWaveHeader(char* array, int size) {
 
 char verifySpeakerHeader(char* array, int size) {
 	return
-		(size>1)&&(array[1]==0x00)
+		(size>2)&&(array[1]==0x00)
 	;
 }
 
@@ -98,48 +97,19 @@ char verifyHeader(char* array, int size) {
 	return 05;
 }
 
+const char* getExtDesc(int type) {
+	static const char extarraydesc[8][10]={"raw","level","image","wave","midi","unknown","palette","pcspeaker"};
+	return extarraydesc[type];
+}
 
 /***************************************************************\
 |                      Parsing resource file                    |
 \***************************************************************/
 
-#if 0
-//Parse line
-void parseResource(tResource* r[], char* line) {
-	//declare variables
-	int                i=0;
-	int                k=0;
-	unsigned short int id,ty;
-
-	//Begin parsing
-	for (;!(line[k]=='\r'||line[k]=='\n'||(!line[k]));k++);
-	line[k]=0;
-
-	if (getNumberToken(line,&id,' ',&i,6)) {
-		r[id]=(tResource*)malloc(sizeof(tResource));
-		getNumberToken(line,&(*(r[id])).size,' ',&i,6);
-		getNumberToken(line,&(*(r[id])).offset,' ',&i,6);
-		getUpperToken(line,(*(r[id])).file,' ',&i,12);
-		if (getNumberToken(line,&ty,' ',&i,3)) {
-			(*(r[id])).desc=(char*)malloc(255);
-			if (getToken(line,(*(r[id])).desc,'#',&i,255)) {
-				(*(r[id])).coms=(char*)malloc(1023);
-				if (!getToken(line,(*(r[id])).coms,0,&i,1023)) {
-					free ((*(r[id])).coms);
-					(*(r[id])).coms=NULL;
-				}
-			}
-		} else {
-			(*(r[id])).desc=NULL;
-		}
-		(*(r[id])).type=(char)ty;
-	}
-}
-#endif
-
+//Initializes the resource table
 void emptyTable(tResource* r[]) {
 	int i=0;
-	for (;i<65536;i++) r[i]=NULL;
+	for (;i<MAX_RES_COUNT;i++) r[i]=NULL;
 }
 
 //parse file
@@ -155,127 +125,6 @@ char parseFile(char* vFile, char* datFile, tResource* r[]) {
 	freeTagStructure(tree);
 
 	return 0;
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	char parsing=0;
-	char line[MAX_LINE_SIZE];
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	FILE* fp;
-
-	//empty resource array
-	emptyTable(r);
-
-	//parse file
-	if ((fp=fopen(vFile,"rt"))!=NULL) {
-		while (fgets(line,MAX_LINE_SIZE,fp)!=NULL) {
-			if (parsing) {
-				if (equals(line,E)) {
-					parsing=0;
-				} else {
-					parseResource(r,line);
-				}
-			} else {
-				if (equals(line,B)) parsing=1;
-			}
-		}
-		fclose(fp);
-		return 1;
-	} else {
-		return 0;
-	}
-#endif
-}
-
-//generate file
-char generateFile(char* vFile,tResource* r[]) {
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	FILE* fp;
-	FILE* source;
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	char coms[MAX_LINE_SIZE];
-	char line[MAX_LINE_SIZE];
-	char none[]="";
-	char parsing=0;
-	int id=0;
-
-	if ((fp=fopen("res.tmp","wt"))!=NULL) {
-		//insert headers
-		if ((source=fopen(vFile,"rt"))!=NULL) {
-			while ((parsing!=2)&&(fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				if (parsing) {
-					if (equals(line,E)) {
-						parsing=2;
-					}
-				} else {
-					if (equals(line,B)) {
-						parsing=1;
-					} else {
-						fputs(line,fp);
-					}
-				}
-			}
-		}
-
-		//insert main body file
-		fputs(B,fp);
-		fputs("\n",fp);
-
-		for (;id<65536;id++) {
-			if (r[id]!=NULL) {
-				if (1||((*(r[id])).desc==NULL)) { //todo see this line
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms,none);
-					} else {
-						sprintf(coms," #",(*(r[id])).coms);
-					}
-				} else {
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms," %s",(*(r[id])).desc);
-					} else {
-						sprintf(coms," %s#%s",(*(r[id])).desc,(*(r[id])).coms);
-					}
-				}
-				sprintf(line,"<item itemtype=\"%d\" value=\"%d\" file=\"%s\" external=\"res%05d.bmp\">Res %d</item>\n",
-					(*(r[id])).type,
-					id,
-				//(*(r[id])).size,
-				//(*(r[id])).offset,
-				(*(r[id])).file,
-				id,id
-				//,
-				//coms
-				);
-				fputs(line,fp);
-			}
-		}
-		fputs("\n",fp);
-		fputs(E,fp);
-
-		//insert footers
-		if (source!=NULL) {
-			while ((parsing==2) && (fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				fputs(line,fp);
-			}
-			fclose(source);
-		}
-		fclose(fp);
-		remove(vFile);
-		rename("res.tmp",vFile);
-		return 1;
-	} else {
-		return 0;
-	}
-#else
-	//New code ignores this function (resources.xml is read only)
-	return 1;
-#endif
 }
 
 //Resources output to xml functions
@@ -300,7 +149,7 @@ void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char
 	}
 	//TODO: set itemtype in words
 	fprintf(unknownXmlFile,RES_XML_UNKNOWN_ITEM,
-		id,id,ext,type,id
+		id,id,ext,getExtDesc(type),id
 	); //To the xml output
 }
 
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 1d7c120..2591faa 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -41,7 +41,6 @@ resources.c: Princed Resources : Resource Handler
 #include "pr.h"
 #include "xml.h"
 #include "xmlsearch.h"
-#include "parser.h"
 #include "disk.h"
 #include "memory.h"
 #include "resources.h"
@@ -84,7 +83,7 @@ char verifyWaveHeader(char* array, int size) {
 
 char verifySpeakerHeader(char* array, int size) {
 	return
-		(size>1)&&(array[1]==0x00)
+		(size>2)&&(array[1]==0x00)
 	;
 }
 
@@ -98,48 +97,19 @@ char verifyHeader(char* array, int size) {
 	return 05;
 }
 
+const char* getExtDesc(int type) {
+	static const char extarraydesc[8][10]={"raw","level","image","wave","midi","unknown","palette","pcspeaker"};
+	return extarraydesc[type];
+}
 
 /***************************************************************\
 |                      Parsing resource file                    |
 \***************************************************************/
 
-#if 0
-//Parse line
-void parseResource(tResource* r[], char* line) {
-	//declare variables
-	int                i=0;
-	int                k=0;
-	unsigned short int id,ty;
-
-	//Begin parsing
-	for (;!(line[k]=='\r'||line[k]=='\n'||(!line[k]));k++);
-	line[k]=0;
-
-	if (getNumberToken(line,&id,' ',&i,6)) {
-		r[id]=(tResource*)malloc(sizeof(tResource));
-		getNumberToken(line,&(*(r[id])).size,' ',&i,6);
-		getNumberToken(line,&(*(r[id])).offset,' ',&i,6);
-		getUpperToken(line,(*(r[id])).file,' ',&i,12);
-		if (getNumberToken(line,&ty,' ',&i,3)) {
-			(*(r[id])).desc=(char*)malloc(255);
-			if (getToken(line,(*(r[id])).desc,'#',&i,255)) {
-				(*(r[id])).coms=(char*)malloc(1023);
-				if (!getToken(line,(*(r[id])).coms,0,&i,1023)) {
-					free ((*(r[id])).coms);
-					(*(r[id])).coms=NULL;
-				}
-			}
-		} else {
-			(*(r[id])).desc=NULL;
-		}
-		(*(r[id])).type=(char)ty;
-	}
-}
-#endif
-
+//Initializes the resource table
 void emptyTable(tResource* r[]) {
 	int i=0;
-	for (;i<65536;i++) r[i]=NULL;
+	for (;i<MAX_RES_COUNT;i++) r[i]=NULL;
 }
 
 //parse file
@@ -155,127 +125,6 @@ char parseFile(char* vFile, char* datFile, tResource* r[]) {
 	freeTagStructure(tree);
 
 	return 0;
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	char parsing=0;
-	char line[MAX_LINE_SIZE];
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	FILE* fp;
-
-	//empty resource array
-	emptyTable(r);
-
-	//parse file
-	if ((fp=fopen(vFile,"rt"))!=NULL) {
-		while (fgets(line,MAX_LINE_SIZE,fp)!=NULL) {
-			if (parsing) {
-				if (equals(line,E)) {
-					parsing=0;
-				} else {
-					parseResource(r,line);
-				}
-			} else {
-				if (equals(line,B)) parsing=1;
-			}
-		}
-		fclose(fp);
-		return 1;
-	} else {
-		return 0;
-	}
-#endif
-}
-
-//generate file
-char generateFile(char* vFile,tResource* r[]) {
-
-//Old code (will be removed soon)
-#if 0
-	//declare variables
-	FILE* fp;
-	FILE* source;
-	char B[]=BEGIN_TABLE;
-	char E[]=END_TABLE;
-	char coms[MAX_LINE_SIZE];
-	char line[MAX_LINE_SIZE];
-	char none[]="";
-	char parsing=0;
-	int id=0;
-
-	if ((fp=fopen("res.tmp","wt"))!=NULL) {
-		//insert headers
-		if ((source=fopen(vFile,"rt"))!=NULL) {
-			while ((parsing!=2)&&(fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				if (parsing) {
-					if (equals(line,E)) {
-						parsing=2;
-					}
-				} else {
-					if (equals(line,B)) {
-						parsing=1;
-					} else {
-						fputs(line,fp);
-					}
-				}
-			}
-		}
-
-		//insert main body file
-		fputs(B,fp);
-		fputs("\n",fp);
-
-		for (;id<65536;id++) {
-			if (r[id]!=NULL) {
-				if (1||((*(r[id])).desc==NULL)) { //todo see this line
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms,none);
-					} else {
-						sprintf(coms," #",(*(r[id])).coms);
-					}
-				} else {
-					if ((*(r[id])).coms==NULL) {
-						sprintf(coms," %s",(*(r[id])).desc);
-					} else {
-						sprintf(coms," %s#%s",(*(r[id])).desc,(*(r[id])).coms);
-					}
-				}
-				sprintf(line,"<item itemtype=\"%d\" value=\"%d\" file=\"%s\" external=\"res%05d.bmp\">Res %d</item>\n",
-					(*(r[id])).type,
-					id,
-				//(*(r[id])).size,
-				//(*(r[id])).offset,
-				(*(r[id])).file,
-				id,id
-				//,
-				//coms
-				);
-				fputs(line,fp);
-			}
-		}
-		fputs("\n",fp);
-		fputs(E,fp);
-
-		//insert footers
-		if (source!=NULL) {
-			while ((parsing==2) && (fgets(line,MAX_LINE_SIZE,source)!=NULL)) {
-				fputs(line,fp);
-			}
-			fclose(source);
-		}
-		fclose(fp);
-		remove(vFile);
-		rename("res.tmp",vFile);
-		return 1;
-	} else {
-		return 0;
-	}
-#else
-	//New code ignores this function (resources.xml is read only)
-	return 1;
-#endif
 }
 
 //Resources output to xml functions
@@ -300,7 +149,7 @@ void AddToUnknownXml(const char* vFiledat,unsigned short id,const char* ext,char
 	}
 	//TODO: set itemtype in words
 	fprintf(unknownXmlFile,RES_XML_UNKNOWN_ITEM,
-		id,id,ext,type,id
+		id,id,ext,getExtDesc(type),id
 	); //To the xml output
 }
 
diff --git a/PR/src/pr.dsp b/PR/src/pr.dsp
index 8693cb1..3d9f0e0 100644
--- a/PR/src/pr.dsp
+++ b/PR/src/pr.dsp
@@ -211,6 +211,7 @@ DEP_CPP_COMPI=\
 	".\include\disk.h"\
 	".\include\mid.h"\
 	".\include\pal.h"\
+	".\include\pr.h"\
 	".\include\resources.h"\
 	".\include\wav.h"\
 	
@@ -267,23 +268,11 @@ DEP_CPP_EXTRA=\
 	".\include\extract.h"\
 	".\include\mid.h"\
 	".\include\pal.h"\
+	".\include\pr.h"\
 	".\include\resources.h"\
 	".\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=.\parser.c
-
 !IF  "$(CFG)" == "tasks - Win32 Release"
 
 !ELSEIF  "$(CFG)" == "tasks - Win32 Debug"
@@ -321,6 +310,7 @@ DEP_CPP_PR_C10=\
 SOURCE=.\resources.c
 DEP_CPP_RESOU=\
 	".\include\compress.h"\
+	".\include\disk.h"\
 	".\include\pr.h"\
 	".\include\resources.h"\
 	".\include\xml.h"\
@@ -427,10 +417,6 @@ SOURCE=.\include\pal.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\include\parser.h
-# End Source File
-# Begin Source File
-
 SOURCE=.\include\pr.h
 # End Source File
 # Begin Source File
@@ -454,5 +440,45 @@ SOURCE=.\include\xml.h
 SOURCE=include\xmlsearch.h
 # End Source File
 # End Group
+# Begin Group "Text Files"
+
+# PROP Default_Filter "*.txt"
+# Begin Source File
+
+SOURCE=..\changelog.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\gpl.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\readme.coders.txt
+# End Source File
+# Begin Source File
+
+SOURCE=..\readme.txt
+# End Source File
+# End Group
+# Begin Group "Other Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\Makefile
+# End Source File
+# Begin Source File
+
+SOURCE=.\winbins\pr.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\bin\resources.sample.xml
+# End Source File
+# Begin Source File
+
+SOURCE=.\bin\resources.xml
+# End Source File
+# End Group
 # End Target
 # End Project
diff --git a/PR/src/xml.c b/PR/src/xml.c
index 8bc291b..5f91923 100644
--- a/PR/src/xml.c
+++ b/PR/src/xml.c
@@ -376,7 +376,7 @@ tTag* makeTree(char** p,char* name, int* error,tTag* father) {
 			if (str==NULL) {*error=2;return NULL;}
 
 			//Set variable and destroy old variables
-			sprintf(str,"%s%c%s",father->external,DIR_SEPARATOR,tag->external);
+			sprintf(str,"%s/%s",father->external,tag->external);
 			free(tag->external);
 			if ((*(father->external))==0) free(father->external);
 			tag->external=str;