Changeset e10d43118219b4cd6e2fce4c44b70778f9ebcc30

Show
Ignore:
Timestamp:
11/10/07 17:34:53 (10 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1194712493 +0000
git-parent:

[050188ce4cea0fe17c21eba1d429ff44e0f92ea4]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1194712493 +0000
Message:

Port the http interface to the Lua Interface Module framework.

  • share/luaintf/http.lua: Equivalent of the legacy modules/control/http/
    module. (The new module takes 272 lines of Lua, instead of 5475 lines for
    the old one.) Functionality is basically the same except for CGI support
    which is missing.
  • share/http-lua/: The HTML files using the new <?vlc [lua code] ?> syntax.
  • modules/misc/lua/: Add Lua bindings for a few VLC function, the most
    important being the HTTPd high level functions, ACLs, stat and opendir.

The Lua code still needs to be cleaned up a bit.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Makefile.am

    r5dd38e7 re10d431  
    442442      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/luaintf/modules/`basename $${i}` ; \ 
    443443    done ; \ 
     444    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/dialogs 
     445    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/js 
     446    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old 
     447    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old/admin 
     448    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old/vlm 
     449    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/images 
     450    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/requests 
     451    for i in $(srcdir)/share/http-lua/*.* ; do \ 
     452      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/`basename $${i}` ; \ 
     453    done ; \ 
     454    for i in $(srcdir)/share/http-lua/dialogs/* ; do \ 
     455      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/dialogs/`basename $${i}` ; \ 
     456    done ; \ 
     457    for i in $(srcdir)/share/http-lua/js/*.* ; do \ 
     458      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/js/`basename $${i}` ; \ 
     459    done ; \ 
     460    for i in $(srcdir)/share/http-lua/old/*.* ; do \ 
     461      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old/`basename $${i}` ; \ 
     462    done ; \ 
     463    for i in $(srcdir)/share/http-lua/old/admin/*.* ; do \ 
     464      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old/admin/`basename $${i}` ; \ 
     465    done ; \ 
     466    for i in $(srcdir)/share/http-lua/old/vlm/*.* ; do \ 
     467      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/old/vlm/`basename $${i}` ; \ 
     468    done ; \ 
     469    for i in $(srcdir)/share/http-lua/images/*.* ; do \ 
     470      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/images/`basename $${i}` ; \ 
     471    done ; \ 
     472    for i in $(srcdir)/share/http-lua/requests/*.* ; do \ 
     473      $(INSTALL) -m 644 $${i} $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/requests/`basename $${i}` ; \ 
     474    done ; \ 
     475    $(INSTALL) -m 644 $(srcdir)/share/http-lua/requests/readme $(top_builddir)/VLC-release.app/Contents/MacOS/share/http-lua/requests/readme.txt 
    444476    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http/dialogs 
    445477    $(INSTALL) -d $(top_builddir)/VLC-release.app/Contents/MacOS/share/http/js 
     
    647679    done 
    648680 
     681    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/images" 
     682    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/requests" 
     683    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/js" 
     684    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/dialogs" 
     685    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/old" 
     686    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/old/vlm" 
     687    mkdir -p "$(top_builddir)/vlc-${VERSION}/http-lua/old/admin" 
     688    cp $(srcdir)/share/http-lua/*.html $(top_builddir)/vlc-${VERSION}/http-lua/ ; 
     689    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/*.html ; 
     690    cp $(srcdir)/share/http-lua/.hosts $(top_builddir)/vlc-${VERSION}/http-lua/ ; 
     691    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/.hosts ; 
     692    cp $(srcdir)/share/http-lua/*.css $(top_builddir)/vlc-${VERSION}/http-lua/ ; 
     693    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/*.css ; 
     694    cp $(srcdir)/share/http-lua/js/*.js $(top_builddir)/vlc-${VERSION}/http-lua/js/ ; 
     695    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/js/*.js ; 
     696    cp $(srcdir)/share/http-lua/dialogs/* $(top_builddir)/vlc-${VERSION}/http-lua/dialogs/ ; 
     697    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/dialogs/* ; 
     698    cp $(srcdir)/share/http-lua/dialogs/.hosts $(top_builddir)/vlc-${VERSION}/http-lua/dialogs/ ; 
     699    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/dialogs/.hosts ; 
     700    cp $(srcdir)/share/http-lua/*.ico $(top_builddir)/vlc-${VERSION}/http-lua/ ; 
     701    cp $(srcdir)/share/http-lua/images/*.png $(top_builddir)/vlc-${VERSION}/http-lua/images/ 
     702    cp $(srcdir)/share/http-lua/requests/*.xml $(top_builddir)/vlc-${VERSION}/http-lua/requests/ ; 
     703    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/requests/*.xml ; 
     704    cp $(srcdir)/share/http-lua/requests/readme $(top_builddir)/vlc-${VERSION}/http-lua/requests/readme.txt ; 
     705    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/requests/readme.txt ; 
     706 
     707    cp $(srcdir)/share/http-lua/old/*.html $(top_builddir)/vlc-${VERSION}/http-lua/old/ ; 
     708    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/old/*.html ; 
     709    cp $(srcdir)/share/http-lua/old/*.css $(top_builddir)/vlc-${VERSION}/http-lua/old/ ; 
     710    cp $(srcdir)/share/http-lua/old/.hosts $(top_builddir)/vlc-${VERSION}/http-lua/old/ ; 
     711    cp $(srcdir)/share/http-lua/old/*.png $(top_builddir)/vlc-${VERSION}/http-lua/old/ ; 
     712    cp $(srcdir)/share/http-lua/old/vlm/*.html $(top_builddir)/vlc-${VERSION}/http-lua/old/vlm/ ; 
     713    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/old/vlm/*.html ; 
     714    cp $(srcdir)/share/http-lua/old/admin/*.html $(top_builddir)/vlc-${VERSION}/http-lua/old/admin/ ; 
     715    unix2dos $(top_builddir)/vlc-${VERSION}/http-lua/old/admin/*.html ; 
     716    cp $(srcdir)/share/http-lua/old/admin/.access $(top_builddir)/vlc-${VERSION}/http-lua/old/admin/ ; 
     717 
    649718    mkdir -p "$(top_builddir)/vlc-${VERSION}/http/images" 
    650719    mkdir -p "$(top_builddir)/vlc-${VERSION}/http/requests" 
  • modules/misc/lua/Modules.am

    rde31813 re10d431  
    1 SOURCES_lua = playlist.c meta.c intf.c vlc.c vlc.h callbacks.c objects.c variables.c configuration.c net.c vlm.c 
     1SOURCES_lua = playlist.c meta.c intf.c vlc.c vlc.h callbacks.c objects.c variables.c configuration.c net.c vlm.c httpd.c acl.c 
  • modules/misc/lua/callbacks.c

    rde31813 re10d431  
    160160    p_callback->i_index = i_index; 
    161161    p_callback->i_type = var_Type( p_obj, psz_var ); 
    162     p_callback->L = lua_newthread( L ); 
     162    p_callback->L = lua_newthread( L ); /* Do we have to keep a reference to this thread somewhere to prevent garbage collection? */ 
    163163 
    164164    var_AddCallback( p_obj, psz_var, vlclua_callback, p_callback ); 
  • modules/misc/lua/intf.c

    rd510781 re10d431  
    123123    int i; 
    124124    if( !p_input ) return vlclua_error( L ); 
    125     vlc_mutex_lock( &input_GetItem(p_input)->lock ); 
     125    //vlc_mutex_lock( &input_GetItem(p_input)->lock ); 
    126126    i_cat = input_GetItem(p_input)->i_categories; 
    127127    lua_createtable( L, 0, i_cat ); 
     
    142142        lua_settable( L, -3 ); 
    143143    } 
    144     vlc_object_release( p_input ); 
     144    //vlc_object_release( p_input ); 
    145145    return 1; 
    146146} 
     
    162162        lua_pushstring( L, input_GetItem(p_input)->psz_name ); 
    163163        vlc_object_release( p_input ); 
     164    } 
     165    return 1; 
     166} 
     167 
     168static int vlclua_input_stats( lua_State *L ) 
     169{ 
     170    input_thread_t *p_input = vlclua_get_input_internal( L ); 
     171    input_item_t *p_item = p_input && p_input->p ? input_GetItem( p_input ) : NULL; 
     172    lua_newtable( L ); 
     173    if( p_item ) 
     174    { 
     175#define STATS_INT( n ) lua_pushinteger( L, p_item->p_stats->i_ ## n ); \ 
     176                       lua_setfield( L, -2, #n ); 
     177#define STATS_FLOAT( n ) lua_pushnumber( L, p_item->p_stats->f_ ## n ); \ 
     178                         lua_setfield( L, -2, #n ); 
     179        STATS_INT( read_bytes ) 
     180        STATS_FLOAT( input_bitrate ) 
     181        STATS_INT( demux_read_bytes ) 
     182        STATS_FLOAT( demux_bitrate ) 
     183        STATS_INT( decoded_video ) 
     184        STATS_INT( displayed_pictures ) 
     185        STATS_INT( lost_pictures ) 
     186        STATS_INT( decoded_audio ) 
     187        STATS_INT( played_abuffers ) 
     188        STATS_INT( lost_abuffers ) 
     189        STATS_INT( sent_packets ) 
     190        STATS_INT( sent_bytes ) 
     191        STATS_FLOAT( send_bitrate ) 
     192#undef STATS_INT 
     193#undef STATS_FLOAT 
    164194    } 
    165195    return 1; 
     
    455485        lua_pushstring( L, p_input->psz_uri ); 
    456486        lua_setfield( L, -2, "path" ); 
    457         lua_pushnumber( L, ((double)p_input->i_duration)*1e-6 ); 
     487        if( p_input->i_duration < 0 ) 
     488            lua_pushnumber( L, -1 ); 
     489        else 
     490            lua_pushnumber( L, ((double)p_input->i_duration)*1e-6 ); 
    458491        lua_setfield( L, -2, "duration" ); 
    459492        lua_pushinteger( L, p_input->i_nb_played ); 
     
    477510    intf_thread_t *p_intf = (intf_thread_t *)vlclua_get_this( L ); 
    478511    playlist_t *p_playlist = pl_Yield( p_intf ); 
     512    /* 
    479513    int i_count = 0; 
    480     lua_settop( L, 0 ); 
     514    lua_settop( L, 0 );*/ 
    481515    if( p_playlist->p_input ) 
    482516    { 
    483         char *psz_uri = 
     517        /*char *psz_uri = 
    484518            input_item_GetURI( input_GetItem( p_playlist->p_input ) ); 
    485519        lua_pushstring( L, psz_uri ); 
    486520        free( psz_uri ); 
    487         lua_pushnumber( L, config_GetInt( p_intf, "volume" ) ); 
     521        lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/ 
    488522        vlc_mutex_lock( &p_playlist->object_lock ); 
    489523        switch( p_playlist->status.i_status ) 
     
    493527                break; 
    494528            case PLAYLIST_RUNNING: 
    495                 lua_pushstring( L, "running" ); 
     529                lua_pushstring( L, "playing" ); 
    496530                break; 
    497531            case PLAYLIST_PAUSED: 
     
    503537        } 
    504538        vlc_mutex_unlock( &p_playlist->object_lock ); 
    505         i_count += 3; 
    506     } 
    507     vlc_object_release( p_playlist ); 
    508     return i_count; 
     539        /*i_count += 3;*/ 
     540    } 
     541    else 
     542    { 
     543        lua_pushstring( L, "stopped" ); 
     544    } 
     545    vlc_object_release( p_playlist ); 
     546    return 1; 
    509547} 
    510548 
     
    553591    { "decode_uri", vlclua_decode_uri }, 
    554592    { "resolve_xml_special_chars", vlclua_resolve_xml_special_chars }, 
     593    { "convert_xml_special_chars", vlclua_convert_xml_special_chars }, 
    555594 
    556595    { "lock_and_wait", vlclua_lock_and_wait }, 
     
    559598    { "version", vlclua_version }, 
    560599    { "license", vlclua_license }, 
     600    { "copyright", vlclua_copyright }, 
    561601    { "should_die", vlclua_intf_should_die }, 
    562602    { "quit", vlclua_quit }, 
     603 
     604    { "homedir", vlclua_homedir }, 
     605    { "datadir", vlclua_datadir }, 
     606    { "configdir", vlclua_configdir }, 
     607    { "cachedir", vlclua_cachedir }, 
     608    { "datadir_list", vlclua_datadir_list }, 
    563609 
    564610    { NULL, NULL } 
     
    621667    { "enqueue", vlclua_playlist_enqueue }, 
    622668    { "get", vlclua_playlist_get }, 
     669    { "stats", vlclua_input_stats }, 
    623670 
    624671    { NULL, NULL } 
     
    665712    { "read", vlclua_fd_read }, 
    666713    { "write", vlclua_fd_write }, 
     714    { "stat", vlclua_stat }, 
     715 
     716    { "opendir", vlclua_opendir }, 
    667717 
    668718    { "new_fd_set", vlclua_fd_set_new }, 
     
    684734}; 
    685735 
     736static luaL_Reg p_reg_httpd[] = 
     737{ 
     738    { "host_new", vlclua_httpd_tls_host_new }, 
     739    { "host_delete", vlclua_httpd_host_delete }, 
     740    { "handler_new", vlclua_httpd_handler_new }, 
     741    { "handler_delete", vlclua_httpd_handler_delete }, 
     742    { "file_new", vlclua_httpd_file_new }, 
     743    { "file_delete", vlclua_httpd_file_delete }, 
     744    { "redirect_new", vlclua_httpd_redirect_new }, 
     745    { "redirect_delete", vlclua_httpd_redirect_delete }, 
     746 
     747    { NULL, NULL } 
     748}; 
     749 
     750static luaL_Reg p_reg_acl[] = 
     751{ 
     752    { "create", vlclua_acl_create }, 
     753    { "delete", vlclua_acl_delete }, 
     754    { "check", vlclua_acl_check }, 
     755    { "duplicate", vlclua_acl_duplicate }, 
     756    { "add_host", vlclua_acl_add_host }, 
     757    { "add_net", vlclua_acl_add_net }, 
     758    { "load_file", vlclua_acl_load_file }, 
     759 
     760    { NULL, NULL } 
     761}; 
    686762 
    687763static void Run( intf_thread_t *p_intf ); 
     
    818894    luaL_register_submodule( L, "fd", p_reg_fd ); 
    819895    luaL_register_submodule( L, "vlm", p_reg_vlm ); 
     896    luaL_register_submodule( L, "httpd", p_reg_httpd ); 
     897    luaL_register_submodule( L, "acl", p_reg_acl ); 
    820898    /* clean up */ 
    821899    lua_pop( L, 1 ); 
  • modules/misc/lua/net.c

    rde31813 re10d431  
    206206    return 1; 
    207207} 
     208 
     209int vlclua_stat( lua_State *L ) 
     210{ 
     211#ifdef HAVE_SYS_STAT_H 
     212    const char *psz_path = luaL_checkstring( L, 1 ); 
     213    struct stat s; 
     214    if( utf8_stat( psz_path, &s ) ) 
     215        return 0; 
     216        //return luaL_error( L, "Couldn't stat %s.", psz_path ); 
     217    lua_newtable( L ); 
     218    if( S_ISREG( s.st_mode ) ) 
     219        lua_pushstring( L, "file" ); 
     220    else if( S_ISDIR( s.st_mode ) ) 
     221        lua_pushstring( L, "dir" ); 
     222#ifdef S_ISCHR 
     223    else if( S_ISCHR( s.st_mode ) ) 
     224        lua_pushstring( L, "character device" ); 
     225#endif 
     226#ifdef S_ISBLK 
     227    else if( S_ISBLK( s.st_mode ) ) 
     228        lua_pushstring( L, "block device" ); 
     229#endif 
     230#ifdef S_ISFIFO 
     231    else if( S_ISFIFO( s.st_mode ) ) 
     232        lua_pushstring( L, "fifo" ); 
     233#endif 
     234#ifdef S_ISLNK 
     235    else if( S_ISLNK( s.st_mode ) ) 
     236        lua_pushstring( L, "symbolic link" ); 
     237#endif 
     238#ifdef S_ISSOCK 
     239    else if( S_ISSOCK( s.st_mode ) ) 
     240        lua_pushstring( L, "socket" ); 
     241#endif 
     242    else 
     243        lua_pushstring( L, "unknown" ); 
     244    lua_setfield( L, -2, "type" ); 
     245    lua_pushinteger( L, s.st_mode ); 
     246    lua_setfield( L, -2, "mode" ); 
     247    lua_pushinteger( L, s.st_uid ); 
     248    lua_setfield( L, -2, "uid" ); 
     249    lua_pushinteger( L, s.st_gid ); 
     250    lua_setfield( L, -2, "gid" ); 
     251    lua_pushinteger( L, s.st_size ); 
     252    lua_setfield( L, -2, "size" ); 
     253    lua_pushinteger( L, s.st_atime ); 
     254    lua_setfield( L, -2, "access_time" ); 
     255    lua_pushinteger( L, s.st_mtime ); 
     256    lua_setfield( L, -2, "modification_time" ); 
     257    lua_pushinteger( L, s.st_ctime ); 
     258    lua_setfield( L, -2, "creation_time" ); 
     259    return 1; 
     260#else 
     261#   warning "Woops, looks like we don't have stat on your platform" 
     262    return luaL_error( L, "System is missing <sys/stat.h>" ); 
     263#endif 
     264} 
     265 
     266int vlclua_opendir( lua_State *L ) 
     267{ 
     268    const char *psz_dir = luaL_checkstring( L, 1 ); 
     269    DIR *p_dir; 
     270    int i = 0; 
     271#ifdef HAVE_SYS_STAT_H 
     272    struct stat s; 
     273    if( utf8_stat( psz_dir, &s ) == -1 ) 
     274        return luaL_error( L, "Error while trying to stat `%s'.", psz_dir ); 
     275    if( !S_ISDIR( s.st_mode ) ) 
     276        return luaL_error( L, "`%s' is not a directory.", psz_dir ); 
     277#endif 
     278    if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL ) 
     279        return luaL_error( L, "cannot open directory `%s'.", psz_dir ); 
     280 
     281    lua_newtable( L ); 
     282    for( ;; ) 
     283    { 
     284        char *psz_filename = utf8_readdir( p_dir ); 
     285        if( !psz_filename ) break; 
     286        i++; 
     287        lua_pushstring( L, psz_filename ); 
     288        lua_rawseti( L, -2, i ); 
     289        free( psz_filename ); 
     290    } 
     291    closedir( p_dir ); 
     292    return 1; 
     293} 
  • modules/misc/lua/vlc.c

    rd510781 re10d431  
    120120 
    121121/***************************************************************************** 
     122 * Get the VLC copyright 
     123 *****************************************************************************/ 
     124int vlclua_copyright( lua_State *L ) 
     125{ 
     126    lua_pushstring( L, COPYRIGHT_MESSAGE ); 
     127    return 1; 
     128} 
     129 
     130/***************************************************************************** 
    122131 * Get the VLC license msg/disclaimer 
    123132 *****************************************************************************/ 
     
    138147    vlc_object_kill( p_this->p_libvlc ); 
    139148    return 0; 
     149} 
     150 
     151/***************************************************************************** 
     152 * Global properties getters 
     153 *****************************************************************************/ 
     154int vlclua_datadir( lua_State *L ) 
     155{ 
     156    lua_pushstring( L, config_GetDataDir() ); 
     157    return 1; 
     158} 
     159int vlclua_homedir( lua_State *L ) 
     160{ 
     161    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_homedir ); 
     162    return 1; 
     163} 
     164int vlclua_configdir( lua_State *L ) 
     165{ 
     166    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_configdir ); 
     167    return 1; 
     168} 
     169int vlclua_cachedir( lua_State *L ) 
     170{ 
     171    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_cachedir ); 
     172    return 1; 
     173} 
     174int vlclua_datadir_list( lua_State *L ) 
     175{ 
     176    const char *psz_dirname = luaL_checkstring( L, 1 ); 
     177    vlc_object_t *p_this = vlclua_get_this( L ); 
     178    char  *ppsz_dir_list[] = { NULL, NULL, NULL, NULL }; 
     179    char **ppsz_dir = ppsz_dir_list; 
     180    int i = 1; 
     181 
     182    if( vlclua_dir_list( p_this, psz_dirname, ppsz_dir_list ) != VLC_SUCCESS ) 
     183        return 0; 
     184    lua_newtable( L ); 
     185    for( ; *ppsz_dir; ppsz_dir++ ) 
     186    { 
     187        lua_pushstring( L, *ppsz_dir ); 
     188        lua_rawseti( L, -2, i ); 
     189        i ++; 
     190    } 
     191    return 1; 
    140192} 
    141193 
     
    270322                             * up to (stack size - 1) arguments */ 
    271323        resolve_xml_special_chars( psz_string ); 
     324        lua_pushstring( L, psz_string ); 
     325        free( psz_string ); 
     326    } 
     327    return i_top; 
     328} 
     329 
     330int vlclua_convert_xml_special_chars( lua_State *L ) 
     331{ 
     332    int i_top = lua_gettop( L ); 
     333    int i; 
     334    for( i = 1; i <= i_top; i++ ) 
     335    { 
     336        char *psz_string = convert_xml_special_chars( luaL_checkstring(L,1) ); 
     337        lua_remove( L, 1 ); 
    272338        lua_pushstring( L, psz_string ); 
    273339        free( psz_string ); 
  • modules/misc/lua/vlc.h

    rd510781 re10d431  
    101101} 
    102102 
     103static inline const char *luaL_nilorcheckstring( lua_State *L, int narg ) 
     104{ 
     105    if( lua_isnil( L, narg ) ) 
     106        return NULL; 
     107    return luaL_checkstring( L, narg ); 
     108} 
     109 
    103110/***************************************************************************** 
    104111 * Lua vlc_object_t wrapper 
     
    133140int vlclua_fd_write( lua_State * ); 
    134141 
     142int vlclua_stat( lua_State * ); 
     143int vlclua_opendir( lua_State * ); 
     144 
    135145int vlclua_vlm_new( lua_State * ); 
    136146int vlclua_vlm_delete( lua_State * ); 
    137147int vlclua_vlm_execute_command( lua_State * ); 
    138148 
     149int vlclua_httpd_tls_host_new( lua_State *L ); 
     150int vlclua_httpd_host_delete( lua_State *L ); 
     151int vlclua_httpd_handler_new( lua_State * L ); 
     152int vlclua_httpd_handler_delete( lua_State *L ); 
     153int vlclua_httpd_file_new( lua_State *L ); 
     154int vlclua_httpd_file_delete( lua_State *L ); 
     155int vlclua_httpd_redirect_new( lua_State *L ); 
     156int vlclua_httpd_redirect_delete( lua_State *L ); 
     157 
     158int vlclua_acl_create( lua_State * ); 
     159int vlclua_acl_delete( lua_State * ); 
     160int vlclua_acl_check( lua_State * ); 
     161int vlclua_acl_duplicate( lua_State * ); 
     162int vlclua_acl_add_host( lua_State * ); 
     163int vlclua_acl_add_net( lua_State * ); 
     164int vlclua_acl_load_file( lua_State * ); 
     165 
     166 
    139167/***************************************************************************** 
    140168 * Lua function bridge 
     
    146174int vlclua_version( lua_State * ); 
    147175int vlclua_license( lua_State * ); 
     176int vlclua_copyright( lua_State * ); 
    148177int vlclua_quit( lua_State * ); 
     178 
     179int vlclua_datadir( lua_State * ); 
     180int vlclua_homedir( lua_State * ); 
     181int vlclua_configdir( lua_State * ); 
     182int vlclua_cachedir( lua_State * ); 
     183int vlclua_datadir_list( lua_State * ); 
    149184 
    150185int vlclua_pushvalue( lua_State *L, int i_type, vlc_value_t val ); /* internal use only */ 
     
    170205int vlclua_decode_uri( lua_State * ); 
    171206int vlclua_resolve_xml_special_chars( lua_State * ); 
     207int vlclua_convert_xml_special_chars( lua_State * ); 
    172208 
    173209int vlclua_msg_dbg( lua_State * ); 
  • share/Makefile.am

    rde31813 re10d431  
    264264    luaintf/telnet.lua \ 
    265265    luaintf/dummy.lua 
     266 
     267DIST_http_lua = \ 
     268    http-lua/.hosts \ 
     269    http-lua/dialogs/.hosts \ 
     270    http-lua/dialogs/browse \ 
     271    http-lua/dialogs/footer \ 
     272    http-lua/dialogs/input \ 
     273    http-lua/dialogs/main \ 
     274    http-lua/dialogs/mosaic \ 
     275    http-lua/dialogs/playlist \ 
     276    http-lua/dialogs/sout \ 
     277    http-lua/dialogs/vlm \ 
     278    http-lua/favicon.ico \ 
     279    http-lua/images/delete.png \ 
     280    http-lua/images/delete_small.png \ 
     281    http-lua/images/eject.png \ 
     282    http-lua/images/empty.png \ 
     283    http-lua/images/fullscreen.png \ 
     284    http-lua/images/help.png \ 
     285    http-lua/images/info.png \ 
     286    http-lua/images/loop.png \ 
     287    http-lua/images/minus.png \ 
     288    http-lua/images/next.png \ 
     289    http-lua/images/pause.png \ 
     290    http-lua/images/play.png \ 
     291    http-lua/images/playlist.png \ 
     292    http-lua/images/playlist_small.png \ 
     293    http-lua/images/plus.png \ 
     294    http-lua/images/prev.png \ 
     295    http-lua/images/refresh.png \ 
     296    http-lua/images/repeat.png \ 
     297    http-lua/images/sd.png \ 
     298    http-lua/images/shuffle.png \ 
     299    http-lua/images/slider_bar.png \ 
     300    http-lua/images/slider_left.png \ 
     301    http-lua/images/slider_point.png \ 
     302    http-lua/images/slider_right.png \ 
     303    http-lua/images/snapshot.png \ 
     304    http-lua/images/slow.png \ 
     305    http-lua/images/sort.png \ 
     306    http-lua/images/sout.png \ 
     307    http-lua/images/speaker.png \ 
     308    http-lua/images/speaker_mute.png \ 
     309    http-lua/images/stop.png \ 
     310    http-lua/images/vlc16x16.png \ 
     311    http-lua/images/volume_down.png \ 
     312    http-lua/images/volume_up.png \ 
     313    http-lua/images/white.png \ 
     314    http-lua/images/white_cross_small.png \ 
     315    http-lua/index.html \ 
     316    http-lua/js/functions.js \ 
     317    http-lua/js/mosaic.js \ 
     318    http-lua/js/vlm.js \ 
     319    http-lua/mosaic.html \ 
     320    http-lua/old/.hosts \ 
     321    http-lua/old/admin/.access \ 
     322    http-lua/old/admin/browse.html \ 
     323    http-lua/old/admin/dboxfiles.html \ 
     324    http-lua/old/admin/index.html \ 
     325    http-lua/old/cone_minus.png \ 
     326    http-lua/old/cone_plus.png \ 
     327    http-lua/old/index.html \ 
     328    http-lua/old/info.html \ 
     329    http-lua/old/style.css \ 
     330    http-lua/old/vlm/edit.html \ 
     331    http-lua/old/vlm/index.html \ 
     332    http-lua/old/vlm/new.html \ 
     333    http-lua/old/vlm/show.html \ 
     334    http-lua/old/webcam.html \ 
     335    http-lua/requests/browse.xml \ 
     336    http-lua/requests/playlist.xml \ 
     337    http-lua/requests/status.xml \ 
     338    http-lua/requests/vlm.xml \ 
     339    http-lua/requests/vlm_cmd.xml \ 
     340    http-lua/requests/readme \ 
     341    http-lua/style.css \ 
     342    http-lua/iehacks.css \ 
     343    http-lua/vlm.html \ 
     344    http-lua/vlm_export.html \ 
     345    http-lua/flash.html 
  • share/luaintf/modules/common.lua

    rde31813 re10d431  
    7171                         math.floor(duration%60)) 
    7272end 
     73 
     74-- realpath 
     75function realpath(path) 
     76    return string.gsub(string.gsub(string.gsub(string.gsub(path,"/%.%./[^/]+","/"),"/[^/]+/%.%./","/"),"/%./","/"),"//","/") 
     77end 
     78 
     79-- seek 
     80function seek(value) 
     81    local input = vlc.object.input() 
     82    if string.sub(value,#value)=="%" then 
     83        vlc.var.set(input,"position",tonumber(string.sub(value,1,#value-1))/100.) 
     84    else 
     85        vlc.var.set(input,"time",tonumber(value)) 
     86    end 
     87end 
  • share/luaintf/rc.lua

    rd510781 re10d431  
    287287 
    288288function seek(name,client,value) 
    289     local input = vlc.object.input() 
    290     if string.sub(value,#value)=="%" then 
    291         vlc.var.set(input,"position",tonumber(string.sub(value,1,#value-1))/100.) 
    292     else 
    293         vlc.var.set(input,"time",tonumber(value)) 
    294     end 
     289    common.seek(value) 
    295290end 
    296291