X-Git-Url: http://git.maemo.org/git/?p=routino;a=blobdiff_plain;f=src%2Ftagging.c;fp=src%2Ftagging.c;h=57e3cea238b9317593fe1245f58fad2a530d0403;hp=814580f17b7b4d475d2ca2a69d35520dcaf8a5ba;hb=9dffc9de96014e24d1fd1030a79317ba34c504e8;hpb=42c9226fc71c19af4d755c6900120bfa07f7e99c diff --git a/src/tagging.c b/src/tagging.c index 814580f..57e3cea 100644 --- a/src/tagging.c +++ b/src/tagging.c @@ -1,5 +1,5 @@ /*************************************** - $Header: /home/amb/routino/src/RCS/tagging.c,v 1.2 2010/05/23 10:18:59 amb Exp $ + $Header: /home/amb/routino/src/RCS/tagging.c,v 1.5 2010/09/17 17:40:41 amb Exp $ Load the tagging rules from a file and the functions for handling them. @@ -26,7 +26,7 @@ #include #include -#include "functions.h" +#include "files.h" #include "tagging.h" #include "xmlparse.h" @@ -54,22 +54,15 @@ static void apply_actions(TaggingRule *rule,int match,TagList *input,TagList *ou //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding); //static int RoutinoTaggingType_function(const char *_tag_,int _type_); static int WayType_function(const char *_tag_,int _type_); -static int IfType_function(const char *_tag_,int _type_,const char *k,const char *v); +static int NodeType_function(const char *_tag_,int _type_); static int RelationType_function(const char *_tag_,int _type_); +static int IfType_function(const char *_tag_,int _type_,const char *k,const char *v); static int OutputType_function(const char *_tag_,int _type_,const char *k,const char *v); static int SetType_function(const char *_tag_,int _type_,const char *k,const char *v); -static int NodeType_function(const char *_tag_,int _type_); /* The XML tag definitions */ -/*+ The NodeType type tag. +*/ -static xmltag NodeType_tag= - {"node", - 0, {NULL}, - NodeType_function, - {NULL}}; - /*+ The SetType type tag. +*/ static xmltag SetType_tag= {"set", @@ -84,13 +77,6 @@ static xmltag OutputType_tag= OutputType_function, {NULL}}; -/*+ The RelationType type tag. +*/ -static xmltag RelationType_tag= - {"relation", - 0, {NULL}, - RelationType_function, - {NULL}}; - /*+ The IfType type tag. +*/ static xmltag IfType_tag= {"if", @@ -98,6 +84,20 @@ static xmltag IfType_tag= IfType_function, {&SetType_tag,&OutputType_tag,NULL}}; +/*+ The RelationType type tag. +*/ +static xmltag RelationType_tag= + {"relation", + 0, {NULL}, + RelationType_function, + {&IfType_tag,NULL}}; + +/*+ The NodeType type tag. +*/ +static xmltag NodeType_tag= + {"node", + 0, {NULL}, + NodeType_function, + {&IfType_tag,NULL}}; + /*+ The WayType type tag. +*/ static xmltag WayType_tag= {"way", @@ -128,28 +128,32 @@ static xmltag *xml_toplevel_tags[]={&xmlDeclaration_tag,&RoutinoTaggingType_tag, /*++++++++++++++++++++++++++++++++++++++ - The function that is called when the NodeType XSD type is seen + The function that is called when the SetType XSD type is seen - int NodeType_function Returns 0 if no error occured or something else otherwise. + int SetType_function Returns 0 if no error occured or something else otherwise. const char *_tag_ Set to the name of the element tag that triggered this function call. int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. + + const char *k The contents of the 'k' attribute (or NULL if not defined). + + const char *v The contents of the 'v' attribute (or NULL if not defined). ++++++++++++++++++++++++++++++++++++++*/ -static int NodeType_function(const char *_tag_,int _type_) +static int SetType_function(const char *_tag_,int _type_,const char *k,const char *v) { if(_type_&XMLPARSE_TAG_START) - current_list=&NodeRules; + AppendTaggingAction(current_rule,k,v,0); return(0); } /*++++++++++++++++++++++++++++++++++++++ - The function that is called when the SetType XSD type is seen + The function that is called when the OutputType XSD type is seen - int SetType_function Returns 0 if no error occured or something else otherwise. + int OutputType_function Returns 0 if no error occured or something else otherwise. const char *_tag_ Set to the name of the element tag that triggered this function call. @@ -160,19 +164,19 @@ static int NodeType_function(const char *_tag_,int _type_) const char *v The contents of the 'v' attribute (or NULL if not defined). ++++++++++++++++++++++++++++++++++++++*/ -static int SetType_function(const char *_tag_,int _type_,const char *k,const char *v) +static int OutputType_function(const char *_tag_,int _type_,const char *k,const char *v) { if(_type_&XMLPARSE_TAG_START) - AppendTaggingAction(current_rule,k,v,0); + AppendTaggingAction(current_rule,k,v,1); return(0); } /*++++++++++++++++++++++++++++++++++++++ - The function that is called when the OutputType XSD type is seen + The function that is called when the IfType XSD type is seen - int OutputType_function Returns 0 if no error occured or something else otherwise. + int IfType_function Returns 0 if no error occured or something else otherwise. const char *_tag_ Set to the name of the element tag that triggered this function call. @@ -183,10 +187,12 @@ static int SetType_function(const char *_tag_,int _type_,const char *k,const cha const char *v The contents of the 'v' attribute (or NULL if not defined). ++++++++++++++++++++++++++++++++++++++*/ -static int OutputType_function(const char *_tag_,int _type_,const char *k,const char *v) +static int IfType_function(const char *_tag_,int _type_,const char *k,const char *v) { if(_type_&XMLPARSE_TAG_START) - AppendTaggingAction(current_rule,k,v,1); + { + current_rule=AppendTaggingRule(current_list,k,v); + } return(0); } @@ -212,25 +218,19 @@ static int RelationType_function(const char *_tag_,int _type_) /*++++++++++++++++++++++++++++++++++++++ - The function that is called when the IfType XSD type is seen + The function that is called when the NodeType XSD type is seen - int IfType_function Returns 0 if no error occured or something else otherwise. + int NodeType_function Returns 0 if no error occured or something else otherwise. const char *_tag_ Set to the name of the element tag that triggered this function call. int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag. - - const char *k The contents of the 'k' attribute (or NULL if not defined). - - const char *v The contents of the 'v' attribute (or NULL if not defined). ++++++++++++++++++++++++++++++++++++++*/ -static int IfType_function(const char *_tag_,int _type_,const char *k,const char *v) +static int NodeType_function(const char *_tag_,int _type_) { if(_type_&XMLPARSE_TAG_START) - { - current_rule=AppendTaggingRule(current_list,k,v); - } + current_list=&NodeRules; return(0); }