git » fp-git.git » commit 9750c19

fixed header dependencies and restructured sources

author ecalot
2005-06-13 18:08:21 UTC
committer ecalot
2005-06-13 18:08:21 UTC
parent e90fdd133c27d8e35eb301221eb73af4f59d8780

fixed header dependencies and restructured sources

PR/src/Makefile +27 -27
PR/src/console/main.c +3 -5
PR/src/include/autodetect.h +5 -26
PR/src/include/bitmap.h +1 -1
PR/src/include/bmp.h +1 -1
PR/src/include/common.h +1 -1
PR/src/include/dat.h +4 -19
PR/src/include/disk.h +1 -13
PR/src/include/export.h +3 -2
PR/src/include/idlist.h +5 -26
PR/src/include/import.h +3 -3
PR/src/include/mid.h +1 -1
PR/src/include/pal.h +1 -2
PR/src/include/parse.h +4 -1
PR/src/include/plv.h +1 -1
PR/src/include/png.h +1 -1
PR/src/include/reslist.h +31 -3
PR/src/include/search.h +1 -1
PR/src/include/tree.h +5 -26
PR/src/include/types.h +31 -3
PR/src/include/unknown.h +5 -26
PR/src/include/wav.h +1 -1
PR/src/lib/actions/classify.c +2 -3
PR/src/lib/formats/bmp.c +2 -2
PR/src/lib/formats/mid.c +2 -2
PR/src/lib/formats/pal.c +3 -5
PR/src/lib/formats/plv.c +0 -1
PR/src/lib/layers/autodetect.c +1 -18
PR/src/lib/layers/dat.c +12 -0
PR/src/lib/layers/disk.c +9 -2
PR/src/lib/layers/idlist.c +1 -18
PR/src/lib/xml/parse.c +7 -2
PR/src/lib/xml/search.c +2 -2
PR/src/lib/xml/tree.c +1 -18
PR/src/lib/xml/unknown.c +1 -18

diff --git a/PR/src/Makefile b/PR/src/Makefile
index 3c8a63e..e343cca 100644
--- a/PR/src/Makefile
+++ b/PR/src/Makefile
@@ -113,31 +113,31 @@ $(XMLFILE): xml/resources.xml
 	$(MAKEDIR) bin
 	$(COPY) xml/resources.xml $(XMLFILE)
 
-.import.o: lib/actions/import.c
+.import.o: lib/actions/import.c include/bmp.h include/common.h include/dat.h include/disk.h include/import.h include/memory.h include/mid.h include/pal.h include/plv.h include/wav.h
 	$(INFO) Compiling import module...
 	$(CC) $(OPTIONS) -c lib/actions/import.c -o $@
 
-.memory.o: lib/layers/memory.c
+.memory.o: lib/layers/memory.c include/memory.h
 	$(INFO) Compiling memory manager...
 	$(CC) $(OPTIONS) -c lib/layers/memory.c -o $@
 
-.export.o: lib/actions/export.c
+.export.o: lib/actions/export.c include/bmp.h include/common.h include/dat.h include/disk.h include/export.h include/memory.h include/mid.h include/pal.h include/plv.h include/reslist.h include/wav.h
 	$(INFO) Compiling export module...
 	$(CC) $(OPTIONS) -c lib/actions/export.c -o $@
 
-.list.o: lib/layers/list.c
+.list.o: lib/layers/list.c include/list.h
 	$(INFO) Compiling list implementation...
 	$(CC) $(OPTIONS) -c lib/layers/list.c -o $@
 
-.reslist.o: lib/layers/reslist.c
+.reslist.o: lib/layers/reslist.c include/memory.h include/reslist.h
 	$(INFO) Compiling resource list module...
 	$(CC) $(OPTIONS) -c lib/layers/reslist.c -o $@
 
-.compress.o: lib/compression/main.c
+.compress.o: lib/compression/main.c include/compress.h include/disk.h include/memory.h
 	$(INFO) Compiling main compression library...
 	$(CC) $(OPTIONS) -c lib/compression/main.c -o .compress.o -o $@
 
-.lzg_compress.o: lib/compression/lzg_compress.c
+.lzg_compress.o: lib/compression/lzg_compress.c include/compress.h
 	$(INFO) Compiling LZG compression module...
 	$(CC) $(OPTIONS) -c lib/compression/lzg_compress.c -o $@
 
@@ -145,84 +145,84 @@ $(XMLFILE): xml/resources.xml
 	$(INFO) Compiling RLE compression module...
 	$(CC) $(OPTIONS) -c lib/compression/rle_compress.c -o $@
 
-.lzg_uncompress.o: lib/compression/lzg_uncompress.c
+.lzg_uncompress.o: lib/compression/lzg_uncompress.c include/compress.h
 	$(INFO) Compiling LZG uncompression module...
 	$(CC) $(OPTIONS) -c lib/compression/lzg_uncompress.c -o $@
 
-.rle_uncompress.o: lib/compression/rle_uncompress.c
+.rle_uncompress.o: lib/compression/rle_uncompress.c include/compress.h
 	$(INFO) Compiling RLE uncompression module...
 	$(CC) $(OPTIONS) -c lib/compression/rle_uncompress.c -o $@
 
-.main.o: console/main.c
+.main.o: console/main.c include/common.h include/compress.h include/disk.h include/filedir.h include/getopt.h include/memory.h include/xmlparse.h
 	$(INFO) Compiling command parsing module for standard mode...
 	$(CC) $(OPTIONS) -c console/main.c -o $@
 
