Skip to content

Commit

Permalink
Added functions scaffolds
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kürzeder committed Jul 22, 2019
1 parent 85a7a92 commit 3cab9af
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
38 changes: 37 additions & 1 deletion module/CFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,42 @@
#include <sys/stat.h>
#endif

int CFunctions::Test(lua_State* luaVM)
{
pModuleManager->DebugPrintf(luaVM, "Module works! JWT ASDOIKFHÜSPAO!");
lua_pushstring(luaVM, "FUCK YOU!");
lua_pushboolean(luaVM, false);
return 2;
}

int CFunctions::SignJWTToken(lua_State* luaVM)
{
// string jwtSign(string payload, string algorithm, string secret)
if (lua_type(luaVM, 1) != LUA_TSTRING || lua_type(luaVM, 2) != LUA_TSTRING || lua_type(luaVM, 3) != LUA_TSTRING)
{
pModuleManager->ErrorPrintf("Bad argument @ jwtSign\n");
lua_pushboolean(luaVM, false);
return 1;
}

lua_pushstring(luaVM, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
return 1;
}

int CFunctions::VerifyJWTToken(lua_State* luaVM)
{
// bool jwtVerify(string token, string algorithm, string secret)
if (lua_type(luaVM, 1) != LUA_TSTRING || lua_type(luaVM, 2) != LUA_TSTRING || lua_type(luaVM, 3) != LUA_TSTRING)
{
pModuleManager->ErrorPrintf("Bad argument @ jwtVerify\n");
lua_pushboolean(luaVM, false);
return 1;
}

lua_pushboolean(luaVM, false);
return 1;
}

/*
int CFunctions::LoadPathGraph(lua_State* luaVM)
{
Expand All @@ -25,7 +61,7 @@ int CFunctions::LoadPathGraph(lua_State* luaVM)
pModuleManager->ErrorPrintf("File does not exist @ loadPathGraph\n");
lua_pushboolean(luaVM, false);
return 1;
}
-}
// Check if path is valid
std::string path{ buf };
Expand Down
7 changes: 7 additions & 0 deletions module/CFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ extern ILuaModuleManager10* pModuleManager;
class CFunctions
{
public:
static int Test(lua_State* luaVM);

static int VerifyJWTToken(lua_State* luaVM);
static int SignJWTToken(lua_State* luaVM);

/*
static int LoadPathGraph(lua_State* luaVM);
static int UnloadPathGraph(lua_State* luaVM);
static int FindShortestPathBetween(lua_State* luaVM);
static int IsGraphLoaded(lua_State* luaVM);
static int FindNodeAt(lua_State* luaVM);
static int GetNodeNeighbors(lua_State* luaVM);
*/
};
11 changes: 3 additions & 8 deletions module/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,9 @@ MTAEXPORT void RegisterFunctions(lua_State* luaVM)
g_Module->AddLuaVM(luaVM);

// Register functions
/*
pModuleManager->RegisterFunction(luaVM, "loadPathGraph", &CFunctions::LoadPathGraph);
pModuleManager->RegisterFunction(luaVM, "unloadPathGraph", &CFunctions::UnloadPathGraph);
pModuleManager->RegisterFunction(luaVM, "findShortestPathBetween", &CFunctions::FindShortestPathBetween);
pModuleManager->RegisterFunction(luaVM, "isGraphLoaded", &CFunctions::IsGraphLoaded);
pModuleManager->RegisterFunction(luaVM, "findNodeAt", &CFunctions::FindNodeAt);
pModuleManager->RegisterFunction(luaVM, "getNodeNeighbors", &CFunctions::GetNodeNeighbors);
*/
pModuleManager->RegisterFunction(luaVM, "jwtTest", &CFunctions::Test);
pModuleManager->RegisterFunction(luaVM, "jwtSign", &CFunctions::SignJWTToken);
pModuleManager->RegisterFunction(luaVM, "jwtVerify", &CFunctions::VerifyJWTToken);
}

MTAEXPORT bool DoPulse()
Expand Down
2 changes: 0 additions & 2 deletions test/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ project "test"
"premake5.lua",
"**.cpp",
"**.h",

"testnodes1.json"
}

0 comments on commit 3cab9af

Please sign in to comment.