00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #include <errno.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030
00031 #include "treeconf_int.h"
00032
00033 RCSTAG("@(#)$Id: _tc_lookup_node.c,v 1.4 2005/06/07 04:53:50 klmitch Exp $");
00034
00054 unsigned int
00055 _tc_lookup_node(treeconf_ctx_t *ctx, const char *name, treeconf_node_t *node,
00056 struct result *res)
00057 {
00058 unsigned int err;
00059 int i;
00060
00061
00062 if ((err = tc_break(&res->r_comps, &res->r_count, name, "./")))
00063 return err;
00064
00065
00066 res->r_startnew = 0;
00067 res->r_node = node;
00068
00069
00070 for (i = 0; i < res->r_count && (!i || node); i++) {
00071 if (node && (tn_type(node) & TC_NODETYPE_MASK) != TC_NODETYPE_NODE)
00072 return ENOENT;
00073
00074
00075 for (node = node ? node->tn_down : tx_config(ctx); node;
00076 node = node->tn_next) {
00077 if (strlen(tn_name(node)) != res->r_comps[i].ts_length ||
00078 strncmp(tn_name(node), res->r_comps[i].ts_string,
00079 res->r_comps[i].ts_length))
00080 continue;
00081
00082 res->r_startnew = i + 1;
00083 res->r_node = node;
00084 break;
00085 }
00086 }
00087
00088 return 0;
00089 }