2 * splitkeys.c - Split a keyring into smaller chunks.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2003 Project Purple
12 #include <sys/types.h>
15 #include "charfuncs.h"
16 #include "keystructs.h"
19 #include "onak-conf.h"
23 int main(int argc, char *argv[])
25 struct openpgp_packet_list *packets = NULL;
26 struct openpgp_packet_list *list_end = NULL;
27 struct openpgp_packet_list *tmp = NULL;
35 maxkeys = atoi(argv[1]);
38 "Couldn't parse %s as a number of keys!\n",
45 initlogthing("splitkeys", config.logfile);
48 result = read_openpgp_stream(stdin_getchar, NULL,
50 if (packets != NULL) {
52 while (list_end->next != NULL) {
54 list_end = list_end->next;
55 if (list_end->next == NULL &&
56 list_end->packet->tag ==
57 OPENPGP_PACKET_PUBLICKEY) {
61 if (tmp->next != NULL) {
65 snprintf(splitfile, 1023, "splitfile-%d.pgp", count);
66 outfd = open(splitfile, O_WRONLY | O_CREAT, 0664);
67 write_openpgp_stream(file_putchar, &outfd,
70 free_packet_list(packets);
74 } while (packets != NULL);