Restructured error,debug anf log API

Renamed functions clicon->clixon, replaced global variables w access functions
Unified clicon_netconf_error with clixon_err()
This commit is contained in:
Olof hagsand 2023-11-13 10:12:52 +01:00
parent 261469be16
commit 24a4991ec8
199 changed files with 4668 additions and 4158 deletions

View file

@ -67,7 +67,7 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include <clixon/clixon.h>
#include "clixon_cli_api.h"
@ -83,7 +83,7 @@
* @endcode
*/
int
pipe_arg_fn(clicon_handle h,
pipe_arg_fn(clixon_handle h,
char *cmd,
char *option,
char *value)
@ -94,19 +94,19 @@ pipe_arg_fn(clicon_handle h,
int i;
if (cmd == NULL || strlen(cmd) == 0){
clicon_err(OE_PLUGIN, EINVAL, "cmd '%s' NULL or empty", cmd);
clixon_err(OE_PLUGIN, EINVAL, "cmd '%s' NULL or empty", cmd);
goto done;
}
if (stat(cmd, &fstat) < 0) {
clicon_err(OE_UNIX, errno, "stat(%s)", cmd);
clixon_err(OE_UNIX, errno, "stat(%s)", cmd);
goto done;
}
if (!S_ISREG(fstat.st_mode)){
clicon_err(OE_UNIX, errno, "%s is not a regular file", cmd);
clixon_err(OE_UNIX, errno, "%s is not a regular file", cmd);
goto done;
}
if ((argv = calloc(4, sizeof(char *))) == NULL){
clicon_err(OE_UNIX, errno, "calloc");
clixon_err(OE_UNIX, errno, "calloc");
goto done;
}
i = 0;
@ -129,7 +129,7 @@ pipe_arg_fn(clicon_handle h,
* @note Any vertical bar (|] in the patterns field is quoted for OR function
*/
int
pipe_grep_fn(clicon_handle h,
pipe_grep_fn(clixon_handle h,
cvec *cvv,
cvec *argv)
{
@ -144,7 +144,7 @@ pipe_grep_fn(clicon_handle h,
char c;
if (cvec_len(argv) != 2){
clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <option> <argname>", cvec_len(argv));
clixon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <option> <argname>", cvec_len(argv));
goto done;
}
if ((cv = cvec_i(argv, 0)) != NULL &&
@ -156,7 +156,7 @@ pipe_grep_fn(clicon_handle h,
strlen(str))
argname = str;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
if (argname && strlen(argname)){
@ -189,7 +189,7 @@ pipe_grep_fn(clicon_handle h,
* @retval -1 Error
*/
int
pipe_wc_fn(clicon_handle h,
pipe_wc_fn(clixon_handle h,
cvec *cvv,
cvec *argv)
{
@ -199,7 +199,7 @@ pipe_wc_fn(clicon_handle h,
char *option = NULL;
if (cvec_len(argv) != 1){
clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <NUM>", cvec_len(argv));
clixon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <NUM>", cvec_len(argv));
goto done;
}
if ((cv = cvec_i(argv, 0)) != NULL &&
@ -220,7 +220,7 @@ pipe_wc_fn(clicon_handle h,
* @retval -1 Error
*/
int
pipe_tail_fn(clicon_handle h,
pipe_tail_fn(clixon_handle h,
cvec *cvv,
cvec *argv)
{
@ -232,7 +232,7 @@ pipe_tail_fn(clicon_handle h,
char *argname = NULL;
if (cvec_len(argv) != 2){
clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <option> <argname>", cvec_len(argv));
clixon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: <option> <argname>", cvec_len(argv));
goto done;
}
if ((cv = cvec_i(argv, 0)) != NULL &&
@ -267,7 +267,7 @@ pipe_tail_fn(clicon_handle h,
* @see cli_show_auto_devs
*/
int
pipe_showas_fn(clicon_handle h,
pipe_showas_fn(clixon_handle h,
cvec *cvv,
cvec *argv)
{
@ -282,7 +282,7 @@ pipe_showas_fn(clicon_handle h,
cxobj *xerr = NULL;
if (cvec_len(argv) < 1 || cvec_len(argv) > 3){
clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected:: <format> [<pretty> [<prepend>]]", cvec_len(argv));
clixon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected:: <format> [<pretty> [<prepend>]]", cvec_len(argv));
goto done;
}
if (cvec_len(argv) > argc){
@ -308,7 +308,7 @@ pipe_showas_fn(clicon_handle h,
if ((ret = xml_bind_yang(h, xt, YB_MODULE, yspec, &xerr)) < 0)
goto done;
if (ret == 0){
clixon_netconf_error(h, xerr, "Parse top file", NULL);
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Parse top file");
goto done;
}
break;