Add Lua method to show system env

`for v in ARDOUR.LuaAPI.env():iter() do print(v) end`
This commit is contained in:
Robin Gareus 2022-12-07 00:27:12 +01:00
parent 0abbe651ea
commit 85a1c463e5
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 26 additions and 0 deletions

View File

@ -273,6 +273,9 @@ namespace ARDOUR { namespace LuaAPI {
/** Crash Test Dummy */
void segfault ();
/** Return system environment variables (POSIX environ) */
std::vector<std::string> env ();
class Vamp {
/** Vamp Plugin Interface
*

View File

@ -552,6 +552,28 @@ ARDOUR::LuaAPI::segfault ()
*p = 0;
}
#ifdef PLATFORM_WINDOWS
std::vector<std::string>
ARDOUR::LuaAPI::env ()
{
std::vector<std::string> rv;
return rv;
}
#else
extern char **environ;
std::vector<std::string>
ARDOUR::LuaAPI::env ()
{
std::vector<std::string> rv;
for (int i = 0; environ[i]; ++i) {
rv.push_back (environ[i]);
}
return rv;
}
#endif
int
ARDOUR::LuaOSC::Address::send (lua_State *L)
{

View File

@ -2955,6 +2955,7 @@ LuaBindings::common (lua_State* L)
.addCFunction ("timecode_to_sample", ARDOUR::LuaAPI::timecode_to_sample)
.addFunction ("wait_for_process_callback", ARDOUR::LuaAPI::wait_for_process_callback)
.addFunction ("segfault", ARDOUR::LuaAPI::segfault)
.addFunction ("env", ARDOUR::LuaAPI::env)
.beginNamespace ("FileTest")
.addConst ("IsRegular", Glib::FILE_TEST_IS_REGULAR)