C-style update: Unified comment, retvals in order, remove trailing spaces
Changed function name for `clicon_debug` functions
This commit is contained in:
parent
6e314dd96f
commit
62348fc9c7
204 changed files with 6047 additions and 4904 deletions
|
|
@ -122,8 +122,8 @@ You can see which CLISPEC it generates via clixon_cli -D 2:
|
|||
* @note XXX only fraction_digits handled,should also have mincv, maxcv, pattern
|
||||
*/
|
||||
static int
|
||||
cli_expand_var_generate(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
cli_expand_var_generate(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
const char *cvtypestr,
|
||||
int options,
|
||||
uint8_t fraction_digits,
|
||||
|
|
@ -135,12 +135,12 @@ cli_expand_var_generate(clicon_handle h,
|
|||
int extvalue = 0;
|
||||
yang_stmt *yspec;
|
||||
cg_var *cv = NULL;
|
||||
|
||||
|
||||
if ((yspec = ys_spec(ys)) != NULL)
|
||||
cv = yang_cv_get(yspec);
|
||||
if (yang_extension_value(ys, "hide", CLIXON_AUTOCLI_NS, &extvalue, NULL) < 0)
|
||||
goto done;
|
||||
if (extvalue || yang_find(ys, Y_STATUS, "deprecated") != NULL)
|
||||
if (extvalue || yang_find(ys, Y_STATUS, "deprecated") != NULL)
|
||||
goto hide;
|
||||
if (yang2api_path_fmt(ys, 1, &api_path_fmt) < 0)
|
||||
goto done;
|
||||
|
|
@ -167,15 +167,18 @@ cli_expand_var_generate(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Create callback with api_path format string as argument
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys yang_stmt of the node at hand
|
||||
* @param[out] cb The string where the result format string is inserted.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see cli_dbxml This is where the xmlkeyfmt string is used
|
||||
* @see pt_callback_reference in CLIgen where the actual callback overwrites the template
|
||||
*/
|
||||
static int
|
||||
cli_callback_generate(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
cli_callback_generate(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -200,6 +203,7 @@ cli_callback_generate(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Print cligen help string as ("<helpstring>")
|
||||
*
|
||||
* @param[in] cb CLIgen buf holding generated CLIspec
|
||||
* @param[in] helptext Help text
|
||||
*/
|
||||
|
|
@ -243,10 +247,13 @@ yang2cli_print_alias(cbuf *cb,
|
|||
}
|
||||
|
||||
/*! Generate identityref statements for CLI variables
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] ytype Resolved yang type.
|
||||
* @param[in] helptext CLI help text
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see yang2cli_var_sub Its sub-function
|
||||
*/
|
||||
static int
|
||||
|
|
@ -267,7 +274,7 @@ yang2cli_var_identityref(yang_stmt *ys,
|
|||
yang_stmt *ymod;
|
||||
yang_stmt *yprefix;
|
||||
yang_stmt *yspec;
|
||||
|
||||
|
||||
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) == NULL)
|
||||
goto ok;
|
||||
if ((ybaseid = yang_find_identity(ytype, yang_argument_get(ybaseref))) == NULL)
|
||||
|
|
@ -316,10 +323,13 @@ yang2cli_var_identityref(yang_stmt *ys,
|
|||
}
|
||||
|
||||
/*! Generate range check statements for CLI variables
|
||||
*
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] options Flags field of optional values, eg YANG_OPTIONS_RANGE
|
||||
* @param[in] cvv Cvec with array of range_min/range_max cv:s (if YANG_OPTIONS_RANGE is set in options)
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see yang2cli_var_sub which is the main function
|
||||
* In yang ranges are given as range 1 or range 1 .. 16, encoded in a cvv
|
||||
* 0 : range_min = x
|
||||
|
|
@ -349,7 +359,7 @@ yang2cli_var_range(yang_stmt *ys,
|
|||
int i;
|
||||
cg_var *cv1; /* lower limit */
|
||||
cg_var *cv2; /* upper limit */
|
||||
|
||||
|
||||
/* Loop through range_min and range_min..range_max */
|
||||
i = 0;
|
||||
while (i<cvec_len(cvv)){
|
||||
|
|
@ -376,9 +386,12 @@ yang2cli_var_range(yang_stmt *ys,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang variable pattern statement
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] patterns Cvec of regexp patterns
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see cv_validate_pattern for netconf validate code
|
||||
* @note for cligen, need to escape " -> \"
|
||||
*/
|
||||
|
|
@ -387,14 +400,14 @@ yang2cli_var_pattern(clicon_handle h,
|
|||
cvec *patterns,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
int retval = -1;
|
||||
enum regexp_mode mode;
|
||||
cg_var *cvp;
|
||||
char *pattern;
|
||||
int invert;
|
||||
char *posix = NULL;
|
||||
int i;
|
||||
|
||||
cg_var *cvp;
|
||||
char *pattern;
|
||||
int invert;
|
||||
char *posix = NULL;
|
||||
int i;
|
||||
|
||||
mode = clicon_yang_regexp(h);
|
||||
cvp = NULL; /* Loop over compiled regexps */
|
||||
while ((cvp = cvec_each(patterns, cvp)) != NULL){
|
||||
|
|
@ -439,6 +452,7 @@ static int yang2cli_var_union(clicon_handle h, yang_stmt *ys, char *origtype,
|
|||
yang_stmt *ytype, char *helptext, cbuf *cb);
|
||||
|
||||
/*! Generate CLI code for Yang leaf state ment to CLIgen variable of specific type
|
||||
*
|
||||
* Check for completion (of already existent values), ranges (eg range[min:max]) and
|
||||
* patterns, (eg regexp:"[0.9]*").
|
||||
* @param[in] h Clixon handle
|
||||
|
|
@ -451,11 +465,13 @@ static int yang2cli_var_union(clicon_handle h, yang_stmt *ys, char *origtype,
|
|||
* @param[in] patterns Cvec of regexp patterns
|
||||
* @param[in] fraction for decimal64, how many digits after period
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see yang_type_resolve for options and other arguments
|
||||
*/
|
||||
static int
|
||||
yang2cli_var_sub(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ytype, /* resolved type */
|
||||
char *helptext,
|
||||
enum cv_type cvtype,
|
||||
|
|
@ -481,7 +497,6 @@ yang2cli_var_sub(clicon_handle h,
|
|||
}
|
||||
type = ytype?yang_argument_get(ytype):NULL;
|
||||
cvtypestr = cv_type2str(cvtype);
|
||||
|
||||
if (type && strcmp(type, "identityref") == 0)
|
||||
cprintf(cb, "(");
|
||||
cprintf(cb, "<%s:%s", yang_argument_get(ys), cvtypestr);
|
||||
|
|
@ -533,17 +548,20 @@ yang2cli_var_sub(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Resolve a single Yang union and generate code
|
||||
*
|
||||
* Part of generating CLI code for Yang leaf statement to CLIgen variable
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement (caller of type)
|
||||
* @param[in] origtype Name of original type in the call
|
||||
* @param[in] ytsub Yang type invocation, a sub-type of a resolved union type
|
||||
* @param[in] cb Buffer where cligen code is written
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement (caller of type)
|
||||
* @param[in] origtype Name of original type in the call
|
||||
* @param[in] ytsub Yang type invocation, a sub-type of a resolved union type
|
||||
* @param[in] cb Buffer where cligen code is written
|
||||
* @param[in] helptext CLI help text
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
yang2cli_var_union_one(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ys,
|
||||
char *origtype,
|
||||
yang_stmt *ytsub,
|
||||
char *helptext,
|
||||
|
|
@ -581,7 +599,7 @@ yang2cli_var_union_one(clicon_handle h,
|
|||
else {
|
||||
if (clicon_type2cv(origtype, restype, ys, &cvtype) < 0)
|
||||
goto done;
|
||||
if ((retval = yang2cli_var_sub(h, ys, ytype, helptext, cvtype,
|
||||
if ((retval = yang2cli_var_sub(h, ys, ytype, helptext, cvtype,
|
||||
options, cvv, patterns, fraction_digits, cb)) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -593,17 +611,20 @@ yang2cli_var_union_one(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Loop over all sub-types of a Yang union
|
||||
*
|
||||
* Part of generating CLI code for Yang leaf statement to CLIgen variable
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement (caller)
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement (caller)
|
||||
* @param[in] origtype Name of original type in the call
|
||||
* @param[in] ytype Yang resolved type (a union in this case)
|
||||
* @param[in] helptext CLI help text
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @param[in] ytype Yang resolved type (a union in this case)
|
||||
* @param[in] helptext CLI help text
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
yang2cli_var_union(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ys,
|
||||
char *origtype,
|
||||
yang_stmt *ytype,
|
||||
char *helptext,
|
||||
|
|
@ -633,7 +654,7 @@ yang2cli_var_union(clicon_handle h,
|
|||
|
||||
static int
|
||||
yang2cli_var_leafref(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *yrestype,
|
||||
char *helptext,
|
||||
enum cv_type cvtype,
|
||||
|
|
@ -669,11 +690,11 @@ yang2cli_var_leafref(clicon_handle h,
|
|||
if (completionp && regular_value)
|
||||
cprintf(cb, "(");
|
||||
if (regular_value)
|
||||
if (yang2cli_var_sub(h, ys, yrestype, helptext, cvtype,
|
||||
if (yang2cli_var_sub(h, ys, yrestype, helptext, cvtype,
|
||||
options, cvv, patterns, fraction_digits, cb) < 0)
|
||||
goto done;
|
||||
if (completionp){
|
||||
if ((ret = cli_expand_var_generate(h, ys, cvtypestr,
|
||||
if ((ret = cli_expand_var_generate(h, ys, cvtypestr,
|
||||
options, fraction_digits, regular_value,
|
||||
cb)) < 0)
|
||||
goto done;
|
||||
|
|
@ -688,11 +709,14 @@ yang2cli_var_leafref(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang leaf statement to CLIgen variable
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement of original leaf
|
||||
* @param[in] yreferred Yang statement of referred node for type (leafref)
|
||||
* @param[in] helptext CLI help text
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*
|
||||
* Make a type lookup and complete a cligen variable expression such as <a:string>.
|
||||
* One complication is yang union, that needs a recursion since it consists of
|
||||
|
|
@ -707,7 +731,7 @@ yang2cli_var_leafref(clicon_handle h,
|
|||
static int
|
||||
yang2cli_var(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *yreferred,
|
||||
yang_stmt *yreferred,
|
||||
char *helptext,
|
||||
cbuf *cb)
|
||||
{
|
||||
|
|
@ -723,12 +747,12 @@ yang2cli_var(clicon_handle h,
|
|||
int options = 0;
|
||||
int completionp;
|
||||
int ret;
|
||||
|
||||
|
||||
if ((patterns = cvec_new(0)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cvec_new");
|
||||
goto done;
|
||||
}
|
||||
if (yang_type_get(yreferred, &origtype, &yrestype,
|
||||
if (yang_type_get(yreferred, &origtype, &yrestype,
|
||||
&options, &cvv, patterns, NULL, &fraction_digits) < 0)
|
||||
goto done;
|
||||
restype = yang_argument_get(yrestype);
|
||||
|
|
@ -739,7 +763,7 @@ yang2cli_var(clicon_handle h,
|
|||
cvtypestr = cv_type2str(cvtype);
|
||||
/* Note restype can be NULL here for example with unresolved hardcoded uuid */
|
||||
|
||||
if (strcmp(restype, "union") == 0){
|
||||
if (strcmp(restype, "union") == 0){
|
||||
/* Union: loop over resolved type's sub-types (can also be recursive unions) */
|
||||
cprintf(cb, "(");
|
||||
if (yang2cli_var_union(h, ys, origtype, yrestype, helptext, cb) < 0)
|
||||
|
|
@ -747,7 +771,7 @@ yang2cli_var(clicon_handle h,
|
|||
if (autocli_completion(h, &completionp) < 0)
|
||||
goto done;
|
||||
if (completionp){
|
||||
if ((ret = cli_expand_var_generate(h, ys, cvtypestr,
|
||||
if ((ret = cli_expand_var_generate(h, ys, cvtypestr,
|
||||
options, fraction_digits, 1, cb)) < 0)
|
||||
goto done;
|
||||
if (ret == 1)
|
||||
|
|
@ -770,15 +794,15 @@ yang2cli_var(clicon_handle h,
|
|||
}
|
||||
if (yang_path_arg(yreferred, path_arg, &yref) < 0)
|
||||
goto done;
|
||||
if (yref == NULL){
|
||||
if (yref == NULL){
|
||||
/* Give up: use yreferred
|
||||
*/
|
||||
if (yang2cli_var_leafref(h, ys, yrestype, helptext, cvtype, options,
|
||||
if (yang2cli_var_leafref(h, ys, yrestype, helptext, cvtype, options,
|
||||
cvv, patterns, fraction_digits, cb) < 0)
|
||||
goto done;
|
||||
}
|
||||
else {
|
||||
if (yreferred == yref){
|
||||
if (yreferred == yref){
|
||||
clicon_err(OE_YANG, 0, "Referred YANG node for leafref path %s points to self", path_arg);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -803,26 +827,29 @@ yang2cli_var(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang leaf statement
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] level Indentation level
|
||||
* @param[in] callback If set, include a "; cli_set()" callback, otherwise not
|
||||
* @param[in] callback If set, include a "; cli_set()" callback, otherwise not
|
||||
* @param[in] key_leaf 0: ordinary leaf, 1:prekey, 2: lastkey
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* Some complexity in callback, key_leaf and extralevel logic.
|
||||
* If extralevel -> add extra { } level
|
||||
* + if callbacks add: cb();{}
|
||||
*/
|
||||
static int
|
||||
yang2cli_leaf(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang2cli_leaf(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
int callback,
|
||||
int key_leaf,
|
||||
cbuf *cb)
|
||||
{
|
||||
yang_stmt *yd; /* description */
|
||||
int retval = -1;
|
||||
yang_stmt *yd; /* description */
|
||||
char *helptext = NULL;
|
||||
char *s;
|
||||
autocli_listkw_t listkw;
|
||||
|
|
@ -841,7 +868,7 @@ yang2cli_leaf(clicon_handle h,
|
|||
}
|
||||
cprintf(cb, "%*s", level*3, "");
|
||||
/* Called a second time in yang2cli_var, room for optimization */
|
||||
if (yang_type_get(ys, NULL, &yrestype,
|
||||
if (yang_type_get(ys, NULL, &yrestype,
|
||||
NULL, NULL, NULL, NULL, NULL) < 0)
|
||||
goto done;
|
||||
if (key_leaf == 0 && strcmp(yang_argument_get(yrestype), "empty") != 0)
|
||||
|
|
@ -905,27 +932,30 @@ yang2cli_leaf(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang container statement
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] level Indentation level
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
yang2cli_container(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang2cli_container(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
yang_stmt *yc;
|
||||
yang_stmt *yd;
|
||||
int retval = -1;
|
||||
char *helptext = NULL;
|
||||
char *s;
|
||||
int compress = 0;
|
||||
yang_stmt *ymod = NULL;
|
||||
int extvalue = 0;
|
||||
int ret;
|
||||
|
||||
|
||||
if (ys_real_module(ys, &ymod) < 0)
|
||||
goto done;
|
||||
/* If non-presence container && HIDE mode && only child is
|
||||
|
|
@ -964,7 +994,7 @@ yang2cli_container(clicon_handle h,
|
|||
}
|
||||
}
|
||||
yc = NULL;
|
||||
while ((yc = yn_each(ys, yc)) != NULL)
|
||||
while ((yc = yn_each(ys, yc)) != NULL)
|
||||
if (yang2cli_stmt(h, yc, level+1, cb) < 0)
|
||||
goto done;
|
||||
if (!compress)
|
||||
|
|
@ -977,24 +1007,27 @@ yang2cli_container(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang list statement
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] level Indentation level
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
yang2cli_list(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
yang_stmt *yc;
|
||||
yang_stmt *yd;
|
||||
yang_stmt *yleaf;
|
||||
cg_var *cvi;
|
||||
char *keyname;
|
||||
cvec *cvk = NULL; /* vector of index keys */
|
||||
int retval = -1;
|
||||
char *helptext = NULL;
|
||||
char *s;
|
||||
int last_key = 0;
|
||||
|
|
@ -1023,7 +1056,7 @@ yang2cli_list(clicon_handle h,
|
|||
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
|
||||
keyname = cv_string_get(cvi);
|
||||
if ((yleaf = yang_find(ys, Y_LEAF, keyname)) == NULL){
|
||||
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
|
||||
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
|
||||
yang_argument_get(ys), keyname);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1066,7 +1099,7 @@ yang2cli_list(clicon_handle h,
|
|||
}
|
||||
cprintf(cb, "%*s}\n", level*3, "");
|
||||
/* Close with } for each key */
|
||||
while (keynr--)
|
||||
while (keynr--)
|
||||
cprintf(cb, "%*s}\n", level*3, "");
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -1081,18 +1114,20 @@ yang2cli_list(clicon_handle h,
|
|||
* @param[in] ys Yang statement
|
||||
* @param[in] level Indentation level
|
||||
* @param[out] cb Buffer where cligen code is written
|
||||
@example
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @code
|
||||
choice interface-type {
|
||||
container ethernet { ... }
|
||||
container fddi { ... }
|
||||
}
|
||||
@example.end
|
||||
@Note Removes 'meta-syntax' from cli syntax. They are not shown when xml is
|
||||
* @code.end
|
||||
@note Removes 'meta-syntax' from cli syntax. They are not shown when xml is
|
||||
translated to cli. and therefore input-syntax != output syntax. Which is bad
|
||||
*/
|
||||
static int
|
||||
yang2cli_choice(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
yang2cli_choice(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
cbuf *cb)
|
||||
{
|
||||
|
|
@ -1206,6 +1241,7 @@ yang2cli_uses(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Generate CLI code for Yang statement
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] ys Yang statement
|
||||
* @param[in] level Indentation level
|
||||
|
|
@ -1214,9 +1250,9 @@ yang2cli_uses(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
yang2cli_stmt(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
yang2cli_stmt(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
int level,
|
||||
cbuf *cb)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -1230,11 +1266,11 @@ yang2cli_stmt(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
|
||||
clicon_debug(4, "%s obsolete: %s %s, skipped", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s obsolete: %s %s, skipped", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
goto ok;
|
||||
}
|
||||
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
|
||||
clicon_debug(4, "%s deprecated: %s %s", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s deprecated: %s %s", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
}
|
||||
/* Check if autocli skip */
|
||||
if (yang_extension_value(ys, "skip", CLIXON_AUTOCLI_NS, &extvalue, NULL) < 0)
|
||||
|
|
@ -1252,7 +1288,7 @@ yang2cli_stmt(clicon_handle h,
|
|||
#ifdef AUTOCLI_GROUPING_TOPLEVEL_SKIP
|
||||
cornercase = yang_keyword_get(yang_parent_get(ys)) == Y_MODULE || yang_keyword_get(yang_parent_get(ys)) == Y_SUBMODULE;
|
||||
#endif
|
||||
if (yang_keyword_get(ys) != Y_USES && yang_flag_get(ys, YANG_FLAG_GROUPING)
|
||||
if (yang_keyword_get(ys) != Y_USES && yang_flag_get(ys, YANG_FLAG_GROUPING)
|
||||
&& !cornercase
|
||||
)
|
||||
goto ok;
|
||||
|
|
@ -1301,6 +1337,7 @@ yang2cli_stmt(clicon_handle h,
|
|||
}
|
||||
|
||||
/*! Add cv with name to cvec
|
||||
*
|
||||
* @param[in] cvv Either existing or NULL
|
||||
* @param[in] name Name of cv to add
|
||||
* @retval cvv Either same as in cvv parameter or new
|
||||
|
|
@ -1310,7 +1347,7 @@ cvec_add_name(cvec *cvv,
|
|||
char *name)
|
||||
{
|
||||
cg_var *cv= NULL;
|
||||
|
||||
|
||||
if (cvv == NULL &&
|
||||
(cvv = cvec_new(0)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cvec_new");
|
||||
|
|
@ -1382,7 +1419,7 @@ yang2cli_post(clicon_handle h,
|
|||
char *name;
|
||||
cg_var *cv = NULL;
|
||||
int j=0;
|
||||
|
||||
|
||||
cv = NULL;
|
||||
while ((cv = cvec_each(cop->co_cvec, cv)) != NULL){
|
||||
name = cv_name_get(cv);
|
||||
|
|
@ -1480,7 +1517,7 @@ yang2cli_post(clicon_handle h,
|
|||
* XXX merge with yang2cli_yspec
|
||||
*/
|
||||
static int
|
||||
yang2cli_grouping(clicon_handle h,
|
||||
yang2cli_grouping(clicon_handle h,
|
||||
yang_stmt *ys,
|
||||
char *treename)
|
||||
{
|
||||
|
|
@ -1495,7 +1532,7 @@ yang2cli_grouping(clicon_handle h,
|
|||
cg_obj *co;
|
||||
int config;
|
||||
int i;
|
||||
|
||||
|
||||
if ((pt0 = pt_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "pt_new");
|
||||
goto done;
|
||||
|
|
@ -1506,11 +1543,11 @@ yang2cli_grouping(clicon_handle h,
|
|||
}
|
||||
/* Traverse YANG, loop through all modules and generate CLI, inline of yang2cli_stmt */
|
||||
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
|
||||
clicon_debug(4, "%s obsolete: %s %s, skipped", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s obsolete: %s %s, skipped", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
goto empty;
|
||||
}
|
||||
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
|
||||
clicon_debug(4, "%s deprecated: %s %s", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s deprecated: %s %s", __FUNCTION__, yang_argument_get(ys), yang_argument_get(ys_module(ys)));
|
||||
}
|
||||
/* Only produce autocli for YANG non-config only if autocli-treeref-state is true */
|
||||
if (autocli_treeref_state(h, &treeref_state) < 0)
|
||||
|
|
@ -1539,12 +1576,12 @@ yang2cli_grouping(clicon_handle h,
|
|||
fprintf(stderr, "%s\n", cbuf_get(cb));
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(CLIXON_DBG_DEFAULT, "%s Generated auto-cli for grouping:%s",
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s Generated auto-cli for grouping:%s",
|
||||
__FUNCTION__, yang_argument_get(ys));
|
||||
/* Add prefix: assume new are appended */
|
||||
for (i=0; i<pt_len_get(pt); i++){
|
||||
if ((co = pt_vec_i_get(pt, i)) != NULL){
|
||||
clicon_debug(CLIXON_DBG_DEFAULT, "%s command: %s",
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s command: %s",
|
||||
__FUNCTION__, co->co_command);
|
||||
co_prefix_set(co, prefix);
|
||||
}
|
||||
|
|
@ -1562,7 +1599,7 @@ yang2cli_grouping(clicon_handle h,
|
|||
clicon_log(LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
|
||||
__FUNCTION__, treename, cbuf_get(cb));
|
||||
else
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: Top-level cli-spec %s:\n%s",
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s: Top-level cli-spec %s:\n%s",
|
||||
__FUNCTION__, treename, cbuf_get(cb));
|
||||
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
|
||||
clicon_err(OE_YANG, errno, "cligen_parsetree_merge");
|
||||
|
|
@ -1614,7 +1651,7 @@ yang2cli_grouping(clicon_handle h,
|
|||
* @note Tie-break of same top-level symbol: prefix is NYI
|
||||
*/
|
||||
int
|
||||
yang2cli_yspec(clicon_handle h,
|
||||
yang2cli_yspec(clicon_handle h,
|
||||
yang_stmt *yspec,
|
||||
char *treename)
|
||||
{
|
||||
|
|
@ -1629,7 +1666,7 @@ yang2cli_yspec(clicon_handle h,
|
|||
cg_obj *co;
|
||||
int i;
|
||||
int config;
|
||||
|
||||
|
||||
if ((pt0 = pt_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "pt_new");
|
||||
goto done;
|
||||
|
|
@ -1669,12 +1706,12 @@ yang2cli_yspec(clicon_handle h,
|
|||
fprintf(stderr, "%s\n", cbuf_get(cb));
|
||||
goto done;
|
||||
}
|
||||
clicon_debug(CLIXON_DBG_DEFAULT, "%s Generated auto-cli for module:%s",
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s Generated auto-cli for module:%s",
|
||||
__FUNCTION__, yang_argument_get(ymod));
|
||||
/* Add prefix: assume new are appended */
|
||||
for (i=0; i<pt_len_get(pt); i++){
|
||||
if ((co = pt_vec_i_get(pt, i)) != NULL){
|
||||
clicon_debug(CLIXON_DBG_DEFAULT, "%s command: %s",
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s command: %s",
|
||||
__FUNCTION__, co->co_command);
|
||||
co_prefix_set(co, prefix);
|
||||
}
|
||||
|
|
@ -1693,7 +1730,7 @@ yang2cli_yspec(clicon_handle h,
|
|||
clicon_log(LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
|
||||
__FUNCTION__, treename, cbuf_get(cb));
|
||||
else
|
||||
clicon_debug(CLIXON_DBG_DETAIL, "%s: Top-level cli-spec %s:\n%s",
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s: Top-level cli-spec %s:\n%s",
|
||||
__FUNCTION__, treename, cbuf_get(cb));
|
||||
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
|
||||
clicon_err(OE_YANG, errno, "cligen_parsetree_merge");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue