diff options
author | deva <deva> | 2006-03-07 19:12:18 +0000 |
---|---|---|
committer | deva <deva> | 2006-03-07 19:12:18 +0000 |
commit | 4f84ffc811d93371f395f11a0e0f42000eaa99fc (patch) | |
tree | b562b6c55f2a825dbbc12646df9741b51e1dff79 /lib | |
parent | 1390ddfe6afe41dba141f8170f9b277573ebe8cd (diff) |
*** empty log message ***
Diffstat (limited to 'lib')
-rw-r--r-- | lib/file.cc | 4 | ||||
-rw-r--r-- | lib/info.cc | 10 | ||||
-rw-r--r-- | lib/info.h | 6 | ||||
-rw-r--r-- | lib/miav_config.cc | 21 | ||||
-rw-r--r-- | lib/miav_config.h | 10 |
5 files changed, 39 insertions, 12 deletions
diff --git a/lib/file.cc b/lib/file.cc index 3a59334..6bd8438 100644 --- a/lib/file.cc +++ b/lib/file.cc @@ -81,8 +81,8 @@ File::~File() info->info("[%s]", filelist[cnt].c_str()); } - std::string *trash = config->readString("server_trash"); - std::string *later = config->readString("server_later"); + std::string *trash = MIaV::config->readString("server_trash"); + std::string *later = MIaV::config->readString("server_later"); switch(savestate) { case NO_CHANGE: diff --git a/lib/info.cc b/lib/info.cc index 701a705..a7b5f3e 100644 --- a/lib/info.cc +++ b/lib/info.cc @@ -66,3 +66,13 @@ void Info::log(char *fmt, ...) // End of safezone pthread_mutex_unlock(&mutex); } + + +// For the global info object +void MIaV::initInfo(Info* i) +{ + info = i; +} + +Info *MIaV::info = NULL; + @@ -58,4 +58,10 @@ protected: string log_filename; }; +// For the global info object +namespace MIaV { + void initInfo(Info* info); + extern Info* info; +}; + #endif/*__MIAV_INFO_H__*/ diff --git a/lib/miav_config.cc b/lib/miav_config.cc index adfa5c5..81436cf 100644 --- a/lib/miav_config.cc +++ b/lib/miav_config.cc @@ -26,12 +26,10 @@ */ #include <config.h> #include "miav_config.h" +#include "info.h" -MiavConfig *config; - -MiavConfig::MiavConfig(char *file, Info *i) +MiavConfig::MiavConfig(char *file) { - info = i; configs = NULL; filename = string(file); @@ -40,7 +38,7 @@ MiavConfig::MiavConfig(char *file, Info *i) FILE* fp = fopen(file, "r"); if(!fp) { - if(info) info->error("Error reading configuration file %s\n", file); + if(MIaV::info) MIaV::info->error("Error reading configuration file %s\n", file); else fprintf(stderr, "Error reading configuration file %s\n", file); return; } @@ -76,7 +74,7 @@ MiavConfig::~MiavConfig() */ void MiavConfig::parseError(char* msg, _cfg* cfg) { - if(info) info->error("Error parsing file %s at line %d:\n\t%s\n\t%s\n", + if(MIaV::info) MIaV::info->error("Error parsing file %s at line %d:\n\t%s\n\t%s\n", filename.c_str(), cfg->line, cfg->orig, @@ -462,12 +460,21 @@ _cfg *MiavConfig::findNode(char* node) if(!strcmp(node, cfg->name->c_str())) return cfg; cfg = cfg->next; } - if(info) info->error("Missing line in configuration file: \"%s\"!\n", node); + if(MIaV::info) MIaV::info->error("Missing line in configuration file: \"%s\"!\n", node); else fprintf(stderr, "Missing line in configuration file: \"%s\"!\n", node); return NULL; } +// For the global config object. +void MIaV::initConfig(MiavConfig *c) +{ + config = c; +} + +MiavConfig *MIaV::config = NULL; + + #ifdef __TEST_MIAV_CONFIG int main(int argc, char *argv[]) { diff --git a/lib/miav_config.h b/lib/miav_config.h index a8658f1..c97802d 100644 --- a/lib/miav_config.h +++ b/lib/miav_config.h @@ -64,7 +64,7 @@ typedef struct __cfg { class MiavConfig { public: - MiavConfig(char *file, Info *info = NULL); + MiavConfig(char *file); ~MiavConfig(); int readInt(char *node); @@ -73,7 +73,6 @@ public: float readFloat(char *node); protected: - Info *info; string filename; _cfg *createSemantics(_cfg *cfg); @@ -93,6 +92,11 @@ protected: _cfg *configs; }; -extern MiavConfig *config; + +// For the global config object +namespace MIaV { + void initConfig(MiavConfig *config); + extern MiavConfig *config; +}; #endif/*__MIAV_MIAV_CONFIG_H__*/ |