summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-06-11 09:42:41 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-06-11 09:42:41 +0000
commitf926fe585d8fd182975f4f38e8245bbd4acd1821 (patch)
tree5fee517639db666803735ba1ea8061720a238dee
parentde20fbecd0e467378671e67e2060a7f0c83b1468 (diff)
refactor md5 code to be able to work from a filehandle (like a pipe output)
-rw-r--r--usr.sbin/pkg_add/OpenBSD/md5.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/md5.pm b/usr.sbin/pkg_add/OpenBSD/md5.pm
index 1d15db4f69b..b9713c05d02 100644
--- a/usr.sbin/pkg_add/OpenBSD/md5.pm
+++ b/usr.sbin/pkg_add/OpenBSD/md5.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: md5.pm,v 1.5 2007/05/02 15:05:30 espie Exp $
+# $OpenBSD: md5.pm,v 1.6 2008/06/11 09:42:40 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -25,10 +25,19 @@ sub fromfile
{
my $fname = shift;
open(my $file, '<', $fname) or die "can't open $fname: $!";
+ my $digest = fromfh($file);
+ close($file) or die "problem closing $fname: $!";
+ return $digest;
+}
+
+sub fromfh
+{
+ my $file = shift;
+
my $md5 = new Digest::MD5;
$md5->addfile($file);
- close($file) or die "problem closing $fname: $!";
return $md5->digest;
}
+
1;