2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Config.cpp

Committer:
shimniok
Date:
2018-12-03
Revision:
4:de7feb458652
Child:
5:eff573d4ede7

File content as of revision 4:de7feb458652:

#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) {
}