]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge commit 'meins/master'
authorAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 14:36:46 +0000 (15:36 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 6 Dec 2008 14:36:46 +0000 (15:36 +0100)
32 files changed:
Makefile.in
aacdec_filter.c
alsa_write.c
alsa_write.ggo
amp_filter.c
amp_filter.ggo
audiod.c
audiod_command.c
compress_filter.c
compress_filter.ggo
configure.ac
error.h
fade.c
file_write.c
file_write.ggo
filter.c
filter.ggo
filter.h
filter_common.c
ggo.c [new file with mode: 0644]
ggo.h [new file with mode: 0644]
grab_client.c
gui.c
mp3dec_filter.c
oggdec_filter.c
oggdec_filter.ggo
server.c
wav_filter.c
write.c
write.ggo
write.h
write_common.c

index 9e60b0df1f399b94bc1c90c7915366bb083fa970..1563739bfa50cd9c47cda249057a986e83b53668 100644 (file)
@@ -116,6 +116,8 @@ 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";; \
+               filter.ggo) O="--no-handle-help";; \
+               write.ggo) O="--no-handle-help";; \
        esac; \
        if test $< != fsck.ggo; then O="$$O --conf-parser "; fi; \
        gengetopt $$O \
@@ -143,6 +145,14 @@ man/man1/para_audiod.1: para_audiod audiod_command_list.man
        mkdir -p man/man1
        help2man -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
 
+man/man1/para_filter.1: para_filter
+       mkdir -p man/man1
+       help2man -h --detailed-help -N ./$< > $@
+
+man/man1/para_write.1: para_write
+       mkdir -p man/man1
+       help2man -h --detailed-help -N ./$< > $@
+
 man/man1/%.1: %
        mkdir -p man/man1
        help2man -N ./$< > $@
index 956f338db741586e7ee784d2e3523a41783fbf25..8eddc0e71566d7c9cb816a5d52d70e5d35bb5b84 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "error.h"
 #include "string.h"
index 89d1995caccc24ecc8f988dff8d5862c56ad0b69..ae471679f076f17fbce5b3d8d27ed5458d1fb4cd 100644 (file)
@@ -21,6 +21,7 @@
 #include "string.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "alsa_write.cmdline.h"
 #include "error.h"
@@ -236,10 +237,17 @@ err_out:
  */
 void alsa_write_init(struct writer *w)
 {
+       struct alsa_write_args_info dummy;
+
+       alsa_cmdline_parser_init(&dummy);
        w->open = alsa_open;
        w->close = alsa_close;
        w->pre_select = alsa_write_pre_select;
        w->post_select = alsa_write_post_select;
        w->parse_config = alsa_parse_config;
        w->shutdown = NULL; /* nothing to do */
+       w->help = (struct ggo_help) {
+               .short_help = alsa_write_args_info_help,
+               .detailed_help = alsa_write_args_info_detailed_help
+       };
 }
index 371ec89f259ebae40581c6031f6e3aba51dd23d3..84f49d58916bcce0ba51e1ab65347f25eb7c58a5 100644 (file)
@@ -1,28 +1,34 @@
-section "alsa options"
-######################
-
 option "device" d
 #~~~~~~~~~~~~~~~~
 "set PCM device"
-       string typestr="device"
-       default="default"
-       optional
+string typestr="device"
+default="default"
+optional
+details="
+       On systems with dmix, a better choice than the default
+       value might be to use \"plug:swmix\".
+"
 
 option "channels" c
 #~~~~~~~~~~~~~~~~~~
-"number of channels (only necessary for raw
-audio)"
-
-       int typestr="num"
-       default="2"
-       optional
+"specify number of channels"
+int typestr="num"
+default="2"
+optional
+details="
+       This option is only necessary for playing raw audio with
+       para_write.  In all other cases (plaing wav files with
+       para_write or using this writer with para_audiod), the number
+       of channels will be obtained from other resources.
+"
 
 option "samplerate" s
 #~~~~~~~~~~~~~~~~~~~~~
