summaryrefslogtreecommitdiff
path: root/src/cnode/cnode-algorithm.cpp
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2020-02-10 22:59:27 +0100
committerDaniil Baturin <daniil@baturin.org>2020-02-10 22:59:27 +0100
commit7f6eb1ed2c2a9dc76227ac355446b6d4b6c27733 (patch)
tree7da0ad990903eacd43c398577058a93a3f170460 /src/cnode/cnode-algorithm.cpp
parent699963ac8cce88fe15751e3b426f4381bade02f2 (diff)
downloadvyatta-cfg-7f6eb1ed2c2a9dc76227ac355446b6d4b6c27733.tar.gz
vyatta-cfg-7f6eb1ed2c2a9dc76227ac355446b6d4b6c27733.zip
T2026: make cli-shell-api showConfig fail on errors.
Diffstat (limited to 'src/cnode/cnode-algorithm.cpp')
-rw-r--r--src/cnode/cnode-algorithm.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/cnode/cnode-algorithm.cpp b/src/cnode/cnode-algorithm.cpp
index 379fb6a..7463534 100644
--- a/src/cnode/cnode-algorithm.cpp
+++ b/src/cnode/cnode-algorithm.cpp
@@ -24,6 +24,8 @@
#include <cparse/cparse.hpp>
#include <cnode/cnode-algorithm.hpp>
+#include <vyos-errors.h>
+
using namespace cnode;
using namespace cstore;
using namespace std;
@@ -851,31 +853,33 @@ _print_cmds_list(const char *op, vector<Cpath>& list)
}
////// algorithms
-void
+int
cnode::show_cfg_diff(const CfgNode& cfg1, const CfgNode& cfg2,
Cpath& cur_path, bool show_def, bool hide_secret,
bool context_diff)
{
if (cfg1.isInvalid() || cfg2.isInvalid()) {
printf("Specified configuration path is not valid\n");
- return;
+ return VYOS_INVALID_PATH;
}
if ((cfg1.isEmpty() && cfg2.isEmpty())
|| (!cfg1.exists() && !cfg2.exists())) {
printf("Configuration under specified path is empty\n");
- return;
+ return VYOS_EMPTY_CONFIG;
}
// use an invalid value for initial last_ctx
Cpath last_ctx;
_show_diff(&cfg1, &cfg2, -1, cur_path, last_ctx, show_def, hide_secret,
context_diff);
+ return VYOS_SUCCESS;
}
-void
+int
cnode::show_cfg(const CfgNode& cfg, bool show_def, bool hide_secret)
{
Cpath cur_path;
- show_cfg_diff(cfg, cfg, cur_path, show_def, hide_secret);
+ int res = show_cfg_diff(cfg, cfg, cur_path, show_def, hide_secret);
+ return res;
}
void
@@ -916,7 +920,7 @@ cnode::get_cmds(const CfgNode& cfg, vector<Cpath>& set_list,
_get_cmds_diff(&cfg, &cfg, cur_path, del_list, set_list, com_list);
}
-void
+int
cnode::showConfig(const string& cfg1, const string& cfg2,
const Cpath& path, bool show_def, bool hide_secret,
bool context_diff, bool show_cmds, bool ignore_edit)
@@ -960,14 +964,16 @@ cnode::showConfig(const string& cfg1, const string& cfg2,
}
if (!croot1.get() || !croot2.get()) {
printf("Cannot parse specified config file(s)\n");
- return;
+ return 1;
}
if (show_cmds) {
show_cmds_diff(*croot1, *croot2);
+ return 0;
} else {
- show_cfg_diff(*croot1, *croot2, cur_path, show_def, hide_secret,
- context_diff);
+ int res = show_cfg_diff(*croot1, *croot2, cur_path, show_def, hide_secret,
+ context_diff);
+ return res;
}
}