From 121d97cbddd7f56750c5ba8802f7534b3ac8b7e9 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 12 Sep 2008 12:02:11 +0000 Subject: [PATCH] - add repo_add_poolstr_array - move updates="key,key.." to repomd.xml --- src/repo.c | 11 +++++++ src/repo.h | 1 + tools/repo_repomdxml.c | 76 ++++++++++++++++++++++++++++++++++++++++------ tools/repo_updateinfoxml.c | 26 ++-------------- 4 files changed, 81 insertions(+), 33 deletions(-) diff --git a/src/repo.c b/src/repo.c index df9a414..b829fcd 100644 --- a/src/repo.c +++ b/src/repo.c @@ -1029,6 +1029,17 @@ repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str) } void +repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str) +{ + Repodata *data = repo_findrepodata(repo, p, keyname); + if (p < 0) + p = p + data->extrastart; + else + p = p - data->start; + repodata_add_poolstr_array(data, repodata_get_handle(data, p), keyname, str); +} + +void repo_internalize(Repo *repo) { int i; diff --git a/src/repo.h b/src/repo.h index ee19efb..67d44cf 100644 --- a/src/repo.h +++ b/src/repo.h @@ -228,6 +228,7 @@ void repo_set_id(Repo *repo, Id p, Id keyname, Id id); void repo_set_num(Repo *repo, Id p, Id keyname, Id num); void repo_set_str(Repo *repo, Id p, Id keyname, const char *str); void repo_set_poolstr(Repo *repo, Id p, Id keyname, const char *str); +void repo_add_poolstr_array(Repo *repo, Id p, Id keyname, const char *str); void repo_internalize(Repo *repo); void repo_disable_paging(Repo *repo); diff --git a/tools/repo_repomdxml.c b/tools/repo_repomdxml.c index f137ce6..f387406 100644 --- a/tools/repo_repomdxml.c +++ b/tools/repo_repomdxml.c @@ -92,6 +92,34 @@ static struct stateswitch stateswitches[] = { { NUMSTATES } }; +/* + * split l into m parts, store to sp[] + * split at whitespace + */ + +static inline int +split_comma(char *l, char **sp, int m) +{ + int i; + for (i = 0; i < m;) + { + while (*l == ',') + l++; + if (!*l) + break; + sp[i++] = l; + if (i == m) + break; + while (*l && !(*l == ',')) + l++; + if (!*l) + break; + *l++ = 0; + } + return i; +} + + struct parsedata { int depth; enum state state; @@ -113,7 +141,7 @@ struct parsedata { * find attribute */ -static const char * +static inline const char * find_attr(const char *txt, const char **atts) { for (; *atts; atts += 2) @@ -124,6 +152,7 @@ find_attr(const char *txt, const char **atts) return 0; } + static void XMLCALL startElement(void *userData, const char *name, const char **atts) { @@ -165,15 +194,44 @@ startElement(void *userData, const char *name, const char **atts) { case STATE_START: break; case STATE_REPOMD: - expirestr = find_attr("expire", atts); - if ( expirestr != NULL ) - expire = atoi(expirestr); - if ( expire > 0 ) - { - /* save the timestamp in the non solvable number 1 */ - repo_set_num(pd->repo, -1, REPOSITORY_EXPIRE, expire); + { + const char *updstr; + char *value; + char *fvalue; + + expirestr = (char*) find_attr("expire", atts); + if ( expirestr != NULL ) + expire = atoi(expirestr); + if ( expire > 0 ) + { + /* save the timestamp in the non solvable number 1 */ + repo_set_num(pd->repo, -1, REPOSITORY_EXPIRE, expire); + } + + updstr = find_attr("updates", atts); + if ( updstr != NULL ) + { + value = strdup(updstr); + fvalue = value; /* save the first */ + if ( value != NULL ) + { + char *sp[2]; + while (value) + { + int words = split_comma(value, sp, 2); + if (!words) + break; + if (sp[0]) + repo_add_poolstr_array(pd->repo, -1, REPOSITORY_UPDATES, sp[0]); + if (words == 1) + break; + value = sp[1]; + } + free(fvalue); + } + } + break; } - break; case STATE_DATA: break; case STATE_LOCATION: break; case STATE_CHECKSUM: break; diff --git a/tools/repo_updateinfoxml.c b/tools/repo_updateinfoxml.c index 618d6a4..b96b972 100644 --- a/tools/repo_updateinfoxml.c +++ b/tools/repo_updateinfoxml.c @@ -135,22 +135,6 @@ struct parsedata { static int package_filename_seen = 0; static int package_flags = 0; /* same for reboot/restart flags, to be written at */ - -/* - * find attribute - */ - -static const char * -find_attr(const char *txt, const char **atts) -{ - for (; *atts; atts += 2) - { - if (!strcmp(*atts, txt)) - return atts[1]; - } - return 0; -} - /* * create evr (as Id) from 'epoch', 'version' and 'release' attributes */ @@ -360,15 +344,9 @@ startElement(void *userData, const char *name, const char **atts) break; case STATE_PKGLIST: break; - /* */ + /* data, -1, REPOSITORY_UPDATES, cid); - break; - } + break; /* Fedora 8 */ case STATE_NAME: break; -- 2.7.4