summaryrefslogtreecommitdiff
path: root/lib/miav_config.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/miav_config.cc')
-rw-r--r--lib/miav_config.cc21
1 files changed, 14 insertions, 7 deletions
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[]) {