2 * add.c - CGI to add keys.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
17 #include "charfuncs.h"
20 #include "keystructs.h"
24 #include "onak-conf.h"
27 int main(int argc, char *argv[])
29 struct openpgp_packet_list *packets = NULL;
30 struct openpgp_publickey *keys = NULL;
32 struct buffer_ctx ctx;
36 memset(&ctx, 0, sizeof(ctx));
38 params = getcgivars(argc, argv);
39 for (i = 0; params != NULL && params[i] != NULL; i += 2) {
40 if (!strcmp(params[i], "keytext")) {
41 ctx.buffer = params[i+1];
42 ctx.size = strlen(ctx.buffer);
55 start_html("onak : Add");
56 if (ctx.buffer == NULL) {
57 puts("Error: No keytext to add supplied.");
61 initlogthing("add", config.logfile);
62 dearmor_openpgp_stream(buffer_fetchchar,
65 if (packets != NULL) {
66 count = parse_keys(packets, &keys);
67 logthing(LOGTHING_NOTICE, "Received %d keys.",
69 printf("Storing %d keys.\n", count);
76 count = cleankeys(keys);
77 logthing(LOGTHING_INFO, "%d keys cleaned.",
80 count = update_keys(&keys, true);
81 logthing(LOGTHING_NOTICE, "Got %d new keys.",
91 puts("No OpenPGP packets found in input.");
97 return (EXIT_SUCCESS);