OSSP CVS Repository

ossp - Difference in ossp-pkg/cfg/cfg_node.c versions 1.2 and 1.3
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/cfg/cfg_node.c 1.2 -> 1.3

--- 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;

CVSTrac 2.0.1