* Experimental text syntax parser/loader
* Added new text syntax parsing and loading from CLI
* Unified text output functions to `xml2txt` and moved to clixon_text_syntax.[ch]
* The following are removed: `cli_xml2txt` and `xml2txt_cb`
* Text output format changed:
* Namespace/modulename added to top-level
* See [Support performant load_config_file(...) for TEXT format](https://github.com/clicon/clixon/issues/324)
This commit is contained in:
parent
43a57dad79
commit
2ece0b8f51
29 changed files with 1140 additions and 238 deletions
|
|
@ -67,7 +67,7 @@
|
|||
#include "clixon/clixon.h"
|
||||
|
||||
/* Command line options passed to getopt(3) */
|
||||
#define UTIL_XML_OPTS "hD:f:Jjl:pvoy:Y:t:T:u"
|
||||
#define UTIL_XML_OPTS "hD:f:JjXl:pvoy:Y:t:T:u"
|
||||
|
||||
static int
|
||||
validate_tree(clicon_handle h,
|
||||
|
|
@ -118,6 +118,7 @@ usage(char *argv0)
|
|||
"\t-f <file>\tXML input file (overrides stdin)\n"
|
||||
"\t-J \t\tInput as JSON\n"
|
||||
"\t-j \t\tOutput as JSON\n"
|
||||
"\t-X \t\tOutput as TEXT \n"
|
||||
"\t-l <s|e|o> \tLog on (s)yslog, std(e)rr, std(o)ut (stderr is default)\n"
|
||||
"\t-o \t\tOutput the file\n"
|
||||
"\t-v \t\tValidate the result in terms of Yang model (requires -y)\n"
|
||||
|
|
@ -144,6 +145,7 @@ main(int argc,
|
|||
int logdst = CLICON_LOG_STDERR;
|
||||
int jsonin = 0;
|
||||
int jsonout = 0;
|
||||
int textout = 0;
|
||||
char *input_filename = NULL;
|
||||
char *top_input_filename = NULL;
|
||||
char *yang_file_dir = NULL;
|
||||
|
|
@ -196,6 +198,9 @@ main(int argc,
|
|||
case 'j':
|
||||
jsonout++;
|
||||
break;
|
||||
case 'X':
|
||||
textout++;
|
||||
break;
|
||||
case 'l': /* Log destination: s|e|o|f */
|
||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||
usage(argv[0]);
|
||||
|
|
@ -334,9 +339,16 @@ main(int argc,
|
|||
if (validate_tree(h, xt, yspec) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* 4. Output data (xml/json) */
|
||||
/* 4. Output data (xml/json/text) */
|
||||
if (output){
|
||||
if (jsonout)
|
||||
if (textout){
|
||||
xc = NULL;
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL){
|
||||
if (xml2txt(xc, fprintf, stdout, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else if (jsonout)
|
||||
xml2json_cbuf(cb, xt, pretty, 1); /* print json */
|
||||
else
|
||||
clicon_xml2cbuf(cb, xt, 0, pretty, -1, 1); /* print xml */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue