From 8fe89832159647cd165cf7de282eb713bf01bc0f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 8 Oct 2014 03:20:30 +0200 Subject: complain about unkown command line arguments --- src/options-launch.c | 16 ++++++++++++++++ src/options-rtp.c | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/src/options-launch.c b/src/options-launch.c index fad40fe..16e855d 100644 --- a/src/options-launch.c +++ b/src/options-launch.c @@ -61,6 +61,21 @@ static void options_defaults(options_t* opt) opt->pipeline_ = NULL; } +static GQuark options_error_quark() +{ + static GQuark quark = 0; + if (!quark) + quark = g_quark_from_static_string("sydra_options_error"); + + return quark; +} + +static gboolean options_parse_remaining(const gchar *option_name, const gchar *value, gpointer data, GError **error) +{ + g_set_error(error, options_error_quark(), G_OPTION_ERROR_FAILED, "unkown option '%s'", value); + return FALSE; +} + static int options_parse_post(options_t* opt); int options_parse(options_t* opt, int argc, char* argv[]) @@ -97,6 +112,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) "set the application name (will be used by xvimagesink for window title)", "NAME" }, { "pipeline", 'p', 0, G_OPTION_ARG_STRING, &opt->pipeline_, "the gst-launch style pipeline description", "PIPELINE DESCRIPTION" }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_CALLBACK, options_parse_remaining, NULL, NULL}, { NULL } }; GOptionContext *ctx = g_option_context_new("- spreadspace streaming hydra "); diff --git a/src/options-rtp.c b/src/options-rtp.c index 70cc5fc..3a1aab8 100644 --- a/src/options-rtp.c +++ b/src/options-rtp.c @@ -224,6 +224,12 @@ static gboolean options_parse_mode(const gchar *option_name, const gchar *value, return TRUE; } +static gboolean options_parse_remaining(const gchar *option_name, const gchar *value, gpointer data, GError **error) +{ + g_set_error(error, options_error_quark(), G_OPTION_ERROR_FAILED, "unkown option '%s'", value); + return FALSE; +} + static int options_parse_post(options_t* opt); int options_parse(options_t* opt, int argc, char* argv[]) @@ -260,6 +266,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) "set the application name (will be used by xvimagesink for window title)", "NAME" }, { "mode", 'm', 0, G_OPTION_ARG_CALLBACK, options_parse_mode, "the main operation mode", "(sender|receiver)" }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_CALLBACK, options_parse_remaining, NULL, NULL}, { NULL } }; GOptionContext *ctx = g_option_context_new("- spreadspace streaming hydra "); -- cgit v1.2.3