From 76fffe8fc5cf6c8414d8b00daefffe9bed612dd6 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 24 Aug 2005 13:49:21 +0000 Subject: [PATCH] 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 * 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. --- ChangeLog | 6 ++++ docs/gst/tmpl/gstutils.sgml | 12 +++++++ gst/gst.c | 81 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 187d52f..8ad3afa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-08-24 Andy Wingo + + * 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 * gst/base/gstbasetransform.c: (gst_base_transform_transform_caps), diff --git a/docs/gst/tmpl/gstutils.sgml b/docs/gst/tmpl/gstutils.sgml index 890f0bf..fd30801 100644 --- a/docs/gst/tmpl/gstutils.sgml +++ b/docs/gst/tmpl/gstutils.sgml @@ -94,6 +94,12 @@ various utility functions @\ parent_type_as_macro: @\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ + parent_type_as_macro: +@\ parent_type_as_macro: @interface_type: @interface_type_as_macro: @@ -110,6 +116,12 @@ various utility functions @\ interface_as_function: @\ + interface_as_function: +@\ + interface_as_function: +@\ + interface_as_function: +@\ interface_as_function: diff --git a/gst/gst.c b/gst/gst.c index 7f278cf..dda3926 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -169,6 +169,51 @@ enum 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 parse_debug_list (const gchar * list) { @@ -177,33 +222,33 @@ parse_debug_list (const gchar * list) g_return_if_fail (list != NULL); - walk = split = g_strsplit (list, ",", 0); + split = g_strsplit (list, ",", 0); - while (walk[0]) { - gchar **values = g_strsplit (walk[0], ":", 2); + for (walk = split; *walk; walk++) { + if (strchr (*walk, ':')) { + gchar **values = g_strsplit (*walk, ":", 2); - if (values[0] && values[1]) { - gint level = 0; + if (values[0] && values[1]) { + gint level; + const gchar *category; - g_strstrip (values[0]); - g_strstrip (values[1]); - level = strtol (values[1], NULL, 0); - 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); + if (parse_debug_category (values[0], &category) + && parse_debug_level (values[1], &level)) + gst_debug_set_threshold_for_name (category, 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); } -#ifndef NUL -#define NUL '\0' -#endif - /** * gst_init_get_popt_table: * -- 2.7.4