35# include <sys/types.h>
56 : logger(
"ProfileManager", std::cerr)
94 message =
"Loaded profile: " + filename;
103 message =
"Failed to load profile: " + filename;
115 std::list<std::string> profiles;
125 char *env_profile = getenv(
"PRESAGE_CONFIG");
126 if (env_profile != NULL) {
127 profiles.push_back(env_profile);
137 if (! profilename.empty()) {
138 profiles.push_back(profilename);
144 for (std::list<std::string>::const_iterator it = profiles.begin();
145 it != profiles.end();
169 res = RegOpenKeyExA (HKEY_CURRENT_USER,
"Software\\Presage", 0,
172 if (res == ERROR_SUCCESS)
175 dst = (
char*) malloc (size);
177 res = RegQueryValueExA (reg_key,
"", 0, &type,
178 (LPBYTE) dst, &size);
179 if (res == ERROR_MORE_DATA && type == REG_SZ) {
180 char* tmp_dst = (
char*) realloc (dst, size);
181 if (tmp_dst != NULL) {
186 dst = (
char*) malloc (size);
192 res = RegQueryValueExA (reg_key,
"", 0,
197 if (type != REG_SZ || res != ERROR_SUCCESS)
209 RegCloseKey (reg_key);
225 const char* USERPROFILE =
"USERPROFILE";
226 char* value = getenv(USERPROFILE);
234 struct passwd *my_passwd;
237 my_passwd = getpwuid (me);
241 result = my_passwd->pw_dir;
247 const char*
HOME =
"HOME";
248 char* value = getenv(
HOME);
272 logger << ERROR <<
"Failed to save configuration to profile " <<
endl;
Variable * find(const std::string &variable) const
static const char * DEFAULT_PROFILE_FILENAME
bool loaded_at_least_one_profile
static const char * LOGGER
void set_autopersist(const std::string &value)
void cache_log_message(Logger< char >::Level level, const std::string &message)
Profile * create_profile_from_xml(const std::string &filename)
std::list< CachedLogMessage > cached_log_messages
std::string get_system_etc_dir() const
std::string get_user_home_dir() const
void save_profile() const
static const char * AUTOPERSIST
void flush_cached_log_messages()
ProfileManager(const std::string="")
void init_profiles(const std::string &profilename)
Configuration * get_configuration()
void read_from_configuration(Configuration *configuration)
void read_into_configuration(Configuration *configuration)
bool write_to_file() const
bool file_read_ok() const
static bool isTrue(const char *)
std::string get_value() const
_SetLevel setlevel(std::string __l)
Manipulator for level.
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)