summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-18 16:44:32 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-18 16:44:32 +0000
commitc44fbbea0488dada04e7183eb7518fa972375bce (patch)
tree1c3d0dcf7e7a30998de69c1202b3a0c7a150dcac /src/util.c
parent52c98d2eb39d00659d051e6e74e0e8a098754163 (diff)
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.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c19
1 files changed, 19 insertions, 0 deletions
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;
+}