Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ConfigFile by
Diff: ConfigFile.cpp
- Revision:
- 5:56d544b8e5c6
- Parent:
- 4:940510a29b44
- Child:
- 6:f6ceafabe9f8
--- 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.
