From 3c052f02933ce1299f136b2d5fb2e6946bf9f1c5 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau
Date: Sun, 10 Aug 2008 22:44:24 +0200
Subject: Use g_file_get_contents

Signed-off-by: Matt Colyer <matt@colyer.name>
---
 src/userpref.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/userpref.c b/src/userpref.c
index 1dfc6ff..c792d1f 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -162,27 +162,14 @@ int read_file_in_confdir(char* file, gnutls_datum_t* data)
 		return 0;
 
 	gchar* filepath = g_build_path(G_DIR_SEPARATOR_S,  g_get_user_config_dir(), LIBIPHONE_CONF_DIR,  file, NULL);
-	if (g_file_test(filepath, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
-
-		FILE * pFile;
-		
-		pFile = fopen ( filepath , "rb" );
-		if (pFile==NULL)
-			return 0;
-
-		fseek (pFile , 0 , SEEK_END);
-		data->size = ftell (pFile);
-		rewind (pFile);
-		
-		data->data = (char*)gnutls_malloc(data->size);
-		if (data->data == NULL)
-			return 0;
-		
-		// copy the file into the buffer:
-		fread (data->data,1,data->size,pFile);	
-		fclose (pFile);
-	}
-	return 1;
+	gboolean success;
+	gsize size;
+	char *content;		
+	success = g_file_get_contents (filepath, &content, &size, NULL);
+	g_free (filepath);
+	data->data = content;
+	data->size = size;
+	return success;
 }
 
 int get_root_private_key(gnutls_datum_t* root_privkey)
-- 
cgit v1.1-32-gdbae