Rip unnecessary headerDump() and the last ancient artifacts using it

- xml format dump gives an output that can actually be further processed
This commit is contained in:
Panu Matilainen 2009-09-10 14:14:49 +03:00
parent ec8f057f64
commit 5327ac46e5
5 changed files with 1 additions and 241 deletions

View File

@ -125,11 +125,7 @@ rpmgraph_LDADD = lib/librpm.la
dist_bin_SCRIPTS = scripts/gendiff
check_PROGRAMS = dumpdb
dumpdb_SOURCES = tools/dumpdb.c
dumpdb_LDADD = lib/librpm.la
check_PROGRAMS += rpminject
check_PROGRAMS = rpminject
rpminject_SOURCES = tools/rpminject.c
rpminject_LDADD = build/librpmbuild.la

View File

@ -17,138 +17,6 @@ uint64_t htonll( uint64_t n ) {
return n;
}
void headerDump(Header h, FILE *f, int flags)
{
int i;
indexEntry p;
const char * tag;
const char * type;
/* First write out the length of the index (count of index entries) */
fprintf(f, "Entry count: %d\n", h->indexUsed);
/* Now write the index */
p = h->index;
fprintf(f, "\n CT TAG TYPE "
" OFSET COUNT\n");
for (i = 0; i < h->indexUsed; i++) {
switch (p->info.type) {
case RPM_NULL_TYPE:
type = "NULL";
break;
case RPM_CHAR_TYPE:
type = "CHAR";
break;
case RPM_BIN_TYPE:
type = "BIN";
break;
case RPM_INT8_TYPE:
type = "INT8";
break;
case RPM_INT16_TYPE:
type = "INT16";
break;
case RPM_INT32_TYPE:
type = "INT32";
break;
case RPM_INT64_TYPE:
type = "INT64";
break;
case RPM_STRING_TYPE:
type = "STRING";
break;
case RPM_STRING_ARRAY_TYPE:
type = "STRING_ARRAY";
break;
case RPM_I18NSTRING_TYPE:
type = "I18N_STRING";
break;
default:
type = "(unknown)";
break;
}
tag = rpmTagGetName(p->info.tag);
fprintf(f, "Entry : %3.3d (%d)%-14s %-18s 0x%.8x %.8d\n", i,
p->info.tag, tag, type, (unsigned) p->info.offset,
(int) p->info.count);
if (flags & HEADER_DUMP_INLINE) {
char *dp = p->data;
int c = p->info.count;
int ct = 0;
/* Print the data inline */
switch (p->info.type) {
case RPM_INT32_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%08x (%d)\n", ct++,
(unsigned) *((int32_t *) dp),
(int) *((int32_t *) dp));
dp += sizeof(int32_t);
}
break;
case RPM_INT16_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%04x (%d)\n", ct++,
(unsigned) (*((int16_t *) dp) & 0xffff),
(int) *((int16_t *) dp));
dp += sizeof(int16_t);
}
break;
case RPM_INT8_TYPE:
while (c--) {
fprintf(f, " Data: %.3d 0x%02x (%d)\n", ct++,
(unsigned) (*((int8_t *) dp) & 0xff),
(int) *((int8_t *) dp));
dp += sizeof(int8_t);
}
break;
case RPM_BIN_TYPE:
while (c > 0) {
fprintf(f, " Data: %.3d ", ct);
while (c--) {
fprintf(f, "%02x ", (unsigned) (*(int8_t *)dp & 0xff));
ct++;
dp += sizeof(int8_t);
if (! (ct % 8)) {
break;
}
}
fprintf(f, "\n");
}
break;
case RPM_CHAR_TYPE:
while (c--) {
char ch = (char) *((char *) dp);
fprintf(f, " Data: %.3d 0x%2x %c (%d)\n", ct++,
(unsigned)(ch & 0xff),
(isprint(ch) ? ch : ' '),
(int) *((char *) dp));
dp += sizeof(char);
}
break;
case RPM_STRING_TYPE:
case RPM_STRING_ARRAY_TYPE:
case RPM_I18NSTRING_TYPE:
while (c--) {
fprintf(f, " Data: %.3d %s\n", ct++, (char *) dp);
dp = strchr(dp, 0);
dp++;
}
break;
default:
fprintf(stderr, _("Data type %d not supported\n"),
(int) p->info.type);
break;
}
}
p++;
}
}
/*
* Backwards compatibility wrappers for legacy interfaces.
* Remove these some day...

View File

@ -124,15 +124,6 @@ int headerGetRawEntry(Header h, rpmTag tag,
rpm_data_t * p,
rpm_count_t * c);
/** \ingroup header
* Dump a header in human readable format (for debugging).
* @param h header
* @param f file handle
* @param flags 0 or HEADER_DUMP_INLINE
*/
void headerDump(Header h, FILE *f, int flags);
#define HEADER_DUMP_INLINE 1
#ifdef __cplusplus
}
#endif

View File

@ -1,36 +0,0 @@
#include "system.h"
const char *__progname;
#include "lib/header_internal.h"
#include "debug.h"
int main(int argc, char *argv[])
{
Header h;
FD_t fdi;
setprogname(argv[0]); /* Retrofit glibc __progname */
if (argc == 1) {
fdi = Fopen("-", "r.ufdio");
} else {
fdi = Fopen(argv[1], "r.ufdio");
}
if (Ferror(fdi)) {
fprintf(stderr, "cannot open %s: %s\n",
(argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
exit(EXIT_FAILURE);
}
h = headerRead(fdi, HEADER_MAGIC_YES);
if (!h) {
fprintf(stderr, "headerRead error: %s\n", Fstrerror(fdi));
exit(EXIT_FAILURE);
}
Fclose(fdi);
headerDump(h, stdout, HEADER_DUMP_INLINE, rpmTagTable);
h = headerFree(h);
return 0;
}

View File

@ -1,59 +0,0 @@
#include "system.h"
const char *__progname;
#include "lib/header_internal.h"
#include <rpm/rpmtag.h>
#include <rpm/rpmlib.h> /* rpmReadConfigFiles */
#include <rpm/rpmdb.h>
#include "debug.h"
int main(int argc, char *argv[])
{
unsigned int dspBlockNum = 0; /* default to all */
rpmdb db;
setprogname(argv[0]); /* Retrofit glibc __progname */
rpmReadConfigFiles(NULL, NULL);
if (argc == 2) {
dspBlockNum = atoi(argv[1]);
} else if (argc != 1) {
fprintf(stderr, "dumpdb <block num>\n");
exit(1);
}
if (rpmdbOpen("", &db, O_RDONLY, 0644)) {
fprintf(stderr, "cannot open Packages\n");
exit(1);
}
{ Header h = NULL;
unsigned int blockNum = 0;
rpmdbMatchIterator mi;
#define _RECNUM rpmdbGetIteratorOffset(mi)
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
while ((h = rpmdbNextIterator(mi)) != NULL) {
blockNum++;
if (!(dspBlockNum != 0 && dspBlockNum != blockNum))
continue;
headerDump(h, stdout, HEADER_DUMP_INLINE);
fprintf(stdout, "Offset: %d\n", _RECNUM);
if (dspBlockNum && blockNum > dspBlockNum)
exit(0);
}
mi = rpmdbFreeIterator(mi);
}
rpmdbClose(db);
return 0;
}