~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to tools/rpmheader.c

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* rpmheader: spit out the header portion of a package */
 
2
 
 
3
#include "system.h"
 
4
 
 
5
#include "header.h"
 
6
#include "rpmlead.h"
 
7
#include "signature.h"
 
8
#include "debug.h"
 
9
 
 
10
int main(int argc, char **argv)
 
11
{
 
12
    FD_t fdi, fdo;
 
13
    struct rpmlead lead;
 
14
    Header hd;
 
15
    int rc;
 
16
    
 
17
    setprogname(argv[0]);       /* Retrofit glibc __progname */
 
18
    if (argc == 1) {
 
19
        fdi = Fopen("-", "r.ufdio");
 
20
    } else {
 
21
        fdi = Fopen(argv[1], "r.ufdio");
 
22
    }
 
23
 
 
24
    if (Ferror(fdi)) {
 
25
        fprintf(stderr, "%s: %s: %s\n", argv[0],
 
26
                (argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
 
27
        exit(EXIT_FAILURE);
 
28
    }
 
29
 
 
30
    readLead(fdi, &lead);
 
31
    rpmReadSignature(fdi, NULL, lead.signature_type);
 
32
    hd = headerRead(fdi, (lead.major >= 3) ?
 
33
                    HEADER_MAGIC_YES : HEADER_MAGIC_NO);
 
34
    fdo = Fopen("-", "w.ufdio");
 
35
    rc = headerWrite(fdo, hd, HEADER_MAGIC_YES);
 
36
    
 
37
    return rc;
 
38
}