lunch-rest/environment.cpp
2020-09-20 16:27:49 +02:00

19 lines
451 B
C++

#include "environment.hpp"
#include <cstring>
char **environment_env_ptr = nullptr;
void setupEnv(char **env) {
environment_env_ptr = env;
}
std::string getEnv(const std::string &env) {
auto env_ptr = environment_env_ptr;
while(*env_ptr != NULL) {
if(!std::strncmp(env.c_str(), *env_ptr, env.length()) && (*env_ptr)[env.length()] == '=')
return std::strchr(*env_ptr,'=')+1;
env_ptr++;
}
return "";
}