diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index 39f1cb39..bb52137e 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -1002,7 +1002,13 @@ from_client_msg(clicon_handle h,
}
}
reply:
- assert(cbuf_len(cbret));
+ if (cbuf_len(cbret) == 0)
+ cprintf(cbret, ""
+ "operation-failed"
+ "rpc"
+ "error"
+ "Internal error"
+ "");
clicon_debug(1, "%s %s", __FUNCTION__, cbuf_get(cbret));
if (send_msg_reply(ce->ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
switch (errno){
diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c
index 2622d9ed..18288125 100644
--- a/apps/cli/cli_plugin.c
+++ b/apps/cli/cli_plugin.c
@@ -67,9 +67,9 @@
#include "cli_handle.h"
-/*
- * Name of plugin functions
+/*! Name of master plugin functions
* More in clicon_plugin.h
+ * @note not really used consider documenting or remove
*/
#define PLUGIN_PROMPT_HOOK "plugin_prompt_hook"
#define PLUGIN_PARSE_HOOK "plugin_parse_hook"
@@ -658,6 +658,10 @@ clicon_parse(clicon_handle h,
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
goto done;
}
+ if ((pt = cligen_tree_active_get(cli_cligen(h))) == NULL){
+ fprintf(stderr, "No such parse-tree registered: %s\n", modename);
+ goto done;
+ }
if ((cvv = cvec_new(0)) == NULL){
clicon_err(OE_UNIX, errno, "cvec_new");
goto done;;
@@ -903,102 +907,6 @@ cli_prompt(char *fmt)
return prompt;
}
-
-/*
- * Run command in CLI engine
- */
-int
-cli_exec(clicon_handle h, char *cmd, char **mode, int *result)
-{
- return clicon_parse(h, cmd, mode, result);
-}
-
-
-/*
- * push_one
- * nifty code that 'pushes' a syntax one ore more levels
- * op: eg "set"
- * cmd: eg "edit policy-options"
- */
-int
-cli_ptpush(clicon_handle h, char *mode, char *string, char *op)
-{
- cg_obj *co, *co_cmd, *cc;
- parse_tree *pt;
- char **vec = NULL;
- int i, j, nvec;
- int found;
- parse_tree pt_top;
- cli_syntaxmode_t *m;
-
- if ((m = syntax_mode_find(cli_syntax(h), mode, 0)) == NULL)
- return 0;
- pt_top = m->csm_pt;
- if ((co_cmd = co_find_one(pt_top, op)) == NULL)
- return 0;
- pt = &co_cmd->co_pt;
- /* vec is the command, eg 'edit policy_option' */
- if ((vec = clicon_strsep(string, " ", &nvec)) == NULL)
- goto catch;
- co = NULL;
- found = 0;
- for (i=0; ipt_len; j++){
- co = pt->pt_vec[j];
- if (co && co->co_type == CO_COMMAND &&
- (strcmp(co->co_command, vec[i])==0)){
- pt = &co->co_pt;
- found++;
- break;
- }
- }
- if (!found)
- break;//not found on this level
- }
- if (found){ // match all levels
- if (!co_cmd->co_pushed){
- co_cmd->co_pt_push = co_cmd->co_pt;
- co_cmd->co_pushed++;
- }
- co_cmd->co_pt = co->co_pt;
- pt = &co_cmd->co_pt;
- for (i=0; ipt_len; i++) /* set correct parent */
- if ((cc = pt->pt_vec[i]) != NULL)
- co_up_set(cc, co_cmd);
- }
- catch:
- if (vec)
- free(vec);
- return 0;
-}
-
-int
-cli_ptpop(clicon_handle h, char *mode, char *op)
-{
- cg_obj *co_cmd, *cc;
- int i;
- parse_tree *pt;
- parse_tree pt_top;
- cli_syntaxmode_t *m;
-
- if ((m = syntax_mode_find(cli_syntax(h), mode, 0)) == NULL)
- return 0;
- pt_top = m->csm_pt;
- if ((co_cmd = co_find_one(pt_top, op)) == NULL) //set
- return 0;
- if (!co_cmd->co_pushed)
- return 0;
- co_cmd->co_pushed = 0;
- co_cmd->co_pt = co_cmd->co_pt_push;
- pt = &co_cmd->co_pt;
- for (i=0; ipt_len; i++) /* set correct parent */
- if ((cc = pt->pt_vec[i]) != NULL)
- co_up_set(cc, co_cmd);
- return 0;
-}
-
-
/*! Find a cli plugin based on name and resolve a function pointer in it.
* Callback from clicon_dbvars_parse()
* Find a cli plugin based on name if given and use dlsym to resolve a
diff --git a/apps/cli/clixon_cli_api.h b/apps/cli/clixon_cli_api.h
index 57952e47..e24e9053 100644
--- a/apps/cli/clixon_cli_api.h
+++ b/apps/cli/clixon_cli_api.h
@@ -54,7 +54,6 @@ int cli_syntax_load(clicon_handle h);
int cli_handler_err(FILE *fd);
int cli_set_prompt(clicon_handle h, const char *mode, const char *prompt);
char *cli_prompt(char *fmt);
-int cli_exec(clicon_handle h, char *cmd, char **mode, int *result);
int cli_ptpush(clicon_handle h, char *mode, char *string, char *op);
int cli_ptpop(clicon_handle h, char *mode, char *op);
diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c
index 84da6b32..c958730f 100644
--- a/apps/restconf/restconf_methods.c
+++ b/apps/restconf/restconf_methods.c
@@ -723,7 +723,7 @@ api_operation_post(clicon_handle h,
xbot = xtop;
if (api_path2xml(oppath, yspec, xtop, 1, &xbot, &y) < 0)
goto done;
- if (data){
+ if (data && strlen(data)){
/* Parse input data as json or xml into xml */
if (parse_xml){
if (clicon_xml_parse_str(data, &xdata) < 0){