summaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'options.c')
-rw-r--r--options.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/options.c b/options.c
index 839909e..5ee3e50 100644
--- a/options.c
+++ b/options.c
@@ -175,11 +175,17 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-C","--chroot", opt->chroot_dir_)
PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
- PARSE_STRING_PARAM("-f","--config", opt->conf_file_)
PARSE_STRING_PARAM("-s","--socket", opt->command_sock_)
+#ifdef OPT_SWITCHCTL
+ PARSE_STRING_PARAM("-f","--config", opt->conf_file_)
PARSE_STRING_PARAM("-d","--device", opt->switch_dev_)
PARSE_STRING_PARAM("-m","--mode", mode)
PARSE_STRING_PARAM("-c","--channel", channel)
+#endif
+#ifdef OPT_SERIALCLIENT
+ PARSE_STRING_PARAM("-d","--device", opt->serial_dev_)
+ PARSE_STRING_PARAM("-t","--type", opt->type_)
+#endif
else
return i;
}
@@ -217,6 +223,7 @@ int options_parse_post(options_t* opt)
return -1;
// nothing to do
+#ifdef OPT_SWITCHCTL
FILE* conf_file = fopen(opt->conf_file_, "r");
if(conf_file) {
char buf[100];
@@ -242,6 +249,7 @@ int options_parse_post(options_t* opt)
log_printf(ERROR,"unable to open conf file (%s): %s", opt->conf_file_, strerror(errno));
return -1;
}
+#endif
return 0;
}
@@ -251,6 +259,7 @@ void options_default(options_t* opt)
if(!opt)
return;
+/* common */
opt->progname_ = strdup("rhctl");
opt->daemonize_ = 1;
opt->username_ = NULL;
@@ -259,12 +268,18 @@ void options_default(options_t* opt)
opt->pid_file_ = NULL;
string_list_init(&opt->log_targets_);
+ opt->command_sock_ = strdup("/var/run/rhctl/switchctl.sock");
+
+/* switchctl */
opt->mode_ = MODE_MASTER;
opt->channel_ = CHAN_MAIN;
opt->conf_file_ = strdup("/etc/rhctl/switchctl.conf");
- opt->command_sock_ = strdup("/var/run/rhctl/switchctl.sock");
opt->switch_dev_ = strdup("/dev/audioswitch");
key_value_storage_init(&opt->alias_table_);
+
+/* serialclient */
+ opt->serial_dev_ = strdup("/dev/ttyUSB0");
+ opt->type_ = NULL;
}
void options_clear(options_t* opt)
@@ -272,6 +287,7 @@ void options_clear(options_t* opt)
if(!opt)
return;
+/* common */
if(opt->progname_)
free(opt->progname_);
if(opt->username_)
@@ -284,13 +300,21 @@ void options_clear(options_t* opt)
free(opt->pid_file_);
string_list_clear(&opt->log_targets_);
- if(opt->conf_file_)
- free(opt->conf_file_);
if(opt->command_sock_)
free(opt->command_sock_);
+
+/* switchctl */
+ if(opt->conf_file_)
+ free(opt->conf_file_);
if(opt->switch_dev_)
free(opt->switch_dev_);
key_value_storage_clear(&opt->alias_table_);
+
+/* serialclient */
+ if(opt->serial_dev_)
+ free(opt->serial_dev_);
+ if(opt->type_)
+ free(opt->type_);
}
void options_print_usage()
@@ -304,11 +328,17 @@ void options_print_usage()
printf(" [-P|--write-pid] <path> write pid to this file\n");
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
- 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");
+#ifdef OPT_SWITCHCTL
+ printf(" [-f|--config] <file> the configuration file e.g. /etc/rhctl/switchctl.conf\n");
+ printf(" [-d|--device] <tty> the tty the audio switch is connected to e.g. /dev/audioswitch\n");
+ printf(" [-m|--mode] <mode> the initial mode to use e.g. master\n");
+ printf(" [-c|--channel] <channel> the initial channel to use e.g. main\n");
+#endif
+#ifdef OPT_SERIALCLIENT
+ printf(" [-d|--device] <tty> the tty to connect to e.g. /dev/ttyUSB0\n");
+ printf(" [-t|--type] <type> use this client type\n");
+#endif
}
void options_print(options_t* opt)
@@ -325,11 +355,19 @@ void options_print(options_t* opt)
printf("log_targets: \n");
string_list_print(&opt->log_targets_, " '", "'\n");
+ printf("command_sock: '%s'\n", opt->command_sock_);
+
+#ifdef OPT_SWITCHCTL
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_);
printf("alias_table: \n");
key_value_storage_print(&opt->alias_table_, " '", "' -> '", "'\n");
+#endif
+
+#ifdef OPT_SERIALCLIENT
+ printf("serial_dev: '%s'\n", opt->serial_dev_);
+ printf("type: '%s'\n", opt->type_);
+#endif
}