From 835c4dd7e77b485c6a3002a94449f67acf5b0973 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 3 Dec 2015 10:26:16 +0100 Subject: [PATCH] spliting search id Change-Id: I069750a6d02ca7967daeeee1b01dbdb082221146 --- wgtpkg-digsig.c | 16 +++++++++++----- 1 file 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 */ -- 2.16.6