From 64948579f6875faf51f0453ec8b85f329a5824a4 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 15 Jun 2004 15:12:04 +0000 Subject: [PATCH] Common signature/header data spew. CVS patchset: 7336 CVS date: 2004/06/15 15:12:04 --- tools/Makefile.am | 4 ++-- tools/rpmtool.c | 67 +++++++++++++++++++++++++------------------------------ 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index a932b1b..dc029b2 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -19,7 +19,7 @@ INCLUDES = -I. \ EXTRA_DIST = rpminject.c rpmsort.c rpmxml.c rpmxp.c rpmxp.h hashtab.h -EXTRA_PROGRAMS = convertdb1 rpminject rpmsort +EXTRA_PROGRAMS = convertdb1 rpminject rpmsort rpmtool rpmxml LDADD = \ $(top_builddir)/lib/librpm.la \ @@ -27,7 +27,7 @@ LDADD = \ staticLDFLAGS = @LDFLAGS_STATIC@ @LDFLAGS_NPTL@ -noinst_PROGRAMS = rpmtool rpmxml dumpdb +noinst_PROGRAMS = dumpdb pkgbindir = @RPMCONFIGDIR@ pkgbin_PROGRAMS = debugedit javadeps rpmcache rpmdeps rpmfile diff --git a/tools/rpmtool.c b/tools/rpmtool.c index bfcedc0..5149c89 100644 --- a/tools/rpmtool.c +++ b/tools/rpmtool.c @@ -246,6 +246,30 @@ static void initTool(const char * argv0) } } +static void spewHeader(FD_t fdo, Header h) +{ + headerTagTableEntry tbl = (headerIsEntry(h, RPMTAG_HEADERI18NTABLE)) + ? rpmTagTable : rpmSTagTable; + + if (obits & RPMIOBITS_DUMP) { + headerDump(h, stdout, HEADER_DUMP_INLINE, tbl); + } else if (obits & RPMIOBITS_XML) { + const char * errstr = NULL; + const char * fmt = "[%{*:xml}\n]"; + char * t; + + t = headerSprintf(h, fmt, tbl, rpmHeaderFormats, &errstr); + + if (t != NULL) { + if (rpmxpDTD != NULL && *rpmxpDTD != '\0') + Fwrite(rpmxpDTD, strlen(rpmxpDTD), 1, fdo); + Fwrite(t, strlen(t), 1, fdo); + } + t = _free(t); + } else + headerWrite(fdo, h, HEADER_MAGIC_YES); +} + int main(int argc, char *const argv[]) { @@ -402,45 +426,14 @@ fprintf(stderr, "*** Fopen(%s,%s)\n", (ofn != NULL ? ofn : "-"), omode); if (obits & RPMIOBITS_LEAD) writeLead(fdo, &lead); - if (obits & RPMIOBITS_SHEADER) { - if (obits & RPMIOBITS_DUMP) { - headerDump(sigh, stdout, HEADER_DUMP_INLINE, rpmSTagTable); - } else if (obits & RPMIOBITS_XML) { - const char * errstr = NULL; + if (obits & RPMIOBITS_SHEADER) + spewHeader(fdo, sigh); - s = "[%{*:xml}\n]"; - t = headerSprintf(sigh, s, rpmSTagTable, rpmHeaderFormats, &errstr); - - if (t != NULL) { - if (rpmxpDTD != NULL && *rpmxpDTD != '\0') - Fwrite(rpmxpDTD, strlen(rpmxpDTD), 1, fdo); - Fwrite(t, strlen(t), 1, fdo); - } - t = _free(t); - } else - headerWrite(fdo, sigh, HEADER_MAGIC_YES); - } - - if (obits & RPMIOBITS_HEADER) { - if (obits & RPMIOBITS_DUMP) { - headerDump(h, stdout, HEADER_DUMP_INLINE, rpmTagTable); - } else if (obits & RPMIOBITS_XML) { - const char * errstr = NULL; - - s = "[%{*:xml}\n]"; - t = headerSprintf(h, s, rpmTagTable, rpmHeaderFormats, &errstr); - - if (t != NULL) { - if (rpmxpDTD != NULL && *rpmxpDTD != '\0') - Fwrite(rpmxpDTD, strlen(rpmxpDTD), 1, fdo); - Fwrite(t, strlen(t), 1, fdo); - } - t = _free(t); - } else - headerWrite(fdo, h, HEADER_MAGIC_YES); - } + if (obits & RPMIOBITS_HEADER) + spewHeader(fdo, h); - if (obits & RPMIOBITS_PAYLOAD) { + if (obits & RPMIOBITS_PAYLOAD) + { if (obits & RPMIOBITS_UNCOMPRESS) { const char * payload_compressor = NULL; const char * rpmio_flags; -- 2.7.4