Fix static link problem in example

This commit is contained in:
Olof hagsand 2024-02-17 22:21:04 +01:00
parent ff171afd65
commit ea1efe8845
4 changed files with 21 additions and 18 deletions

View file

@ -78,6 +78,9 @@ CPPFLAGS = @CPPFLAGS@
ifeq ($(LINKAGE),dynamic)
CPPFLAGS += -fPIC
endif
ifeq ($(LINKAGE),dynamic)
CFLAGS += -DDYNAMICLINKAGE
endif
BE_PLUGIN = $(APPNAME)_backend.so
BE2_PLUGIN = $(APPNAME)_backend_nacm.so
@ -111,7 +114,7 @@ $(BE_PLUGIN): $(BE_OBJ)
ifeq ($(LINKAGE),dynamic)
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $< -lclixon -lclixon_backend
else
# can include -L in LDFLAGS?
# can include -L in LDFLAGS?
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $< -lclixon -lclixon_backend
endif
@ -176,8 +179,8 @@ install: $(YANGSPECS) $(CLISPECS) $(PLUGINS) $(APPNAME).xml restconf.xml autocli
[ -n "$$(getent passwd "$(CLICON_USER)")" ] || useradd -M -s /usr/sbin/nologin -g "$(CLICON_GROUP)" "$(CLICON_USER)"
install -d -m 0755 $(DESTDIR)$(sysconfdir)/clixon
install -m 0644 $(APPNAME).xml $(DESTDIR)$(sysconfdir)/clixon
install -m 0644 autocli.xml $(DESTDIR)$(sysconfdir)/clixon
install -m 0644 restconf.xml $(DESTDIR)$(sysconfdir)/clixon
install -m 0644 autocli.xml $(DESTDIR)$(sysconfdir)/clixon/$(APPNAME)
install -m 0644 restconf.xml $(DESTDIR)$(sysconfdir)/clixon/$(APPNAME)
install -d -m 0755 $(DESTDIR)$(datarootdir)/$(APPNAME)/yang
install -d -m 0755 $(DESTDIR)$(YANG_INSTALLDIR)
install -m 0644 $(YANGSPECS) $(DESTDIR)$(YANG_INSTALLDIR)

View file

@ -304,8 +304,11 @@ myerror(clixon_handle h,
errmsg_t *oldfn = NULL;
_errmsg_callback_fn = myerrmsg;
#ifdef DYNAMICLINKAGE
/* This does not link statically */
if (cli_remove(h, cvv, argv) < 0)
goto done;
#endif
retval = 0;
done:
_errmsg_callback_fn = oldfn;

View file

@ -1205,9 +1205,8 @@ xml_diff_context(cbuf *cb,
* @param[in] x1 Second XML tree
* @param[in] x0c Start of sublist in first XML tree
* @param[in] x1c Start of sublist in second XML tree
* @param[in] yc Yang of x0c/x1c
* @param[in] yc Yang of x0c/x1c. If NULL special case of anydata
* @param[in] level How many spaces to insert before each line
* @param[in] skiptop 0: Include top object 1: Skip top-object, only children,
* @retval 0 Ok
* @retval -1 Error
* @see xml_diff_ordered_by_user
@ -1220,15 +1219,14 @@ xml_diff2cbuf_ordered_by_user(cbuf *cb,
cxobj *x0c,
cxobj *x1c,
yang_stmt *yc,
int level,
int skiptop)
int level)
{
int retval = 1;
cxobj *xi;
cxobj *xj;
xj = x1c;
do {
do { /* Mark all x1 as ADD */
xml_flag_set(xj, XML_FLAG_ADD);
} while ((xj = xml_child_each(x1, xj, CX_ELMNT)) != NULL &&
xml_spec(xj) == yc);
@ -1426,11 +1424,9 @@ xml_diff2cbuf(cbuf *cb,
b0 = xml_body(x0c);
b1 = xml_body(x1c);
if (eq && y0c && y1c && y0c == y1c && yang_find(y0c, Y_ORDERED_BY, "user")){
if (xml_diff2cbuf_ordered_by_user(cb, x0, x1, x0c, x1c, y0c,
level, skiptop) < 0)
if (xml_diff2cbuf_ordered_by_user(cb, x0, x1, x0c, x1c, y0c, level) < 0)
goto done;
/* Add all in x0 marked as DELETE in x0vec
* Flags can remain: XXX should apply to all
/* Show all marked as DELETE as - entries
*/
xi = x0c;
do {
@ -1447,9 +1443,9 @@ xml_diff2cbuf(cbuf *cb,
}
while ((xi = xml_child_each(x0, xi, CX_ELMNT)) != NULL &&
xml_spec(xi) == y0c);
x0c = xi;
/* Add all in x1 marked as ADD in x1vec */
x0c = xi; /* skip entries in this yang class */
/* Show all marked as ADD as + entries
*/
xj = x1c;
do {
if (xml_flag(xj, XML_FLAG_ADD)){
@ -1467,7 +1463,7 @@ xml_diff2cbuf(cbuf *cb,
xml_spec(xj) == y1c);
x1c = xj;
continue;
}
} /* ordered-by user */
else if (eq < 0){
if (nr==0 && skiptop==0){
xml_diff_context(cb, x0, level1);
@ -1515,8 +1511,7 @@ xml_diff2cbuf(cbuf *cb,
goto done;
}
}
else if (y0c == NULL && y1c == NULL && (b0 || b1)) {
/* Special case for anydata terminals */
else if (y0c == NULL && y1c == NULL && (b0 || b1)) { /* Anydata terminals */
if (b0 == NULL || b1 == NULL || strcmp(b0, b1) != 0){
if (xml_diff2cbuf_leaf(cb, x0, x1, level, skiptop,
y0, x0c, x1c, b0, b1, &nr) < 0)

View file

@ -91,8 +91,10 @@ wait_backend
new "orig error"
expectpart "$($clixon_cli -1 -f $cfg -l n example error orig)" 255 "Config error: api-path syntax error " ": application invalid-value Invalid api-path: (must start with '/')"
if [ ${LINKAGE} = dynamic ]; then
new "customized error"
expectpart "$($clixon_cli -1 -f $cfg -l n example error custom)" 255 "My new err-string"
fi
if [ $BE -ne 0 ]; then
new "Kill backend"