Commit 3c052f02 authored by Christophe Fergeau's avatar Christophe Fergeau Committed by Matt Colyer

Use g_file_get_contents

Signed-off-by: 's avatarMatt Colyer <matt@colyer.name>
parent 2f2b8d7e
...@@ -162,27 +162,14 @@ int read_file_in_confdir(char* file, gnutls_datum_t* data) ...@@ -162,27 +162,14 @@ int read_file_in_confdir(char* file, gnutls_datum_t* data)
return 0; return 0;
gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL); 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))) { gboolean success;
gsize size;
FILE * pFile; char *content;
success = g_file_get_contents (filepath, &content, &size, NULL);
pFile = fopen ( filepath , "rb" ); g_free (filepath);
if (pFile==NULL) data->data = content;
return 0; data->size = size;
return success;
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;
} }
int get_root_private_key(gnutls_datum_t* root_privkey) int get_root_private_key(gnutls_datum_t* root_privkey)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment