Author: noodles
Date: 2003/10/04 10:21:40
Various minor code cleanups to reduce compiler warnings (especially with c99).
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* 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 $
* @x: The integer to rotate.
* @n: The number of bytes to rotate it by.
*/
* @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)
{
__asm__("roll %%cl,%0"
:"=r" (x)
*
* Copyright 2002 Project Purple
*
*
* 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 $
int buffer_fetchchar(void *ctx, size_t count, unsigned char *c)
{
struct buffer_ctx *buf = NULL;
int buffer_fetchchar(void *ctx, size_t count, unsigned char *c)
{
struct buffer_ctx *buf = NULL;
buf = (struct buffer_ctx *) ctx;
for (i = 0; i < count; i++) {
buf = (struct buffer_ctx *) ctx;
for (i = 0; i < count; i++) {
{
struct buffer_ctx *buf = NULL;
size_t newsize = 0;
{
struct buffer_ctx *buf = NULL;
size_t newsize = 0;
buf = (struct buffer_ctx *) ctx;
buf = (struct buffer_ctx *) ctx;
*/
int stdin_getchar(void *ctx, 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);
*/
int stdout_putchar(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);
*
* Copyright 2002 Project Purple
*
*
* 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__
*/
#ifndef __CHARFUNCS_H__
*/
struct buffer_ctx {
char *buffer;
*/
struct buffer_ctx {
char *buffer;
- int offset;
- int size;
+ size_t offset;
+ size_t size;
*
* Copyright 2000-2002 Project Purple
*
*
* 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 $
* TODO: The problem is the object has pointers that
* need freed too.
*/
* 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;
hashtable[i] = NULL;
}
elements = 0;
*
* Copyright 2000-2002 Project Purple
*
*
* 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 $
* objectfree then it's called for each element to free them, if it's NULL
* just the list is freed.
*/
* 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))
free(curll);
curll = nextll;
}
free(curll);
curll = nextll;
}
*
* Copyright 2002 Project Purple
*
*
* 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 $
* objectfree then it's called for each element to free them, if it's NULL
* just the list is freed.
*/
* 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));
*
* Copyright 2002 Project Purple
*
*
* 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 <unistd.h>
#include "armor.h"
#include <unistd.h>
#include "armor.h"
#include "getcgi.h"
#include "keydb.h"
#include "keyindex.h"
#include "getcgi.h"
#include "keydb.h"
#include "keyindex.h"
#define OP_INDEX 2
#define OP_VINDEX 3
#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)
{
void find_keys(char *search, uint64_t keyid, bool ishex,
bool fingerprint, bool exact, bool verbose, bool mrhkp)
{
flatten_publickey(publickey,
&packets,
&list_end);
flatten_publickey(publickey,
&packets,
&list_end);
- armor_openpgp_stream(putnextchar,
+ armor_openpgp_stream(stdout_putchar,
NULL,
packets);
puts("</pre>");
NULL,
packets);
puts("</pre>");
#include <unistd.h>
#include "armor.h"
#include <unistd.h>
#include "armor.h"
#include "keydb.h"
#include "keyid.h"
#include "keyindex.h"
#include "keystructs.h"
#include "parsekey.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;
int main(int argc, char *argv[])
{
struct openpgp_packet_list *packets = NULL;
read_openpgp_stream(getnextchar, ctx, &packets, 0);
*/
fputs("Doing dearmor_openpgp_stream():\n", stderr);
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);
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);
/*
fputs("Doing parse_keys():\n", stderr);
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* 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> */
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
/* heavily modified for GnuPG by <werner.koch@guug.de> */
void md5_init( MD5_CONTEXT *ctx )
{
ctx->A = 0x67452301;
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;
ctx->D = 0x10325476;
ctx->nblocks = 0;
*
* Copyright 2002 Project Purple
*
*
* 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 "mem.h"
#include "parsekey.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.
/**
* parse_keys - Process a stream of packets for public keys + sigs.
* @packets: The packet list to parse.
int maxnum)
{
unsigned char curchar = 0;
int maxnum)
{
unsigned char curchar = 0;
- unsigned long count = 0;
struct openpgp_packet_list *curpacket = NULL;
int rc = 0;
int keys = 0;
struct openpgp_packet_list *curpacket = NULL;
int rc = 0;
int keys = 0;
* allocate memory for it.
*/
inpacket = true;
* allocate memory for it.
*/
inpacket = true;
if (curpacket != NULL) {
curpacket->next = malloc(sizeof (*curpacket));
curpacket = curpacket->next;
if (curpacket != NULL) {
curpacket->next = malloc(sizeof (*curpacket));
curpacket = curpacket->next;
*
* Copyright 2002 Project Purple
*
*
* 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__
*/
#ifndef __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);
-
/**
* parse_keys - Process a stream of packets for public keys + sigs.
* @packets: The packet list to parse.
/**
* parse_keys - Process a stream of packets for public keys + sigs.
* @packets: The packet list to parse.