-
-"force given sample rate (only necessary for
-raw audio)"
-
-       int typestr="num"
-       default="44100"
-       optional
+"force given sample rate"
+int typestr="num"
+default="44100"
+optional
+details="
+       Again, it is only necessary to specify this when playing raw
+       audio with para_write.
+"
index 2f05260157de9e7103d1a717812981773489fd59..a88719e33544b4a08e3d74862ee54cf13cae3d19 100644 (file)
@@ -10,6 +10,7 @@
 #include "amp_filter.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "string.h"
 #include "error.h"
@@ -92,9 +93,15 @@ static void amp_open(struct filter_node *fn)
  */
 void amp_filter_init(struct filter *f)
 {
+       struct amp_filter_args_info dummy;
+
+       amp_cmdline_parser_init(&dummy);
        f->open = amp_open;
        f->close = amp_close;
        f->convert = amp_convert;
-       f->print_help = amp_cmdline_parser_print_help;
        f->parse_config = amp_parse_config;
+       f->help = (struct ggo_help) {
+               .short_help = amp_filter_args_info_help,
+               .detailed_help = amp_filter_args_info_detailed_help
+       };
 }
index 1849dc3ab4fcc3e6e2ad8dbeddf93931978cbd8e..865df3ac4048b330daf9055ffb47c2b1a2999eb3 100644 (file)
@@ -1,6 +1,5 @@
-section "The amplify filter"
-
 option "amp" a
+#~~~~~~~~~~~~~
 "amplification value"
 int typestr="number"
 default="32"
@@ -10,12 +9,9 @@ details="
        which the amplitude of the audio stream is multiplied. The
        formula for the scaling factor is
 
-               factor = 1 + amp / 64
+               factor = 1 + amp / 64.
 
-       amp value       scaling factor
-       ~~~~~~~~~       ~~~~~~~~~~~~~~
-       0               1
-       32              1.5
-       64              2
-       128             3
+       For example, an amplifiction value of zero results in a
+       scaling factor of one while an amplification value of 64
+       means to double the volume.
 "
index b9bd852aeba0ee3c65f9eec62ed6de977d41126a..bd0d049a457a4cbc35406eb1d59801e59879ca0a 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -15,6 +15,7 @@
 #include "list.h"
 #include "sched.h"
 #include "recv.h"
+#include "ggo.h"
 #include "filter.h"
 #include "grab_client.cmdline.h"
 #include "grab_client.h"
@@ -186,7 +187,7 @@ out:
  * \param ll loglevel
  * \param fmt the format string
  */
-void para_log(int ll, const char* fmt,...)
+__printf_2_3 void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
        FILE *outfd;
index fe8143ba928651e1aef5ccdb22d70e4200f0672f..27ef63caea22f9af45d9a951a5df39d1cb078210 100644 (file)
@@ -14,6 +14,7 @@
 #include "list.h"
 #include "close_on_fork.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "grab_client.cmdline.h"
 #include "grab_client.h"
index bf129b4ad13b939ec7ceb7cbbd2cf6d3e9563225..c7af325385ae7013dc44d64fa061266903aee040 100644 (file)
@@ -14,6 +14,7 @@
 #include "compress_filter.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "string.h"
 #include "error.h"
@@ -120,9 +121,15 @@ static void open_compress(struct filter_node *fn)
  */
 void compress_filter_init(struct filter *f)
 {
+       struct compress_filter_args_info dummy;
+
+       compress_cmdline_parser_init(&dummy);
        f->open = open_compress;
        f->close = close_compress;
        f->convert = compress;
-       f->print_help = compress_cmdline_parser_print_help;
        f->parse_config = compress_parse_config;
+       f->help = (struct ggo_help) {
+               .short_help = compress_filter_args_info_help,
+               .detailed_help = compress_filter_args_info_detailed_help
+       };
 }
