diff options
author | Rob Bradford <rob@o-hand.com> | 2008-08-26 14:34:28 +0100 |
---|---|---|
committer | Rob Bradford <rob@o-hand.com> | 2008-09-01 11:41:21 +0100 |
commit | a461d2d7af6482fafcf992433b5d35dac23e51e5 (patch) | |
tree | 0dd27dd208fbe623f567f2b8ad936fca91539e1c /rest/rest-main.c | |
parent | 278d8d407f569cd2a1c3f88544389301da695c11 (diff) | |
download | librest-a461d2d7af6482fafcf992433b5d35dac23e51e5.tar.gz |
Add a debugging macro that can output debugging conditional on an env. var.
Diffstat (limited to 'rest/rest-main.c')
-rw-r--r-- | rest/rest-main.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/rest/rest-main.c b/rest/rest-main.c new file mode 100644 index 0000000..e817db0 --- /dev/null +++ b/rest/rest-main.c @@ -0,0 +1,42 @@ +#include "rest-private.h" + +guint rest_debug_flags = 0; + +/* + * "Private" function used to set debugging flags based on environment + * variables. Called upon entry into all public functions. + */ +void +_rest_setup_debugging (void) +{ + const gchar *tmp; + gchar **parts; + gint i = 0; + static gboolean setup_done = FALSE; + + if (setup_done) + return; + + tmp = g_getenv ("REST_DEBUG"); + + if (tmp) + { + parts = g_strsplit (tmp, ",", -1); + + for (i = 0; parts[i] != NULL; i++) + { + if (g_str_equal (tmp, "xml-parser")) + { + rest_debug_flags |= REST_DEBUG_XML_PARSER; + } else if (g_str_equal (tmp, "proxy")) { + rest_debug_flags |= REST_DEBUG_PROXY; + } else if (g_str_equal (tmp, "all")) { + rest_debug_flags |= REST_DEBUG_ALL; + } + } + + g_strfreev (parts); + } + + setup_done = TRUE; +} |