From f3f09b43da6def98cec48bd5682a1a6ccfd5c81e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 1 Jan 2001 03:43:27 +0000 Subject: [PATCH] Added command line parsing for Original commit message from CVS: Added command line parsing for --gst-info-mask, --gst-debug-mask and --help Dump the FLAGS and options on --help --- gst/Makefile.am | 2 +- gst/gst.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ gst/gstcpu.c | 5 ++-- gst/gstinfo.c | 9 ++++++ 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/gst/Makefile.am b/gst/Makefile.am index 9d3096fa1d..fb114fc16b 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -82,7 +82,7 @@ noinst_HEADERS = \ gsti386.h \ gstppc.h -CFLAGS += -Wall +CFLAGS += -g -Wall libgst_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS) libgst_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE) diff --git a/gst/gst.c b/gst/gst.c index 0b22f5b151..191c26b940 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -20,6 +20,8 @@ * Boston, MA 02111-1307, USA. */ +#include + #include "gst_private.h" #include "gstcpu.h" @@ -38,6 +40,7 @@ gchar *_gst_progname; extern gint _gst_trace_on; +static gboolean gst_init_check (int *argc, gchar ***argv); /** * gst_init: @@ -60,6 +63,10 @@ gst_init (int *argc, char **argv[]) gtk_init (argc,argv); + if (!gst_init_check (argc,argv)) { + exit (0); + } + _gst_cpu_initialize (); _gst_type_initialize (); _gst_plugin_initialize (); @@ -77,6 +84,79 @@ gst_init (int *argc, char **argv[]) } } +/* returns FALSE if the program can be aborted */ +static gboolean +gst_init_check (int *argc, + gchar ***argv) +{ + gboolean ret = TRUE; + gboolean showhelp = FALSE; + + if (argc && argv) { + gint i, j, k; + + for (i=1; i< *argc; i++) { + if (!strncmp ("--gst-info-mask=", (*argv)[i], 16)) { + guint32 val; + + sscanf ((*argv)[i]+16, "%08x", &val); + + gst_info_set_categories (val); + + (*argv)[i] = NULL; + } + else if (!strncmp ("--gst-info-mask=", (*argv)[i], 16)) { + guint32 val; + + sscanf ((*argv)[i]+16, "%08x", &val); + + //FIXME + //gst_info_set_categories (val); + + (*argv)[i] = NULL; + } + else if (!strncmp ("--help", (*argv)[i], 6)) { + showhelp = TRUE; + } + } + + for (i = 1; i < *argc; i++) { + for (k = i; k < *argc; k++) + if ((*argv)[k] != NULL) + break; + + if (k > i) { + k -= i; + for (j = i + k; j < *argc; j++) + (*argv)[j-k] = (*argv)[j]; + *argc -= k; + } + } + } + + if (showhelp) { + guint i; + + g_print ("usage %s [OPTION...]\n", (*argv)[0]); + + g_print ("\nGStreamer options\n"); + g_print (" --gst-info-mask=FLAGS Gst info flags to set (current %08x)\n", gst_info_get_categories()); + g_print (" --gst-debug-mask=FLAGS Gst debugging flags to set\n"); + + g_print ("\nGStreamer info/debug FLAGS (to be ored)\n"); + + for (i = 0; i