* Added experimental binary search API function: xml_binsearch

* Added content parameter to `clicon_rpc_get` (-1 or CONTENT_ALL is default)
* Reverted change in clixon-lib.yang
This commit is contained in:
Olof hagsand 2019-08-14 11:13:24 +02:00
parent 8b7b7b0f60
commit 10a2dbe8ec
17 changed files with 137 additions and 250 deletions

View file

@ -153,16 +153,6 @@ static const map_str2int http_media_map[] = {
{NULL, -1}
};
/* See RFC 8040 4.8.1
* @see query_content_str2int
*/
static const map_str2int query_content_map[] = {
{"config", CONTENT_CONFIG},
{"nonconfig", CONTENT_NONCONFIG},
{"all", CONTENT_ALL},
{NULL, -1}
};
int
restconf_err2code(char *tag)
{
@ -187,18 +177,6 @@ restconf_media_int2str(restconf_media media)
return clicon_int2str(http_media_map, media);
}
const query_content
query_content_str2int(char *str)
{
return clicon_str2int(query_content_map, str);
}
const char *
query_content_int2str(query_content nr)
{
return clicon_int2str(query_content_map, nr);
}
/*! Return media_in from Content-Type, -1 if not found or unrecognized
* @note media-type syntax does not support parameters
* @see RFC7231 Sec 3.1.1.1 for media-type syntax type:

View file

@ -57,16 +57,6 @@ enum restconf_media{
};
typedef enum restconf_media restconf_media;
/*! Content query parameter RFC 8040 Sec 4.8.1
*/
enum query_content{
CONTENT_CONFIG,
CONTENT_NONCONFIG,
CONTENT_ALL /* default */
};
typedef enum query_content query_content;
/*
* Prototypes (also in clixon_restconf.h)
*/
@ -76,8 +66,6 @@ const char *restconf_code2reason(int code);
const restconf_media restconf_media_str2int(char *media);
const char *restconf_media_int2str(restconf_media media);
restconf_media restconf_content_type(FCGX_Request *r);
const query_content query_content_str2int(char *str);
const char *query_content_int2str(query_content nr);
int restconf_badrequest(FCGX_Request *r);
int restconf_unauthorized(FCGX_Request *r);
int restconf_forbidden(FCGX_Request *r);

View file

@ -115,7 +115,7 @@ api_data_get2(clicon_handle h,
char *namespace = NULL;
cvec *nsc = NULL;
char *str;
query_content content = CONTENT_ALL;
netconf_content content = CONTENT_ALL;
clicon_debug(1, "%s", __FUNCTION__);
if ((yspec = clicon_dbspec_yang(h)) == NULL){
@ -125,7 +125,7 @@ api_data_get2(clicon_handle h,
/* Check for content attribute */
if ((str = cvec_find_str(qvec, "content")) != NULL){
clicon_debug(1, "%s content=%s", __FUNCTION__, str);
if ((content = query_content_str2int(str)) == -1){
if ((content = netconf_content_str2int(str)) == -1){
if (netconf_bad_attribute_xml(&xerr, "application",
"<bad-attribute>content</bad-attribute>", "Unrecognized value of content attribute") < 0)
goto done;
@ -168,10 +168,10 @@ api_data_get2(clicon_handle h,
ret = clicon_rpc_get_config(h, "running", xpath, namespace, &xret);
break;
case CONTENT_NONCONFIG:
ret = clicon_rpc_get_state(h, xpath, namespace, &xret);
ret = clicon_rpc_get(h, xpath, namespace, CONTENT_NONCONFIG, &xret);
break;
case CONTENT_ALL:
ret = clicon_rpc_get(h, xpath, namespace, &xret);
ret = clicon_rpc_get(h, xpath, namespace, CONTENT_ALL, &xret);
break;
default:
clicon_err(OE_XML, EINVAL, "Invalid content attribute %d", content);