From 84f7ba47c32bfe5f31ee733f911c3a158ad774bb Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 3 Sep 2014 23:57:59 +0200 Subject: updated options parser --- src/options.c | 62 +++++++++++++++++------------------------------------------ src/options.h | 12 ++++-------- src/sydra.c | 11 ++++++++++- 3 files changed, 32 insertions(+), 53 deletions(-) diff --git a/src/options.c b/src/options.c index 1273542..afe9a37 100644 --- a/src/options.c +++ b/src/options.c @@ -198,21 +198,13 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_) PARSE_STRING_LIST("-L","--log", opt->log_targets_) PARSE_BOOL_PARAM("-U", "--debug", opt->debug_) - PARSE_STRING_PARAM("-s","--source", opt->src_bin_desc_) - PARSE_STRING_PARAM("-d","--output-dir", opt->output_dir_) - PARSE_STRING_PARAM("-f","--name-format", opt->name_format_) - PARSE_INT_PARAM("-m","--mode", opt->mode_, 8) - PARSE_BOOL_PARAM("-n", "--nocache", opt->nocache_) - PARSE_INT_PARAM("-i","--interval", opt->interval_, 10) - PARSE_INT_PARAM("-o","--offset", opt->offset_, 10) - PARSE_STRING_PARAM("-x","--post-process", opt->post_process_) + PARSE_STRING_PARAM("-n","--appname", opt->appname_) + PARSE_STRING_PARAM("-R","--rec-dir", opt->rec_dir_) + PARSE_STRING_PARAM("-r","--rec-name-format", opt->rec_name_format_) else return i; } - if(opt->interval_ <= 0) - return -4; - if(opt->debug_) { string_list_add(&opt->log_targets_, "stdout:5"); opt->daemonize_ = 0; @@ -246,14 +238,9 @@ void options_default(options_t* opt) opt->pid_file_ = NULL; string_list_init(&opt->log_targets_); opt->debug_ = 0; - opt->src_bin_desc_ = NULL; - opt->output_dir_ = strdup("/srv/archiv"); - opt->name_format_ = strdup("%Y-%m-%d-%H00.ogg"); - opt->mode_ = 0644; - opt->nocache_ = 0; - opt->interval_ = 50; - opt->offset_ = 0; - opt->post_process_ = NULL; + opt->appname_ = NULL; + opt->rec_dir_ = strdup("./recordings/"); + opt->rec_name_format_ = strdup("%Y-%m-%d_%H-%M-$S"); } void options_clear(options_t* opt) @@ -272,14 +259,12 @@ void options_clear(options_t* opt) if(opt->pid_file_) free(opt->pid_file_); string_list_clear(&opt->log_targets_); - if(opt->src_bin_desc_) - free(opt->src_bin_desc_); - if(opt->output_dir_) - free(opt->output_dir_); - if(opt->name_format_) - free(opt->name_format_); - if(opt->post_process_) - free(opt->post_process_); + if(opt->appname_) + free(opt->appname_); + if(opt->rec_dir_) + free(opt->rec_dir_); + if(opt->rec_name_format_) + free(opt->rec_name_format_); } void options_print_usage() @@ -295,15 +280,9 @@ void options_print_usage() printf(" [-L|--log] :[,[,..]]\n"); printf(" add a log target, can be invoked several times\n"); printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n"); - printf(" [-s|--source] a gstreamer pipeline-style description which will be used\n"); - printf(" as data source, see gst-launch man-page for syntax\n"); - printf(" [-d|--output-dir] path to the output directory\n"); - printf(" [-f|--name-format] the file name format, see manpage of strftime for the syntax\n"); - printf(" [-m|--mode] octal representation of the file permission mode\n"); - printf(" [-n|--nocache] Use O_DIRECT for recorded files\n"); - printf(" [-i|--interval] interval for time checks in ms\n"); - printf(" [-o|--offset] time offset for recordings in ms\n"); - printf(" [-x|--post-process]