cscvs to tla changeset 107
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:04 +0000 (23:48 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:04 +0000 (23:48 +0000)
Author: noodles
Date: 2003/10/04 10:21:40
Various minor code cleanups to reduce compiler warnings (especially with c99).

bithelp.h
charfuncs.c
charfuncs.h
hash.c
ll.c
ll.h
lookup.c
main.c
md5.c
parsekey.c
parsekey.h

index 200b036354399f82cbb2138838d01eb41a696c3c..76324b44b4e734730cf4a9fe7badd8b2e3cf87b2 100644 (file)
--- 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)
index 52f1155b4c173219a60089729a54fd208848cf38..f509fc8653948e6645b8c3c797698de7cab27bba 100644 (file)
@@ -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 <stdio.h>
@@ -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);
 }
index ffa7bf93046b6ea55727496e311dc34ad7a2ae0e..c5ee2a0904858c93a7031c3b86312ff7e581d808 100644 (file)
@@ -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 9ee8b9bd62e9d4203743d3fd16f635b268340845..03def747c2fb5d77707316a3eb797af267d811fe 100644 (file)
--- 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 <stdio.h>
@@ -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 debf52b278759d9702f6cad1b729a6931f8bac08..b823d23813c902eca0802f08c5ac568464b6d2de 100644 (file)
--- 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 <assert.h>
@@ -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 43a5bd364c4032c92e6b319d6118eb9842c3a821..be6dc4ed8fa3a7f1cc6c1f74228fb0da1d07a005 100644 (file)
--- 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__ */
index 71c27c3357f32e27806fd0be668a8c5d244b7a3b..72798ceb103108f2541ec546ea7b87e0ae7cfd65 100644 (file)
--- 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 <inttypes.h>
@@ -16,6 +16,7 @@
 #include <unistd.h>
 
 #include "armor.h"
+#include "charfuncs.h"
 #include "getcgi.h"
 #include "keydb.h"
 #include "keyindex.h"
 #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("</pre>");
diff --git a/main.c b/main.c
index 9580e018519937647bed293a40039fefc8c60bb7..58e3ca743a44fec7e3362eefffdbaac50b0281e8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,23 +4,13 @@
 #include <unistd.h>
 
 #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 2cde87d8cb383c0bad95596b6694de7b821e29ff..7673af20c6a027eaa9ea623c7906257488c9bfb3 100644 (file)
--- 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 <drepper@gnu.ai.mit.edu>, 1995.  */
 /* heavily modified for GnuPG by <werner.koch@guug.de> */
@@ -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;
index 35c14c08c07170b5289a7c8626408edbcb07bf3c..83fca29f9ce19902756c34fb59895c95b6542ecd 100644 (file)
@@ -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 <assert.h>
 #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;
index ed7e3a0daf2c8200deff01f7b61346a3755babac..7e2e2bdfd3f5f535681747190e22598a73f0dc46 100644 (file)
@@ -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__
 
 #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.