Add rpmfiFDigestHex() for converting the binary digest to hex
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 30 May 2008 09:21:48 +0000 (12:21 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 2 Jun 2008 06:50:48 +0000 (09:50 +0300)
- conversion (back to) hex presentation is done manually in several places,
  might as well have a function to do it...

lib/rpmfi.c
lib/rpmfi.h

index c8dc23a..e5c3c24 100644 (file)
@@ -196,6 +196,17 @@ const unsigned char * rpmfiFDigest(rpmfi fi, pgpHashAlgo *algo, size_t *len)
     return digest;
 }
 
+char * rpmfiFDigestHex(rpmfi fi, pgpHashAlgo *algo)
+{
+    size_t diglen = 0;
+    char *fdigest = NULL;
+    const unsigned char *digest = rpmfiFDigest(fi, algo, &diglen);
+    if (digest) {
+       fdigest = pgpHexStr(digest, diglen);
+    }
+    return fdigest;
+}
+
 const char * rpmfiFLink(rpmfi fi)
 {
     const char * flink = NULL;
index c857440..072bc78 100644 (file)
@@ -216,6 +216,17 @@ rpmfileState rpmfiFState(rpmfi fi);
 const unsigned char * rpmfiFDigest(rpmfi fi, pgpHashAlgo *algo, size_t *diglen);
 
 /** \ingroup rpmfi
+ * Return current file (hex) digest of file info set.
+ * The file info set stores file digests in binary format to conserve
+ * memory, this converts the binary data back to hex presentation used in
+ * headers. 
+ * @param fi           file info set
+ * @retval algo                digest hash algoritm used (pass NULL to ignore)
+ * @return             current file digest (malloc'ed), NULL on invalid
+ */
+char * rpmfiFDigestHex(rpmfi fi, pgpHashAlgo *algo);
+
+/** \ingroup rpmfi
  * Return current file (binary) md5 digest from file info set.
  * @deprecated         Use rpmfiFDigest() instead
  * @param fi           file info set