index 3f4f8e2ea8ccabc745bc1770809b96e43063b728..74dcbc0332753e1011962a62c9dbe961881b4d1f 100644 (file)
@@ -1,7 +1,37 @@
-section "The dynamic audio range compressor"
+option "blocksize" b
+#~~~~~~~~~~~~~~~~~~~
+"adjust block size"
+int typestr="number"
+default="15"
+optional
+details = "
+       Larger blocksize means fewer volume adjustments per time unit.
+"
 
-option "blocksize" b "larger blocksize means fewer volume adjustments per time unit" int typestr="number" default="15" optional
-option "aggressiveness" a "controls the maximum amount to amplify by" int typestr="number" default="4" optional
-option "inertia" i "how much inertia ramping has" int typestr="number" default="6" optional
-option "target_level" t "target signal level (0-32768)" int typestr="number" default="20000" optional
-option "damp" d "if non-zero, scale down after normalizing" int typestr="number" default="0" optional
+option "aggressiveness" a
+#~~~~~~~~~~~~~~~~~~~~~~~~
+ "controls the maximum amount to amplify by"
+int typestr="number"
+default="4"
+optional
+
+option "inertia" i
+#~~~~~~~~~~~~~~~~~
+ "how much inertia ramping has"
+ int typestr="number"
+default="6"
+optional
+
+option "target_level" t
+#~~~~~~~~~~~~~~~~~~~~~~
+"target signal level (0-32768)"
+int typestr="number"
+default="20000"
+optional
+
+option "damp" d
+#~~~~~~~~~~~~~~
+"if non-zero, scale down after normalizing"
+int typestr="number"
+default="0"
+optional
index f62a2038a1524d49ea5c7926c9aaa593dcdab1f6..62223839a82d9ce85d00e08e3f0e95b256d8c67b 100644 (file)
@@ -83,7 +83,7 @@ daemon stat crypt http_send close_on_fork ipc acl afh fade amp_filter
 dccp_send fd user_list chunk_queue afs osl aft mood score attribute blob ringbuffer
 playlist sha1 rbtree sched audiod grab_client filter_common wav_filter compress_filter
 http_recv dccp_recv recv_common write_common file_write audiod_command
-client_common recv stdout filter stdin audioc write client fsck exec send_common"
+client_common recv stdout filter stdin audioc write client fsck exec send_common ggo"
 
 all_executables="server recv filter audioc write client fsck afh"
 
@@ -96,7 +96,7 @@ receivers=" http dccp"
 senders=" http dccp"
 
 filter_cmdline_objs="filter.cmdline compress_filter.cmdline amp_filter.cmdline"
-filter_errlist_objs="filter_common wav_filter compress_filter filter string stdin stdout sched fd amp_filter"
+filter_errlist_objs="filter_common wav_filter compress_filter filter string stdin stdout sched fd amp_filter ggo"
 filter_ldflags=""
 filters=" compress wav amp"
 
@@ -110,7 +110,7 @@ audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
 audiod_errlist_objs="audiod signal string daemon stat net
        time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
        recv_common fd sched write_common file_write audiod_command crypt
-       client_common"
+       client_common ggo"
 audiod_ldflags=""
 audiod_audio_formats=""
 
@@ -127,7 +127,7 @@ server_ldflags=""
 server_audio_formats=" mp3"
 
 write_cmdline_objs="write.cmdline file_write.cmdline"
-write_errlist_objs="write write_common file_write time fd string sched stdin"
+write_errlist_objs="write write_common file_write time fd string sched stdin ggo"
 write_ldflags=""
 writers=" file"
 default_writer="FILE_WRITE"
diff --git a/error.h b/error.h
index 89910a47cd028c0eeb851b428bf08afca928e8b2..37ff48a9463780220cd7e02b431d622080a432a4 100644 (file)
--- a/error.h
+++ b/error.h
@@ -28,6 +28,7 @@ DEFINE_ERRLIST_OBJECT_ENUM;
 #define IPC_ERRORS
 #define DCCP_SEND_ERRORS
 #define HTTP_SEND_ERRORS
+#define GGO_ERRORS
 
 
 extern const char **para_errlist[];
