C-API: Changed type of veclen parameter to size_t in xpath_vec_flag()
Rewrite of sed -e to be portable to freebsd
This commit is contained in:
parent
5b9921933a
commit
6fedf65de7
8 changed files with 23 additions and 14 deletions
|
|
@ -72,6 +72,7 @@ Developers may need to change their code
|
||||||
* Added netconf ssh subsystem
|
* Added netconf ssh subsystem
|
||||||
* Renamed from `clixon` built in `docker/base`
|
* Renamed from `clixon` built in `docker/base`
|
||||||
* C-API
|
* C-API
|
||||||
|
* Changed type of `veclen` parameter to `size_t` in `xpath_vec_flag()`
|
||||||
* Added `with-defaults` parameter (default 0) to `xmldb_get0()`
|
* Added `with-defaults` parameter (default 0) to `xmldb_get0()`
|
||||||
* Added `sock_flags` parameter to `clixon_proc_socket()`
|
* Added `sock_flags` parameter to `clixon_proc_socket()`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,6 @@ candidate_validate(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Do a diff between candidate and running, then start a commit transaction
|
/*! Do a diff between candidate and running, then start a commit transaction
|
||||||
*
|
*
|
||||||
* The code reverts changes if the commit fails. But if the revert
|
* The code reverts changes if the commit fails. But if the revert
|
||||||
|
|
@ -646,7 +645,7 @@ candidate_validate(clicon_handle h,
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] xe Request: <rpc><xn></rpc> (or NULL)
|
* @param[in] xe Request: <rpc><xn></rpc> (or NULL)
|
||||||
* @param[in] db A candidate database, not necessarily "candidate"
|
* @param[in] db A candidate database, not necessarily "candidate"
|
||||||
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
|
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. (if retval = 0)
|
||||||
* @retval -1 Error - or validation failed
|
* @retval -1 Error - or validation failed
|
||||||
* @retval 0 Validation failed (with cbret set)
|
* @retval 0 Validation failed (with cbret set)
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ main_commit(clicon_handle h,
|
||||||
cxobj *target = transaction_target(td); /* wanted XML tree */
|
cxobj *target = transaction_target(td); /* wanted XML tree */
|
||||||
cxobj **vec = NULL;
|
cxobj **vec = NULL;
|
||||||
int i;
|
int i;
|
||||||
int len;
|
size_t len;
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
|
|
||||||
if (_transaction_log)
|
if (_transaction_log)
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ int xpath_vec_ctx(cxobj *xcur, cvec *nsc, const char *xpath, int localonly, xp
|
||||||
|
|
||||||
int xpath_vec_bool(cxobj *xcur, cvec *nsc, const char *xpformat, ...) __attribute__ ((format (printf, 3, 4)));
|
int xpath_vec_bool(cxobj *xcur, cvec *nsc, const char *xpformat, ...) __attribute__ ((format (printf, 3, 4)));
|
||||||
int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags,
|
int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags,
|
||||||
cxobj ***vec, int *veclen, ...) __attribute__ ((format (printf, 3, 7)));
|
cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 7)));
|
||||||
|
|
||||||
/* Functions with explicit namespace context (nsc) set. If you do not need
|
/* Functions with explicit namespace context (nsc) set. If you do not need
|
||||||
* explicit namespace contexts (most do not) consider using the API functions
|
* explicit namespace contexts (most do not) consider using the API functions
|
||||||
|
|
|
||||||
|
|
@ -332,10 +332,13 @@ clixon_event_poll(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Dispatch file descriptor events (and timeouts) by invoking callbacks.
|
/*! Dispatch file descriptor events (and timeouts) by invoking callbacks.
|
||||||
* There is an issue with fairness that timeouts may take over all events
|
*
|
||||||
* One could try to poll the file descriptors after a timeout?
|
* @param[in] h Clixon handle
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error: eg select, callback, timer,
|
* @retval -1 Error: eg select, callback, timer,
|
||||||
|
* @note There is an issue with fairness between timeouts and events
|
||||||
|
* Currently a socket that is not read/emptied properly starve timeouts.
|
||||||
|
* One could try to poll the file descriptors after a timeout?
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_event_loop(clicon_handle h)
|
clixon_event_loop(clicon_handle h)
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,7 @@ xml_default(yang_stmt *yt,
|
||||||
case Y_CHOICE:{
|
case Y_CHOICE:{
|
||||||
if (xml_default_choice(yc, xt, state) < 0)
|
if (xml_default_choice(yc, xt, state) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -823,7 +823,7 @@ xpath_vec(cxobj *xcur,
|
||||||
* @retval -1 error.
|
* @retval -1 error.
|
||||||
* @code
|
* @code
|
||||||
* cxobj **vec;
|
* cxobj **vec;
|
||||||
* int veclen;
|
* size_t veclen;
|
||||||
* cvec *nsc; // namespace context (not NULL)
|
* cvec *nsc; // namespace context (not NULL)
|
||||||
* if (xpath_vec_flag(xcur, nsc, "//symbol/foo", XML_FLAG_ADD, &vec, &veclen) < 0)
|
* if (xpath_vec_flag(xcur, nsc, "//symbol/foo", XML_FLAG_ADD, &vec, &veclen) < 0)
|
||||||
* goto err;
|
* goto err;
|
||||||
|
|
@ -842,7 +842,7 @@ xpath_vec_flag(cxobj *xcur,
|
||||||
const char *xpformat,
|
const char *xpformat,
|
||||||
uint16_t flags,
|
uint16_t flags,
|
||||||
cxobj ***vec,
|
cxobj ***vec,
|
||||||
int *veclen,
|
size_t *veclen,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -852,6 +852,7 @@ xpath_vec_flag(cxobj *xcur,
|
||||||
xp_ctx *xr = NULL;
|
xp_ctx *xr = NULL;
|
||||||
int i;
|
int i;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
int ilen = 0; /* change when cxvec_append uses size_t */
|
||||||
|
|
||||||
va_start(ap, veclen);
|
va_start(ap, veclen);
|
||||||
len = vsnprintf(NULL, 0, xpformat, ap);
|
len = vsnprintf(NULL, 0, xpformat, ap);
|
||||||
|
|
@ -870,17 +871,18 @@ xpath_vec_flag(cxobj *xcur,
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
*vec=NULL;
|
*vec=NULL;
|
||||||
*veclen = 0;
|
|
||||||
if (xpath_vec_ctx(xcur, nsc, xpath, 0, &xr) < 0)
|
if (xpath_vec_ctx(xcur, nsc, xpath, 0, &xr) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (xr && xr->xc_type == XT_NODESET){
|
if (xr && xr->xc_type == XT_NODESET){
|
||||||
for (i=0; i<xr->xc_size; i++){
|
for (i=0; i<xr->xc_size; i++){
|
||||||
|
int ilen;
|
||||||
x = xr->xc_nodeset[i];
|
x = xr->xc_nodeset[i];
|
||||||
if (flags==0x0 || xml_flag(x, flags))
|
if (flags==0x0 || xml_flag(x, flags))
|
||||||
if (cxvec_append(x, vec, veclen) < 0)
|
if (cxvec_append(x, vec, &ilen) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*veclen = ilen;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (xr)
|
if (xr)
|
||||||
|
|
|
||||||
|
|
@ -171,9 +171,12 @@ EOF
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Mask netconf header and footer
|
# Mask netconf header and footer
|
||||||
sed -i -e "s/<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">//" -e 's/<\/data><\/rpc-reply>]]>]]>//' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
sed -i -e "s/<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">//" /var/tmp/test_netconf_monitoring.sh/ex.yang
|
||||||
|
sed -i -e 's/<\/data><\/rpc-reply>]]>]]>//' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
||||||
# Decode XML
|
# Decode XML
|
||||||
sed -i -e 's/>/>/g' -e 's/</</g' -e 's/\&/\&/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
sed -i -e 's/>/>/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
||||||
|
sed -i -e 's/</</g' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
||||||
|
sed -i -e 's/\&/\&/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
|
||||||
new "get-schema check yang $b"
|
new "get-schema check yang $b"
|
||||||
diff $dir/ex.yang $f
|
diff $dir/ex.yang $f
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue