diff options
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -158,6 +158,9 @@ int options_parse(options_t* opt, int argc, char* argv[]) argc--; + char* mode = NULL; + char* channel = NULL; + int i; for(i=1; argc > 0; ++i) { @@ -175,10 +178,36 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_PARAM("-f","--config", opt->conf_file_) PARSE_STRING_PARAM("-s","--socket", opt->command_sock_) PARSE_STRING_PARAM("-d","--device", opt->switch_dev_) + PARSE_STRING_PARAM("-m","--mode", mode) + PARSE_STRING_PARAM("-c","--channel", channel) else return i; } + if(mode) { + if(!strcmp(mode, "master")) + opt->mode_ = MODE_MASTER; + else if(!strcmp(mode, "standby")) + opt->mode_ = MODE_STANDBY; + else { + free(mode); + return -3; + } + free(mode); + } + + if(channel) { + if(!strcmp(channel, "main")) + opt->channel_ = CHAN_MAIN; + else if(!strcmp(channel, "music")) + opt->channel_ = CHAN_MUSIC; + else { + free(channel); + return -4; + } + free(channel); + } + return 0; } @@ -278,6 +307,8 @@ void options_print_usage() printf(" [-f|--config] <file> the configuration file e.g. /etc/rhctl/switchctl.conf\n"); printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/rhctl/switchctl.sock\n"); printf(" [-d|--device] <tty> the tty the audio switch is connected to\n"); + printf(" [-m|--mode] <mode> the initial mode to use\n"); + printf(" [-c|--channel] <channel> the initial channel to use\n"); } void options_print(options_t* opt) @@ -294,6 +325,8 @@ void options_print(options_t* opt) printf("log_targets: \n"); string_list_print(&opt->log_targets_, " '", "'\n"); + printf("mode: '%s'\n", opt->mode_ == MODE_MASTER ? "master" : "standby"); + printf("channel: '%s'\n", opt->channel_ == CHAN_MAIN ? "main" : "music"); printf("conf_file: '%s'\n", opt->conf_file_); printf("command_sock: '%s'\n", opt->command_sock_); printf("switch_dev: '%s'\n", opt->switch_dev_); |