From: Thadeu Lima de Souza Cascardo Date: Sun, 7 Jun 2009 16:55:10 +0000 (-0300) Subject: Use configuration default values. X-Git-Tag: v0.1.3~97 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Frnetproxy.git;a=commitdiff_plain;h=de2391c71d93512f29cf64ff8edfa80179c1ed1b Use configuration default values. When there is no value for a given configuration key, use default values. --- diff --git a/popproxy.c b/popproxy.c index c2a12d2..fb1a8c1 100644 --- a/popproxy.c +++ b/popproxy.c @@ -90,9 +90,29 @@ int main (int argc, char** argv) exit (1); } - conf_address = g_key_file_get_string (keyfile, "global", "address", NULL); - port = g_key_file_get_integer (keyfile, "global", "port", NULL); - server_address = g_key_file_get_string (keyfile, "global", "server", NULL); + error = NULL; + conf_address = g_key_file_get_string (keyfile, "global", "address", + &error); + if (conf_address == NULL && error != NULL) + { + conf_address = g_strdup ("0.0.0.0"); + g_error_free (error); + } + error = NULL; + port = g_key_file_get_integer (keyfile, "global", "port", &error); + if (port == 0 && error != NULL) + { + port = 110; + g_error_free (error); + } + error = NULL; + server_address = g_key_file_get_string (keyfile, "global", "server", + &error); + if (server_address == NULL && error != NULL) + { + server_address = g_strdup ("127.0.0.1"); + g_error_free (error); + } inetaddr = gnet_inetaddr_new_nonblock (conf_address, port); if (gnet_server_new (inetaddr, port,