Exported the Base64 encoding and decoding functions to Lua API.
This commit is contained in:
parent
e7e65b5005
commit
bcf5021feb
src
@ -190,6 +190,50 @@ static int tolua_LOGERROR(lua_State * tolua_S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int tolua_Base64Encode(lua_State * tolua_S)
|
||||||
|
{
|
||||||
|
cLuaState L(tolua_S);
|
||||||
|
if (
|
||||||
|
!L.CheckParamString(1) ||
|
||||||
|
!L.CheckParamEnd(2)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AString Src;
|
||||||
|
L.GetStackValue(1, Src);
|
||||||
|
AString res = Base64Encode(Src);
|
||||||
|
L.Push(res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int tolua_Base64Decode(lua_State * tolua_S)
|
||||||
|
{
|
||||||
|
cLuaState L(tolua_S);
|
||||||
|
if (
|
||||||
|
!L.CheckParamString(1) ||
|
||||||
|
!L.CheckParamEnd(2)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AString Src;
|
||||||
|
L.GetStackValue(1, Src);
|
||||||
|
AString res = Base64Decode(Src);
|
||||||
|
L.Push(res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cPluginLua * GetLuaPlugin(lua_State * L)
|
cPluginLua * GetLuaPlugin(lua_State * L)
|
||||||
{
|
{
|
||||||
// Get the plugin identification out of LuaState:
|
// Get the plugin identification out of LuaState:
|
||||||
@ -2869,6 +2913,8 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
|||||||
tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN);
|
tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN);
|
||||||
tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN);
|
tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN);
|
||||||
tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR);
|
tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR);
|
||||||
|
tolua_function(tolua_S, "Base64Encode", tolua_Base64Encode);
|
||||||
|
tolua_function(tolua_S, "Base64Decode", tolua_Base64Decode);
|
||||||
|
|
||||||
tolua_beginmodule(tolua_S, "cFile");
|
tolua_beginmodule(tolua_S, "cFile");
|
||||||
tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents);
|
tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents);
|
||||||
|
@ -79,10 +79,10 @@ extern AString URLDecode(const AString & a_String); // Cannot export to Lua aut
|
|||||||
extern AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, char a_To); // Needn't export to Lua, since Lua doesn't have chars anyway
|
extern AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, char a_To); // Needn't export to Lua, since Lua doesn't have chars anyway
|
||||||
|
|
||||||
/// Decodes a Base64-encoded string into the raw data
|
/// Decodes a Base64-encoded string into the raw data
|
||||||
extern AString Base64Decode(const AString & a_Base64String);
|
extern AString Base64Decode(const AString & a_Base64String); // Exported manually due to embedded NULs and extra parameter
|
||||||
|
|
||||||
/// Encodes a string into Base64
|
/// Encodes a string into Base64
|
||||||
extern AString Base64Encode(const AString & a_Input);
|
extern AString Base64Encode(const AString & a_Input); // Exported manually due to embedded NULs and extra parameter
|
||||||
|
|
||||||
/// Reads two bytes from the specified memory location and interprets them as BigEndian short
|
/// Reads two bytes from the specified memory location and interprets them as BigEndian short
|
||||||
extern short GetBEShort(const char * a_Mem);
|
extern short GetBEShort(const char * a_Mem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user