From 1bce047ddcb31229dc50a9354b23f31a8106c2c1 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 17 Jan 2003 16:06:23 +0000 Subject: [PATCH] avoid having to depend on glib 2.2 Original commit message from CVS: avoid having to depend on glib 2.2 --- gst/gsturi.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gst/gsturi.c b/gst/gsturi.c index ec07b48..e835cc9 100644 --- a/gst/gsturi.c +++ b/gst/gsturi.c @@ -139,6 +139,26 @@ gst_uri_handler_find (const gchar *name) } /** + * this is a straight copy from glib 2.2 + * remove this function when glib 2.2 is sufficiently widespread and + * then change to using the regular g_str_has_prefix + */ +static gboolean +g_str_has_prefix_glib22 (gchar *haystack, gchar *needle) +{ + if (haystack == NULL && needle == NULL) { + return TRUE; + } + if (haystack == NULL || needle == NULL) { + return FALSE; + } + if (strncmp (haystack, needle, strlen (needle)) == 0) { + return TRUE; + } + return FALSE; +} + +/** * gst_uri_handler_find_by_uri: * @uri: the uri to find a handler for * @@ -159,7 +179,7 @@ gst_uri_handler_find_by_uri (const gchar *uri) while (walk) { handler = GST_URI_HANDLER (walk->data); - if (g_str_has_prefix (uri, handler->uri)) + if (g_str_has_prefix_glib22 ((gchar *) uri, handler->uri)) break; walk = g_list_next (walk); -- 2.7.4