[gmime: 23/27] Add helper for reading the GMimeFilterChecksum result as string (#34)



commit a145e3e3cb6fc7a8db59cdfd33d856d0e57ea209
Author: albrechtd <albrecht dress arcor de>
Date:   Mon Nov 13 20:09:42 2017 +0100

    Add helper for reading the GMimeFilterChecksum result as string (#34)
    
    Add helper for reading the GMimeFilterChecksum result as a string

 gmime/gmime-filter-checksum.c |   17 +++++++++++++++++
 gmime/gmime-filter-checksum.h |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gmime/gmime-filter-checksum.c b/gmime/gmime-filter-checksum.c
index be3b4f5..f4f0251 100644
--- a/gmime/gmime-filter-checksum.c
+++ b/gmime/gmime-filter-checksum.c
@@ -190,3 +190,20 @@ g_mime_filter_checksum_get_digest (GMimeFilterChecksum *checksum, unsigned char
        
        return len;
 }
+
+
+/**
+ * g_mime_filter_checksum_get_string:
+ * @checksum: checksum filter object
+ *
+ * Outputs the checksum digest as a newly allocated hexadecimal string.
+ *
+ * Returns: the hexadecimal representation of the checksum. The returned string should be freed with 
g_free() when no longer needed.
+ **/
+gchar *
+g_mime_filter_checksum_get_string (GMimeFilterChecksum *checksum)
+{
+       g_return_val_if_fail (GMIME_IS_FILTER_CHECKSUM (checksum), NULL);
+
+       return g_strdup (g_checksum_get_string (checksum->checksum));
+}
diff --git a/gmime/gmime-filter-checksum.h b/gmime/gmime-filter-checksum.h
index 7b11d42..4743ab2 100644
--- a/gmime/gmime-filter-checksum.h
+++ b/gmime/gmime-filter-checksum.h
@@ -60,6 +60,7 @@ GType g_mime_filter_checksum_get_type (void);
 GMimeFilter *g_mime_filter_checksum_new (GChecksumType type);
 
 size_t g_mime_filter_checksum_get_digest (GMimeFilterChecksum *checksum, unsigned char *digest, size_t len);
+gchar *g_mime_filter_checksum_get_string (GMimeFilterChecksum *checksum);
 
 G_END_DECLS
 


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