-.pr.o: lib/pr.c
+.pr.o: lib/pr.c include/classify.h include/common.h include/compress.h include/disk.h include/export.h include/import.h include/memory.h
 	$(INFO) Compiling main library primitives for both modes...
 	$(CC) $(OPTIONS) -c lib/pr.c -o $@
 	
-.filedir.o: console/filedir.c
+.filedir.o: console/filedir.c include/disk.h include/memory.h include/xmlsearch.h
 	$(INFO) Compiling directory and recursive file reading module for standard mode...
 	$(CC) $(OPTIONS) -c console/filedir.c -o $@
 
-.resources.o: lib/resources.c
+.resources.o: lib/resources.c include/common.h include/compress.h include/disk.h include/memory.h include/resources.h include/xmlsearch.h
 	$(INFO) Compiling resource manager module...
 	$(CC) $(OPTIONS) -c lib/resources.c -o $@
 
-.classify.o: lib/actions/classify.c
+.classify.o: lib/actions/classify.c include/classify.h include/common.h include/dat.h include/disk.h include/memory.h include/resources.h
 	$(INFO) Compiling classification module...
 	$(CC) $(OPTIONS) -c lib/actions/classify.c -o $@
 
-.parse.o: lib/xml/parse.c
+.parse.o: lib/xml/parse.c include/common.h include/disk.h include/memory.h include/xmlparse.h
 	$(INFO) Compiling XML parsing module...
 	$(CC) $(OPTIONS) -c lib/xml/parse.c -o $@
 
-.search.o: lib/xml/search.c
+.search.o: lib/xml/search.c include/common.h include/memory.h include/reslist.h include/xmlparse.h include/xmlsearch.h
 	$(INFO) Compiling XML search features...
 	$(CC) $(OPTIONS) -c lib/xml/search.c -o $@
 
-.disk.o: lib/layers/disk.c
+.disk.o: lib/layers/disk.c include/common.h include/direntwin.h include/disk.h include/memory.h include/xmlparse.h
 	$(INFO) Compiling disk access library...
 	$(CC) $(OPTIONS) -c lib/layers/disk.c -o $@
 
-.dat.o: lib/layers/dat.c
+.dat.o: lib/layers/dat.c include/common.h include/dat.h include/disk.h include/reslist.h
 	$(INFO) Compiling DAT editing library...
 	$(CC) $(OPTIONS) -c lib/layers/dat.c -o $@
 
-.bmp.o: lib/formats/bmp.c
+.bmp.o: lib/formats/bmp.c include/bmp.h include/common.h include/dat.h include/disk.h include/memory.h
 	$(INFO) Compiling bitmap files support \(bmp\)...
 	$(CC) $(OPTIONS) -c lib/formats/bmp.c -o $@
 
-.mid.o: lib/formats/mid.c
+.mid.o: lib/formats/mid.c include/common.h include/dat.h include/disk.h include/memory.h include/mid.h
 	$(INFO) Compiling MIDI audio files support \(mid\)...
 	$(CC) $(OPTIONS) -c lib/formats/mid.c -o $@
 
-.plv.o: lib/formats/plv.c
+.plv.o: lib/formats/plv.c include/dat.h include/disk.h include/memory.h include/plv.h
 	$(INFO) Compiling prince level files support \(plv\)...
 	$(CC) $(OPTIONS) -c lib/formats/plv.c -o $@
 
-.pal.o: lib/formats/pal.c
+.pal.o: lib/formats/pal.c include/dat.h include/disk.h include/memory.h include/pal.h include/resources.h
 	$(INFO) Compiling JASC palette support \(pal\)...
 	$(CC) $(OPTIONS) -c lib/formats/pal.c -o $@
 
-.wav.o: lib/formats/wav.c
+.wav.o: lib/formats/wav.c include/dat.h include/disk.h include/wav.h
 	$(INFO) Compiling digital wave audio support \(wav\)...
 	$(CC) $(OPTIONS) -c lib/formats/wav.c -o $@
 
-.dirent.o: ports/dirent.c
+.dirent.o: ports/dirent.c include/direntwin.h
 	$(INFO) Porting the dirent structure...
 	$(CC) $(OPTIONS) -c ports/dirent.c -o $@
 	
-.getopt.o: ports/getopt.c
+.getopt.o: ports/getopt.c include/getopt.h
 	$(INFO) Porting the Unix-like getopt function \(first part\)...
 	$(CC) $(OPTIONS) -c ports/getopt.c -o $@
 
-.getopt1.o: ports/getopt1.c
+.getopt1.o: ports/getopt1.c include/getopt.h
 	$(INFO) Porting the Unix-like getopt function \(second part\)...
 	$(CC) $(OPTIONS) -c ports/getopt1.c -o $@
 
 #python
-.python.o: addons/python/python.c
+.python.o: addons/python/python.c include/pr.h
 	$(INFO) Building the python interfaces
 	$(CC) -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -fPIC -I/usr/include/python2.3 -c addons/python/python.c $(INCLUDE) -o $@
 	
