From: Michael Matz Date: Wed, 13 Aug 2008 13:26:29 +0000 (+0000) Subject: Support searching in filelists via the dataiterator. Under control of an X-Git-Tag: BASE-SuSE-Code-12_1-Branch~573 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fcd89ae9c3f3efc1d9e939ca9548b6da8f8f9d9;p=platform%2Fupstream%2Flibsolv.git Support searching in filelists via the dataiterator. Under control of an extra flag, because this is fairly costly. Intended for user-controled queries, _not_ to be used by the solver or the like. --- diff --git a/src/repo.h b/src/repo.h index 8645aed..4999b5d 100644 --- a/src/repo.h +++ b/src/repo.h @@ -160,6 +160,12 @@ typedef struct _KeyValue { #define SEARCH_ALL_REPOS (1<<11) #define SEARCH_SKIP_KIND (1<<12) +/* By default we don't match in attributes representing filelists + because the construction of those strings is costly. Specify this + flag if you want this. In that case kv->str will contain the full + filename (if matched of course). */ +#define SEARCH_FILES (1<<13) + /* Internal */ #define __SEARCH_ONESOLVABLE (1 << 31) diff --git a/src/repodata.c b/src/repodata.c index c902895..33993e0 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -767,6 +767,16 @@ dataiterator_match_int_real(Dataiterator *di, int flags, const void *vmatch) break; case REPOKEY_TYPE_STR: break; + case REPOKEY_TYPE_DIRSTRARRAY: + if (!(flags & SEARCH_FILES)) + return 0; + /* Put the full filename into kv->str. */ + kv->str = repodata_dir2str(di->data, kv->id, kv->str); + /* And to compensate for that put the "empty" directory into + kv->id, so that later calls to repodata_dir2str on this data + come up with the same filename again. */ + kv->id = 0; + break; default: return 0; } diff --git a/tools/dumpsolv.c b/tools/dumpsolv.c index ec37bbe..3e95f0c 100644 --- a/tools/dumpsolv.c +++ b/tools/dumpsolv.c @@ -321,7 +321,7 @@ int main(int argc, char **argv) #if 0 printf ("\nSearchresults:\n"); Dataiterator di; - dataiterator_init(&di, pool->repos[0], 0, 0, "3", SEARCH_EXTRA | SEARCH_SUBSTRING | SEARCH_ALL_REPOS); + dataiterator_init(&di, pool->repos[0], 0, 0, "3", SEARCH_EXTRA | SEARCH_SUBSTRING | SEARCH_ALL_REPOS | SEARCH_FILES); //int count = 0; while (dataiterator_step(&di)) {