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.1 2003/09/30 21:16:14 noodles Exp $
14 #include <sys/types.h>
17 #include "charfuncs.h"
18 #include "keystructs.h"
22 int main(int argc, char *argv[])
24 struct openpgp_packet_list *packets = NULL;
25 struct openpgp_packet_list *list_end = NULL;
26 struct openpgp_packet_list *tmp = NULL;
34 maxkeys = atoi(argv[1]);
37 "Couldn't parse %s as a number of keys!\n",
44 result = read_openpgp_stream(stdin_getchar, NULL,
46 if (packets != NULL) {
48 while (list_end->next != NULL) {
50 list_end = list_end->next;
51 if (list_end->next == NULL &&
52 list_end->packet->tag == 6) {
57 snprintf(splitfile, 1023, "splitfile-%d.pgp", count);
58 outfd = open(splitfile, O_WRONLY | O_CREAT, 0664);
59 write_openpgp_stream(file_putchar, &outfd,
62 free_packet_list(packets);
66 } while (packets != NULL);