Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

tools/dumpdb.c

Go to the documentation of this file.
00001 #include "system.h"
00002 
00003 #include "rpmlib.h"
00004 #include "debug.h"
00005 
00006 int main(int argc, char ** argv)
00007 {
00008     unsigned int dspBlockNum = 0;               /* default to all */
00009     rpmdb db;
00010 
00011     setprogname(argv[0]);       /* Retrofit glibc __progname */
00012     rpmReadConfigFiles(NULL, NULL);
00013 
00014     if (argc == 2) {
00015         dspBlockNum = atoi(argv[1]);
00016     } else if (argc != 1) {
00017         fprintf(stderr, _("dumpdb <block num>\n"));
00018         exit(1);
00019     }
00020 
00021     if (rpmdbOpen("", &db, O_RDONLY, 0644)) {
00022         fprintf(stderr, _("cannot open /var/lib/rpm/packages.rpm\n"));
00023         exit(1);
00024     }
00025 
00026     {   Header h = NULL;
00027         unsigned int blockNum = 0;
00028         rpmdbMatchIterator mi;
00029 #define _RECNUM rpmdbGetIteratorOffset(mi)
00030 
00031         mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
00032 
00033         while ((h = rpmdbNextIterator(mi)) != NULL) {
00034 
00035             blockNum++;
00036             if (!(dspBlockNum != 0 && dspBlockNum != blockNum))
00037                 continue;
00038 
00039             headerDump(h, stdout, 1, rpmTagTable);
00040             fprintf(stdout, "Offset: %d\n", _RECNUM);
00041     
00042             if (dspBlockNum && blockNum > dspBlockNum)
00043                 exit(0);
00044         }
00045 
00046         rpmdbFreeIterator(mi);
00047 
00048     }
00049 
00050     rpmdbClose(db);
00051 
00052     return 0;
00053 }

Generated at Sun Apr 8 18:43:02 2001 for rpm by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000