git » fp-git.git » commit d39d692

renamed functions

author ecalot
2006-01-09 03:24:36 UTC
committer ecalot
2006-01-09 03:24:36 UTC
parent 3690aceb0d648becc11f240bf94d5c5d58bc3684

renamed functions

PR/src/console/filedir.c +15 -15
PR/src/console/main.c +6 -6
PR/src/include/dat.h +3 -4
PR/src/include/en.lang.pr.h +25 -25
PR/src/include/idlist.h +3 -3
PR/src/include/memory.h +4 -2
PR/src/include/pr.h +11 -11
PR/src/include/reslist.h +1 -1
PR/src/include/search.h +6 -9
PR/src/include/tree.h +4 -4
PR/src/include/types.h +1 -1
PR/src/lib/actions/classify.c +7 -5
PR/src/lib/actions/export.c +9 -9
PR/src/lib/actions/import.c +8 -9
PR/src/lib/compression/rle_compress.c +2 -3
PR/src/lib/formats/bmp.c +5 -5
PR/src/lib/formats/mid.c +3 -3
PR/src/lib/formats/wav.c +1 -1
PR/src/lib/layers/autodetect.c +4 -1
PR/src/lib/layers/dat.c +8 -8
PR/src/lib/layers/idlist.c +39 -33
PR/src/lib/layers/list.c +1 -1
PR/src/lib/layers/memory.c +18 -1
PR/src/lib/layers/reslist.c +7 -10
PR/src/lib/layers/resourcematch.c +14 -15
PR/src/lib/layers/stringformat.c +28 -28
PR/src/lib/object/image/image16.c +17 -18
PR/src/lib/object/image/image2.c +17 -18
PR/src/lib/object/image/image256.c +17 -18
PR/src/lib/object/image/image_common.c +17 -18
PR/src/lib/pr.c +7 -7
PR/src/lib/xml/parse.c +61 -61
PR/src/lib/xml/search.c +26 -42
PR/src/lib/xml/tree.c +70 -76
PR/src/lib/xml/unknown.c +15 -15

diff --git a/PR/src/console/filedir.c b/PR/src/console/filedir.c
index 4d5766c..9623b28 100644
--- a/PR/src/console/filedir.c
+++ b/PR/src/console/filedir.c
@@ -31,10 +31,10 @@ filedir.c: Princed Resources : Read command line file arguments and generate a f
   DO NOT remove this copyright notice
 */
 
-#include "search.h" /* tTag */
+#include "disk.h"
 #include "memory.h" /* malloc, strallocandcopy */
+#include "search.h" /* tTag */
 #include <string.h> /* strcat */
-#include "disk.h"
 
 /* Private Searching Structures */
 
@@ -105,7 +105,7 @@ typedef struct {
 	tFileDir2*  list;
 }tPassListAndDir;
 
