2 * keymerge.c - Takes a key on stdin, merges it and outputs the difference.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
15 #include "keystructs.h"
20 int stdin_getchar(void *ctx, unsigned char *c)
28 int stdout_putchar(void *ctx, unsigned char c)
34 int main(int argc, char *argv[])
36 struct openpgp_packet_list *packets = NULL;
37 struct openpgp_packet_list *list_end = NULL;
38 struct openpgp_publickey *keys = NULL;
39 struct openpgp_publickey *prev = NULL;
40 struct openpgp_publickey *curkey = NULL;
41 struct openpgp_publickey *oldkey = NULL;
43 int rc = EXIT_SUCCESS;
45 dearmor_openpgp_stream(stdin_getchar, NULL, &packets);
46 parse_keys(packets, &keys);
47 free_packet_list(packets);
51 for (curkey = keys; curkey != NULL; curkey = curkey->next) {
52 fprintf(stderr, "Dealing with key.\n");
53 fprintf(stderr, "fetch_key: %d\n",
54 fetch_key(get_keyid(curkey), &oldkey));
57 * If we already have the key stored in the DB then merge it
58 * with the new one that's been supplied. Otherwise the key
59 * we've just got is the one that goes in the DB and also the
60 * one that we send out.
63 fprintf(stderr, "merge_keys: %d\n",
64 merge_keys(oldkey, curkey));
65 if (curkey->revocations == NULL &&
66 curkey->uids == NULL &&
67 curkey->subkeys == NULL) {
68 fprintf(stderr, "No new info.\n");
72 prev->next = curkey->next;
78 /* TODO: store_key(oldkey); */
79 free_publickey(oldkey);
89 flatten_publickey(keys, &packets, &list_end);
93 armor_openpgp_stream(stdout_putchar, NULL, packets);
94 free_packet_list(packets);