author | ecalot
<ecalot> 2006-01-16 02:57:42 UTC |
committer | ecalot
<ecalot> 2006-01-16 02:57:42 UTC |
parent | ebe1ca3e2e471836da0b7995fac6c1814c679c2c |
PR/src/lib/xml/parse.c | +31 | -36 |
PR/src/lib/xml/search.c | +9 | -6 |
PR/src/lib/xml/tree.c | +2 | -1 |
diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c index 51bd71a..bc18d27 100644 --- a/PR/src/lib/xml/parse.c +++ b/PR/src/lib/xml/parse.c @@ -71,11 +71,8 @@ const char* getExtDesc(int type) { #define parse_FillAttr(a,b) if (equalsIgnoreCase(attr,b)) { freeAllocation(a); (a)=(val); return 0;} #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);\ - } + if ((tag->attribute==NULL)&&(father->attribute!=NULL)) \ + tag->attribute=strallocandcopy(father->attribute); #define parse_Error return PR_RESULT_ERR_XML_PARSING @@ -365,44 +362,42 @@ tTag* parse_makeTree(char** p,char* name, int* error,tTag* father) { * XML_TAG_CLOSE If tag is closed in the same opening * XML_TAG_OPEN If tag remains open */ - if ((*error)==XML_TAG_CLOSE) { - *error=PR_RESULT_SUCCESS; /* No errors, end of the tag in the same tag <tag /> */ - return tag; - } /* In case there are some empty attributes, they may be inherited */ /* BEGIN specific XML tag inheritance */ - { - int x; + 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 /*is folder */)||(tag->path!=NULL)) { char* str; - 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;} - if (tag->path==NULL) {tag->path=(char*)malloc(1);*(tag->path)=0;} - - /* Create new variable */ - x=strlen(father->path)+strlen(tag->path)+2; - str=(char*)malloc(x); - if (str==NULL) {*error=PR_RESULT_ERR_MEMORY;return NULL;} - - /* Set variable and destroy old variables */ - sprintf(str,"%s/%s",father->path,tag->path); - free(tag->path); - if ((*(father->path))==0) {free(father->path);father->path=NULL;} - tag->path=str; - } + /* Make sure paths do exist */ + if (father->path==NULL) {father->path=(char*)malloc(1);*(father->path)=0;} + if (tag->path==NULL) {tag->path=(char*)malloc(1);*(tag->path)=0;} + + /* Create new variable */ + str=(char*)malloc(strlen(father->path)+strlen(tag->path)+2); + if (str==NULL) {*error=PR_RESULT_ERR_MEMORY;return NULL;} + + /* Set variable and destroy old variables */ + sprintf(str,"%s/%s",father->path,tag->path); + free(tag->path); + if ((*(father->path))==0) {free(father->path);father->path=NULL;} + tag->path=str; } /* END specific XML tag inheritance */ + + if ((*error)==XML_TAG_CLOSE) { + *error=PR_RESULT_SUCCESS; /* No errors, end of the tag in the same tag <tag /> */ + return tag; + } + /* Parse Child tags */ while (1) { (*error)=getNextTag(p, &value); diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c index 985ad39..581bc1c 100644 --- a/PR/src/lib/xml/search.c +++ b/PR/src/lib/xml/search.c @@ -38,11 +38,11 @@ search.c: Princed Resources : Specific XML handling functions /* Includes */ #include "common.h" +#include "memory.h" #include "parse.h" #include "search.h" -#include "memory.h" -#include <string.h> #include "translate.h" /* to translate indexes */ +#include <string.h> /***************************************************************\ | Filtering XML structure to tResourceList | @@ -96,11 +96,14 @@ void search_workTag(const tTag* t,void* pass) { 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);*/ /* Skipping conditions */ if (!equalsIgnoreCase(t->file,datFile)) return; /* If it doesn't belong to the given DAT file */ if (!t->value) return; /* If there was not number id */ if (!t->index) return; /* If there was not index id */ if (!equalsIgnoreCase(t->tag,"item")) return; /* If the tag isn't an item */ +/*printf("terminan las preguntas\n");*/ /* Process tag and copy values to resource: */ @@ -125,7 +128,7 @@ void search_workTag(const tTag* t,void* pass) { search_keepIdAttributesElse(palette,palette,paletteindex,index); /* 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 */ + 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; @@ -169,9 +172,9 @@ extern FILE* outputStream; const tTag* search_searchTree(const tTag* t,const char* datFile, const char* id) { /* tTag* - tag pointer if found - NULL if not found - */ + * tag pointer if found + * NULL if not found + */ tTag* children; const tTag* result; diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c index a123968..35c331a 100644 --- a/PR/src/lib/xml/tree.c +++ b/PR/src/lib/xml/tree.c @@ -138,7 +138,7 @@ void tree_TagCommonFactor(tTag* parent) { tList valueList; long offset; } attrInfo[attributeCount]; - +printf("aaaaaaaaaaaa\n"); if (!parent->child) return; /* avoid a full cycle for foils */ tree_bindAttr(palette,0); @@ -552,6 +552,7 @@ void treeDeleteFile(const char* file, tTag* tree) { #define tree_TotalInheritance(a) if (parent->a&&child->a&&equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;} void tree_rec_fix(tTag* parent,tTag* child) { +printf("aaaaaaaaaaaaa\n"); if (child->next) tree_rec_fix(parent,child->next); if (child->child) tree_rec_fix(child,child->child);