diff --git a/fade.c b/fade.c
index 48faed83124baeea273337ae950b0e88aeb8fc03..33f1ccbeda51ae52cc1dd6a627b545aee84b0923 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -28,7 +28,7 @@
 INIT_FADE_ERRLISTS;
 struct fade_args_info conf;
 
-void para_log(__a_unused int ll, const char *fmt,...)
+__printf_2_3 void para_log(__a_unused int ll, const char *fmt, ...)
 {
        va_list argp;
        time_t t1;
index 839515f88ada154bcabc9d89b4a0f274d5911a94..533d33313136133f675a80ca7db98a2aba6f8346 100644 (file)
@@ -12,6 +12,7 @@
 #include "para.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "string.h"
 #include "fd.h"
@@ -109,10 +110,17 @@ __malloc static void *file_write_parse_config(const char *options)
 /** the init function of the file writer */
 void file_write_init(struct writer *w)
 {
+       struct file_write_args_info dummy;
+
+       file_cmdline_parser_init(&dummy);
        w->open = file_write_open;
        w->pre_select = file_write_pre_select;
        w->post_select = file_write_post_select;
        w->parse_config = file_write_parse_config;
        w->close = file_write_close;
        w->shutdown = NULL; /* nothing to do */
+       w->help = (struct ggo_help) {
+               .short_help = file_write_args_info_help,
+               .detailed_help = file_write_args_info_detailed_help
+       };
 }
index a172f75779aa201bf6b82f9808443b9c41275b1e..56c44f7a7a6096b0e7e338f9571168bb5f1c56d4 100644 (file)
@@ -1,11 +1,9 @@
-section "file writer options"
-
 option "filename" f
 #~~~~~~~~~~~~~~~~~~
-
-"select output file name. Defaults to a
-random filename in ~/.paraslash."
-
-       string typestr="filename"
-       optional
+"specify output file name"
+string typestr="filename"
+optional
+details="
+       Defaults to a random filename in ~/.paraslash.
+"
 
index b97bdaaa3cbc9de39d62573da476495c73cc3e6a..0ffb723e218793a2ac69f4d905b643adb04667c3 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -11,6 +11,7 @@
 #include "filter.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "string.h"
 #include "stdin.h"
@@ -94,15 +95,44 @@ err:
        return ret;
 }
 
+__noreturn static void print_help_and_die(void)
+{
+       int i, d = conf.detailed_help_given;
+       const char **p = d? filter_args_info_detailed_help
+               : filter_args_info_help;
+
+       printf_or_die("%s\n\n", FILTER_CMDLINE_PARSER_PACKAGE "-"
+               FILTER_CMDLINE_PARSER_VERSION);
+       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);
+       }
+       exit(0);
+}
+
 static int parse_config(int argc, char *argv[])
 {
        static char *cf; /* config file */
        struct stat statbuf;
-       int i;
 
        if (filter_cmdline_parser(argc, argv, &conf))
                return -E_FILTER_SYNTAX;
        HANDLE_VERSION_FLAG("filter", conf);
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
        if (!cf) {
                char *home = para_homedir();
                cf = make_message("%s/.paraslash/filter.conf", home);
@@ -118,15 +148,7 @@ static int parse_config(int argc, char *argv[])
                if (filter_cmdline_parser_config_file(cf, &conf, &params))
                        return -E_FILTER_SYNTAX;
        }
-       if (!conf.list_filters_given)
-               return 1;
-       printf("available filters: ");
-       FOR_EACH_SUPPORTED_FILTER(i)
-               printf("%s%s%s", i? " " : "", filters[i].name,
-                       filters[i].parse_config? "*": "");
-       printf("\nFilters marked with \"*\" have further command line options. Try\n"
-               "\tpara_filter -f '<filtername> -h'\nfor more information.\n");
-       exit(EXIT_SUCCESS);
+       return 1;
 }
 
 /**
index 111e87c698bcfb33441f47d971cb94e02b5ef5fd..5376a6f8c73996c8e85444cfb781f1b755b03911 100644 (file)
@@ -1,17 +1,24 @@
-option "loglevel" l "set loglevel (0-6)" int typestr="level" default="4" optional
-option "filter" f "Specify filter.
+option "loglevel" l
+#~~~~~~~~~~~~~~~~~~
+ "set loglevel (0-6)"
+int typestr="level"
+default="4"
+optional
 
-May be given multiple times to 'pipe' the stream
-through arbitrary many filters in an efficient
-way.  The same filter may appear more than once,
-order matters.
+option "filter" f
+#~~~~~~~~~~~~~~~~
+"Specify filter."
+string typestr="filter_spec"
+optional
+multiple
+details="
+       May be given multiple times to 'pipe' the stream through
+       arbitrary many filters in an efficient way.  The same filter
+       may appear more than once, order matters.
 
-Filter options may be specified for each '-f'
-option separately. Note that you will have to
-quote these options like this:
+       Filter options may be specified for each '-f' option
+       separately. Note that you will have to quote these options
+       like this:
 
-       -f 'compress --inertia 5 --damp 2'
+               -f 'compress --inertia 5 --damp 2'
 "
-string typestr="filter_spec" optional multiple
-
-option "list_filters" L "print list of available filters and exit" flag off
index 39cec9ba03f4cbee46497b43fda7bdebc7b63dbb..0c3ac70834b6c3909bd59bc87b9121811c6d3620 100644 (file)
--- a/filter.h
+++ b/filter.h
@@ -183,13 +183,6 @@ struct filter {
         * by the open() function.
         */
        void (*close)(struct filter_node *fn);
