2 * splitkeys.c - Split a keyring into smaller chunks.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2003 Project Purple
8 * $Id: splitkeys.c,v 1.2 2003/10/03 23:03:02 noodles Exp $
14 #include <sys/types.h>
17 #include "charfuncs.h"
18 #include "keystructs.h"
21 #include "onak-conf.h"
24 int main(int argc, char *argv[])
26 struct openpgp_packet_list *packets = NULL;
27 struct openpgp_packet_list *list_end = NULL;
28 struct openpgp_packet_list *tmp = NULL;
36 maxkeys = atoi(argv[1]);
39 "Couldn't parse %s as a number of keys!\n",
46 initlogthing("splitkeys", config.logfile);
49 result = read_openpgp_stream(stdin_getchar, NULL,
51 if (packets != NULL) {
53 while (list_end->next != NULL) {
55 list_end = list_end->next;
56 if (list_end->next == NULL &&
57 list_end->packet->tag == 6) {
62 snprintf(splitfile, 1023, "splitfile-%d.pgp", count);
63 outfd = open(splitfile, O_WRONLY | O_CREAT, 0664);
64 write_openpgp_stream(file_putchar, &outfd,
67 free_packet_list(packets);
71 } while (packets != NULL);