fade.c: replace args_info by conf
authorAndre Noll <maan@systemlinux.org>
Sat, 26 May 2007 20:43:15 +0000 (22:43 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 26 May 2007 20:43:15 +0000 (22:43 +0200)
to be consistent with the other paraslash applications that also use
conf for the gengetopt args_info struct.

fade.c

diff --git a/fade.c b/fade.c
index 8893ca606e0d7e85ddf69513b0790214cb7452c7..8da91134a5208d36700e6aba4aafbc02ebc685ff 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -34,7 +34,7 @@
 #include "string.h"
 
 
-struct fade_args_info args_info;
+struct fade_args_info conf;
 
 void para_log(__a_unused int ll, const char *fmt,...)
 {
@@ -57,7 +57,7 @@ static int open_mixer(void)
 {
        int mixer_fd;
 
-       if ((mixer_fd = open(args_info.mixer_device_arg, O_RDWR, 0)) < 0)
+       if ((mixer_fd = open(conf.mixer_device_arg, O_RDWR, 0)) < 0)
                return -1;
        return mixer_fd;
 }
@@ -187,22 +187,22 @@ static void sweet_dreams(void)
        time_t t1, wake_time_epoch;
        unsigned int delay;
        struct tm *tm;
-       int min = args_info.wake_min_arg;
-       char *fa_stream = args_info.fa_stream_arg;
-       char *wake_stream = args_info.wake_stream_arg;
+       int min = conf.wake_min_arg;
+       char *fa_stream = conf.fa_stream_arg;
+       char *wake_stream = conf.wake_stream_arg;
        //char *current_stream = stat_items[STREAM].content;
-       int wf = args_info.wake_fade_arg;
-       int sf = args_info.fa_fade_arg;
-       int wv = args_info.wake_vol_arg;
-       int sv = args_info.fa_vol_arg;
-       int iv = args_info.sleep_ivol_arg;
-       char *cmd, *sleep_stream = args_info.sleep_stream_given?
-               args_info.sleep_stream_arg : NULL;
+       int wf = conf.wake_fade_arg;
+       int sf = conf.fa_fade_arg;
+       int wv = conf.wake_vol_arg;
+       int sv = conf.fa_vol_arg;
+       int iv = conf.sleep_ivol_arg;
+       char *cmd, *sleep_stream = conf.sleep_stream_given?
+               conf.sleep_stream_arg : NULL;
 
        /* calculate wake time */
        time(&t1);
-       if (args_info.wake_hour_given) {
-               int hour = args_info.wake_hour_arg;
+       if (conf.wake_hour_given) {
+               int hour = conf.wake_hour_arg;
                tm = localtime(&t1);
                if (tm->tm_hour > hour || (tm->tm_hour == hour && tm->tm_min> min)) {
                        t1 += 86400; /* wake time is tomorrow */
@@ -255,33 +255,32 @@ static void snooze(void)
 {
        unsigned sleep_time;
 
-       if (args_info.snooze_time_arg <= 0)
+       if (conf.snooze_time_arg <= 0)
                return;
-       sleep_time = args_info.snooze_time_arg;
-       if (get_vol() < args_info.snooze_out_vol_arg)
-               set_vol(args_info.snooze_out_vol_arg);
+       sleep_time = conf.snooze_time_arg;
+       if (get_vol() < conf.snooze_out_vol_arg)
+               set_vol(conf.snooze_out_vol_arg);
        else
-               fade(args_info.snooze_out_vol_arg, args_info.snooze_out_fade_arg);
+               fade(conf.snooze_out_vol_arg, conf.snooze_out_fade_arg);
        client_cmd("pause");
-       PARA_NOTICE_LOG("%d seconds snooze time...\n", args_info.snooze_time_arg);
+       PARA_NOTICE_LOG("%d seconds snooze time...\n", conf.snooze_time_arg);
        sleep(sleep_time);
        client_cmd("play");
-       fade(args_info.snooze_in_vol_arg, args_info.snooze_in_fade_arg);
+       fade(conf.snooze_in_vol_arg, conf.snooze_in_fade_arg);
 }
 
 static int configfile_exists(void)
 {
        static char *config_file;
 
-       if (!args_info.config_file_given) {
+       if (!conf.config_file_given) {
                char *home = para_homedir();
-               const char *conf = ".paraslash/fade.conf";
                free(config_file);
-               config_file = make_message("%s/%s", home, conf);
+               config_file = make_message("%s/.paraslash/fade.conf", home);
                free(home);
-               args_info.config_file_arg = config_file;
+               conf.config_file_arg = config_file;
        }
-       return file_exists(args_info.config_file_arg);
+       return file_exists(conf.config_file_arg);
 }
 
 
@@ -289,35 +288,35 @@ int main(int argc, char *argv[])
 {
        int ret;
 
-       if (fade_cmdline_parser(argc, argv, &args_info))
+       if (fade_cmdline_parser(argc, argv, &conf))
                exit(EXIT_FAILURE);
-       HANDLE_VERSION_FLAG("fade", args_info);
+       HANDLE_VERSION_FLAG("fade", conf);
        ret = configfile_exists();
-       if (!ret && args_info.config_file_given) {
+       if (!ret && conf.config_file_given) {
                PARA_EMERG_LOG("can not read config file %s\n",
-                       args_info.config_file_arg);
+                       conf.config_file_arg);
                exit(EXIT_FAILURE);
        }
        if (ret)
-               fade_cmdline_parser_configfile(args_info.config_file_arg,
-                       &args_info, 0, 0, 0);
+               fade_cmdline_parser_configfile(conf.config_file_arg,
+                       &conf, 0, 0, 0);
        if ((ret = open_mixer()) < 0) {
                PARA_EMERG_LOG("can not open mixer device %s.",
-                       args_info.mixer_device_arg);
+                       conf.mixer_device_arg);
                exit(EXIT_FAILURE);
        } else
                close(ret);
        ret = 0;
        setlinebuf(stdout);
-       if (!strcmp(args_info.mode_arg, "sleep")) {
+       if (!strcmp(conf.mode_arg, "sleep")) {
                sweet_dreams();
                goto out;
        }
-       if (!strcmp(args_info.mode_arg, "fade")) {
-               fade(args_info.fade_vol_arg, args_info.fade_time_arg);
+       if (!strcmp(conf.mode_arg, "fade")) {
+               fade(conf.fade_vol_arg, conf.fade_time_arg);
                goto out;
        }
-       if (!strcmp(args_info.mode_arg, "snooze")) {
+       if (!strcmp(conf.mode_arg, "snooze")) {
                snooze();
                goto out;
        }