* clixon-config YAML file has new revision: 2019-02-06.

* Replaced all calls to (obsolete) `cli_output` with `fprintf`
* Added _experimental_ config option `CLICON_CLI_UTF8` default set to 0.
  * CLIgen UTF8 does not work with scrolling and control editing
This commit is contained in:
Olof hagsand 2019-02-06 14:33:04 +01:00
parent ae8d28fae8
commit 5b1c3d9a86
11 changed files with 55 additions and 28 deletions

View file

@ -87,6 +87,9 @@
* `commit` - NACM is applied to candidate and running operations only (3.2.8) * `commit` - NACM is applied to candidate and running operations only (3.2.8)
* Client-side RPC:s are _not_ supported. * Client-side RPC:s are _not_ supported.
* Recovery user "_nacm_recovery" added. * Recovery user "_nacm_recovery" added.
* Change GIT branch handling to a single working master branch
* Develop branched abandoned
* Travis CI supported, see [https://travis-ci.org/clicon/clixon]
### API changes on existing features (you may need to change your code) ### API changes on existing features (you may need to change your code)
* Added `username` argument to `xmldb_put()` datastore function for NACM data-node write checks * Added `username` argument to `xmldb_put()` datastore function for NACM data-node write checks
@ -119,14 +122,15 @@
* For backward compatibility, define CLICON_CLI_MODEL_TREENAME_PATCH in clixon_custom.h * For backward compatibility, define CLICON_CLI_MODEL_TREENAME_PATCH in clixon_custom.h
### Minor changes ### Minor changes
* Change GIT branch handling to a single working master branch
* Develop branched abandoned
* Travis CI supported, see [https://travis-ci.org/clicon/clixon]
* XML parser conformance to W3 spec * XML parser conformance to W3 spec
* Names lexically correct (NCName) * Names lexically correct (NCName)
* Syntactically Correct handling of '<?' (processing instructions) and '<?xml' (XML declaration) * Syntactically Correct handling of '<?' (processing instructions) and '<?xml' (XML declaration)
* XML prolog syntax for 'well-formed' XML * XML prolog syntax for 'well-formed' XML
* `<!DOCTYPE` (ie DTD) is not supported. * `<!DOCTYPE` (ie DTD) is not supported.
* clixon-config YAML file has new revision: 2019-02-06.
* Replaced all calls to (obsolete) `cli_output` with `fprintf`
* Added _experimental_ config option `CLICON_CLI_UTF8` default set to 0.
* CLIgen UTF8 does not work with scrolling and control editing
* Added `make test` from top-level Makefile * Added `make test` from top-level Makefile
* Added `xml_rootchild_node()` lib function as variant of `xml_rootchild()` * Added `xml_rootchild_node()` lib function as variant of `xml_rootchild()`
* Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf. * Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf.

View file

@ -352,7 +352,7 @@ main(int argc, char **argv)
break; /* see above */ break; /* see above */
case 'F': /* read commands from file */ case 'F': /* read commands from file */
if (freopen(optarg, "r", stdin) == NULL){ if (freopen(optarg, "r", stdin) == NULL){
cli_output(stderr, "freopen: %s\n", strerror(errno)); fprintf(stderr, "freopen: %s\n", strerror(errno));
return -1; return -1;
} }
break; break;
@ -531,6 +531,7 @@ main(int argc, char **argv)
*(argv-1) = tmp; *(argv-1) = tmp;
cligen_line_scrolling_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_LINESCROLLING")); cligen_line_scrolling_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_LINESCROLLING"));
cligen_utf8_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_UTF8"));
/* Launch interfactive event loop, unless -1 */ /* Launch interfactive event loop, unless -1 */
if (restarg != NULL && strlen(restarg)){ if (restarg != NULL && strlen(restarg)){
char *mode = cli_syntax_mode(h); char *mode = cli_syntax_mode(h);

View file

@ -455,15 +455,13 @@ int
cli_handler_err(FILE *f) cli_handler_err(FILE *f)
{ {
if (clicon_errno){ if (clicon_errno){
cli_output(f, "%s: %s", fprintf(f, "%s: %s", clicon_strerror(clicon_errno), clicon_err_reason);
clicon_strerror(clicon_errno),
clicon_err_reason);
if (clicon_suberrno) if (clicon_suberrno)
cli_output(f, ": %s", strerror(clicon_suberrno)); fprintf(f, ": %s", strerror(clicon_suberrno));
cli_output(f, "\n"); fprintf(f, "\n");
} }
else else
cli_output(f, "CLI command error\n"); fprintf(f, "CLI command error\n");
return 0; return 0;
} }
@ -482,7 +480,6 @@ clicon_eval(clicon_handle h,
{ {
int retval = 0; int retval = 0;
cli_output_reset();
if (!cligen_exiting(cli_cligen(h))) { if (!cligen_exiting(cli_cligen(h))) {
clicon_err_reset(); clicon_err_reset();
if ((retval = cligen_eval(cli_cligen(h), match_obj, cvv)) < 0) { if ((retval = cligen_eval(cli_cligen(h), match_obj, cvv)) < 0) {
@ -546,7 +543,7 @@ clicon_parse(clicon_handle h,
} }
else { else {
if ((smode = syntax_mode_find(stx, modename, 0)) == NULL) { if ((smode = syntax_mode_find(stx, modename, 0)) == NULL) {
cli_output(f, "Can't find syntax mode '%s'\n", modename); fprintf(f, "Can't find syntax mode '%s'\n", modename);
goto done; goto done;
} }
} }
@ -576,13 +573,12 @@ clicon_parse(clicon_handle h,
switch (retval) { switch (retval) {
case CG_EOF: /* eof */ case CG_EOF: /* eof */
case CG_ERROR: case CG_ERROR:
cli_output(f, "CLI parse error: %s\n", cmd); fprintf(f, "CLI parse error: %s\n", cmd);
break; break;
case CG_NOMATCH: /* no match */ case CG_NOMATCH: /* no match */
/* clicon_err(OE_CFG, 0, "CLI syntax error: \"%s\": %s", /* clicon_err(OE_CFG, 0, "CLI syntax error: \"%s\": %s",
cmd, cli_nomatch(h));*/ cmd, cli_nomatch(h));*/
cli_output(f, "CLI syntax error: \"%s\": %s\n", fprintf(f, "CLI syntax error: \"%s\": %s\n", cmd, cli_nomatch(h));
cmd, cli_nomatch(h));
break; break;
case CG_MATCH: case CG_MATCH:
if (strcmp(modename, *modenamep)){ /* Command in different mode */ if (strcmp(modename, *modenamep)){ /* Command in different mode */
@ -596,7 +592,7 @@ clicon_parse(clicon_handle h,
*evalres = r; *evalres = r;
break; break;
default: default:
cli_output(f, "CLI syntax error: \"%s\" is ambiguous\n", cmd); fprintf(f, "CLI syntax error: \"%s\" is ambiguous\n", cmd);
break; break;
} /* switch retval */ } /* switch retval */
} }

View file

@ -193,7 +193,7 @@ expand_dbvar(void *h,
if (xml_merge(xt, xtop, yspec, &reason) < 0) /* Merge xtop into xt */ if (xml_merge(xt, xtop, yspec, &reason) < 0) /* Merge xtop into xt */
goto done; goto done;
if (reason){ if (reason){
cli_output(stderr, "%s\n", reason); fprintf(stderr, "%s\n", reason);
goto done; goto done;
} }
if ((xcur = xpath_first(xt, "%s", xpath)) == NULL){ if ((xcur = xpath_first(xt, "%s", xpath)) == NULL){
@ -602,9 +602,11 @@ done:
return retval; return retval;
} }
int cli_show_version(clicon_handle h, cvec *vars, cvec *argv) int cli_show_version(clicon_handle h,
cvec *vars,
cvec *argv)
{ {
cli_output(stdout, "%s\n", CLIXON_VERSION_STRING); fprintf(stdout, "%s\n", CLIXON_VERSION_STRING);
return 0; return 0;
} }

View file

@ -67,7 +67,6 @@ int cli_notification_register(clicon_handle h, char *stream, enum format_enum fo
char *filter, int status, char *filter, int status,
int (*fn)(int, void*), void *arg); int (*fn)(int, void*), void *arg);
#define cli_output cligen_output
/* cli_common.c: CLIgen new vector callbacks */ /* cli_common.c: CLIgen new vector callbacks */

View file

@ -65,6 +65,7 @@ On linux:
sudo usermod -a -G clicon <user> sudo usermod -a -G clicon <user>
sudo usermod -a -G clicon www-data sudo usermod -a -G clicon www-data
``` ```
(you may have to restart shell)
Verify: Verify:
``` ```

View file

@ -122,10 +122,21 @@ For example, using nginx, install, and edit config file: /etc/nginx/sites-availa
``` ```
server { server {
... ...
location / {
root /usr/share/nginx/html/restconf;
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
include fastcgi_params;
}
location /restconf { location /restconf {
fastcgi_pass unix:/www-data/fastcgi_restconf.sock; fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
include fastcgi_params; include fastcgi_params;
} }
location /streams {
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
include fastcgi_params;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
} }
``` ```
Start nginx daemon Start nginx daemon

View file

@ -63,8 +63,8 @@ mycallback(clicon_handle h, cvec *cvv, cvec *argv)
/* Access cligen callback variables */ /* Access cligen callback variables */
myvar = cvec_find(cvv, "var"); /* get a cligen variable from vector */ myvar = cvec_find(cvv, "var"); /* get a cligen variable from vector */
cli_output(stderr, "%s: %d\n", __FUNCTION__, cv_int32_get(myvar)); /* get int value */ fprintf(stderr, "%s: %d\n", __FUNCTION__, cv_int32_get(myvar)); /* get int value */
cli_output(stderr, "arg = %s\n", cv_string_get(cvec_i(argv,0))); /* get string value */ fprintf(stderr, "arg = %s\n", cv_string_get(cvec_i(argv,0))); /* get string value */
/* Show eth0 interfaces config using XPATH */ /* Show eth0 interfaces config using XPATH */
if (clicon_rpc_get_config(h, "running", if (clicon_rpc_get_config(h, "running",

View file

@ -44,6 +44,7 @@ SHELL = /bin/sh
all: all:
./test_xml.sh ./test_xml.sh
./test_json.sh
# ./all.sh # ./all.sh
clean: clean:

View file

@ -40,7 +40,7 @@ datarootdir = @datarootdir@
CLIXON_DATADIR = @CLIXON_DATADIR@ CLIXON_DATADIR = @CLIXON_DATADIR@
YANGSPECS = clixon-config@2018-10-21.yang YANGSPECS = clixon-config@2019-02-06.yang
YANGSPECS += clixon-lib@2019-01-02.yang YANGSPECS += clixon-lib@2019-01-02.yang
YANGSPECS += clixon-rfc5277@2008-07-01.yang YANGSPECS += clixon-rfc5277@2008-07-01.yang

View file

@ -39,6 +39,10 @@ module clixon-config {
***** END LICENSE BLOCK *****"; ***** END LICENSE BLOCK *****";
revision 2019-02-06 {
description
"Released in Clixon 3.9";
}
revision 2018-10-21 { revision 2018-10-21 {
description description
"Released in Clixon 3.8"; "Released in Clixon 3.8";
@ -275,6 +279,14 @@ module clixon-config {
Set to 1 if you want CLI to scroll sideways when approaching Set to 1 if you want CLI to scroll sideways when approaching
right margin"; right margin";
} }
leaf CLICON_CLI_UTF8 {
type int8;
default 0;
description
"Set to 1 to enable CLIgen UTF-8 experimental mode.
Note that this feature is EXPERIMENTAL and may not properly handle
scrolling, control characters, etc";
}
leaf CLICON_SOCK_FAMILY { leaf CLICON_SOCK_FAMILY {
type string; type string;
default "UNIX"; default "UNIX";