[vlc-devel] [PATCH 07/10] Moves a usefull function of access/directory.c from Remi Denis-Courmont to src/text/url.c
Rémi Denis-Courmont
remi at remlab.net
Mon Jun 16 15:20:48 CEST 2014
Please do not introduce new exported symbol prefixes. Not sure this needs to be exported by libvlccore anyway.
--
Rémi Denis-Courmont
Sent from my NVIDIA Tegra-powered device
----- Reply message -----
De : "Julien 'Lta' BALLET" <elthariel at gmail.com>
Pour : <vlc-devel at videolan.org>
Cc : "Julien 'Lta' BALLET" <contact at lta.io>
Objet : [vlc-devel] [PATCH 07/10] Moves a usefull function of access/directory.c from Remi Denis-Courmont to src/text/url.c
Date : lun., juin 16, 2014 15:41
From: Julien 'Lta' BALLET <contact at lta.io>
---
include/vlc_url.h | 1 +
src/libvlccore.sym | 1 +
src/text/url.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/include/vlc_url.h b/include/vlc_url.h
index 820250f..ef0b0f1 100644
--- a/include/vlc_url.h
+++ b/include/vlc_url.h
@@ -49,6 +49,7 @@ VLC_API char * decode_URI_duplicate( const char *psz ) VLC_MALLOC;
VLC_API char * decode_URI( char *psz );
VLC_API char * encode_URI_component( const char *psz ) VLC_MALLOC;
VLC_API char * make_path( const char *url ) VLC_MALLOC;
+VLC_API bool has_ext( const char *psz_exts, const char *psz_uri );
VLC_API void vlc_UrlParse (vlc_url_t *, const char *, unsigned char);
VLC_API void vlc_UrlClean (vlc_url_t *);
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7b40435..ef062ba 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -241,6 +241,7 @@ vlc_UrlParse
vlc_UrlClean
vlc_path2uri
make_path
+has_ext
mdate
module_config_free
module_config_get
diff --git a/src/text/url.c b/src/text/url.c
index 3492a54..1814c2a 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -379,6 +379,44 @@ out:
static char *vlc_idna_to_ascii (const char *);
/**
+ * Does the provided URI/path/stuff has one of the extension provided ?
+ *
+ * \param psz_exts A comma separated list of extension without dot, or only
+ * one ext (ex: "avi,mkv,webm")
+ * \param psz_uri The uri/path to check (ex: "file:///home/foo/bar.avi")
+ *
+ * \return true if the uri/path has one of the provided extension
+ * false otherwise.
+ */
+bool has_ext( const char *psz_exts, const char *psz_uri )
+{
+ if( psz_exts == NULL )
+ return false;
+
+ const char *ext = strrchr( psz_uri, '.' );
+ if( ext == NULL )
+ return false;
+
+ size_t extlen = strlen (++ext);
+
+ for( const char *type = psz_exts, *end; type[0]; type = end + 1 )
+ {
+ end = strchr( type, ',' );
+ if ( end == NULL )
+ end = type + strlen( type );
+
+ if ( type + extlen == end && !strncasecmp ( ext, type, extlen ) )
+ return true;
+
+ if (*end == '\0')
+ break;
+ }
+
+ return false;
+}
+
+
+/**
* Splits an URL into parts.
* \param url structure of URL parts [OUT]
* \param str nul-terminated URL string to split
--
1.9.3
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140616/138af7a9/attachment.html>
More information about the vlc-devel
mailing list