From 5b4b082e7c37b46d5fa1729dff6496da8840085f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 7 Dec 2008 11:16:43 +0100 Subject: [PATCH] Make functions for printing recv/filter/write help public. So that these functions can also be used by audiod. --- filter.c | 17 ++--------------- filter.h | 2 +- filter_common.c | 19 +++++++++++++++++++ recv.c | 17 ++--------------- recv.h | 1 + recv_common.c | 18 ++++++++++++++++++ write.c | 16 ++-------------- write_common.c | 18 ++++++++++++++++++ write_common.h | 1 + 9 files changed, 64 insertions(+), 45 deletions(-) diff --git a/filter.c b/filter.c index 0ffb723e..d67aeae4 100644 --- a/filter.c +++ b/filter.c @@ -97,7 +97,7 @@ err: __noreturn static void print_help_and_die(void) { - int i, d = conf.detailed_help_given; + int d = conf.detailed_help_given; const char **p = d? filter_args_info_detailed_help : filter_args_info_help; @@ -106,20 +106,7 @@ __noreturn static void print_help_and_die(void) printf_or_die("%s\n\n", filter_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); - - printf_or_die("\nAvailable filters: \n\t"); - FOR_EACH_SUPPORTED_FILTER(i) - printf_or_die("%s%s", i? " " : "", filters[i].name); - printf_or_die("\n\n"); - - FOR_EACH_SUPPORTED_FILTER(i) { - struct filter *f = filters + i; - - if (!f->help.short_help) - continue; - printf_or_die("Options for %s:\n", f->name); - ggo_print_help(&f->help, d); - } + print_filter_helps(d); exit(0); } diff --git a/filter.h b/filter.h index 0c3ac708..c2a6310b 100644 --- a/filter.h +++ b/filter.h @@ -204,7 +204,7 @@ void close_filters(struct filter_chain *fc); void filter_init(struct filter *all_filters); int check_filter_arg(char *filter_arg, void **conf); void filter_pre_select(__a_unused struct sched *s, struct task *t); - +void print_filter_helps(int detailed); static inline void write_int16_host_endian(char *buf, int val) { diff --git a/filter_common.c b/filter_common.c index 45f57605..a39eefd6 100644 --- a/filter_common.c +++ b/filter_common.c @@ -263,3 +263,22 @@ int check_filter_arg(char *fa, void **conf) return -E_UNSUPPORTED_FILTER; } +void print_filter_helps(int detailed) +{ + int i; + + printf_or_die("\nAvailable filters: \n\t"); + FOR_EACH_SUPPORTED_FILTER(i) + printf_or_die("%s%s", i? " " : "", filters[i].name); + printf_or_die("\n\n"); + + FOR_EACH_SUPPORTED_FILTER(i) { + struct filter *f = filters + i; + + if (!f->help.short_help) + continue; + printf_or_die("Options for %s:\n", f->name); + ggo_print_help(&f->help, detailed); + } + +} diff --git a/recv.c b/recv.c index 1df476f7..52935a88 100644 --- a/recv.c +++ b/recv.c @@ -30,8 +30,7 @@ INIT_RECV_ERRLISTS; __noreturn static void print_help_and_die(void) { - printf("dsfsfsd\n"); - int i, d = conf.detailed_help_given; + int d = conf.detailed_help_given; const char **p = d? recv_args_info_detailed_help : recv_args_info_help; @@ -40,19 +39,7 @@ __noreturn static void print_help_and_die(void) printf_or_die("%s\n\n", recv_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); - - printf_or_die("\nAvailable receivers: \n\t"); - FOR_EACH_RECEIVER(i) - printf_or_die("%s%s", i? " " : "", receivers[i].name); - printf_or_die("\n\n"); - FOR_EACH_RECEIVER(i) { - struct receiver *r = receivers + i; - - if (!r->help.short_help) - continue; - printf_or_die("Options for %s:\n", r->name); - ggo_print_help(&r->help, d); - } + print_receiver_helps(d); exit(0); } diff --git a/recv.h b/recv.h index f8b15292..3aed0180 100644 --- a/recv.h +++ b/recv.h @@ -135,3 +135,4 @@ extern struct receiver receivers[]; #define FOR_EACH_RECEIVER(i) for (i = 0; receivers[i].name; i++) void *check_receiver_arg(char *ra, int *receiver_num); +void print_receiver_helps(int detailed); diff --git a/recv_common.c b/recv_common.c index 03f569fe..5f2412b5 100644 --- a/recv_common.c +++ b/recv_common.c @@ -84,3 +84,21 @@ void *check_receiver_arg(char *ra, int *receiver_num) PARA_ERROR_LOG("receiver not found\n"); return NULL; } + +void print_receiver_helps(int detailed) +{ + int i; + + printf_or_die("\nAvailable receivers: \n\t"); + FOR_EACH_RECEIVER(i) + printf_or_die("%s%s", i? " " : "", receivers[i].name); + printf_or_die("\n\n"); + FOR_EACH_RECEIVER(i) { + struct receiver *r = receivers + i; + + if (!r->help.short_help) + continue; + printf_or_die("Options for %s:\n", r->name); + ggo_print_help(&r->help, detailed); + } +} diff --git a/write.c b/write.c index 6e78e773..9b7a9211 100644 --- a/write.c +++ b/write.c @@ -163,7 +163,7 @@ out: __noreturn static void print_help_and_die(void) { - int i, d = conf.detailed_help_given; + int d = conf.detailed_help_given; const char **p = d? write_args_info_detailed_help : write_args_info_help; @@ -172,19 +172,7 @@ __noreturn static void print_help_and_die(void) printf_or_die("%s\n\n", write_args_info_usage); for (; *p; p++) printf_or_die("%s\n", *p); - - printf_or_die("\nAvailable writers: \n\t"); - FOR_EACH_WRITER(i) - printf_or_die("%s%s", i? " " : "", writer_names[i]); - printf_or_die("\n\n"); - FOR_EACH_WRITER(i) { - struct writer *w = writers + i; - - if (!w->help.short_help) - continue; - printf_or_die("Options for %s:\n", writer_names[i]); - ggo_print_help(&w->help, d); - } + print_writer_helps(d); exit(0); } diff --git a/write_common.c b/write_common.c index d66b20ca..5896d91c 100644 --- a/write_common.c +++ b/write_common.c @@ -211,3 +211,21 @@ struct writer_node_group *setup_default_wng(void) wng->writer_nodes[0].conf = writers[DEFAULT_WRITER].parse_config(""); return wng; } + +void print_writer_helps(int detailed) +{ + int i; + + printf_or_die("\nAvailable writers: \n\t"); + FOR_EACH_WRITER(i) + printf_or_die("%s%s", i? " " : "", writer_names[i]); + printf_or_die("\n\n"); + FOR_EACH_WRITER(i) { + struct writer *w = writers + i; + + if (!w->help.short_help) + continue; + printf_or_die("Options for %s:\n", writer_names[i]); + ggo_print_help(&w->help, detailed); + } +} diff --git a/write_common.h b/write_common.h index 8d94d2a0..7f0bbc57 100644 --- a/write_common.h +++ b/write_common.h @@ -12,3 +12,4 @@ struct writer_node_group *wng_new(unsigned num_writers); void init_supported_writers(void); void *check_writer_arg(const char *wa, int *writer_num); struct writer_node_group *setup_default_wng(void); +void print_writer_helps(int detailed); -- 2.39.5