A demo of the iniparser library. It contains the iniparser library. It's not very memory efficient but it works fine.
main.cpp@0:670712c250da, 2009-12-11 (annotated)
- Committer:
- rolf
- Date:
- Fri Dec 11 15:58:40 2009 +0000
- Revision:
- 0:670712c250da
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rolf | 0:670712c250da | 1 | #include "mbed.h" |
rolf | 0:670712c250da | 2 | #include "iniparser.h" |
rolf | 0:670712c250da | 3 | |
rolf | 0:670712c250da | 4 | /* iniparser - an INI file parser under mit licence. |
rolf | 0:670712c250da | 5 | url: http://ndevilla.free.fr/iniparser/ |
rolf | 0:670712c250da | 6 | doc: http://ndevilla.free.fr/iniparser/html/index.html |
rolf | 0:670712c250da | 7 | */ |
rolf | 0:670712c250da | 8 | |
rolf | 0:670712c250da | 9 | #if 0 // content of foo.txt |
rolf | 0:670712c250da | 10 | [sec1] |
rolf | 0:670712c250da | 11 | foo = bar ; command |
rolf | 0:670712c250da | 12 | quax = 42 |
rolf | 0:670712c250da | 13 | |
rolf | 0:670712c250da | 14 | [sec2] |
rolf | 0:670712c250da | 15 | foo = 0; nope |
rolf | 0:670712c250da | 16 | #endif |
rolf | 0:670712c250da | 17 | |
rolf | 0:670712c250da | 18 | DigitalOut myled(LED1); |
rolf | 0:670712c250da | 19 | LocalFileSystem local("local"); |
rolf | 0:670712c250da | 20 | int main() { |
rolf | 0:670712c250da | 21 | dictionary *dir = iniparser_load("/local/foo.txt"); |
rolf | 0:670712c250da | 22 | printf("sec1: %s\n", iniparser_getstring(dir, "sec1:foo", "default")); |
rolf | 0:670712c250da | 23 | printf("sec2: %d\n", iniparser_getint(dir, "sec2:foo", 42)); |
rolf | 0:670712c250da | 24 | while(1) { |
rolf | 0:670712c250da | 25 | myled = 1; |
rolf | 0:670712c250da | 26 | wait(0.2); |
rolf | 0:670712c250da | 27 | myled = 0; |
rolf | 0:670712c250da | 28 | wait(0.2); |
rolf | 0:670712c250da | 29 | } |
rolf | 0:670712c250da | 30 | } |