From c44fbbea0488dada04e7183eb7518fa972375bce Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Sun, 18 Sep 2011 16:44:32 +0000 Subject: base64.c has gone from being a base64 implementation to a small wrapper around GMappedFile and the glib base64 encoder. Makes more sense in util.c now. --- src/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index e37e728..1bfc20b 100644 --- a/src/util.c +++ b/src/util.c @@ -373,3 +373,22 @@ gdouble json_double_to_progress(JsonNode *n) return 0.0; } } + +gchar *trg_base64encode(const gchar *filename) +{ + GError *error = NULL; + GMappedFile *mf = g_mapped_file_new(filename, FALSE, &error); + gchar *b64out = NULL; + + if (error) + { + g_error("%s",error->message); + g_error_free(error); + } else { + b64out = g_base64_encode((guchar*)g_mapped_file_get_contents(mf), g_mapped_file_get_length(mf)); + } + + g_mapped_file_unref(mf); + + return b64out; +} -- cgit v1.2.3