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"
28 int main(int argc, char *argv[])
30 struct openpgp_packet_list *packets = NULL;
31 struct openpgp_publickey *keys = NULL;
33 struct buffer_ctx ctx;
37 memset(&ctx, 0, sizeof(ctx));
39 params = getcgivars(argc, argv);
40 for (i = 0; params != NULL && params[i] != NULL; i += 2) {
41 if (!strcmp(params[i], "keytext")) {
42 ctx.buffer = params[i+1];
43 ctx.size = strlen(ctx.buffer);
56 start_html("onak : Add");
57 if (ctx.buffer == NULL) {
58 puts("Error: No keytext to add supplied.");
62 initlogthing("add", config.logfile);
63 dearmor_openpgp_stream(buffer_fetchchar,
66 if (packets != NULL) {
67 count = parse_keys(packets, &keys);
68 logthing(LOGTHING_NOTICE, "Received %d keys.",
70 printf("Storing %d keys.\n", count);
77 count = cleankeys(keys);
78 logthing(LOGTHING_INFO, "%d keys cleaned.",
81 count = update_keys(&keys);
82 logthing(LOGTHING_NOTICE, "Got %d new keys.",
91 puts("No OpenPGP packets found in input.");
97 return (EXIT_SUCCESS);