From 97fe7b550c0ff5549985363c753b1d52b9248c5f Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Fri, 7 Dec 2018 18:41:02 +0900 Subject: [PATCH] axfer: enable each backend to print own help This commit adds an operation for xfer backend to print help text. In this time, content of the help is not implemented yet. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- axfer/xfer-libasound.c | 6 ++++++ axfer/xfer-libffado.c | 6 ++++++ axfer/xfer-options.c | 6 ++++++ axfer/xfer.c | 5 +++++ axfer/xfer.h | 2 ++ 5 files changed, 25 insertions(+) diff --git a/axfer/xfer-libasound.c b/axfer/xfer-libasound.c index bacd835..c774ced 100644 --- a/axfer/xfer-libasound.c +++ b/axfer/xfer-libasound.c @@ -880,6 +880,11 @@ static void xfer_libasound_destroy(struct xfer_context *xfer) state->log = NULL; } +static void xfer_libasound_help(struct xfer_context *xfer) +{ + printf(" (placeholder)\n"); +} + const struct xfer_data xfer_libasound = { .s_opts = S_OPTS, .l_opts = l_opts, @@ -893,6 +898,7 @@ const struct xfer_data xfer_libasound = { .pause = xfer_libasound_pause, .post_process = xfer_libasound_post_process, .destroy = xfer_libasound_destroy, + .help = xfer_libasound_help, }, .private_size = sizeof(struct libasound_state), }; diff --git a/axfer/xfer-libffado.c b/axfer/xfer-libffado.c index 3b52e2c..0052336 100644 --- a/axfer/xfer-libffado.c +++ b/axfer/xfer-libffado.c @@ -537,6 +537,11 @@ static void xfer_libffado_destroy(struct xfer_context *xfer) state->guid_literal = NULL; } +static void xfer_libffado_help(struct xfer_context *xfer) +{ + printf(" (placeholder)\n"); +} + const struct xfer_data xfer_libffado = { .s_opts = S_OPTS, .l_opts = l_opts, @@ -550,6 +555,7 @@ const struct xfer_data xfer_libffado = { .pause = xfer_libffado_pause, .post_process = xfer_libffado_post_process, .destroy = xfer_libffado_destroy, + .help = xfer_libffado_help, }, .private_size = sizeof(struct libffado_state), }; diff --git a/axfer/xfer-options.c b/axfer/xfer-options.c index aaa30d5..b81bcb2 100644 --- a/axfer/xfer-options.c +++ b/axfer/xfer-options.c @@ -373,6 +373,12 @@ int xfer_options_parse_args(struct xfer_context *xfer, if (xfer->help) { print_help(); + if (xfer->ops->help) { + printf("\n"); + printf(" BACKEND-OPTIONS (%s) =\n", + xfer_label_from_type(xfer->type)); + xfer->ops->help(xfer); + } return 0; } diff --git a/axfer/xfer.c b/axfer/xfer.c index fdf6e60..6682b3b 100644 --- a/axfer/xfer.c +++ b/axfer/xfer.c @@ -30,6 +30,11 @@ enum xfer_type xfer_type_from_label(const char *label) return XFER_TYPE_UNSUPPORTED; } +const char *xfer_label_from_type(enum xfer_type type) +{ + return xfer_type_labels[type]; +} + int xfer_context_init(struct xfer_context *xfer, enum xfer_type type, snd_pcm_stream_t direction, int argc, char *const *argv) { diff --git a/axfer/xfer.h b/axfer/xfer.h index db2e296..24349cd 100644 --- a/axfer/xfer.h +++ b/axfer/xfer.h @@ -53,6 +53,7 @@ struct xfer_context { }; enum xfer_type xfer_type_from_label(const char *label); +const char *xfer_label_from_type(enum xfer_type type); int xfer_context_init(struct xfer_context *xfer, enum xfer_type type, snd_pcm_stream_t direction, int argc, char *const *argv); @@ -96,6 +97,7 @@ struct xfer_ops { void (*post_process)(struct xfer_context *xfer); void (*destroy)(struct xfer_context *xfer); void (*pause)(struct xfer_context *xfer, bool enable); + void (*help)(struct xfer_context *xfer); }; struct xfer_data { -- 2.47.1