2  * add.c - CGI to add keys.
 
   4  * Jonathan McDowell <noodles@earth.li>
 
   6  * Copyright 2002 Project Purple
 
  17 #include "keystructs.h"
 
  27 int cgi_getchar(void *ctx, size_t count, unsigned char *c)
 
  29         struct cgi_get_ctx *buf = NULL;
 
  31         buf = (struct cgi_get_ctx *) ctx;
 
  33         while (count-- > 0 && *c != 0) {
 
  34                 *c = buf->buffer[buf->offset++];
 
  40 int main(int argc, char *argv[])
 
  42         struct openpgp_packet_list *packets = NULL;
 
  43         struct openpgp_publickey *keys = NULL;
 
  45         struct cgi_get_ctx ctx;
 
  48         memset(&ctx, 0, sizeof(ctx));
 
  50         params = getcgivars(argc, argv);
 
  51         for (i = 0; params != NULL && params[i] != NULL; i += 2) {
 
  52                 if (!strcmp(params[i], "keytext")) {
 
  53                         ctx.buffer = params[i+1];
 
  66         start_html("onak : Add");
 
  67         if (ctx.buffer == NULL) {
 
  68                 puts("Error: No keytext to add supplied.");
 
  70                 dearmor_openpgp_stream(cgi_getchar,
 
  73                 if (packets != NULL) {
 
  74                         parse_keys(packets, &keys);
 
  76                         printf("Got %d new keys.\n",
 
  77                                         update_keys(&keys, false));
 
  80                         puts("No OpenPGP packets found in input.");
 
  84         return (EXIT_SUCCESS);