#include "string.h"
#include "mix.h"
#include "error.h"
+#include "ggo.h"
#include "version.h"
INIT_FADE_ERRLISTS;
#define FOR_EACH_MIXER(i) for ((i) = 0; (i) < NUM_SUPPORTED_MIXERS; (i)++)
static int loglevel;
-__printf_2_3 void date_log(int ll, const char *fmt, ...)
+static __printf_2_3 void date_log(int ll, const char *fmt, ...)
{
va_list argp;
time_t t1;
return;
time(&t1);
tm = localtime(&t1);
- printf("%d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec);
+ fprintf(stderr, "%d:%02d:%02d ", tm->tm_hour, tm->tm_min, tm->tm_sec);
va_start(argp, fmt);
vprintf(fmt, argp);
va_end(argp);
return ret;
}
+static int set_val(struct mixer *m, struct mixer_handle *h)
+{
+ return m->set(h, conf.val_arg);
+}
+
static struct mixer *get_mixer_or_die(void)
{
int i;
exit(EXIT_FAILURE);
}
+__noreturn static void print_help_and_die(void)
+{
+ struct ggo_help h = DEFINE_GGO_HELP(fade);
+ bool d = conf.detailed_help_given;
+
+ ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS);
+ exit(0);
+}
+
int main(int argc, char *argv[])
{
int ret;
fade_cmdline_parser(argc, argv, &conf);
loglevel = get_loglevel_by_name(conf.loglevel_arg);
version_handle_flag("fade", conf.version_given);
+ if (conf.help_given || conf.detailed_help_given)
+ print_help_and_die();
ret = configfile_exists();
if (!ret && conf.config_file_given) {
PARA_EMERG_LOG("can not read config file %s\n",
case mode_arg_snooze:
ret = snooze(m, h);
break;
+ case mode_arg_set:
+ ret = set_val(m, h);
+ break;
default: /* sleep mode */
ret = sweet_dreams(m, h);
break;