CLuaInstance: Add script function "createChannelIDfromUrl' to create...

...WebTV channel_id from a specified url

 - Set Lua api version to 1.6
This commit is contained in:
M. Liebmann
2015-10-28 12:11:59 +01:00
parent 8c60bf6f22
commit 77a2b389bd
2 changed files with 29 additions and 1 deletions

View File

@@ -35,6 +35,7 @@
#include <gui/movieplayer.h>
#include <driver/pictureviewer/pictureviewer.h>
#include <neutrino.h>
#include <zapit/types.h>
#include "luainstance.h"
#include <video.h>
@@ -529,6 +530,7 @@ const luaL_Reg CLuaInstance::methods[] =
{ "strFind", CLuaInstance::strFind },
{ "strSub", CLuaInstance::strSub },
{ "checkVersion", CLuaInstance::checkVersion },
{ "createChannelIDfromUrl", CLuaInstance::createChannelIDfromUrl },
{ NULL, NULL }
};
@@ -2708,3 +2710,28 @@ int CLuaInstance::checkVersion(lua_State *L)
}
// --------------------------------------------------------------------------------
int CLuaInstance::createChannelIDfromUrl(lua_State *L)
{
int numargs = lua_gettop(L);
if (numargs < 2) {
printf("CLuaInstance::%s: no arguments\n", __func__);
lua_pushnil(L);
return 1;
}
const char *url = luaL_checkstring(L, 2);
if (strlen(url) < 1 ) {
lua_pushnil(L);
return 1;
}
t_channel_id id = CREATE_CHANNEL_ID(0, 0, 0, url);
char id_str[17];
snprintf(id_str, sizeof(id_str), "%llx", id);
lua_pushstring(L, id_str);
return 1;
}
// --------------------------------------------------------------------------------

View File

@@ -34,7 +34,7 @@ extern "C" {
#include <vector>
#define LUA_API_VERSION_MAJOR 1
#define LUA_API_VERSION_MINOR 5
#define LUA_API_VERSION_MINOR 6
/* this is stored as userdata in the lua_State */
struct CLuaData
@@ -319,6 +319,7 @@ private:
static bool tableLookup(lua_State*, const char*, bool &value);
static int checkVersion(lua_State *L);
static int createChannelIDfromUrl(lua_State *L);
};
#endif /* _LUAINSTANCE_H */