Changed general file descriptors to specific for CDU
Dependents: CDUFinal CDU_Mbed_36
Fork of ConfigFile by
Diff: ConfigFile.cpp
- Revision:
- 5:56d544b8e5c6
- Parent:
- 4:940510a29b44
- Child:
- 6:f6ceafabe9f8
diff -r 940510a29b44 -r 56d544b8e5c6 ConfigFile.cpp --- a/ConfigFile.cpp Sun Sep 12 07:53:10 2010 +0000 +++ b/ConfigFile.cpp Wed Sep 15 12:23:15 2010 +0000 @@ -197,6 +197,36 @@ return true; } +int ConfigFile::getCount() { + int cnt = 0; + for (int i = 0; i < MAXCONFIG; i++) { + config_t *p = configlist[i]; + if (p != NULL) { + cnt++; + } + } + return cnt; +} + +bool ConfigFile::getKeyAndValue(int index, char *key, size_t keybufsiz, char *value, size_t valuebufsiz) { + int cnt = 0; + for (int i = 0; i < MAXCONFIG; i++) { + config_t *p = configlist[i]; + if (p != NULL) { + if (cnt == index) { + if ((strlen(p->key) < keybufsiz) && (strlen(p->value) < valuebufsiz)) { + strcpy(key, p->key); + strcpy(value, p->value); + return true; + } + return false; + } + cnt++; + } + } + return false; +} + bool ConfigFile::read(char *file) { /* * Open the target file.