2 * splitkeys.c - Split a keyring into smaller chunks.
4 * Copyright 2003 Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <https://www.gnu.org/licenses/>.
22 #include <sys/types.h>
25 #include "charfuncs.h"
26 #include "keystructs.h"
31 int main(int argc, char *argv[])
33 struct openpgp_packet_list *packets = NULL;
34 struct openpgp_packet_list *list_end = NULL;
35 struct openpgp_packet_list *tmp = NULL;
42 maxkeys = atoi(argv[1]);
45 "Couldn't parse %s as a number of keys!\n",
52 read_openpgp_stream(stdin_getchar, NULL,
54 if (packets != NULL) {
56 while (list_end->next != NULL) {
58 list_end = list_end->next;
59 if (list_end->next == NULL &&
60 list_end->packet->tag ==
61 OPENPGP_PACKET_PUBLICKEY) {
65 if (tmp != NULL && tmp->next != NULL) {
69 snprintf(splitfile, 1023, "splitfile-%d.pgp", count);
70 outfd = open(splitfile, O_WRONLY | O_CREAT, 0664);
71 write_openpgp_stream(file_putchar, &outfd,
74 free_packet_list(packets);
78 } while (packets != NULL);