|
@@ -195,6 +195,30 @@ int srp_help_insert(kcontext_t *context)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+int srp_compl_show(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_SHOW, BOOL_TRUE, BOOL_TRUE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int srp_compl_show_abs(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_SHOW, BOOL_FALSE, BOOL_TRUE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int srp_help_show(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_SHOW, BOOL_TRUE, BOOL_TRUE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int srp_help_show_abs(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_SHOW, BOOL_FALSE, BOOL_TRUE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
int srp_prompt_edit_path(kcontext_t *context)
|
|
int srp_prompt_edit_path(kcontext_t *context)
|
|
{
|
|
{
|
|
faux_argv_t *cur_path = NULL;
|
|
faux_argv_t *cur_path = NULL;
|
|
@@ -289,6 +313,18 @@ int srp_PLINE_INSERT_FROM(kcontext_t *context)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+int srp_PLINE_SHOW(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_check_type(context, PT_NOT_SHOW, 1, BOOL_TRUE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+int srp_PLINE_SHOW_ABS(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ return srp_check_type(context, PT_NOT_SHOW, 1, BOOL_FALSE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
static faux_argv_t *assemble_insert_to(sr_session_ctx_t *sess, const kpargv_t *pargv,
|
|
static faux_argv_t *assemble_insert_to(sr_session_ctx_t *sess, const kpargv_t *pargv,
|
|
faux_argv_t *cur_path, const char *candidate_value, pline_opts_t *opts)
|
|
faux_argv_t *cur_path, const char *candidate_value, pline_opts_t *opts)
|
|
{
|
|
{
|
|
@@ -920,7 +956,7 @@ static int show(kcontext_t *context, sr_datastore_t ds,
|
|
fprintf(stderr, ERRORMSG "Can't get expression\n");
|
|
fprintf(stderr, ERRORMSG "Can't get expression\n");
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
- if (!(expr->pat & PT_EDIT)) {
|
|
|
|
|
|
+ if (!(expr->pat & PT_SHOW)) {
|
|
fprintf(stderr, ERRORMSG "Illegal expression for 'show' operation\n");
|
|
fprintf(stderr, ERRORMSG "Illegal expression for 'show' operation\n");
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
@@ -1184,10 +1220,8 @@ int srp_compl_xpath(kcontext_t *context)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// Function for mass config strings load. It can load stream of KPath strings
|
|
|
|
-// (without "set" command, only path and value). Function doesn't use
|
|
|
|
-// pre-connected session because it can be executed within FILTER or utility.
|
|
|
|
-int srp_mass_set(int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
|
|
|
|
|
|
+// Function for mass operations.
|
|
|
|
+int srp_mass_op(char op, int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
|
|
const pline_opts_t *opts, const char *user, bool_t stop_on_error)
|
|
const pline_opts_t *opts, const char *user, bool_t stop_on_error)
|
|
{
|
|
{
|
|
int ret = -1;
|
|
int ret = -1;
|
|
@@ -1254,15 +1288,38 @@ int srp_mass_set(int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
|
|
|
|
|
|
iter = faux_list_head(pline->exprs);
|
|
iter = faux_list_head(pline->exprs);
|
|
while ((expr = (pexpr_t *)faux_list_each(&iter))) {
|
|
while ((expr = (pexpr_t *)faux_list_each(&iter))) {
|
|
- if (!(expr->pat & PT_SET)) {
|
|
|
|
- err_num++;
|
|
|
|
- fprintf(stderr, "Error: Illegal expression for set operation\n");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (sr_set_item_str(sess, expr->xpath, expr->value, NULL, 0) !=
|
|
|
|
- SR_ERR_OK) {
|
|
|
|
|
|
+ // Set
|
|
|
|
+ if (op == 's') {
|
|
|
|
+ if (!(expr->pat & PT_SET)) {
|
|
|
|
+ err_num++;
|
|
|
|
+ fprintf(stderr, "Error: Illegal expression"
|
|
|
|
+ " for set operation\n");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (sr_set_item_str(sess, expr->xpath,
|
|
|
|
+ expr->value, NULL, 0) != SR_ERR_OK) {
|
|
|
|
+ err_num++;
|
|
|
|
+ fprintf(stderr, "Error: Can't set data\n");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ // Del
|
|
|
|
+ } else if (op == 'd') {
|
|
|
|
+ if (!(expr->pat & PT_DEL)) {
|
|
|
|
+ err_num++;
|
|
|
|
+ fprintf(stderr, "Error: Illegal expression"
|
|
|
|
+ " for del operation\n");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (sr_delete_item(sess, expr->xpath, 0) !=
|
|
|
|
+ SR_ERR_OK) {
|
|
|
|
+ err_num++;
|
|
|
|
+ fprintf(stderr, "Error: Can't del data\n");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
err_num++;
|
|
err_num++;
|
|
- fprintf(stderr, "Error: Can't set data\n");
|
|
|
|
|
|
+ fprintf(stderr, "Error: Illegal operation '%c'\n",
|
|
|
|
+ op);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1294,3 +1351,23 @@ out:
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Function for mass config strings load. It can load stream of KPath strings
|
|
|
|
+// (without "set" command, only path and value). Function doesn't use
|
|
|
|
+// pre-connected session because it can be executed within FILTER or utility.
|
|
|
|
+int srp_mass_set(int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
|
|
|
|
+ const pline_opts_t *opts, const char *user, bool_t stop_on_error)
|
|
|
|
+{
|
|
|
|
+ return srp_mass_op('s', fd, ds, cur_path, opts, user, stop_on_error);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Function for mass config strings deletion. It can get stream of KPath strings
|
|
|
|
+// (without "del" command, only path). Function doesn't use
|
|
|
|
+// pre-connected session because it can be executed within FILTER or utility.
|
|
|
|
+int srp_mass_del(int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
|
|
|
|
+ const pline_opts_t *opts, const char *user, bool_t stop_on_error)
|
|
|
|
+{
|
|
|
|
+ return srp_mass_op('d', fd, ds, cur_path, opts, user, stop_on_error);
|
|
|
|
+}
|