Length of xml vector in many structs changed from to since it is a vector size, not byte size. This includes transaction_data_t
This commit is contained in:
parent
5be5b02a84
commit
04017c97ba
23 changed files with 57 additions and 54 deletions
|
|
@ -35,6 +35,7 @@ Expected: May 2020
|
|||
|
||||
### C-API changes on existing features (you may need to change your plugin C-code)
|
||||
|
||||
* Length of xml vector in many structs changed from `size_t` to `int`since it is a vector size, not byte size. This includes `transaction_data_t`
|
||||
* `xml_merge()` changed to use 3-value return: 1:OK, 0:Yang failed, -1: Error
|
||||
* `clixon_netconf_error(category, xerr, msg, arg)` removed first argument -> `clixon_netconf_error(xerr, msg, arg)`
|
||||
* CLI
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ typedef struct {
|
|||
cxobj *td_src; /* Source database xml tree */
|
||||
cxobj *td_target; /* Target database xml tree */
|
||||
cxobj **td_dvec; /* Delete xml vector */
|
||||
size_t td_dlen; /* Delete xml vector length */
|
||||
int td_dlen; /* Delete xml vector length */
|
||||
cxobj **td_avec; /* Add xml vector */
|
||||
size_t td_alen; /* Add xml vector length */
|
||||
int td_alen; /* Add xml vector length */
|
||||
cxobj **td_scvec; /* Source changed xml vector */
|
||||
cxobj **td_tcvec; /* Target changed xml vector */
|
||||
size_t td_clen; /* Changed xml vector length */
|
||||
int td_clen; /* Changed xml vector length */
|
||||
} transaction_data_t;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ main_commit(clicon_handle h,
|
|||
cxobj *target = transaction_target(td); /* wanted XML tree */
|
||||
cxobj **vec = NULL;
|
||||
int i;
|
||||
size_t len;
|
||||
int len;
|
||||
cvec *nsc = NULL;
|
||||
|
||||
if (_transaction_log)
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop,
|
|||
cxobj **xpathp, yang_stmt **ypathp, cxobj **xerr);
|
||||
int xml2api_path_1(cxobj *x, cbuf *cb);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, size_t *xlen, char *format,
|
||||
int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format,
|
||||
...) __attribute__ ((format (printf, 5, 6)));;
|
||||
int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, size_t *xlen, char *format,
|
||||
int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format,
|
||||
...) __attribute__ ((format (printf, 5, 6)));;
|
||||
#else
|
||||
int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, clixon_xvec **xvec, char *format, ...);
|
||||
int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, clixon_xvec **xvec, char *format, ...);
|
||||
int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...);
|
||||
int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...);
|
||||
#endif
|
||||
|
||||
#endif /* _CLIXON_PATH_H_ */
|
||||
|
|
|
|||
|
|
@ -226,9 +226,9 @@ int xml_copy_one(cxobj *xn0, cxobj *xn1);
|
|||
int xml_copy(cxobj *x0, cxobj *x1);
|
||||
cxobj *xml_dup(cxobj *x0);
|
||||
|
||||
int cxvec_dup(cxobj **vec0, size_t len0, cxobj ***vec1, size_t *len1);
|
||||
int cxvec_append(cxobj *x, cxobj ***vec, size_t *len);
|
||||
int cxvec_prepend(cxobj *x, cxobj ***vec, size_t *len);
|
||||
int cxvec_dup(cxobj **vec0, int len0, cxobj ***vec1, int *len1);
|
||||
int cxvec_append(cxobj *x, cxobj ***vec, int *len);
|
||||
int cxvec_prepend(cxobj *x, cxobj ***vec, int *len);
|
||||
int xml_apply(cxobj *xn, enum cxobj_type type, xml_applyfn_t fn, void *arg);
|
||||
int xml_apply0(cxobj *xn, enum cxobj_type type, xml_applyfn_t fn, void *arg);
|
||||
int xml_apply_ancestor(cxobj *xn, xml_applyfn_t fn, void *arg);
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ int xmlns_assign(cxobj *x);
|
|||
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);
|
||||
int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0);
|
||||
int xml_diff(yang_stmt *yspec, cxobj *x0, cxobj *x1,
|
||||
cxobj ***first, size_t *firstlen,
|
||||
cxobj ***second, size_t *secondlen,
|
||||
cxobj ***changed_x0, cxobj ***changed_x1, size_t *changedlen);
|
||||
cxobj ***first, int *firstlen,
|
||||
cxobj ***second, int *secondlen,
|
||||
cxobj ***changed_x0, cxobj ***changed_x1, int *changedlen);
|
||||
int xml_tree_prune_flagged_sub(cxobj *xt, int flag, int test, int *upmark);
|
||||
int xml_tree_prune_flagged(cxobj *xt, int flag, int test);
|
||||
int xml_namespace_change(cxobj *x, char *namespace, char *prefix);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ clixon_xvec *clixon_xvec_dup(clixon_xvec *xv0);
|
|||
int clixon_xvec_free(clixon_xvec *xv);
|
||||
int clixon_xvec_len(clixon_xvec *xv);
|
||||
cxobj *clixon_xvec_i(clixon_xvec *xv, int i);
|
||||
int clixon_xvec_extract(clixon_xvec *xv, cxobj ***xvec, size_t *xlen);
|
||||
int clixon_xvec_extract(clixon_xvec *xv, cxobj ***xvec, int *xlen);
|
||||
int clixon_xvec_append(clixon_xvec *xv, cxobj *x);
|
||||
int clixon_xvec_prepend(clixon_xvec *xv, cxobj *x);
|
||||
int clixon_xvec_insert_pos(clixon_xvec *xv, cxobj *x, int i);
|
||||
|
|
|
|||
|
|
@ -135,12 +135,12 @@ int xpath_vec_ctx(cxobj *xcur, cvec *nsc, char *xpath, int localonly, xp_ctx
|
|||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...) __attribute__ ((format (printf, 3, 4)));
|
||||
int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags,
|
||||
cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 7)));
|
||||
cxobj ***vec, int *veclen, ...) __attribute__ ((format (printf, 3, 7)));
|
||||
|
||||
#else
|
||||
int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...);
|
||||
int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags,
|
||||
cxobj ***vec, size_t *veclen, ...);
|
||||
cxobj ***vec, int *veclen, ...);
|
||||
#endif
|
||||
|
||||
/* Functions with explicit namespace context (nsc) set. If you do not need
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ enum xp_objtype{
|
|||
struct xp_ctx{
|
||||
enum xp_objtype xc_type;
|
||||
cxobj **xc_nodeset; /* if type XT_NODESET */
|
||||
size_t xc_size; /* Length of nodeset */
|
||||
int xc_size; /* Length of nodeset */
|
||||
int xc_bool; /* if xc_type XT_BOOL */
|
||||
double xc_number; /* if xc_type XT_NUMBER */
|
||||
char *xc_string; /* if xc_type XT_STRING */
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@
|
|||
int xpath_list_optimize_stats(int *hits);
|
||||
int xpath_list_optimize_set(int enable);
|
||||
void xpath_optimize_exit(void);
|
||||
//int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, size_t *xlen0);
|
||||
#if 0 /* XXX kludge for include file dependencies */
|
||||
int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, int *xlen0);
|
||||
#else
|
||||
int xpath_optimize_check();
|
||||
#endif
|
||||
|
||||
#endif /* _CLIXON_XPATH_OPTIMIZE_H */
|
||||
|
|
|
|||
|
|
@ -225,11 +225,7 @@ keyval_pos(char *uint)
|
|||
goto done;
|
||||
}
|
||||
cv = cvec_i(cvv, 0);
|
||||
if (cv_type_set(cv, CGV_UINT32) < 0){
|
||||
clicon_err(OE_UNIX, errno, "cv_type_set");
|
||||
cvv = NULL;
|
||||
goto done;
|
||||
}
|
||||
cv_type_set(cv, CGV_UINT32);
|
||||
if ((ret = cv_parse1(uint, cv, &reason)) < 0){
|
||||
clicon_err(OE_UNIX, errno, "cv_parse1");
|
||||
cvv = NULL;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct clixon_json_yacc {
|
|||
cxobj *jy_xtop; /* cxobj top element (fixed) */
|
||||
cxobj *jy_current; /* cxobj active element (changes with parse context) */
|
||||
cxobj **jy_xvec; /* Vector of created top-level nodes (to know which are created) */
|
||||
size_t jy_xlen; /* Length of jy_xvec */
|
||||
int jy_xlen; /* Length of jy_xvec */
|
||||
};
|
||||
typedef struct clixon_json_yacc clixon_json_yacc;
|
||||
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ nacm_datanode_prepare(clicon_handle h,
|
|||
cvec *nsc0 = NULL; /* Non-canonical namespace context */
|
||||
yang_stmt *yspec;
|
||||
cxobj **xvec = NULL;
|
||||
size_t xlen = 0;
|
||||
int xlen = 0;
|
||||
int ret;
|
||||
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
|
|
@ -422,7 +422,7 @@ nacm_datanode_prepare(clicon_handle h,
|
|||
if (ret == 0)
|
||||
continue;
|
||||
if (xlen > 1)
|
||||
clicon_log(LOG_WARNING, "%s path:%s Clixon only supports single returns, this had: %lu", __FUNCTION__, path, xlen);
|
||||
clicon_log(LOG_WARNING, "%s path:%s Clixon only supports single returns, this had: %d", __FUNCTION__, path, xlen);
|
||||
if (clixon_xvec_append(xpathvec, xvec?xvec[0]:NULL) < 0) /* XXX: vector of vectors? */
|
||||
goto done;
|
||||
if (xvec){
|
||||
|
|
|
|||
|
|
@ -1507,7 +1507,7 @@ int
|
|||
clixon_xml_find_api_path(cxobj *xt,
|
||||
yang_stmt *yt,
|
||||
cxobj ***xvec,
|
||||
size_t *xlen,
|
||||
int *xlen,
|
||||
char *format,
|
||||
...)
|
||||
{
|
||||
|
|
@ -1584,7 +1584,7 @@ clixon_xml_find_api_path(cxobj *xt,
|
|||
* - Number of keys in key-value list does not match Yang list
|
||||
* @code
|
||||
* cxobj **vec = NULL;
|
||||
* size_t len = 0;
|
||||
* int len = 0;
|
||||
* if (clixon_xml_find_instance_id(x, yspec, &vec, &len, "/symbol/%s", "foo") < 0)
|
||||
* goto err;
|
||||
* for (i=0; i<len; i++){
|
||||
|
|
@ -1601,7 +1601,7 @@ int
|
|||
clixon_xml_find_instance_id(cxobj *xt,
|
||||
yang_stmt *yt,
|
||||
cxobj ***xvec,
|
||||
size_t *xlen,
|
||||
int *xlen,
|
||||
char *format,
|
||||
...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ xml_stats_one(cxobj *x,
|
|||
}
|
||||
if (szp)
|
||||
*szp = sz;
|
||||
clicon_debug(1, "%s %" PRIu64, __FUNCTION__, sz);
|
||||
clicon_debug(1, "%s %zu", __FUNCTION__, sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ xml_stats(cxobj *xt,
|
|||
if (szp)
|
||||
*szp += sz;
|
||||
}
|
||||
clicon_debug(1, "%s %" PRIu64, __FUNCTION__, *szp);
|
||||
clicon_debug(1, "%s %zu", __FUNCTION__, *szp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1911,9 +1911,9 @@ xml_dup(cxobj *x0)
|
|||
*/
|
||||
int
|
||||
cxvec_dup(cxobj **vec0,
|
||||
size_t len0,
|
||||
int len0,
|
||||
cxobj ***vec1,
|
||||
size_t *len1)
|
||||
int *len1)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
@ -1934,7 +1934,7 @@ cxvec_dup(cxobj **vec0,
|
|||
* @retval -1 Error
|
||||
* @code
|
||||
* cxobj **xvec = NULL;
|
||||
* size_t xlen = 0;
|
||||
* int xlen = 0;
|
||||
* cxobj *x;
|
||||
*
|
||||
* if (cxvec_append(x, &xvec, &xlen) < 0)
|
||||
|
|
@ -1943,11 +1943,12 @@ cxvec_dup(cxobj **vec0,
|
|||
* free(xvec);
|
||||
* @endcode
|
||||
* @see cxvec_prepend
|
||||
* @see clixon_cxvec_append which is its own encapsulated xml vector datatype
|
||||
*/
|
||||
int
|
||||
cxvec_append(cxobj *x,
|
||||
cxobj ***vec,
|
||||
size_t *len)
|
||||
int *len)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
@ -1978,11 +1979,12 @@ cxvec_append(cxobj *x,
|
|||
* free(xvec);
|
||||
* @endcode
|
||||
* @see cxvec_prepend
|
||||
* @see clixon_cxvec_prepend which is its own encapsulated xml vector datatype
|
||||
*/
|
||||
int
|
||||
cxvec_prepend(cxobj *x,
|
||||
cxobj ***vec,
|
||||
size_t *len)
|
||||
int *len)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -443,12 +443,12 @@ xml_diff1(yang_stmt *ys,
|
|||
cxobj *x0,
|
||||
cxobj *x1,
|
||||
cxobj ***x0vec,
|
||||
size_t *x0veclen,
|
||||
int *x0veclen,
|
||||
cxobj ***x1vec,
|
||||
size_t *x1veclen,
|
||||
int *x1veclen,
|
||||
cxobj ***changed_x0,
|
||||
cxobj ***changed_x1,
|
||||
size_t *changedlen)
|
||||
int *changedlen)
|
||||
{
|
||||
int retval = -1;
|
||||
cxobj *x0c = NULL; /* x0 child */
|
||||
|
|
@ -551,12 +551,12 @@ xml_diff(yang_stmt *yspec,
|
|||
cxobj *x0,
|
||||
cxobj *x1,
|
||||
cxobj ***first,
|
||||
size_t *firstlen,
|
||||
int *firstlen,
|
||||
cxobj ***second,
|
||||
size_t *secondlen,
|
||||
int *secondlen,
|
||||
cxobj ***changed_x0,
|
||||
cxobj ***changed_x1,
|
||||
size_t *changedlen)
|
||||
int *changedlen)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ struct clixon_xml_parse_yacc {
|
|||
yang_stmt *xy_yspec; /* If set, top-level yang-spec */
|
||||
int xy_lex_state; /* lex return state */
|
||||
cxobj **xy_xvec; /* Vector of created top-level nodes (to know which are created) */
|
||||
size_t xy_xlen; /* Length of xy_xvec */
|
||||
int xy_xlen; /* Length of xy_xvec */
|
||||
};
|
||||
typedef struct clixon_xml_parse_yacc clixon_xml_yacc;
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ clixon_xvec_i(clixon_xvec *xv,
|
|||
int
|
||||
clixon_xvec_extract(clixon_xvec *xv,
|
||||
cxobj ***xvec,
|
||||
size_t *xlen)
|
||||
int *xlen)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -770,7 +770,7 @@ xpath_vec(cxobj *xcur,
|
|||
* @retval -1 error.
|
||||
* @code
|
||||
* cxobj **vec;
|
||||
* size_t veclen;
|
||||
* int veclen;
|
||||
* cvec *nsc; // namespace context (not NULL)
|
||||
* if (xpath_vec_flag(xcur, nsc, "//symbol/foo", XML_FLAG_ADD, &vec, &veclen) < 0)
|
||||
* goto err;
|
||||
|
|
@ -789,7 +789,7 @@ xpath_vec_flag(cxobj *xcur,
|
|||
char *xpformat,
|
||||
uint16_t flags,
|
||||
cxobj ***vec,
|
||||
size_t *veclen,
|
||||
int *veclen,
|
||||
...)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
|
|||
|
|
@ -253,12 +253,12 @@ nodetest_recursive(cxobj *xn,
|
|||
cvec *nsc,
|
||||
int localonly,
|
||||
cxobj ***vec0,
|
||||
size_t *vec0len)
|
||||
int *vec0len)
|
||||
{
|
||||
int retval = -1;
|
||||
cxobj *xsub;
|
||||
cxobj **vec = *vec0;
|
||||
size_t veclen = *vec0len;
|
||||
int veclen = *vec0len;
|
||||
|
||||
xsub = NULL;
|
||||
while ((xsub = xml_child_each(xn, xsub, node_type)) != NULL) {
|
||||
|
|
@ -306,7 +306,7 @@ xp_eval_step(xp_ctx *xc0,
|
|||
cxobj *xv;
|
||||
cxobj *xp;
|
||||
cxobj **vec = NULL;
|
||||
size_t veclen = 0;
|
||||
int veclen = 0;
|
||||
xpath_tree *nodetest = xs->xs_c0;
|
||||
xp_ctx *xc = NULL;
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ int
|
|||
xpath_optimize_check(xpath_tree *xs,
|
||||
cxobj *xv,
|
||||
cxobj ***xvec0,
|
||||
size_t *xlen0)
|
||||
int *xlen0)
|
||||
{
|
||||
#ifdef XPATH_LIST_OPTIMIZE
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ main(int argc,
|
|||
cxobj *x = NULL;
|
||||
cxobj *xc;
|
||||
cxobj **xvec = NULL;
|
||||
size_t xlen = 0;
|
||||
int xlen = 0;
|
||||
int c;
|
||||
int len;
|
||||
char *buf = NULL;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
#define UTIL_XML_MOD_OPTS "hD:o:y:b:x:p:s"
|
||||
|
||||
enum opx{
|
||||
OPX_ERROR = -1,
|
||||
OPX_INSERT,
|
||||
OPX_MERGE,
|
||||
OPX_PARENT
|
||||
|
|
@ -126,7 +127,7 @@ main(int argc, char **argv)
|
|||
int sort = 0;
|
||||
int ret;
|
||||
clicon_handle h;
|
||||
enum opx opx = -1;
|
||||
enum opx opx = OPX_ERROR;
|
||||
char *reason = NULL;
|
||||
|
||||
clicon_log_init("clixon_insert", LOG_DEBUG, CLICON_LOG_STDERR);
|
||||
|
|
@ -168,7 +169,7 @@ main(int argc, char **argv)
|
|||
/* Sanity check: check mandatory arguments */
|
||||
if (x1str == NULL || x0str == NULL || yangfile == NULL)
|
||||
usage(argv0);
|
||||
if (opx == -1)
|
||||
if (opx == OPX_ERROR)
|
||||
usage(argv0);
|
||||
if ((yspec = yspec_new()) == NULL)
|
||||
goto done;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue