Merge branch 'master' into feature_openconfig_compress

This commit is contained in:
Olof Hagsand 2021-10-22 09:23:48 +02:00 committed by GitHub
commit 9d8d9ac042
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 997 additions and 139 deletions

View file

@ -3553,15 +3553,20 @@ yang_anydata_add(yang_stmt *yp,
return ys;
}
/*! Find extension argument and return extension argument value
/*! Find extension argument and return if extension exists and its argument value
*
* @param[in] ys Yang statement
* @param[in] name Name of the extension
* @param[in] ns The namespace
* @param[out] exist The extension exists.
* @param[out] value clispec operator (hide/none) - direct pointer into yang, dont free
* @retval 0 OK: Look in exist and value for return value
* @retval -1 Error
* This is for extensions with an argument
* @code
* char *value = NULL;
* if (yang_extension_value(ys, "mymode", "urn:example:lib", &value) < 0)
* int exist = 0;
* if (yang_extension_value(ys, "mymode", "urn:example:lib", &exist, &value) < 0)
* err;
* if (value != NULL){
* // use extension value
@ -3572,6 +3577,7 @@ int
yang_extension_value(yang_stmt *ys,
char *name,
char *ns,
int *exist,
char **value)
{
int retval = -1;
@ -3585,7 +3591,7 @@ yang_extension_value(yang_stmt *ys,
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
yext = NULL; /* This loop gets complicated in trhe case the extension is augmented */
yext = NULL; /* This loop gets complicated in the case the extension is augmented */
while ((yext = yn_each(ys, yext)) != NULL) {
if (yang_keyword_get(yext) != Y_UNKNOWN)
continue;
@ -3593,15 +3599,17 @@ yang_extension_value(yang_stmt *ys,
continue;
if (yang_find_prefix_by_namespace(ymod, ns, &prefix) < 0)
goto ok;
cbuf_reset(cb);
cprintf(cb, "%s:%s", prefix, name);
if (strcmp(yang_argument_get(yext), cbuf_get(cb)) != 0)
continue;
break;
}
if (yext != NULL){ /* Found */
if ((cv = yang_cv_get(yext)) == NULL)
goto ok;
if (value)
if (exist)
*exist = 1;
if (value &&
(cv = yang_cv_get(yext)) != NULL)
*value = cv_string_get(cv);
}
ok: