aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2015-12-03 10:26:16 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2015-12-03 10:26:16 +0100
commit835c4dd7e77b485c6a3002a94449f67acf5b0973 (patch)
treef53e9b826ae7d3c5699bc7893d950c8f4e8ebcc1
parent0bc4aed95f8b93a509afeca9dde9d30e1b85916a (diff)
spliting search id
Change-Id: I069750a6d02ca7967daeeee1b01dbdb082221146
-rw-r--r--wgtpkg-digsig.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/wgtpkg-digsig.c b/wgtpkg-digsig.c
index 96f4280..26ee824 100644
--- a/wgtpkg-digsig.c
+++ b/wgtpkg-digsig.c
@@ -67,7 +67,7 @@ static xmlNodePtr next_element_type(xmlNodePtr node, const char *name)
}
/* search the element node of id. NOTE : not optimized at all */
-static xmlNodePtr search_id(const char *id)
+static xmlNodePtr search_for(const char *attrname, const char *value)
{
char *val;
xmlNodePtr iter, next;
@@ -76,10 +76,10 @@ static xmlNodePtr search_id(const char *id)
result = NULL;
iter = xmlDocGetRootElement(document);
while (iter != NULL) {
- val = xmlGetProp(iter, "Id");
- if (val != NULL && !strcmp(val, id)) {
+ val = xmlGetProp(iter, attrname);
+ if (val != NULL && !strcmp(val, value)) {
if (result != NULL) {
- syslog(LOG_ERR, "duplicated Id %s", id);
+ syslog(LOG_ERR, "duplicated %s %s", attrname, value);
free(val);
return NULL;
}
@@ -101,9 +101,15 @@ static xmlNodePtr search_id(const char *id)
iter = next;
}
if (result == NULL)
- syslog(LOG_ERR, "node of Id '%s' not found", id);
+ syslog(LOG_ERR, "node of %s '%s' not found", attrname, value);
return result;
}
+
+/* search the element node of id. NOTE : not optimized at all */
+static xmlNodePtr search_id(const char *id)
+{
+ return search_for("Id", id);
+}
#endif
/* check the digest of one element */