Index: ossp-pkg/cfg/cfg.h RCS File: /v/ossp/cvs/ossp-pkg/cfg/cfg.h,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/cfg/cfg.h,v' 2>/dev/null --- cfg.h 2002/07/04 06:16:13 1.2 +++ cfg.h 2002/07/04 12:30:08 1.3 @@ -42,7 +42,9 @@ CFG_ERR_USE, CFG_ERR_INT, CFG_ERR_SYS, - CFG_ERR_SYN + CFG_ERR_SYN, + CFG_ERR_FMT, + CFG_ERR_GOT } cfg_rc_t; /* ============================================================ */ @@ -59,7 +61,6 @@ /* list of node types */ typedef enum { - CFG_NODE_TYPE_NN = 0, /* node unknown */ CFG_NODE_TYPE_SEQ, /* node represents a sequence */ CFG_NODE_TYPE_DIR, /* node represents a directive */ CFG_NODE_TYPE_TOK /* node represents a token */ @@ -75,6 +76,15 @@ CFG_NODE_ATTR_DATA /* pointer to the node annotation data */ } cfg_node_attr_t; +/* list of node goto */ +typedef enum { + CFG_NODE_GOTO_PARENT, + CFG_NODE_GOTO_LBROTH, + CFG_NODE_GOTO_RBROTH, + CFG_NODE_GOTO_CHILD1, + CFG_NODE_GOTO_CHILDL +} cfg_node_goto_t; + /* list of node linking variants */ typedef enum { CFG_NODE_LINK_PARENT, @@ -89,6 +99,7 @@ cfg_rc_t cfg_node_create (cfg_node_t **node); cfg_rc_t cfg_node_set (cfg_node_t *node, cfg_node_attr_t attr, ...); cfg_rc_t cfg_node_get (cfg_node_t *node, cfg_node_attr_t attr, ...); +cfg_rc_t cfg_node_goto (cfg_node_t *node, cfg_node_goto_t id, cfg_node_t **node2); cfg_rc_t cfg_node_link (cfg_node_t *node, cfg_node_link_t id, cfg_node_t *node2); cfg_rc_t cfg_node_unlink (cfg_node_t *node); cfg_rc_t cfg_node_apply (cfg_node_t *node, void (*cb_fct)(void *, cfg_node_t *), void *cb_ctx); Index: ossp-pkg/cfg/cfg_node.c RCS File: /v/ossp/cvs/ossp-pkg/cfg/cfg_node.c,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/cfg/cfg_node.c,v' 2>/dev/null --- cfg_node.c 2002/07/04 06:16:13 1.2 +++ cfg_node.c 2002/07/04 12:30:08 1.3 @@ -41,10 +41,10 @@ if ((n = malloc(sizeof(cfg_node_t))) == NULL) return CFG_ERR_SYS; - n->type = CFG_NODE_TYPE_NN; n->parent = NULL; n->rbroth = NULL; n->child1 = NULL; + n->type = CFG_NODE_TYPE_TOK; n->token = NULL; cfg_data_init(&n->data); *node = n; @@ -134,6 +134,51 @@ return CFG_OK; } +cfg_rc_t cfg_node_goto(cfg_node_t *node, cfg_node_goto_t id, cfg_node_t **node2) +{ + cfg_node_t *n; + + if (node == NULL || node2 == NULL) + return CFG_ERR_ARG; + *node2 = NULL; + switch (id) { + case CFG_NODE_GOTO_PARENT: { + *node2 = node->parent; + break; + } + case CFG_NODE_GOTO_LBROTH: { + if ((n = node->parent) != NULL) { + if ((n = n->child1) != NULL) { + while (n->rbroth != node && n->rbroth != NULL) + n = n->rbroth; + if (n->rbroth == node) + *node2 = n; + } + } + break; + } + case CFG_NODE_GOTO_RBROTH: { + *node2 = node->rbroth; + break; + } + case CFG_NODE_GOTO_CHILD1: { + *node2 = node->child1; + break; + } + case CFG_NODE_GOTO_CHILDL: { + if ((n = node->child1) != NULL) { + while (n->rbroth != NULL) + n = n->rbroth; + *node2 = n; + } + break; + } + } + if (*node2 == NULL) + return CFG_ERR_GOT; + return CFG_OK; +} + cfg_rc_t cfg_node_link(cfg_node_t *node, cfg_node_link_t id, cfg_node_t *node2) { cfg_node_t *n; Index: ossp-pkg/cfg/cfg_node.h RCS File: /v/ossp/cvs/ossp-pkg/cfg/cfg_node.h,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/cfg/cfg_node.h,v' 2>/dev/null --- cfg_node.h 2002/07/04 06:16:13 1.2 +++ cfg_node.h 2002/07/04 12:30:08 1.3 @@ -35,11 +35,16 @@ #include "cfg_data.h" struct cfg_node_st { - cfg_node_type_t type; /* type of node */ + /* node linkage */ cfg_node_t *parent; /* pointer to parent node */ cfg_node_t *rbroth; /* pointer to right brother node */ cfg_node_t *child1; /* pointer to first child node */ + + /* node contents */ + cfg_node_type_t type; /* type of node */ char *token; /* pointer to corresponding token string */ + + /* node annotation */ cfg_data_t data; /* annotation data */ };