From ff762fb499be220ccd680f3bf68dca44a902a5ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Dec 2008 16:10:17 +0000 Subject: * Pass HashType values instead of strings. --- src/libutil/hash.cc | 9 +++++++++ src/libutil/hash.hh | 3 +++ 2 files changed, 12 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 70604a50a3..eef01fe4d6 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -335,4 +335,13 @@ HashType parseHashType(const string & s) } +string printHashType(HashType ht) +{ + if (ht == htMD5) return "md5"; + else if (ht == htSHA1) return "sha1"; + else if (ht == htSHA256) return "sha256"; + else throw Error("cannot print unknown hash type"); +} + + } diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index c3932b11b1..062d97254b 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -82,6 +82,9 @@ Hash compressHash(const Hash & hash, unsigned int newSize); /* Parse a string representing a hash type. */ HashType parseHashType(const string & s); +/* And the reverse. */ +string printHashType(HashType ht); + union Ctx; -- cgit 1.4.1