gst/gst.c (parse_debug_list): Accept e.g. GST_DEBUG=4 to mean the same thing as GST_DEBUG=*:4.

Original commit message from CVS:
2005-08-24  Andy Wingo  <wingo@pobox.com>

* gst/gst.c (parse_debug_list): Accept e.g. GST_DEBUG=4 to mean
the same thing as GST_DEBUG=*:4.
(parse_debug_level, parse_debug_category): New helper parsers.
This commit is contained in:
Andy Wingo 2005-08-24 13:49:21 +00:00
parent 6519d7bfba
commit 76fffe8fc5
3 changed files with 81 additions and 18 deletions

View file

@ -1,3 +1,9 @@
2005-08-24 Andy Wingo <wingo@pobox.com>
* gst/gst.c (parse_debug_list): Accept e.g. GST_DEBUG=4 to mean
the same thing as GST_DEBUG=*:4.
(parse_debug_level, parse_debug_category): New helper parsers.
2005-08-24 Thomas Vander Stichele <thomas at apestaart dot org> 2005-08-24 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps), * gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),

View file

@ -93,6 +93,12 @@ various utility functions
parent_type_as_macro: parent_type_as_macro:
@\ @\
parent_type_as_macro: parent_type_as_macro:
@\
parent_type_as_macro:
@\
parent_type_as_macro:
@\
parent_type_as_macro:
@\ @\
parent_type_as_macro: parent_type_as_macro:
@interface_type: @interface_type:
@ -109,6 +115,12 @@ various utility functions
interface_as_function: interface_as_function:
@\ @\
interface_as_function: interface_as_function:
@\
interface_as_function:
@\
interface_as_function:
@\
interface_as_function:
@\ @\
interface_as_function: interface_as_function:

View file

@ -169,6 +169,51 @@ enum
ARG_REGISTRY ARG_REGISTRY
}; };
/* debug-spec ::= category-spec [, category-spec]*
* category-spec ::= category:val | val
* category ::= [^:]+
* val ::= [0-5]
*/
#ifndef NUL
#define NUL '\0'
#endif
static gboolean
parse_debug_category (gchar * str, const gchar ** category)
{
if (!str)
return FALSE;
/* works in place */
g_strstrip (str);
if (str[0] != NUL) {
*category = str;
return TRUE;
}
return FALSE;
}
static gboolean
parse_debug_level (gchar * str, gint * level)
{
if (!str)
return FALSE;
/* works in place */
g_strstrip (str);
if (str[0] != NUL && str[1] == NUL
&& str[0] >= '0' && str[0] < '0' + GST_LEVEL_COUNT) {
*level = str[0] - '0';
return TRUE;
}
return FALSE;
}
static void static void
parse_debug_list (const gchar * list) parse_debug_list (const gchar * list)
{ {
@ -177,33 +222,33 @@ parse_debug_list (const gchar * list)
g_return_if_fail (list != NULL); g_return_if_fail (list != NULL);
walk = split = g_strsplit (list, ",", 0); split = g_strsplit (list, ",", 0);
while (walk[0]) { for (walk = split; *walk; walk++) {
gchar **values = g_strsplit (walk[0], ":", 2); if (strchr (*walk, ':')) {
gchar **values = g_strsplit (*walk, ":", 2);
if (values[0] && values[1]) { if (values[0] && values[1]) {
gint level = 0; gint level;
const gchar *category;
g_strstrip (values[0]); if (parse_debug_category (values[0], &category)
g_strstrip (values[1]); && parse_debug_level (values[1], &level))
level = strtol (values[1], NULL, 0); gst_debug_set_threshold_for_name (category, level);
if (level >= 0 && level < GST_LEVEL_COUNT) {
GST_DEBUG ("setting debugging to level %d for name \"%s\"",
level, values[0]);
gst_debug_set_threshold_for_name (values[0], level);
} }
g_strfreev (values);
} else {
gint level;
if (parse_debug_level (*walk, &level))
gst_debug_set_default_threshold (level);
} }
g_strfreev (values);
walk++;
} }
g_strfreev (split); g_strfreev (split);
} }
#ifndef NUL
#define NUL '\0'
#endif
/** /**
* gst_init_get_popt_table: * gst_init_get_popt_table:
* *