git » fp-git.git » commit 3a13da8

hooked flag system

author ecalot
2006-06-27 02:18:24 UTC
committer ecalot
2006-06-27 02:18:24 UTC
parent c133d9ab31a6a78aeab6548716c0e5b419b10c94

hooked flag system

PR/src/lib/xml/search.c +8 -8
PR/src/lib/xml/tree.c +2 -2

diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index 64837ec..ce0bb85 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -42,6 +42,7 @@ search.c: Princed Resources : Specific XML handling functions
 #include "parse.h"
 #include "search.h"
 #include "translate.h" /* to translate indexes */
+#include "stringflag.h" /* to translate flags */
 #include <string.h>
 
 /***************************************************************\
@@ -95,7 +96,6 @@ void search_workTag(const tTag* t,void* pass) {
 	const char* datFile=((tPassWork*)pass)->datFile;
 	tResourceList* rlist=((tPassWork*)pass)->rlist;
 	tResource res;
-	char* end;
 
 /*printf("comienzan las preguntas (t->file,datFile)=(%s,%s)\n",t->file,datFile);
 printf("tv=%s ti=%s tag=%s\n",t->value,t->index,t->tag);*/
@@ -118,18 +118,19 @@ printf("tv=%s ti=%s tag=%s\n",t->value,t->index,t->tag);*/
 				res.type=i;
 		/* If error it returns 0 and the verifyHeader will try to detect the type */
 	}
-	if (res.type==eResTypeImage16) {
+	if (res.type==eResTypeImage16) { /* Transform the default TypeImage16 to the corresponding type */
 		switch (ptoi(t->colors)) {
 		case 2:
 			res.type=eResTypeImage2;
 			break;										
-		case 256:
-			res.type=eResTypeImage256;
-			break;										
 		case 16:
-		default:
+		case 0: /* none defaults to 16 */
 			res.type=eResTypeImage16;
 			break;	
+		default: /* other number defaults to 256 */
+		case 256:
+			res.type=eResTypeImage256;
+			break;										
 		}
 	}
 #endif
@@ -145,8 +146,7 @@ printf("tv=%s ti=%s tag=%s\n",t->value,t->index,t->tag);*/
 	/* Copy number, title, desc and path */
 	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;
+		res.flags=parseflag(t->flags);
 	} else {
 		res.flags=0;
 	}
diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 7fd3b73..3b11d0c 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -40,6 +40,7 @@ tree.c: Princed Resources : Specific XML tree handling routines
 #include "common.h"
 #include "list.h"    /* list primitives needed by the Common Factor routines */
 #include "memory.h"
+#include "stringflag.h" /* to translate flags */
 #include "parse.h"   /* getTagStructure */
 #include "unknown.h" /* typedef tUnknownFile */
 #include <stdio.h>
@@ -419,8 +420,7 @@ void treeStatusItem(int value,const char* index,const char* path,const char* typ
 	item->index=strallocandcopy(index);
 	item->path=strallocandcopy(path);
 	item->type=strallocandcopy(type);
-	sprintf(aux,"0x%lx",flags);
-	item->flags=strallocandcopy(aux);
+	item->flags=strallocandcopy(generateflag(flags));
 	sprintf(aux,"Unknown %s %d",typedesc, count);
 	item->desc=strallocandcopy(aux);