author | ecalot
<ecalot> 2005-06-11 06:24:35 UTC |
committer | ecalot
<ecalot> 2005-06-11 06:24:35 UTC |
parent | b9420f9e6e8aaf6f0d60793db3569ced536b4851 |
PR/doc/changelog.txt | +1 | -0 |
PR/src/include/autodetect.h | +7 | -6 |
PR/src/include/idlist.h | +7 | -6 |
PR/src/include/search.h | +2 | -0 |
PR/src/include/tree.h | +7 | -6 |
PR/src/include/unknown.h | +7 | -6 |
PR/src/lib/actions/export.c | +1 | -1 |
PR/src/lib/actions/import.c | +1 | -1 |
PR/src/lib/layers/autodetect.c | +35 | -29 |
PR/src/lib/layers/idlist.c | +35 | -29 |
PR/src/lib/xml/tree.c | +35 | -29 |
PR/src/lib/xml/unknown.c | +35 | -29 |
diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt index 95a586f..2bb94f8 100644 --- a/PR/doc/changelog.txt +++ b/PR/doc/changelog.txt @@ -157,6 +157,7 @@ Versions: vdungeon.dat@vdungeon/chopper/*.bmp) * PR v1.2 (future plans) x Finish python interface + x Fix the language support 2) ToDo List & Future Plans: diff --git a/PR/src/include/autodetect.h b/PR/src/include/autodetect.h index 8057c7c..01397c2 100644 --- a/PR/src/include/autodetect.h +++ b/PR/src/include/autodetect.h @@ -60,16 +60,17 @@ resources.h: Princed Resources : Resource Handler headers #define RES_TYPECOUNT 8 +#include "dat.h" /* Id list for partial manipulation */ -typedef enum {eString,eValue}tResIdType; +typedef enum {eString,eId,eIdValue}tResLocationType; typedef struct { - tResIdType idType; + tResLocationType type; union { - char* text; - long number; - } value; + char* text; + tResourceId id; + } field; }tResIdListItem; typedef struct { @@ -79,7 +80,7 @@ typedef struct { void parseGivenPath(char* path); int partialListActive(); -int isInThePartialList(const char* file, int value); +int isInThePartialList(const char* vFile, tResourceId id); void freePartialList(); /* Includes */ diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h index 8057c7c..01397c2 100644 --- a/PR/src/include/idlist.h +++ b/PR/src/include/idlist.h @@ -60,16 +60,17 @@ resources.h: Princed Resources : Resource Handler headers #define RES_TYPECOUNT 8 +#include "dat.h" /* Id list for partial manipulation */ -typedef enum {eString,eValue}tResIdType; +typedef enum {eString,eId,eIdValue}tResLocationType; typedef struct { - tResIdType idType; + tResLocationType type; union { - char* text; - long number; - } value; + char* text; + tResourceId id; + } field; }tResIdListItem; typedef struct { @@ -79,7 +80,7 @@ typedef struct { void parseGivenPath(char* path); int partialListActive(); -int isInThePartialList(const char* file, int value); +int isInThePartialList(const char* vFile, tResourceId id); void freePartialList(); /* Includes */ diff --git a/PR/src/include/search.h b/PR/src/include/search.h index fd519a1..bb69709 100644 --- a/PR/src/include/search.h +++ b/PR/src/include/search.h @@ -43,6 +43,8 @@ xmlparse.h: Princed Resources : xml handling functions header file #include "xmlparse.h" #include "resources.h" +void str5uppercpy (char* dst,const char* src); + /****************************************************************\ | Tag Tree Searching Functions | \****************************************************************/ diff --git a/PR/src/include/tree.h b/PR/src/include/tree.h index 8057c7c..01397c2 100644 --- a/PR/src/include/tree.h +++ b/PR/src/include/tree.h @@ -60,16 +60,17 @@ resources.h: Princed Resources : Resource Handler headers #define RES_TYPECOUNT 8 +#include "dat.h" /* Id list for partial manipulation */ -typedef enum {eString,eValue}tResIdType; +typedef enum {eString,eId,eIdValue}tResLocationType; typedef struct { - tResIdType idType; + tResLocationType type; union { - char* text; - long number; - } value; + char* text; + tResourceId id; + } field; }tResIdListItem; typedef struct { @@ -79,7 +80,7 @@ typedef struct { void parseGivenPath(char* path); int partialListActive(); -int isInThePartialList(const char* file, int value); +int isInThePartialList(const char* vFile, tResourceId id); void freePartialList(); /* Includes */ diff --git a/PR/src/include/unknown.h b/PR/src/include/unknown.h index 8057c7c..01397c2 100644 --- a/PR/src/include/unknown.h +++ b/PR/src/include/unknown.h @@ -60,16 +60,17 @@ resources.h: Princed Resources : Resource Handler headers #define RES_TYPECOUNT 8 +#include "dat.h" /* Id list for partial manipulation */ -typedef enum {eString,eValue}tResIdType; +typedef enum {eString,eId,eIdValue}tResLocationType; typedef struct { - tResIdType idType; + tResLocationType type; union { - char* text; - long number; - } value; + char* text; + tResourceId id; + } field; }tResIdListItem; typedef struct { @@ -79,7 +80,7 @@ typedef struct { void parseGivenPath(char* path); int partialListActive(); -int isInThePartialList(const char* file, int value); +int isInThePartialList(const char* vFile, tResourceId id); void freePartialList(); /* Includes */ diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c index 62c77fd..879ddbd 100644 --- a/PR/src/lib/actions/export.c +++ b/PR/src/lib/actions/export.c @@ -94,7 +94,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.value /*TODO: use res.id and code the index support to the partial list*/)) { /* If the resource was specified do the tasks */ + if (isInThePartialList(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 */ diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c index f3d4ff5..e493da0 100644 --- a/PR/src/lib/actions/import.c +++ b/PR/src/lib/actions/import.c @@ -163,7 +163,7 @@ 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.value /*TODO: use res.id and code the index support to the partial list*/)) { /* If the resource was specified */ + if (isInThePartialList(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 */ diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c index 1bd1805..0a36425 100644 --- a/PR/src/lib/layers/autodetect.c +++ b/PR/src/lib/layers/autodetect.c @@ -127,9 +127,7 @@ void parseGivenPath(char* path) { int i; int separator=0; - int resourceValue; int j=0; - unsigned char n; int size; char aux[PARSING_MAX_TOKEN_SIZE]; @@ -169,27 +167,30 @@ void parseGivenPath(char* path) { partialList.list=(tResIdListItem*)malloc(sizeof(tResIdListItem)*partialList.count); /* Parse values and save them in the list */ - resourceValue=0; for(i=separator;j!=partialList.count;i++) { - n=path[i]; - if ((0x2F<n)&&(n<0x3A)) { - resourceValue=resourceValue*10+(n-'0'); - } else { - if (n) { - partialList.list[j].idType=eString; - aux[0]='/'; - aux[1]=0; - strcat(aux,path+separator); - partialList.list[j].value.text=strallocandcopy(repairFolders(aux)); - while (path[i]) i++; - } else { - partialList.list[j].idType=eValue; - partialList.list[j].value.number=resourceValue; - } - resourceValue=0; - separator=i+1; - j++; + unsigned int value; + int converted; + char index[5]; + converted=sscanf(path+i,"%u:%5s",&value,index); + switch (converted) { + case 2: + partialList.list[j].type=eId; + partialList.list[j].field.id.value=value; + str5uppercpy(partialList.list[j].field.id.index,index); + break; + case 1: + partialList.list[j].type=eIdValue; + partialList.list[j].field.id.value=value; + break; + default: + partialList.list[j].type=eString; + aux[0]='/';aux[1]=0; + strcat(aux,path+i); + partialList.list[j].field.text=strallocandcopy(repairFolders(aux)); + break; } + while (path[i]) i++; + j++; } } @@ -256,7 +257,7 @@ int matchesIn(const char* text,const char* mask) { return valor?1:matches1(text,token,0,0); } -int isInThePartialList(const char* vFile, int value) { +int isInThePartialList(const char* vFile, tResourceId id) { /* Cases: "path/path@" all files are false @@ -272,11 +273,16 @@ int isInThePartialList(const char* vFile, int value) { file=(char*)repairFolders(vFile); for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eValue) { - if (value==partialList.list[i].value.number) return 1; - } else { - if (file) - if (matchesIn(file,partialList.list[i].value.text)) return 1; + switch (partialList.list[i].type) { + case eIdValue: + if (id.value==partialList.list[i].field.id.value) return 1; + break; + case eString: + if (file && matchesIn(file,partialList.list[i].field.text)) return 1; + break; + case eId: + if (!resIdCmp(id,partialList.list[i].field.id)) return 1; + break; } } return 0; @@ -285,8 +291,8 @@ int isInThePartialList(const char* vFile, int value) { void freePartialList() { int i; for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eString) - free(partialList.list[i].value.text); + if (partialList.list[i].type==eString) + free(partialList.list[i].field.text); } free(partialList.list); partialList.count=0; diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c index 1bd1805..0a36425 100644 --- a/PR/src/lib/layers/idlist.c +++ b/PR/src/lib/layers/idlist.c @@ -127,9 +127,7 @@ void parseGivenPath(char* path) { int i; int separator=0; - int resourceValue; int j=0; - unsigned char n; int size; char aux[PARSING_MAX_TOKEN_SIZE]; @@ -169,27 +167,30 @@ void parseGivenPath(char* path) { partialList.list=(tResIdListItem*)malloc(sizeof(tResIdListItem)*partialList.count); /* Parse values and save them in the list */ - resourceValue=0; for(i=separator;j!=partialList.count;i++) { - n=path[i]; - if ((0x2F<n)&&(n<0x3A)) { - resourceValue=resourceValue*10+(n-'0'); - } else { - if (n) { - partialList.list[j].idType=eString; - aux[0]='/'; - aux[1]=0; - strcat(aux,path+separator); - partialList.list[j].value.text=strallocandcopy(repairFolders(aux)); - while (path[i]) i++; - } else { - partialList.list[j].idType=eValue; - partialList.list[j].value.number=resourceValue; - } - resourceValue=0; - separator=i+1; - j++; + unsigned int value; + int converted; + char index[5]; + converted=sscanf(path+i,"%u:%5s",&value,index); + switch (converted) { + case 2: + partialList.list[j].type=eId; + partialList.list[j].field.id.value=value; + str5uppercpy(partialList.list[j].field.id.index,index); + break; + case 1: + partialList.list[j].type=eIdValue; + partialList.list[j].field.id.value=value; + break; + default: + partialList.list[j].type=eString; + aux[0]='/';aux[1]=0; + strcat(aux,path+i); + partialList.list[j].field.text=strallocandcopy(repairFolders(aux)); + break; } + while (path[i]) i++; + j++; } } @@ -256,7 +257,7 @@ int matchesIn(const char* text,const char* mask) { return valor?1:matches1(text,token,0,0); } -int isInThePartialList(const char* vFile, int value) { +int isInThePartialList(const char* vFile, tResourceId id) { /* Cases: "path/path@" all files are false @@ -272,11 +273,16 @@ int isInThePartialList(const char* vFile, int value) { file=(char*)repairFolders(vFile); for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eValue) { - if (value==partialList.list[i].value.number) return 1; - } else { - if (file) - if (matchesIn(file,partialList.list[i].value.text)) return 1; + switch (partialList.list[i].type) { + case eIdValue: + if (id.value==partialList.list[i].field.id.value) return 1; + break; + case eString: + if (file && matchesIn(file,partialList.list[i].field.text)) return 1; + break; + case eId: + if (!resIdCmp(id,partialList.list[i].field.id)) return 1; + break; } } return 0; @@ -285,8 +291,8 @@ int isInThePartialList(const char* vFile, int value) { void freePartialList() { int i; for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eString) - free(partialList.list[i].value.text); + if (partialList.list[i].type==eString) + free(partialList.list[i].field.text); } free(partialList.list); partialList.count=0; diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c index 1bd1805..0a36425 100644 --- a/PR/src/lib/xml/tree.c +++ b/PR/src/lib/xml/tree.c @@ -127,9 +127,7 @@ void parseGivenPath(char* path) { int i; int separator=0; - int resourceValue; int j=0; - unsigned char n; int size; char aux[PARSING_MAX_TOKEN_SIZE]; @@ -169,27 +167,30 @@ void parseGivenPath(char* path) { partialList.list=(tResIdListItem*)malloc(sizeof(tResIdListItem)*partialList.count); /* Parse values and save them in the list */ - resourceValue=0; for(i=separator;j!=partialList.count;i++) { - n=path[i]; - if ((0x2F<n)&&(n<0x3A)) { - resourceValue=resourceValue*10+(n-'0'); - } else { - if (n) { - partialList.list[j].idType=eString; - aux[0]='/'; - aux[1]=0; - strcat(aux,path+separator); - partialList.list[j].value.text=strallocandcopy(repairFolders(aux)); - while (path[i]) i++; - } else { - partialList.list[j].idType=eValue; - partialList.list[j].value.number=resourceValue; - } - resourceValue=0; - separator=i+1; - j++; + unsigned int value; + int converted; + char index[5]; + converted=sscanf(path+i,"%u:%5s",&value,index); + switch (converted) { + case 2: + partialList.list[j].type=eId; + partialList.list[j].field.id.value=value; + str5uppercpy(partialList.list[j].field.id.index,index); + break; + case 1: + partialList.list[j].type=eIdValue; + partialList.list[j].field.id.value=value; + break; + default: + partialList.list[j].type=eString; + aux[0]='/';aux[1]=0; + strcat(aux,path+i); + partialList.list[j].field.text=strallocandcopy(repairFolders(aux)); + break; } + while (path[i]) i++; + j++; } } @@ -256,7 +257,7 @@ int matchesIn(const char* text,const char* mask) { return valor?1:matches1(text,token,0,0); } -int isInThePartialList(const char* vFile, int value) { +int isInThePartialList(const char* vFile, tResourceId id) { /* Cases: "path/path@" all files are false @@ -272,11 +273,16 @@ int isInThePartialList(const char* vFile, int value) { file=(char*)repairFolders(vFile); for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eValue) { - if (value==partialList.list[i].value.number) return 1; - } else { - if (file) - if (matchesIn(file,partialList.list[i].value.text)) return 1; + switch (partialList.list[i].type) { + case eIdValue: + if (id.value==partialList.list[i].field.id.value) return 1; + break; + case eString: + if (file && matchesIn(file,partialList.list[i].field.text)) return 1; + break; + case eId: + if (!resIdCmp(id,partialList.list[i].field.id)) return 1; + break; } } return 0; @@ -285,8 +291,8 @@ int isInThePartialList(const char* vFile, int value) { void freePartialList() { int i; for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eString) - free(partialList.list[i].value.text); + if (partialList.list[i].type==eString) + free(partialList.list[i].field.text); } free(partialList.list); partialList.count=0; diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c index 1bd1805..0a36425 100644 --- a/PR/src/lib/xml/unknown.c +++ b/PR/src/lib/xml/unknown.c @@ -127,9 +127,7 @@ void parseGivenPath(char* path) { int i; int separator=0; - int resourceValue; int j=0; - unsigned char n; int size; char aux[PARSING_MAX_TOKEN_SIZE]; @@ -169,27 +167,30 @@ void parseGivenPath(char* path) { partialList.list=(tResIdListItem*)malloc(sizeof(tResIdListItem)*partialList.count); /* Parse values and save them in the list */ - resourceValue=0; for(i=separator;j!=partialList.count;i++) { - n=path[i]; - if ((0x2F<n)&&(n<0x3A)) { - resourceValue=resourceValue*10+(n-'0'); - } else { - if (n) { - partialList.list[j].idType=eString; - aux[0]='/'; - aux[1]=0; - strcat(aux,path+separator); - partialList.list[j].value.text=strallocandcopy(repairFolders(aux)); - while (path[i]) i++; - } else { - partialList.list[j].idType=eValue; - partialList.list[j].value.number=resourceValue; - } - resourceValue=0; - separator=i+1; - j++; + unsigned int value; + int converted; + char index[5]; + converted=sscanf(path+i,"%u:%5s",&value,index); + switch (converted) { + case 2: + partialList.list[j].type=eId; + partialList.list[j].field.id.value=value; + str5uppercpy(partialList.list[j].field.id.index,index); + break; + case 1: + partialList.list[j].type=eIdValue; + partialList.list[j].field.id.value=value; + break; + default: + partialList.list[j].type=eString; + aux[0]='/';aux[1]=0; + strcat(aux,path+i); + partialList.list[j].field.text=strallocandcopy(repairFolders(aux)); + break; } + while (path[i]) i++; + j++; } } @@ -256,7 +257,7 @@ int matchesIn(const char* text,const char* mask) { return valor?1:matches1(text,token,0,0); } -int isInThePartialList(const char* vFile, int value) { +int isInThePartialList(const char* vFile, tResourceId id) { /* Cases: "path/path@" all files are false @@ -272,11 +273,16 @@ int isInThePartialList(const char* vFile, int value) { file=(char*)repairFolders(vFile); for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eValue) { - if (value==partialList.list[i].value.number) return 1; - } else { - if (file) - if (matchesIn(file,partialList.list[i].value.text)) return 1; + switch (partialList.list[i].type) { + case eIdValue: + if (id.value==partialList.list[i].field.id.value) return 1; + break; + case eString: + if (file && matchesIn(file,partialList.list[i].field.text)) return 1; + break; + case eId: + if (!resIdCmp(id,partialList.list[i].field.id)) return 1; + break; } } return 0; @@ -285,8 +291,8 @@ int isInThePartialList(const char* vFile, int value) { void freePartialList() { int i; for (i=0;i<partialList.count;i++) { - if (partialList.list[i].idType==eString) - free(partialList.list[i].value.text); + if (partialList.list[i].type==eString) + free(partialList.list[i].field.text); } free(partialList.list); partialList.count=0;