diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index d03f56bb..96fb6edf 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -109,7 +109,7 @@ install-include: clixon_backend.h clixon_backend_handle.h clixon_backend_transac # Just link test programs test.c : - echo "main(){}" > $@ + echo "int main(){}" > $@ test: test.c $(LIBOBJ) $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. -l:$(MYLIB) $(LIBS) -o $@ diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index c800bcfe..4213d4df 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -302,7 +302,8 @@ main(int argc, char **argv) int sockfamily; /* In the startup, logs to stderr & syslog and debug flag set later */ - clicon_log_init(__PROGRAM__, LOG_INFO, CLICON_LOG_STDERR|CLICON_LOG_SYSLOG); + + clicon_log_init(__PROGRAM__, LOG_INFO, CLICON_LOG_STDERR|CLICON_LOG_SYSLOG); /* Initiate CLICON handle */ if ((h = backend_handle_init()) == NULL) return -1; @@ -343,10 +344,13 @@ main(int argc, char **argv) break; } /* + * Here we have the debug flag settings, use that. * Syslogs also to stderr, but later turn stderr off in daemon mode. * error only to syslog. debug to syslog + * XXX: if started in a start-daemon script, there will be irritating + * double syslogs until fork below. */ - clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_STDERR|CLICON_LOG_SYSLOG); + clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_SYSLOG); clicon_debug_init(debug, NULL); /* Find and read configfile */ @@ -554,7 +558,7 @@ main(int argc, char **argv) demonized errors OK. Before this stage, errors are logged on stderr also */ if (foreground==0){ - clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_SYSLOG); + clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_SYSLOG); if (daemon(0, 0) < 0){ fprintf(stderr, "config: daemon"); exit(-1); diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index 00f90a1d..1b21d38d 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -105,7 +105,7 @@ uninstall: # Just link test programs test.c : - echo "main(){}" > $@ + echo "int main(){}" > $@ test: test.c $(LIBOBJ) $(CC) $(INCLUDES) $(LDFLAGS) $< $(LIBOBJ) -L. -l:$(MYLIB) $(LIBS) -o $@ diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index 53b20105..1aaa802b 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -138,6 +138,8 @@ str2cvec(char *string, clicon_debug(1, "error cvec_add %s", strerror(errno)); goto err; } + while ((strlen(s) > 0) && isblank(*s)) + s++; cv_name_set(cv, s); cv_string_set(cv, valu); free(valu); diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index 1e42c619..ef7dfcdf 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -432,7 +432,8 @@ request_process(clicon_handle h, /* If present, check credentials */ if (plugin_credentials(h, r, &auth) < 0) goto done; - clicon_debug(1, "%s credentials ok 1", __FUNCTION__); + clicon_debug(1, "%s credentials ok auth:%d (should be 1)", + __FUNCTION__, auth); if (auth == 0) goto done; clicon_debug(1, "%s credentials ok 2", __FUNCTION__); diff --git a/lib/src/clixon_xsl.c b/lib/src/clixon_xsl.c index ecbe392b..704fac41 100644 --- a/lib/src/clixon_xsl.c +++ b/lib/src/clixon_xsl.c @@ -21,6 +21,7 @@ * Limited XML XPATH and XSLT functions. * NOTE: there is a main function at the end of this file where you can test out * different xpath expressions. + * Look at the end of the file for a test unit program */ /* https://www.w3.org/TR/xpath/ @@ -449,10 +450,12 @@ xpath_expr(char *predicate_expression, if ((x = xml_find(xv, e_a)) != NULL && (xml_type(x) == CX_ATTR)){ if (!e_v || strcmp(xml_value(x), e_v) == 0){ - clicon_debug(2, "%s %x %x", __FUNCTION__, flags, xml_flag(xv, flags)); - if (flags==0x0 || xml_flag(xv, flags)) + clicon_debug(2, "%s %x %x", __FUNCTION__, flags, xml_flag(xv, flags)); + if (flags==0x0 || xml_flag(xv, flags)){ if (cxvec_append(xv, &vec, &veclen) < 0) goto done; + break; /* xv added */ + } } } } @@ -483,11 +486,14 @@ xpath_expr(char *predicate_expression, } for (i=0; i<*vec0len; i++){ xv = (*vec0)[i]; - if ((x = xml_find(xv, tag)) != NULL && - (xml_type(x) == CX_ELMNT)){ + /* Check if more may match,... */ + x = NULL; + while ((x = xml_child_each(xv, x, CX_ELMNT)) != NULL) { + if (strcmp(tag, xml_name(x)) != 0) + continue; if ((val = xml_body(x)) != NULL && strcmp(val, e) == 0){ - clicon_debug(2, "%s %x %x", __FUNCTION__, flags, xml_flag(xv, flags)); + clicon_debug(2, "%s %x %x", __FUNCTION__, flags, xml_flag(xv, flags)); if (flags==0x0 || xml_flag(xv, flags)) if (cxvec_append(xv, &vec, &veclen) < 0) goto done; @@ -508,13 +514,13 @@ xpath_expr(char *predicate_expression, } /*! Given vec0, add matches to vec1 - * @param[in] xe + * @param[in] xe XPATH in structured (parsed) form * @param[in] descendants0 - * @param[in] vec0 - * @param[in] vec0len - * @param[in] flags - * @param[out] vec1 - * @param[out] vec1len + * @param[in] vec0 vector of XML trees + * @param[in] vec0len length of XML trees + * @param[in] flags if != 0, only match xml nodes matching flags + * @param[out] vec2 Result XML node vector + * @param[out] vec2len Length of result vector. * XXX: Kommer in i funktionen med vec0, resultatet appendas i vec1 * vec0 --> vec * Det är nog bra om vec0 inte ändras, är input parameter @@ -673,12 +679,12 @@ xpath_split(char *xpathstr, } /*! Process single xpath expression on xml tree - * @param[in] xpath - * @param[in] vec0 - * @param[in] vec0len - * @param[in] flags - * @param[out] vec - * @param[out] veclen + * @param[in] xpath string with XPATH syntax + * @param[in] vec0 vector of XML trees + * @param[in] vec0len length of XML trees + * @param[in] flags if != 0, only match xml nodes matching flags + * @param[out] vec2 Result XML node vector + * @param[out] vec2len Length of result vector. */ static int xpath_exec(char *xpath,