X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=34cea48c6a81ab2d7d6743e28706181415362824;hp=998a6d2cccde01cf45bcb6e5dea9d5e11c3f7da0;hb=6f5030f4b257aba7ea4265ef3ae35d96477bbfc3;hpb=0c4e55bbaa21f24f66e57a555341924840850c71 diff --git a/write.c b/write.c index 998a6d2c..34cea48c 100644 --- a/write.c +++ b/write.c @@ -1,11 +1,12 @@ /* - * Copyright (C) 2005-2008 Andre Noll + * Copyright (C) 2005-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file write.c Paraslash's standalone wav/raw player. */ +#include #include #include @@ -14,6 +15,7 @@ #include "write.cmdline.h" #include "list.h" #include "sched.h" +#include "ggo.h" #include "stdin.h" #include "write.h" #include "write_common.h" @@ -121,7 +123,8 @@ register_check_wav: s->timeout.tv_usec = 1; } -INIT_STDERR_LOGGING(conf.loglevel_arg) +static int loglevel; +INIT_STDERR_LOGGING(loglevel) static struct writer_node_group *check_args(void) { @@ -129,20 +132,7 @@ 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); - } + loglevel = get_loglevel_by_name(conf.loglevel_arg); if (conf.start_time_given) { long unsigned sec, usec; if (sscanf(conf.start_time_arg, "%lu:%lu", @@ -164,7 +154,7 @@ static struct writer_node_group *check_args(void) conf.writer_arg[i], &writer_num); if (!g->writer_nodes[i].conf) goto out; - g->writer_nodes[i].writer = &writers[writer_num]; + g->writer_nodes[i].writer_num = writer_num; } ret = 1; out: @@ -174,6 +164,21 @@ out: return NULL; } +__noreturn static void print_help_and_die(void) +{ + int 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); + print_writer_helps(d); + exit(0); +} + /** * Para_write's main function. * @@ -192,9 +197,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; + writer_init(); 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) @@ -208,7 +215,7 @@ int main(int argc, char *argv[]) sit.bufsize = conf.bufsize_arg * 1024; sit.buf = para_malloc(sit.bufsize); - wng->buf = sit.buf; + wng->bufp = &sit.buf; wng->loaded = &sit.loaded; wng->input_error = &sit.task.error;