Common signature/header data spew.
authorjbj <devnull@localhost>
Tue, 15 Jun 2004 15:12:04 +0000 (15:12 +0000)
committerjbj <devnull@localhost>
Tue, 15 Jun 2004 15:12:04 +0000 (15:12 +0000)
CVS patchset: 7336
CVS date: 2004/06/15 15:12:04

tools/Makefile.am
tools/rpmtool.c

index a932b1b..dc029b2 100644 (file)
@@ -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
index bfcedc0..5149c89 100644 (file)
@@ -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;