-void addFileToList(const char* file,void* pass2) {
+void fd_addFileToList(const char* file,void* pass2) {
 	register tPassListAndDir* pass=pass2;
 	char path[256];
 	char* dat;
@@ -123,12 +123,12 @@ void addFileToList(const char* file,void* pass2) {
 	free(dat);
 }
 
-void addFileToListTag(const tTag* t,void* pass2) {
-	addFileToList(t->file,pass2);
+void fd_addFileToListTag(const tTag* t,void* pass2) {
+	fd_addFileToList(t->file,pass2);
 }
 
 /* Search all files in the XML tree and returns them */
-int listAllDatFiles(const char* vResFile, const char* directory, const char* opt, tFileDir2* list) {
+int fd_listAllDatFiles(const char* vResFile, const char* directory, const char* opt, tFileDir2* list) {
 	/* Declare error variable */
 	tPassListAndDir pass;
 	tTag* structure;
@@ -139,10 +139,10 @@ int listAllDatFiles(const char* vResFile, const char* directory, const char* opt
 	pass.list=list;
 
 	/* Generate XML structure if doesn't exist */
-	if ((error=parseStructure(vResFile,&structure))) return error;
+	if ((error=xmlParseStructure(vResFile,&structure))) return error;
 
 	/* Use the XML structure to Generate the file list */
-	workTree(structure,&pass,addFileToListTag);
+	xmlRunOverTree(structure,&pass,fd_addFileToListTag);
 
 	/* All done */
 	list=pass.list;
@@ -155,12 +155,12 @@ typedef struct {
 	int result;
 }tPassFileAndResult;
 
-void checkIfFileExists(const tTag* t,void* pass2) {
+void fd_checkIfFileExists(const tTag* t,void* pass2) {
 	register tPassFileAndResult* pass=pass2;
 	if (equalsIgnoreCase(pass->file,t->file)) pass->result=1;
 }
 
-int isADatFile(const char* vResFile, const char* file) {
+int fd_isADatFile(const char* vResFile, const char* file) {
 	/* Declare error variable */
 	tPassFileAndResult pass;
 	tTag* structure;
@@ -170,10 +170,10 @@ int isADatFile(const char* vResFile, const char* file) {
 	pass.result=0;
 
 	/* Generate XML structure if doesn't exist */
-	if ((error=parseStructure(vResFile,&structure))) return error;
+	if ((error=xmlParseStructure(vResFile,&structure))) return error;
 
 	/* Use the XML structure to Generate the file list */
-	workTree(structure,&pass,checkIfFileExists);
+	xmlRunOverTree(structure,&pass,fd_checkIfFileExists);
 
 	/* All done */
 	return pass.result;
@@ -204,7 +204,7 @@ int fileDirGetFilesImport(tFileDir2* list1,tFileDir2* files,const char* resfile,
 			} else {
 			/* if the DAT type wasn't given by the -t option let's use all the files in the XML */
 				int isdat;
-				isdat=isADatFile(resfile,file);
+				isdat=fd_isADatFile(resfile,file);
 				if (isdat<0) parseError=isdat;
 				if (isdat) {
 					type=eFile;
@@ -215,7 +215,7 @@ int fileDirGetFilesImport(tFileDir2* list1,tFileDir2* files,const char* resfile,
 		}
 
 		if ((!dirs)&&type==eDirectory) {
-			parseError=listAllDatFiles(resfile, file, opt, files);
+			parseError=fd_listAllDatFiles(resfile, file, opt, files);
 		}
 		if (type==eDirectory) dirs++;
 		if (type==eFile) {
@@ -262,7 +262,7 @@ int fileDirGetFilesExport(tFileDir2* list1,tFileDir2* files,int notHasRecursiveF
 			pass.dir=NULL;
 			pass.opt=opt;
 			pass.list=files;
-			recurseDirectory(file,!notHasRecursiveFlag,&pass,addFileToList);
+			recurseDirectory(file,!notHasRecursiveFlag,&pass,fd_addFileToList);
 			files=pass.list;
 		} else {
 			strcpy(output,file);
diff --git a/PR/src/console/main.c b/PR/src/console/main.c
index 8de4b5d..e4423c9 100644
--- a/PR/src/console/main.c
+++ b/PR/src/console/main.c
@@ -50,7 +50,7 @@ main.c: PR console program parsing and IDE
 
 FILE* outputStream;
 
-void syntax() {
+void main_syntax() {
 	fprintf(outputStream,PARSING_HELP_BEGIN);
 	fprintf(outputStream,PARSING_HELP_PART1);
 	fprintf(outputStream,PARSING_HELP_PART2);
@@ -177,14 +177,14 @@ int main (int argc, char **argv) {
 	}
 
 	if (hasFlag(help_flag)) {
-		syntax();
+		main_syntax();
 	} else if (optimizeXmlFile) { /* special case optimize */
 		tTag* tree;
-		tree=parseXmlFile(optimizeXmlFile,&result);
+		tree=xmlParseFile(optimizeXmlFile,&result);
 		if (result==PR_RESULT_SUCCESS) {
-			if (tree) resourceTreeCommonFactor(tree->child);
+			if (tree) xmlOptimizeCommonFactor(tree->child);
 			resourceTreeFixInheritances(&tree);
-			result=generateXMLfile(optimizeXmlFile,tree);
+			result=xmlGenerateFile(optimizeXmlFile,tree);
 			freeTagStructure(tree);
 		}
 		fprintf(outputStream,PR_TEXT_RESULT,errors[-result],result);
@@ -253,7 +253,7 @@ int main (int argc, char **argv) {
 		}
 	}
 
-	freeParsingCache();
+	freeXmlCache();
 	freeAllocation(datAuthor);
 	freeAllocation(datFileName);
 	freeAllocation(extension);
diff --git a/PR/src/include/dat.h b/PR/src/include/dat.h
index a994dfb..a674837 100644
--- a/PR/src/include/dat.h
+++ b/PR/src/include/dat.h
@@ -50,9 +50,9 @@ int checkSum(const unsigned char* data,int size);
 #define PR_DAT_INCLUDE_DATREAD
 #define PR_DAT_INCLUDE_DATWRITE
 
+/* DAT reading and writing primitives */
 #ifdef PR_DAT_INCLUDE_DATREAD
 #ifdef PR_DAT_INCLUDE_DATWRITE
-/* DAT reading and writing primitives */
 int mRWBeginDatFile(const char* vFile, unsigned short int *numberOfItems, int optionflag);
 #define mRWCloseDatFile(dontSave) \
 mReadCloseDatFile();\
@@ -60,20 +60,19 @@ mWriteCloseDatFile(dontSave,optionflag,backupExtension)
 #endif
 #endif
 
-#ifdef PR_DAT_INCLUDE_DATREAD
 /* DAT reading primitives */
+#ifdef PR_DAT_INCLUDE_DATREAD
 int  mReadBeginDatFile(unsigned short int *numberOfItems,const char* vFile);
 int  mReadFileInDatFile(tResource* res, int k);
 int  mReadFileInDatFileId(tResource* res);
 void mReadCloseDatFile();
 #endif
 
-#ifdef PR_DAT_INCLUDE_DATWRITE
 /* DAT writing primitives */
+#ifdef PR_DAT_INCLUDE_DATWRITE
 int  mWriteBeginDatFile(const char* vFile, int optionflag);
 void mWriteFileInDatFile(const tResource* res);
 void mWriteFileInDatFileIgnoreChecksum(const tResource* res);
-/*void mWriteInitResource(tResource** res);*/
 void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension);
 #endif
 
diff --git a/PR/src/include/en.lang.pr.h b/PR/src/include/en.lang.pr.h
index 60c9ff1..5795140 100644
--- a/PR/src/include/en.lang.pr.h
+++ b/PR/src/include/en.lang.pr.h
@@ -48,10 +48,10 @@ pr.h: Princed Resources : English language strings
 
 #define PR_TEXT_FILE_NOT_FOUND    "Result: File or directory '%s' not found\n"
 
-#define PR_TEXT_SCANNING_CURRENT  "Scanning dat files in current directory\n"
-#define PR_TEXT_SCANNING_GIVEN    "Scanning dat files in given directory\n"
+#define PR_TEXT_SCANNING_CURRENT  "Scanning DAT files in current directory\n"
+#define PR_TEXT_SCANNING_GIVEN    "Scanning DAT files in given directory\n"
 
-#define PR_TEXT_IMPORTING_CURRENT "Importing all valid dat files from the current directory\n"
+#define PR_TEXT_IMPORTING_CURRENT "Importing all valid DAT files from the current directory\n"
 #define PR_TEXT_IMPORTING_GIVEN   "Importing all valid files from given directory\n"
 
 #define PR_TEXT_TASK_COMPILE      "Importing '%s' from '%s'\n"
@@ -74,8 +74,8 @@ pr.h: Princed Resources : English language strings
 #define PR_TEXT_EXPORT_ERROR      "'%s' has errors, aborting...\n"
 #define PR_TEXT_EXPORT_BMP_WARN   "Warning: Extracted file may be corrupt\n"
 
-#define PR_TEXT_ERROR_ONE_DIR     "You may select one directory to export all dat files or specifiy dat files.\nBoth actions are not allowed.\n"
-#define PR_TEXT_ERROR_XML_FILE    "Error, check the xml file\n"
+#define PR_TEXT_ERROR_ONE_DIR     "You may select one directory to export all DAT files or specify DAT files.\nBoth actions are not allowed.\n"
+#define PR_TEXT_ERROR_XML_FILE    "Error, check the XML file\n"
 
 /***************************************************************\
 |                        Text Output Arrays                     |
@@ -84,8 +84,8 @@ pr.h: Princed Resources : English language strings
 #define PR_TEXT_ERRORS {\
 	"Success",\
 	NULL, /* help shown */\
-	"Dat file not found",\
-	"Expected dat file, but a directory was given",\
+	"DAT file not found",\
+	"Expected DAT file, but a directory was given",\
 	"DAT file reading permission denied",\
 	"DAT file writing permission denied",\
 	"File not found",\
@@ -102,7 +102,7 @@ pr.h: Princed Resources : English language strings
   "Input line syntax error",\
   "Extraction error",\
 	"-19",\
-	"You may select one directory to export all dat files or specify dat files; both actions are not allowed",\
+	"You may select one directory to export all DAT files or specify DAT files; both actions are not allowed",\
 	"Recursive flag must not be set when you import files",\
 	"No files selected", /* should never happen because default is "." */\
 	"-23"}
@@ -116,21 +116,21 @@ pr.h: Princed Resources : English language strings
 	"Midis file",\
 	"Valid DAT file with undefined content",\
 	"Graphic DAT file",\
-	"Internal PC Speaker dat file",\
+	"Internal PC Speaker DAT file",\
 	NULL,NULL,NULL,\
-	"invalid Pop2 dat file",\
+	"invalid Pop2 DAT file",\
 	"Pop2 level file",\
-	"Pop2 graphic dat file",\
-	"Pop2 wav dat file",\
-	"Pop2 midi dat file",\
-	"Pop2 valid dat file",\
-	"Pop2 graphic dat file"}
+	"Pop2 graphic DAT file",\
+	"Pop2 wav DAT file",\
+	"Pop2 midi DAT file",\
+	"Pop2 valid DAT file",\
+	"Pop2 graphic DAT file"}
 
 #define PR_TEXT_IMPORT_ARRAY {\
 	"File successfully imported",\
 	"DAT file not found or invalid in partial importation",\
 	"DAT File couldn't be open",\
-	"XML Parseing error",\
+	"XML Parsing error",\
 	"No memory",\
 	"XML Attribute not recognized",\
 	"XML File not found"}
@@ -151,9 +151,9 @@ pr.h: Princed Resources : English language strings
   Mandatory arguments to long options are mandatory for short options too.\n\
 \n"
 #define PARSING_HELP_PART1 "\
-   -i, -m, --import[=DIRNAME] imports from DIRNAME into given dat file\n\
-   -c, --classify             returns the dat file type\n\
-   -e, -x, --export[=DIRNAME] exports given dat file into DIRNAME\n\
+   -i, -m, --import[=DIRNAME] imports from DIRNAME into given DAT file\n\
+   -c, --classify             returns the DAT file type\n\
+   -e, -x, --export[=DIRNAME] exports given DAT file into DIRNAME\n\
 \n"
 #define PARSING_HELP_PART2 "\
    -a, --setauthor=NAME       sets your name in extracted plv files\n\
@@ -161,16 +161,16 @@ pr.h: Princed Resources : English language strings
    -f, --force                rewrites your files without prompting\n\
    -g, --cgi                  run as CGI and output mime headers\n\
    -h, -?, --help             display this help and exit\n\
-   -s, --resource=RESFILE     uses an user-specific resource xml file\n\
+   -s, --resource=RESFILE     uses an user-specific resource XML file\n\
 "PARSING_SHOWRAW(PARSING_RAW)
 
 #define PARSING_HELP_PART3 "\
-   -r, --recursive            searches for all dat files (only if DATFILEPATH\n\
-                              is not a dat file)\n\
-   -t, --datfile=DATFILE      specifies a dat file to read resources\n\
+   -r, --recursive            searches for all DAT files (only if DATFILEPATH\n\
+                              is not a DAT file)\n\
+   -t, --datfile=DATFILE      specifies a DAT file to read resources\n\
                               different than the original file\n\
    -z, --compression-level=N  a number from 1 to 7 specifying how hard has PR\n\
-                              to try to reduce the generated dat files\n"
+                              to try to reduce the generated DAT files\n"
 
 #define PARSING_HELP_PART4 "\
                               1 is high speed, low compression, 7 is high\n\
@@ -181,7 +181,7 @@ pr.h: Princed Resources : English language strings
                               any extraction\n\
    -v, --verbose              explain what is being done\n\
        --version              output version information and exit\n\
-       --xml-optimize=XMLFILE optimizes a resources xml file\n\
+       --xml-optimize=XMLFILE optimizes a resources XML file\n\
 \n"
 
 #define PR_TXT_AUTHORS           "Authors"
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h
index 03ea25e..b5cfbd7 100644
--- a/PR/src/include/idlist.h
+++ b/PR/src/include/idlist.h
@@ -38,8 +38,8 @@ idlist.h: Princed Resources : Resource id list headers
 #include "reslist.h" /* tResourceId */
 
 int  parseGivenPath(char* path);
-int  partialListActive();
-int  isInThePartialList(const char* vFile, tResourceId id);
-void freePartialList();
+int  itemMatchingListActive();
+int  isInTheItemMatchingList(const char* vFile, tResourceId id);
+void freeItemMatchingList();
 
 #endif
diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h
index 5f3d3c0..392a9ea 100644
--- a/PR/src/include/memory.h
+++ b/PR/src/include/memory.h
@@ -40,6 +40,8 @@ memory.h: Princed Resources : Memory handling & comparison prototypes
 char* strallocandcopy(const char* text);
 #define freeAllocation(m) if ((m)!=NULL) free(m)
 
+#define ptoi(p) ((p!=NULL)?atoi(p):0)
+
 /* equalsIgnoreCase is built in unless we are in the BSD standards that is taken from string.h */
 #ifdef __USE_BSD
 #include <string.h>
@@ -50,9 +52,9 @@ char* strallocandcopy(const char* text);
 int equalsIgnoreCase2(const char s1[],const char s2[]);
 #endif
 
-char* toLower(const char* txt);
+char* strToLower(const char* txt);
 void str5lowercpy (char* dst,const char* src);
 int matchesIn(const char *s, const char *p);
+int getOrder(const char* order);
 
 #endif
-
diff --git a/PR/src/include/pr.h b/PR/src/include/pr.h
index f5bb5a9..a0c8398 100644
--- a/PR/src/include/pr.h
+++ b/PR/src/include/pr.h
@@ -68,10 +68,10 @@ typedef struct tTag {
 \***************************************************************/
 /* The library EXPORTS are:
  * freeParsedStructure
- * freeParsingCache
+ * freeXmlCache
  * freeTagStructure
- * parseStructure
- * parseXmlFile
+ * xmlParseStructure
+ * xmlParseFile
  * prClassifyDat
  * prExportDat
  * prExportDatOpt
@@ -103,17 +103,17 @@ void  prSetOutput         (FILE* output);
 void  setCompressionLevel (int cl);
 
 /* XML parsing functions */
-tTag* resourceTreeGetChild(tTag* whereAmI);
-tTag* resourceTreeGetNext (tTag* whereAmI);
-int   resourceTreeGetInfo (tTag* whereAmI,	char** tag, char** desc, char** path, char** file, char** type, char** name, char** palette, char** value, char** version, char** number);
-int   parseStructure      (const char* vFile, tTag** structure);
 void  freeParsedStructure (tTag** structure);
-void  freeParsingCache    ();
 void  freeTagStructure    (tTag* structure);
-tTag* parseXmlFile        (const char* vFile,int* error);
-int   generateXMLfile     (const char* vFile,/*const*/ tTag* t);
-void  resourceTreeCommonFactor   (tTag* tag);
+void  freeXmlCache        ();
 void  resourceTreeFixInheritances(tTag* *tree);
+tTag* resourceTreeGetChild(tTag* whereAmI);
+int   resourceTreeGetInfo (tTag* whereAmI,	char** tag, char** desc, char** path, char** file, char** type, char** name, char** palette, char** value, char** version, char** number);
+tTag* resourceTreeGetNext (tTag* whereAmI);
+void  xmlOptimizeCommonFactor    (tTag* tag);
+int   xmlGenerateFile     (const char* vFile,const tTag* t);
+tTag* xmlParseFile        (const char* vFile,int* error);
+int   xmlParseStructure   (const char* vFile, tTag** structure);
 
 /* unknown.xml logging */
 
diff --git a/PR/src/include/reslist.h b/PR/src/include/reslist.h
index a6c2358..067c767 100644
--- a/PR/src/include/reslist.h
+++ b/PR/src/include/reslist.h
@@ -68,7 +68,7 @@ void printr(const tResource* record); /* for debug purposes */
 #define resourceListDrop(r)	list_drop(r)
 
 int resCmp(const void* a,const void* b);
-int resIdCmp(tResourceId a,tResourceId b);
+int resourceListCompareId(tResourceId a,tResourceId b);
 const tResource* resourceListGetElement(tResourceList* r);
 tResourceList resourceListCreate(int isCopy);
 void resourceListAddInfo(tResourceList* r,tResource* res);
diff --git a/PR/src/include/search.h b/PR/src/include/search.h
index 5f2f32e..3aa1bc3 100644
--- a/PR/src/include/search.h
+++ b/PR/src/include/search.h
@@ -42,20 +42,19 @@ search.h: Princed Resources : Abstract XML tree searching prototypes
 #include "common.h" /* tTag */
 #include "reslist.h"
 
-/* parse XML file */
-int parseFile(const char* vFile, const char* datFile, tResourceList *r);
-
 /****************************************************************\
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-const tTag* searchTree(const tTag* t,const char* datFile, const char* id);
-void workTag(const tTag* t,void* pass);
+/* parse XML file */
+int xmlParseFileForResource(const char* vFile, const char* datFile, tResourceList *r);
 
 /* Abstract function that runs all the tree and executes "function(tag,pass)" for each tag */
-void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*));
+void xmlRunOverTree(const tTag* t,void* pass, void (*function)(const tTag*,void*));
 
-void compareXmlFile(tTag* modified,tTag* original);
+#ifdef COMPILE_WITH_COMPARISION
+void xmlCompareFiles(tTag* modified,tTag* original);
+#endif
 
 /* File List Functions */
 char* getFileFromList();
@@ -70,7 +69,5 @@ typedef struct tPassCompare {
 	const tTag* tag;
 }tPassCompare;
 
-int getOrder(const char* order);
-
 #endif
 
diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h
index b950c6d..5dc29ef 100644
--- a/PR/src/include/tree.h
+++ b/PR/src/include/tree.h
@@ -44,9 +44,9 @@ typedef struct {
 	tTag*        itemCursor;
 } tTreeStatus;
 
-void unknown_item(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count, tTreeStatus* status);
-void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status);
-void unknown_deletetreefile(const char* file, tTag* tree);
-void generateXML(int n,tTag* t,FILE* outputStream);
+void treeStatusItem  (int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count, tTreeStatus* status);
+void treeStatusFolder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status);
+void treeDeleteFile  (const char* file, tTag* tree);
+void treeXmlGenerate (int n,const tTag* t,FILE* outputStream);
 
 #endif
diff --git a/PR/src/include/types.h b/PR/src/include/types.h
index a6c2358..067c767 100644
--- a/PR/src/include/types.h
+++ b/PR/src/include/types.h
@@ -68,7 +68,7 @@ void printr(const tResource* record); /* for debug purposes */
 #define resourceListDrop(r)	list_drop(r)
 
 int resCmp(const void* a,const void* b);
-int resIdCmp(tResourceId a,tResourceId b);
+int resourceListCompareId(tResourceId a,tResourceId b);
 const tResource* resourceListGetElement(tResourceList* r);
 tResourceList resourceListCreate(int isCopy);
 void resourceListAddInfo(tResourceList* r,tResource* res);
diff --git a/PR/src/lib/actions/classify.c b/PR/src/lib/actions/classify.c
index b5f6955..e32c666 100644
--- a/PR/src/lib/actions/classify.c
+++ b/PR/src/lib/actions/classify.c
@@ -31,13 +31,13 @@ tasks.c: Princed Resources : File classify routines
   DO NOT remove this copyright notice
 */
 
-#include <stdio.h>
+#include "autodetect.h"
 #include "classify.h"
-#include "memory.h"
+#include "common.h"
 #include "dat.h"
 #include "disk.h" /* mLoadFileArray */
-#include "common.h"
-#include "autodetect.h"
+#include "memory.h"
+#include <stdio.h>
 
 /***************************************************************\
 |                    Get the type of a DAT file                 |
@@ -129,7 +129,9 @@ int prClassify(const char* fileName) {
 			for (i=0;i<fileSize;i++) {
 				checkSum+=fileData[i]<<((3-(i%4))*8);
 			}
-			/* printf("{%lu,%ld},\n",checkSum,fileSize); */
+#ifdef DEBUG_GETCHECKSUM
+			printf("{%lu,%ld},\n",checkSum,fileSize);
+#endif
 
 			/* compare checksum*/
 			for (i=0;x[i].size;i++)
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index 829b76a..ddf20ef 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -48,10 +48,10 @@ export.c: Princed Resources : DAT Extractor
 #include "unknown.h"
 
 #include "bmp.h"
-#include "wav.h"
+#include "mid.h"
 #include "pal.h"
 #include "plv.h"
-#include "mid.h"
+#include "wav.h"
 
 extern FILE* outputStream;
 
@@ -96,7 +96,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 		/* add to res more information from the resource list */
 		resourceListAddInfo(r,&res);
 
-		if (isInThePartialList(res.path,res.id)) { /* If the resource was specified do the tasks */
+		if (isInTheItemMatchingList(res.path,res.id)) { /* If the resource was specified do the tasks */
 			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.data,res.size);
 			if (!(hasFlag(unknown_flag))) { /* If unknown flag is set do nothing but generate the unknown.xml file */
 				if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */
@@ -114,12 +114,12 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 						ok=writeData(res.data,1,vFileext,res.size,optionflag,backupExtension); /* Ignore checksum */
 						break;
 					case eResTypePalette: /* save and remember palette file */
-						/* This will remember the palette for the next images
+						/* Remember the palette for the next images
 						 * (because it's more probable to get all the images after its palette) */
 						mLoadPalette(res.data,image,mReadGetVersion());
 						bufferedPalette=res.id;
 						resourceListAdd(&paletteBuffer,&res);
-						/* This will export the palette */
+						/* Export the palette */
 						ok=mFormatExportPal(res.data,vFileext,res.size,optionflag,backupExtension);
 						break;
 					case eResTypePcspeaker: /* save pcs file */
@@ -131,12 +131,12 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 						break;
 					case eResTypeImage: /* save image */
 						/* Palette handling */
-						if (resIdCmp(res.palette,bufferedPalette)) { /* The palette isn't in the buffer */
+						if (resourceListCompareId(res.palette,bufferedPalette)) { /* The palette isn't in the buffer */
 							tResource readPalette;
 							readPalette.id=res.palette;
-							/* read the palette and load it into memory */
+							/* Read the palette and load it into memory */
 							if (mReadFileInDatFileId(&readPalette)) {
-								/* all right, it's not so bad, I can handle it! I'll buffer the new palette */
+								/* All right, it's not so bad, I can handle it! I'll buffer the new palette */
 								bufferedPalette=readPalette.id;
 								mLoadPalette(readPalette.data,image,mReadGetVersion());
 								resourceListAdd(&paletteBuffer,&readPalette);
@@ -158,7 +158,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 				}
 				if (ok) count++;
 			} else {
-				/* if the DAT file is unknown, add it in the XML */
+				/* If the DAT file is unknown, add it in the XML */
 				getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,format);
 			}
 		}
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index 8b74a53..b523e43 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -85,7 +85,7 @@ int mAddCompiledFileToDatFile(tResource* res,const char* vFile) {
 |                   M A I N   F U N C T I O N                   |
 \***************************************************************/
 
-int fullCompile(const char* vFiledat, const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName,const char* backupExtension) {
+int import_full(const char* vFiledat, const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName,const char* backupExtension) {
 	/*
 		Return values:
 			-1 File couldn't be open for writing
@@ -135,7 +135,7 @@ int fullCompile(const char* vFiledat, const char* vDirExt, tResourceList* r, int
 	return error;
 }
 
-int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName,const char* backupExtension) {
+int import_partial(const char* vFiledat, const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName,const char* backupExtension) {
 	/*
 		Return values:
 			-2 Previous DAT file was invalid
@@ -163,14 +163,14 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r,
 		/* add to res more information from the resource list */
 		resourceListAddInfo(r,&res);
 
-		if (isInThePartialList(res.path,res.id)) { /* If the resource was specified */
+		if (isInTheItemMatchingList(res.path,res.id)) { /* If the resource was specified */
 			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.data,res.size);
 			if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */
 
 			/* get save file name (if unknown document is in the XML) */
 			getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
 
-			/* the file is in the partial list, so I'll import */
+			/* the file is in the partial matching list, so I'll import */
 			if ((newRes.size=mLoadFileArray(vFileext,&newRes.data))>0) {
 				newRes.id=res.id;
 				newRes.type=res.type;
@@ -187,7 +187,7 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r,
 				errors++;
 			}
 		} else {
-			/* the file wasn't in the partial list, so I'll re-copy it from the open DAT file */
+			/* the file wasn't in the partial matching list, so I'll re-copy it from the open DAT file */
 			mWriteFileInDatFileIgnoreChecksum(&res);
 		}
 	}
@@ -200,11 +200,10 @@ int partialCompile(const char* vFiledat, const char* vDirExt, tResourceList* r,
 }
 
 int compile(const char* vFiledat, const char* vDirExt, tResourceList* r, int optionflag, const char* vDatFileName,const char* backupExtension) {
-
-	if (partialListActive()) {
-		return partialCompile(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
+	if (itemMatchingListActive()) {
+		return import_partial(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
 	} else {
-		return fullCompile(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
+		return import_full(vFiledat,vDirExt,r,optionflag,vDatFileName,backupExtension);
 	}
 }
 
diff --git a/PR/src/lib/compression/rle_compress.c b/PR/src/lib/compression/rle_compress.c
index 85019db..f0c89db 100644
--- a/PR/src/lib/compression/rle_compress.c
+++ b/PR/src/lib/compression/rle_compress.c
@@ -50,12 +50,11 @@ void compressRle(const unsigned char* input, int inputSize,
 
 		/* Step 2: Look and copy the string until more than two repeated bytes are found */
 		while (
-			(cursorPix+1<imgEnd)&&  /* bugfix: reads one more */
+			(cursorPix+1<imgEnd)&&  /* reads one more */
 			(
 				(*cursorPix!=*(cursorPix+1))||
 				(
-					/* (*cursorPix==*(cursorPix+1))&& */
-					((cursorPix+2)<imgEnd)&& /* bugfix: reads one more */
+					((cursorPix+2)<imgEnd)&& /* reads one more */
 					(*cursorPix!=*(cursorPix+2))
 				)
 			)&&
diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c
index 47c0232..77823f8 100644
--- a/PR/src/lib/formats/bmp.c
+++ b/PR/src/lib/formats/bmp.c
@@ -32,14 +32,14 @@ bmp.c: Princed Resources : BMP file support
   DO NOT remove this copyright notice
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "common.h"
 #include "bmp.h"
+#include "common.h"
+#include "dat.h"
 #include "disk.h"
 #include "memory.h"
-#include "dat.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 extern FILE* outputStream;
 
diff --git a/PR/src/lib/formats/mid.c b/PR/src/lib/formats/mid.c
index f104e96..1951a42 100644
--- a/PR/src/lib/formats/mid.c
+++ b/PR/src/lib/formats/mid.c
@@ -32,12 +32,12 @@ mid.c: Princed Resources : MIDI files support
 */
 
 /* Includes */
-#include "mid.h"
-#include "disk.h"
 #include "common.h"
 #include "dat.h"
-#include <string.h>
+#include "disk.h"
+#include "mid.h"
 #include <stdlib.h>
+#include <string.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 */
diff --git a/PR/src/lib/formats/wav.c b/PR/src/lib/formats/wav.c
index db5578a..5c6ec05 100644
--- a/PR/src/lib/formats/wav.c
+++ b/PR/src/lib/formats/wav.c
@@ -32,9 +32,9 @@ wav.c: Princed Resources : WAV files support
 */
 
 /* Includes */
-#include "wav.h"
 #include "dat.h"
 #include "disk.h"
+#include "wav.h"
 
 int mFormatExportWav(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
 	FILE*         target;
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index 8fc60cf..114ec4a 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -49,7 +49,10 @@ int verifyImageHeader(const unsigned char *array, int size) {
 	unsigned char imageBitRate;
 	imageBitRate=((unsigned char)array[6]&0xF0);
 	return (size>7) && (!array[5]) && ((imageBitRate==0xB0));
-	/* return (size>7) && (!array[5]) && ((imageBitRate==0xB0)||(imageBitRate==0x00)); */
+	/* NOTE:
+	 * return (size>7) && (!array[5]) && ((imageBitRate==0xB0)||(imageBitRate==0x00));
+	 * works for monochrome images (but is very common and matches more than that)
+	 */
 }
 
 int verifyPaletteHeader(const unsigned char *array, int size) {
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index ca1269b..618dc16 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -35,9 +35,9 @@ dat.c: Princed Resources : DAT format library implementation
 #include <stdlib.h>
 #include <string.h>
 
-#include "disk.h"
 #include "common.h"
 #include "dat.h"
+#include "disk.h"
 
 #include "reslist.h"
 
@@ -90,7 +90,7 @@ int checkSum(const unsigned char* data,int size) {
 #define dat_readCursorGetFlags(r)     ((r.popVersion==pop1)?(1<<24):(r.currentRecord[8]<<16|r.currentRecord[9]<<8|r.currentRecord[10]))
 #define dat_readCursorGetVersion(r)   (r.popVersion)
 
-void rememberIndex(char* to, const char* from) {
+void dat_rememberIndex(char* to, const char* from) {
 	int i=4;
 	from+=3;
 	while (i--) {
@@ -102,7 +102,7 @@ void rememberIndex(char* to, const char* from) {
 	*to=0;
 }
 
-void saveIndex(char* to, const char* from) {
+void dat_saveIndex(char* to, const char* from) {
 	int i=4;
 	int k=0;
 	from+=3;
@@ -128,7 +128,7 @@ int dat_cursorNextIndex(tIndexCursor* r) {
 		}
 
 		/* remember the new slave index name */
-		rememberIndex(r->slaveIndexName,(char*)(r->highData+2+6*r->currentMasterItem));
+		dat_rememberIndex(r->slaveIndexName,(char*)(r->highData+2+6*r->currentMasterItem));
 
 		/* remember the new slave index size */
 		r->slaveItems=array2short(r->highData+array2short(r->highData+6+6*r->currentMasterItem));
@@ -161,7 +161,7 @@ int dat_cursorNext(tIndexCursor* r) {
 void dat_cursorFirst(tIndexCursor* r) {
 	if (r->popVersion==pop2) {
 		/* remember the first slave index name */
-		rememberIndex(r->slaveIndexName,(char*)(r->highData+2));
+		dat_rememberIndex(r->slaveIndexName,(char*)(r->highData+2));
 		r->currentRecord=r->highData+array2short(r->highData+6)+2;
 	} else {
 		r->currentRecord=r->highData+2;
@@ -206,7 +206,7 @@ int dat_cursorMove(tIndexCursor* r,int pos) {
 				/* Great! we found it */
 
 				/* remember the new slave index name */
-				rememberIndex(r->slaveIndexName,(char*)(r->highData+2+6*i));
+				dat_rememberIndex(r->slaveIndexName,(char*)(r->highData+2+6*i));
 
 				/* remember the new slave index size */
 				r->slaveItems=itemCount;
@@ -296,7 +296,7 @@ tIndexCursor dat_createCursor(unsigned char* highData,int highDataSize,unsigned
 		r.masterItems=array2short(highData);
 
 		/* remember the first slave index name */
-		rememberIndex(r.slaveIndexName,(char*)(highData+2));
+		dat_rememberIndex(r.slaveIndexName,(char*)(highData+2));
 
 		/* remember the first slave index size */
 		r.slaveItems=array2short(highData+array2short(highData+6));
@@ -526,7 +526,7 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension
 			strcpy(index,"X");
 			do {
 				if (strncmp(res->id.index,index,4)) {
-					saveIndex(aux,res->id.index);
+					dat_saveIndex(aux,res->id.index);
 					for (c=0;c<4;c++)
 						fwritechar((unsigned char*)(aux+c),writeDatFile);
 					fwriteshort(&totalItems,writeDatFile); /* Junk (I) */
diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c
index e96a0bc..e058983 100644
--- a/PR/src/lib/layers/idlist.c
+++ b/PR/src/lib/layers/idlist.c
@@ -19,7 +19,7 @@
 */
 
 /*
-idlist.c: Princed Resources : Partial Id list routines
+idlist.c: Princed Resources : Matching Id's list routines
 \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
  Copyright 2003 Princed Development Team
   Created: 24 Aug 2003
@@ -36,12 +36,12 @@ idlist.c: Princed Resources : Partial Id list routines
 \***************************************************************/
 
 /* Includes */
-#include <stdio.h>
-#include <string.h> /* strcat strlen */
 #include "disk.h"
+#include "idlist.h"
 #include "memory.h"
 #include "resourcematch.h"
-#include "idlist.h"
+#include <stdio.h>
+#include <string.h> /* strcat strlen */
 
 /* Id list for partial manipulation. Private type */
 typedef struct {
@@ -49,10 +49,10 @@ typedef struct {
 	tResourceMatch* list;
 }tResIdList;
 
-static tResIdList partialList;
+static tResIdList itemMatchingList;
 
-int partialListActive() {
-	return partialList.count;
+int itemMatchingListActive() {
+	return itemMatchingList.count;
 }
 
 /***************************************************************\
@@ -74,15 +74,21 @@ int parseGivenPath(char* path) {
 	 *  datfile.dat@#last            --> *   *    last *
 	 *  datfile.dat@#second          --> *   *    1    *
 	 *  datfile.dat@:shap            --> *   shap *    *
+	 *  datfile.dat@:sh*             --> *   sh*  *    *
 	 *  datfile.dat@:tga palette     --> *   palt *    *
 	 *  datfile.dat@#785             --> *   *    785  *
 	 *  datfile.dat@/a.bmp           --> *   *    *    a.bmp
 	 *  datfile.dat@/img*.bmp        --> *   *    *    img*.bmp
+	 *  datfile.dat@!11              --> \xac11 *    *    *
+	 *  datfile.dat@#!first          --> *   *    >=1  *
+	 *  datfile.dat@!/img*.bmp       --> *   *    *    not img*.bmp
+	 *  datfile.dat@:!sh*            --> *   \xacsh* *    *
+	 *  datfile.dat@0,1,2,3          --> <=3 *    *    *
 	 *
 	 * PRE:
-	 *  partialList.list was not allocated
+	 *  itemMatchingList.list was not allocated
 	 * POST:
-	 *  partialList.count=0 and partialList.list=NULL if all resources
+	 *  itemMatchingList.count=0 and itemMatchingList.list=NULL if all resources
 	 *  path was trimmed in the "@"
 	 */
 
@@ -93,8 +99,8 @@ int parseGivenPath(char* path) {
 	int error=0;
 
 	/* Check if the variable wasn't initialized before */
-	if (partialList.count!=0) return PR_RESULT_ERR_WRONG_PRIMITIVE_CALL;
-	partialList.list=NULL;
+	if (itemMatchingList.count!=0) return PR_RESULT_ERR_WRONG_PRIMITIVE_CALL;
+	itemMatchingList.list=NULL;
 
 	/* Validates the NULL path */
 	if (path==NULL) return PR_RESULT_SUCCESS;
@@ -115,56 +121,56 @@ int parseGivenPath(char* path) {
 	if (!path[separator]) return PR_RESULT_SUCCESS; /* There was no separator */
 
 	/* Count values, separate them with '\0' and allocate memory */
-	partialList.count=1;
+	itemMatchingList.count=1;
 	path[separator]=0; /* Trim the path to the separator */
 	i=++separator;
 	while(path[i]) {
 		if (path[i]==',') {
-			partialList.count++;
+			itemMatchingList.count++;
 			path[i]=0;
 		}
 		i++;
 	}
-	partialList.list=(tResourceMatch*)malloc(sizeof(tResourceMatch)*partialList.count);
+	itemMatchingList.list=(tResourceMatch*)malloc(sizeof(tResourceMatch)*itemMatchingList.count);
 
 	/* Parse values and save them in the list */
-	for(i=separator;(!error)&&(j!=partialList.count);i++) {
-		error=initRM(path+i,partialList.list+j);
+	for(i=separator;(!error)&&(j!=itemMatchingList.count);i++) {
+		error=initRM(path+i,itemMatchingList.list+j);
 		while (path[i]) i++;
 		j++;
 	}
 	if (error) {
-		for (i=0;i<j-1;i++) freeRM(partialList.list+i);
+		for (i=0;i<j-1;i++) freeRM(itemMatchingList.list+i);
 		return PR_RESULT_ERR_COMMAND_LINE_SYNTAX;
 	}
 	return PR_RESULT_SUCCESS;
 }
 
-int isInThePartialList(const char* vFile, tResourceId id) {
+int isInTheItemMatchingList(const char* vFile, tResourceId id) {
 	/*
-		Cases:
-			"path/path@"                     all files are false
-			"path/path"                      all files are true
-			"path/path@12file/jjj.bmp,777"   only file "12file/jjj.bmp" and id 777 are true
-			"path/path@1,2,3"                only ids 1, 2 and 3 are true
-			"path/path@12file/?mage1*.bmp"   each file matching "12file/?mage1*.bmp" is true
-	*/
+	 * Cases:
+	 * "path/path@"                     all files are false
+	 * "path/path"                      all files are true
+	 * "path/path@12file/jjj.bmp,777"   only file "12file/jjj.bmp" and id 777 are true
+	 * "path/path@1,2,3"                only ids 1, 2 and 3 are true
+	 * "path/path@12file/?mage1*.bmp"   each file matching "12file/?mage1*.bmp" is true
+	 */
 	int i;
 
-	if (!partialList.count) return 1; /* true */
+	if (!itemMatchingList.count) return 1; /* true */
 
-	for (i=0;i<partialList.count;i++)
-		if (runRM(partialList.list+i,repairFolders(vFile?vFile:""),&id)) return 1; /* true */
+	for (i=0;i<itemMatchingList.count;i++)
+		if (runRM(itemMatchingList.list+i,repairFolders(vFile?vFile:""),&id)) return 1; /* true */
 
 	return 0; /* false */
 }
 
-void freePartialList() {
-	void* aux=partialList.list;
-	if (partialList.list) {
-		while (partialList.count--) freeRM(partialList.list++);
+void freeItemMatchingList() {
+	void* aux=itemMatchingList.list;
+	if (itemMatchingList.list) {
+		while (itemMatchingList.count--) freeRM(itemMatchingList.list++);
 		free(aux);
 	}
-	partialList.list=NULL;
+	itemMatchingList.list=NULL;
 }
 
diff --git a/PR/src/lib/layers/list.c b/PR/src/lib/layers/list.c
index 30d7b2a..d1b6fab 100644
--- a/PR/src/lib/layers/list.c
+++ b/PR/src/lib/layers/list.c
@@ -32,9 +32,9 @@ list.c: Princed Resources : Order-optimized list implementation
 */
 
 /* Defines */
+#include "list.h"
 #include <stdlib.h>
 #include <string.h> /* memcpy */
-#include "list.h"
 
 tList list_create(int dataSize,int dataCmp(const void*,const void*),void dataFree(void* a)) {
 	tList r;
diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c
index f9814b4..b8c85bb 100644
--- a/PR/src/lib/layers/memory.c
+++ b/PR/src/lib/layers/memory.c
@@ -54,7 +54,7 @@ void str5lowercpy (char* dst,const char* src) {
 	*dst=0;
 }
 
-char* toLower(const char* txt) {
+char* strToLower(const char* txt) {
 	static char ret[5];
 	char* r=ret;
 	while (*txt) {
@@ -85,3 +85,20 @@ int equalsIgnoreCase2(const char s1[],const char s2[]) {
 	return !(s1[i]||s2[i]);
 }
 #endif
+
+int getOrder(const char* order) {
+	if (order) {
+		if (equalsIgnoreCase(order,"first")) {
+			return 0; /* first */
+		} else if (equalsIgnoreCase(order,"second")) {
+			return 1; /* second */
+		} else if (equalsIgnoreCase(order,"last")) {
+			return 65535; /* last */
+		} else {
+			return atoi(order);
+		}
+	} else {
+		return 0; /* else: first */
+	}
+}
+
diff --git a/PR/src/lib/layers/reslist.c b/PR/src/lib/layers/reslist.c
index 7db1ba1..99e85c6 100644
--- a/PR/src/lib/layers/reslist.c
+++ b/PR/src/lib/layers/reslist.c
@@ -32,14 +32,14 @@ reslist.c: Princed Resources : Resource list layer implementation
 */
 
 /* Defines */
-#include "reslist.h"
-#include <string.h> /* strncmp */
 #include "memory.h" /* freeAllocation */
+#include "reslist.h"
 #include <stdio.h> /* debug */
+#include <string.h> /* strncmp */
 
 /* resource list layer (that uses the abstract list layer primitives) */
 
-int resIdCmp(const tResourceId a,const tResourceId b) {
+int resourceListCompareId(const tResourceId a,const tResourceId b) {
 	/* the index has the priority */
 	int c=strncmp(a.index,b.index,5);
 	if (c>0) return GT;
@@ -55,20 +55,17 @@ int resIdCmp(const tResourceId a,const tResourceId b) {
 	return EQ;
 }
 
-int resCmp(const void* a,const void* b) {
-	return resIdCmp(((tResource*)a)->id,((tResource*)b)->id);
+int reslist_compare(const void* a,const void* b) {
+	return resourceListCompareId(((tResource*)a)->id,((tResource*)b)->id);
 }
 
-void resFree(void* a) {
+void freeResource(void* a) {
 	tResource* res=a;
 	freeAllocation(res->desc);
 	freeAllocation(res->name);
 	freeAllocation(res->path);
 }
 
-void resFreeDummy(void* a) {
-}
-
 const tResource* resourceListGetElement(tResourceList* r) {
 	const tResource* ret=list_getCursor(r);
 	if (ret) list_nextCursor(r);
@@ -76,7 +73,7 @@ const tResource* resourceListGetElement(tResourceList* r) {
 }
 
 tResourceList resourceListCreate(int isCopy) {
-	return list_create(sizeof(tResource),resCmp,isCopy?resFreeDummy:resFree);
+	return list_create(sizeof(tResource),reslist_compare,isCopy?NULL:freeResource);
 }
 
 void resourceListAdd(tResourceList* r,tResource* res) {
diff --git a/PR/src/lib/layers/resourcematch.c b/PR/src/lib/layers/resourcematch.c
index 05d40c2..7e8f4bc 100644
--- a/PR/src/lib/layers/resourcematch.c
+++ b/PR/src/lib/layers/resourcematch.c
@@ -31,11 +31,10 @@ resourcematch.c: Princed Resources : Partial list matching abstract layer
   DO NOT remove this copyright notice
 */
 
-#include <stdio.h>
 #include "memory.h"
-#include "search.h" /* getOrder */
 #include "resourcematch.h"
 #include "translate.h" /* translate */
+#include <stdio.h>
 
 #define dVal 1
 #define dInd 2
@@ -59,7 +58,7 @@ void freeRM(tResourceMatch *r) {
 	freeAllocation(r->path);
 }
 
-void xemit(tStatus s, char c) {
+void rm_emit(tStatus s, char c) {
 	static tStatus old=eDone;
 	static char* a=aux;
 	static int x=0;
@@ -102,7 +101,7 @@ int initRM(const char* text, tResourceMatch *r) {
 					if (t!=text) return PR_RESULT_ERR_COMMAND_LINE_SYNTAX; /* one ! inside the val number */
 					result.flag|=nVal;
 				} else { /* default action */
-					xemit(status,*t);
+					rm_emit(status,*t);
 				}
 			}
 			break;
@@ -110,7 +109,7 @@ int initRM(const char* text, tResourceMatch *r) {
 		case '/': /* path */
 			status=ePat;
 			result.flag|=dPat;
-			xemit(status,'/'); /* starts with / */
+			rm_emit(status,'/'); /* starts with / */
 			break;
 		case ':': /* index */
 			if (status!=ePat) { /* after path, no index is allowed */
@@ -124,7 +123,7 @@ int initRM(const char* text, tResourceMatch *r) {
 					return PR_RESULT_ERR_COMMAND_LINE_SYNTAX; /* ind flag has been set, duplicated index? */
 				}
 				result.flag|=dInd;
-			} else xemit(status,*t);
+			} else rm_emit(status,*t);
 			break;
 		case '#': /* order */
 			if (status!=ePat) { /* after path, no order is allowed */
@@ -138,18 +137,18 @@ int initRM(const char* text, tResourceMatch *r) {
 					return PR_RESULT_ERR_COMMAND_LINE_SYNTAX; /* ord flag has been set, duplicated order? */
 				}
 				result.flag|=dOrd;
-			} else xemit(status,*t);
+			} else rm_emit(status,*t);
 			break;
 		case 0:
 			status=eDone;
 			break;
 		default: /* by default "value" */
 			if (status==eVal) result.flag|=dVal;
-			xemit(status,*t);
+			rm_emit(status,*t);
 			break;
 		}
 	}
-	xemit(eDone,0);
+	rm_emit(eDone,0);
 	*r=result;
 
 	if ( ( !(result.flag&dVal) ) && ( result.flag&nVal ) )
@@ -159,7 +158,7 @@ int initRM(const char* text, tResourceMatch *r) {
 }
 
 /* matches becomes false only if the flag is true and the match is false */
-#define compare(n,x,a) m=m&&( (!(r->flag&x)) || ( (!(a)) != (!(r->flag&n)) ))
+#define rm_compare(n,x,a) m=m&&( (!(r->flag&x)) || ( (!(a)) != (!(r->flag&n)) ))
 
 int runRM(const tResourceMatch *r, const char* path, const tResourceId *id) {
 	int m=1; /* by default it matches */
@@ -181,11 +180,11 @@ int runRM(const tResourceMatch *r, const char* path, const tResourceId *id) {
 	rindex=r->index?r->index:null;
 	rpath=r->path?r->path:null;
 
-	/* compare each field */
-	compare(nOrd,dOrd,r->order==id->order);
-	compare(nVal,dVal,r->value==id->value);
-	compare(nInd,dInd,matchesIn(id->index,rindex)||matchesIn(translateInt2Ext(id->index),rindex));
-	compare(nPat,dPat,matchesIn(path,rpath));
+	/* rm_compare each field */
+	rm_compare(nOrd,dOrd,r->order==id->order);
+	rm_compare(nVal,dVal,r->value==id->value);
+	rm_compare(nInd,dInd,matchesIn(id->index,rindex)||matchesIn(translateInt2Ext(id->index),rindex));
+	rm_compare(nPat,dPat,matchesIn(path,rpath));
 
 	return m;
 }
diff --git a/PR/src/lib/layers/stringformat.c b/PR/src/lib/layers/stringformat.c
index 022e4f6..c9d8942 100644
--- a/PR/src/lib/layers/stringformat.c
+++ b/PR/src/lib/layers/stringformat.c
@@ -39,32 +39,32 @@ stringformat.c: Princed Resources : Format string parsing feature routines
 static int i;
 static char buffer[200];
 
-int emit(char c) {
+int sf_emit(char c) {
 	if (i==200) return 0; /* false */
 	buffer[i++]=c;
 	return 1; /* true */
 }
 
-void emitString(const char* txt, int size, int zeroflag) {
+void sf_emitString(const char* txt, int size, int zeroflag) {
 	int complete;
 	int length;
 
 	length=strlen(txt);
 	complete=(length>size)?0:size-length;
 
-	while (complete--) emit(zeroflag?'0':' ');
+	while (complete--) sf_emit(zeroflag?'0':' ');
 
-	for (complete=0;complete<length;complete++) emit(txt[complete]);
+	for (complete=0;complete<length;complete++) sf_emit(txt[complete]);
 }
 
-void recEmit(int k) {
+void sf_recursiveEmit(int k) {
 	if (k) {
-		recEmit(k/10);
-		emit('0'+(k%10));
+		sf_recursiveEmit(k/10);
+		sf_emit('0'+(k%10));
 	}
 }
 
-void emitNumber(int n, int size, int zeroflag) {
+void sf_emitNumber(int n, int size, int zeroflag) {
 	int complete;
 	int digits=0;
 	int k=n;
@@ -76,12 +76,12 @@ void emitNumber(int n, int size, int zeroflag) {
 
 	complete=(digits>size)?0:size-digits;
 
-	while (complete--) emit(zeroflag?'0':' ');
+	while (complete--) sf_emit(zeroflag?'0':' ');
 
-	recEmit(n);
+	sf_recursiveEmit(n);
 }
 
-#define readk(k) (k=*(format++))
+#define sf_read_k(k) (k=*(format++))
 
 const char* parseformat(const char* format,long value,const char* index, const char* type, const char* extension, long numberOfThisType, int order, const char* desc,const char* name) {
 	/* This function parses format in this way:
@@ -116,64 +116,64 @@ const char* parseformat(const char* format,long value,const char* index, const c
 
 	i=0; /* initialize buffer */
 
-	while (readk(k)) { /* for each byte in format as k */
+	while (sf_read_k(k)) { /* for each byte in format as k */
 		if (k=='%') {
 			zeroflag=0;
 			size=0;
 
-			readk(k); /* read next char */
+			sf_read_k(k); /* read next char */
 			if (!k) return NULL; /* just in case the string is finished in the wrong place */
 
 			if (k=='0') { /* it's %0... */
 				zeroflag=1;
-				readk(k); /* read next char */
+				sf_read_k(k); /* read next char */
 				if (!k) return NULL; /* just in case the string is finished in the wrong place */
 			}
 			while (isNumber(k)) { /* it's %0[0-9]... */
 				size=size*10+k-'0';
-				readk(k); /* read next char */
+				sf_read_k(k); /* read next char */
 				if (!k) return NULL; /* just in case the string is finished in the wrong place */
 			}
 			switch (k) {
 			case 'v': /* value */
-				emitNumber(value,size,zeroflag);
+				sf_emitNumber(value,size,zeroflag);
 				break;
 			case 'i': /* index name */
-				emitString(index,size,zeroflag);
+				sf_emitString(index,size,zeroflag);
 				break;
 			case 'I': /* index human name */
-				emitString(translateInt2Ext(index),size,zeroflag);
+				sf_emitString(translateInt2Ext(index),size,zeroflag);
 				break;
 			case 't': /* item type (image, wave, etc) */
-				emitString(type,size,zeroflag);
+				sf_emitString(type,size,zeroflag);
 				break;
 			case 'e': /* extension (bmp, wav, etc) */
-				emitString(extension,size,zeroflag);
+				sf_emitString(extension,size,zeroflag);
 				break;
 			case 'n': /* number of the item typed in %t */
-				emitNumber(numberOfThisType,size,zeroflag);
+				sf_emitNumber(numberOfThisType,size,zeroflag);
 				break;
 			case 'o': /* order number (in case the index and values are the same) */
-				emitNumber(order,size,zeroflag);
+				sf_emitNumber(order,size,zeroflag);
 				break;
 			case 'd': /* description */
-				emitString(desc,size,zeroflag);
+				sf_emitString(desc,size,zeroflag);
 				break;
 			case 'm': /* name */
-				emitString(name,size,zeroflag);
+				sf_emitString(name,size,zeroflag);
 				break;
 			case '%': /* the % symbol */
-				emit(k); /* emit it */
+				sf_emit(k); /* sf_emit it */
 				break;
 			default:
 				return NULL;
 			}
-		} else { /* normal characters are emitted */
-			emit(k);
+		} else { /* normal characters are sf_emitted */
+			sf_emit(k);
 		}
 	}
 
-	return emit(0)?buffer:NULL; /* close the string and return it (return NULL in case of error)*/
+	return sf_emit(0)?buffer:NULL; /* close the string and return it (return NULL in case of error)*/
 }
 
 #ifdef DEBUG_STRINGS
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 44a74c6..ec9f6cb 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -43,7 +43,7 @@ compress.c: Princed Resources : Image Compression Library
  * Definitions:
  *  no compression is called RAW
  *  there are 2 algorithms types: RLE and LZG
- *  we can use the modifier: transpose and not transpose (t)
+ *  we can use the modifier: cmp_transpose and not cmp_transpose (t)
  *  we can use the LZG modifier: Higher (checks more extensively the LZG window
  *   without ignoring less probable patterns) (+)
  *
@@ -114,30 +114,30 @@ void setCompressionLevel(int cl) {
 }
 
 /***************************************************************\
-|                        Image transpose                        |
+|                        Image cmp_transpose                        |
 \***************************************************************/
 
 /* Determines where the transposed byte must be saved */
-int transpose(int x,int w,int h) {
+int cmp_transpose(int x,int w,int h) {
 	return ((x%h)*(w))+(int)(x/h);
 }
 
-void transposeImage(tImage* image,int size) {
+void cmp_transposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
+		outputaux[cmp_transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
 	free(image->pix);
 	image->pix=outputaux;
 }
 
-void antiTransposeImage(tImage* image,int size) {
+void cmp_antiTransposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[cursor]=image->pix[transpose(cursor,image->widthInBytes,image->height)];
+		outputaux[cursor]=image->pix[cmp_transpose(cursor,image->widthInBytes,image->height)];
 	free(image->pix);
 	image->pix=outputaux;
 }
@@ -200,7 +200,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
@@ -210,7 +210,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		default:
 			result=COMPRESS_RESULT_FATAL; /* unknown algorithm */
@@ -233,15 +233,15 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	imageSizeInBytes=image->widthInBytes*image->height;
 
 	/*
-		Perform all compressions
-	*/
+	 * Perform all compressions
+	 */
 
 	/* Forward compression */
 
 	/* COMPRESS_RAW
 	 * The allocation size is the image size.
 	 * The algorithm is hard-coded.
-	 * There is no need to code a transposed version because
+	 * There is no need to code a cmp_transposed version because
 	 * we have no compression to improve.
 	 */
 	compressed[COMPRESS_RAW]=getMemory(imageSizeInBytes);
@@ -293,7 +293,7 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	 * using the image matrix transposed.
 	 */
 	cLevel(3)
-		antiTransposeImage(image,imageSizeInBytes);
+		cmp_antiTransposeImage(image,imageSizeInBytes);
 
 	/* COMPRESS_RLE_UD */
 	cLevel(3) {
@@ -319,8 +319,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 		max_alg++;
 	}
 	/*
-		Process results
-	*/
+	 * Process results
+	 */
 
 	/* Select the best compression (find minimum) */
 	*dataSizeInBytes=compressedSize[COMPRESS_RAW];
@@ -338,8 +338,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	(*dataSizeInBytes)+=6;
 
 	/*
-		Write header
-	*/
+	 * Write header
+	 */
 
 	/* (16 bits)height (Intel short int format) */
 	(*data)[0]=image->height;
@@ -355,4 +355,3 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	for (i=COMPRESS_RAW;i<max_alg;i++) free(compressed[i]);
 	return 1; /* true */
 }
-
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index 44a74c6..ec9f6cb 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -43,7 +43,7 @@ compress.c: Princed Resources : Image Compression Library
  * Definitions:
  *  no compression is called RAW
  *  there are 2 algorithms types: RLE and LZG
- *  we can use the modifier: transpose and not transpose (t)
+ *  we can use the modifier: cmp_transpose and not cmp_transpose (t)
  *  we can use the LZG modifier: Higher (checks more extensively the LZG window
  *   without ignoring less probable patterns) (+)
  *
@@ -114,30 +114,30 @@ void setCompressionLevel(int cl) {
 }
 
 /***************************************************************\
-|                        Image transpose                        |
+|                        Image cmp_transpose                        |
 \***************************************************************/
 
 /* Determines where the transposed byte must be saved */
-int transpose(int x,int w,int h) {
+int cmp_transpose(int x,int w,int h) {
 	return ((x%h)*(w))+(int)(x/h);
 }
 
-void transposeImage(tImage* image,int size) {
+void cmp_transposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
+		outputaux[cmp_transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
 	free(image->pix);
 	image->pix=outputaux;
 }
 
-void antiTransposeImage(tImage* image,int size) {
+void cmp_antiTransposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[cursor]=image->pix[transpose(cursor,image->widthInBytes,image->height)];
+		outputaux[cursor]=image->pix[cmp_transpose(cursor,image->widthInBytes,image->height)];
 	free(image->pix);
 	image->pix=outputaux;
 }
@@ -200,7 +200,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
@@ -210,7 +210,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		default:
 			result=COMPRESS_RESULT_FATAL; /* unknown algorithm */
@@ -233,15 +233,15 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	imageSizeInBytes=image->widthInBytes*image->height;
 
 	/*
-		Perform all compressions
-	*/
+	 * Perform all compressions
+	 */
 
 	/* Forward compression */
 
 	/* COMPRESS_RAW
 	 * The allocation size is the image size.
 	 * The algorithm is hard-coded.
-	 * There is no need to code a transposed version because
+	 * There is no need to code a cmp_transposed version because
 	 * we have no compression to improve.
 	 */
 	compressed[COMPRESS_RAW]=getMemory(imageSizeInBytes);
@@ -293,7 +293,7 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	 * using the image matrix transposed.
 	 */
 	cLevel(3)
-		antiTransposeImage(image,imageSizeInBytes);
+		cmp_antiTransposeImage(image,imageSizeInBytes);
 
 	/* COMPRESS_RLE_UD */
 	cLevel(3) {
@@ -319,8 +319,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 		max_alg++;
 	}
 	/*
-		Process results
-	*/
+	 * Process results
+	 */
 
 	/* Select the best compression (find minimum) */
 	*dataSizeInBytes=compressedSize[COMPRESS_RAW];
@@ -338,8 +338,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	(*dataSizeInBytes)+=6;
 
 	/*
-		Write header
-	*/
+	 * Write header
+	 */
 
 	/* (16 bits)height (Intel short int format) */
 	(*data)[0]=image->height;
@@ -355,4 +355,3 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	for (i=COMPRESS_RAW;i<max_alg;i++) free(compressed[i]);
 	return 1; /* true */
 }
-
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index 44a74c6..ec9f6cb 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -43,7 +43,7 @@ compress.c: Princed Resources : Image Compression Library
  * Definitions:
  *  no compression is called RAW
  *  there are 2 algorithms types: RLE and LZG
- *  we can use the modifier: transpose and not transpose (t)
+ *  we can use the modifier: cmp_transpose and not cmp_transpose (t)
  *  we can use the LZG modifier: Higher (checks more extensively the LZG window
  *   without ignoring less probable patterns) (+)
  *
@@ -114,30 +114,30 @@ void setCompressionLevel(int cl) {
 }
 
 /***************************************************************\
-|                        Image transpose                        |
+|                        Image cmp_transpose                        |
 \***************************************************************/
 
 /* Determines where the transposed byte must be saved */
-int transpose(int x,int w,int h) {
+int cmp_transpose(int x,int w,int h) {
 	return ((x%h)*(w))+(int)(x/h);
 }
 
-void transposeImage(tImage* image,int size) {
+void cmp_transposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
+		outputaux[cmp_transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
 	free(image->pix);
 	image->pix=outputaux;
 }
 
-void antiTransposeImage(tImage* image,int size) {
+void cmp_antiTransposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[cursor]=image->pix[transpose(cursor,image->widthInBytes,image->height)];
+		outputaux[cursor]=image->pix[cmp_transpose(cursor,image->widthInBytes,image->height)];
 	free(image->pix);
 	image->pix=outputaux;
 }
@@ -200,7 +200,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
@@ -210,7 +210,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		default:
 			result=COMPRESS_RESULT_FATAL; /* unknown algorithm */
@@ -233,15 +233,15 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	imageSizeInBytes=image->widthInBytes*image->height;
 
 	/*
-		Perform all compressions
-	*/
+	 * Perform all compressions
+	 */
 
 	/* Forward compression */
 
 	/* COMPRESS_RAW
 	 * The allocation size is the image size.
 	 * The algorithm is hard-coded.
-	 * There is no need to code a transposed version because
+	 * There is no need to code a cmp_transposed version because
 	 * we have no compression to improve.
 	 */
 	compressed[COMPRESS_RAW]=getMemory(imageSizeInBytes);
@@ -293,7 +293,7 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	 * using the image matrix transposed.
 	 */
 	cLevel(3)
-		antiTransposeImage(image,imageSizeInBytes);
+		cmp_antiTransposeImage(image,imageSizeInBytes);
 
 	/* COMPRESS_RLE_UD */
 	cLevel(3) {
@@ -319,8 +319,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 		max_alg++;
 	}
 	/*
-		Process results
-	*/
+	 * Process results
+	 */
 
 	/* Select the best compression (find minimum) */
 	*dataSizeInBytes=compressedSize[COMPRESS_RAW];
@@ -338,8 +338,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	(*dataSizeInBytes)+=6;
 
 	/*
-		Write header
-	*/
+	 * Write header
+	 */
 
 	/* (16 bits)height (Intel short int format) */
 	(*data)[0]=image->height;
@@ -355,4 +355,3 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	for (i=COMPRESS_RAW;i<max_alg;i++) free(compressed[i]);
 	return 1; /* true */
 }
-
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 44a74c6..ec9f6cb 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -43,7 +43,7 @@ compress.c: Princed Resources : Image Compression Library
  * Definitions:
  *  no compression is called RAW
  *  there are 2 algorithms types: RLE and LZG
- *  we can use the modifier: transpose and not transpose (t)
+ *  we can use the modifier: cmp_transpose and not cmp_transpose (t)
  *  we can use the LZG modifier: Higher (checks more extensively the LZG window
  *   without ignoring less probable patterns) (+)
  *
@@ -114,30 +114,30 @@ void setCompressionLevel(int cl) {
 }
 
 /***************************************************************\
-|                        Image transpose                        |
+|                        Image cmp_transpose                        |
 \***************************************************************/
 
 /* Determines where the transposed byte must be saved */
-int transpose(int x,int w,int h) {
+int cmp_transpose(int x,int w,int h) {
 	return ((x%h)*(w))+(int)(x/h);
 }
 
-void transposeImage(tImage* image,int size) {
+void cmp_transposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
+		outputaux[cmp_transpose(cursor,image->widthInBytes,image->height)]=image->pix[cursor];
 	free(image->pix);
 	image->pix=outputaux;
 }
 
-void antiTransposeImage(tImage* image,int size) {
+void cmp_antiTransposeImage(tImage* image,int size) {
 	unsigned char* outputaux=getMemory(size);
 	int cursor;
 
 	for (cursor=0;cursor<size;cursor++)
-		outputaux[cursor]=image->pix[transpose(cursor,image->widthInBytes,image->height)];
+		outputaux[cursor]=image->pix[cmp_transpose(cursor,image->widthInBytes,image->height)];
 	free(image->pix);
 	image->pix=outputaux;
 }
@@ -200,7 +200,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
@@ -210,7 +210,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
-			transposeImage(image,imageSizeInBytes);
+			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		default:
 			result=COMPRESS_RESULT_FATAL; /* unknown algorithm */
@@ -233,15 +233,15 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	imageSizeInBytes=image->widthInBytes*image->height;
 
 	/*
-		Perform all compressions
-	*/
+	 * Perform all compressions
+	 */
 
 	/* Forward compression */
 
 	/* COMPRESS_RAW
 	 * The allocation size is the image size.
 	 * The algorithm is hard-coded.
-	 * There is no need to code a transposed version because
+	 * There is no need to code a cmp_transposed version because
 	 * we have no compression to improve.
 	 */
 	compressed[COMPRESS_RAW]=getMemory(imageSizeInBytes);
@@ -293,7 +293,7 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	 * using the image matrix transposed.
 	 */
 	cLevel(3)
-		antiTransposeImage(image,imageSizeInBytes);
+		cmp_antiTransposeImage(image,imageSizeInBytes);
 
 	/* COMPRESS_RLE_UD */
 	cLevel(3) {
@@ -319,8 +319,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 		max_alg++;
 	}
 	/*
-		Process results
-	*/
+	 * Process results
+	 */
 
 	/* Select the best compression (find minimum) */
 	*dataSizeInBytes=compressedSize[COMPRESS_RAW];
@@ -338,8 +338,8 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	(*dataSizeInBytes)+=6;
 
 	/*
-		Write header
-	*/
+	 * Write header
+	 */
 
 	/* (16 bits)height (Intel short int format) */
 	(*data)[0]=image->height;
@@ -355,4 +355,3 @@ int mCompressGraphic(unsigned char* *data,tImage* image, int* dataSizeInBytes) {
 	for (i=COMPRESS_RAW;i<max_alg;i++) free(compressed[i]);
 	return 1; /* true */
 }
-
diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c
index f7bf35a..14322b8 100644
--- a/PR/src/lib/pr.c
+++ b/PR/src/lib/pr.c
@@ -53,17 +53,17 @@ pr.c: Main source file for Princed Resources library
 
 #include "common.h"
 
+#include "classify.h"
 #include "export.h"
 #include "import.h"
-#include "classify.h"
 
 #include "disk.h"      /* getFileNameFromPath */
 #include "idlist.h"
-#include "reslist.h"
 #include "memory.h"    /* getMemory, free */
-#include "unknown.h"
+#include "reslist.h"
 
 #include "search.h"    /* parse */
+#include "unknown.h"
 
 /***************************************************************\
 |                      Main working functions                   |
@@ -143,7 +143,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 	currentDatFileName=strallocandcopy(aux);
 
 	/* Parse XML and export the file */
-	a=parseFile(vResFile,currentDatFileName,&r);
+	a=xmlParseFileForResource(vResFile,currentDatFileName,&r);
 	if (a==PR_RESULT_SUCCESS) {
 		/* exporting errors/no errors */
 		a=extract(currentDatFile,vDirName,&r,opt,currentDatFileName,datAuthor,backupExtension,format);
@@ -151,7 +151,7 @@ int prExportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 	resourceListDrop(&r);
 	free(currentDatFileName);
 	free(currentDatFile);
-	freePartialList();
+	freeItemMatchingList();
 
 	return a;
 }
@@ -219,7 +219,7 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 	currentDatFileName=strallocandcopy(aux);
 
 	/* Parse XML and import files */
-	a=parseFile(vResFile,currentDatFileName,&r);
+	a=xmlParseFileForResource(vResFile,currentDatFileName,&r);
 	if (a==PR_RESULT_SUCCESS) {
 		/* importing errors/no errors */
 		a=compile (currentDatFile, vDirName,&r,opt,currentDatFileName,backupExtension);
@@ -227,7 +227,7 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 	resourceListDrop(&r);
 	free(currentDatFileName);
 	free(currentDatFile);
-	freePartialList();
+	freeItemMatchingList();
 	return a;
 }
 
diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c
index d137b98..51bd71a 100644
--- a/PR/src/lib/xml/parse.c
+++ b/PR/src/lib/xml/parse.c
@@ -62,22 +62,22 @@ const char* getExtDesc(int 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=='?'))
+#define parse_IsSpace(c) ((c==' ')||(c==9))||(c=='\n')||(c=='\r')
+#define parse_IsChar(c) ((('a'<=c)&&(c<='z'))||(('A'<=c)&&(c<='Z'))||(c=='_')||(c=='-')||(c=='?'))
 
-#define Separate while (IsSpace(*i)) i++
-#define NextWord(i) while (IsChar(*(i))) (i)++
+#define parse_Separate while (parse_IsSpace(*i)) i++
+#define parse_NextWord(i) while (parse_IsChar(*(i))) (i)++
 
-#define FillAttr(a,b) if (equalsIgnoreCase(attr,b)) { freeAllocation(a); (a)=(val); return 0;}
+#define parse_FillAttr(a,b) if (equalsIgnoreCase(attr,b)) { freeAllocation(a); (a)=(val); return 0;}
 
-#define TotalInheritance(attribute) \
+#define parse_TotalInheritance(attribute) \
 		if ((tag->attribute==NULL)&&(father->attribute!=NULL)) {\
 			x=strlen(father->attribute)+1;\
 			tag->attribute=(char*)malloc(x);\
 			memcpy(tag->attribute,father->attribute,x);\
 		}
 
-#define ParseError return PR_RESULT_ERR_XML_PARSING
+#define parse_Error return PR_RESULT_ERR_XML_PARSING
 
 tTag* getTagStructure() {
 	/* initializes */
@@ -131,7 +131,7 @@ void freeTagStructure(tTag* t) {
 	free(t);
 }
 
-int attribFill(char* attr,char* val, tTag* t) {
+int parse_attribFill(char* attr,char* val, tTag* t) {
 	/*
 	 * PR_RESULT_ERR_XML_ATTR  Attribute mismatch
 	 * PR_RESULT_SUCCESS       Ok
@@ -142,24 +142,24 @@ int attribFill(char* attr,char* val, tTag* t) {
 		return PR_RESULT_SUCCESS;
 	}
 
-	FillAttr(t->desc,"desc");
-	FillAttr(t->path,"external"); /* external is a path alias for old compatibility */
-	FillAttr(t->path,"path");
-	FillAttr(t->file,"file");
-	FillAttr(t->type,"type");
-	FillAttr(t->type,"itemtype"); /* deprecated alias for type */
-	FillAttr(t->name,"name");
-	FillAttr(t->name,"title"); /* title is a name alias */
-	FillAttr(t->palette,"palette");
-	FillAttr(t->value,"value");
-	FillAttr(t->index,"index");
-	FillAttr(t->order,"order");
-	FillAttr(t->paletteindex,"paletteindex");
-	FillAttr(t->paletteorder,"paletteorder");
-	FillAttr(t->version,"version");
-	FillAttr(t->number,"levelnumber"); /* levelnumber is a number alias */
-	FillAttr(t->number,"number");
-	FillAttr(t->flags,"flags");
+	parse_FillAttr(t->desc,"desc");
+	parse_FillAttr(t->path,"external"); /* external is a path alias for old compatibility */
+	parse_FillAttr(t->path,"path");
+	parse_FillAttr(t->file,"file");
+	parse_FillAttr(t->type,"type");
+	parse_FillAttr(t->type,"itemtype"); /* deprecated alias for type */
+	parse_FillAttr(t->name,"name");
+	parse_FillAttr(t->name,"title"); /* title is a name alias */
+	parse_FillAttr(t->palette,"palette");
+	parse_FillAttr(t->value,"value");
+	parse_FillAttr(t->index,"index");
+	parse_FillAttr(t->order,"order");
+	parse_FillAttr(t->paletteindex,"paletteindex");
+	parse_FillAttr(t->paletteorder,"paletteorder");
+	parse_FillAttr(t->version,"version");
+	parse_FillAttr(t->number,"levelnumber"); /* levelnumber is a number alias */
+	parse_FillAttr(t->number,"number");
+	parse_FillAttr(t->flags,"flags");
 
 	return PR_RESULT_ERR_XML_ATTR;
 }
@@ -169,7 +169,7 @@ int attribFill(char* attr,char* val, tTag* t) {
 \****************************************************************/
 
 /* Parse text functions */
-int parseNext(char** pString, tTag* tag) {
+int parse_parseNext(char** pString, tTag* tag) {
 	/*
 	 * PR_RESULT_ERR_XML_ATTR    Attribute not recognized
 	 * PR_RESULT_ERR_MEMORY      No memory
@@ -186,7 +186,7 @@ int parseNext(char** pString, tTag* tag) {
 	int size;
 	char* i=*pString;
 
-	Separate;
+	parse_Separate;
 
 	if (*i=='>') {
 		*pString=i+1;
@@ -194,21 +194,21 @@ int parseNext(char** pString, tTag* tag) {
 	}
 	if (*i=='/') {
 		i++;
-		Separate;
+		parse_Separate;
 		if (*i=='>') {
 			*pString=i+1;
 			return XML_TAG_CLOSE;
 		} else {
-			ParseError;
+			parse_Error;
 		}
 	}
 
 	start=i;
-	NextWord(i);
-	if (start==i) ParseError;
-	if (*i==0)    ParseError;
+	parse_NextWord(i);
+	if (start==i) parse_Error;
+	if (*i==0)    parse_Error;
 
-	if (!(IsSpace(*i)||(*i=='=')||(*i=='>'))) ParseError;
+	if (!(parse_IsSpace(*i)||(*i=='=')||(*i=='>'))) parse_Error;
 
 	size=(long int)i-(long int)start; /* Note: casted to long for portability with 64 bits architectures */
 	attribute=(char*)malloc(1+size);
@@ -220,7 +220,7 @@ int parseNext(char** pString, tTag* tag) {
 		int k=0;
 		/* It's a text attribute */
 		i++;
-		if (*i!='"') ParseError;
+		if (*i!='"') parse_Error;
 		i++;
 		/* Parse until the next " */
 		for(start=i; (k<MAX_VALUE_SIZE)&&(*i!='"')&&(*i!=0) ;i++) {
@@ -246,7 +246,7 @@ int parseNext(char** pString, tTag* tag) {
 		}
 		if ((*i)!='"') {
 			free(attribute);
-			ParseError;
+			parse_Error;
 		}
 		i++;
 		value=(char*)malloc(k+1);
@@ -266,7 +266,7 @@ int parseNext(char** pString, tTag* tag) {
 		value[0]=0;
 	}
 
-	if (attribFill(attribute,value,tag)) {
+	if (parse_attribFill(attribute,value,tag)) {
 		free(attribute);
 		free(value);
 		return PR_RESULT_ERR_XML_ATTR;
@@ -292,19 +292,19 @@ int getNextTag(char** pString, char** value) {
 	char* start;
 	int   size;
 
-	Separate;
+	parse_Separate;
 
 	if (*i=='<') {
 		/* it is a tag */
 		i++;
-		Separate;
+		parse_Separate;
 		if (*i=='/') {
 			result=XML_WAS_CLOSER;
 			i++;
 		} else {
 			if ((*i=='!')||(*i=='?')) {
 				while ((*i)&&((*i)!='>')) i++;
-				if (!(*i)) ParseError;
+				if (!(*i)) parse_Error;
 				i++;
 				if (!(*i)) return XML_WAS_EOD;
 				result=getNextTag(&i,value);
@@ -315,9 +315,9 @@ int getNextTag(char** pString, char** value) {
 			}
 		}
 		start=i;
-		NextWord(i);
-		if (start==i) ParseError;
-		if (*i==0)    ParseError;
+		parse_NextWord(i);
+		if (start==i) parse_Error;
+		if (*i==0)    parse_Error;
 		i++;
 
 		size=(int)((long int)i-(long int)start); /* Note: casted to long for portability with 64 bits architectures */
@@ -342,7 +342,7 @@ int getNextTag(char** pString, char** value) {
 }
 
 /* Parse Tree functions */
-tTag* makeTree(char** p,char* name, int* error,tTag* father) {
+tTag* parse_makeTree(char** p,char* name, int* error,tTag* father) {
 	/* *error
 	 * PR_RESULT_ERR_XML_ATTR    Attribute not recognized
 	 * PR_RESULT_ERR_MEMORY      No memory
@@ -358,7 +358,7 @@ tTag* makeTree(char** p,char* name, int* error,tTag* father) {
 	tag=getTagStructure();
 	tag->tag=name;
 
-	while (!((*error)=parseNext(p, tag)));
+	while (!((*error)=parse_parseNext(p, tag)));
 
 	if ((*error)<0) {freeTagStructure(tag);return NULL;} /* Fatal error */
 	/* (*error) is
@@ -376,15 +376,15 @@ tTag* makeTree(char** p,char* name, int* error,tTag* father) {
 		int x;
 		char* str;
 
-		TotalInheritance(palette);
-		TotalInheritance(paletteindex);
-		TotalInheritance(paletteorder);
-		TotalInheritance(type);
-		TotalInheritance(file);
-		TotalInheritance(index);
-		TotalInheritance(order);
-		TotalInheritance(flags);
-		/* PartialConcatInheritance(tag->path,father->path,tag->value); */
+		parse_TotalInheritance(palette);
+		parse_TotalInheritance(paletteindex);
+		parse_TotalInheritance(paletteorder);
+		parse_TotalInheritance(type);
+		parse_TotalInheritance(file);
+		parse_TotalInheritance(index);
+		parse_TotalInheritance(order);
+		parse_TotalInheritance(flags);
+		/* parse_PartialConcatInheritance(tag->path,father->path,tag->value); */
 		if ((tag->value==NULL)||(tag->path!=NULL)) {
 			/* Make sure paths do exist */
 			if (father->path==NULL) {father->path=(char*)malloc(1);*(father->path)=0;}
@@ -418,10 +418,10 @@ tTag* makeTree(char** p,char* name, int* error,tTag* father) {
 		switch (result) {
 			case XML_WAS_TAG:
 				if (children==NULL) {
-					tag->child=makeTree(p,value,error,tag);
+					tag->child=parse_makeTree(p,value,error,tag);
 					children=tag->child;
 				} else {
-					children->next=makeTree(p,value,error,tag);
+					children->next=parse_makeTree(p,value,error,tag);
 					children=children->next;
 				}
 				if (*error) {freeTagStructure(tag); return NULL;}
@@ -468,7 +468,7 @@ void showTag(int n,tTag* t) {
 
 #endif
 
-tTag* parseXmlFile(const char* vFile,int* error) {
+tTag* xmlParseFile(const char* vFile,int* error) {
 	/* error may take the following values:
 	 * PR_RESULT_ERR_XML_PARSING Parse error
 	 * PR_RESULT_ERR_MEMORY      No memory
@@ -498,7 +498,7 @@ tTag* parseXmlFile(const char* vFile,int* error) {
 	}
 
 	father=getTagStructure();
-	tag=makeTree(&p,value,error,father);
+	tag=parse_makeTree(&p,value,error,father);
 
 	if ((*error)<0) {
 		freeTagStructure(tag);
@@ -532,7 +532,7 @@ static char lastFile[256]="";
 static int xmlStructureError=0;
 
 /* cache parsed structure. If null is passed the default name will be used */
-int parseStructure(const char* vFile,tTag** structure) {
+int xmlParseStructure(const char* vFile,tTag** structure) {
 	/* Resources input XML tree. Private+abstract variable */
 	static const char defaultXmlFile[]=RES_XML_RESOURC_XML;
 
@@ -542,7 +542,7 @@ int parseStructure(const char* vFile,tTag** structure) {
 	if (strcmp(lastFile,vFile)) {
 		/* if the file is different than the cached file */
 		freeParsedStructure(&xmlStructure);
-		xmlStructure=parseXmlFile(vFile,&xmlStructureError);
+		xmlStructure=xmlParseFile(vFile,&xmlStructureError);
 		strncpy(lastFile,vFile,256); /* remember the new cached filename */
 	}
 
@@ -555,7 +555,7 @@ int parseStructure(const char* vFile,tTag** structure) {
 	return xmlStructureError;
 }
 
-void freeParsingCache() {
+void freeXmlCache() {
 	freeParsedStructure(&xmlStructure);
 	lastFile[0]=0;
 }
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index 00bcacf..985ad39 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -49,61 +49,45 @@ search.c: Princed Resources : Specific XML handling functions
 \***************************************************************/
 
 /* parse file */
-int parseFile(const char* vFile, const char* datFile, tResourceList *rlist) {
+void search_workTag(const tTag* t,void* pass);
+
+int xmlParseFileForResource(const char* vFile, const char* datFile, tResourceList *rlist) {
 	/* Declare error variable */
 	int error;
 	tPassWork pass;
 	tTag* structure;
 
 	/* Generate XML structure if doesn't exist */
-	if ((error=parseStructure(vFile,&structure))) return error;
+	if ((error=xmlParseStructure(vFile,&structure))) return error;
 
 	/* Use the XML structure to Generate the resource structure of the file */
 	pass.datFile=datFile;
 	pass.rlist=rlist;
-	workTree(structure,&pass,workTag);
+	xmlRunOverTree(structure,&pass,search_workTag);
 
 	/* All done */
 	return PR_RESULT_SUCCESS;
 }
 
-int getOrder(const char* order) {
-	if (order) {
-		if (equalsIgnoreCase(order,"first")) {
-			return 0; /* first */
-		} else if (equalsIgnoreCase(order,"second")) {
-			return 1; /* second */
-		} else if (equalsIgnoreCase(order,"last")) {
-			return 65535; /* last */
-		} else {
-			return atoi(order);
-		}
-	} else {
-		return 0; /* else: first */
-	}
-}
-
 /****************************************************************\
 |                   Tag Tree Searching Functions                 |
 \****************************************************************/
 
-#define ptoi(p) ((p!=NULL)?atoi(p):0)
-
-#define keepStringAttribute(attribute) res.attribute=strallocandcopy(t->attribute)
-#define keepIntAttribute(attribute,type) res.attribute=(type)ptoi(t->attribute);
-#define keepIdAttributes(attribute,idnum,idindex) \
+#define search_keepStringAttribute(attribute) res.attribute=strallocandcopy(t->attribute)
+#define search_keepIntAttribute(attribute,type) res.attribute=(type)ptoi(t->attribute);
+#define search_keepIdAttributes(attribute,idnum,idindex) \
 	res.attribute.value=(unsigned short int)ptoi(t->idnum);\
 	if (t->idindex) str5lowercpy(res.attribute.index,translateExt2Int(t->idindex));\
 	else res.attribute.index[0]=0
 
-#define keepIdAttributesElse(attribute,idnum,idindex,idelse) \
+#define search_keepIdAttributesElse(attribute,idnum,idindex,idelse) \
 	res.attribute.value=(unsigned short int)ptoi(t->idnum);\
 	if (t->idindex) str5lowercpy(res.attribute.index,translateExt2Int(t->idindex));\
 	else str5lowercpy(res.attribute.index,t->idelse)
 
-void workTag(const tTag* t,void* pass) {
+void search_workTag(const tTag* t,void* pass) {
 	/*
-		If the tag matches, it is converted to resource and added to the array
+	 * If the tag matches, it is converted to resource and added to the array
 	*/
 
 	/* Declare variables */
@@ -137,25 +121,25 @@ void workTag(const tTag* t,void* pass) {
 	res.palette.order=getOrder(t->paletteorder);
 
 	/* Copy id and palette id */
-	keepIdAttributes(id,value,index);
-	keepIdAttributesElse(palette,palette,paletteindex,index);
+	search_keepIdAttributes(id,value,index);
+	search_keepIdAttributesElse(palette,palette,paletteindex,index);
 
 	/* Copy number, title, desc and path */
-	keepIntAttribute(number,unsigned char);    /* Transforms the char* levelnumer/number attribute into a char value, if error, demo level is used */
+	search_keepIntAttribute(number,unsigned char);    /* Transforms the char* levelnumer/number attribute into a char value, if error, demo level is used */
 	if (t->flags) {
 		res.flags=strtol(t->flags,&end,0);
 		if (*end) return;
 	} else {
 		res.flags=0;
 	}
-	keepStringAttribute(desc);  /* only for plv */
-	keepStringAttribute(name);  /* only for plv */
-	keepStringAttribute(path);
+	search_keepStringAttribute(desc);  /* only for plv */
+	search_keepStringAttribute(name);  /* only for plv */
+	search_keepStringAttribute(path);
 
 	resourceListAdd(rlist,&res);
 }
 
-void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*)) {
+void xmlRunOverTree(const tTag* t,void* pass, void (*function)(const tTag*,void*)) {
 	/*
 		Runs the given function for each matching tag
 	*/
@@ -166,7 +150,7 @@ void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*)) {
 		children=t->child;
 
 		while (children!=NULL) {
-			workTree(children,pass,function);
+			xmlRunOverTree(children,pass,function);
 			children=children->next;
 		}
 	}
@@ -176,14 +160,14 @@ void workTree(const tTag* t,void* pass, void (*function)(const tTag*,void*)) {
 |                       Compare two XML files                    |
 \****************************************************************/
 
-#ifdef DO_NOT_IGNORE_COMPARATION
+#ifdef COMPILE_WITH_COMPARISION
 
 static int compareStatisticsOk=0;
 static int compareStatisticsTotals=0;
 static int compareStatisticsWarnings=0;
 extern FILE* outputStream;
 
-const tTag* searchTree(const tTag* t,const char* datFile, const char* id) {
+const tTag* search_searchTree(const tTag* t,const char* datFile, const char* id) {
 	/* tTag*
 		tag pointer if found
 		NULL if not found
@@ -198,7 +182,7 @@ const tTag* searchTree(const tTag* t,const char* datFile, const char* id) {
 		children=t->child;
 
 		while (children!=NULL) {
-			if (NULL!=(result=searchTree(children,datFile,id))) {
+			if (NULL!=(result=search_searchTree(children,datFile,id))) {
 				return result;
 			}
 			children=children->next;
@@ -207,14 +191,14 @@ const tTag* searchTree(const tTag* t,const char* datFile, const char* id) {
 	return NULL;
 }
 
-void compareXmlFileForTag(const tTag* tag,void* pass) {
+void search_compareForeach(const tTag* tag,void* pass) {
 	const tTag* modified;
 	const tTag* result;
 
 	modified=((tPassCompare*)pass)->tag;
 
 	if ((tag->file)&&(tag->value)) {
-		result=searchTree(modified,tag->file,tag->value);
+		result=search_searchTree(modified,tag->file,tag->value);
 		if (!result) {
 			fprintf(outputStream,"Error: Item not found: '%s@%s'\n",tag->value,tag->file);
 			fprintf(outputStream,"-> <item value=\"%s\" path=\"%s\" type=\"%s\" palette=\"%s\">%s</item>\n",
@@ -236,11 +220,11 @@ void compareXmlFileForTag(const tTag* tag,void* pass) {
 	}
 }
 
-void compareXmlFile(tTag* modified,tTag* original) {
+void xmlCompareFiles(tTag* modified,tTag* original) {
 	tPassCompare pass;
 	pass.tag=modified;
 
-	workTree(original,&pass,compareXmlFileForTag);
+	xmlRunOverTree(original,&pass,search_compareForeach);
 	fprintf(outputStream,"Statistics:\n Totals: %d\n Working: %d (%5.2f%%)\n Warnings: %d\n Missing: %d (%5.2f%%)\n",
 		compareStatisticsTotals,
 		compareStatisticsOk,(float)(100*(float)compareStatisticsOk/compareStatisticsTotals),
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index bf67815..1d7a1f4 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -79,7 +79,7 @@ typedef struct {
 	int count;
 }tAttrCount;
 
-int attrcmp(const void* x,const void* y) {
+int tree_attrcmp(const void* x,const void* y) {
 	register const tAttrCount* a=x;
 	register const tAttrCount* b=y;
 	/* the index has the priority */
@@ -89,13 +89,12 @@ int attrcmp(const void* x,const void* y) {
 	return EQ;
 }
 
-void increase(const char* attr,tList* l,int *lcount) {
+void tree_increaseList(const char* attr,tList* l,int *lcount) {
 	tAttrCount a;
 	tAttrCount* aux;
 
 	if (!attr) return; /* if not attribute, do nothing */
 
-/*	printf("increase: %s\n",attr);*/
 	a.attr=attr;
 	a.count=1; /* if it appeared for the first time */
 	if (list_moveCursor(l,&a)) {
@@ -109,10 +108,10 @@ void increase(const char* attr,tList* l,int *lcount) {
 
 #define attributeCount 8
 /* this is the most ugly thing I've ever made... nevertheless it was the only way to make it abstract */
-#define bindAttr(name,i) attrInfo[i].offset=(long)(&(parent->name))-(long)(parent)
-#define getAttr(tag) (*( (char**)((long)(tag)+attrInfo[i].offset) ))
+#define tree_bindAttr(name,i) attrInfo[i].offset=(long)(&(parent->name))-(long)(parent)
+#define tree_getAttr(tag) (*( (char**)((long)(tag)+attrInfo[i].offset) ))
 
-void commonFactor(tTag* parent) {
+void tree_TagCommonFactor(tTag* parent) {
 	tTag* child;
 	const tAttrCount* a;
 	int i;
@@ -125,25 +124,25 @@ void commonFactor(tTag* parent) {
 		long offset;
 	} attrInfo[attributeCount];
 
-	bindAttr(palette,0);
-	bindAttr(paletteindex,1);
-	bindAttr(paletteorder,2);
-	bindAttr(type,3);
-	bindAttr(file,4);
-	bindAttr(index,5);
-	bindAttr(order,6);
-	bindAttr(flags,7);
+	tree_bindAttr(palette,0);
+	tree_bindAttr(paletteindex,1);
+	tree_bindAttr(paletteorder,2);
+	tree_bindAttr(type,3);
+	tree_bindAttr(file,4);
+	tree_bindAttr(index,5);
+	tree_bindAttr(order,6);
+	tree_bindAttr(flags,7);
 
 	/* initialize counting list */
 	for (i=0;i<attributeCount;i++) {
-		attrInfo[i].l=list_create(sizeof(tAttrCount),attrcmp,NULL);
+		attrInfo[i].l=list_create(sizeof(tAttrCount),tree_attrcmp,NULL);
 		attrInfo[i].c=0;
 		attrInfo[i].lcount=0;
 	}
 
 	for (child=parent->child;child;child=child->next) {
 		for (i=0;i<attributeCount;i++) {
-			increase(getAttr(child),&(attrInfo[i].l),&attrInfo[i].lcount);
+			tree_increaseList(tree_getAttr(child),&(attrInfo[i].l),&attrInfo[i].lcount);
 			attrInfo[i].c++;
 		}
 	}
@@ -153,7 +152,6 @@ void commonFactor(tTag* parent) {
 		result=NULL;
 		list_firstCursor(&(attrInfo[i].l));
 		while ((a=list_getCursor(&(attrInfo[i].l)))) {
-/*			printf("running through %s (%d)\n",a->attr,a->count);*/
 			if (a->count*7>attrInfo[i].c*5 && a->count>max) {
 				max=a->count;
 				result=a->attr;
@@ -162,14 +160,14 @@ void commonFactor(tTag* parent) {
 		}
 
 		if (result) {
-			if (getAttr(parent)!=result) { /* it is possible, and is the most probable case, that the parent was already the best choice. In that case, do nothing */
-				freeAllocation(getAttr(parent));
-				getAttr(parent)=strallocandcopy(result); /* result is copied to avoid checking each time a string is released below */
+			if (tree_getAttr(parent)!=result) { /* it is possible, and is the most probable case, that the parent was already the best choice. In that case, do nothing */
+				freeAllocation(tree_getAttr(parent));
+				tree_getAttr(parent)=strallocandcopy(result); /* result is copied to avoid checking each time a string is released below */
 			}
 			for (child=parent->child;child;child=child->next) {
-				if (getAttr(child)&&!strcmp(getAttr(child),getAttr(parent))) {
-					freeAllocation(getAttr(child)); /* the first time this is ran, result is released! */
-					getAttr(child)=NULL;
+				if (tree_getAttr(child)&&!strcmp(tree_getAttr(child),tree_getAttr(parent))) {
+					freeAllocation(tree_getAttr(child)); /* the first time this is ran, result is released! */
+					tree_getAttr(child)=NULL;
 				}
 			}
 		}
@@ -177,16 +175,16 @@ void commonFactor(tTag* parent) {
 	}
 }
 
-void resourceTreeCommonFactor(tTag* tag) {
+void xmlOptimizeCommonFactor(tTag* tag) {
 	if (tag) {
-		resourceTreeCommonFactor(tag->next);
-		resourceTreeCommonFactor(tag->child);
-		commonFactor(tag); /* post order */
+		xmlOptimizeCommonFactor(tag->next);
+		xmlOptimizeCommonFactor(tag->child);
+		tree_TagCommonFactor(tag); /* post order */
 	}
 }
 
 #ifdef DEBUG_CF
-void test() {
+void tree_test() {
 	tTag tr[100];
 	int i;
 	for (i=0;i<6800;i++) ((char*)tr)[i]=0;
@@ -232,11 +230,11 @@ void test() {
 	tr[15].palette=strallocandcopy("joj11");
 	tr[16].palette=strallocandcopy("joj11");
 
-	generateXML(0,tr,stdout);
+	treeXmlGenerate(0,tr,stdout);
 
-	resourceTreeCommonFactor(tr);
+	xmlOptimizeCommonFactor(tr);
 
-	generateXML(0,tr,stdout);
+	treeXmlGenerate(0,tr,stdout);
 
 }
 #endif
@@ -245,7 +243,7 @@ void test() {
 |                     Tag generation routines                   |
 \***************************************************************/
 
-void unknown_folder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status) {
+void treeStatusFolder(const char* path, const char* file, int palette, const char* paletteindex, tTreeStatus* status) {
 	char number[10];
 	tTag* folder=getTagStructure();
 
@@ -266,7 +264,7 @@ void unknown_folder(const char* path, const char* file, int palette, const char*
 	status->itemCursor=NULL;
 }
 
-void unknown_item(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count, tTreeStatus* status) {
+void treeStatusItem(int value,const char* index,const char* path,const char* type,unsigned long int flags,const char* typedesc,int count, tTreeStatus* status) {
 	char aux[100];
 	tTag* item=getTagStructure();
 
@@ -293,7 +291,7 @@ void unknown_item(int value,const char* index,const char* path,const char* type,
 |                       Memory tree --> XML                     |
 \***************************************************************/
 
-void generateXML(int n,/*const*/ tTag* t,FILE* outputStream) {
+void treeXmlGenerate(int n,const tTag* t,FILE* outputStream) {
 	int a;
 	tTag* children;
 
@@ -302,29 +300,29 @@ void generateXML(int n,/*const*/ tTag* t,FILE* outputStream) {
 	if (t!=NULL) {
 		fprintf(outputStream,"<%s",t->tag);
 
-#define FillAttr2(a,b) if (a) fprintf(outputStream," %s=\"%s\"",b,a)
-
-	if (t->child) FillAttr2(t->desc,"name");
-	FillAttr2(t->path,"path");
-	FillAttr2(t->file,"file");
-	FillAttr2(t->type,"type");
-	FillAttr2(t->desc,"desc");
-	FillAttr2(t->palette,"palette");
-	FillAttr2(t->value,"value");
-	FillAttr2(t->index,"index");
-	FillAttr2(t->order,"order");
-	FillAttr2(t->paletteindex,"paletteindex");
-	FillAttr2(t->paletteorder,"paletteorder");
-	FillAttr2(t->version,"version");
-	FillAttr2(t->number,"number");
-	FillAttr2(t->flags,"flags");
+#define tree_FillAttr(a,b) if (a) fprintf(outputStream," %s=\"%s\"",b,a)
+
+	if (t->child) tree_FillAttr(t->desc,"name");
+	tree_FillAttr(t->path,"path");
+	tree_FillAttr(t->file,"file");
+	tree_FillAttr(t->type,"type");
+	tree_FillAttr(t->desc,"desc");
+	tree_FillAttr(t->palette,"palette");
+	tree_FillAttr(t->value,"value");
+	tree_FillAttr(t->index,"index");
+	tree_FillAttr(t->order,"order");
+	tree_FillAttr(t->paletteindex,"paletteindex");
+	tree_FillAttr(t->paletteorder,"paletteorder");
+	tree_FillAttr(t->version,"version");
+	tree_FillAttr(t->number,"number");
+	tree_FillAttr(t->flags,"flags");
 
 #undef FillAttr
 
 		if ((children=t->child)) {
 			fprintf(outputStream,">\n");
 			while (children!=NULL) {
-				generateXML(n+1,children,outputStream);
+				treeXmlGenerate(n+1,children,outputStream);
 				children=children->next;
 			}
 			for(a=0;a<n;a++) fprintf (outputStream,"\t");
@@ -339,10 +337,10 @@ void generateXML(int n,/*const*/ tTag* t,FILE* outputStream) {
 	}
 }
 
-int generateXMLfile(const char* vFile,/*const*/ tTag* t) {
+int xmlGenerateFile(const char* vFile,const tTag* t) {
 	FILE* fd;
 	if (!(fd=fopen(vFile,"wb"))) return PR_RESULT_ERR_XML_NOT_OPEN;
-	generateXML(0,t,fd);
+	treeXmlGenerate(0,t,fd);
 	return PR_RESULT_SUCCESS;
 }
 
@@ -350,7 +348,7 @@ int generateXMLfile(const char* vFile,/*const*/ tTag* t) {
 |                File attribute deletion routines               |
 \***************************************************************/
 
-void rec_tree(tTag* *t,const char* file) {
+void tree_rec(tTag* *t,const char* file) {
 	tTag* aux=*t;
 	tTag* aux2;
 
@@ -367,39 +365,39 @@ void rec_tree(tTag* *t,const char* file) {
 				*t=aux->next;
 			}
 			aux->next=NULL;
-			if (*t) rec_tree(t,file);
+			if (*t) tree_rec(t,file);
 		} else {
-			if ((*t) && (*t)->next) rec_tree(&((*t)->next),file);
+			if ((*t) && (*t)->next) tree_rec(&((*t)->next),file);
 		}
 	}
 
-	if ((*t) && (*t)->child) rec_tree(&((*t)->child),file);
+	if ((*t) && (*t)->child) tree_rec(&((*t)->child),file);
 }
 
-void unknown_deletetreefile(const char* file, tTag* tree) {
+void treeDeleteFile(const char* file, tTag* tree) {
 	if (tree)
-		rec_tree(&(tree->child),file);
+		tree_rec(&(tree->child),file);
 }
 
 /***************************************************************\
 |                  Inheritance fixing routines                  |
 \***************************************************************/
 
-#define TotalInheritance2(a) if (parent->a&&child->a&&equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;}
+#define tree_TotalInheritance(a) if (parent->a&&child->a&&equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;}
 
-void rec_tree_fix(tTag* parent,tTag* child) {
-	if (child->next) rec_tree_fix(parent,child->next);
-	if (child->child) rec_tree_fix(child,child->child);
+void tree_rec_fix(tTag* parent,tTag* child) {
+	if (child->next) tree_rec_fix(parent,child->next);
+	if (child->child) tree_rec_fix(child,child->child);
 
 	if (parent) {
-		TotalInheritance2(palette);
-		TotalInheritance2(paletteindex);
-		TotalInheritance2(paletteorder);
-		TotalInheritance2(type);
-		TotalInheritance2(file);
-		TotalInheritance2(index);
-		TotalInheritance2(order);
-		TotalInheritance2(flags);
+		tree_TotalInheritance(palette);
+		tree_TotalInheritance(paletteindex);
+		tree_TotalInheritance(paletteorder);
+		tree_TotalInheritance(type);
+		tree_TotalInheritance(file);
+		tree_TotalInheritance(index);
+		tree_TotalInheritance(order);
+		tree_TotalInheritance(flags);
 
 		/* partial */
 		if ((parent->path!=NULL)&&(child->path!=NULL)) {
@@ -411,18 +409,14 @@ void rec_tree_fix(tTag* parent,tTag* child) {
 			free(child->path);
 			child->path=aux;
 		}
-
 	}
-
 }
 
 void resourceTreeFixInheritances(tTag* *tree) {
-	/*printf("fixing inheritances in tree\n");*/
 	if (*tree) {
-		rec_tree_fix(NULL,(*tree));
+		tree_rec_fix(NULL,(*tree));
 
 		freeAllocation((*tree)->path);
 		(*tree)->path=NULL;
 	}
 }
-
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 93a2fa3..9299726 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -37,15 +37,15 @@ unknown.c: Princed Resources : Unknown resources handler implementation
 \***************************************************************/
 
 /* Includes */
-#include <stdio.h>
-#include "tree.h"
 #include "common.h"
 #include "disk.h"
-#include "unknown.h"
 #include "memory.h"
+#include "parse.h" /* getTagStructure */
 #include "stringformat.h"
 #include "translate.h"
-#include "parse.h" /* getTagStructure */
+#include "tree.h"
+#include "unknown.h"
+#include <stdio.h>
 
 /***************************************************************\
 |                     Unknown.xml primitives                    |
@@ -57,7 +57,7 @@ unknown.c: Princed Resources : Unknown resources handler implementation
 #define XML_TAG_RESOURCES     "resources"
 #define XML_ATTRV_VERSION     "build-1"
 
-char* getVersion(const char* oldVersion) {
+char* unknown_getVersion(const char* oldVersion) {
 	char* newVersion;
 	int l,i;
 
@@ -96,13 +96,13 @@ int unknownLogStart (const char* file,int optionflag, const char* backupExtensio
 
 		unknownFile.status.folderFirst=NULL;
 		unknownFile.status.folderCursor=NULL;
-		unknownFile.tree=parseXmlFile(file,&error);
+		unknownFile.tree=xmlParseFile(file,&error);
 		if (error) {
 			unknownFile.tree=getTagStructure();
 			unknownFile.tree->version=strallocandcopy(XML_ATTRV_VERSION);
 			unknownFile.tree->tag=strallocandcopy(XML_TAG_RESOURCES);
 		} else {
-			char* version=getVersion(unknownFile.tree->version);
+			char* version=unknown_getVersion(unknownFile.tree->version);
 			freeAllocation(unknownFile.tree->version);
 			unknownFile.tree->version=version;
 		}
@@ -121,14 +121,14 @@ int unknownLogStop () {
 	if (!unknownFile.fd) return PR_RESULT_ERR_XML_NOT_OPEN; /* File not open */
 
 	/* common factor tree reducing function */
-	if (unknownFile.tree) resourceTreeCommonFactor(unknownFile.tree->child);
+	if (unknownFile.tree) xmlOptimizeCommonFactor(unknownFile.tree->child);
 
 	/* it is time to fix the inheritances */
 	resourceTreeFixInheritances(&unknownFile.tree);
 
 	/* now we'll add the new generated part of the tree at the end of the second level (resources id the first) */
 	if (unknownFile.tree) {
-		resourceTreeCommonFactor(unknownFile.tree); /* here some common factors are moved up */
+		xmlOptimizeCommonFactor(unknownFile.tree); /* here some common factors are moved up */
 		if (unknownFile.tree->child) {
 			for (t=unknownFile.tree->child;t->next;t=t->next);
 			t->next=unknownFile.status.folderFirst; /* the first folder of the new tree */
@@ -138,7 +138,7 @@ int unknownLogStop () {
 	}
 
 	/* generate the XML file */
-	generateXML(0,unknownFile.tree,unknownFile.fd);
+	treeXmlGenerate(0,unknownFile.tree,unknownFile.fd);
 
 	/* it's time to free the tree */
 	freeParsedStructure (&unknownFile.tree);
@@ -160,21 +160,21 @@ int unknownLogAppend(const char* vFiledat,tResourceId id,const char* ext,tResour
 	if (!unknownFile.fd) return PR_RESULT_ERR_XML_NOT_OPEN; /* File not open, logging is off, just a warning */
 
 	if (!unknownFile.currentDat) { /* this is the beginning of the file */
-		unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index)),&unknownFile.status);
+		treeStatusFolder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(strToLower(pal.index)),&unknownFile.status);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 		/* it could be moved here the read-parsing-loading and write-opening,
 		 * but it is necessary to know the parsing status before the extractions are started */
-		unknown_deletetreefile(vFiledat,unknownFile.tree);
+		treeDeleteFile(vFiledat,unknownFile.tree);
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		int i;
-		unknown_folder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(toLower(pal.index)),&unknownFile.status);
+		treeStatusFolder(vFiledatWithPath,vFiledat,pal.value,translateInt2Ext(strToLower(pal.index)),&unknownFile.status);
 		freeAllocation(unknownFile.currentDat);
 		unknownFile.currentDat=strallocandcopy(vFiledat);
-		unknown_deletetreefile(vFiledat,unknownFile.tree);
+		treeDeleteFile(vFiledat,unknownFile.tree);
 		for (i=0;i<RES_TYPECOUNT;i++) unknownFile.typeCount[i]=0; /* re-initialize in 0 for next file processing */
 	}
 
-	unknown_item(id.value,translateInt2Ext(toLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count,&unknownFile.status);
+	treeStatusItem(id.value,translateInt2Ext(strToLower(id.index)),filename,getExtDesc(type),flags,getExtDesc(type),count,&unknownFile.status);
 
 	return PR_RESULT_SUCCESS;
 }