git » fp-git.git » commit 56de07e

debugging code stripped

author ecalot
2004-07-05 10:54:12 UTC
committer ecalot
2004-07-05 10:54:12 UTC
parent 20ddc552af3ff446a96d96f94e280624270086c3

debugging code stripped

PR/src/include/autodetect.h +1 -1
PR/src/include/idlist.h +1 -1
PR/src/include/plv.h +1 -1
PR/src/include/tree.h +1 -1
PR/src/include/unknown.h +1 -1
PR/src/lib/actions/export.c +7 -13
PR/src/lib/actions/import.c +8 -12
PR/src/lib/formats/plv.c +2 -7
PR/src/lib/layers/autodetect.c +2 -2
PR/src/lib/layers/dat.c +0 -2
PR/src/lib/layers/disk.c +16 -22
PR/src/lib/layers/idlist.c +2 -2
PR/src/lib/xml/parse.c +1 -1
PR/src/lib/xml/tree.c +2 -2
PR/src/lib/xml/unknown.c +2 -2

diff --git a/PR/src/include/autodetect.h b/PR/src/include/autodetect.h
index ab7b920..629f316 100644
--- a/PR/src/include/autodetect.h
+++ b/PR/src/include/autodetect.h
@@ -114,7 +114,7 @@ int verifyHeader(const unsigned char* array, int size);
 \***************************************************************/
 
 /* CheckSum verification */
-int checkSum(unsigned char* data,int size);
+int checkSum(const unsigned char* data,int size);
 
 /* Empty resource table */
 void emptyTable(tResource* r[]);
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h
index ab7b920..629f316 100644
--- a/PR/src/include/idlist.h
+++ b/PR/src/include/idlist.h
@@ -114,7 +114,7 @@ int verifyHeader(const unsigned char* array, int size);
 \***************************************************************/
 
 /* CheckSum verification */
-int checkSum(unsigned char* data,int size);
+int checkSum(const unsigned char* data,int size);
 
 /* Empty resource table */
 void emptyTable(tResource* r[]);
