summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmgi.c2
-rw-r--r--lib/rpmgi.h4
-rw-r--r--lib/tgi.c28
3 files changed, 21 insertions, 13 deletions
diff --git a/lib/rpmgi.c b/lib/rpmgi.c
index e267698b0..b498f6816 100644
--- a/lib/rpmgi.c
+++ b/lib/rpmgi.c
@@ -311,7 +311,7 @@ fprintf(stderr, "*** gi %p\t%p[%d]\n", gi, gi->argv, gi->argc);
return NULL;
}
-rpmgi rpmgiNew(rpmts ts, int tag, void * keyp, size_t keylen)
+rpmgi rpmgiNew(rpmts ts, int tag, const void * keyp, size_t keylen)
{
rpmgi gi = xcalloc(1, sizeof(*gi));
diff --git a/lib/rpmgi.h b/lib/rpmgi.h
index 160d6b471..1a3fe82e0 100644
--- a/lib/rpmgi.h
+++ b/lib/rpmgi.h
@@ -24,7 +24,7 @@ struct rpmgi_s {
/*@refcounted@*/
rpmts ts; /*!< Iterator transaction set. */
int tag; /*!< Iterator type. */
- void * keyp; /*!< Iterator key. */
+ const void * keyp; /*!< Iterator key. */
size_t keylen; /*!< Iterator key length. */
int active; /*!< Iterator is active? */
@@ -110,7 +110,7 @@ rpmgi rpmgiFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmgi gi)
* @return new general iterator
*/
/*@null@*/
-rpmgi rpmgiNew(rpmts ts, int tag, void * keyp, size_t keylen)
+rpmgi rpmgiNew(rpmts ts, int tag, /*@null@*/ const void * keyp, size_t keylen)
/*@globals internalState @*/
/*@modifies ts, internalState @*/;
diff --git a/lib/tgi.c b/lib/tgi.c
index 73e04bb65..4734cfc3d 100644
--- a/lib/tgi.c
+++ b/lib/tgi.c
@@ -10,7 +10,8 @@
#include "debug.h"
-static int gitag = RPMDBI_FTSWALK;
+static const char * gitagstr = "packages";
+static const char * gikeystr = NULL;
static int ftsOpts = 0;
static const char * queryFormat = NULL;
@@ -38,14 +39,10 @@ static struct poptOption optionsTable[] = {
{ "rpmgidebug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmgi_debug, -1,
N_("debug generalized iterator"), NULL},
- { "rpmdb", '\0', POPT_ARG_VAL, &gitag, RPMDBI_PACKAGES,
- N_("iterate rpmdb"), NULL },
- { "hdlist", '\0', POPT_ARG_VAL, &gitag, RPMDBI_HDLIST,
- N_("iterate hdlist"), NULL },
- { "arglist", '\0', POPT_ARG_VAL, &gitag, RPMDBI_ARGLIST,
- N_("iterate arglist"), NULL },
- { "ftswalk", '\0', POPT_ARG_VAL, &gitag, RPMDBI_FTSWALK,
- N_("iterate fts(3) walk"), NULL },
+ { "tag", '\0', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &gitagstr, 0,
+ N_("iterate tag index"), NULL },
+ { "key", '\0', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &gikeystr, 0,
+ N_("tag value key"), NULL },
{ "qf", '\0', POPT_ARG_STRING, &queryFormat, 0,
N_("use the following query format"), "QUERYFORMAT" },
@@ -85,6 +82,7 @@ main(int argc, char *const argv[])
rpmts ts = NULL;
rpmVSFlags vsflags;
rpmgi gi = NULL;
+ int gitag = RPMDBI_PACKAGES;
const char ** av;
int ac;
int rc = 0;
@@ -96,6 +94,16 @@ main(int argc, char *const argv[])
if (ftsOpts == 0)
ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
+ if (gitagstr != NULL) {
+ gitag = tagValue(gitagstr);
+ if (gitag < 0) {
+ fprintf(stderr, _("unknown --tag argument: %s\n"), gitagstr);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* XXX ftswalk segfault with no args. */
+
ts = rpmtsCreate();
vsflags = rpmExpandNumeric("%{?_vsflags_query}");
if (rpmcliQueryFlags & VERIFY_DIGEST)
@@ -110,7 +118,7 @@ main(int argc, char *const argv[])
(void) rpmtsSetTid(ts, tid);
}
- gi = rpmgiNew(ts, gitag, NULL, 0);
+ gi = rpmgiNew(ts, gitag, gikeystr, 0);
av = poptGetArgs(optCon);
(void) rpmgiSetArgs(gi, av, ftsOpts);