[Code formatting: Change indentation style to space](https://github.com/clicon/clixon/issues/379)
* Applies to all c/h/y/l/sh files and .editorconfig
This commit is contained in:
parent
a9d1ab006c
commit
d84c529ff1
376 changed files with 38147 additions and 38133 deletions
|
|
@ -73,14 +73,14 @@ static int
|
|||
usage(char *argv0)
|
||||
{
|
||||
fprintf(stderr, "Tool to validate a database\nusage:%s [options]\n"
|
||||
"where options are\n"
|
||||
"where options are\n"
|
||||
"\t-h \t\tHelp\n"
|
||||
"\t-D <level> \tDebug\n"
|
||||
"\t-f <file>\tClixon config file\n"
|
||||
"\t-d <file>\tDatabase name (if not candidate, must be in XMLDBDIR)\n"
|
||||
"\t-c \t\tValidate + commit, otherwise only validate\n"
|
||||
"\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
|
||||
argv0);
|
||||
"\t-D <level> \tDebug\n"
|
||||
"\t-f <file>\tClixon config file\n"
|
||||
"\t-d <file>\tDatabase name (if not candidate, must be in XMLDBDIR)\n"
|
||||
"\t-c \t\tValidate + commit, otherwise only validate\n"
|
||||
"\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
|
||||
argv0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -105,70 +105,70 @@ main(int argc,
|
|||
|
||||
/* Initialize clixon handle */
|
||||
if ((h = clicon_handle_init()) == NULL)
|
||||
goto done;
|
||||
goto done;
|
||||
/*
|
||||
* Command-line options for help, debug, and config-file
|
||||
*/
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((c = getopt(argc, argv, UTIL_COMMIT_OPTS)) != -1)
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
break;
|
||||
case 'D':
|
||||
if (sscanf(optarg, "%d", &dbg) != 1)
|
||||
usage(argv[0]);
|
||||
break;
|
||||
case 'f': /* config file */
|
||||
if (!strlen(optarg))
|
||||
usage(argv[0]);
|
||||
clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg);
|
||||
break;
|
||||
case 'c': /* commit (otherwise only validate) */
|
||||
case 'd': /* candidate database (if not candidate) */
|
||||
case 'o': /* Configuration option */
|
||||
break; /* see next getopt */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
break;
|
||||
case 'D':
|
||||
if (sscanf(optarg, "%d", &dbg) != 1)
|
||||
usage(argv[0]);
|
||||
break;
|
||||
case 'f': /* config file */
|
||||
if (!strlen(optarg))
|
||||
usage(argv[0]);
|
||||
clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg);
|
||||
break;
|
||||
case 'c': /* commit (otherwise only validate) */
|
||||
case 'd': /* candidate database (if not candidate) */
|
||||
case 'o': /* Configuration option */
|
||||
break; /* see next getopt */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
clicon_debug_init(dbg, NULL);
|
||||
yang_init(h);
|
||||
/* Find and read configfile */
|
||||
if (clicon_options_main(h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Initialize plugin module by creating a handle holding plugin and callback lists */
|
||||
if (clixon_plugin_module_init(h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Now run through the operational args */
|
||||
opterr = 1;
|
||||
optind = 1;
|
||||
while ((c = getopt(argc, argv, UTIL_COMMIT_OPTS)) != -1)
|
||||
switch (c) {
|
||||
case 'h' : /* help */
|
||||
case 'D' : /* debug */
|
||||
case 'f': /* config file */
|
||||
break;
|
||||
case 'c': /* commit (otherwise only validate) */
|
||||
commit++;
|
||||
break;
|
||||
case 'd': /* candidate database (if not candidate) */
|
||||
database = optarg;
|
||||
break;
|
||||
case 'o':{ /* Configuration option */
|
||||
char *val;
|
||||
if ((val = index(optarg, '=')) == NULL)
|
||||
usage(argv[0]);
|
||||
*val++ = '\0';
|
||||
if (clicon_option_add(h, optarg, val) < 0)
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'h' : /* help */
|
||||
case 'D' : /* debug */
|
||||
case 'f': /* config file */
|
||||
break;
|
||||
case 'c': /* commit (otherwise only validate) */
|
||||
commit++;
|
||||
break;
|
||||
case 'd': /* candidate database (if not candidate) */
|
||||
database = optarg;
|
||||
break;
|
||||
case 'o':{ /* Configuration option */
|
||||
char *val;
|
||||
if ((val = index(optarg, '=')) == NULL)
|
||||
usage(argv[0]);
|
||||
*val++ = '\0';
|
||||
if (clicon_option_add(h, optarg, val) < 0)
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||
xml_nsctx_namespace_netconf_default(h);
|
||||
|
|
@ -177,72 +177,72 @@ main(int argc,
|
|||
* Otherwise it is loaded in netconf_module_load below
|
||||
*/
|
||||
if (netconf_module_features(h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
|
||||
/* Create top-level yang spec and store as option */
|
||||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
clicon_dbspec_yang_set(h, yspec);
|
||||
goto done;
|
||||
clicon_dbspec_yang_set(h, yspec);
|
||||
/* Load backend plugins before yangs are loaded (eg extension callbacks) */
|
||||
if ((dir = clicon_backend_dir(h)) != NULL &&
|
||||
clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir,
|
||||
clicon_option_str(h, "CLICON_BACKEND_REGEXP")) < 0)
|
||||
goto done;
|
||||
clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir,
|
||||
clicon_option_str(h, "CLICON_BACKEND_REGEXP")) < 0)
|
||||
goto done;
|
||||
/* Load Yang modules
|
||||
* 1. Load a yang module as a specific absolute filename */
|
||||
if ((str = clicon_yang_main_file(h)) != NULL)
|
||||
if (yang_spec_parse_file(h, str, yspec) < 0)
|
||||
goto done;
|
||||
if (yang_spec_parse_file(h, str, yspec) < 0)
|
||||
goto done;
|
||||
/* 2. Load a (single) main module */
|
||||
if ((str = clicon_yang_module_main(h)) != NULL)
|
||||
if (yang_spec_parse_module(h, str, clicon_yang_module_revision(h),
|
||||
yspec) < 0)
|
||||
goto done;
|
||||
if (yang_spec_parse_module(h, str, clicon_yang_module_revision(h),
|
||||
yspec) < 0)
|
||||
goto done;
|
||||
/* 3. Load all modules in a directory (will not overwrite file loaded ^) */
|
||||
if ((str = clicon_yang_main_dir(h)) != NULL)
|
||||
if (yang_spec_load_dir(h, str, yspec) < 0)
|
||||
goto done;
|
||||
if (yang_spec_load_dir(h, str, yspec) < 0)
|
||||
goto done;
|
||||
/* Load clixon lib yang module */
|
||||
if (yang_spec_parse_module(h, "clixon-lib", NULL, yspec) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Load yang module library, RFC7895 */
|
||||
if (yang_modules_init(h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Add generic yang specs, used by netconf client and as internal protocol
|
||||
*/
|
||||
if (netconf_module_load(h) < 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Load yang restconf module */
|
||||
if (yang_spec_parse_module(h, "ietf-restconf", NULL, yspec)< 0)
|
||||
goto done;
|
||||
goto done;
|
||||
/* Load yang YANG module state */
|
||||
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE") &&
|
||||
yang_spec_parse_module(h, "ietf-yang-library", NULL, yspec)< 0)
|
||||
goto done;
|
||||
yang_spec_parse_module(h, "ietf-yang-library", NULL, yspec)< 0)
|
||||
goto done;
|
||||
/* Here all modules are loaded */
|
||||
if (database == NULL)
|
||||
database = "candidate";
|
||||
database = "candidate";
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (commit){
|
||||
if ((ret = candidate_commit(h, NULL, database, cb)) < 0)
|
||||
goto done;
|
||||
if ((ret = candidate_commit(h, NULL, database, cb)) < 0)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
if ((ret = candidate_validate(h, database, cb)) < 0)
|
||||
goto done;
|
||||
if ((ret = candidate_validate(h, database, cb)) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (ret == 0){
|
||||
clicon_err(OE_DB, 0, " Failed: %s", cbuf_get(cb));
|
||||
goto done;
|
||||
clicon_err(OE_DB, 0, " Failed: %s", cbuf_get(cb));
|
||||
goto done;
|
||||
}
|
||||
fprintf(stdout, "OK\n");
|
||||
retval = 0;
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue