* 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:
Olof hagsand 2022-05-19 12:56:44 +02:00
parent 43a57dad79
commit 2ece0b8f51
29 changed files with 1140 additions and 238 deletions

View file

@ -698,7 +698,7 @@ compare_xmls(cxobj *xc1,
xc = NULL;
if (astext)
while ((xc = xml_child_each(xc1, xc, -1)) != NULL)
xml2txt_cb(f, xc, cligen_output);
xml2txt(xc, cligen_output, f, 0);
else
while ((xc = xml_child_each(xc1, xc, -1)) != NULL)
clicon_xml2file_cb(f, xc, 0, 1, cligen_output);
@ -715,7 +715,7 @@ compare_xmls(cxobj *xc1,
xc = NULL;
if (astext)
while ((xc = xml_child_each(xc2, xc, -1)) != NULL)
xml2txt_cb(f, xc, cligen_output);
xml2txt(xc, cligen_output, f, 0);
else
while ((xc = xml_child_each(xc2, xc, -1)) != NULL)
clicon_xml2file_cb(f, xc, 0, 1, cligen_output);
@ -882,6 +882,14 @@ load_config_file(clicon_handle h,
goto done;
}
break;
case FORMAT_TEXT:
if ((ret = clixon_text_syntax_parse_file(fp, YB_NONE, yspec, &xt, &xerr)) < 0)
goto done;
if (ret == 0){
clixon_netconf_error(xerr, "Loading", filename);
goto done;
}
break;
case FORMAT_CLI:
{
char *mode = cli_syntax_mode(h);
@ -1034,7 +1042,7 @@ save_config_file(clicon_handle h,
goto done;
break;
case FORMAT_TEXT:
if (xml2txt(f, xt, 0) < 0)
if (xml2txt(xt, fprintf, f, 0) < 0)
goto done;
break;
case FORMAT_CLI:
@ -1165,7 +1173,7 @@ cli_notification_cb(int s,
goto done;
break;
case FORMAT_TEXT:
if (xml2txt_cb(stdout, x, cligen_output) < 0)
if (xml2txt(x, cligen_output, stdout, 0) < 0)
goto done;
break;
default: