Shinichiro Nakamura
/
ConfigFile_TestProgram
A test program for ConfigFile library.
Diff: main.cpp
- Revision:
- 0:78215cbf31b4
- Child:
- 1:d125bda3cf74
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Sep 12 07:40:20 2010 +0000 @@ -0,0 +1,68 @@ +/** + * Test program for configuration file interface class (Version 0.0.1) + * + * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) + * http://shinta.main.jp/ + */ +#include "mbed.h" + +#include "ConfigFile.h" + +ConfigFile cfg; +LocalFileSystem local("local"); + +/** + * ================================================== + * Input (input.cfg) + * ================================================== + * # + * # Configuration file for mbed. + * # + * + * MyKey1=This is a value for key1. + * MyKey2=Value 2 + * + * Message1 = This is a test message no.1 + * Message2 = This is a test message no.2 + * + * ================================================== + * Output (output.cfg) + * ================================================== + * MyKey1=This is a value for key1. + * MyKey2=Value 2 + * Message1 = This is a test message no.1 + * Message2 = This is a test message no.2 + * + * ================================================== + * Output (console) + * ================================================== + * 'MyKey1'='This is a value for key1.' + * 'MyKey2'='Value 2' + */ +int main() { + + char *key1 = "MyKey1"; + char *key2 = "MyKey2"; + char value[BUFSIZ]; + + /* + * Read a configuration file from a mbed. + */ + cfg.read("/local/input.cfg"); + + /* + * Read a configuration value. + */ + cfg.getValue(key1, &value[0], sizeof(value)); + printf("'%s'='%s'\n", key1, value); + cfg.getValue(key2, &value[0], sizeof(value)); + printf("'%s'='%s'\n", key2, value); + + /* + * Write a configuration file to a mbed. + */ + cfg.write("/local/output.cfg"); + + while (1) { + } +}