Removing newlines from XML data [https://github.com/clicon/clixon/issues/65]
This commit is contained in:
parent
26a75a4c50
commit
03ac48ab2b
6 changed files with 44 additions and 10 deletions
|
|
@ -72,6 +72,7 @@ usage(char *argv0)
|
|||
"where options are\n"
|
||||
"\t-h \t\tHelp\n"
|
||||
"\t-D <level> \tDebug\n"
|
||||
"\t-j \tOutput as JSON\n"
|
||||
"\t-l <s|e|o> \tLog on (s)yslog, std(e)rr, std(o)ut (stderr is default)\n",
|
||||
argv0);
|
||||
exit(0);
|
||||
|
|
@ -87,10 +88,11 @@ main(int argc,
|
|||
int retval = -1;
|
||||
int c;
|
||||
int logdst = CLICON_LOG_STDERR;
|
||||
int json = 0;
|
||||
|
||||
optind = 1;
|
||||
opterr = 0;
|
||||
while ((c = getopt(argc, argv, "hD:l:")) != -1)
|
||||
while ((c = getopt(argc, argv, "hD:jl:")) != -1)
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
|
|
@ -99,6 +101,9 @@ main(int argc,
|
|||
if (sscanf(optarg, "%d", &debug) != 1)
|
||||
usage(argv[0]);
|
||||
break;
|
||||
case 'j':
|
||||
json++;
|
||||
break;
|
||||
case 'l': /* Log destination: s|e|o|f */
|
||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||
usage(argv[0]);
|
||||
|
|
@ -114,7 +119,10 @@ main(int argc,
|
|||
}
|
||||
xc = NULL;
|
||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL)
|
||||
clicon_xml2cbuf(cb, xc, 0, 0); /* print xml */
|
||||
if (json)
|
||||
xml2json_cbuf(cb, xc, 0); /* print xml */
|
||||
else
|
||||
clicon_xml2cbuf(cb, xc, 0, 0); /* print xml */
|
||||
fprintf(stdout, "%s", cbuf_get(cb));
|
||||
fflush(stdout);
|
||||
#if 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue