J
joe bruin
hello all.
i am trying to get rid of some warnings and do "the right thing".
although in this particular case, i am not sure what the right thing
is.
the code:
typedef struct
{
void *ctx;
void (*init)(void *);
void (*update)(void *, const void *, unsigned long);
void (*final)(unsigned char *, void *);
int mdlen;
char *name;
} digest_t;
MD2_CTX md2ctx;
MD4_CTX md4ctx;
MD5_CTX md5ctx;
SHA_CTX shactx;
RIPEMD160_CTX rmdctx;
digest_t dig[] =
{
{ &md2ctx, MD2_Init, MD2_Update, MD2_Final,
MD2_DIGEST_LENGTH, "MD2" },
{ &md4ctx, MD4_Init, MD4_Update, MD4_Final,
MD4_DIGEST_LENGTH, "MD4" },
{ &md5ctx, MD5_Init, MD5_Update, MD5_Final,
MD5_DIGEST_LENGTH, "MD5" },
{ &shactx, SHA_Init, SHA_Update, SHA_Final,
SHA_DIGEST_LENGTH, "SHA" },
{ &shactx, SHA1_Init, SHA1_Update, SHA1_Final,
SHA_DIGEST_LENGTH, "SHA1" },
{ &rmdctx, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final,
RIPEMD160_DIGEST_LENGTH, "RIPEMD160" }
};
this code will yield a "warning: initialization from incompatible
pointer type", on every Init, Update, and Final function in dig[].
these functions are all in the format:
void MD5_Init(MD5_CTX *c);
void MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
void MD5_Final(unsigned char *md, MD5_CTX *c);
with different types for the context. short of writing a wrapper
function for each of these (or one smart wrapper function for them
all), is there a safe solution to fix these assignments? while i'm at
it, please post other corrections are you see fit to call them.
thanks,
joe
i am trying to get rid of some warnings and do "the right thing".
although in this particular case, i am not sure what the right thing
is.
the code:
typedef struct
{
void *ctx;
void (*init)(void *);
void (*update)(void *, const void *, unsigned long);
void (*final)(unsigned char *, void *);
int mdlen;
char *name;
} digest_t;
MD2_CTX md2ctx;
MD4_CTX md4ctx;
MD5_CTX md5ctx;
SHA_CTX shactx;
RIPEMD160_CTX rmdctx;
digest_t dig[] =
{
{ &md2ctx, MD2_Init, MD2_Update, MD2_Final,
MD2_DIGEST_LENGTH, "MD2" },
{ &md4ctx, MD4_Init, MD4_Update, MD4_Final,
MD4_DIGEST_LENGTH, "MD4" },
{ &md5ctx, MD5_Init, MD5_Update, MD5_Final,
MD5_DIGEST_LENGTH, "MD5" },
{ &shactx, SHA_Init, SHA_Update, SHA_Final,
SHA_DIGEST_LENGTH, "SHA" },
{ &shactx, SHA1_Init, SHA1_Update, SHA1_Final,
SHA_DIGEST_LENGTH, "SHA1" },
{ &rmdctx, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final,
RIPEMD160_DIGEST_LENGTH, "RIPEMD160" }
};
this code will yield a "warning: initialization from incompatible
pointer type", on every Init, Update, and Final function in dig[].
these functions are all in the format:
void MD5_Init(MD5_CTX *c);
void MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
void MD5_Final(unsigned char *md, MD5_CTX *c);
with different types for the context. short of writing a wrapper
function for each of these (or one smart wrapper function for them
all), is there a safe solution to fix these assignments? while i'm at
it, please post other corrections are you see fit to call them.
thanks,
joe