Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# rpmheader.c

Go to the documentation of this file.

    00001 /* rpmheader: spit out the header portion of a package */
    00002
    00003 #include "system.h"
    00004
    00005 #include "header.h"
    00006 #include "rpmlead.h"
    00007 #include "signature.h"
    00008 #include "debug.h"
    00009
    00010 int main(int argc, char **argv)
    00011 {
    00012     FD_t fdi, fdo;
    00013     struct rpmlead lead;
    00014     Header hd;
    00015     int rc;
    00016
    00017     setprogname(argv[0]);       /* Retrofit glibc __progname */
    00018     if (argc == 1) {
    00019         fdi = Fopen("-", "r.ufdio");
    00020     } else {
    00021         fdi = Fopen(argv[1], "r.ufdio");
    00022     }
    00023
    00024     if (Ferror(fdi)) {
    00025         fprintf(stderr, "%s: %s: %s\n", argv[0],
    00026                 (argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
    00027         exit(EXIT_FAILURE);
    00028     }
    00029
    00030     readLead(fdi, &lead);
    00031     rpmReadSignature(fdi, NULL, lead.signature_type);
    00032     hd = headerRead(fdi, (lead.major >= 3) ?
    00033                     HEADER_MAGIC_YES : HEADER_MAGIC_NO);
    00034     fdo = Fopen("-", "w.ufdio");
    00035     rc = headerWrite(fdo, hd, HEADER_MAGIC_YES);
    00036
    00037     return rc;
    00038 }