diff --git a/PR/src/include/plv.h b/PR/src/include/plv.h
index 164f71d..f5279a0 100644
--- a/PR/src/include/plv.h
+++ b/PR/src/include/plv.h
@@ -74,7 +74,7 @@ int mFormatExportPlv(const unsigned char* data, const char *vFileext,unsigned lo
 /* Format stuff */
 #define PLV_HEADER_A           "POP_LVL\x01\x01"
 #define PLV_HEADER_A_SIZE      9
-#define PLV_HEADER_B           "\08x\0\0"
+#define PLV_HEADER_B           "\x08\0\0"
 #define PLV_HEADER_B_SIZE      4
 #define PLV_FOOT_EDITOR        "EDITORNAME\0PR\0EDITORVERS\0"PR_VERSION"\0AUTHOR"
 #define PLV_FOOT_TITLE         "TITLE"
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index ab7b920..629f316 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -114,7 +114,7 @@ int verifyHeader(const unsigned char* array, int size);
 \***************************************************************/
 
 /* CheckSum verification */
-int checkSum(unsigned char* data,int size);
+int checkSum(const unsigned char* data,int size);
 
 /* Empty resource table */
 void emptyTable(tResource* r[]);
diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h
index ab7b920..629f316 100644
--- a/PR/src/include/unknown.h
+++ b/PR/src/include/unknown.h
@@ -114,7 +114,7 @@ int verifyHeader(const unsigned char* array, int size);
 \***************************************************************/
 
 /* CheckSum verification */
-int checkSum(unsigned char* data,int size);
+int checkSum(const unsigned char* data,int size);
 
 /* Empty resource table */
 void emptyTable(tResource* r[]);
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index b3defa0..9729f7d 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -84,34 +84,30 @@ int extract(const char* vFiledat,const char* vDirExt, tResource* r[], int option
 
 	/* Initialize abstract variables to read this new DAT file */
 	if (!mReadBeginDatFile(&numberOfItems,vFiledat)) return -1;
-fld("a");
+
 	/* Initializes the palette list */
 	initializePaletteList;
 	
-fld("b");
+
 
 	/* main loop */
 	for (indexNumber=0;ok&&(indexNumber<numberOfItems);indexNumber++) {
 		id=mReadFileInDatFile(indexNumber,&data,&size);
-fld("c");
-/* printf("*K) id=%d size=%d %d:%d:%d:%d:%d:%d\n",id,size,data[0],data[1],data[2],data[3],data[4],data[5]); */
 
 		if (id<0) return -3; /* Read error */
 		if (id==0xFFFF) continue; /* Tammo Jan Bug fix */
 		if (id>=MAX_RES_COUNT) return -3; /* A file with an ID out of range will be treated as invalid */
-fld("d");
 
 		/* set resource information on this index entry */
 		if (mReadInitResource(r+id,data,size)) return -2;
-fld("e");
-/* printf("z->%d\n",r[id]->type); */
+
 		if ((r[id]->type==RES_TYPE_PALETTE)||isInThePartialList(r[id]->path,id)) { /* If the resource was specified or is a palette, do the tasks */
 			if (!(hasFlag(unknown_flag))) { /* If unknown flag is set do nothing but generate the unknown.xml file */
 				if (hasFlag(raw_flag)) r[id]->type=0; /* If "extract as raw" is set, type is 0 */
 
 				/* get save file name (if unknown document it in the xml) */
 				getFileName(vFileext,vDirExt,r[id],(unsigned short)id,vFiledat,vDatFileName,optionflag,backupExtension);
-fld("f");
+
 				switch (r[id]->type) {
 					case RES_TYPE_LEVEL:
 						ok=ok&&mFormatExportPlv(data,vFileext,size,r[id]->number,vDatFileName,r[id]->name,r[id]->desc,vDatAuthor,optionflag,backupExtension);
@@ -134,16 +130,14 @@ fld("f");
 						break;
 					case RES_TYPE_PCSPEAKER: /* save pcs file */
 					case RES_TYPE_MIDI:	/* save midi file */
-/* printf("a->%d\n",ok); */
 						ok=ok&&mFormatExportMid(data,vFileext,size,optionflag,backupExtension);
-/* printf("b->%d\n",ok); */
 						break;
 					case RES_TYPE_WAVE: /* save wav file */
 						ok=ok&&mFormatExportWav(data,vFileext,size,optionflag,backupExtension);
 						break;
 					case RES_TYPE_IMAGE: /* save image */
 						/* Palette handling */
-fld("Z1");
+
 						if (r[id]->palette!=bufferedPalette) { /* The palette isn't in the buffer */
 							if (r[id]->palette) { /* We need a palette */
 								/*
@@ -165,9 +159,9 @@ fld("Z1");
 							}
 						}
 						/* Export bitmap */
-fld("Z2");
+
 						ok=ok&&mFormatExportBmp(data,vFileext,size,image,optionflag,backupExtension);
-fld("Z3");
+
 						break;
 				}
 				/* Verbose information */
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index 8338462..67d8f6d 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -105,9 +105,9 @@ int fullCompile(const char* vFiledat, const char* vDirExt, tResource* r[], int o
 	int ok=0;
 	unsigned char* data;
 	unsigned short int id=1;
-fld("itdb");
+
 	if (!mWriteBeginDatFile(vFiledat,optionflag)) return -1; /* File couldn't be open */
-fld("tb");
+
 	for (;id!=MAX_RES_COUNT;id++) {
 		if (r[id]!=NULL) {
 			if (hasFlag(raw_flag)) r[id]->type=0; /* compile from raw */
@@ -129,13 +129,13 @@ fld("tb");
 			}
 		}
 	}
-fld("kb");
+
 	/* Close file. If empty, don't save */
 	mWriteCloseDatFile(r,!ok,optionflag,backupExtension);
-fld("db");
+
 	/* Free allocated resources and dynamic strings */
 	freeResources;
-fld("zb");
+
 	if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_DONE,ok,error);
 	return error;
 }
@@ -167,12 +167,12 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResource* r[], in
 		if (id<0) RW_ERROR; /* Read error */ /* TODO BUG: return doesn't close file */
 		if (id==0xFFFF) continue; /* Tammo Jan Bug fix */
 		if (id>=MAX_RES_COUNT) RW_ERROR; /* A file with an ID out of range will be treated as invalid */
-fld("e");
+
 		mWriteInitResource(r+id);
 		if (r[id]&&isInThePartialList(r[id]->path,id)) { /* If the resource was specified */
 			if (hasFlag(raw_flag)) r[id]->type=0; /* compile from raw */
 			getFileName(vFileext,vDirExt,r[id],(unsigned short)id,vFiledat,vDatFileName,optionflag,backupExtension);
-fld("g");
+
 			/* the file is in the archive, so i'll add it to the main dat body */
 			if ((r[id]->size=((unsigned long)mLoadFileArray(vFileext,&data)))) {
 				if (!mAddCompiledFileToDatFile(data,r[id],vFileext)) {
@@ -192,26 +192,22 @@ fld("g");
 			mWriteFileInDatFileIgnoreChecksum(data,size);
 		}
 	}
-fld("k");
 
 	/* Close dat file */
 	mRWCloseDatFile(0);
 
 	/* Free allocated resources and dynamic strings */
 	freeResources;
-fld("b");
 
 	if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_DONE,ok,error);
 	return error;
 }
 
 int compile(const char* vFiledat, const char* vDirExt, tResource* r[], int optionflag, const char* vDatFileName,const char* backupExtension) {
-fld("b");
+
 	if (partialListActive()) {
-fld("fub");
 		return partialCompile(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
 	} else {
-fld("fdb");
 		return fullCompile(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
 	}
 }
diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c
index 9a16565..1d1db38 100644
--- a/PR/src/lib/formats/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -164,32 +164,27 @@ int mFormatImportPlv(unsigned char* data, tResource *res) {
 	/* declare variables */
 	unsigned char* pos;
 	unsigned long int oldSize=res->size;
-fld("a");
+
 	/* integrity check 1 */
 	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE) return 0;
 	/* if (memcmp(data,PLV_HEADER_A,PLV_HEADER_A_SIZE)) return 0; */
 
-fld("b");
+
 	/* jump to size */
 	pos=data+PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE;
 	/* read size and jump to data */
-
 	res->size=array2long(pos);pos+=4;
 
-fld("c");
 	/* integrity check 2 */
 	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE+res->size) return 0;
 
-fld("d-");
 	/* verify checksum */
 
 /* TODO: uncomment this line and validate checksums in plvs */
 	if (!checkSum(pos,res->size)) return 0;
 
-fld("e");
 	/* save data */
 	mWriteFileInDatFileIgnoreChecksum(pos,res->size--);
 
-fld("f");
 	return 1;
 }
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index d116498..996d085 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -216,7 +216,7 @@ void freePartialList() {
 |                       Checksum handling                       |
 \***************************************************************/
 
-int checkSum(unsigned char* data,int size) {
+int checkSum(const unsigned char* data,int size) {
 	unsigned char  checksum = 1;
 
 	/* calculates the checksum */
@@ -311,7 +311,7 @@ static unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 void endUnknownXml(int optionflag, const char* backupExtension) {
 	if (unknownXmlFile!=NULL) {
 		int i;
-		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
+		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END); /* TODO: use fwrite instead */
 		writeCloseOk(unknownXmlFile,optionflag,backupExtension);
 		unknownXmlFile=NULL;
 		for (i=0;i<RES_TYPECOUNT;i++) typeCount[i]=0;
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index d699f26..3922f4c 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -107,8 +107,6 @@ int mReadFileInDatFile(int k,unsigned char* *data,unsigned long  int *size) {
 
 	/* for each archived file the index is read */
 	id=    array2short(indexPointer+ofk+k*recordSize);/*(indexPointer[ofk+k*recordSize])+(indexPointer[ofk+k*recordSize+1]<<8);*/
-/* printf("a ver: %d %d\n",id,(indexPointer[ofk+k*recordSize])+(indexPointer[ofk+k*recordSize+1]<<8)); */
-	
 	offset=array2long(indexPointer+ofk+k*recordSize+2);/*indexPointer[ofk+k*recordSize+2])+(indexPointer[ofk+k*recordSize+3]<<8)+(indexPointer[ofk+k*recordSize+4]<<16)+(indexPointer[ofk+k*recordSize+5]<<24);*/
 	*size= array2short(indexPointer+ofk+k*recordSize+6)+1;/*indexPointer[ofk+k*recordSize+6])+(indexPointer[ofk+k*recordSize+7]<<8)+1;*/
 	if ((!pop1)&&(!(indexPointer[ofk+k*recordSize+8]==0x40)&&(!indexPointer[ofk+k*recordSize+9])&&(!indexPointer[ofk+k*recordSize+10]))) return -1;
diff --git a/PR/src/lib/layers/disk.c b/PR/src/lib/layers/disk.c
index 6cdeae5..9555da7 100644
--- a/PR/src/lib/layers/disk.c
+++ b/PR/src/lib/layers/disk.c
@@ -71,7 +71,7 @@ extern FILE* outputStream;
 const char *repairFolders(const char* a) {
 	int i,k;
 	static char result[MAX_FILENAME_SIZE];
-fld("rf1");
+
 
 	for (i=0,k=0;a[i]&&(k<MAX_FILENAME_SIZE);) {
 		if (isDirSep(a,i)) {
@@ -84,9 +84,9 @@ fld("rf1");
 		}
 		k++;
 	}
-fld("rf2");
+
 	result[k]=0;
-fld("rf3");
+
 	return result;
 }
 
@@ -133,21 +133,21 @@ void addFileToOpenFilesList(const char* fileName,int hasBackup) {
 	*/
 
 	tOpenFiles* newNode;
-fld("h1");
+
 
 	/* Create the new node and fill in the fields */
 	newNode=(tOpenFiles*)malloc(sizeof(tOpenFiles));
 	newNode->next=openFilesList;
 	newNode->name=strallocandcopy(fileName);
-fld("h2");
+
 	if (hasBackup) {
-fld("h3");
+
 		newNode->size=mLoadFileArray(fileName,&(newNode->content));
-fld("h3");
+
 	} else {
-fld("h4");
+
 		newNode->size=0;
-fld("h4");
+
 	}
 	openFilesList=newNode;
 }
@@ -220,9 +220,7 @@ int writeClose(FILE* fp,int dontSave,int optionflag,const char* backupExtension)
 		if (size) free(content);
 	}
 
-	dontSave=fclose(fp);
-
-	return dontSave;
+	return fclose(fp);
 }
 
 int writeOpen(const char* vFileext, FILE* *fp, int optionflag) {
@@ -255,7 +253,7 @@ int writeOpen(const char* vFileext, FILE* *fp, int optionflag) {
 	tcsetattr (STDIN_FILENO, TCSANOW, &term);
 #endif
 #endif
-fld("g2");
+
 
 	/* Create base directory and save file */
 	file=repairFolders(vFileext);
@@ -263,7 +261,7 @@ fld("g2");
 	/* Verify if file already exists. */
 	fileType=isDir(vFileext);
 	if (fileType==eDirectory) return 0;
-fld("g3");
+
 
 	if (fileType==eFile) {
 		/* File exists. We need to ask */
@@ -278,7 +276,7 @@ fld("g3");
 	} else {
 		makebase(file);
 	}
-fld("g4");
+
 
 #ifdef UNIX
 #ifndef IGNORE_TERM_CHANGE
@@ -291,12 +289,12 @@ fld("g4");
 		If the file exists, we need to remember the old content in memory
 		if not, we need to know the name in case we need to delete it
 	*/
-fld("g5");
+
 
 	addFileToOpenFilesList(file,hasFlag(backup_flag));
-fld("g6");
+
 	if ((result=((*fp=fopen(file,"wb"))!=NULL))) addPointerToOpenFilesList(*fp);
-fld("g7");
+
 	return result;
 }
 
@@ -327,11 +325,8 @@ int writeData(const unsigned char* data, int ignoreChars, char* vFileext, int si
 
 	/* Save file */
 	ok=writeOpen(vFileext,&target,optionflag);
-/* printf("x->%d\n",ok); */
 	ok=ok&&((!size)||fwrite(data+ignoreChars,size,1,target));
-/* printf("x->%d\n",ok); */
 	ok=ok&&(!writeCloseOk(target,optionflag,backupExtension));
-/* printf("x->%d\n",ok); */
 	return ok;
 }
 
@@ -355,7 +350,6 @@ int mLoadFileArray(const char* vFile,unsigned char** array) {
 		/* get file size */
 		fseek(fp,0,SEEK_END);
 		aux=ftell(fp);
-fld("mLoadFileArray: 1");
 		if ( !aux || (aux>SIZE_OF_FILE) || ( ((*array=(unsigned char*)malloc(aux+1))==NULL) ) ) {
 			/* if the file was null or bigger than the max size or couldn't allocate the file in memory */
 			fclose(fp);
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index d116498..996d085 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -216,7 +216,7 @@ void freePartialList() {
 |                       Checksum handling                       |
 \***************************************************************/
 
-int checkSum(unsigned char* data,int size) {
+int checkSum(const unsigned char* data,int size) {
 	unsigned char  checksum = 1;
 
 	/* calculates the checksum */
@@ -311,7 +311,7 @@ static unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 void endUnknownXml(int optionflag, const char* backupExtension) {
 	if (unknownXmlFile!=NULL) {
 		int i;
-		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
+		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END); /* TODO: use fwrite instead */
 		writeCloseOk(unknownXmlFile,optionflag,backupExtension);
 		unknownXmlFile=NULL;
 		for (i=0;i<RES_TYPECOUNT;i++) typeCount[i]=0;
diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c
index a9a4f03..4858622 100644
--- a/PR/src/lib/xml/parse.c
+++ b/PR/src/lib/xml/parse.c
@@ -465,7 +465,7 @@ tTag* parseXmlFile(const char* vFile,int* error) {
 		*error=-4; /* File not open */
 		return NULL;
 	}
-	l[size-1]=0; /* The last character must be an end of line (the > is forbiden) */ 
+	/* bugfix moved to loadArray */ l[size-1]=0; /* The last character must be an end of line (the > is forbiden) */ 
 	p=l;
 
 	*error=getNextTag(&p, &value);
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index d116498..996d085 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -216,7 +216,7 @@ void freePartialList() {
 |                       Checksum handling                       |
 \***************************************************************/
 
-int checkSum(unsigned char* data,int size) {
+int checkSum(const unsigned char* data,int size) {
 	unsigned char  checksum = 1;
 
 	/* calculates the checksum */
@@ -311,7 +311,7 @@ static unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 void endUnknownXml(int optionflag, const char* backupExtension) {
 	if (unknownXmlFile!=NULL) {
 		int i;
-		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
+		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END); /* TODO: use fwrite instead */
 		writeCloseOk(unknownXmlFile,optionflag,backupExtension);
 		unknownXmlFile=NULL;
 		for (i=0;i<RES_TYPECOUNT;i++) typeCount[i]=0;
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index d116498..996d085 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -216,7 +216,7 @@ void freePartialList() {
 |                       Checksum handling                       |
 \***************************************************************/
 
-int checkSum(unsigned char* data,int size) {
+int checkSum(const unsigned char* data,int size) {
 	unsigned char  checksum = 1;
 
 	/* calculates the checksum */
@@ -311,7 +311,7 @@ static unsigned int typeCount[RES_TYPECOUNT]; /* initialized in 0 */
 void endUnknownXml(int optionflag, const char* backupExtension) {
 	if (unknownXmlFile!=NULL) {
 		int i;
-		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END);
+		fprintf(unknownXmlFile,RES_XML_UNKNOWN_END); /* TODO: use fwrite instead */
 		writeCloseOk(unknownXmlFile,optionflag,backupExtension);
 		unknownXmlFile=NULL;
 		for (i=0;i<RES_TYPECOUNT;i++) typeCount[i]=0;