root/openpgpsdk/trunk/examples/verify.c

Revision 452 (checked in by ben, 6 years ago)

Improve workingness of tests.

Line 
1 #include <openpgpsdk/packet.h>
2 #include <openpgpsdk/packet-parse.h>
3 #include <openpgpsdk/util.h>
4 #include <openpgpsdk/accumulate.h>
5 #include <openpgpsdk/keyring.h>
6 #include <openpgpsdk/validate.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <fcntl.h>
10
11 #include <openpgpsdk/final.h>
12
13 int main(int argc,char **argv)
14     {
15     ops_parse_info_t *pinfo;
16     ops_keyring_t keyring;
17     const char *target;
18     int fd;
19
20     if(argc != 2)
21         {
22         fprintf(stderr,"%s <file to verify>\n",argv[0]);
23         exit(1);
24         }
25
26     target=argv[1];
27
28     ops_init();
29
30     memset(&keyring,'\0',sizeof keyring);
31
32     pinfo=ops_parse_info_new();
33
34     if(!strcmp(target,"-"))
35         fd=0;
36     else
37         {
38         fd=open(target,O_RDONLY);
39         if(fd < 0)
40             {
41             perror(target);
42             exit(2);
43             }
44         }
45
46     ops_reader_set_fd(pinfo,fd);
47
48     ops_parse_and_accumulate(&keyring,pinfo);
49
50     ops_dump_keyring(&keyring);
51
52     ops_validate_all_signatures(&keyring);
53
54     ops_keyring_free(&keyring);
55
56     ops_finish();
57
58     return 0;
59     }
Note: See TracBrowser for help on using the browser.