13 #ifndef __STOUT_OS_RAW_ENVIRONMENT_HPP__ 14 #define __STOUT_OS_RAW_ENVIRONMENT_HPP__ 25 #include <crt_externs.h> 26 #elif !defined(__WINDOWS__) 74 return *_NSGetEnviron();
96 return _NSGetEnviron();
104 #endif // __WINDOWS__ 125 environment(that.environment)
129 that.environment = std::map<std::string, std::string>();
132 template <
typename Map>
138 envp =
new char*[size + 1];
141 for (
auto it = map.begin(); it != map.end(); ++it) {
144 envp[
index] =
new char[entry.size() + 1];
145 ::memcpy(envp[index], entry.c_str(), entry.size() + 1);
149 envp[
index] =
nullptr;
154 size =
object.values.size();
157 envp =
new char*[size + 1];
165 envp[
index] =
new char[entry.size() + 1];
166 ::memcpy(envp[index], entry.c_str(), entry.size() + 1);
170 envp[
index] =
nullptr;
175 if (envp ==
nullptr) {
179 for (
size_t i = 0; i < size; i++) {
185 operator char**()
const 190 operator std::map<std::string, std::string>()
197 Envp& operator=(
const Envp&) =
delete;
201 std::map<std::string, std::string> environment;
207 #endif // __STOUT_OS_RAW_ENVIRONMENT_HPP__
Definition: posix_signalhandler.hpp:23
char *** environmentp()
Definition: environment.hpp:88
Envp(const JSON::Object &object)
Definition: environment.hpp:152
Result< int > index(const std::string &link)
Definition: environment.hpp:119
const T & as() const &
Definition: json.hpp:353
#define foreachpair(KEY, VALUE, ELEMS)
Definition: foreach.hpp:51
Iterable< V > map(F &&f, const Iterable< U, Us... > &input)
Definition: lambda.hpp:46
Envp(const Map &map)
Definition: environment.hpp:133
Envp(Envp &&that)
Definition: environment.hpp:122
std::string stringify(int flags)
std::string value
Definition: json.hpp:84
~Envp()
Definition: environment.hpp:173
char ** environment()
Definition: environment.hpp:66