]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - audiod.c
audiod: Include help for receivers/filter/writers in help output.
[paraslash.git] / audiod.c
index b9bd852aeba0ee3c65f9eec62ed6de977d41126a..e3db6bea822d4f6fd5954e19436f28358b13d906 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -14,6 +14,7 @@
 #include "audiod.cmdline.h"
 #include "list.h"
 #include "sched.h"
+#include "ggo.h"
 #include "recv.h"
 #include "filter.h"
 #include "grab_client.cmdline.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;
@@ -1068,6 +1069,24 @@ static void set_initial_status(void)
                PARA_WARNING_LOG("invalid mode\n");
 }
 
+__noreturn static void print_help_and_die(void)
+{
+       int d = conf.detailed_help_given;
+       const char **p = d? audiod_args_info_detailed_help
+               : audiod_args_info_help;
+
+       printf_or_die("%s\n\n", AUDIOD_CMDLINE_PARSER_PACKAGE "-"
+               AUDIOD_CMDLINE_PARSER_VERSION);
+       printf_or_die("%s\n\n", audiod_args_info_usage);
+       for (; *p; p++)
+               printf_or_die("%s\n", *p);
+       print_receiver_helps(d);
+       print_filter_helps(d);
+       print_writer_helps(d);
+       exit(0);
+}
+
+
 /**
  * the main function of para_audiod
  *
@@ -1111,8 +1130,10 @@ int main(int argc, char *argv[])
        }
        if (conf.logfile_given)
                logfile = open_log(conf.logfile_arg);
-       log_welcome("para_audiod", conf.loglevel_arg);
        i = init_stream_io();
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
+       log_welcome("para_audiod", conf.loglevel_arg);
        if (i < 0) {
                PARA_EMERG_LOG("init stream io error: %s\n", para_strerror(-i));
                exit(EXIT_FAILURE);