From 09bc0d93af3b3f4039b3864374748b13091f11f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 9 Mar 2006 12:08:54 +0000 Subject: [PATCH] Add new API: gst_uri_has_protocol() (#333779). Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * gst/gsturi.c: (gst_uri_has_protocol): * gst/gsturi.h: Add new API: gst_uri_has_protocol() (#333779). --- ChangeLog | 7 +++++++ docs/gst/gstreamer-sections.txt | 1 + gst/gsturi.c | 26 ++++++++++++++++++++++++++ gst/gsturi.h | 2 ++ 4 files changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index df2f8cc..ba808af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-09 Tim-Philipp Müller + + * docs/gst/gstreamer-sections.txt: + * gst/gsturi.c: (gst_uri_has_protocol): + * gst/gsturi.h: + Add new API: gst_uri_has_protocol() (#333779). + 2006-03-09 Wim Taymans * gst/gstclock.c: (gst_clock_entry_new), diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 1ef79a7..6de8ba3 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1973,6 +1973,7 @@ GstURIType GST_URI_TYPE_IS_VALID gst_uri_protocol_is_valid gst_uri_is_valid +gst_uri_has_protocol gst_uri_get_protocol gst_uri_get_location gst_uri_construct diff --git a/gst/gsturi.c b/gst/gsturi.c index 84bb194..24eaa28 100644 --- a/gst/gsturi.c +++ b/gst/gsturi.c @@ -373,6 +373,32 @@ gst_uri_get_protocol (const gchar * uri) } /** + * gst_uri_has_protocol: + * @uri: an URI string + * @protocol: a protocol string (e.g. "http") + * + * Returns TRUE if the protocol of a given valid URI matches @protocol. + * + * Since: 0.10.4 + */ +gboolean +gst_uri_has_protocol (const gchar * uri, const gchar * protocol) +{ + gchar *colon; + + g_return_val_if_fail (uri != NULL, FALSE); + g_return_val_if_fail (protocol != NULL, FALSE); + g_return_val_if_fail (gst_uri_is_valid (uri), FALSE); + + colon = strstr (uri, "://"); + + if (colon == NULL) + return FALSE; + + return (strncmp (uri, protocol, (size_t) (colon - uri)) == 0); +} + +/** * gst_uri_get_location: * @uri: A URI string * diff --git a/gst/gsturi.h b/gst/gsturi.h index f76f56d..82bae5d 100644 --- a/gst/gsturi.h +++ b/gst/gsturi.h @@ -115,6 +115,8 @@ struct _GstURIHandlerInterface { gboolean gst_uri_protocol_is_valid (const gchar * protocol); gboolean gst_uri_is_valid (const gchar * uri); gchar * gst_uri_get_protocol (const gchar * uri); +gboolean gst_uri_has_protocol (const gchar * uri, + const gchar * protocol); gchar * gst_uri_get_location (const gchar * uri); gchar * gst_uri_construct (const gchar * protocol, const gchar * location); -- 2.7.4