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.3 2003/10/03 23:34:06 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) {
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);