* Changed debug levels in clicon_debug() to be based on maskable flags
* Added flag names: `CLIXON_DBG_*`
* Added maskable flags that can be combined when debugging:
* `DEFAULT` = 1: Basic debug message, espcially initialization
* `MSG` = 2: Input and output packets, read datastore
* `DETAIL` = 4: Details: message dump in hex, xpath parse trees, etc
* `EXTRA` = 8: Extra detailed logs
* Test: some errors in yang-lib where content-id was in wrong place
This commit is contained in:
parent
8342b74968
commit
da9bfcbb53
47 changed files with 425 additions and 210 deletions
|
|
@ -114,10 +114,21 @@
|
|||
#include "clixon_path.h"
|
||||
#include "clixon_api_path_parse.h"
|
||||
|
||||
/*
|
||||
also called from yacc generated code *
|
||||
*/
|
||||
/* Best debugging is to enable PARSE_DEBUG below and add -d to the LEX compile statement in the Makefile
|
||||
* And then run the testcase with -D 1
|
||||
* Disable it to stop any calls to clicon_debug. Having it on by default would mean very large debug outputs.
|
||||
*/
|
||||
#if 0
|
||||
#define _PARSE_DEBUG(s) clicon_debug(1,(s))
|
||||
#define _PARSE_DEBUG1(s, s1) clicon_debug(1,(s), (s1))
|
||||
#else
|
||||
#define _PARSE_DEBUG(s)
|
||||
#define _PARSE_DEBUG1(s, s1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Also called from yacc generated code *
|
||||
*/
|
||||
void
|
||||
clixon_api_path_parseerror(void *_ay,
|
||||
char *s)
|
||||
|
|
@ -148,7 +159,7 @@ static clixon_path *
|
|||
path_append(clixon_path *list,
|
||||
clixon_path *new)
|
||||
{
|
||||
clicon_debug(3, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
ADDQ(new, list);
|
||||
|
|
@ -161,7 +172,7 @@ static clixon_path *
|
|||
path_add_keyvalue(clixon_path *cp,
|
||||
cvec *cvk)
|
||||
{
|
||||
clicon_debug(3, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (cp)
|
||||
cp->cp_cvk = cvk;
|
||||
return cp;
|
||||
|
|
@ -173,7 +184,7 @@ path_new(char *module_name,
|
|||
{
|
||||
clixon_path *cp = NULL;
|
||||
|
||||
clicon_debug(3, "%s(%s,%s)", __FUNCTION__, module_name, id);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s(%s,%s)", __FUNCTION__, module_name, id);
|
||||
if ((cp = malloc(sizeof(*cp))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "malloc");
|
||||
goto done;
|
||||
|
|
@ -203,7 +214,7 @@ static cvec *
|
|||
keyval_add(cvec *cvv,
|
||||
cg_var *cv)
|
||||
{
|
||||
clicon_debug(3, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (cv == NULL)
|
||||
goto done;
|
||||
if (cvv == NULL &&
|
||||
|
|
@ -229,7 +240,7 @@ keyval_set(char *name,
|
|||
{
|
||||
cg_var *cv = NULL;
|
||||
|
||||
clicon_debug(3, "%s(%s=%s)", __FUNCTION__, name?name:"NULL", val);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s(%s=%s)", __FUNCTION__, name?name:"NULL", val);
|
||||
if ((cv = cv_new(CGV_STRING)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cv_new");
|
||||
goto done;
|
||||
|
|
@ -256,43 +267,43 @@ keyval_set(char *name,
|
|||
/*
|
||||
*/
|
||||
|
||||
start : list X_EOF {clicon_debug(2,"top");_AY->ay_top=$1; YYACCEPT; }
|
||||
start : list X_EOF {_PARSE_DEBUG("top");_AY->ay_top=$1; YYACCEPT; }
|
||||
;
|
||||
|
||||
list : list SLASH element { if (($$ = path_append($1, $3)) == NULL) YYABORT;
|
||||
clicon_debug(2,"list = list / element");}
|
||||
_PARSE_DEBUG("list = list / element");}
|
||||
| { $$ = NULL;
|
||||
clicon_debug(2,"list = ");}
|
||||
_PARSE_DEBUG("list = ");}
|
||||
;
|
||||
|
||||
element : api_identifier { $$=$1;
|
||||
clicon_debug(2,"element = api_identifier");}
|
||||
_PARSE_DEBUG("element = api_identifier");}
|
||||
| list_instance { $$=$1;
|
||||
clicon_debug(2,"element = list_instance");}
|
||||
_PARSE_DEBUG("element = list_instance");}
|
||||
;
|
||||
|
||||
api_identifier : module_name COLON IDENTIFIER { $$ = path_new($1, $3); free($1); free($3);
|
||||
clicon_debug(2,"api_identifier = module_name : IDENTIFIER");}
|
||||
_PARSE_DEBUG("api_identifier = module_name : IDENTIFIER");}
|
||||
| IDENTIFIER { $$ = path_new(NULL, $1); free($1);
|
||||
clicon_debug(2,"api_identifier = IDENTIFIER");}
|
||||
_PARSE_DEBUG("api_identifier = IDENTIFIER");}
|
||||
;
|
||||
|
||||
module_name : IDENTIFIER { $$ = $1;
|
||||
clicon_debug(2,"module_name = IDENTIFIER");}
|
||||
_PARSE_DEBUG("module_name = IDENTIFIER");}
|
||||
;
|
||||
|
||||
list_instance : api_identifier EQUAL key_values { $$ = path_add_keyvalue($1, $3);
|
||||
clicon_debug(2,"list_instance->api_identifier = key_values");}
|
||||
_PARSE_DEBUG("list_instance->api_identifier = key_values");}
|
||||
;
|
||||
|
||||
key_values : key_values COMMA key_value { if (($$ = keyval_add($1, $3)) == NULL) YYABORT;
|
||||
clicon_debug(2,"key_values->key_values , key_value");}
|
||||
_PARSE_DEBUG("key_values->key_values , key_value");}
|
||||
| key_value { if (($$ = keyval_add(NULL, $1)) == NULL) YYABORT;
|
||||
clicon_debug(2,"key_values->key_value");}
|
||||
_PARSE_DEBUG("key_values->key_value");}
|
||||
;
|
||||
|
||||
key_value : STRING { $$ = keyval_set(NULL, $1); free($1); clicon_debug(2,"keyvalue->STRING"); }
|
||||
| { $$ = keyval_set(NULL, ""); clicon_debug(2,"keyvalue->"); }
|
||||
key_value : STRING { $$ = keyval_set(NULL, $1); free($1); _PARSE_DEBUG("keyvalue->STRING"); }
|
||||
| { $$ = keyval_set(NULL, ""); _PARSE_DEBUG("keyvalue->"); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ xmldb_exists(clicon_handle h,
|
|||
char *filename = NULL;
|
||||
struct stat sb;
|
||||
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, db);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, db);
|
||||
if (xmldb_db2file(h, db, &filename) < 0)
|
||||
goto done;
|
||||
if (lstat(filename, &sb) < 0)
|
||||
|
|
@ -445,7 +445,7 @@ xmldb_delete(clicon_handle h,
|
|||
char *filename = NULL;
|
||||
struct stat sb;
|
||||
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, db);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, db);
|
||||
if (xmldb_clear(h, db) < 0)
|
||||
goto done;
|
||||
if (xmldb_db2file(h, db, &filename) < 0)
|
||||
|
|
@ -478,7 +478,7 @@ xmldb_create(clicon_handle h,
|
|||
db_elmnt *de = NULL;
|
||||
cxobj *xt = NULL;
|
||||
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, db);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, db);
|
||||
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
||||
if ((xt = de->de_xml) != NULL){
|
||||
xml_free(xt);
|
||||
|
|
|
|||
|
|
@ -994,16 +994,11 @@ xmldb_get_cache(clicon_handle h,
|
|||
if (disable_nacm_on_empty(x1t, yspec) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* Copy the matching parts of the (relevant) XML tree.
|
||||
* If cache was empty, also update to datastore cache
|
||||
*/
|
||||
if (clicon_debug_get()>1)
|
||||
if (clixon_xml2file(stderr, x1t, 0, 1, fprintf, 0, 0) < 0)
|
||||
goto done;
|
||||
clicon_debug_xml(CLIXON_DBG_DETAIL, x1t, "%s", __FUNCTION__);
|
||||
*xtop = x1t;
|
||||
retval = 1;
|
||||
done:
|
||||
clicon_debug(2, "%s retval:%d", __FUNCTION__, retval);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s retval:%d", __FUNCTION__, retval);
|
||||
if (xvec)
|
||||
free(xvec);
|
||||
return retval;
|
||||
|
|
@ -1154,7 +1149,7 @@ xmldb_get_zerocopy(clicon_handle h,
|
|||
*xtop = x0t;
|
||||
retval = 1;
|
||||
done:
|
||||
clicon_debug(2, "%s retval:%d", __FUNCTION__, retval);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s retval:%d", __FUNCTION__, retval);
|
||||
if (xvec)
|
||||
free(xvec);
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ clixon_event_reg_fd(int fd,
|
|||
e->e_type = EVENT_FD;
|
||||
e->e_next = ee;
|
||||
ee = e;
|
||||
clicon_debug(2, "%s, registering %s", __FUNCTION__, e->e_string);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s, registering %s", __FUNCTION__, e->e_string);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ clixon_event_reg_timeout(struct timeval t,
|
|||
}
|
||||
e->e_next = e1;
|
||||
*e_prev = e;
|
||||
clicon_debug(2, "%s: %s", __FUNCTION__, str);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: %s", __FUNCTION__, str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ clixon_event_loop(clicon_handle h)
|
|||
if (n==0){ /* Timeout */
|
||||
e = ee_timers;
|
||||
ee_timers = ee_timers->e_next;
|
||||
clicon_debug(2, "%s timeout: %s", __FUNCTION__, e->e_string);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s timeout: %s", __FUNCTION__, e->e_string);
|
||||
if ((*e->e_fn)(0, e->e_arg) < 0){
|
||||
free(e);
|
||||
goto err;
|
||||
|
|
@ -428,7 +428,7 @@ clixon_event_loop(clicon_handle h)
|
|||
}
|
||||
e_next = e->e_next;
|
||||
if(e->e_type == EVENT_FD && FD_ISSET(e->e_fd, &fdset)){
|
||||
clicon_debug(2, "%s: FD_ISSET: %s", __FUNCTION__, e->e_string);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: FD_ISSET: %s", __FUNCTION__, e->e_string);
|
||||
if ((*e->e_fn)(e->e_fd, e->e_arg) < 0){
|
||||
clicon_debug(1, "%s Error in: %s", __FUNCTION__, e->e_string);
|
||||
goto err;
|
||||
|
|
|
|||
|
|
@ -126,10 +126,16 @@
|
|||
#include "clixon_path.h"
|
||||
#include "clixon_instance_id_parse.h"
|
||||
|
||||
/*
|
||||
also called from yacc generated code *
|
||||
*/
|
||||
/* Enable for debugging, steals some cycles otherwise */
|
||||
#if 0
|
||||
#define _PARSE_DEBUG(s) clicon_debug(1,(s))
|
||||
#else
|
||||
#define _PARSE_DEBUG(s)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Also called from yacc generated code *
|
||||
*/
|
||||
void
|
||||
clixon_instance_id_parseerror(void *_iy,
|
||||
char *s)
|
||||
|
|
@ -160,7 +166,7 @@ static clixon_path *
|
|||
path_append(clixon_path *list,
|
||||
clixon_path *new)
|
||||
{
|
||||
clicon_debug(2, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
ADDQ(new, list);
|
||||
|
|
@ -175,7 +181,7 @@ static clixon_path *
|
|||
path_add_keyvalue(clixon_path *cp,
|
||||
cvec *cvk)
|
||||
{
|
||||
clicon_debug(2, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (cp == NULL)
|
||||
goto done;
|
||||
cp->cp_cvk = cvk;
|
||||
|
|
@ -189,7 +195,7 @@ path_new(char *prefix,
|
|||
{
|
||||
clixon_path *cp = NULL;
|
||||
|
||||
clicon_debug(2, "%s(%s,%s)", __FUNCTION__, prefix, id);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s(%s,%s)", __FUNCTION__, prefix, id);
|
||||
if ((cp = malloc(sizeof(*cp))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "malloc");
|
||||
goto done;
|
||||
|
|
@ -219,7 +225,7 @@ keyval_pos(char *uint)
|
|||
char *reason=NULL;
|
||||
int ret;
|
||||
|
||||
clicon_debug(2, "%s(%s)", __FUNCTION__, uint);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s(%s)", __FUNCTION__, uint);
|
||||
if ((cvv = cvec_new(1)) == NULL) {
|
||||
clicon_err(OE_UNIX, errno, "cvec_new");
|
||||
goto done;
|
||||
|
|
@ -252,7 +258,7 @@ static cvec *
|
|||
keyval_add(cvec *cvv,
|
||||
cg_var *cv)
|
||||
{
|
||||
clicon_debug(2, "%s()", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s()", __FUNCTION__);
|
||||
if (cv == NULL)
|
||||
goto done;
|
||||
if (cvv == NULL &&
|
||||
|
|
@ -278,7 +284,7 @@ keyval_set(char *name,
|
|||
{
|
||||
cg_var *cv = NULL;
|
||||
|
||||
clicon_debug(2, "%s(%s=%s)", __FUNCTION__, name, val);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s(%s=%s)", __FUNCTION__, name, val);
|
||||
if ((cv = cv_new(CGV_STRING)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cv_new");
|
||||
goto done;
|
||||
|
|
@ -307,74 +313,74 @@ keyval_set(char *name,
|
|||
/*
|
||||
*/
|
||||
|
||||
start : list X_EOF { clicon_debug(3,"top"); _IY->iy_top=$1; YYACCEPT; }
|
||||
start : list X_EOF { _PARSE_DEBUG("top"); _IY->iy_top=$1; YYACCEPT; }
|
||||
;
|
||||
|
||||
list : list SLASH element { if (($$ = path_append($1, $3)) == NULL) YYABORT;
|
||||
clicon_debug(3,"list = list / element");}
|
||||
_PARSE_DEBUG("list = list / element");}
|
||||
| SLASH element { if (($$ = path_append(NULL, $2)) == NULL) YYABORT;
|
||||
clicon_debug(3,"list = / element");}
|
||||
_PARSE_DEBUG("list = / element");}
|
||||
;
|
||||
|
||||
element : node_id element2 { $$ = path_add_keyvalue($1, $2);
|
||||
clicon_debug(3,"element = node_id element2");}
|
||||
_PARSE_DEBUG("element = node_id element2");}
|
||||
;
|
||||
|
||||
node_id : IDENTIFIER { $$ = path_new(NULL, $1); free($1);
|
||||
clicon_debug(3,"node_id = IDENTIFIER");}
|
||||
_PARSE_DEBUG("node_id = IDENTIFIER");}
|
||||
| prefix COLON IDENTIFIER { $$ = path_new($1, $3); free($1); free($3);
|
||||
clicon_debug(3,"node_id = prefix : IDENTIFIER");}
|
||||
_PARSE_DEBUG("node_id = prefix : IDENTIFIER");}
|
||||
;
|
||||
|
||||
prefix : IDENTIFIER { $$=$1; clicon_debug(3,"prefix = IDENTIFIER");}
|
||||
prefix : IDENTIFIER { $$=$1; _PARSE_DEBUG("prefix = IDENTIFIER");}
|
||||
|
||||
element2 : key_preds { $$=$1; clicon_debug(3,"element2 = key_preds"); }
|
||||
| leaf_list_pred { $$=$1; clicon_debug(3,"element2 = leaf_list_pred"); }
|
||||
| pos { $$=$1; clicon_debug(3,"element2 = key_preds"); }
|
||||
| { $$=NULL; clicon_debug(3,"element2 = "); }
|
||||
element2 : key_preds { $$=$1; _PARSE_DEBUG("element2 = key_preds"); }
|
||||
| leaf_list_pred { $$=$1; _PARSE_DEBUG("element2 = leaf_list_pred"); }
|
||||
| pos { $$=$1; _PARSE_DEBUG("element2 = key_preds"); }
|
||||
| { $$=NULL; _PARSE_DEBUG("element2 = "); }
|
||||
;
|
||||
|
||||
leaf_list_pred : LSQBR leaf_list_pred_expr RSQBR
|
||||
{ if (($$ = keyval_add(NULL, $2)) == NULL) YYABORT;
|
||||
clicon_debug(3,"leaf_list_pred = [ leaf_list_pred_expr ]"); }
|
||||
_PARSE_DEBUG("leaf_list_pred = [ leaf_list_pred_expr ]"); }
|
||||
;
|
||||
|
||||
leaf_list_pred_expr : DOT EQUAL qstring { $$ = keyval_set(".", $3); free($3);
|
||||
clicon_debug(3,"leaf_list_pred_expr = '.=' qstring"); }
|
||||
_PARSE_DEBUG("leaf_list_pred_expr = '.=' qstring"); }
|
||||
;
|
||||
|
||||
pos : LSQBR UINT RSQBR { $$ = keyval_pos($2); free($2);
|
||||
clicon_debug(3,"pos = [ UINT ]"); }
|
||||
_PARSE_DEBUG("pos = [ UINT ]"); }
|
||||
;
|
||||
|
||||
key_preds : key_preds key_pred { if (($$ = keyval_add($1, $2)) == NULL) YYABORT;
|
||||
clicon_debug(3,"key_preds = key_pred key_preds"); }
|
||||
_PARSE_DEBUG("key_preds = key_pred key_preds"); }
|
||||
| key_pred { if (($$ = keyval_add(NULL, $1)) == NULL) YYABORT;
|
||||
clicon_debug(3,"key_preds = key_pred");}
|
||||
_PARSE_DEBUG("key_preds = key_pred");}
|
||||
;
|
||||
|
||||
key_pred : LSQBR key_pred_expr RSQBR { $$ = $2;
|
||||
clicon_debug(3,"key_pred = [ key_pred_expr ]"); }
|
||||
_PARSE_DEBUG("key_pred = [ key_pred_expr ]"); }
|
||||
;
|
||||
|
||||
key_pred_expr : node_id_k EQUAL qstring { $$ = keyval_set($1, $3); free($1); free($3);
|
||||
clicon_debug(3,"key_pred_expr = node_id_k = qstring"); }
|
||||
_PARSE_DEBUG("key_pred_expr = node_id_k = qstring"); }
|
||||
;
|
||||
|
||||
node_id_k : IDENTIFIER { $$ = $1;
|
||||
clicon_debug(3,"node_id_k = IDENTIFIER %s", $1); }
|
||||
_PARSE_DEBUG("node_id_k = IDENTIFIER"); }
|
||||
| prefix COLON IDENTIFIER { $$ = $3; /* ignore prefix in key? */
|
||||
clicon_debug(3,"node_id_k = prefix %s : IDENTIFIER %s", $1, $3); free($1);}
|
||||
_PARSE_DEBUG("node_id_k = prefix : IDENTIFIER"); free($1);}
|
||||
;
|
||||
|
||||
qstring : DQUOTE STRING DQUOTE { $$=$2;
|
||||
clicon_debug(3,"qstring = \" string \""); }
|
||||
_PARSE_DEBUG("qstring = \" string \""); }
|
||||
| DQUOTE DQUOTE { $$=strdup("");
|
||||
clicon_debug(3,"qstring = \" \""); }
|
||||
_PARSE_DEBUG("qstring = \" \""); }
|
||||
| SQUOTE STRING SQUOTE { $$=$2;
|
||||
clicon_debug(3,"qstring = ' string '"); }
|
||||
_PARSE_DEBUG("qstring = ' string '"); }
|
||||
| SQUOTE SQUOTE { $$=strdup("");
|
||||
clicon_debug(3,"qstring = ''"); }
|
||||
_PARSE_DEBUG("qstring = ''"); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ json_current_new(clixon_json_yacc *jy,
|
|||
char *prefix = NULL;
|
||||
char *id = NULL;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
/* Find colon separator and if found split into prefix:name */
|
||||
if (nodeid_split(name, &prefix, &id) < 0)
|
||||
goto done;
|
||||
|
|
@ -210,7 +210,7 @@ json_current_new(clixon_json_yacc *jy,
|
|||
static int
|
||||
json_current_pop(clixon_json_yacc *jy)
|
||||
{
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (jy->jy_current)
|
||||
jy->jy_current = xml_parent(jy->jy_current);
|
||||
return 0;
|
||||
|
|
@ -221,7 +221,7 @@ json_current_clone(clixon_json_yacc *jy)
|
|||
{
|
||||
cxobj *xn;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (jy->jy_current == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ json_current_body(clixon_json_yacc *jy,
|
|||
int retval = -1;
|
||||
cxobj *xn;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if ((xn = xml_new("body", jy->jy_current, CX_BODY)) == NULL)
|
||||
goto done;
|
||||
if (value && xml_value_append(xn, value) < 0)
|
||||
|
|
|
|||
|
|
@ -367,12 +367,12 @@ clicon_debug_get(void)
|
|||
* print message if level >= dbglevel.
|
||||
* The message is sent to clicon_log. EIther to syslog, stderr or both, depending on
|
||||
* clicon_log_init() setting
|
||||
* The dbgdebug level strategy is:
|
||||
* 1: Logical debug message
|
||||
* 2: Input and output packets
|
||||
* 3: Message dump in hex, xpath parse trees
|
||||
*
|
||||
* @param[in] dbglevel 0: No debug, 1-3: increasing levels of debug
|
||||
* The dbgdebug level strategy is a mask of the following masks:
|
||||
* 1: Basic debug message, espcially initialization
|
||||
* 2: Input and output packets, read datastore
|
||||
* 4: Details: message dump in hex, xpath parse trees, etc
|
||||
* See CLIXON_DBG_* flags
|
||||
* @param[in] dbglevel 0: No debug, 1-7 combined of the CLIXON_DBG_ flags above
|
||||
* @param[in] format Message to print as argv.
|
||||
* @see clicon_debug_xml Specialization for XML tree
|
||||
*/
|
||||
|
|
@ -386,7 +386,8 @@ clicon_debug(int dbglevel,
|
|||
int retval = -1;
|
||||
size_t trunc;
|
||||
|
||||
if (dbglevel > clicon_debug_get()) /* compare debug level with global variable */
|
||||
/* Mask debug level with global dbg variable */
|
||||
if ((dbglevel & clicon_debug_get()) == 0)
|
||||
return 0;
|
||||
/* first round: compute length of debug message */
|
||||
va_start(args, format);
|
||||
|
|
|
|||
|
|
@ -1589,7 +1589,9 @@ netconf_module_load(clicon_handle h)
|
|||
/* Load yang spec */
|
||||
if (yang_spec_parse_module(h, "ietf-netconf", NULL, yspec)< 0)
|
||||
goto done;
|
||||
/* Load yang Netconf stream discovery */
|
||||
/* Load yang Netconf stream discovery
|
||||
* Actually add by default since create-subscription is in this module
|
||||
*/
|
||||
if (clicon_option_bool(h, "CLICON_STREAM_DISCOVERY_RFC5277"))
|
||||
if (yang_spec_parse_module(h, "clixon-rfc5277", NULL, yspec)< 0)
|
||||
goto done;
|
||||
|
|
@ -1685,7 +1687,7 @@ netconf_db_find(cxobj *xn,
|
|||
* printf("%s", cbuf_get(cb));
|
||||
* cbuf_free(cb);
|
||||
* @endcode
|
||||
* @see clixon_netconf_error
|
||||
* @see clixon_netconf_error_fn
|
||||
*/
|
||||
int
|
||||
netconf_err2cb(cxobj *xerr,
|
||||
|
|
@ -1877,6 +1879,7 @@ netconf_hello_server(clicon_handle h,
|
|||
* @param[in] xerr Netconf error xml tree on the form: <rpc-error>
|
||||
* @param[in] format Format string
|
||||
* @param[in] arg String argument to format (optional)
|
||||
* @see netconf_err2cb
|
||||
*/
|
||||
int
|
||||
clixon_netconf_error_fn(const char *fn,
|
||||
|
|
@ -2130,8 +2133,9 @@ netconf_output(int s,
|
|||
char *buf = cbuf_get(cb);
|
||||
int len = cbuf_len(cb);
|
||||
|
||||
clicon_debug(1, "SEND %s", msg);
|
||||
if (clicon_debug_get() > 1){ /* XXX: below only works to stderr, clicon_debug may log to syslog */
|
||||
clicon_debug(CLIXON_DBG_MSG, "Send ext: %s", cbuf_get(cb));
|
||||
#if 0 // Extra sanity check for debugging
|
||||
{
|
||||
cxobj *xt = NULL;
|
||||
if (clixon_xml_parse_string(buf, YB_NONE, NULL, &xt, NULL) == 0){
|
||||
if (clixon_xml2file(stderr, xml_child_i(xt, 0), 0, 0, fprintf, 0, 0) < 0)
|
||||
|
|
@ -2140,6 +2144,7 @@ netconf_output(int s,
|
|||
xml_free(xt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (write(s, buf, len) < 0){
|
||||
if (errno == EPIPE)
|
||||
clicon_debug(1, "%s write err SIGPIPE", __FUNCTION__);
|
||||
|
|
@ -2224,7 +2229,7 @@ netconf_input_chunked_framing(char ch,
|
|||
{
|
||||
int retval = 0;
|
||||
|
||||
clicon_debug(2, "%s ch:%c(%d) state:%d size:%zu", __FUNCTION__, ch, ch, *state, *size);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s ch:%c(%d) state:%d size:%zu", __FUNCTION__, ch, ch, *state, *size);
|
||||
switch (*state){
|
||||
case 0:
|
||||
if (ch == '\n'){
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ parse_configfile_one(const char *filename,
|
|||
clicon_err(OE_UNIX, errno, "open configure file: %s", filename);
|
||||
return -1;
|
||||
}
|
||||
clicon_debug(2, "%s: Reading config file %s", __FUNCTION__, filename);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: Reading config file %s", __FUNCTION__, filename);
|
||||
if ((ret = clixon_xml_parse_file(fp, yspec?YB_MODULE:YB_NONE, yspec, &xt, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ api_path2xpath_cvv(cvec *api_path,
|
|||
nsc = NULL;
|
||||
}
|
||||
done:
|
||||
clicon_debug(2, "%s retval:%d", __FUNCTION__, retval);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s retval:%d", __FUNCTION__, retval);
|
||||
if (cberr)
|
||||
cbuf_free(cberr);
|
||||
if (valvec)
|
||||
|
|
@ -1120,7 +1120,7 @@ api_path2xml_vec(char **vec,
|
|||
ok:
|
||||
retval = 1; /* OK */
|
||||
done:
|
||||
clicon_debug(2, "%s retval:%d", __FUNCTION__, retval);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s retval:%d", __FUNCTION__, retval);
|
||||
if (cberr)
|
||||
cbuf_free(cberr);
|
||||
if (prefix)
|
||||
|
|
@ -1185,7 +1185,7 @@ api_path2xml(char *api_path,
|
|||
cxobj *xroot;
|
||||
cbuf *cberr = NULL;
|
||||
|
||||
clicon_debug(2, "%s api_path:%s", __FUNCTION__, api_path);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s api_path:%s", __FUNCTION__, api_path);
|
||||
if ((cberr = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -909,7 +909,7 @@ clixon_process_sched_register(clicon_handle h,
|
|||
struct timeval t;
|
||||
struct timeval t1 = {0, 100000}; /* 100ms */
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
gettimeofday(&t, NULL);
|
||||
if (delay)
|
||||
timeradd(&t, &t1, &t);
|
||||
|
|
@ -917,7 +917,7 @@ clixon_process_sched_register(clicon_handle h,
|
|||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
clicon_debug(2, "%s retval:%d", __FUNCTION__, retval);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s retval:%d", __FUNCTION__, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,12 +189,13 @@ clicon_msg_decode(struct clicon_msg *msg,
|
|||
char *xmlstr;
|
||||
int ret;
|
||||
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
/* hdr */
|
||||
if (id)
|
||||
*id = ntohl(msg->op_id);
|
||||
/* body */
|
||||
xmlstr = msg->op_body;
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, xmlstr);
|
||||
// XXX clicon_debug(CLIXON_DBG_MSG, "Recv: %s", xmlstr);
|
||||
if ((ret = clixon_xml_parse_string(xmlstr, yspec?YB_RPC:YB_NONE, yspec, xml, xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
|
|
@ -229,7 +230,7 @@ clicon_connect_unix(clicon_handle h,
|
|||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, sockpath, sizeof(addr.sun_path)-1);
|
||||
|
||||
clicon_debug(2, "%s: connecting to %s", __FUNCTION__, addr.sun_path);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: connecting to %s", __FUNCTION__, addr.sun_path);
|
||||
if (connect(s, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0){
|
||||
if (errno == EACCES)
|
||||
clicon_err(OE_CFG, errno, "connecting unix socket: %s. "
|
||||
|
|
@ -292,16 +293,20 @@ atomicio(ssize_t (*fn) (int, void *, size_t),
|
|||
return (pos);
|
||||
}
|
||||
|
||||
#if 0 // Extra debug
|
||||
/*! Print message on debug. Log if syslog, stderr if not
|
||||
* @param[in] msg CLICON msg
|
||||
*/
|
||||
static int
|
||||
msg_dump(struct clicon_msg *msg)
|
||||
msg_dump(int dbglevel,
|
||||
struct clicon_msg *msg)
|
||||
{
|
||||
int retval = -1;
|
||||
cbuf *cb = NULL;
|
||||
int i;
|
||||
|
||||
if ((dbglevel & clicon_debug_get()) == 0) /* compare debug level with global variable */
|
||||
goto ok;
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_CFG, errno, "cbuf_new");
|
||||
goto done;
|
||||
|
|
@ -310,7 +315,7 @@ msg_dump(struct clicon_msg *msg)
|
|||
for (i=0; i<ntohl(msg->op_len); i++){
|
||||
cprintf(cb, "%02x", ((char*)msg)[i]&0xff);
|
||||
if ((i+1)%32==0){
|
||||
clicon_debug(2, "%s", cbuf_get(cb));
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", cbuf_get(cb));
|
||||
cbuf_reset(cb);
|
||||
cprintf(cb, "%s:", __FUNCTION__);
|
||||
}
|
||||
|
|
@ -318,13 +323,15 @@ msg_dump(struct clicon_msg *msg)
|
|||
if ((i+1)%4==0)
|
||||
cprintf(cb, " ");
|
||||
}
|
||||
clicon_debug(2, "%s", cbuf_get(cb));
|
||||
clicon_debug(dbglevel, "%s", cbuf_get(cb));
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! Send a CLICON netconf message using internal IPC message
|
||||
*
|
||||
|
|
@ -339,10 +346,12 @@ clicon_msg_send(int s,
|
|||
int retval = -1;
|
||||
int e;
|
||||
|
||||
clicon_debug(2, "%s: send msg len=%d",
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: send msg len=%d",
|
||||
__FUNCTION__, ntohl(msg->op_len));
|
||||
if (clicon_debug_get() > 2)
|
||||
msg_dump(msg);
|
||||
#if 0 // Extra debug
|
||||
msg_dump(CLIXON_DBG_EXTRA, msg);
|
||||
#endif
|
||||
clicon_debug(CLIXON_DBG_MSG, "Send: %s", msg->op_body);
|
||||
if (atomicio((ssize_t (*)(int, void *, size_t))write,
|
||||
s, msg, ntohl(msg->op_len)) < 0){
|
||||
e = errno;
|
||||
|
|
@ -384,6 +393,7 @@ clicon_msg_rcv(int s,
|
|||
sigfn_t oldhandler;
|
||||
uint32_t mlen;
|
||||
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
*eof = 0;
|
||||
if (0)
|
||||
set_signal(SIGINT, atomicio_sig_handler, &oldhandler);
|
||||
|
|
@ -402,7 +412,7 @@ clicon_msg_rcv(int s,
|
|||
goto done;
|
||||
}
|
||||
mlen = ntohl(hdr.op_len);
|
||||
clicon_debug(2, "%s: rcv msg len=%d",
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: rcv msg len=%d",
|
||||
__FUNCTION__, mlen);
|
||||
if ((*msg = (struct clicon_msg *)malloc(mlen)) == NULL){
|
||||
clicon_err(OE_CFG, errno, "malloc");
|
||||
|
|
@ -417,8 +427,10 @@ clicon_msg_rcv(int s,
|
|||
clicon_err(OE_CFG, errno, "body too short");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_debug_get() > 2)
|
||||
msg_dump(*msg);
|
||||
#if 0 // Extra debug
|
||||
msg_dump(CLIXON_DBG_EXTRA, *msg);
|
||||
#endif
|
||||
clicon_debug(CLIXON_DBG_MSG, "Recv: %s", (*msg)->op_body);
|
||||
retval = 0;
|
||||
done:
|
||||
if (0)
|
||||
|
|
@ -447,7 +459,7 @@ clicon_msg_rcv1(int s,
|
|||
int xml_state = 0;
|
||||
int poll;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
*eof = 0;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
while (1){
|
||||
|
|
@ -484,6 +496,7 @@ clicon_msg_rcv1(int s,
|
|||
break; /* No data to read */
|
||||
} /* while */
|
||||
ok:
|
||||
clicon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
|
||||
retval = 0;
|
||||
done:
|
||||
clicon_debug(1, "%s done", __FUNCTION__);
|
||||
|
|
@ -502,6 +515,8 @@ clicon_msg_send1(int s,
|
|||
{
|
||||
int retval = -1;
|
||||
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
|
||||
if (atomicio((ssize_t (*)(int, void *, size_t))write,
|
||||
s, cbuf_get(cb), cbuf_len(cb)) < 0){
|
||||
clicon_err(OE_CFG, errno, "atomicio");
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ clicon_rpc_msg(clicon_handle h,
|
|||
#ifdef RPC_USERNAME_ASSERT
|
||||
assert(strstr(msg->op_body, "username")!=NULL); /* XXX */
|
||||
#endif
|
||||
clicon_debug(2, "%s request:%s", __FUNCTION__, msg->op_body);
|
||||
/* Create a socket and connect to it, either UNIX, IPv4 or IPv6 per config options */
|
||||
if (clicon_rpc_msg_once(h, msg, &retdata, &eof, &s) < 0)
|
||||
goto done;
|
||||
|
|
@ -232,7 +231,6 @@ clicon_rpc_msg(clicon_handle h,
|
|||
goto done;
|
||||
#endif
|
||||
}
|
||||
clicon_debug(2, "%s retdata:%s", __FUNCTION__, retdata);
|
||||
|
||||
if (retdata){
|
||||
/* Cannot populate xret here because need to know RPC name (eg "lock") in order to associate yang
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ stream_timer_setup(int fd,
|
|||
struct stream_replay *r;
|
||||
struct stream_replay *r1;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
/* Go thru callbacks and see if any have timed out, if so remove them
|
||||
* Could also be done by a separate timer.
|
||||
*/
|
||||
|
|
@ -502,7 +502,7 @@ stream_notify1(clicon_handle h,
|
|||
int retval = -1;
|
||||
struct stream_subscription *ss;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
/* Go thru all subscriptions and find matches */
|
||||
if ((ss = es->es_subscription) != NULL)
|
||||
do {
|
||||
|
|
@ -557,7 +557,7 @@ stream_notify(clicon_handle h,
|
|||
struct timeval tv;
|
||||
event_stream_t *es;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if ((es = stream_find(h, stream)) == NULL)
|
||||
goto ok;
|
||||
va_start(args, event);
|
||||
|
|
@ -633,7 +633,7 @@ stream_notify_xml(clicon_handle h,
|
|||
struct timeval tv;
|
||||
event_stream_t *es;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if ((es = stream_find(h, stream)) == NULL)
|
||||
goto ok;
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
|
|
|
|||
|
|
@ -2436,7 +2436,7 @@ clicon_log_xml(int level,
|
|||
* @param[in] x XML tree that is logged without prettyprint
|
||||
* @param[in] format Message to print as argv.
|
||||
* @see clicon_log_xml For syslog
|
||||
* @see clicon_debug base function
|
||||
* @see clicon_debug base function and see CLIXON_DBG_* flags
|
||||
*/
|
||||
int
|
||||
clicon_debug_xml(int dbglevel,
|
||||
|
|
@ -2450,7 +2450,8 @@ clicon_debug_xml(int dbglevel,
|
|||
int retval = -1;
|
||||
size_t trunc;
|
||||
|
||||
if (dbglevel > clicon_debug_get()) /* compare debug level with global variable */
|
||||
/* Mask debug level with global dbg variable */
|
||||
if ((dbglevel & clicon_debug_get()) == 0)
|
||||
return 0;
|
||||
/* Print xml as cbuf */
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ _xml_parse(const char *str,
|
|||
int failed = 0; /* yang assignment */
|
||||
int i;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (strlen(str) == 0){
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ xml2cvec(cxobj *xt,
|
|||
}
|
||||
}
|
||||
if (clicon_debug_get() > 1){
|
||||
clicon_debug(2, "%s cvv:\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s cvv:\n", __FUNCTION__);
|
||||
cvec_print(stderr, cvv);
|
||||
}
|
||||
*cvv0 = cvv;
|
||||
|
|
@ -825,6 +825,14 @@ xml2xpath1(cxobj *x,
|
|||
* @param[out] xpath Malloced xpath string. Need to free() after use
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error. (eg XML malformed)
|
||||
* @code
|
||||
* char *xpath = NULL;
|
||||
* cxobj *x;
|
||||
* ... x is inside an xml tree ...
|
||||
* if (xml2xpath(x, nsc, &xpath) < 0)
|
||||
* err;
|
||||
* free(xpath);
|
||||
* @endcode
|
||||
* @note x needs to be bound to YANG, see eg xml_bind_yang()
|
||||
*/
|
||||
int
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
|
||||
/* Enable for debugging, steals some cycles otherwise */
|
||||
#if 0
|
||||
#define _PARSE_DEBUG(s) clicon_debug(3,(s))
|
||||
#define _PARSE_DEBUG(s) clicon_debug(1,(s))
|
||||
#else
|
||||
#define _PARSE_DEBUG(s)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ xml_cmp(cxobj *x1,
|
|||
break;
|
||||
} /* switch */
|
||||
done:
|
||||
clicon_debug(3, "%s %s %s eq:%d nr: %d %d yi: %d %d", __FUNCTION__, xml_name(x1), xml_name(x2), equal, nr1, nr2, yi1, yi2);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s %s eq:%d nr: %d %d yi: %d %d", __FUNCTION__, xml_name(x1), xml_name(x2), equal, nr1, nr2, yi1, yi2);
|
||||
return equal;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ xpath_tree_eq(xpath_tree *xt1, /* pattern */
|
|||
(xt2->xs_type == XP_PRIME_NR || xt2->xs_type == XP_PRIME_STR))
|
||||
#endif
|
||||
){
|
||||
clicon_debug(2, "%s type %s vs %s\n", __FUNCTION__,
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s type %s vs %s\n", __FUNCTION__,
|
||||
xpath_tree_int2str(xt1->xs_type),
|
||||
xpath_tree_int2str(xt2->xs_type));
|
||||
goto neq;
|
||||
|
|
@ -405,19 +405,19 @@ xpath_tree_eq(xpath_tree *xt1, /* pattern */
|
|||
goto eq;
|
||||
}
|
||||
if (xt1->xs_int != xt2->xs_int){
|
||||
clicon_debug(2, "%s int\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s int\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
if (xt1->xs_double != xt2->xs_double){
|
||||
clicon_debug(2, "%s double\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s double\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
if (clicon_strcmp(xt1->xs_s0, xt2->xs_s0)){
|
||||
clicon_debug(2, "%s s0\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s s0\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
if (clicon_strcmp(xt1->xs_s1, xt2->xs_s1)){
|
||||
clicon_debug(2, "%s s1\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s s1\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
xc1 = xt1->xs_c0;
|
||||
|
|
@ -426,7 +426,7 @@ xpath_tree_eq(xpath_tree *xt1, /* pattern */
|
|||
;
|
||||
else{
|
||||
if (xc1 == NULL || xc2 == NULL){
|
||||
clicon_debug(2, "%s NULL\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s NULL\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
if ((ret = xpath_tree_eq(xc1, xc2, vec, len)) < 0)
|
||||
|
|
@ -440,7 +440,7 @@ xpath_tree_eq(xpath_tree *xt1, /* pattern */
|
|||
;
|
||||
else{
|
||||
if (xc1 == NULL || xc2 == NULL){
|
||||
clicon_debug(2, "%s NULL\n", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s NULL\n", __FUNCTION__);
|
||||
goto neq;
|
||||
}
|
||||
if ((ret = xpath_tree_eq(xc1, xc2, vec, len)) < 0)
|
||||
|
|
@ -531,7 +531,7 @@ xpath_parse(const char *xpath,
|
|||
clixon_xpath_yacc xpy = {0,};
|
||||
cbuf *cb = NULL;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (xpath == NULL){
|
||||
clicon_err(OE_XML, EINVAL, "XPath is NULL");
|
||||
goto done;
|
||||
|
|
@ -556,7 +556,7 @@ xpath_parse(const char *xpath,
|
|||
goto done;
|
||||
}
|
||||
xpath_tree_print_cb(cb, xpy.xpy_top);
|
||||
clicon_debug(3, "xpath parse tree:\n%s", cbuf_get(cb));
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "xpath parse tree:\n%s", cbuf_get(cb));
|
||||
}
|
||||
xpath_parse_exit(&xpy);
|
||||
xpath_scan_exit(&xpy);
|
||||
|
|
@ -602,7 +602,7 @@ xpath_vec_ctx(cxobj *xcur,
|
|||
xpath_tree *xptree = NULL;
|
||||
xp_ctx xc = {0,};
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (xpath_parse(xpath, &xptree) < 0)
|
||||
goto done;
|
||||
xc.xc_type = XT_NODESET;
|
||||
|
|
@ -1082,7 +1082,7 @@ xpath2canonical(const char *xpath0,
|
|||
cbuf *xcb = NULL;
|
||||
int ret;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
/* Parse input xpath into an xpath-tree */
|
||||
if (xpath_parse(xpath0, &xpt) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ nodetest_recursive(cxobj *xn,
|
|||
xsub = NULL;
|
||||
while ((xsub = xml_child_each(xn, xsub, node_type)) != NULL) {
|
||||
if (nodetest_eval(xsub, nodetest, nsc, localonly) == 1){
|
||||
clicon_debug(2, "%s %x %x", __FUNCTION__, flags, xml_flag(xsub, flags));
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %x %x", __FUNCTION__, flags, xml_flag(xsub, flags));
|
||||
if (flags==0x0 || xml_flag(xsub, flags))
|
||||
if (cxvec_append(xsub, &vec, &veclen) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ yang_path_arg(yang_stmt *ys,
|
|||
xp_yang_ctx *xyr = NULL;
|
||||
xp_yang_ctx *xy = NULL;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (path_arg == NULL){
|
||||
clicon_err(OE_XML, EINVAL, "path-arg is NULL");
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -1014,7 +1014,6 @@ yn_each(yang_stmt *yparent,
|
|||
return NULL;
|
||||
for (i=yprev?yprev->_ys_vector_i+1:0; i<yparent->ys_len; i++){
|
||||
if ((yc = yparent->ys_stmt[i]) == NULL){
|
||||
assert(yc); /* XXX Check if happens */
|
||||
continue;
|
||||
}
|
||||
/* make room for other conditionals */
|
||||
|
|
@ -1366,7 +1365,7 @@ yang_find_prefix_by_namespace(yang_stmt *ys,
|
|||
yang_stmt *yimport;
|
||||
yang_stmt *yprefix;
|
||||
|
||||
clicon_debug(2, "%s", __FUNCTION__);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (prefix == NULL){
|
||||
clicon_err(OE_YANG, EINVAL, "prefix is NULL");
|
||||
goto done;
|
||||
|
|
@ -2957,7 +2956,7 @@ yang_features(clicon_handle h,
|
|||
ret = 0;
|
||||
if (yang_subparse(yang_argument_get(ys), ys, YA_IF_FEATURE, mainfile, 1, &ret) < 0)
|
||||
goto done;
|
||||
clicon_debug(2, "%s %s %d", __FUNCTION__, yang_argument_get(ys), ret);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s %d", __FUNCTION__, yang_argument_get(ys), ret);
|
||||
if (ret == 0)
|
||||
goto disabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ yang_augment_node(clicon_handle h,
|
|||
}
|
||||
/* */
|
||||
schema_nodeid = yang_argument_get(ys);
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, schema_nodeid);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, schema_nodeid);
|
||||
/* Find the target */
|
||||
if (yang_abs_schema_nodeid(ys, schema_nodeid, &ytarget) < 0)
|
||||
goto done;
|
||||
|
|
@ -881,7 +881,7 @@ filename2revision(const char *filename,
|
|||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, base);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, base);
|
||||
if ((p = rindex(base, '.')) != NULL) /* strip postfix .yang */
|
||||
*p = '\0';
|
||||
if ((p = index(base, '@')) != NULL){ /* extract revision date */
|
||||
|
|
@ -904,19 +904,17 @@ filename2revision(const char *filename,
|
|||
* @param[in] h CLICON handle
|
||||
* @param[in] module Name of main YANG module.
|
||||
* @param[in] revision Revision or NULL
|
||||
* @param[out] revactual Actual revision (if retval=1)
|
||||
* @param[out] fbuf Buffer containing filename (if retval=1)
|
||||
* @retval 1 Match found, Most recent entry returned in fbuf and revactual
|
||||
* @param[out] fbuf Buffer containing filename or NULL (if retval=1)
|
||||
* @retval 1 Match found, Most recent entry returned in fbuf
|
||||
* @retval 0 No matching entry found
|
||||
* @retval -1 Error
|
||||
* @note for bootstrapping, dir may have to be set.
|
||||
*/
|
||||
static int
|
||||
yang_parse_find_match(clicon_handle h,
|
||||
const char *module,
|
||||
const char *revision,
|
||||
uint32_t *revactual,
|
||||
cbuf *fbuf)
|
||||
int
|
||||
yang_file_find_match(clicon_handle h,
|
||||
const char *module,
|
||||
const char *revision,
|
||||
cbuf *fbuf)
|
||||
{
|
||||
int retval = -1;
|
||||
cbuf *regex = NULL;
|
||||
|
|
@ -960,7 +958,8 @@ yang_parse_find_match(clicon_handle h,
|
|||
/* Entries are sorted, last entry should be most recent date
|
||||
*/
|
||||
if (ndp != 0){
|
||||
cprintf(fbuf, "%s/%s", dir, dp[ndp-1].d_name);
|
||||
if (fbuf)
|
||||
cprintf(fbuf, "%s/%s", dir, dp[ndp-1].d_name);
|
||||
if (dp)
|
||||
free(dp);
|
||||
retval = 1;
|
||||
|
|
@ -990,7 +989,8 @@ yang_parse_find_match(clicon_handle h,
|
|||
bestcv = cv;
|
||||
}
|
||||
if (bestcv){
|
||||
cprintf(fbuf, "%s", cv_string_get(bestcv)); /* file path */
|
||||
if (fbuf)
|
||||
cprintf(fbuf, "%s", cv_string_get(bestcv)); /* file path */
|
||||
retval = 1; /* found */
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1080,7 +1080,7 @@ yang_parse_module(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
/* Match a yang file with or without revision in yang-dir list */
|
||||
if ((nr = yang_parse_find_match(h, module, revision, &revf, fbuf)) < 0)
|
||||
if ((nr = yang_file_find_match(h, module, revision, fbuf)) < 0)
|
||||
goto done;
|
||||
if (nr == 0){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ yang_subparse(char *str,
|
|||
int retval = -1;
|
||||
clixon_yang_sub_parse_yacc ife = {0,};
|
||||
|
||||
clicon_debug(2, "%s %s", __FUNCTION__, str);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, str);
|
||||
ife.if_parse_string = str;
|
||||
ife.if_linenum = linenum;
|
||||
if (enabled)
|
||||
|
|
@ -120,7 +120,7 @@ yang_schema_nodeid_subparse(char *str,
|
|||
int retval = -1;
|
||||
clixon_yang_schemanode_yacc ife = {0,};
|
||||
|
||||
clicon_debug(3, "%s %s", __FUNCTION__, str);
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s", __FUNCTION__, str);
|
||||
ife.if_parse_string = str;
|
||||
ife.if_linenum = linenum;
|
||||
ife.if_mainfile = mainfile;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue