Changed general file descriptors to specific for CDU

Dependents:   CDUFinal CDU_Mbed_36

Fork of ConfigFile by Shinichiro Nakamura

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) {