Commit 4aa188ca authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

lua: move url_parse() from net to strings (fixes #3447)

Leave an alias in url_parse() for compatiblity for the time being.
parent eb43fb75
......@@ -49,4 +49,6 @@ void luaopen_equalizer( lua_State *L );
void luaopen_win( lua_State *L );
#endif
int vlclua_url_parse( lua_State *L );
#endif
......@@ -162,37 +162,6 @@ static void vlclua_fd_unmap_safe( lua_State *L, unsigned idx )
net_Close( fd );
}
/*****************************************************************************
*
*****************************************************************************/
static int vlclua_url_parse( lua_State *L )
{
const char *psz_url = luaL_checkstring( L, 1 );
vlc_url_t url;
vlc_UrlParse( &url, psz_url );
lua_newtable( L );
lua_pushstring( L, url.psz_protocol );
lua_setfield( L, -2, "protocol" );
lua_pushstring( L, url.psz_username );
lua_setfield( L, -2, "username" );
lua_pushstring( L, url.psz_password );
lua_setfield( L, -2, "password" );
lua_pushstring( L, url.psz_host );
lua_setfield( L, -2, "host" );
lua_pushinteger( L, url.i_port );
lua_setfield( L, -2, "port" );
lua_pushstring( L, url.psz_path );
lua_setfield( L, -2, "path" );
lua_pushstring( L, url.psz_option );
lua_setfield( L, -2, "option" );
vlc_UrlClean( &url );
return 1;
}
/*****************************************************************************
* Net listen
*****************************************************************************/
......@@ -508,7 +477,7 @@ static const luaL_Reg vlclua_net_intf_reg[] = {
#endif
/* The following functions do not depend on intf_thread_t and do not really
* belong in net.* but are left here for backward compatibility: */
{ "url_parse", vlclua_url_parse },
{ "url_parse", vlclua_url_parse /* deprecated since 3.0.0 */ },
{ "stat", vlclua_stat }, /* Not really "net" */
{ "opendir", vlclua_opendir }, /* Not really "net" */
{ NULL, NULL }
......
......@@ -100,6 +100,34 @@ static int vlclua_make_path( lua_State *L )
return 1;
}
int vlclua_url_parse( lua_State *L )
{
const char *psz_url = luaL_checkstring( L, 1 );
vlc_url_t url;
vlc_UrlParse( &url, psz_url );
lua_newtable( L );
lua_pushstring( L, url.psz_protocol );
lua_setfield( L, -2, "protocol" );
lua_pushstring( L, url.psz_username );
lua_setfield( L, -2, "username" );
lua_pushstring( L, url.psz_password );
lua_setfield( L, -2, "password" );
lua_pushstring( L, url.psz_host );
lua_setfield( L, -2, "host" );
lua_pushinteger( L, url.i_port );
lua_setfield( L, -2, "port" );
lua_pushstring( L, url.psz_path );
lua_setfield( L, -2, "path" );
lua_pushstring( L, url.psz_option );
lua_setfield( L, -2, "option" );
vlc_UrlClean( &url );
return 1;
}
static int vlclua_resolve_xml_special_chars( lua_State *L )
{
int i_top = lua_gettop( L );
......@@ -155,6 +183,7 @@ static const luaL_Reg vlclua_strings_reg[] = {
{ "encode_uri_component", vlclua_encode_uri_component },
{ "make_uri", vlclua_make_uri },
{ "make_path", vlclua_make_path },
{ "url_parse", vlclua_url_parse },
{ "resolve_xml_special_chars", vlclua_resolve_xml_special_chars },
{ "convert_xml_special_chars", vlclua_convert_xml_special_chars },
{ "from_charset", vlclua_from_charset },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment