From: Jonathan McDowell Date: Mon, 31 May 2004 23:48:04 +0000 (+0000) Subject: cscvs to tla changeset 107 X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/58d762ea573eb3cfea626bb52ea7a99e24b8a0aa cscvs to tla changeset 107 Author: noodles Date: 2003/10/04 10:21:40 Various minor code cleanups to reduce compiler warnings (especially with c99). --- diff --git a/bithelp.h b/bithelp.h index 200b036..76324b4 100644 --- a/bithelp.h +++ b/bithelp.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: bithelp.h,v 1.3 2003/06/04 20:57:07 noodles Exp $ + * $Id: bithelp.h,v 1.4 2003/10/04 10:21:40 noodles Exp $ */ #ifndef __BITHELP_H__ @@ -28,7 +28,7 @@ * @x: The integer to rotate. * @n: The number of bytes to rotate it by. */ -static inline unsigned int rol(int x, int n) +static inline unsigned int rol(unsigned int x, int n) { __asm__("roll %%cl,%0" :"=r" (x) diff --git a/charfuncs.c b/charfuncs.c index 52f1155..f509fc8 100644 --- a/charfuncs.c +++ b/charfuncs.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: charfuncs.c,v 1.3 2003/09/30 17:15:39 noodles Exp $ + * $Id: charfuncs.c,v 1.4 2003/10/04 10:21:40 noodles Exp $ */ #include @@ -24,7 +24,7 @@ int buffer_fetchchar(void *ctx, size_t count, unsigned char *c) { struct buffer_ctx *buf = NULL; - int i; + size_t i; buf = (struct buffer_ctx *) ctx; for (i = 0; i < count; i++) { @@ -48,7 +48,7 @@ int buffer_putchar(void *ctx, size_t count, unsigned char *c) { struct buffer_ctx *buf = NULL; size_t newsize = 0; - int i; + size_t i; buf = (struct buffer_ctx *) ctx; @@ -88,16 +88,7 @@ int file_putchar(void *fd, size_t count, unsigned char *c) */ int stdin_getchar(void *ctx, size_t count, unsigned char *c) { - int ic = 0; - - while ((count > 0) && (ic != EOF)) { - ic = getchar(); - *c = ic; - c++; - count--; - } - - return (ic == EOF); + return (fread(c, 1, count, stdin) != count); } /** @@ -105,10 +96,5 @@ int stdin_getchar(void *ctx, size_t count, unsigned char *c) */ int stdout_putchar(void *ctx, size_t count, unsigned char *c) { - int i; - - for (i = 0; i < count; i++) { - putchar(c[i]); - } - return 0; + return (fwrite(c, 1, count, stdout) != count); } diff --git a/charfuncs.h b/charfuncs.h index ffa7bf9..c5ee2a0 100644 --- a/charfuncs.h +++ b/charfuncs.h @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: charfuncs.h,v 1.3 2003/09/30 17:15:39 noodles Exp $ + * $Id: charfuncs.h,v 1.4 2003/10/04 10:21:40 noodles Exp $ */ #ifndef __CHARFUNCS_H__ @@ -21,8 +21,8 @@ */ struct buffer_ctx { char *buffer; - int offset; - int size; + size_t offset; + size_t size; }; /** diff --git a/hash.c b/hash.c index 9ee8b9b..03def74 100644 --- a/hash.c +++ b/hash.c @@ -5,7 +5,7 @@ * * Copyright 2000-2002 Project Purple * - * $Id: hash.c,v 1.8 2003/06/04 20:57:08 noodles Exp $ + * $Id: hash.c,v 1.9 2003/10/04 10:21:40 noodles Exp $ */ #include @@ -57,7 +57,7 @@ void destroyhash(void) * TODO: The problem is the object has pointers that * need freed too. */ - llfree(curll, free_statskey); + llfree(curll, (void (*)(void *)) free_statskey); hashtable[i] = NULL; } elements = 0; diff --git a/ll.c b/ll.c index debf52b..b823d23 100644 --- a/ll.c +++ b/ll.c @@ -5,7 +5,7 @@ * * Copyright 2000-2002 Project Purple * - * $Id: ll.c,v 1.4 2003/06/04 20:57:10 noodles Exp $ + * $Id: ll.c,v 1.5 2003/10/04 10:21:41 noodles Exp $ */ #include @@ -93,8 +93,7 @@ unsigned long llsize(struct ll *curll) * objectfree then it's called for each element to free them, if it's NULL * just the list is freed. */ -struct ll *llfree(struct ll *curll, - void (*objectfree) (void *object)) +void llfree(struct ll *curll, void (*objectfree) (void *object)) { struct ll *nextll; @@ -107,5 +106,5 @@ struct ll *llfree(struct ll *curll, free(curll); curll = nextll; } - return NULL; + return; } diff --git a/ll.h b/ll.h index 43a5bd3..be6dc4e 100644 --- a/ll.h +++ b/ll.h @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: ll.h,v 1.3 2003/06/04 20:57:10 noodles Exp $ + * $Id: ll.h,v 1.4 2003/10/04 10:21:41 noodles Exp $ */ #ifndef __LL_H__ @@ -93,7 +93,6 @@ unsigned long llsize(struct ll *curll); * objectfree then it's called for each element to free them, if it's NULL * just the list is freed. */ -struct ll *llfree(struct ll *curll, - void (*objectfree) (void *object)); +void llfree(struct ll *curll, void (*objectfree) (void *object)); #endif /* __LL_H__ */ diff --git a/lookup.c b/lookup.c index 71c27c3..72798ce 100644 --- a/lookup.c +++ b/lookup.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: lookup.c,v 1.10 2003/06/07 13:45:34 noodles Exp $ + * $Id: lookup.c,v 1.11 2003/10/04 10:21:41 noodles Exp $ */ #include @@ -16,6 +16,7 @@ #include #include "armor.h" +#include "charfuncs.h" #include "getcgi.h" #include "keydb.h" #include "keyindex.h" @@ -29,11 +30,6 @@ #define OP_INDEX 2 #define OP_VINDEX 3 -int putnextchar(void *ctx, size_t count, unsigned char *c) -{ - return printf("%.*s", (int) count, c); -} - void find_keys(char *search, uint64_t keyid, bool ishex, bool fingerprint, bool exact, bool verbose, bool mrhkp) { @@ -160,7 +156,7 @@ int main(int argc, char *argv[]) flatten_publickey(publickey, &packets, &list_end); - armor_openpgp_stream(putnextchar, + armor_openpgp_stream(stdout_putchar, NULL, packets); puts(""); diff --git a/main.c b/main.c index 9580e01..58e3ca7 100644 --- a/main.c +++ b/main.c @@ -4,23 +4,13 @@ #include #include "armor.h" +#include "charfuncs.h" #include "keydb.h" #include "keyid.h" #include "keyindex.h" #include "keystructs.h" #include "parsekey.h" -int getnextchar(void *ctx, size_t count, unsigned char *c) -{ - return (!read(0, c, count)); -} - -int putnextchar(void *ctx, size_t count, unsigned char *c) -{ - return (!write(1, c, count)); -} - - int main(int argc, char *argv[]) { struct openpgp_packet_list *packets = NULL; @@ -35,9 +25,9 @@ int main(int argc, char *argv[]) read_openpgp_stream(getnextchar, ctx, &packets, 0); */ fputs("Doing dearmor_openpgp_stream():\n", stderr); - dearmor_openpgp_stream(getnextchar, NULL, &packets); + dearmor_openpgp_stream(stdin_getchar, NULL, &packets); fputs("Doing armor_openpgp_stream():\n", stderr); - armor_openpgp_stream(putnextchar, NULL, packets); + armor_openpgp_stream(stdout_putchar, NULL, packets); /* fputs("Doing parse_keys():\n", stderr); diff --git a/md5.c b/md5.c index 2cde87d..7673af2 100644 --- a/md5.c +++ b/md5.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: md5.c,v 1.2 2003/06/04 20:57:10 noodles Exp $ + * $Id: md5.c,v 1.3 2003/10/04 10:21:41 noodles Exp $ */ /* Written by Ulrich Drepper , 1995. */ /* heavily modified for GnuPG by */ @@ -36,8 +36,8 @@ void md5_init( MD5_CONTEXT *ctx ) { ctx->A = 0x67452301; - ctx->B = 0xefcdab89; - ctx->C = 0x98badcfe; + ctx->B = 0xefcdab89U; + ctx->C = 0x98badcfeU; ctx->D = 0x10325476; ctx->nblocks = 0; diff --git a/parsekey.c b/parsekey.c index 35c14c0..83fca29 100644 --- a/parsekey.c +++ b/parsekey.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: parsekey.c,v 1.15 2003/10/03 23:24:16 noodles Exp $ + * $Id: parsekey.c,v 1.16 2003/10/04 10:21:40 noodles Exp $ */ #include @@ -21,20 +21,6 @@ #include "mem.h" #include "parsekey.h" -/** - * add_key - Takes a key and adds it to the keyserver. - * @key: The public key to add. - * - * This function takes a public key and adds it to the keyserver. - * It first of all sees if we already have the key locally. If we do then - * we retrieve it and merge the two keys. We then store the resulting key - * (or just the original we received if we don't already have it). We then - * send out the appropriate updates to our keyserver peers. - */ -int add_key(struct openpgp_publickey *key) { - return 0; -} - /** * parse_keys - Process a stream of packets for public keys + sigs. * @packets: The packet list to parse. @@ -175,7 +161,6 @@ int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count, int maxnum) { unsigned char curchar = 0; - unsigned long count = 0; struct openpgp_packet_list *curpacket = NULL; int rc = 0; int keys = 0; @@ -197,7 +182,6 @@ int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count, * allocate memory for it. */ inpacket = true; - count = 0; if (curpacket != NULL) { curpacket->next = malloc(sizeof (*curpacket)); curpacket = curpacket->next; diff --git a/parsekey.h b/parsekey.h index ed7e3a0..7e2e2bd 100644 --- a/parsekey.h +++ b/parsekey.h @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: parsekey.h,v 1.5 2003/09/30 20:40:11 noodles Exp $ + * $Id: parsekey.h,v 1.6 2003/10/04 10:21:40 noodles Exp $ */ #ifndef __PARSEKEY_H__ @@ -13,18 +13,6 @@ #include "keystructs.h" -/** - * add_key - Takes a key and adds it to the keyserver. - * @key: The public key to add. - * - * This function takes a public key and adds it to the keyserver. - * It first of all sees if we already have the key locally. If we do then - * we retrieve it and merge the two keys. We then store the resulting key - * (or just the original we received if we don't already have it). We then - * send out the appropriate updates to our keyserver peers. - */ -int add_key(struct openpgp_publickey *key); - /** * parse_keys - Process a stream of packets for public keys + sigs. * @packets: The packet list to parse.