From: jbj Date: Tue, 15 Jun 2004 15:12:04 +0000 (+0000) Subject: Common signature/header data spew. X-Git-Tag: tznext/4.11.0.1.tizen20130304~6433 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64948579f6875faf51f0453ec8b85f329a5824a4;p=tools%2Flibrpm-tizen.git Common signature/header data spew. CVS patchset: 7336 CVS date: 2004/06/15 15:12:04 --- 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;