diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2018-09-08 22:31:43 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2020-04-16 12:53:00 +0200 |
| commit | 612c2c15d86e0e5c7e35f1a9a1491f90f365b93c (patch) | |
| tree | 5fd4cb67296f7748d26a420ad6357615dcd3b382 /lib/command.c | |
| parent | 249a771b63505b24d2a8c05158d7692384811533 (diff) | |
*: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.
And while we're add it, rename from pointless ".func" to ".config_write".
[v2: fix forgotten ldpd config_write]
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/command.c b/lib/command.c index a26ec1a266..7d46202da8 100644 --- a/lib/command.c +++ b/lib/command.c @@ -200,9 +200,11 @@ static struct cmd_node enable_node = { .prompt = "%s# ", }; +static int config_write_host(struct vty *vty); static struct cmd_node config_node = { .node = CONFIG_NODE, .prompt = "%s(config)# ", + .config_write = config_write_host, }; static const struct facility_map { @@ -352,10 +354,9 @@ static bool cmd_hash_cmp(const void *a, const void *b) } /* Install top node of command vector. */ -void install_node(struct cmd_node *node, int (*func)(struct vty *)) +void install_node(struct cmd_node *node) { vector_set_index(cmdvec, node->node, node); - node->func = func; node->cmdgraph = graph_new(); node->cmd_vector = vector_init(VECTOR_MIN_SIZE); // add start node @@ -1723,8 +1724,8 @@ static int vty_write_config(struct vty *vty) vty_out(vty, "!\n"); for (i = 0; i < vector_active(cmdvec); i++) - if ((node = vector_slot(cmdvec, i)) && node->func) { - if ((*node->func)(vty)) + if ((node = vector_slot(cmdvec, i)) && node->config_write) { + if ((*node->config_write)(vty)) vty_out(vty, "!\n"); } @@ -2889,11 +2890,11 @@ void cmd_init(int terminal) host.motdfile = NULL; /* Install top nodes. */ - install_node(&view_node, NULL); - install_node(&enable_node, NULL); - install_node(&auth_node, NULL); - install_node(&auth_enable_node, NULL); - install_node(&config_node, config_write_host); + install_node(&view_node); + install_node(&enable_node); + install_node(&auth_node); + install_node(&auth_enable_node); + install_node(&config_node); /* Each node's basic commands. */ install_element(VIEW_NODE, &show_version_cmd); |
