comparison OrthancFramework/Sources/Lua/LuaContext.cpp @ 4300:b30a8de92ad9

abi continued
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 05 Nov 2020 19:33:18 +0100
parents bf7b9edf6b81
children 3af1d763763a
comparison
equal deleted inserted replaced
4299:3f85db78c441 4300:b30a8de92ad9
576 { 576 {
577 lua_close(lua_); 577 lua_close(lua_);
578 } 578 }
579 579
580 580
581 void LuaContext::Execute(const std::string &command)
582 {
583 ExecuteInternal(NULL, command);
584 }
585
586 void LuaContext::Execute(std::string &output, const std::string &command)
587 {
588 ExecuteInternal(&output, command);
589 }
590
591
581 void LuaContext::ExecuteInternal(std::string* output, 592 void LuaContext::ExecuteInternal(std::string* output,
582 const std::string& command) 593 const std::string& command)
583 { 594 {
584 log_.clear(); 595 log_.clear();
585 int error = (luaL_loadbuffer(lua_, command.c_str(), command.size(), "line") || 596 int error = (luaL_loadbuffer(lua_, command.c_str(), command.size(), "line") ||
605 { 616 {
606 lua_settop(lua_, 0); 617 lua_settop(lua_, 0);
607 lua_getglobal(lua_, name); 618 lua_getglobal(lua_, name);
608 return lua_type(lua_, -1) == LUA_TFUNCTION; 619 return lua_type(lua_, -1) == LUA_TFUNCTION;
609 } 620 }
621
622
623 #if ORTHANC_ENABLE_CURL == 1
624 void LuaContext::SetHttpCredentials(const char* username,
625 const char* password)
626 {
627 httpClient_.SetCredentials(username, password);
628 }
629 #endif
610 630
611 631
612 void LuaContext::Execute(Json::Value& output, 632 void LuaContext::Execute(Json::Value& output,
613 const std::string& command) 633 const std::string& command)
614 { 634 {