2 * add.c - CGI to add keys.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
8 * $Id: add.c,v 1.15 2004/05/31 14:16:49 noodles Exp $
18 #include "charfuncs.h"
21 #include "keystructs.h"
25 #include "onak-conf.h"
29 int main(int argc, char *argv[])
31 struct openpgp_packet_list *packets = NULL;
32 struct openpgp_publickey *keys = NULL;
34 struct buffer_ctx ctx;
38 memset(&ctx, 0, sizeof(ctx));
40 params = getcgivars(argc, argv);
41 for (i = 0; params != NULL && params[i] != NULL; i += 2) {
42 if (!strcmp(params[i], "keytext")) {
43 ctx.buffer = params[i+1];
44 ctx.size = strlen(ctx.buffer);
57 start_html("onak : Add");
58 if (ctx.buffer == NULL) {
59 puts("Error: No keytext to add supplied.");
63 initlogthing("add", config.logfile);
64 dearmor_openpgp_stream(buffer_fetchchar,
67 if (packets != NULL) {
68 printf("Storing %d keys.\n",
69 parse_keys(packets, &keys));
75 count = cleankeys(keys);
76 logthing(LOGTHING_INFO, "%d keys cleaned.",
79 count = update_keys(&keys);
80 printf("Got %d new keys.\n", count);
81 logthing(LOGTHING_NOTICE, "Got %d new keys.",
90 puts("No OpenPGP packets found in input.");
96 return (EXIT_SUCCESS);