From 5327ac46e53205bf5f5adc83d2487e77d6e44851 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 10 Sep 2009 14:14:49 +0300 Subject: [PATCH] Rip unnecessary headerDump() and the last ancient artifacts using it - xml format dump gives an output that can actually be further processed --- Makefile.am | 6 +-- lib/header_internal.c | 132 -------------------------------------------------- lib/header_internal.h | 9 ---- tools/dump.c | 36 -------------- tools/dumpdb.c | 59 ---------------------- 5 files changed, 1 insertion(+), 241 deletions(-) delete mode 100644 tools/dump.c delete mode 100644 tools/dumpdb.c diff --git a/Makefile.am b/Makefile.am index aa87b8c..70b2501 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/lib/header_internal.c b/lib/header_internal.c index 44673ed..382d898 100644 --- a/lib/header_internal.c +++ b/lib/header_internal.c @@ -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... diff --git a/lib/header_internal.h b/lib/header_internal.h index c9cecf1..8223e30 100644 --- a/lib/header_internal.h +++ b/lib/header_internal.h @@ -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 diff --git a/tools/dump.c b/tools/dump.c deleted file mode 100644 index 5877755..0000000 --- a/tools/dump.c +++ /dev/null @@ -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 ? "" : 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; -} diff --git a/tools/dumpdb.c b/tools/dumpdb.c deleted file mode 100644 index 04d55c9..0000000 --- a/tools/dumpdb.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "system.h" -const char *__progname; - -#include "lib/header_internal.h" - -#include -#include /* rpmReadConfigFiles */ -#include - -#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 \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; -} -- 2.7.4