Improve help/man page of para_recv.
authorAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 16:56:08 +0000 (17:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 16:56:08 +0000 (17:56 +0100)
13 files changed:
Makefile.in
audiod.c
configure.ac
dccp_recv.c
dccp_recv.ggo
http_recv.c
http_recv.ggo
ortp_recv.c
ortp_recv.ggo
recv.c
recv.ggo
recv.h
recv_common.c

index 1563739..f4bae24 100644 (file)
@@ -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 ./$< > $@
index bd0d049..22611eb 100644 (file)
--- 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"
index 6222383..664280a 100644 (file)
@@ -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"
index d0bc535..c73088f 100644 (file)
@@ -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
+       };
 }
index 52cfef6..9717329 100644 (file)
@@ -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
index c7eb485..7716bb0 100644 (file)
@@ -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
+       };
 }
index c368efd..2f1b4d6 100644 (file)
@@ -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
index 164c1cb..102fe9a 100644 (file)
@@ -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();
 }
index 192f21c..a706d54 100644 (file)
@@ -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 7ef78a9..1df476f 100644 (file)
--- 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 '<receivername> -h'\n"
-                       "for help on <receivername>.\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);
index febe1a9..b7003b0 100644 (file)
--- 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 d6c012b..f8b1529 100644 (file)
--- 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);
index c8f97c9..03f569f 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "recv.h"
 #include "string.h"