From: Thadeu Lima de Souza Cascardo Date: Sun, 7 Jun 2009 15:40:48 +0000 (-0300) Subject: Exit if not able to read and parse the configuration file. X-Git-Tag: v0.1.3~99 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Frnetproxy.git;a=commitdiff_plain;h=e758e4dd429bd27b82af9fa07d7fb08fa15bd4e4 Exit if not able to read and parse the configuration file. --- diff --git a/popproxy.c b/popproxy.c index e525afa..3a9a2d3 100644 --- a/popproxy.c +++ b/popproxy.c @@ -59,6 +59,7 @@ int main (int argc, char** argv) GOptionContext* opt_ctx; GKeyFile *keyfile; GInetAddr* inetaddr; + GError *error; gchar* conf_address; gint port; gchar *server_address; @@ -79,7 +80,15 @@ int main (int argc, char** argv) keyfile = g_key_file_new (); - g_key_file_load_from_file (keyfile, configfile, G_KEY_FILE_NONE, NULL); + error = NULL; + if (g_key_file_load_from_file (keyfile, configfile, + G_KEY_FILE_NONE, &error) == FALSE) + { + fprintf (stderr, "Could not load configuration file %s: %s.\n", + configfile, error->message); + g_error_free (error); + exit (1); + } conf_address = g_key_file_get_string (keyfile, "global", "address", NULL); port = g_key_file_get_integer (keyfile, "global", "port", NULL);