Changed code so that it will be compatible with c++.

1. Added #ifdef extern "C" to public header files.
2. Changed variables that are key words in c++, to different names (like ns instead of namespace).
3. Changed char* to const char* for constant strings.
This commit is contained in:
shmuels 2020-07-02 15:00:53 +03:00
parent eda4a58ebf
commit 58ea4eba27
27 changed files with 274 additions and 119 deletions

View file

@ -355,7 +355,7 @@ changelog_iterate(clicon_handle h,
/*! Automatic upgrade using changelog
* @param[in] h Clicon handle
* @param[in] xt Top-level XML tree to be updated (includes other ns as well)
* @param[in] namespace Namespace of module (for info)
* @param[in] ns Namespace of module (for info)
* @param[in] op One of XML_FLAG_ADD, _DEL, _CHANGE
* @param[in] from From revision on the form YYYYMMDD
* @param[in] to To revision on the form YYYYMMDD (0 not in system)
@ -369,7 +369,7 @@ changelog_iterate(clicon_handle h,
int
xml_changelog_upgrade(clicon_handle h,
cxobj *xt,
char *namespace,
char *ns,
uint16_t op,
uint32_t from,
uint32_t to,
@ -399,7 +399,7 @@ xml_changelog_upgrade(clicon_handle h,
* - note it t=0 then no changelog is applied
*/
if (xpath_vec(xchlog, NULL, "changelog[namespace=\"%s\"]",
&vec, &veclen, namespace) < 0)
&vec, &veclen, ns) < 0)
goto done;
/* Get all changelogs in the interval [from,to]*/
for (i=0; i<veclen; i++){
@ -487,7 +487,7 @@ clixon_xml_changelog_init(clicon_handle h)
/*! Given a top-level XML tree and a namespace, return a vector of matching XML nodes
* @param[in] h Clicon handle
* @param[in] xt Top-level XML tree, with children marked with namespaces
* @param[in] namespace The namespace to select
* @param[in] ns The namespace to select
* @param[out] vecp Vector containining XML nodes w namespace. Null-terminated.
* @param[out] veclenp Length of vector
* @note Need to free vec after use with free()
@ -500,7 +500,7 @@ clixon_xml_changelog_init(clicon_handle h)
int
xml_namespace_vec(clicon_handle h,
cxobj *xt,
char *namespace,
char *ns,
cxobj ***vecp,
size_t *veclenp)
{
@ -508,7 +508,7 @@ xml_namespace_vec(clicon_handle h,
cxobj **xvec = NULL;
size_t xlen;
cxobj *xc;
char *ns;
char *ns0;
int i;
/* Allocate upper bound on length (ie could be too large) + a NULL element
@ -523,9 +523,9 @@ xml_namespace_vec(clicon_handle h,
xc = NULL;
i = 0;
while ((xc = xml_child_each(xt, xc, CX_ELMNT)) != NULL) {
if (xml2ns(xc, NULL, &ns) < 0) /* Get namespace of XML */
if (xml2ns(xc, NULL, &ns0) < 0) /* Get namespace of XML */
goto done;
if (strcmp(namespace, ns))
if (strcmp(ns, ns0))
continue; /* no match */
xvec[i++] = xc;
}