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
This commit is contained in:
Wim Taymans 2001-01-01 03:43:27 +00:00
parent 24c64f54c5
commit f3f09b43da
4 changed files with 93 additions and 3 deletions

View file

@ -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)

View file

@ -20,6 +20,8 @@
* Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#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<GST_CAT_MAX_CATEGORY; i++) {
g_print (" %08x %s %s\n", 1<<i,
(gst_info_get_categories() & (1<<i)?"(enabled)":" "),
gst_get_category_name (i));
}
ret = FALSE;
}
return ret;
}
/**
* gst_main:
*

View file

@ -41,9 +41,10 @@ static gchar *stringcat (gchar *a,gchar *b) {
gchar *c;
if (a) {
c = g_strconcat(a,b,NULL);
g_free(a);
} else
g_free (a);
} else {
c = g_strdup(b);
}
return c;
}

View file

@ -178,3 +178,12 @@ gst_default_error_handler (gchar *file, gchar *function,
exit(1);
}
gst_info_init (int *argc,
char ***argv)
{
if (argc && argv) {
}
}