![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: Config.cpp
- Revision:
- 4:de7feb458652
- Child:
- 5:eff573d4ede7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config.cpp Mon Dec 03 21:51:14 2018 +0000 @@ -0,0 +1,50 @@ +#include "Config.h" + + +int Config::load(char *filename) +{ + char buf[MAXBUF]; + char *key; + char *value; + int status=0; + FILE *fp; + + fp = fopen(filename, "r"); + if (fp == NULL) { + status = -1; + } else { + while (!feof(fp)) { + fgets(buf, MAXBUF-1, fp); + if (buf[0] != '#') { + key = strtok(buf, ":"); + value = strtok(NULL, ":"); + if (*key && *value) { + printf("<%s>=<%s>\n", key, value); + // look for key + // parse value + // set options + } + } + } + fclose(fp); + }; + + return status; +} + + +/** Attach a setter for each key. The type of the setter's arg will be + * enforced by the parser when the config file is loaded. + */ +void Config::attach(Callback<void(char *)> set, char *key) { +} + + +void Config::attach(Callback<void(int)> set, char *key) { +} + +void Config::attach(Callback<void(float)> set, char *key) { +} + +void Config::attach(Callback<void(double)> set, char *key) { +} \ No newline at end of file