-       /**
-        * Print the help text for this filter and exit.
-        *
-        * This is optional and it is not necessary to initialize this pointer if
-        * the filter does not have a help text.
-        */
-       void (*print_help)(void);
        /**
         * A pointer to the filter's command line parser.
         *
@@ -203,6 +196,8 @@ struct filter {
         * argv. On failure, a negative paraslash error code must be returned.
         */
        int (*parse_config)(int argc, char **argv, void **config);
+
+       struct ggo_help help;
 };
 
 void close_filters(struct filter_chain *fc);
index 29d6c957498216a9cec77b6ccd4a7f03b65385aa..45f576050c6f34a56dfb8f6cfff495478466f212 100644 (file)
@@ -13,6 +13,7 @@
 #include "list.h"
 #include "sched.h"
 #include "fd.h"
+#include "ggo.h"
 #include "filter.h"
 #include "error.h"
 #include "string.h"
diff --git a/ggo.c b/ggo.c
new file mode 100644 (file)
index 0000000..55f1043
--- /dev/null
+++ b/ggo.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
+/** \file ggo.c Function for printing help. */
+
+
+#include "para.h"
+#include "ggo.h"
+
+__printf_1_2 void printf_or_die(const char *fmt, ...)
+{
+       va_list argp;
+       int ret;
+
+       va_start(argp, fmt);
+       ret = vprintf(fmt, argp);
+       va_end(argp);
+       if (ret >= 0)
+               return;
+       fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
+}
+
+void ggo_print_help(struct ggo_help *help, int detailed_help)
+{
+       const char **p;
+
+       if (!help)
+               return;
+       if (detailed_help)
+               p = help->detailed_help;
+       else
+               p = help->short_help;
+       if (!p)
+               return;
+       p += 3; /* skip -h and -V */
+       for (; *p; p++)
+               printf_or_die("\t%s\n", *p);
+}
diff --git a/ggo.h b/ggo.h
new file mode 100644 (file)
index 0000000..c9111b1
--- /dev/null
+++ b/ggo.h
@@ -0,0 +1,7 @@
+struct ggo_help {
+       const char **short_help;
+       const char **detailed_help;
+};
+
+void ggo_print_help(struct ggo_help *help, int detailed_help);
+void printf_or_die(const char *fmt, ...);
index 77d3616d2c2e41b3caf32f5fea13d54cf778642b..b9d70147bb63de054005be4eb17f13e5ae42ee43 100644 (file)
@@ -18,6 +18,7 @@
 #include "grab_client.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "grab_client.h"
 #include "audiod.h"
