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

# tools/rpmarchive.c

Go to the documentation of this file.

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