summaryrefslogtreecommitdiff
path: root/lib/cmdtree.c
blob: 5bb76cce3aaef57deb14c94d838f52c57a636a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Command DFA module.
 * Provides a DFA data structure and associated functions for manipulating it.
 * Used to match user command line input.
 *
 * @author Quentin Young <qlyoung@cumulusnetworks.com>
 */

#include "memory.h"
#include "cmdtree.h"

struct graph_node *
add_node(struct graph_node *parent, struct graph_node *child)
{
  int index;
  struct graph_node *p_child;

  for (index = 0; index < vector_active(parent->children); index++)
  {
    *p_child = vector_slot(parent->children, index);
    if (cmp_node(child, p_child))
      return p_child;
  }
  vector_set(parent->children, child);
  return child;
}

int
cmp_node(struct graph_node *first, struct graph_node *second)
{
}

struct graph_node *
new_node(enum graph_node_type type)
{
  struct graph_node *node = XMALLOC(MTYPE_TMP, sizeof(graph_node));
  node->type = type;
  node->children = vector_init(VECTOR_MIN_SIZE);
  node->is_leaf = 0;
  node->is_root = 0;
  node->func = NULL;

  return node;
}