/***************************************
- $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.
#include <string.h>
#include <stdlib.h>
-#include "functions.h"
+#include "files.h"
#include "tagging.h"
#include "xmlparse.h"
//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",
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",
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",
/*++++++++++++++++++++++++++++++++++++++
- 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.
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.
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);
}
/*++++++++++++++++++++++++++++++++++++++
- 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);
}