From 5ba8f6dff01904907d1dcfaa1555c8ceb5a72c90 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 6 Dec 2008 17:56:08 +0100 Subject: [PATCH] Improve help/man page of para_recv. --- Makefile.in | 5 +++++ audiod.c | 2 +- configure.ac | 2 +- dccp_recv.c | 8 ++++++++ dccp_recv.ggo | 16 +++++++++++++--- http_recv.c | 8 ++++++++ http_recv.ggo | 18 +++++++++++++++--- ortp_recv.c | 8 ++++++++ ortp_recv.ggo | 23 +++++++++++++++++++---- recv.c | 43 ++++++++++++++++++++++++++++++++----------- recv.ggo | 22 +++++++++++++++------- recv.h | 4 ++++ recv_common.c | 1 + 13 files changed, 130 insertions(+), 30 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1563739b..f4bae24a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -116,6 +116,7 @@ grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo audioc.ggo) O="--unamed-opts=command";; \ fsck.ggo) O="--unamed-opts=table";; \ afh.ggo) O="--unamed-opts=audio_file";; \ + recv.ggo) O="--no-handle-help";; \ filter.ggo) O="--no-handle-help";; \ write.ggo) O="--no-handle-help";; \ esac; \ @@ -153,6 +154,10 @@ man/man1/para_write.1: para_write mkdir -p man/man1 help2man -h --detailed-help -N ./$< > $@ +man/man1/para_recv.1: para_recv + mkdir -p man/man1 + help2man -h --detailed-help -N ./$< > $@ + man/man1/%.1: % mkdir -p man/man1 help2man -N ./$< > $@ diff --git a/audiod.c b/audiod.c index bd0d049a..22611eb0 100644 --- a/audiod.c +++ b/audiod.c @@ -14,8 +14,8 @@ #include "audiod.cmdline.h" #include "list.h" #include "sched.h" -#include "recv.h" #include "ggo.h" +#include "recv.h" #include "filter.h" #include "grab_client.cmdline.h" #include "grab_client.h" diff --git a/configure.ac b/configure.ac index 62223839..664280ac 100644 --- a/configure.ac +++ b/configure.ac @@ -89,7 +89,7 @@ all_executables="server recv filter audioc write client fsck afh" recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline" recv_errlist_objs="http_recv recv_common recv time string net dccp_recv - fd sched stdout" + fd sched stdout ggo" recv_ldflags="" receivers=" http dccp" diff --git a/dccp_recv.c b/dccp_recv.c index d0bc5354..c73088f8 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -18,6 +18,7 @@ #include "error.h" #include "list.h" #include "sched.h" +#include "ggo.h" #include "recv.h" #include "string.h" #include "net.h" @@ -143,10 +144,17 @@ static void dccp_recv_post_select(struct sched *s, struct task *t) */ void dccp_recv_init(struct receiver *r) { + struct dccp_recv_args_info dummy; + + dccp_recv_cmdline_parser_init(&dummy); r->shutdown = dccp_shutdown; r->open = dccp_recv_open; r->close = dccp_recv_close; r->pre_select = dccp_recv_pre_select; r->post_select = dccp_recv_post_select; r->parse_config = dccp_recv_parse_config; + r->help = (struct ggo_help) { + .short_help = dccp_recv_args_info_help, + .detailed_help = dccp_recv_args_info_detailed_help + }; } diff --git a/dccp_recv.ggo b/dccp_recv.ggo index 52cfef6d..9717329d 100644 --- a/dccp_recv.ggo +++ b/dccp_recv.ggo @@ -1,3 +1,13 @@ -section "options of the dccp receiver" -option "host" i "ip or host" string default="localhost" optional -option "port" p "port to connect to" int default="8000" optional +option "host" i +"ip or host" +string default="localhost" +optional +details=" + Both IPv4 and IPv6 addresses are supported. +" + +option "port" p +"port to connect to" +int +default="8000" +optional diff --git a/http_recv.c b/http_recv.c index c7eb485a..7716bb0f 100644 --- a/http_recv.c +++ b/http_recv.c @@ -14,6 +14,7 @@ #include "http.h" #include "list.h" #include "sched.h" +#include "ggo.h" #include "recv.h" #include "http_recv.cmdline.h" #include "net.h" @@ -189,10 +190,17 @@ static int http_recv_open(struct receiver_node *rn) */ void http_recv_init(struct receiver *r) { + struct http_recv_args_info dummy; + + http_recv_cmdline_parser_init(&dummy); r->open = http_recv_open; r->close = http_recv_close; r->pre_select = http_recv_pre_select; r->post_select = http_recv_post_select; r->shutdown = http_shutdown; r->parse_config = http_recv_parse_config; + r->help = (struct ggo_help) { + .short_help = http_recv_args_info_help, + .detailed_help = http_recv_args_info_detailed_help + }; } diff --git a/http_recv.ggo b/http_recv.ggo index c368efd7..2f1b4d61 100644 --- a/http_recv.ggo +++ b/http_recv.ggo @@ -1,3 +1,15 @@ -section "options of the http receiver" -option "host" i "ip or host" string default="localhost" optional -option "port" p "tcp port to connect to" int default="8000" optional +option "host" i +#~~~~~~~~~~~~~~ +"ip or host" +string +default="localhost" +optional +details=" + Both IPv4 and IPv6 addresses are supported. +" + +option "port" p +#~~~~~~~~~~~~~~ +"tcp port to connect to" +int default="8000" +optional diff --git a/ortp_recv.c b/ortp_recv.c index 164c1cb0..102fe9ac 100644 --- a/ortp_recv.c +++ b/ortp_recv.c @@ -11,6 +11,7 @@ #include "ortp.h" #include "list.h" #include "sched.h" +#include "ggo.h" #include "recv.h" #include "ortp_recv.cmdline.h" @@ -280,12 +281,19 @@ static int ortp_recv_open(struct receiver_node *rn) */ void ortp_recv_init(struct receiver *r) { + struct ortp_recv_args_info dummy; + + ortp_recv_cmdline_parser_init(&dummy); r->shutdown = ortp_shutdown; r->open = ortp_recv_open; r->close = ortp_recv_close; r->pre_select = ortp_recv_pre_select; r->post_select = ortp_recv_post_select; r->parse_config = ortp_recv_parse_config; + r->help = (struct ggo_help) { + .short_help = ortp_recv_args_info_help, + .detailed_help = ortp_recv_args_info_detailed_help + }; ortp_init(); } diff --git a/ortp_recv.ggo b/ortp_recv.ggo index 192f21c2..a706d543 100644 --- a/ortp_recv.ggo +++ b/ortp_recv.ggo @@ -1,4 +1,19 @@ -section "ortp options" -option "host" i "ip or host to receive rtp packets from" string default="224.0.1.38" optional -option "port" p "udp port." int typestr="portnumber" default="1500" optional -option "jitter_compensation" j "set ortp's adaptive jitter compensation" int typestr="milliseconds" default="0" optional +option "host" i +"ip or host to receive rtp packets from" +string default="224.0.1.38" +optional +details=" + The default address resoves to DANTZ.MCAST.NET and activates + multicast. +" + +option "port" p "udp port" +int typestr="portnumber" +default="1500" +optional + +option "jitter_compensation" j +"set ortp's adaptive jitter compensation" +int typestr="milliseconds" +default="0" +optional diff --git a/recv.c b/recv.c index 7ef78a90..1df476f7 100644 --- a/recv.c +++ b/recv.c @@ -12,6 +12,7 @@ #include "para.h" #include "list.h" #include "sched.h" +#include "ggo.h" #include "recv.h" #include "recv.cmdline.h" #include "fd.h" @@ -27,21 +28,41 @@ INIT_STDERR_LOGGING(conf.loglevel_arg); /** init array of error codes used by para_recv */ INIT_RECV_ERRLISTS; -static void *parse_config(int argc, char *argv[], int *receiver_num) +__noreturn static void print_help_and_die(void) { - int i; + printf("dsfsfsd\n"); + int i, d = conf.detailed_help_given; + const char **p = d? recv_args_info_detailed_help + : recv_args_info_help; + + printf_or_die("%s\n\n", RECV_CMDLINE_PARSER_PACKAGE "-" + RECV_CMDLINE_PARSER_VERSION); + 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); + } + exit(0); +} + +static void *parse_config(int argc, char *argv[], int *receiver_num) +{ if (recv_cmdline_parser(argc, argv, &conf)) return NULL; HANDLE_VERSION_FLAG("recv", conf); - if (conf.list_receivers_given) { - printf("available receivers: "); - for (i = 0; receivers[i].name; i++) - printf("%s%s", i? " " : "", receivers[i].name); - printf("\nTry\n\tpara_recv -r ' -h'\n" - "for help on .\n"); - exit(EXIT_SUCCESS); - } + if (conf.help_given || conf.detailed_help_given) + print_help_and_die(); return check_receiver_arg(conf.receiver_arg, receiver_num); } @@ -69,7 +90,7 @@ int main(int argc, char *argv[]) memset(&sot, 0, sizeof(struct stdout_task)); memset(&rn, 0, sizeof(struct receiver_node)); - for (ret = 0; receivers[ret].name; ret++) + FOR_EACH_RECEIVER(ret) receivers[ret].init(&receivers[ret]); ret = -E_RECV_SYNTAX; rn.conf = parse_config(argc, argv, &receiver_num); diff --git a/recv.ggo b/recv.ggo index febe1a9c..b7003b0e 100644 --- a/recv.ggo +++ b/recv.ggo @@ -1,11 +1,19 @@ -option "loglevel" l "set loglevel (0-6)" int typestr="level" default="4" optional -option "list_receivers" L "print list of available receivers" flag off -option "receiver" r "Select receiver. +option "loglevel" l +#~~~~~~~~~~~~~~~~~~ +"set loglevel (0-6)" +int typestr="level" +default="4" +optional -Any options for the selected receiver must -be quoted. Example: +option "receiver" r +"Select receiver" +string typestr="receiver_spec" +default="http" +optional +details=" + Any options for the selected receiver must + be quoted. Example: - -r 'http -i www.paraslash.org -p 8009' + -r 'http -i www.paraslash.org -p 8009' " -string typestr="receiver_spec" default="http" optional diff --git a/recv.h b/recv.h index d6c012b6..f8b15292 100644 --- a/recv.h +++ b/recv.h @@ -104,6 +104,8 @@ struct receiver { * \sa select(2), struct receiver. */ void (*post_select)(struct sched *s, struct task *t); + + struct ggo_help help; }; @@ -130,4 +132,6 @@ extern struct receiver receivers[]; ORTP_RECEIVER \ {.name = NULL}}; +#define FOR_EACH_RECEIVER(i) for (i = 0; receivers[i].name; i++) + void *check_receiver_arg(char *ra, int *receiver_num); diff --git a/recv_common.c b/recv_common.c index c8f97c9e..03f569fe 100644 --- a/recv_common.c +++ b/recv_common.c @@ -10,6 +10,7 @@ #include "list.h" #include "sched.h" +#include "ggo.h" #include "recv.h" #include "string.h" -- 2.39.5