lets you query a package by record number

CVS patchset: 448
CVS date: 1996/03/01 03:29:18
This commit is contained in:
ewt 1996-03-01 03:29:18 +00:00
parent 55134cf737
commit 1da80ad8a5
1 changed files with 22 additions and 7 deletions

29
query.c
View File

@ -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;
}