A demo of the iniparser library. It contains the iniparser library. It's not very memory efficient but it works fine.

Dependencies:   mbed

main.cpp

Committer:
rolf
Date:
2009-12-11
Revision:
0:670712c250da

File content as of revision 0:670712c250da:

#include "mbed.h"
#include "iniparser.h"

/* iniparser - an INI file parser under mit licence.
   url: http://ndevilla.free.fr/iniparser/
   doc: http://ndevilla.free.fr/iniparser/html/index.html
*/

#if 0 // content of foo.txt
[sec1]
foo = bar ; command
quax = 42

[sec2]
foo = 0; nope
#endif

DigitalOut myled(LED1);
LocalFileSystem local("local");
int main() {
    dictionary *dir = iniparser_load("/local/foo.txt");
    printf("sec1: %s\n", iniparser_getstring(dir, "sec1:foo", "default"));
    printf("sec2: %d\n", iniparser_getint(dir, "sec2:foo", 42));
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}