]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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 1563739bfa50cd9c47cda249057a986e83b53668..f4bae24a6df311f86725f3860f20adfcc3fbd3b9 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 bd0d049a457a4cbc35406eb1d59801e59879ca0a..22611eb0db41f98c6ece8cfc70422eee478b5d63 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 62223839a82d9ce85d00e08e3f0e95b256d8c67b..664280ac9a4835e8e5fe1209584fb25217e2554a 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 d0bc53542137ac06cce22b75fcbe17d649041b9b..c73088f83939e153d94e3eb4dcead35d04a1ff05 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 52cfef6d7bbce0491676407d42b91a9794c2efaf..9717329d29b036baf460fb747901ea41b913e632 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 c7eb485a7797f282917c8c4d4b4d34889cba603b..7716bb0f9f9c5ba5439bb7cd70c2055887e7e3c1 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 c368efd7ad301339b86d02574f2b4e4f721152cc..2f1b4d61d54b3be411e2fb78a509685d8f4b07c2 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 164c1cb0be3a2e344ef3e74cc3e11521d64fb4c6..102fe9acb90c773d3d40c9d4939b02331c6ebe26 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 192f21c273044e23764e88e137abd51a7a856094..a706d543609059792baa32504cc4d986048433eb 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 7ef78a90368c7770c58e7878e60fa78aa819da75..1df476f79c2e4c2dce5c0a78d57c8c972b4ae3af 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 febe1a9cea5de7b6dd5e2a9d45a7accb253660b7..b7003b0e5b2bacde7b68c1028b39ca015e9105bd 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 d6c012b649a545da6c572afbb48a9ec572351b01..f8b1529236b143f95dfa4882acbb2c29e7eeb88f 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 c8f97c9e9d61ef914da8559bf7b10ce6fb3e4542..03f569fe3aff4386f9792881a023d7be520fad0e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "recv.h"
 #include "string.h"