From: Klaus Kaempf Date: Wed, 9 Apr 2008 15:39:31 +0000 (+0000) Subject: convert and as multiple arrays within the X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~423 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06e43479d08027230392bbee228d3f69d1536210;p=thirdparty%2Flibsolv.git convert and as multiple arrays within the .solv file, see knownid.h for the attribute names. --- diff --git a/tools/repo_updateinfoxml.c b/tools/repo_updateinfoxml.c index 8190d174..94d13c0a 100644 --- a/tools/repo_updateinfoxml.c +++ b/tools/repo_updateinfoxml.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 2007, Novell Inc. * @@ -6,6 +5,8 @@ * for further information */ +#define DO_ARRAY 1 + #define _GNU_SOURCE #include #include @@ -119,6 +120,18 @@ struct parsedata { int atemp; }; +/* + * if we have seen a ... + * inside of ... + * + * If not, we must insert an empty filename to UPDATE_COLLECTION_FILENAME + * at in order to keep all UPDATE_COLLECTION_* arrays in sync + */ + +static int package_filename_seen = 0; +static int package_flags = 0; /* same for reboot/restart flags, to be written at */ + + /* * find attribute */ @@ -312,6 +325,26 @@ startElement(void *userData, const char *name, const char **atts) * type="bugzilla"/> */ case STATE_REFERENCE: + { + const char *url = 0, *id = 0, *title = 0, *type = 0; + for (; *atts; atts += 2) + { + if (!strcmp(*atts, "href")) + url = atts[1]; + else if (!strcmp(*atts, "id")) + id = atts[1]; + else if (!strcmp(*atts, "title")) + title = atts[1]; + else if (!strcmp(*atts, "type")) + type = atts[1]; + } +#if DO_ARRAY + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_REFERENCE_URL, url); + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_REFERENCE_ID, id); + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_REFERENCE_TITLE, title); + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_REFERENCE_TYPE, type); +#endif + } break; /* This update ... */ case STATE_DESCRIPTION: @@ -336,6 +369,11 @@ startElement(void *userData, const char *name, const char **atts) Id evr = makeevr_atts(pool, pd, atts); /* parse "epoch", "version", "release" */ Id n, a, na; Id rel_id; + + /* reset package_* markers, to be evaluated at */ + package_filename_seen = 0; + package_flags = 0; + for (; *atts; atts += 2) { if (!strcmp(*atts, "arch")) @@ -357,8 +395,13 @@ startElement(void *userData, const char *name, const char **atts) rel_id = rel2id(pool, na, evr, REL_LT, 1); solvable->conflicts = repo_addid_dep(pd->repo, solvable->conflicts, rel_id, 0); - - if (1) { +#if DO_ARRAY + repodata_add_idarray(pd->data, pd->datanum, UPDATE_COLLECTION_NAME, n); + repodata_add_idarray(pd->data, pd->datanum, UPDATE_COLLECTION_EVR, a); + repodata_add_idarray(pd->data, pd->datanum, UPDATE_COLLECTION_ARCH, evr); +#else + /* _FILENAME and _FLAGS are written at */ + if (1) { const char *evrstr = id2str(pool, evr); int buflen = strlen(name) + 1 + strlen(evrstr) + 1 + strlen(arch?arch:"") + 1; char *buf; @@ -369,6 +412,7 @@ startElement(void *userData, const char *name, const char **atts) repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_COLLECTION, buf); free(buf); } +#endif } break; /* libntlm-0.4.2-1.fc8.x86_64.rpm */ @@ -464,20 +508,52 @@ endElement(void *userData, const char *name) case STATE_NAME: break; case STATE_PACKAGE: + { +#if DO_ARRAY + /* write _FILENAME and _FLAGS at + * to ensure all UPDATE_COLLECTION_* arrays are filled in parallel + */ + if (!package_filename_seen) + { + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_COLLECTION_FILENAME, ""); + } + repodata_add_idarray(pd->data, pd->datanum, UPDATE_COLLECTION_FLAGS, package_flags+1); +#endif + } break; /* libntlm-0.4.2-1.fc8.x86_64.rpm */ case STATE_FILENAME: + { +#if DO_ARRAY + repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_COLLECTION_FILENAME, pd->content); + package_filename_seen = 1; +#endif + } break; /* True */ case STATE_REBOOT: { - repodata_set_void(pd->data, pd->datanum, UPDATE_REBOOT); + if (pd->content + && (pd->content[0] == 'T' + || pd->content[0] == 't')) + { + /* FIXME: this is per-package, the global flag should be computed at runtime */ + repodata_set_void(pd->data, pd->datanum, UPDATE_REBOOT); + package_flags = 1; + } } break; /* True */ case STATE_RESTART: { - repodata_set_void(pd->data, pd->datanum, UPDATE_RESTART); + if (pd->content + && (pd->content[0] == 'T' + || pd->content[0] == 't')) + { + /* FIXME: this is per-package, the global flag should be computed at runtime */ + repodata_set_void(pd->data, pd->datanum, UPDATE_RESTART); + package_flags = 2; + } } break; default: