diff --git a/Frameworks/OakSystem/src/process.cc b/Frameworks/OakSystem/src/process.cc index bfeae290..aa12e5a0 100644 --- a/Frameworks/OakSystem/src/process.cc +++ b/Frameworks/OakSystem/src/process.cc @@ -6,58 +6,11 @@ #include #include #include -#include OAK_DEBUG_VAR(Process); namespace oak { - static bool exclude_variable (std::string const& variable) - { - static std::string const BlackListedPrefixes[] = { "TM_", "OAK_", "DIALOG", "MAKE", "MFLAGS" }; - iterate(prefix, BlackListedPrefixes) - { - if(variable.find(*prefix) == 0) - return true; - } - return false; - } - - std::map setup_basic_environment () - { - passwd* entry = path::passwd_entry(); - - int mib[2] = { CTL_USER, USER_CS_PATH }; - size_t len = 0; - sysctl(mib, 2, NULL, &len, NULL, 0); - char* path = new char[len]; - sysctl(mib, 2, path, &len, NULL, 0); - - std::map res; - - char*** envPtr = _NSGetEnviron(); - for(char** pair = *envPtr; pair && *pair; ++pair) - { - char* value = strchr(*pair, '='); - if(value && *value == '=' && !exclude_variable(std::string(*pair, value))) - res[std::string(*pair, value)] = value + 1; - } - - res["HOME"] = entry->pw_dir; - res["PATH"] = path; - res["TMPDIR"] = path::temp(); - res["LOGNAME"] = entry->pw_name; - res["USER"] = entry->pw_name; - - return res; - } - - std::map const& basic_environment () - { - static std::map environment = setup_basic_environment(); - return environment; - } - struct kill_process_group_in_background_t { kill_process_group_in_background_t (pid_t groupId) diff --git a/Frameworks/OakSystem/src/process.h b/Frameworks/OakSystem/src/process.h index 1a67eea1..ddca9f78 100644 --- a/Frameworks/OakSystem/src/process.h +++ b/Frameworks/OakSystem/src/process.h @@ -6,7 +6,6 @@ namespace oak { - PUBLIC std::map const& basic_environment (); PUBLIC void kill_process_group_in_background (pid_t groupId); struct PUBLIC process_t diff --git a/Frameworks/io/src/environment.cc b/Frameworks/io/src/environment.cc new file mode 100644 index 00000000..535baf52 --- /dev/null +++ b/Frameworks/io/src/environment.cc @@ -0,0 +1,54 @@ +#include "environment.h" +#include "path.h" +#include +#include + +namespace oak +{ + static bool exclude_variable (std::string const& variable) + { + static std::string const BlackListedPrefixes[] = { "TM_", "OAK_", "DIALOG", "MAKE", "MFLAGS" }; + iterate(prefix, BlackListedPrefixes) + { + if(variable.find(*prefix) == 0) + return true; + } + return false; + } + + std::map setup_basic_environment () + { + passwd* entry = path::passwd_entry(); + + int mib[2] = { CTL_USER, USER_CS_PATH }; + size_t len = 0; + sysctl(mib, 2, NULL, &len, NULL, 0); + char* path = new char[len]; + sysctl(mib, 2, path, &len, NULL, 0); + + std::map res; + + char*** envPtr = _NSGetEnviron(); + for(char** pair = *envPtr; pair && *pair; ++pair) + { + char* value = strchr(*pair, '='); + if(value && *value == '=' && !exclude_variable(std::string(*pair, value))) + res[std::string(*pair, value)] = value + 1; + } + + res["HOME"] = entry->pw_dir; + res["PATH"] = path; + res["TMPDIR"] = path::temp(); + res["LOGNAME"] = entry->pw_name; + res["USER"] = entry->pw_name; + + return res; + } + + std::map const& basic_environment () + { + static std::map environment = setup_basic_environment(); + return environment; + } + +} /* io */ \ No newline at end of file diff --git a/Frameworks/io/src/environment.h b/Frameworks/io/src/environment.h new file mode 100644 index 00000000..b4199563 --- /dev/null +++ b/Frameworks/io/src/environment.h @@ -0,0 +1,12 @@ +#ifndef IO_ENVIRONMENT_H_P8799509 +#define IO_ENVIRONMENT_H_P8799509 + +#include + +namespace oak +{ + PUBLIC std::map const& basic_environment (); + +} /* io */ + +#endif /* end of include guard: IO_ENVIRONMENT_H_P8799509 */ diff --git a/Frameworks/io/src/io.h b/Frameworks/io/src/io.h index be3e1b83..11041515 100644 --- a/Frameworks/io/src/io.h +++ b/Frameworks/io/src/io.h @@ -6,5 +6,6 @@ #import "swap_file_data.h" #import "socket.h" #import "pipe.h" +#import "environment.h" #endif /* end of include guard: IO_H_VLV818VO */ diff --git a/Frameworks/io/target b/Frameworks/io/target index 00e7e739..3d029bb6 100644 --- a/Frameworks/io/target +++ b/Frameworks/io/target @@ -2,4 +2,4 @@ SOURCES = src/*.cc TEST_SOURCES = tests/* LINK += text cf regexp FRAMEWORKS = Carbon Security -EXPORT = src/io.h src/path.h src/entries.h src/events.h src/intermediate.h src/pipe.h src/move_path.h src/icon.h src/resource.h src/socket.h src/swap_file_data.h +EXPORT = src/*.h diff --git a/Frameworks/network/src/tbz.cc b/Frameworks/network/src/tbz.cc index aef0b9f4..59d3fd67 100644 --- a/Frameworks/network/src/tbz.cc +++ b/Frameworks/network/src/tbz.cc @@ -1,7 +1,7 @@ #include "tbz.h" #include -#include #include +#include namespace network { diff --git a/Frameworks/scm/src/drivers/git.cc b/Frameworks/scm/src/drivers/git.cc index 99fff3e0..29ad4a57 100644 --- a/Frameworks/scm/src/drivers/git.cc +++ b/Frameworks/scm/src/drivers/git.cc @@ -2,7 +2,6 @@ #include "utility.h" #include #include -#include // oak::basic_environment() #include #include #include diff --git a/Frameworks/scm/src/drivers/hg.cc b/Frameworks/scm/src/drivers/hg.cc index d482ab27..9f0797e7 100644 --- a/Frameworks/scm/src/drivers/hg.cc +++ b/Frameworks/scm/src/drivers/hg.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include OAK_DEBUG_VAR(SCM_Hg); diff --git a/Frameworks/settings/src/settings.cc b/Frameworks/settings/src/settings.cc index 7cedc294..9e095609 100644 --- a/Frameworks/settings/src/settings.cc +++ b/Frameworks/settings/src/settings.cc @@ -3,7 +3,6 @@ #include "track_paths.h" #include #include -#include #include #include #include