author | ecalot
<ecalot> 2005-06-23 11:23:40 UTC |
committer | ecalot
<ecalot> 2005-06-23 11:23:40 UTC |
parent | 19f96f3e15afa8b61e549df85861bb4d0f95b049 |
PR/src/include/idlist.h | +3 | -17 |
PR/src/lib/layers/idlist.c | +34 | -9 |
PR/src/lib/layers/memory.c | +1 | -1 |
diff --git a/PR/src/include/idlist.h b/PR/src/include/idlist.h index 6020875..44884ee 100644 --- a/PR/src/include/idlist.h +++ b/PR/src/include/idlist.h @@ -35,23 +35,9 @@ idlist.h: Princed Resources : Resource id list headers #define _IDLIST_H_ /* Includes */ -#include "reslist.h" - -/* Id list for partial manipulation */ -typedef enum {eString,eId,eIdValue}tResLocationType; - -typedef struct { - tResLocationType type; - union { - char* text; - tResourceId id; - } field; -}tResIdListItem; - -typedef struct { - int count; - tResIdListItem* list; -}tResIdList; +#include "reslist.h" /* tResourceId */ + +#define PARSING_MAX_TOKEN_SIZE 200 void parseGivenPath(char* path); int partialListActive(); diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c index 051b280..49d5ec4 100644 --- a/PR/src/lib/layers/idlist.c +++ b/PR/src/lib/layers/idlist.c @@ -42,9 +42,21 @@ idlist.c: Princed Resources : Partial Id list #include "memory.h" #include "idlist.h" -/***************************************************************\ -| Partial Resource List Functions | -\***************************************************************/ +/* Id list for partial manipulation. Private type */ +typedef enum {eString,eId,eIdValue,eIdIndex}tResLocationType; + +typedef struct { + tResLocationType type; + union { + char* text; + tResourceId id; + } field; +}tResIdListItem; + +typedef struct { + int count; + tResIdListItem* list; +}tResIdList; static tResIdList partialList; @@ -52,7 +64,9 @@ int partialListActive() { return partialList.count; } -#define PARSING_MAX_TOKEN_SIZE 200 +/***************************************************************\ +| Partial Resource List Functions | +\***************************************************************/ void parseGivenPath(char* path) { /* @@ -66,7 +80,6 @@ void parseGivenPath(char* path) { int separator=0; int j=0; int size; - char aux[PARSING_MAX_TOKEN_SIZE]; /* Check if the variable wasn't initialized before */ if (partialList.count!=0) return; @@ -120,10 +133,19 @@ void parseGivenPath(char* path) { 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)); + /* TODO: test this */ + if (sscanf(path+i,":%5s",index)) { + partialList.list[j].type=eIdIndex; + strncpy(partialList.list[j].field.id.index,index,5); + } else { + char* aux; + partialList.list[j].type=eString; + aux=malloc(strlen(path+i)+2); + aux[0]='/'; + strcpy(aux+1,path+i); + partialList.list[j].field.text=strallocandcopy(repairFolders(aux)); + free(aux); + } break; } while (path[i]) i++; @@ -149,6 +171,9 @@ int isInThePartialList(const char* vFile, tResourceId id) { case eIdValue: if (id.value==partialList.list[i].field.id.value) return 1; break; + case eIdIndex: + if (!strncmp(id.index,partialList.list[i].field.id.index,4)) return 1; + break; case eString: if (vFile && matchesIn(repairFolders(vFile),partialList.list[i].field.text)) return 1; break; diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c index 55ec04c..cc79c5b 100644 --- a/PR/src/lib/layers/memory.c +++ b/PR/src/lib/layers/memory.c @@ -57,7 +57,7 @@ void str5uppercpy (char* dst,const char* src) { int matchesIn(const char *s, const char *p) { switch(*p) { case 0: return !(*s); - case '*': return matchesIn(s,p+1) || ((*s) && matchesIn(s+1,p)); + case '*': while(*(p+1)=='*') p++; return matchesIn(s,p+1) || ((*s) && matchesIn(s+1,p)); case '?': return (*s) && matchesIn(s+1,p+1); case '&': p++; default: return ((*p)==(*s)) && matchesIn(s+1,p+1);