diff --git a/gui.c b/gui.c
index 588507154bfb0e620b256c08c2ce6914b1b7c0e6..616890299047629dcaad4541a239efae19f2b76c 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -489,7 +489,7 @@ static int add_output_line(char *line, __a_unused void *data)
        return 1;
 }
 
-void para_log(int ll, const char *fmt,...)
+__printf_2_3 void para_log(int ll, const char *fmt,...)
 {
        int color;
        char *msg;
index aa2ab510240e448c410dddc90fb445e471859445..ce6cfbcb6e78eebe60764a5dc617cf5b89fd1b53 100644 (file)
@@ -10,6 +10,7 @@
 #include "mp3dec_filter.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "error.h"
 #include <mad.h>
@@ -150,8 +151,15 @@ err:
  */
 void mp3dec_filter_init(struct filter *f)
 {
+       struct mp3dec_filter_args_info dummy;
+
+       mp3dec_cmdline_parser_init(&dummy);
        f->open = mp3dec_open;
        f->convert = mp3dec;
        f->close = mp3dec_close;
        f->parse_config = mp3dec_parse_config;
+       f->help = (struct ggo_help) {
+               .short_help = mp3dec_filter_args_info_help,
+               .detailed_help = mp3dec_filter_args_info_detailed_help
+       };
 }
index 689fc7aac57739ba23989616d4e8cbfb1ed761b1..0653f7dadd0d7223e27ea9e339d113420aaa7a5f 100644 (file)
@@ -11,6 +11,7 @@
 #include "oggdec_filter.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "error.h"
 #include "string.h"
@@ -195,9 +196,15 @@ err:
  */
 void oggdec_filter_init(struct filter *f)
 {
+       struct oggdec_filter_args_info dummy;
+
+       oggdec_cmdline_parser_init(&dummy);
        f->open = ogg_open;
        f->close = ogg_close;
        f->convert = ogg_convert;
-       f->print_help = oggdec_cmdline_parser_print_help;
        f->parse_config = oggdec_parse_config;
+       f->help = (struct ggo_help) {
+               .short_help = oggdec_filter_args_info_help,
+               .detailed_help = oggdec_filter_args_info_detailed_help
+       };
 }
index f088b9379b39104eaf30fdabeb8acd442f9cd904..e2d653d7dafc8674ea95eff31197597284ae29e3 100644 (file)
@@ -16,6 +16,6 @@ int typestr="kilobyte"
 default="16"
 optional
 details="
-       The oggdec filter waits until at least that many bytes are available
-       in the input buffer.
+       On startup, defer decoding until that many kilobytes are
+       available in the input buffer.
 "
index 459f44621bb5c1f8350f2c5192edaa15362b5335..0924ace4b07eac452a193df49c4b48bf6c8562aa 100644 (file)
--- a/server.c
+++ b/server.c
@@ -136,7 +136,7 @@ struct server_command_task {
  * \param ll The log level.
  * \param fmt The format string describing the log message.
  */
-void para_log(int ll, const char* fmt,...)
+__printf_2_3 void para_log(int ll, const char* fmt,...)
 {
        va_list argp;
        FILE *outfd;
index 3fce556d5d1ecb514b0cffeec869103ff0bec178..d30b018de4f6f1a8554e1619ba7e97486d7c7b3e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "filter.h"
 #include "string.h"
 #include "portable_io.h"
diff --git a/write.c b/write.c
index 998a6d2cccde01cf45bcb6e5dea9d5e11c3f7da0..6e78e773c558f3d1c6d5fd8a15d0532645cec570 100644 (file)
--- a/write.c
+++ b/write.c
@@ -14,6 +14,7 @@
 #include "write.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "stdin.h"
 #include "write.h"
 #include "write_common.h"
@@ -129,20 +130,6 @@ static struct writer_node_group *check_args(void)
        struct writer_node_group *g = NULL;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
-       if (conf.list_writers_given) {
-               char *msg = NULL;
-               FOR_EACH_WRITER(i) {
-                       char *tmp = make_message("%s%s%s",
-                               i? msg : "",
-                               i? " " : "",
-                               writer_names[i]);
-                       free(msg);
-                       msg = tmp;
-               }
-               fprintf(stderr, "%s\n", msg);
-               free(msg);
-               exit(EXIT_SUCCESS);
-       }
        if (conf.start_time_given) {
                long unsigned sec, usec;
                if (sscanf(conf.start_time_arg, "%lu:%lu",
@@ -174,6 +161,33 @@ out:
        return NULL;
 }
 
+__noreturn static void print_help_and_die(void)
+{
+       int i, d = conf.detailed_help_given;
+       const char **p = d? write_args_info_detailed_help
+               : write_args_info_help;
+
+       printf_or_die("%s\n\n", WRITE_CMDLINE_PARSER_PACKAGE "-"
+               WRITE_CMDLINE_PARSER_VERSION);
+       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);
+       }
+       exit(0);
+}
+
 /**
  * Para_write's main function.
  *
@@ -192,9 +206,11 @@ int main(int argc, char *argv[])
        struct check_wav_task *cwt = &the_check_wav_task;
        struct initial_delay_task *idt = &the_initial_delay_task;
 
+       init_supported_writers();
        write_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("write", conf);
-       init_supported_writers();
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
 
        wng = check_args();
        if (!wng)
index 1ea8abf29265d9bc6c569f7fbeda5734cd70e972..8f557bb9de6ae1284a2e7e284e618cf75d4995bf 100644 (file)
--- a/write.ggo
+++ b/write.ggo
@@ -1,45 +1,35 @@
-section "general options"
-#########################
-
-option "list_writers" L
-#~~~~~~~~~~~~~~~~~~~~~~
-"print available writers and exit"
-
-       flag off
-
 option "loglevel" l
 #~~~~~~~~~~~~~~~~~~
 "set loglevel (0-6)"
-
-       int typestr="level"
-       default="4"
-       optional
+int typestr="level"
+default="4"
+optional
 
 option "bufsize" b
 #~~~~~~~~~~~~~~~~~
 "input buffer size"
-
-       int typestr="kilobytes"
-       default="64"
-       optional
+int typestr="kilobytes"
+default="64"
+optional
 
 option "writer" w
 #~~~~~~~~~~~~~~~~
-
-"select stream writer
-may be give multiple times. The same writer
-may be specified more than once"
-
-       string typestr="name"
-       default="alsa (file if alsa is unsupported)"
-       optional
-       multiple
+"select stream writer"
+string typestr="name"
+default="alsa (file if alsa is unsupported)"
+optional
+multiple
+details="
+       May be give multiple times. The same writer may be specified
+       more than once.
+"
 
 option "start_time" t
 #~~~~~~~~~~~~~~~~~~~~
-"start playback at given time which must be
-in a:b format where a denotes seconds and b
-denotes microseconds since the epoch"
-
-       string typestr="timeval"
-       optional
+"defer playback"
+string typestr="timeval"
+optional
+details="
+       Start playback at given time which must be in a:b format where
+       a denotes seconds and b denotes microseconds since the epoch.
+"
diff --git a/write.h b/write.h
index 9723977ae4357506ac1c6b64284695577d1e5683..7df62f9f08e68090afe45cb09ec43dde024b7fab 100644 (file)
--- a/write.h
+++ b/write.h
@@ -84,6 +84,7 @@ struct writer {
         * This is a optional function pointer used for cleaning up.
         */
        void (*shutdown)(struct writer_node *);
+       struct ggo_help help;
 };
 
 /**
index 3bf5d1199f560e9ce93b7d97a06e278ce495591f..d66b20ca112dd7cb1135d9211ff880cd2a2fc39c 100644 (file)
@@ -10,6 +10,7 @@
 #include "string.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "write.h"
 #include "error.h"