summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rpmgi.c17
-rw-r--r--lib/rpmgi.h3
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/rpmgi.c b/lib/rpmgi.c
index 65260bff1..7b880686b 100644
--- a/lib/rpmgi.c
+++ b/lib/rpmgi.c
@@ -14,6 +14,8 @@
/*@unchecked@*/
int _rpmgi_debug = 0;
+static const char * hdlistpath = "/usr/share/comps/i386/hdlist";
+
rpmgi XrpmgiUnlink(rpmgi gi, const char * msg, const char * fn, unsigned ln)
{
if (gi == NULL) return NULL;
@@ -68,6 +70,10 @@ fprintf(stderr, "*** gi %p\t%p[%d]\n", gi, gi->argv, gi->argc);
gi->ftsp = NULL;
gi->fts = NULL;
}
+ if (gi->fd != NULL) {
+ (void) Fclose(gi->fd);
+ gi->fd = NULL;
+ }
gi->mi = rpmdbFreeIterator(gi->mi);
gi->ts = rpmtsFree(gi->ts);
@@ -97,6 +103,7 @@ fprintf(stderr, "*** gi %p\t%p\n", gi, gi->mi);
break;
case RPMGI_HDLIST:
+ gi->fd = Fopen(hdlistpath, "r.ufdio");
break;
case RPMGI_ARGLIST:
case RPMGI_FTSWALK:
@@ -189,6 +196,14 @@ const char * rpmgiNext(/*@null@*/ rpmgi gi)
}
break;
case RPMGI_HDLIST:
+ h = headerRead(gi->fd, HEADER_MAGIC_YES);
+ if (h != NULL) {
+ val = rpmgiPathOrQF(gi, "hdlist", &h);
+ } else {
+ (void) Fclose(gi->fd);
+ gi->fd = NULL;
+ gi->i = -1;
+ }
break;
case RPMGI_ARGLIST:
if (gi->argv != NULL && gi->argv[gi->i] != NULL) {
@@ -244,7 +259,7 @@ int rpmgiSetQueryFormat(rpmgi gi, const char * queryFormat)
if (gi != NULL) {
gi->queryFormat = _free(gi->queryFormat);
- gi->queryFormat = xstrdup(queryFormat);
+ gi->queryFormat = (queryFormat != NULL ? xstrdup(queryFormat) : NULL);
}
return rc;
diff --git a/lib/rpmgi.h b/lib/rpmgi.h
index 5a7e1c22c..269c29f74 100644
--- a/lib/rpmgi.h
+++ b/lib/rpmgi.h
@@ -42,6 +42,9 @@ struct rpmgi_s {
/*@dependent@*/
rpmdbMatchIterator mi;
+/*@refcounted@*/
+ FD_t fd;
+
/*@only@*/
const char * queryFormat;