Changeset d5107810595354bd93f6bf65713c039d1bc7cb8b

Show
Ignore:
Timestamp:
11/05/07 22:52:26 (8 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1194299546 +0000
git-parent:

[94742be8ad29e8941d9eec6835f78633cf0f6142]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1194299546 +0000
Message:
  • modules/misc/lua:
    • Add vlc.license()
    • vlc.vlm.execute_command() now returns the VLC error code and the corresponding error message as 2nd and 3rd return values.
  • share/luaintf: add help and module description related stuff to the telnet and rc modules.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/misc/lua/intf.c

    rde31813 rd510781  
    558558 
    559559    { "version", vlclua_version }, 
     560    { "license", vlclua_license }, 
    560561    { "should_die", vlclua_intf_should_die }, 
    561562    { "quit", vlclua_quit }, 
  • modules/misc/lua/vlc.c

    rbddd76b rd510781  
    116116{ 
    117117    lua_pushstring( L, VLC_Version() ); 
     118    return 1; 
     119} 
     120 
     121/***************************************************************************** 
     122 * Get the VLC license msg/disclaimer 
     123 *****************************************************************************/ 
     124int vlclua_license( lua_State *L ) 
     125{ 
     126    lua_pushstring( L, LICENSE_MSG ); 
    118127    return 1; 
    119128} 
  • modules/misc/lua/vlc.h

    rde31813 rd510781  
    145145 
    146146int vlclua_version( lua_State * ); 
     147int vlclua_license( lua_State * ); 
    147148int vlclua_quit( lua_State * ); 
    148149 
  • modules/misc/lua/vlm.c

    rde31813 rd510781  
    8888    const char *psz_command = luaL_checkstring( L, 2 ); 
    8989    vlm_message_t *message; 
    90     vlm_ExecuteCommand( p_vlm, psz_command, &message ); 
     90    int i_ret; 
     91    i_ret = vlm_ExecuteCommand( p_vlm, psz_command, &message ); 
    9192    lua_settop( L, 0 ); 
    9293    push_message( L, message ); 
    9394    vlm_MessageDelete( message ); 
    94     return 1
     95    return 1 + vlclua_push_ret( L, i_ret )
    9596} 
  • share/luaintf/rc.lua

    r94742be rd510781  
    2222--]==========================================================================] 
    2323 
    24 --[==========================================================================[ 
     24description= 
     25[============================================================================[ 
     26 Remote control interface for VLC 
     27 
    2528 This is a modules/control/rc.c look alike (with a bunch of new features) 
    2629  
     
    3437 Note: 
    3538    -I luarc is an alias for -I lua --lua-intf rc 
    36 --]==========================================================================] 
     39 
     40 Configuration options setable throught the --lua-config option are: 
     41    * hosts: A list of hosts to listen on. 
     42    * host: A host to listen on. (won't be used if `hosts' is set) 
     43 The following can be set using the --lua-config option or in the interface 
     44 itself using the `set' command: 
     45    * prompt: The prompt. 
     46    * welcome: The welcome message. 
     47    * width: The default terminal width (used to format text). 
     48    * autocompletion: When issuing an unknown command, print a list of 
     49                      possible commands to autocomplete with. (0 to disable, 
     50                      1 to enable). 
     51    * autoalias: If autocompletion returns only one possibility, use it 
     52                 (0 to disable, 1 to enable). 
     53]============================================================================] 
    3754 
    3855require("common") 
     
    4966        welcome = "Remote control interface initialized. Type `help' for help." 
    5067      } 
     68 
     69--[[ Import custom environement variables from the command line config (if possible) ]] 
     70for k,v in pairs(env) do 
     71    if config[k] then 
     72        if type(env[k]) == type(config[k]) then 
     73            env[k] = config[k] 
     74            vlc.msg.dbg("set environement variable `"..k.."' to "..tonumber(env[k])) 
     75        else 
     76            vlc.msg.err("environement variable `"..k.."' should be of type "..type(env[k])..". config value will be discarded.") 
     77        end 
     78    end 
     79end 
    5180 
    5281--[[ Command functions ]] 
     
    159188    end 
    160189    client:append("+----[ End of playlist ]") 
     190end 
     191 
     192function print_text(label,text) 
     193    return function(name,client) 
     194        client:append("+----[ "..label.." ]") 
     195        client:append "|" 
     196        for line in string.gmatch(text,".-\r?\n") do 
     197            client:append("| "..string.gsub(line,"\r?\n","")) 
     198        end 
     199        client:append "|" 
     200        client:append("+----[ End of "..string.lower(label).." ]") 
     201    end 
    161202end 
    162203 
     
    353394    { "alias"; { func = skip(alias); args = "[cmd]"; help = "set/get command aliases"; adv = true } }; 
    354395    { "eval"; { func = skip(eval); help = "eval some lua (*debug*)"; adv =true } }; -- FIXME: comment out if you're not debugging 
     396    { "description"; { func = print_text("Description",description); help = "describe this module" } }; 
     397    { "license"; { func = print_text("License message",vlc.license()); help = "print VLC's license message"; adv = true } }; 
    355398    { "help"; { func = help; args = "[pattern]"; help = "a help message"; aliases = { "?" } } }; 
    356399    { "longhelp"; { func = help; args = "[pattern]"; help = "a longer help message" } }; 
     
    448491end 
    449492-- Print prompt when switching a client's status to `read' 
    450 h.status_callbacks[host.status.read] = function(client) client:send( client.env.prompt ) end 
     493h.status_callbacks[host.status.read] = function(client) 
     494    client:send( client.env.prompt ) 
     495end 
    451496 
    452497h:listen( config.hosts or config.host or "*console" ) 
  • share/luaintf/telnet.lua

    r786b6c4 rd510781  
    2222--]==========================================================================] 
    2323 
    24 --[==========================================================================[ 
     24description= 
     25[============================================================================[ 
     26 VLM Interface plugin 
     27 
    2528 Copy (features wise) of the original VLC modules/control/telnet.c module. 
    2629 
     
    3235        listen on stdin: vlc -I lua --lua-intf telnet --lua-config "telnet={host='*console'}" 
    3336        listen on stdin + 2 ports on localhost: vlc -I lua --lua-intf telnet --lua-config "telnet={hosts={'localhost:4212','localhost:5678','*console'}}" 
    34 --]==========================================================================] 
     37  
     38 Configuration options setable throught the --lua-config option are: 
     39    * hosts: A list of hosts to listen on (see examples above). 
     40    * host: A host to listen on. (won't be used if `hosts' is set) 
     41    * password: The password used for remote clients. 
     42    * prompt: The prompt. 
     43]============================================================================] 
    3544 
    3645require "host" 
     
    5564end 
    5665function on_read( client ) 
    57     client:send( "> " ) 
     66    client:send( config.prompt and tostring(config.prompt) or "> " ) 
    5867end 
    5968function on_write( client ) 
     
    119128    return false 
    120129end 
     130function print_text(text) 
     131    return function(client) 
     132        client:append(string.gsub(text,"\r?\n","\r\n")) 
     133        return true 
     134    end 
     135end 
    121136function help(client) 
    122137    client:append("    Telnet Specific Commands:") 
     
    127142end 
    128143commands = { 
    129     ["shutdown"] = { func = shutdown, help = "shutdown VLC" }, 
    130     ["quit"]     = { func = quit, help = "logout from telnet/shutdown VLC from local shell" }, 
    131     ["logout"]   = { func = logout, help = "logout" }, 
    132     ["lock"]     = { func = lock, help = "lock the telnet prompt" }, 
    133     ["help"]     = { func = help, help = "show this help", dovlm = true }, 
     144    ["shutdown"]    = { func = shutdown, help = "shutdown VLC" }, 
     145    ["quit"]        = { func = quit, help = "logout from telnet/shutdown VLC from local shell" }, 
     146    ["logout"]      = { func = logout, help = "logout" }, 
     147    ["lock"]        = { func = lock, help = "lock the telnet prompt" }, 
     148    ["description"] = { func = print_text(description), help = "describe this module" }, 
     149    ["license"]     = { func = print_text(vlc.license()), help = "print VLC's license message" }, 
     150    ["help"]        = { func = help, help = "show this help", dovlm = true }, 
    134151    } 
    135152 
     
    139156    if not commands[cmd] or not commands[cmd].func or commands[cmd].dovlm then 
    140157        -- if it's not an interface specific command, it has to be a VLM command 
    141         message = vlc.vlm.execute_command( vlm, cmd ) 
     158        local message, vlc_err = vlc.vlm.execute_command( vlm, cmd ) 
    142159        vlm_message_to_string( client, message ) 
    143160        if not commands[cmd] or not commands[cmd].func and not commands[cmd].dovlm then 
     161            if vlc_err ~= 0 then client:append( "Type `help' for help." ) end 
    144162            return true 
    145163        end