From 06466a8108415c046b5027792ebf183b39cc3c9a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 5 Nov 2013 10:12:26 +0100 Subject: make pacredir work without config file --- pacredir.c | 86 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/pacredir.c b/pacredir.c index 6a622a0..4ddf9e8 100644 --- a/pacredir.c +++ b/pacredir.c @@ -450,55 +450,55 @@ int main(int argc, char ** argv) { /* parse config file */ if ((ini = iniparser_load(CONFIGFILE)) == NULL) { - write_log(stderr, "cannot parse file: " CONFIGFILE "\n"); - return EXIT_FAILURE ; - } + write_log(stderr, "cannot parse file " CONFIGFILE ", continue anyway\n"); + /* continue anyway, there is nothing essential in the config file */ + } else { + /* store interfaces to ignore */ + if ((values = iniparser_getstring(ini, "general:ignore interfaces", NULL)) != NULL) { +# if defined DEBUG + write_log(stdout, "Ignore interface: [%s]\n", values); +# endif + tmp_ignore_interfaces = ignore_interfaces; - /* store interfaces to ignore */ - if ((values = iniparser_getstring(ini, "general:ignore interfaces", NULL)) != NULL) { -# if defined DEBUG - write_log(stdout, "Ignore interface: [%s]\n", values); -# endif - tmp_ignore_interfaces = ignore_interfaces; - - value = strtok(values, DELIMITER); - while (value != NULL) { - tmp_ignore_interfaces->interface = strdup(value); - tmp_ignore_interfaces->next = malloc(sizeof(struct ignore_interfaces)); - tmp_ignore_interfaces = tmp_ignore_interfaces->next; - value = strtok(NULL, DELIMITER); + value = strtok(values, DELIMITER); + while (value != NULL) { + tmp_ignore_interfaces->interface = strdup(value); + tmp_ignore_interfaces->next = malloc(sizeof(struct ignore_interfaces)); + tmp_ignore_interfaces = tmp_ignore_interfaces->next; + value = strtok(NULL, DELIMITER); + } + tmp_ignore_interfaces->interface = NULL; + tmp_ignore_interfaces->next = NULL; } - tmp_ignore_interfaces->interface = NULL; - tmp_ignore_interfaces->next = NULL; - } - - /* add static pacserve hosts */ - if ((values = iniparser_getstring(ini, "general:pacserve hosts", NULL)) != NULL) { -# if defined DEBUG - write_log(stdout, "pacserve hosts: [%s]\n", values); -# endif - value = strtok(values, DELIMITER); - while (value != NULL) { - add_host(value, PACSERVE); - value = strtok(NULL, DELIMITER); + + /* add static pacserve hosts */ + if ((values = iniparser_getstring(ini, "general:pacserve hosts", NULL)) != NULL) { +# if defined DEBUG + write_log(stdout, "pacserve hosts: [%s]\n", values); +# endif + value = strtok(values, DELIMITER); + while (value != NULL) { + add_host(value, PACSERVE); + value = strtok(NULL, DELIMITER); + } } - } - - /* add static pacdbserve hosts */ - if ((values = iniparser_getstring(ini, "general:pacdbserve hosts", NULL)) != NULL) { -# if defined DEBUG - write_log(stdout, "pacdbserve hosts: [%s]\n", values); -# endif - value = strtok(values, DELIMITER); - while (value != NULL) { - add_host(value, PACDBSERVE); - value = strtok(NULL, DELIMITER); + + /* add static pacdbserve hosts */ + if ((values = iniparser_getstring(ini, "general:pacdbserve hosts", NULL)) != NULL) { +# if defined DEBUG + write_log(stdout, "pacdbserve hosts: [%s]\n", values); +# endif + value = strtok(values, DELIMITER); + while (value != NULL) { + add_host(value, PACDBSERVE); + value = strtok(NULL, DELIMITER); + } } + + /* done reading config file, free */ + iniparser_freedict(ini); } - /* done reading config file, free */ - iniparser_freedict(ini); - /* allocate main loop object */ if ((simple_poll = avahi_simple_poll_new()) == NULL) { write_log(stderr, "Failed to create simple poll object.\n"); -- cgit v1.2.3-70-g09d2