summaryrefslogtreecommitdiff
path: root/tools/dump.c
blob: b3243da6f38069a7f455a7994c37ae2d238680da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "system.h"
const char *__progname;

#include "rpmdb/header_internal.h"
#include "debug.h"

int main(int argc, char *argv[])
{
    Header h;
    FD_t fdi;

    setprogname(argv[0]);	/* Retrofit glibc __progname */
    if (argc == 1) {
	fdi = Fopen("-", "r.ufdio");
    } else {
	fdi = Fopen(argv[1], "r.ufdio");
    }

    if (Ferror(fdi)) {
	fprintf(stderr, _("cannot open %s: %s\n"),
		(argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
	exit(EXIT_FAILURE);
    }

    h = headerRead(fdi, HEADER_MAGIC_YES);
    if (!h) {
	fprintf(stderr, _("headerRead error: %s\n"), Fstrerror(fdi));
	exit(EXIT_FAILURE);
    }
    Fclose(fdi);
  
    headerDump(h, stdout, HEADER_DUMP_INLINE, rpmTagTable);
    h = headerFree(h);

    return 0;
}