diff --git a/PR/src/console/main.c b/PR/src/console/main.c
index 8848f97..6173290 100644
--- a/PR/src/console/main.c
+++ b/PR/src/console/main.c
@@ -147,11 +147,9 @@ int main (int argc, char **argv) {
 	/* At least one of these options must be selected, if not, the user needs help! */
 	if (!(hasFlag(import_flag|export_flag|classify_flag))) setFlag(help_flag);
 
-	/* Show about or cgi stuff */
-	if (hasFlag(cgi_flag)) {
-		fprintf(outputStream,PR_CGI_TEXT1);
-		fprintf(outputStream,PR_ABOUT);
-	}
+	/* Show cgi and about stuff */
+	if (hasFlag(cgi_flag)) fprintf(outputStream,PR_CGI_TEXT1);
+	fprintf(outputStream,PR_ABOUT);
 
 	/* Show version screen if requested */
 	if (hasFlag(version_flag)) {
diff --git a/PR/src/include/autodetect.h b/PR/src/include/autodetect.h
index 01397c2..86388bd 100644
--- a/PR/src/include/autodetect.h
+++ b/PR/src/include/autodetect.h
@@ -45,22 +45,11 @@ resources.h: Princed Resources : Resource Handler headers
 /* File extensions */
 
 #define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
-#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
 
-/* Item Types */
-
-#define RES_TYPE_RAW          0
-#define RES_TYPE_LEVEL        1
-#define RES_TYPE_IMAGE        2
-#define RES_TYPE_WAVE         3
-#define RES_TYPE_MIDI         4
-#define RES_TYPE_BINARY       5
-#define RES_TYPE_PALETTE      6
-#define RES_TYPE_PCSPEAKER    7
-
-#define RES_TYPECOUNT         8
-
-#include "dat.h"
+/* Includes */
+#include <stdio.h>
+#include "xmlparse.h"
+#include "reslist.h"
 
 /* Id list for partial manipulation */
 typedef enum {eString,eId,eIdValue}tResLocationType;
@@ -83,12 +72,8 @@ int  partialListActive();
 int isInThePartialList(const char* vFile, tResourceId id);
 void freePartialList();
 
-/* Includes */
-#include <stdio.h>
-#include "xmlparse.h"
-
 /* Verify  header */
-int verifyHeader(const unsigned char* array, int size);
+tResourceType verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -101,12 +86,6 @@ int verifyHeader(const unsigned char* array, int size);
 	 07 Internal Speaker Sounds
 */
 
-#include "dat.h" /* tResource */
-#include "reslist.h" /* tResourceList */
-
-/* CheckSum verification */
-int checkSum(const unsigned char* data,int size);
-
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
diff --git a/PR/src/include/bitmap.h b/PR/src/include/bitmap.h
index 770abb3..0b54ae1 100644
--- a/PR/src/include/bitmap.h
+++ b/PR/src/include/bitmap.h
@@ -35,7 +35,7 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "resources.h"
+#include "dat.h"
 #include "compress.h"
 
 #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
diff --git a/PR/src/include/bmp.h b/PR/src/include/bmp.h
index 770abb3..0b54ae1 100644
--- a/PR/src/include/bmp.h
+++ b/PR/src/include/bmp.h
@@ -35,7 +35,7 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "resources.h"
+#include "dat.h"
 #include "compress.h"
 
 #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index a35c085..2ee19a3 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -65,7 +65,7 @@ common.h: Princed Resources : Defines and prototypes common to all PR code
 \***************************************************************/
 
 #define PR_URL                    "http://www.princed.com.ar"
-#define PR_VERSION                "v1.1-rc2"
+#define PR_VERSION                "v1.1-rc3"
 #define PR_COPY                   "(c) Copyright 2003 - 2005 Princed Development Team"
 
 /***************************************************************\
diff --git a/PR/src/include/dat.h b/PR/src/include/dat.h
index 7009dcf..5b16522 100644
--- a/PR/src/include/dat.h
+++ b/PR/src/include/dat.h
@@ -34,25 +34,7 @@ dat.h: Princed Resources : DAT library headers
 #ifndef _DAT_H_
 #define _DAT_H_
 
-/* types */
-typedef struct {
-	unsigned short int value;
-	char               index[5];
-}tResourceId;
-
-typedef struct {
-	tResourceId        id;
-	tResourceId        palette;
-	long int           size;
-	unsigned long int  offset; /* Used internally in dat.c to remember the offset */
-	unsigned char      number; /* Used for level number */
-	char               type;
-	char*              desc;
-	char*              name;
-	char*              path;
-	unsigned char*     data;
-	unsigned long      flags;
-}tResource;
+#include "reslist.h" /* tResource* */
 
 typedef enum {
 	none=0,
@@ -62,6 +44,9 @@ typedef enum {
 
 tPopVersion mReadGetVersion();
 
+/* CheckSum verification */
+int checkSum(const unsigned char* data,int size);
+
 #define PR_DAT_INCLUDE_DATREAD
 #define PR_DAT_INCLUDE_DATWRITE
 
diff --git a/PR/src/include/disk.h b/PR/src/include/disk.h
index 2a78ae9..773ae51 100644
--- a/PR/src/include/disk.h
+++ b/PR/src/include/disk.h
@@ -45,8 +45,6 @@ disk.h: Princed Resources : Disk Access & File handling functions headers
 #define DISK_TERM_MANIPULATION
 /* #define DISK_ALLWAYS_FORCE   */
 
-/* 64 Kb */
-#define SIZE_OF_FILE     (1200*1024)
 #define MAX_FILENAME_SIZE        260
 
 /* Path defines */
@@ -62,17 +60,6 @@ typedef enum {eFile,eDirectory,eNotFound}whatIs;
 #define charToUpper(a) ((a)&0xDF)
 #define isDirSep(a,i) ((a[i]=='\\')||(a[i]=='/'))
 
-typedef struct tOpenFiles {
-	struct tOpenFiles* next;
-	FILE* file;
-	char* name;
-	unsigned char* content;
-	long int size;
-}tOpenFiles;
-
-char mDiskVealidateFileHeader(unsigned char* text, int size, FILE* fp);
-/* char mSaveRaw      (const char* vFile,const unsigned char* output, int size); */
-#define mSaveRaw(f,d,s,optionflag,backup) writeData(d,0,f,s,optionflag,backup)
 #define writeCloseOk(a,b,c) writeClose(a,0,b,c)
 #define writeCloseDelete(a,b,c) writeClose(a,1,b,c)
 int  writeData     (const unsigned char* data, int ignoreChars, char* vFileext, int size, int optionflag,const char* backupExtension);
@@ -113,3 +100,4 @@ int macfwritel(const void* var,FILE* file);
 #endif
 
 #endif
+
diff --git a/PR/src/include/export.h b/PR/src/include/export.h
index 3b89e9a..ebd24de 100644
--- a/PR/src/include/export.h
+++ b/PR/src/include/export.h
@@ -19,8 +19,8 @@
 */
 
 /*
-extract.h: Princed Resources : DAT Extractor headers
-\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+export.h: Princed Resources : DAT Extractor headers
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 24 Aug 2003
 
@@ -38,3 +38,4 @@ extract.h: Princed Resources : DAT Extractor headers
 
 int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int task, const char* vDatFileName, const char* vDatAuthor,const char* backupExtension);
 #endif
+
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h
index 01397c2..86388bd 100644
--- a/PR/src/include/idlist.h
+++ b/PR/src/include/idlist.h
@@ -45,22 +45,11 @@ resources.h: Princed Resources : Resource Handler headers
 /* File extensions */
 
 #define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
-#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
 
-/* Item Types */
-
-#define RES_TYPE_RAW          0
-#define RES_TYPE_LEVEL        1
-#define RES_TYPE_IMAGE        2
-#define RES_TYPE_WAVE         3
-#define RES_TYPE_MIDI         4
-#define RES_TYPE_BINARY       5
-#define RES_TYPE_PALETTE      6
-#define RES_TYPE_PCSPEAKER    7
-
-#define RES_TYPECOUNT         8
-
-#include "dat.h"
+/* Includes */
+#include <stdio.h>
+#include "xmlparse.h"
+#include "reslist.h"
 
 /* Id list for partial manipulation */
 typedef enum {eString,eId,eIdValue}tResLocationType;
@@ -83,12 +72,8 @@ int  partialListActive();
 int isInThePartialList(const char* vFile, tResourceId id);
 void freePartialList();
 
-/* Includes */
-#include <stdio.h>
-#include "xmlparse.h"
-
 /* Verify  header */
-int verifyHeader(const unsigned char* array, int size);
+tResourceType verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -101,12 +86,6 @@ int verifyHeader(const unsigned char* array, int size);
 	 07 Internal Speaker Sounds
 */
 
-#include "dat.h" /* tResource */
-#include "reslist.h" /* tResourceList */
-
-/* CheckSum verification */
-int checkSum(const unsigned char* data,int size);
-
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
diff --git a/PR/src/include/import.h b/PR/src/include/import.h
index 97014a7..54d8803 100644
--- a/PR/src/include/import.h
+++ b/PR/src/include/import.h
@@ -19,7 +19,7 @@
 */
 
 /*
-compile.h: Princed Resources : DAT Compiler headers
+import.h: Princed Resources : DAT Compiler headers
 \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 24 Aug 2003
@@ -31,8 +31,8 @@ compile.h: Princed Resources : DAT Compiler headers
   DO NOT remove this copyright notice
 */
 
-#ifndef _COMPILE_H_
-#define _COMPILE_H_
+#ifndef _IMPORT_H_
+#define _IMPORT_H_
 
 #include <stdio.h>
 #include "resources.h"
diff --git a/PR/src/include/mid.h b/PR/src/include/mid.h
index 6f9b613..3a4e1c5 100644
--- a/PR/src/include/mid.h
+++ b/PR/src/include/mid.h
@@ -35,7 +35,7 @@ mid.h: Princed Resources : MIDI files support headers
 #define _MID_H_
 
 #include <stdio.h>
-#include "resources.h"
+#include "dat.h"
 
 int mFormatImportMid(tResource *res);
 int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension);
diff --git a/PR/src/include/pal.h b/PR/src/include/pal.h
index 30ce06c..6991db7 100644
--- a/PR/src/include/pal.h
+++ b/PR/src/include/pal.h
@@ -34,8 +34,7 @@ pal.h: Princed Resources : JASC PAL files support headers
 #ifndef _PAL_H_
 #define _PAL_H_
 
-#include "compress.h"
-#include "resources.h"
+#include "dat.h"
 #include <stdio.h>
 
 #define PAL_HEADER "JASC-PAL\r\n0100\r\n16\r\n"
diff --git a/PR/src/include/parse.h b/PR/src/include/parse.h
index 18cf1f6..3683cd8 100644
--- a/PR/src/include/parse.h
+++ b/PR/src/include/parse.h
@@ -35,8 +35,11 @@ xmlparse.h: Princed Resources : xml handling functions headers
 #define _XMLPARSE_H_
 
 int equalsIgnoreCase(const char s1[],const char s2[]);
+const char* getExtDesc(int type);
 
 /* Constants */
-#define MAX_VALUE_SIZE 3000
+#define MAX_VALUE_SIZE        3000
+#define RES_TYPECOUNT         8
+#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
 
 #endif
diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h
index b2de179..b18aadb 100644
--- a/PR/src/include/plv.h
+++ b/PR/src/include/plv.h
@@ -61,7 +61,7 @@ plv.h: Princed Resources : PLV prince level files support headers
 */
 
 #include <stdio.h>
-#include "resources.h"
+#include "dat.h"
 #include "common.h" /* for PR_VERSION */
 
 int mFormatImportPlv(tResource *res);
diff --git a/PR/src/include/png.h b/PR/src/include/png.h
index 770abb3..0b54ae1 100644
--- a/PR/src/include/png.h
+++ b/PR/src/include/png.h
@@ -35,7 +35,7 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "resources.h"
+#include "dat.h"
 #include "compress.h"
 
 #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
diff --git a/PR/src/include/reslist.h b/PR/src/include/reslist.h
index d2a7ed9..8402aa4 100644
--- a/PR/src/include/reslist.h
+++ b/PR/src/include/reslist.h
@@ -35,11 +35,39 @@ reslist.h: Princed Resources : Resource list
 #define _RESLIST_H_
 
 #include "list.h" /* tList */
-
 #define tResourceList tList
 
-#include "dat.h" /* tResourceId & tResource */
-/* TODO: fix header dependencies */
+/* Item Types */
+
+typedef enum {
+RES_TYPE_RAW=0,
+RES_TYPE_LEVEL=1,
+RES_TYPE_IMAGE=2,
+RES_TYPE_WAVE=3,
+RES_TYPE_MIDI=4,
+RES_TYPE_BINARY=5,
+RES_TYPE_PALETTE=6,
+RES_TYPE_PCSPEAKER=7} tResourceType;
+
+/* types */
+typedef struct {
+	unsigned short int value;
+	char               index[5];
+}tResourceId;
+
+typedef struct {
+	tResourceId        id;
+	tResourceId        palette;
+	long int           size;
+	unsigned long int  offset; /* Used internally in dat.c to remember the offset */
+	unsigned char      number; /* Used for level number */
+	tResourceType      type;
+	char*              desc;
+	char*              name;
+	char*              path;
+	unsigned char*     data;
+	unsigned long      flags;
+}tResource;
 
 void printr(const tResource* record); /* for debug purposes */
 
diff --git a/PR/src/include/search.h b/PR/src/include/search.h
index bb69709..7bbb22d 100644
--- a/PR/src/include/search.h
+++ b/PR/src/include/search.h
@@ -41,7 +41,7 @@ xmlparse.h: Princed Resources : xml handling functions header file
 /* Includes */
 #include "common.h" /* tTag */
 #include "xmlparse.h"
-#include "resources.h"
+#include "reslist.h"
 
 void str5uppercpy (char* dst,const char* src);
 	
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index 01397c2..86388bd 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -45,22 +45,11 @@ resources.h: Princed Resources : Resource Handler headers
 /* File extensions */
 
 #define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
-#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
 
-/* Item Types */
-
-#define RES_TYPE_RAW          0
-#define RES_TYPE_LEVEL        1
-#define RES_TYPE_IMAGE        2
-#define RES_TYPE_WAVE         3
-#define RES_TYPE_MIDI         4
-#define RES_TYPE_BINARY       5
-#define RES_TYPE_PALETTE      6
-#define RES_TYPE_PCSPEAKER    7
-
-#define RES_TYPECOUNT         8
-
-#include "dat.h"
+/* Includes */
+#include <stdio.h>
+#include "xmlparse.h"
+#include "reslist.h"
 
 /* Id list for partial manipulation */
 typedef enum {eString,eId,eIdValue}tResLocationType;
@@ -83,12 +72,8 @@ int  partialListActive();
 int isInThePartialList(const char* vFile, tResourceId id);
 void freePartialList();
 
-/* Includes */
-#include <stdio.h>
-#include "xmlparse.h"
-
 /* Verify  header */
-int verifyHeader(const unsigned char* array, int size);
+tResourceType verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -101,12 +86,6 @@ int verifyHeader(const unsigned char* array, int size);
 	 07 Internal Speaker Sounds
 */
 
-#include "dat.h" /* tResource */
-#include "reslist.h" /* tResourceList */
-
-/* CheckSum verification */
-int checkSum(const unsigned char* data,int size);
-
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
diff --git a/PR/src/include/types.h b/PR/src/include/types.h
index d2a7ed9..8402aa4 100644
--- a/PR/src/include/types.h
+++ b/PR/src/include/types.h
@@ -35,11 +35,39 @@ reslist.h: Princed Resources : Resource list
 #define _RESLIST_H_
 
 #include "list.h" /* tList */
-
 #define tResourceList tList
 
-#include "dat.h" /* tResourceId & tResource */
-/* TODO: fix header dependencies */
+/* Item Types */
+
+typedef enum {
+RES_TYPE_RAW=0,
+RES_TYPE_LEVEL=1,
+RES_TYPE_IMAGE=2,
+RES_TYPE_WAVE=3,
+RES_TYPE_MIDI=4,
+RES_TYPE_BINARY=5,
+RES_TYPE_PALETTE=6,
+RES_TYPE_PCSPEAKER=7} tResourceType;
+
+/* types */
+typedef struct {
+	unsigned short int value;
+	char               index[5];
+}tResourceId;
+
+typedef struct {
+	tResourceId        id;
+	tResourceId        palette;
+	long int           size;
+	unsigned long int  offset; /* Used internally in dat.c to remember the offset */
+	unsigned char      number; /* Used for level number */
+	tResourceType      type;
+	char*              desc;
+	char*              name;
+	char*              path;
+	unsigned char*     data;
+	unsigned long      flags;
+}tResource;
 
 void printr(const tResource* record); /* for debug purposes */
 
diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h
index 01397c2..86388bd 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -45,22 +45,11 @@ resources.h: Princed Resources : Resource Handler headers
 /* File extensions */
 
 #define RES_FILE_EXTENSIONS   {"raw","plv","bmp","wav","mid","bin","pal","pcs"}
-#define RES_FILE_TYPES        {"autodetect","level","image","wave","midi","binary","palette","pcspeaker"}
 
-/* Item Types */
-
-#define RES_TYPE_RAW          0
-#define RES_TYPE_LEVEL        1
-#define RES_TYPE_IMAGE        2
-#define RES_TYPE_WAVE         3
-#define RES_TYPE_MIDI         4
-#define RES_TYPE_BINARY       5
-#define RES_TYPE_PALETTE      6
-#define RES_TYPE_PCSPEAKER    7
-
-#define RES_TYPECOUNT         8
-
-#include "dat.h"
+/* Includes */
+#include <stdio.h>
+#include "xmlparse.h"
+#include "reslist.h"
 
 /* Id list for partial manipulation */
 typedef enum {eString,eId,eIdValue}tResLocationType;
@@ -83,12 +72,8 @@ int  partialListActive();
 int isInThePartialList(const char* vFile, tResourceId id);
 void freePartialList();
 
-/* Includes */
-#include <stdio.h>
-#include "xmlparse.h"
-
 /* Verify  header */
-int verifyHeader(const unsigned char* array, int size);
+tResourceType verifyHeader(const unsigned char* array, int size);
 
 /*
 	Headers may be:
@@ -101,12 +86,6 @@ int verifyHeader(const unsigned char* array, int size);
 	 07 Internal Speaker Sounds
 */
 
-#include "dat.h" /* tResource */
-#include "reslist.h" /* tResourceList */
-
-/* CheckSum verification */
-int checkSum(const unsigned char* data,int size);
-
 /* Resources extras */
 void getFileName(char* vFileext,const char* vDirExt,const tResource* r,const char* vFiledat, const char* vDatFileName,int optionflag,const char* backupExtension);
 void getUpperFolder(char* aux, char* vFiledat);
diff --git a/PR/src/include/wav.h b/PR/src/include/wav.h
index 932e5f0..197b07b 100644
--- a/PR/src/include/wav.h
+++ b/PR/src/include/wav.h
@@ -34,7 +34,7 @@ wav.h: Princed Resources : WAV files support headers
 #ifndef _WAV_H_
 #define _WAV_H_
 
-#include "resources.h"
+#include "dat.h"
 #include <stdio.h>
 
 #define WAVE_HEADER {0x52, 0x49, 0x46, 0x46, 0x12, 0x16, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 0xA3, 0x15, 0x00, 0x00}
diff --git a/PR/src/lib/actions/classify.c b/PR/src/lib/actions/classify.c
index 327620e..2a5e221 100644
--- a/PR/src/lib/actions/classify.c
+++ b/PR/src/lib/actions/classify.c
@@ -45,11 +45,9 @@ tasks.c: Princed Resources : Classify a DAT file
 
 #define READ_ERROR {mReadCloseDatFile();return PR_RESULT_ERR_INVALID_DAT;}
 
-/* TODO: centralize all return values in defines. Change the interfaces. */
-
 int prClassifyDat(const char* vFiledat) {
 	int                indexNumber;
-	int                type=RES_TYPE_BINARY;
+	tResourceType      type=RES_TYPE_BINARY;
 	unsigned short int numberOfItems;
 	tPopVersion        popVersion;
 	tResource          res;
@@ -146,3 +144,4 @@ int prClassify(const char* fileName) {
 	
 	return result;
 }
+
diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c
index 430caa5..16a02bf 100644
--- a/PR/src/lib/formats/bmp.c
+++ b/PR/src/lib/formats/bmp.c
@@ -39,7 +39,7 @@ bmp.c: Princed Resources : BMP file support
 #include "bmp.h"
 #include "disk.h"
 #include "memory.h"
-#include "dat.h"
+/*#include "dat.h"*/
 
 extern FILE* outputStream;
 
@@ -195,7 +195,7 @@ int mReadBitMap(tImage* image,unsigned char* data, int size) {
 
 	/* Validate image and file size; get memory to allocate the image */
 	ok=ok&& (filesize==size);
-	ok=ok&& (	(image->pix=getMemory(height*image->widthInBytes*2)) != NULL	);
+	ok=ok&& (	(image->pix=malloc(height*image->widthInBytes*2)) != NULL	);
 	/* if validations==wrong */
 	if (!ok) {
 		freeAllocation(image->pix);
diff --git a/PR/src/lib/formats/mid.c b/PR/src/lib/formats/mid.c
index 95b54fc..45558e3 100644
--- a/PR/src/lib/formats/mid.c
+++ b/PR/src/lib/formats/mid.c
@@ -36,8 +36,8 @@ mid.c: Princed Resources : MIDI files support
 #include "disk.h"
 #include "common.h"
 #include "dat.h"
-#include "memory.h"
 #include <string.h>
+#include <stdlib.h>
 
 int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
 	/* Mid files are saved as raw except you must ignore checksum & sound type */
@@ -47,7 +47,7 @@ int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int
 int mFormatImportMid(tResource *res) {
 	unsigned char* file;
 
-	file=getMemory(res->size+1);
+	file=malloc(res->size+1);
 	file[0]=(unsigned char)((res->type==4)?2:0); /* Now should be 0x02: First character must be a 0x01 (wav type in dat) */
 	memcpy(file+1,res->data,res->size);
 	res->size++;
diff --git a/PR/src/lib/formats/pal.c b/PR/src/lib/formats/pal.c
index 28883f9..61c6a8b 100644
--- a/PR/src/lib/formats/pal.c
+++ b/PR/src/lib/formats/pal.c
@@ -36,9 +36,7 @@ pal.c: Princed Resources : JASC PAL files support
 #include <stdlib.h>
 #include <stdio.h>
 #include "pal.h"
-#include "memory.h"
 #include "disk.h"
-#include "resources.h"
 #include "dat.h"
 
 /***************************************************************\
@@ -49,8 +47,8 @@ static const char* enter="\r\n";
 
 /* Public functions */
 int mFormatExportPal(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension ) {
-	unsigned char* pal=getMemory(240);
-	unsigned char* aux=getMemory(MAX_FILENAME_SIZE);
+	unsigned char* pal=malloc(240);
+	unsigned char* aux=malloc(MAX_FILENAME_SIZE);
 	int i;
 
 	/* Export extra palette information */
@@ -117,7 +115,7 @@ int mFormatImportPal(tResource *res,const char* vFile) {
 	}
 
 	/* Allocate palette */
-	pal=getMemory(100);
+	pal=malloc(100);
 
 	/* set palette with sample */
 	memcpy(pal,pals,100);
diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c
index 385ec75..67915ea 100644
--- a/PR/src/lib/formats/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -44,7 +44,6 @@ plv.c: Princed Resources : PLV prince level files support
 #include "plv.h"
 #include "disk.h"
 #include "dat.h"
-#include "memory.h"
 #include <string.h>
 #include <time.h>
 
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index 83f2378..a1d5a7d 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -94,7 +94,7 @@ int verifyMidiHeader(const unsigned char *array, int size) {
 	;
 }
 
-int verifyHeader(const unsigned char *array, int size) {
+tResourceType verifyHeader(const unsigned char *array, int size) {
 	if (verifyLevelHeader  (array,size)) return RES_TYPE_LEVEL;
 	if (verifyMidiHeader   (array,size)) return RES_TYPE_MIDI;
 	if (verifyImageHeader  (array,size)) return RES_TYPE_IMAGE;
@@ -104,11 +104,6 @@ int verifyHeader(const unsigned char *array, int size) {
 	return RES_TYPE_BINARY;
 }
 
-const char* getExtDesc(int type) {
-	static const char* extarraydesc[]=RES_FILE_TYPES;
-	return extarraydesc[type];
-}
-
 /***************************************************************\
 |                Partial Resource List Functions                |
 \***************************************************************/
@@ -300,18 +295,6 @@ void freePartialList() {
 	partialList.count=0;
 }
 
-/***************************************************************\
-|                       Checksum handling                       |
-\***************************************************************/
-
-int checkSum(const unsigned char* data,int size) {
-	unsigned char  checksum = 1;
-
-	/* validates the checksum */
-	while (size--) checksum+=*(data++);
-	return !checksum;
-}
-
 /***************************************************************\
 |                     Parsing resource file                     |
 \***************************************************************/
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index 0bbe968..bb95c91 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -63,6 +63,18 @@ static unsigned char* readDatFile;
 static int            readDatFileSize;
 static tIndexCursor   readIndexCursor;
 
+/***************************************************************\
+|                       Checksum handling                       |
+\***************************************************************/
+
+int checkSum(const unsigned char* data,int size) {
+	unsigned char  checksum = 1;
+
+	/* validates the checksum */
+	while (size--) checksum+=*(data++);
+	return !checksum;
+}
+
 /* private functions */
 /* todo: move to datindex.c */
 
diff --git a/PR/src/lib/layers/disk.c b/PR/src/lib/layers/disk.c
index c86a3b0..2dd5ee4 100644
--- a/PR/src/lib/layers/disk.c
+++ b/PR/src/lib/layers/disk.c
@@ -37,7 +37,7 @@ disk.c: Princed Resources : Disk Access & File handling functions
 */
 
 /* Defines */
-#include "memory.h"
+#include "memory.h" /* strallocandcopy */
 #include <string.h>
 #include "disk.h"
 #ifndef WIN32
@@ -49,7 +49,6 @@ disk.c: Princed Resources : Disk Access & File handling functions
 
 #ifndef DISK_ALLWAYS_FORCE
 #include "common.h" /* language texts */
-#include "xmlparse.h" /* equalsIgnoreCase */
 #endif
 
 #ifndef WIN32
@@ -79,6 +78,14 @@ disk.c: Princed Resources : Disk Access & File handling functions
 extern FILE* outputStream;
 #endif
 
+typedef struct tOpenFiles {
+	struct tOpenFiles* next;
+	FILE* file;
+	char* name;
+	unsigned char* content;
+	long int size;
+}tOpenFiles;
+
 /***************************************************************\
 |              Disk Access & File handling functions            |
 \***************************************************************/
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index 83f2378..a1d5a7d 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -94,7 +94,7 @@ int verifyMidiHeader(const unsigned char *array, int size) {
 	;
 }
 
-int verifyHeader(const unsigned char *array, int size) {
+tResourceType verifyHeader(const unsigned char *array, int size) {
 	if (verifyLevelHeader  (array,size)) return RES_TYPE_LEVEL;
 	if (verifyMidiHeader   (array,size)) return RES_TYPE_MIDI;
 	if (verifyImageHeader  (array,size)) return RES_TYPE_IMAGE;
@@ -104,11 +104,6 @@ int verifyHeader(const unsigned char *array, int size) {
 	return RES_TYPE_BINARY;
 }
 
-const char* getExtDesc(int type) {
-	static const char* extarraydesc[]=RES_FILE_TYPES;
-	return extarraydesc[type];
-}
-
 /***************************************************************\
 |                Partial Resource List Functions                |
 \***************************************************************/
@@ -300,18 +295,6 @@ void freePartialList() {
 	partialList.count=0;
 }
 
-/***************************************************************\
-|                       Checksum handling                       |
-\***************************************************************/
-
-int checkSum(const unsigned char* data,int size) {
-	unsigned char  checksum = 1;
-
-	/* validates the checksum */
-	while (size--) checksum+=*(data++);
-	return !checksum;
-}
-
 /***************************************************************\
 |                     Parsing resource file                     |
 \***************************************************************/
diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c
index a2d271c..5c8cc57 100644
--- a/PR/src/lib/xml/parse.c
+++ b/PR/src/lib/xml/parse.c
@@ -19,8 +19,8 @@
 */
 
 /*
-xmlparse.c: Princed Resources : xml parsing functions
-\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+parse.c: Princed Resources : xml parsing functions
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 23 Oct 2003
 
@@ -50,6 +50,11 @@ extern FILE* outputStream;
 |                   Tag Tree Handling Functions                  |
 \****************************************************************/
 
+const char* getExtDesc(int type) {
+	static const char* extarraydesc[]=RES_FILE_TYPES;
+	return extarraydesc[type];
+}
+
 /* private defines */
 #define IsSpace(c) ((c==' ')||(c==9))||(c=='\n')||(c=='\r')
 #define IsChar(c) ((('a'<=c)&&(c<='z'))||(('A'<=c)&&(c<='Z'))||(c=='_')||(c=='-')||(c=='?'))
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index 56e0e4a..6104ae6 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -19,8 +19,8 @@
 */
 
 /*
-xmlsearch.c: Princed Resources : specific xml handling functions
-\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+search.c: Princed Resources : specific xml handling functions
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 23 Oct 2003
 
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 83f2378..a1d5a7d 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -94,7 +94,7 @@ int verifyMidiHeader(const unsigned char *array, int size) {
 	;
 }
 
-int verifyHeader(const unsigned char *array, int size) {
+tResourceType verifyHeader(const unsigned char *array, int size) {
 	if (verifyLevelHeader  (array,size)) return RES_TYPE_LEVEL;
 	if (verifyMidiHeader   (array,size)) return RES_TYPE_MIDI;
 	if (verifyImageHeader  (array,size)) return RES_TYPE_IMAGE;
@@ -104,11 +104,6 @@ int verifyHeader(const unsigned char *array, int size) {
 	return RES_TYPE_BINARY;
 }
 
-const char* getExtDesc(int type) {
-	static const char* extarraydesc[]=RES_FILE_TYPES;
-	return extarraydesc[type];
-}
-
 /***************************************************************\
 |                Partial Resource List Functions                |
 \***************************************************************/
@@ -300,18 +295,6 @@ void freePartialList() {
 	partialList.count=0;
 }
 
-/***************************************************************\
-|                       Checksum handling                       |
-\***************************************************************/
-
-int checkSum(const unsigned char* data,int size) {
-	unsigned char  checksum = 1;
-
-	/* validates the checksum */
-	while (size--) checksum+=*(data++);
-	return !checksum;
-}
-
 /***************************************************************\
 |                     Parsing resource file                     |
 \***************************************************************/
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 83f2378..a1d5a7d 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -94,7 +94,7 @@ int verifyMidiHeader(const unsigned char *array, int size) {
 	;
 }
 
-int verifyHeader(const unsigned char *array, int size) {
+tResourceType verifyHeader(const unsigned char *array, int size) {
 	if (verifyLevelHeader  (array,size)) return RES_TYPE_LEVEL;
 	if (verifyMidiHeader   (array,size)) return RES_TYPE_MIDI;
 	if (verifyImageHeader  (array,size)) return RES_TYPE_IMAGE;
@@ -104,11 +104,6 @@ int verifyHeader(const unsigned char *array, int size) {
 	return RES_TYPE_BINARY;
 }
 
-const char* getExtDesc(int type) {
-	static const char* extarraydesc[]=RES_FILE_TYPES;
-	return extarraydesc[type];
-}
-
 /***************************************************************\
 |                Partial Resource List Functions                |
 \***************************************************************/
@@ -300,18 +295,6 @@ void freePartialList() {
 	partialList.count=0;
 }
 
-/***************************************************************\
-|                       Checksum handling                       |
-\***************************************************************/
-
-int checkSum(const unsigned char* data,int size) {
-	unsigned char  checksum = 1;
-
-	/* validates the checksum */
-	while (size--) checksum+=*(data++);
-	return !checksum;
-}
-
 /***************************************************************\
 |                     Parsing resource file                     |
 \***************************************************************/