From 35e284e06a5c8e20d02b61fdcb4bcc20b237c1e4 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 29 Jul 2012 20:51:18 +0200 Subject: [PATCH] Simplify ggo makefile. Currently we have three different targets for creating *_cmdline.[ch] files. This is because receivers, filters and writers need slightly different command line options. This patch defines the common options in the ggo makefile and moves additional parameters to the individual .m4 files so that a single target to create *_cmdline.[ch] is now sufficient. The name of the command line parsers of some filters and writers changed due to this unification, so these are updated accordingly. --- alsa_write.c | 8 ++++---- amp_filter.c | 6 +++--- ao_write.c | 8 ++++---- compress_filter.c | 6 +++--- file_write.c | 8 ++++---- m4/gengetopt/afh.m4 | 2 +- m4/gengetopt/audioc.m4 | 2 +- m4/gengetopt/audiod.m4 | 2 +- m4/gengetopt/client.m4 | 2 +- m4/gengetopt/fade.m4 | 2 ++ m4/gengetopt/filter.m4 | 2 +- m4/gengetopt/gui.m4 | 2 ++ m4/gengetopt/makefile | 46 ++++++++---------------------------------- m4/gengetopt/recv.m4 | 2 +- m4/gengetopt/server.m4 | 2 ++ m4/gengetopt/write.m4 | 2 +- mp3dec_filter.c | 6 +++--- oss_write.c | 8 ++++---- osx_write.c | 8 ++++---- prebuffer_filter.c | 6 +++--- 20 files changed, 53 insertions(+), 77 deletions(-) diff --git a/alsa_write.c b/alsa_write.c index 73c9b823..16497bdf 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -333,13 +333,13 @@ __malloc static void *alsa_parse_config_or_die(int argc, char **argv) struct alsa_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - alsa_cmdline_parser(argc, argv, conf); + alsa_write_cmdline_parser(argc, argv, conf); return conf; } static void alsa_free_config(void *conf) { - alsa_cmdline_parser_free(conf); + alsa_write_cmdline_parser_free(conf); } /** @@ -353,7 +353,7 @@ void alsa_write_init(struct writer *w) { struct alsa_write_args_info dummy; - alsa_cmdline_parser_init(&dummy); + alsa_write_cmdline_parser_init(&dummy); w->close = alsa_close; w->pre_select = alsa_write_pre_select; w->post_select = alsa_write_post_select; @@ -363,5 +363,5 @@ void alsa_write_init(struct writer *w) .short_help = alsa_write_args_info_help, .detailed_help = alsa_write_args_info_detailed_help }; - alsa_cmdline_parser_free(&dummy); + alsa_write_cmdline_parser_free(&dummy); } diff --git a/amp_filter.c b/amp_filter.c index 7e88cc49..dd2c6194 100644 --- a/amp_filter.c +++ b/amp_filter.c @@ -38,7 +38,7 @@ static int amp_parse_config(int argc, char **argv, void **config) struct amp_filter_args_info *amp_conf = para_calloc(sizeof(*amp_conf)); int ret = -E_AMP_SYNTAX; - if (amp_cmdline_parser(argc, argv, amp_conf)) + if (amp_filter_cmdline_parser(argc, argv, amp_conf)) goto err; ret = -ERRNO_TO_PARA_ERROR(EINVAL); if (amp_conf->amp_arg < 0) @@ -123,7 +123,7 @@ err: static void amp_free_config(void *conf) { - amp_cmdline_parser_free(conf); + amp_filter_cmdline_parser_free(conf); } /** @@ -135,7 +135,7 @@ void amp_filter_init(struct filter *f) { struct amp_filter_args_info dummy; - amp_cmdline_parser_init(&dummy); + amp_filter_cmdline_parser_init(&dummy); f->open = amp_open; f->close = amp_close; f->pre_select = generic_filter_pre_select; diff --git a/ao_write.c b/ao_write.c index 165caa0c..b1c344cc 100644 --- a/ao_write.c +++ b/ao_write.c @@ -342,13 +342,13 @@ __malloc static void *aow_parse_config_or_die(int argc, char **argv) struct ao_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - ao_cmdline_parser(argc, argv, conf); + ao_write_cmdline_parser(argc, argv, conf); return conf; } static void aow_free_config(void *conf) { - ao_cmdline_parser_free(conf); + ao_write_cmdline_parser_free(conf); } /** @@ -365,7 +365,7 @@ void ao_write_init(struct writer *w) ao_info **driver_list; char **dh; /* detailed help */ - ao_cmdline_parser_init(&dummy); + ao_write_cmdline_parser_init(&dummy); w->close = aow_close; w->pre_select = aow_pre_select; w->post_select = aow_post_select; @@ -411,7 +411,7 @@ void ao_write_init(struct writer *w) } dh[num_lines] = NULL; w->help.detailed_help = (const char **)dh; - ao_cmdline_parser_free(&dummy); + ao_write_cmdline_parser_free(&dummy); ao_shutdown(); } diff --git a/compress_filter.c b/compress_filter.c index 3dee5ccd..49d6d66c 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -120,7 +120,7 @@ static int compress_parse_config(int argc, char **argv, void **config) = para_calloc(sizeof(*compress_conf)); ret = -E_COMPRESS_SYNTAX; - if (compress_cmdline_parser(argc, argv, compress_conf)) + if (compress_filter_cmdline_parser(argc, argv, compress_conf)) goto err; *config = compress_conf; return 1; @@ -142,7 +142,7 @@ static void compress_open(struct filter_node *fn) static void compress_free_config(void *conf) { - compress_cmdline_parser_free(conf); + compress_filter_cmdline_parser_free(conf); } /** @@ -154,7 +154,7 @@ void compress_filter_init(struct filter *f) { struct compress_filter_args_info dummy; - compress_cmdline_parser_init(&dummy); + compress_filter_cmdline_parser_init(&dummy); f->open = compress_open; f->close = compress_close; f->pre_select = generic_filter_pre_select; diff --git a/file_write.c b/file_write.c index 98175715..32f6c3ab 100644 --- a/file_write.c +++ b/file_write.c @@ -138,13 +138,13 @@ __malloc static void *file_write_parse_config_or_die(int argc, char **argv) struct file_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - file_cmdline_parser(argc, argv, conf); + file_write_cmdline_parser(argc, argv, conf); return conf; } static void file_write_free_config(void *conf) { - file_cmdline_parser_free(conf); + file_write_cmdline_parser_free(conf); } /** the init function of the file writer */ @@ -152,7 +152,7 @@ void file_write_init(struct writer *w) { struct file_write_args_info dummy; - file_cmdline_parser_init(&dummy); + file_write_cmdline_parser_init(&dummy); w->pre_select = file_write_pre_select; w->post_select = file_write_post_select; w->parse_config_or_die = file_write_parse_config_or_die; @@ -162,5 +162,5 @@ void file_write_init(struct writer *w) .short_help = file_write_args_info_help, .detailed_help = file_write_args_info_detailed_help }; - file_cmdline_parser_free(&dummy); + file_write_cmdline_parser_free(&dummy); } diff --git a/m4/gengetopt/afh.m4 b/m4/gengetopt/afh.m4 index 1cb44931..8adb29cf 100644 --- a/m4/gengetopt/afh.m4 +++ b/m4/gengetopt/afh.m4 @@ -1,4 +1,4 @@ -args "--unamed-opts=audio_file" +args "--unamed-opts=audio_file --no-handle-version" include(header.m4) diff --git a/m4/gengetopt/audioc.m4 b/m4/gengetopt/audioc.m4 index cb7ab03e..736d7072 100644 --- a/m4/gengetopt/audioc.m4 +++ b/m4/gengetopt/audioc.m4 @@ -1,4 +1,4 @@ -args "--unamed-opts=command" +args "--unamed-opts=command --conf-parser --no-handle-version" include(header.m4) diff --git a/m4/gengetopt/audiod.m4 b/m4/gengetopt/audiod.m4 index f20bd105..5522a56d 100644 --- a/m4/gengetopt/audiod.m4 +++ b/m4/gengetopt/audiod.m4 @@ -1,4 +1,4 @@ -args "--no-handle-help" +args "--no-handle-help --no-handle-version --conf-parser" include(header.m4) define(CURRENT_PROGRAM,para_audiod) diff --git a/m4/gengetopt/client.m4 b/m4/gengetopt/client.m4 index 6b589dc7..23f7c1e6 100644 --- a/m4/gengetopt/client.m4 +++ b/m4/gengetopt/client.m4 @@ -1,4 +1,4 @@ -args "--unamed-opts=command --no-handle-error" +args "--unamed-opts=command --no-handle-error --conf-parser --no-handle-version" include(header.m4) define(CURRENT_PROGRAM,para_client) diff --git a/m4/gengetopt/fade.m4 b/m4/gengetopt/fade.m4 index 80f8b73c..ff4b451b 100644 --- a/m4/gengetopt/fade.m4 +++ b/m4/gengetopt/fade.m4 @@ -1,3 +1,5 @@ +args "--conf-parser --no-handle-version" + section "General options" ######################### diff --git a/m4/gengetopt/filter.m4 b/m4/gengetopt/filter.m4 index f2efbc44..c7337beb 100644 --- a/m4/gengetopt/filter.m4 +++ b/m4/gengetopt/filter.m4 @@ -1,4 +1,4 @@ -args "--no-handle-help" +args "--no-handle-help --no-handle-version --conf-parser" include(header.m4) include(loglevel.m4) diff --git a/m4/gengetopt/gui.m4 b/m4/gengetopt/gui.m4 index 895229b2..bafd325b 100644 --- a/m4/gengetopt/gui.m4 +++ b/m4/gengetopt/gui.m4 @@ -1,3 +1,5 @@ +args "--conf-parser --no-handle-version" + include(header.m4) define(CURRENT_PROGRAM,para_gui) define(DEFAULT_CONFIG_FILE,~/.paraslash/gui.conf) diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index cc5835c7..c613816f 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -1,45 +1,15 @@ -module_ggo_opts := --set-version="($(PACKAGE_STRING), $(codename))" - -$(cmdline_dir)/%_recv.cmdline.h $(cmdline_dir)/%_recv.cmdline.c: $(ggo_dir)/%_recv.ggo | $(cmdline_dir) - @[ -z "$(Q)" ] || echo 'GGO $<' - $(Q) $(GENGETOPT) $(module_ggo_opts) \ - --output-dir=$(cmdline_dir) \ - --set-package=$(subst .ggo,,$(open = mp3dec_open; f->close = mp3dec_close; f->parse_config = mp3dec_parse_config; diff --git a/oss_write.c b/oss_write.c index 57e2387f..d2dc963e 100644 --- a/oss_write.c +++ b/oss_write.c @@ -207,13 +207,13 @@ __malloc static void *oss_parse_config_or_die(int argc, char **argv) struct oss_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - oss_cmdline_parser(argc, argv, conf); + oss_write_cmdline_parser(argc, argv, conf); return conf; } static void oss_free_config(void *conf) { - oss_cmdline_parser_free(conf); + oss_write_cmdline_parser_free(conf); } /** @@ -227,7 +227,7 @@ void oss_write_init(struct writer *w) { struct oss_write_args_info dummy; - oss_cmdline_parser_init(&dummy); + oss_write_cmdline_parser_init(&dummy); w->close = oss_close; w->pre_select = oss_pre_select; w->post_select = oss_post_select; @@ -237,5 +237,5 @@ void oss_write_init(struct writer *w) .short_help = oss_write_args_info_help, .detailed_help = oss_write_args_info_detailed_help }; - oss_cmdline_parser_free(&dummy); + oss_write_cmdline_parser_free(&dummy); } diff --git a/osx_write.c b/osx_write.c index 69a781cc..8dcfb4cd 100644 --- a/osx_write.c +++ b/osx_write.c @@ -222,13 +222,13 @@ __malloc static void *osx_write_parse_config_or_die(int argc, char **argv) struct osx_write_args_info *conf = para_calloc(sizeof(*conf)); /* exits on errors */ - osx_cmdline_parser(argc, argv, conf); + osx_write_cmdline_parser(argc, argv, conf); return conf; } static void osx_free_config(void *conf) { - osx_cmdline_parser_free(conf); + osx_write_cmdline_parser_free(conf); } static void osx_write_close(struct writer_node *wn) @@ -326,7 +326,7 @@ void osx_write_init(struct writer *w) { struct osx_write_args_info dummy; - osx_cmdline_parser_init(&dummy); + osx_write_cmdline_parser_init(&dummy); w->close = osx_write_close; w->pre_select = osx_write_pre_select; w->post_select = osx_write_post_select; @@ -336,5 +336,5 @@ void osx_write_init(struct writer *w) .short_help = osx_write_args_info_help, .detailed_help = osx_write_args_info_detailed_help }; - osx_cmdline_parser_free(&dummy); + osx_write_cmdline_parser_free(&dummy); } diff --git a/prebuffer_filter.c b/prebuffer_filter.c index 9c6fda56..76ec7c73 100644 --- a/prebuffer_filter.c +++ b/prebuffer_filter.c @@ -82,7 +82,7 @@ static int prebuffer_parse_config(int argc, char **argv, void **config) = para_calloc(sizeof(*prebuffer_conf)); int ret = -E_PREBUFFER_SYNTAX; - if (prebuffer_cmdline_parser(argc, argv, prebuffer_conf)) + if (prebuffer_filter_cmdline_parser(argc, argv, prebuffer_conf)) goto err; ret = -ERRNO_TO_PARA_ERROR(EINVAL); if (prebuffer_conf->duration_arg < 0) @@ -108,7 +108,7 @@ static void prebuffer_open(struct filter_node *fn) static void prebuffer_free_config(void *conf) { - prebuffer_cmdline_parser_free(conf); + prebuffer_filter_cmdline_parser_free(conf); } /** @@ -120,7 +120,7 @@ void prebuffer_filter_init(struct filter *f) { struct prebuffer_filter_args_info dummy; - prebuffer_cmdline_parser_init(&dummy); + prebuffer_filter_cmdline_parser_init(&dummy); f->open = prebuffer_open; f->close = prebuffer_close; f->parse_config = prebuffer_parse_config; -- 2.39.5