[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: domd5()/mdfile() functions in RPM 4.1 API

On Tue, Jul 16, 2002 at 01:01:41AM +0200, Enrico Scholz wrote:
> jbj@redhat.com (Jeff Johnson) writes:
> > > After grepping through the headers, I see that domd5() disappeared in
> > > RPM 4.1. Does there exists another replacement, or was it dropped
> > > entirely and I have do use external libraries to calculate the md5sum
> > > of a file?
> > 
> > domd5 is still alive and well, but is now resident in rpmdb/legacy.[ch]:
> I see it in the API documentatoin and in the library but can not find
> the legacy.h header in the rpm-devel-4.1-0.45 package.

Yup, I'm trying to eliminate domd5 in favor of using rpmio directly
for calculating digests as in the following snippet:

	int asAscii = 1;
	char buf[BUFSIZ];
	char * md5sum;
	size_t md5len;
	FD_t fd;

	fd = Fopen(filename, "r");
        fdInitDigest(fd, PGPHASHALGO_MD5, 0);
        while ((rc = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0)
        fdFiniDigest(fd, PGPHASHALGO_MD5, (void **)&md5sum, &md5len, asAscii);

Any of MD5, SHA1, SHA256 are there, up to 4 at a time, even identical digest
algo's started at different points on the stream, if you're careful about
the placement of fdFiniDigest and/or use Ffluseh().

> Is the missing legacy.h just an oversight or indented? How can I use
> domd5() in the latter case?

I'm not sure that domd5() is what you want any more, as the file is opened
with libelf, checked to see whether a DSO that is prelinked, and, if
so, a helper binary is exec'd to undo the prelinking deed. That's a bit
more than what you're expecting if you just want a md5 digest for a file.

OTOH, the mmap with MADV_SEQUENTIAL in domd5 is ~20% faster than the above,
at least on linux.

Poke me in bugzilla, and I'll try to provide some regular support for
calculating file digests in the API.

At a minimum, I probably need to expose fdInitDigest() et al in rpmio.h.

73 de Jeff

Jeff Johnson	ARS N3NPQ
jbj@redhat.com (jbj@jbj.org)
Chapel Hill, NC

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []