#include "write.cmdline.h"
#include "list.h"
#include "sched.h"
+#include "ggo.h"
#include "stdin.h"
#include "write.h"
#include "write_common.h"
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",
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.
*
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)
goto out;
stdin_set_defaults(&sit);
- if (conf.bufsize_given)
- sit.bufsize = conf.bufsize_arg;
+ ret = -ERRNO_TO_PARA_ERROR(EINVAL);
+ if (conf.bufsize_arg < 0)
+ goto out;
+ if (conf.bufsize_arg >= INT_MAX / 1024)
+ goto out;
+ sit.bufsize = conf.bufsize_arg * 1024;
sit.buf = para_malloc(sit.bufsize);
wng->buf = sit.buf;