]> git.sesse.net Git - vlc/commitdiff
modules/meta_engine/luameta.c: Add resolve_xml_special_chars and decode_uri to the...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 15 Aug 2007 04:40:32 +0000 (04:40 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 15 Aug 2007 04:40:32 +0000 (04:40 +0000)
modules/meta_engine/luameta.c
share/luameta/README.txt

index 9b531c72ec45f0d141e0247a559d9955334b49b0..96c36614fbe137d75e406d6c65a2d901514129a9 100644 (file)
@@ -31,6 +31,8 @@
 #include <vlc_input.h>
 #include <vlc_playlist.h>
 #include <vlc_meta.h>
+#include <vlc_url.h>
+#include <vlc_strings.h>
 #include <vlc_stream.h>
 #include <vlc_charset.h>
 
@@ -139,6 +141,34 @@ static int vlclua_stream_delete( lua_State *p_state )
     return 1;
 }
 
+static int vlclua_decode_uri( lua_State *p_state )
+{
+    int i = lua_gettop( p_state );
+    if( !i ) return 0;
+    const char *psz_cstring = lua_tostring( p_state, 1 );
+    if( !psz_cstring ) return 0;
+    char *psz_string = strdup( psz_cstring );
+    lua_pop( p_state, i );
+    decode_URI( psz_string );
+    lua_pushstring( p_state, psz_string );
+    free( psz_string );
+    return 1;
+}
+
+static int vlclua_resolve_xml_special_chars( lua_State *p_state )
+{
+    int i = lua_gettop( p_state );
+    if( !i ) return 0;
+    const char *psz_cstring = lua_tostring( p_state, 1 );
+    if( !psz_cstring ) return 0;
+    char *psz_string = strdup( psz_cstring );
+    lua_pop( p_state, i );
+    resolve_xml_special_chars( psz_string );
+    lua_pushstring( p_state, psz_string );
+    free( psz_string );
+    return 1;
+}
+
 static int vlclua_msg_dbg( lua_State *p_state )
 {
     vlc_object_t *p_this = vlclua_get_this( p_state );
@@ -187,6 +217,8 @@ static luaL_Reg p_reg[] =
     { "stream_read", vlclua_stream_read },
     { "stream_readline", vlclua_stream_readline },
     { "stream_delete", vlclua_stream_delete },
+    { "decode_uri", vlclua_decode_uri },
+    { "resolve_xml_special_chars", vlclua_resolve_xml_special_chars },
     { "msg_dbg", vlclua_msg_dbg },
     { "msg_warn", vlclua_msg_warn },
     { "msg_err", vlclua_msg_err },
index 9ee05a328081e4eabb5bb612ed205749fbb080b6..bc718544a78990770196516655d5fedb0569b25f 100644 (file)
@@ -39,6 +39,9 @@ VLC defines a global vlc object with the following members:
  * vlc.stream_delete
  * vlc.stream_readline
  * vlc.stream_read
+ * vlc.decode_uri( <string> ): decode %xy characters in a string.
+ * vlc.resolve_xml_special_chars( <string> ): decode &abc; characters in a
+                                             string.
  * vlc.msg_dbg( <string> ): print a debug message.
  * vlc.msg_warn( <string> ): print a warning message.
  * vlc.msg_err( <string> ): print an error message.