2 * add.c - CGI to add keys.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
8 * $Id: add.c,v 1.14 2004/05/26 21:20:05 noodles Exp $
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 printf("Storing %d keys.\n",
68 parse_keys(packets, &keys));
73 count = update_keys(&keys);
74 printf("Got %d new keys.\n", count);
75 logthing(LOGTHING_NOTICE, "Got %d new keys.",
84 puts("No OpenPGP packets found in input.");
90 return (EXIT_SUCCESS);