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:
- 1:f02e081afe42
- Parent:
- 0:6b4ba48753b9
- Child:
- 2:d8febae84a45
diff -r 6b4ba48753b9 -r f02e081afe42 ConfigFile.cpp
--- a/ConfigFile.cpp	Sun Sep 12 07:11:54 2010 +0000
+++ b/ConfigFile.cpp	Sun Sep 12 07:22:00 2010 +0000
@@ -31,12 +31,12 @@
     configlist = NULL;
 }
 
-char *ConfigFile::getValue(char *key) {
+bool ConfigFile::getValue(char *key, char *value, size_t siz) {
     /*
      * Null check.
      */
     if (key == NULL) {
-        return NULL;
+        return false;
     }
 
     /*
@@ -44,13 +44,21 @@
      */
     config_t *p = search(key);
     if (p == NULL) {
-        return NULL;
+        return false;
+    }
+    
+    /*
+     * Check the storage size.
+     */
+    if (siz <= strlen(p->value)) {
+        return false;
     }
 
     /*
-     * Return the value.
+     * Copy the value to the storage.
      */
-    return p->value;
+    strcpy(value, p->value);
+    return true;
 }
 
 bool ConfigFile::setValue(char *key, char *value) {
    