]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Introduce get_config_file_name().
authorAndre Noll <maan@systemlinux.org>
Sat, 13 Nov 2010 19:21:04 +0000 (20:21 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 1 Jun 2012 15:31:32 +0000 (17:31 +0200)
ATM, the config file name is computed in parse_config(). However, for the ipc
stuff we'll need that information as well, so move the computation to a separate
helper function().

dss.c

diff --git a/dss.c b/dss.c
index 3508d38d798c1af448398c2de1d0b438a61bb4e4..bf30f893fa36fb9749d00ab706311709a9d4a42f 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -226,6 +226,18 @@ static __printf_1_2 void dss_msg(const char* fmt,...)
        va_end(argp);
 }
 
+static char *get_config_file_name(void)
+{
+       char *home, *config_file;
+
+       if (conf.config_file_given)
+               return dss_strdup(conf.config_file_arg);
+       home = get_homedir();
+       config_file = make_message("%s/.dssrc", home);
+       free(home);
+       return config_file;
+}
+
 static void dss_get_snapshot_list(struct snapshot_list *sl)
 {
        get_snapshot_list(sl, conf.unit_interval_arg, conf.num_intervals_arg);
@@ -906,18 +918,11 @@ static int check_config(void)
 static int parse_config_file(int override)
 {
        int ret, config_file_exists;
-       char *config_file;
+       char *config_file = get_config_file_name();
        struct stat statbuf;
        char *old_logfile_arg = NULL;
        int old_daemon_given = 0;
 
-       if (conf.config_file_given)
-               config_file = dss_strdup(conf.config_file_arg);
-       else {
-               char *home = get_homedir();
-               config_file = make_message("%s/.dssrc", home);
-               free(home);
-       }
        if (override) { /* SIGHUP */
                if (conf.logfile_given)
                        old_logfile_arg = dss_strdup(conf.logfile_arg);