lets you query a package by record number
authorewt <devnull@localhost>
Fri, 1 Mar 1996 03:29:18 +0000 (03:29 +0000)
committerewt <devnull@localhost>
Fri, 1 Mar 1996 03:29:18 +0000 (03:29 +0000)
CVS patchset: 448
CVS date: 1996/03/01 03:29:18

query.c

diff --git a/query.c b/query.c
index 6b4a817..48617eb 100644 (file)
--- a/query.c
+++ b/query.c
@@ -1,3 +1,4 @@
+#include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -295,6 +296,7 @@ void doQuery(char * prefix, enum querysources source, int queryFlags,
     int isSource;
     rpmdb db;
     dbIndexSet matches;
+    int recNumber;
 
     if (source != QUERY_SRPM && source != QUERY_RPM) {
        if (rpmdbOpen(prefix, &db, O_RDONLY, 0644)) {
@@ -359,14 +361,27 @@ void doQuery(char * prefix, enum querysources source, int queryFlags,
 
       case QUERY_SPACKAGE:
       case QUERY_PACKAGE:
-       rc = findPackageByLabel(db, arg, &matches);
-       if (rc == 1) 
-           fprintf(stderr, "package %s is not installed\n", arg);
-       else if (rc == 2) {
-           fprintf(stderr, "error looking for package %s\n", arg);
+       if (isdigit(arg[0])) {
+           recNumber = atoi(arg);
+           message(MESS_DEBUG, "showing package: %d\n", recNumber);
+           h = rpmdbGetRecord(db, recNumber);
+
+           if (!h) 
+               fprintf(stderr, "record %d could not be read\n", recNumber);
+           else {
+               printHeader(h, queryFlags);
+               freeHeader(h);
+           }
        } else {
-           showMatches(db, matches, queryFlags);
-           freeDBIndexRecord(matches);
+           rc = findPackageByLabel(db, arg, &matches);
+           if (rc == 1) 
+               fprintf(stderr, "package %s is not installed\n", arg);
+           else if (rc == 2) {
+               fprintf(stderr, "error looking for package %s\n", arg);
+           } else {
+               showMatches(db, matches, queryFlags);
+               freeDBIndexRecord(matches);
+           }
        }
        break;
     }