1 | #include "system.h" |
---|
2 | #include "rpmio_internal.h" |
---|
3 | #include "popt.h" |
---|
4 | #include "debug.h" |
---|
5 | |
---|
6 | static int printing = 1; |
---|
7 | static int _debug = 0; |
---|
8 | |
---|
9 | static struct poptOption optionsTable[] = { |
---|
10 | { "print", 'p', POPT_ARG_VAL, &printing, 1, NULL, NULL }, |
---|
11 | { "noprint", 'n', POPT_ARG_VAL, &printing, 0, NULL, NULL }, |
---|
12 | { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, |
---|
13 | POPT_AUTOHELP |
---|
14 | POPT_TABLEEND |
---|
15 | }; |
---|
16 | |
---|
17 | int |
---|
18 | main (int argc, const char *argv[]) |
---|
19 | { |
---|
20 | poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0); |
---|
21 | pgpDig dig; |
---|
22 | const byte * pkt = NULL; |
---|
23 | ssize_t pktlen; |
---|
24 | const char ** args; |
---|
25 | const char * fn; |
---|
26 | int rc, ec = 0; |
---|
27 | |
---|
28 | while ((rc = poptGetNextOpt(optCon)) > 0) |
---|
29 | ; |
---|
30 | |
---|
31 | if ((args = poptGetArgs(optCon)) != NULL) |
---|
32 | while ((fn = *args++) != NULL) { |
---|
33 | pgpArmor pa; |
---|
34 | pa = pgpReadPkts(fn, &pkt, &pktlen); |
---|
35 | if (pa == PGPARMOR_ERROR |
---|
36 | || pa == PGPARMOR_NONE |
---|
37 | || pkt == NULL || pktlen <= 0) |
---|
38 | { |
---|
39 | ec++; |
---|
40 | continue; |
---|
41 | } |
---|
42 | |
---|
43 | fprintf(stderr, "===================== %s\n", fn); |
---|
44 | dig = xcalloc(1, sizeof(*dig)); |
---|
45 | (void) pgpPrtPkts(pkt, pktlen, dig, printing); |
---|
46 | free((void *)pkt); |
---|
47 | pkt = NULL; |
---|
48 | free((void *)dig); |
---|
49 | dig = NULL; |
---|
50 | } |
---|
51 | |
---|
52 | return ec; |
---|
53 | } |
---|