2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $Id: mdXhl.c,v 1.10 1997/02/22 15:07:23 peter Exp $
13 #include <sys/types.h>
24 MDXEnd(MDX_CTX *ctx, char *buf)
27 unsigned char digest[16];
28 static const char hex[]="0123456789abcdef";
36 buf[i+i] = hex[digest[i] >> 4];
37 buf[i+i+1] = hex[digest[i] & 0x0f];
44 MDXFile (const char *filename, char *buf)
46 unsigned char buffer[BUFSIZ];
51 f = open(filename,O_RDONLY);
53 while ((i = read(f,buffer,sizeof buffer)) > 0) {
54 MDXUpdate(&ctx,buffer,i);
60 return MDXEnd(&ctx, buf);
64 MDXData (const unsigned char *data, unsigned int len, char *buf)
69 MDXUpdate(&ctx,data,len);
70 return MDXEnd(&ctx, buf);