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:
Olof hagsand 2022-12-29 15:45:16 +01:00
parent 5b9921933a
commit 6fedf65de7
8 changed files with 23 additions and 14 deletions

View file

@ -72,6 +72,7 @@ Developers may need to change their code
* Added netconf ssh subsystem
* Renamed from `clixon` built in `docker/base`
* C-API
* Changed type of `veclen` parameter to `size_t` in `xpath_vec_flag()`
* Added `with-defaults` parameter (default 0) to `xmldb_get0()`
* Added `sock_flags` parameter to `clixon_proc_socket()`

View file

@ -637,7 +637,6 @@ candidate_validate(clicon_handle h,
goto done;
}
/*! Do a diff between candidate and running, then start a commit transaction
*
* 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] xe Request: <rpc><xn></rpc> (or NULL)
* @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 0 Validation failed (with cbret set)
* @retval 1 Validation OK

View file

@ -200,7 +200,7 @@ main_commit(clicon_handle h,
cxobj *target = transaction_target(td); /* wanted XML tree */
cxobj **vec = NULL;
int i;
int len;
size_t len;
cvec *nsc = NULL;
if (_transaction_log)

View file

@ -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_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
* explicit namespace contexts (most do not) consider using the API functions

View file

@ -332,10 +332,13 @@ clixon_event_poll(int fd)
}
/*! 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?
* @retval 0 OK
* @retval -1 Error: eg select, callback, timer,
*
* @param[in] h Clixon handle
* @retval 0 OK
* @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
clixon_event_loop(clicon_handle h)

View file

@ -370,6 +370,7 @@ xml_default(yang_stmt *yt,
case Y_CHOICE:{
if (xml_default_choice(yc, xt, state) < 0)
goto done;
break;
}
default:
break;

View file

@ -823,7 +823,7 @@ xpath_vec(cxobj *xcur,
* @retval -1 error.
* @code
* cxobj **vec;
* int veclen;
* size_t veclen;
* cvec *nsc; // namespace context (not NULL)
* if (xpath_vec_flag(xcur, nsc, "//symbol/foo", XML_FLAG_ADD, &vec, &veclen) < 0)
* goto err;
@ -842,7 +842,7 @@ xpath_vec_flag(cxobj *xcur,
const char *xpformat,
uint16_t flags,
cxobj ***vec,
int *veclen,
size_t *veclen,
...)
{
int retval = -1;
@ -852,6 +852,7 @@ xpath_vec_flag(cxobj *xcur,
xp_ctx *xr = NULL;
int i;
cxobj *x;
int ilen = 0; /* change when cxvec_append uses size_t */
va_start(ap, veclen);
len = vsnprintf(NULL, 0, xpformat, ap);
@ -870,17 +871,18 @@ xpath_vec_flag(cxobj *xcur,
}
va_end(ap);
*vec=NULL;
*veclen = 0;
if (xpath_vec_ctx(xcur, nsc, xpath, 0, &xr) < 0)
goto done;
if (xr && xr->xc_type == XT_NODESET){
for (i=0; i<xr->xc_size; i++){
int ilen;
x = xr->xc_nodeset[i];
if (flags==0x0 || xml_flag(x, flags))
if (cxvec_append(x, vec, veclen) < 0)
if (cxvec_append(x, vec, &ilen) < 0)
goto done;
}
}
*veclen = ilen;
retval = 0;
done:
if (xr)

View file

@ -171,9 +171,12 @@ EOF
continue
fi
# 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
sed -i -e 's/&gt;/>/g' -e 's/&lt;/</g' -e 's/\&amp;/\&/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/&gt;/>/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/&lt;/</g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/\&amp;/\&/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
new "get-schema check yang $b"
diff $dir/ex.yang $f
if [ $? -ne 0 ]; then