Exit if not able to read and parse the configuration file.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 7 Jun 2009 15:40:48 +0000 (12:40 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 7 Jun 2009 15:40:48 +0000 (12:40 -0300)
popproxy.c

index e525afa..3a9a2d3 100644 (file)
@@ -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);