summaryrefslogtreecommitdiffstats
path: root/lib/libmd/mdXhl.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-07-12 09:13:49 +0000
committerphk <phk@FreeBSD.org>1995-07-12 09:13:49 +0000
commitd7d558428400f0ecc5856f6fcf4f56543aa841f8 (patch)
tree8b1350a696f17c97664a31181c2510c3e018115d /lib/libmd/mdXhl.c
parent0a7cf84cf326542a379591308b02b89e7a365ad6 (diff)
downloadFreeBSD-src-d7d558428400f0ecc5856f6fcf4f56543aa841f8.zip
FreeBSD-src-d7d558428400f0ecc5856f6fcf4f56543aa841f8.tar.gz
Change this to do what it should have done from the start.
Add argument for buffer for output. Fix manuals.
Diffstat (limited to 'lib/libmd/mdXhl.c')
-rw-r--r--lib/libmd/mdXhl.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index d99fb43..817c551 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: mdXhl.c,v 1.4 1995/04/27 16:05:51 wollman Exp $
+ * $Id: mdXhl.c,v 1.5 1995/05/30 05:45:17 rgrimes Exp $
*
*/
@@ -20,16 +20,19 @@
#include <unistd.h>
char *
-MDXEnd(MDX_CTX *ctx)
+MDXEnd(MDX_CTX *ctx, char *buf)
{
int i;
char *p = malloc(33);
unsigned char digest[16];
static const char hex[]="0123456789abcdef";
- if(!p) return 0;
+ if (!p)
+ p = malloc(33);
+ if (!p)
+ return 0;
MDXFinal(digest,ctx);
- for(i=0;i<16;i++) {
+ for (i=0;i<16;i++) {
p[i+i] = hex[digest[i] >> 4];
p[i+i+1] = hex[digest[i] & 0x0f];
}
@@ -38,7 +41,7 @@ MDXEnd(MDX_CTX *ctx)
}
char *
-MDXFile (char *filename)
+MDXFile (char *filename, char *buf)
{
unsigned char buffer[BUFSIZ];
MDX_CTX ctx;
@@ -46,23 +49,23 @@ MDXFile (char *filename)
MDXInit(&ctx);
f = open(filename,O_RDONLY);
- if(f < 0) return 0;
- while((i = read(f,buffer,sizeof buffer)) > 0) {
+ if (f < 0) return 0;
+ while ((i = read(f,buffer,sizeof buffer)) > 0) {
MDXUpdate(&ctx,buffer,i);
}
j = errno;
close(f);
errno = j;
- if(i < 0) return 0;
- return MDXEnd(&ctx);
+ if (i < 0) return 0;
+ return MDXEnd(&ctx, buf);
}
char *
-MDXData (const unsigned char *data, unsigned int len)
+MDXData (const unsigned char *data, unsigned int len, char *buf)
{
MDX_CTX ctx;
MDXInit(&ctx);
MDXUpdate(&ctx,data,len);
- return MDXEnd(&ctx);
+ return MDXEnd(&ctx, buf);
}
OpenPOWER on IntegriCloud