Support searching in filelists via the dataiterator. Under control of an
authorMichael Matz <matz@suse.de>
Wed, 13 Aug 2008 13:26:29 +0000 (13:26 +0000)
committerMichael Matz <matz@suse.de>
Wed, 13 Aug 2008 13:26:29 +0000 (13:26 +0000)
extra flag, because this is fairly costly.  Intended for user-controled
queries, _not_ to be used by the solver or the like.

src/repo.h
src/repodata.c
tools/dumpsolv.c

index 8645aed..4999b5d 100644 (file)
@@ -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)
 
index c902895..33993e0 100644 (file)
@@ -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;
        }
index ec37bbe..3e95f0c 100644 (file)
@@ -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))
     {