Browse Source

Merge branch 'master' into compl

Serj Kalichev 11 months ago
parent
commit
21cd4317cf
3 changed files with 21 additions and 8 deletions
  1. 1 1
      bin/.gitignore
  2. 12 7
      bin/srp_load.c
  3. 8 0
      src/syms.c

+ 1 - 1
bin/.gitignore

@@ -1,2 +1,2 @@
 /ytree
-/sr_load
+/srp_load

+ 12 - 7
bin/srp_load.c

@@ -8,6 +8,7 @@
 #include <faux/file.h>
 #include <faux/argv.h>
 
+#include <libyang/log.h>
 #include <sysrepo.h>
 #include <sysrepo/xpath.h>
 
@@ -67,6 +68,10 @@ int main(int argc, char **argv)
 	if (cmd_opts->cfg)
 		pline_opts_parse_file(cmd_opts->cfg, &opts);
 
+	// Turn off libyang warnings
+	ly_log_level(LY_LLERR);
+	ly_log_options(LY_LOSTORE);
+
 	// Prepare argv structure for current sysrepo path
 	if (cmd_opts->current_path) {
 		cur_path = faux_argv_new();
@@ -211,12 +216,12 @@ static void help(int status, const char *argv0)
 		printf("Usage   : %s [options] [filename]\n", name);
 		printf("Load mass of config strings to Sysrepo repository\n");
 		printf("Options :\n");
-		printf("\t-h, --help Print this help.\n");
-		printf("\t-v, --verbose Be verbose.\n");
-		printf("\t-e, --stop-on-error Stop script execution on error.\n");
-		printf("\t-u <name>, --user=<name> NACM user.\n");
-		printf("\t-f <path>, --conf=<path> Config file.\n");
-		printf("\t-d <ds>, --datastore=<ds> Datastore.\n");
-		printf("\t-p <sr-path>, --current-path=<sr-path> Current sysrepo path.\n");
+		printf("\t-h, --help Print this help\n");
+		printf("\t-v, --verbose Be verbose\n");
+		printf("\t-e, --stop-on-error Stop script execution on error\n");
+		printf("\t-u <name>, --user=<name> NACM user name\n");
+		printf("\t-f <path>, --conf=<path> Config file with parsing settings\n");
+		printf("\t-d <ds>, --datastore=<ds> Datastore (Default is 'candidate'\n");
+		printf("\t-p <sr-path>, --current-path=<sr-path> Current sysrepo path\n");
 	}
 }

+ 8 - 0
src/syms.c

@@ -1230,10 +1230,18 @@ int srp_mass_set(int fd, sr_datastore_t ds, const faux_argv_t *cur_path,
 		pline_t *pline = NULL;
 		faux_argv_t *args = NULL;
 
+		// Don't process empty strings and strings with only spaces
+		if (!faux_str_has_content(line)) {
+			faux_str_free(line);
+			continue;
+		}
+
+		// Add current sysrepo path
 		if (cur_path)
 			args = faux_argv_dup(cur_path);
 		else
 			args = faux_argv_new();
+
 		faux_argv_parse(args, line);
 		pline = pline_parse(sess, args, opts);
 		faux_argv_free(args);