From b94d5040631d855dab431c3e670a7c2f0095829c Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 12 Mar 2021 15:51:52 +0100 Subject: [PATCH] headerlist.c: former pre-production changes not committed --- src/headerlist.c | 67 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/headerlist.c b/src/headerlist.c index 8d36d80..7ef8d85 100644 --- a/src/headerlist.c +++ b/src/headerlist.c @@ -855,9 +855,11 @@ void getXMLPackageChangelog(xmlNode *parent, int i = *count -1; for (xmlNode *entry=parent->children; entry; entry=entry->next) { if (entry->type == XML_ELEMENT_NODE && !strcmp((char*)entry->name, "changelog")) { - (*changelogtime)[i] = atoi((char*)findXMLAttributeByName(entry, "date")); - (*changelogrelease)[i] = strdup((char*)findXMLAttributeByName(entry, "author")); - (*changelogtext)[i] = strdup((char*)entry->children->content); + char *tmp = (char*)findXMLAttributeByName(entry, "date"); + (*changelogtime)[i] = atoi(tmp); + free(tmp); + (*changelogrelease)[i] = (char*)findXMLAttributeByName(entry, "author"); + (*changelogtext)[i] = (char*)entry->children->content; i--; } } @@ -867,6 +869,7 @@ void getXMLPackageChangelog(xmlNode *parent, void getXMLPackageNFV(xmlNode *parent, char ***name, uint_32 **flags, char ***version, int *count) { + char buf[PATH_MAX]; *count = xmlChildElementCount(parent); if (*count == 0) { @@ -887,15 +890,26 @@ void getXMLPackageNFV(xmlNode *parent, char ***name, *count); return; } - (*name)[i] = strdup((char*)findXMLAttributeByName(entry, "name")); - char *ver = (char*)findXMLAttributeByName(entry, "version"); - if (ver) { - (*version)[i] = strdup(ver); - free(ver); - } else - (*version)[i] = strdup(""); + (*name)[i] = (char*)findXMLAttributeByName(entry, "name"); (*flags)[i] = XMLFlagToInt( (char*)findXMLAttributeByName(entry, "flags")); + buf[0] = '\0'; + if ((*flags)[i] != RPMSENSE_ANY) { + char *epoch = (char*)findXMLAttributeByName(entry, "epoch"); + char *ver = (char*)findXMLAttributeByName(entry, "ver"); + char *rel = (char*)findXMLAttributeByName(entry, "rel"); + if (epoch && ver && rel) { + snprintf(buf, PATH_MAX,"%s:%s-%s", epoch, ver, rel); + free(epoch); + free(ver); + free(rel); + } else if (epoch && ver) { + snprintf(buf, PATH_MAX,"%s:%s", epoch, ver); + free(epoch); + free(ver); + } + } + (*version)[i] = strdup(buf); i++; } } @@ -982,6 +996,7 @@ void addNewToSourceHeaderList(struct headerSourceList *newheadersourcelist, int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) { char *scanpath; + char *tmp; struct repoData* repodata = NULL; struct headerSourceList *newheadersourcelist; struct dirent **namelist; @@ -1051,9 +1066,11 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) { newheadersourcelist->name = strdup((char*) findXMLPropertyByName(package_node, "name")->children->content); xmlNode *version = findXMLPropertyByName(package_node, "version"); - newheadersourcelist->epoch = atoi((char*)findXMLAttributeByName(version, "epoch")); - newheadersourcelist->version = strdup((char*)findXMLAttributeByName(version, "ver")); - newheadersourcelist->release = strdup((char*)findXMLAttributeByName(version, "rel")); + tmp = (char*)findXMLAttributeByName(version, "epoch"); + newheadersourcelist->epoch = atoi(tmp); + free(tmp); + newheadersourcelist->version = (char*)findXMLAttributeByName(version, "ver"); + newheadersourcelist->release = (char*)findXMLAttributeByName(version, "rel"); newheadersourcelist->summary = strdup((char*) findXMLPropertyByName(package_node, "summary")->children->content); newheadersourcelist->arch = strdup((char*) @@ -1090,11 +1107,13 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) { logmsg(LOG_WARNING,"missing URL definition for package %s.", newheadersourcelist->name); xmlNode *ptime = findXMLPropertyByName(package_node, "time"); - newheadersourcelist->buildtime = atoi( - (char*)findXMLAttributeByName(ptime, "build")); + tmp = (char*)findXMLAttributeByName(ptime, "build"); + newheadersourcelist->buildtime = atoi(tmp); + free(tmp); xmlNode *psize = findXMLPropertyByName(package_node, "size"); - newheadersourcelist->size = atoi( - (char*)findXMLAttributeByName(psize, "package")); + tmp = (char*)findXMLAttributeByName(psize, "package"); + newheadersourcelist->size = atoi(tmp); + free(tmp); // FIXME: information missing from repodata newheadersourcelist->buildarchs = NULL; newheadersourcelist->excludearch = NULL; @@ -1379,6 +1398,7 @@ char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) { xmlNode *primary_node[ALT_REPS_MAX + 1], *filelists_node[ALT_REPS_MAX + 1]; char *currnames[ALT_REPS_MAX + 1]; char nextname[bufsize + 1]; + char *tmp; char scanpath[bufsize + 1], *altscanpath[ALT_REPS_MAX]; char *scantag, *altscantag[ALT_REPS_MAX]; @@ -1534,9 +1554,11 @@ char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) { newheaderlist->name = strdup((char*) findXMLPropertyByName(primary_node[altidx], "name")->children->content); xmlNode *version = findXMLPropertyByName(primary_node[altidx], "version"); - newheaderlist->epoch = atoi((char*)findXMLAttributeByName(version, "epoch")); - newheaderlist->version = strdup((char*)findXMLAttributeByName(version, "ver")); - newheaderlist->release = strdup((char*)findXMLAttributeByName(version, "rel")); + tmp = (char*)findXMLAttributeByName(version, "epoch"); + newheaderlist->epoch = atoi(tmp); + free(tmp); + newheaderlist->version = (char*)findXMLAttributeByName(version, "ver"); + newheaderlist->release = (char*)findXMLAttributeByName(version, "rel"); newheaderlist->summary = strdup((char*) findXMLPropertyByName(primary_node[altidx], "summary")->children->content); newheaderlist->arch = strdup((char*) @@ -1555,8 +1577,9 @@ char* advanceXMLPackageNode(xmlNode **primary_node, xmlNode **filelists_node) { newheaderlist->sourcename = strdup((char*) findXMLPropertyByName(format, "sourcerpm")->children->content); xmlNode *psize = findXMLPropertyByName(primary_node[altidx], "size"); - newheaderlist->size = atoi( - (char*)findXMLAttributeByName(psize, "package")); + tmp = (char*)findXMLAttributeByName(psize, "package"); + newheaderlist->size = atoi(tmp); + free(tmp); int ret = addNewToHeaderList(&currheaderlist, newheaderlist, ct, altidx, arch);