summaryrefslogtreecommitdiff
path: root/src/miav_config.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/miav_config.cc')
-rw-r--r--src/miav_config.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/miav_config.cc b/src/miav_config.cc
index 9364131..05e0d06 100644
--- a/src/miav_config.cc
+++ b/src/miav_config.cc
@@ -63,8 +63,16 @@ MiavConfig::~MiavConfig()
if(die) free(die);
}
+/**
+ * Adds one configuration entry, from a single zero terminated line.
+ */
_cfg *MiavConfig::addConfig(_cfg *parent, char* conf)
{
+
+ //
+ // FIXME: Check for wellformedness
+ //
+
_cfg *cfg;
printf("[%s]\n", conf);
@@ -97,6 +105,9 @@ _cfg *MiavConfig::addConfig(_cfg *parent, char* conf)
return cfg;
}
+/**
+ * Main parse function, iterates the lines of the file.
+ */
int MiavConfig::parse(char* raw)
{
// Strip the string
@@ -115,13 +126,18 @@ int MiavConfig::parse(char* raw)
start = p+1;
}
}
+ // Allocated in strip
free(conf);
printf("done!\n");
return 0;
}
+/**
+ * Strip all unwanted data from the string, initial to parsing.
+ */
char* MiavConfig::strip(char* conf)
{
+ // Freed in parse!!!
char *stripped = (char*)calloc(strlen(conf) + 2, 1);
char *r;
char *w = stripped;