git » fp-git.git » commit 120c6e7

finished all the TODOs

author ecalot
2005-06-14 19:43:39 UTC
committer ecalot
2005-06-14 19:43:39 UTC
parent f1c0062003ce072995f3850716b5907a94a1ef32

finished all the TODOs

PR/src/console/filedir.c +1 -4
PR/src/include/bitmap.h +2 -2
PR/src/include/bmp.h +2 -2
PR/src/include/mid.h +1 -2
PR/src/include/pal.h +1 -2
PR/src/include/plv.h +1 -2
PR/src/include/png.h +2 -2
PR/src/include/reslist.h +7 -4
PR/src/include/search.h +0 -1
PR/src/include/types.h +7 -4
PR/src/include/wav.h +1 -2
PR/src/lib/actions/import.c +1 -1
PR/src/lib/formats/bmp.c +1 -1
PR/src/lib/layers/dat.c +3 -7
PR/src/lib/layers/reslist.c +4 -2
PR/src/lib/pr.c +1 -0
PR/src/lib/xml/search.c +0 -1

diff --git a/PR/src/console/filedir.c b/PR/src/console/filedir.c
index 159afc2..3d67d73 100644
--- a/PR/src/console/filedir.c
+++ b/PR/src/console/filedir.c
@@ -61,8 +61,7 @@ int filedir_push(const char* text, tFileDir** list, int checkEquals) {
 	if (checkEquals) {
 		node=*list;
 		while (node) {
-			if (equalsIgnoreCase(node->text,text)) /* TODO: use defines If file was in the list, do nothing */
-			/*if (!strcmp(node->file,text)) * If file was in the list, do nothing */
+			if (equalsIgnoreCase(node->text,text)) /* If file was in the list, do nothing */
 				return -1;
 			node=node->next;
 		}
@@ -170,8 +169,6 @@ int isADatFile(const char* vResFile, const char* file) {
 	pass.file=getFileNameFromPath(file);
 	pass.result=0;
 
-	/* TODO: directory must end with / */
-	
 	/* Generate xml structure if doesn't exist */
 	if ((error=parseStructure(vResFile,&structure))) return error;
 
diff --git a/PR/src/include/bitmap.h b/PR/src/include/bitmap.h
index 0b54ae1..d36fb5f 100644
--- a/PR/src/include/bitmap.h
+++ b/PR/src/include/bitmap.h
@@ -35,8 +35,8 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "dat.h"
-#include "compress.h"
+#include "reslist.h" /* tResource */
+#include "compress.h" /* tImage */
 
 #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 0b54ae1..d36fb5f 100644
--- a/PR/src/include/bmp.h
+++ b/PR/src/include/bmp.h
@@ -35,8 +35,8 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "dat.h"
-#include "compress.h"
+#include "reslist.h" /* tResource */
+#include "compress.h" /* tImage */
 
 #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF"
 
diff --git a/PR/src/include/mid.h b/PR/src/include/mid.h
index 3a4e1c5..94872ab 100644
--- a/PR/src/include/mid.h
+++ b/PR/src/include/mid.h
@@ -34,8 +34,7 @@ mid.h: Princed Resources : MIDI files support headers
 #ifndef _MID_H_
 #define _MID_H_
 
-#include <stdio.h>
-#include "dat.h"
+#include "reslist.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 6991db7..aa5b598 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 "dat.h"
-#include <stdio.h>
+#include "reslist.h"
 
 #define PAL_HEADER "JASC-PAL\r\n0100\r\n16\r\n"
 #define PAL_SAMPLE {0x97, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x08, 0x0F, 0x07, 0x0C, 0x13, 0x0C, 0x11, 0x16, 0x11, 0x17, 0x1C, 0x1E, 0x21, 0x25, 0x2F, 0x31, 0x33, 0x3F, 0x3F, 0x3F, 0x2A, 0x2A, 0x2A, 0x15, 0x15, 0x15, 0x17, 0x1C, 0x20, 0x07, 0x0C, 0x13, 0x0C, 0x12, 0x17, 0x15, 0x1A, 0x1F, 0x00, 0x1D, 0x13, 0x00, 0x29, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h
index 0d5eca1..dd646ce 100644
--- a/PR/src/include/plv.h
+++ b/PR/src/include/plv.h
@@ -59,8 +59,7 @@ plv.h: Princed Resources : PLV prince level files support headers
 	All values are unsigned and in the intel x86 architecture
 */
 
-#include <stdio.h>
-#include "dat.h"
+#include "reslist.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 0b54ae1..d36fb5f 100644
--- a/PR/src/include/png.h
+++ b/PR/src/include/png.h
@@ -35,8 +35,8 @@ bmp.h: Princed Resources : BMP file support headers
 #ifndef _BMP_H_
 #define _BMP_H_
 
-#include "dat.h"
-#include "compress.h"
+#include "reslist.h" /* tResource */
+#include "compress.h" /* tImage */
 
 #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 8402aa4..73f0f34 100644
--- a/PR/src/include/reslist.h
+++ b/PR/src/include/reslist.h
@@ -69,14 +69,17 @@ typedef struct {
 	unsigned long      flags;
 }tResource;
 
-void printr(const tResource* record); /* for debug purposes */
+/* void printr(const tResource* record); * for debug purposes */
+
+#define resourceListStartIteration(l) list_firstCursor(l)
+#define resourceListDrop(r)	list_drop(r)
 
-int resIdCmp(tResourceId a,tResourceId b);
 int resCmp(const void* a,const void* b);
-void resourceListDrop(tResourceList* r);
+int resIdCmp(tResourceId a,tResourceId b);
+const tResource* resourceListGetElement(tResourceList* r);
 tResourceList resourceListCreate(int isCopy);
+void resourceListAddInfo(tResourceList* r,tResource* res);
 void resourceListAdd(tResourceList* r,const tResource* res);
 void resourceListDebugPrint(tResourceList* r);
-void resourceListAddInfo(tResourceList* r,tResource* res);
 
 #endif
diff --git a/PR/src/include/search.h b/PR/src/include/search.h
index fbead18..4c64977 100644
--- a/PR/src/include/search.h
+++ b/PR/src/include/search.h
@@ -40,7 +40,6 @@ search.h: Princed Resources : xml handling functions header file
 
 /* Includes */
 #include "common.h" /* tTag */
-#include "parse.h"
 #include "reslist.h"
 
 /****************************************************************\
diff --git a/PR/src/include/types.h b/PR/src/include/types.h
index 8402aa4..73f0f34 100644
--- a/PR/src/include/types.h
+++ b/PR/src/include/types.h
@@ -69,14 +69,17 @@ typedef struct {
 	unsigned long      flags;
 }tResource;
 
-void printr(const tResource* record); /* for debug purposes */
+/* void printr(const tResource* record); * for debug purposes */
+
+#define resourceListStartIteration(l) list_firstCursor(l)
+#define resourceListDrop(r)	list_drop(r)
 
-int resIdCmp(tResourceId a,tResourceId b);
 int resCmp(const void* a,const void* b);
-void resourceListDrop(tResourceList* r);
+int resIdCmp(tResourceId a,tResourceId b);
+const tResource* resourceListGetElement(tResourceList* r);
 tResourceList resourceListCreate(int isCopy);
+void resourceListAddInfo(tResourceList* r,tResource* res);
 void resourceListAdd(tResourceList* r,const tResource* res);
 void resourceListDebugPrint(tResourceList* r);
-void resourceListAddInfo(tResourceList* r,tResource* res);
 
 #endif
diff --git a/PR/src/include/wav.h b/PR/src/include/wav.h
index 197b07b..1dbae62 100644
--- a/PR/src/include/wav.h
+++ b/PR/src/include/wav.h
@@ -34,8 +34,7 @@ wav.h: Princed Resources : WAV files support headers
 #ifndef _WAV_H_
 #define _WAV_H_
 
-#include "dat.h"
-#include <stdio.h>
+#include "reslist.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/import.c b/PR/src/lib/actions/import.c
index 8ece8bc..4652790 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -160,7 +160,7 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r,
 	for (indexNumber=0;(indexNumber<numberOfItems);indexNumber++) {
 		if (!mReadFileInDatFile(&res,indexNumber)) return PR_RESULT_ERR_INVALID_DAT; /* Read error */
 
-		if (res.id.value==0xFFFF) continue; /* Tammo Jan Bug fix * TODO: move to the dat layer? */
+		if (res.id.value==0xFFFF) continue; /* Tammo Jan Bug fix */
 
 		/* add to res more information from the resource list */
 		resourceListAddInfo(r,&res);
diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c
index 43e76da..bffd36b 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;
 
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index 64c3851..bc62f12 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -418,8 +418,7 @@ void dat_write(const tResource* res,unsigned char checksum) {
 	/* do the magic */
 	fwrite(res->data,res->size,1,writeDatFile);
 
-	/* TODO: use an abstract use of the list (at least macros in reslist.h) */
-	list_insert(&resIndex,&insert);
+	resourceListAdd(&resIndex,&insert);
 }
 
 void mWriteFileInDatFileIgnoreChecksum(const tResource* res) {
@@ -467,15 +466,12 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension
 	/* Write index */
 	fwriteshort(&totalItems,writeDatFile); /* Junk total items count to reserve 2 bytes */
 
-	/* TODO: use an abstract use of the list (at least macros in reslist.h) */
-	list_firstCursor(&resIndex);
-	while ((res=list_getCursor(&resIndex))) {
+	resourceListStartIteration(&resIndex);
+	while ((res=resourceListGetElement(&resIndex))) {
 		totalItems++;
 		fwriteshort(&(res->id.value),writeDatFile);
 		fwritelong(&(res->offset),writeDatFile);
 		fwriteshort(&(res->size),writeDatFile);
-
-		list_nextCursor(&resIndex);
 	}
 
 	size2+=totalItems<<3;
diff --git a/PR/src/lib/layers/reslist.c b/PR/src/lib/layers/reslist.c
index 6999597..66fa6d1 100644
--- a/PR/src/lib/layers/reslist.c
+++ b/PR/src/lib/layers/reslist.c
@@ -61,8 +61,10 @@ void resFree(void* a) {
 void resFreeDummy(void* a) {
 }
 
-void resourceListDrop(tResourceList* r) {
-	list_drop(r);
+const tResource* resourceListGetElement(tResourceList* r) {
+	const tResource* ret=list_getCursor(r);
+	if (ret) list_nextCursor(r);
+	return ret;
 }
 
 tResourceList resourceListCreate(int isCopy) {
diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c
index 4fc8abf..c3c3614 100644
--- a/PR/src/lib/pr.c
+++ b/PR/src/lib/pr.c
@@ -59,6 +59,7 @@ pr.c: Main source file for Princed Resources library
 
 #include "disk.h"      /* getFileNameFromPath */
 #include "idlist.h"
+#include "reslist.h"
 #include "memory.h"    /* getMemory, free */
 #include "resources.h"
 
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index 2c4830a..306eb68 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -39,7 +39,6 @@ search.c: Princed Resources : specific xml handling functions
 /* Includes */
 #include "common.h"
 #include "parse.h"
-#include "reslist.h" /* only to add to the list */
 #include "search.h"
 #include "memory.h"
 #include <string.h>