cscvs to tla changeset 1
[onak.git] / main.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/uio.h>
4 #include <unistd.h>
5
6 #include "armor.h"
7 #include "keydb.h"
8 #include "keyid.h"
9 #include "keyindex.h"
10 #include "keystructs.h"
11 #include "parsekey.h"
12
13 int getnextchar(void *ctx, size_t count, unsigned char *c)
14 {
15         return (!read(0, c, count));
16 }
17
18 int putnextchar(void *ctx, unsigned char c)
19 {
20         return (!write(1, &c, 1));
21 }
22
23
24 int main(int argc, char *argv[])
25 {
26         struct openpgp_packet_list *packets = NULL, *newpackets = NULL;
27         struct openpgp_packet_list *list_end = NULL;
28         struct openpgp_publickey *keys = NULL;
29         struct openpgp_publickey *newkeys = NULL;
30         void *ctx = NULL;
31
32         fputs("Doing read_openpgp_stream():\n", stderr);
33         read_openpgp_stream(getnextchar, ctx, &packets);
34
35 //      fputs("Doing dearmor_openpgp_stream():\n", stderr);
36 //      dearmor_openpgp_stream(getnextchar, NULL, &packets);
37 //      fputs("Doing armor_openpgp_stream():\n", stderr);
38 //      armor_openpgp_stream(putnextchar, NULL, packets);
39
40         fputs("Doing parse_keys():\n", stderr);
41         parse_keys(packets, &keys);
42
43         printf("Key id is 0x%llX\n", get_keyid(keys));
44
45 //      key_index(keys, true, false, false);
46
47         initdb();
48         fetch_key(get_keyid(keys), &newkeys);
49         cleanupdb();
50
51         printf("New key id is 0x%llX\n", get_keyid(newkeys));
52
53 //      fputs("Doing flatten_publickey():\n", stderr);
54 //      flatten_publickey(keys, &newpackets, &list_end);
55
56 //      fputs("Doing write_openpgp_stream():\n", stderr);
57 //      write_openpgp_stream(putnextchar, ctx, newpackets);
58
59         return 0;
60 }