X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=add.c;h=d820b528fe30b5b1011e7246a334fec67679223a;hb=8e58a1769ce5e492dd68904dfc81b6e077fc2a3a;hp=323373b36232e82de391a7e8782493e866caf1bf;hpb=4b8483ae278577a3adc8d84da81d77019704466f;p=onak.git diff --git a/add.c b/add.c index 323373b..d820b52 100644 --- a/add.c +++ b/add.c @@ -16,6 +16,7 @@ #include "keydb.h" #include "keystructs.h" #include "parsekey.h" +#include "merge.h" struct cgi_get_ctx { char *buffer; @@ -23,13 +24,15 @@ struct cgi_get_ctx { }; -int cgi_getchar(void *ctx, unsigned char *c) +int cgi_getchar(void *ctx, size_t count, unsigned char *c) { struct cgi_get_ctx *buf = NULL; buf = (struct cgi_get_ctx *) ctx; - *c = buf->buffer[buf->offset++]; + while (count-- > 0 && *c != 0) { + *c = buf->buffer[buf->offset++]; + } return (*c == 0); } @@ -38,7 +41,6 @@ int main(int argc, char *argv[]) { struct openpgp_packet_list *packets = NULL; struct openpgp_publickey *keys = NULL; - struct openpgp_publickey *curkey = NULL; char **params = NULL; struct cgi_get_ctx ctx; int i; @@ -52,8 +54,6 @@ int main(int argc, char *argv[]) } } -// puts("HTTP/1.0 200 OK"); -// puts("Server: onak 0.0.1"); puts("Content-Type: text/html\n"); puts("onak : Add"); if (ctx.buffer == NULL) { @@ -64,18 +64,10 @@ int main(int argc, char *argv[]) &packets); if (packets != NULL) { parse_keys(packets, &keys); - curkey = keys; initdb(); - while (curkey != NULL) { - if (store_key(curkey)) { -// puts("Key added successfully."); - } else { - printf("Problem adding key '%s'.\n", strerror(errno)); - } - curkey = curkey->next; - } + printf("Got %d new keys.\n", + update_keys(&keys)); cleanupdb(); - puts("Keys added."); } else { puts("No OpenPGP packets found in input."); }