A simple .ini file interface.

Dependents:   Smart-WiFly-WebServer SignalGenerator WattEye X10Svr

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Wed Apr 11 00:28:03 2018 +0000
Parent:
23:18b5f3d7ef14
Child:
25:1362b843de86
Commit message:
Add a method to write long integers to the ini file.

Changed in this revision

IniManager.cpp Show annotated file Show diff for this revision Revisions of this file
IniManager.h Show annotated file Show diff for this revision Revisions of this file
--- a/IniManager.cpp	Sat Mar 31 23:36:47 2018 +0000
+++ b/IniManager.cpp	Wed Apr 11 00:28:03 2018 +0000
@@ -313,6 +313,14 @@
     return true;
 }
 
+INI::INI_Return INI::WriteLongInt(const char * section, const char * key, long int value)
+{
+    char buf[20];
+    snprintf(buf, 20, "%ld", value);
+    return WriteString(section, key, buf);
+}
+
+
 // Create the new version as .new
 // once complete, if something actually changed, then rename the .ini to .bak and rename the .new to .ini
 // once complete, if nothing actually changed, then delete the .new
--- a/IniManager.h	Sat Mar 31 23:36:47 2018 +0000
+++ b/IniManager.h	Wed Apr 11 00:28:03 2018 +0000
@@ -172,7 +172,7 @@
     * @param[in] len is the number of characters to write, if specified. If not specified,
     *       the length of the buffer defines the length to write.
     *
-    * @return INI_SUCCESS if the file, section, key, and value are found, and it fits into the specified buffer.
+    * @return INI_SUCCESS if the file, section, key, and value are written.
     * @return INI_NO_FILE_SPEC if the ini file was never set.
     * @return INI_FILE_NOT_FOUND if the ini file was specified, but cannot be found as specified.
     * @return INI_SECTION_NOT_FOUND if the section was not found.
@@ -182,6 +182,23 @@
     INI_Return WriteString(const char * section, const char * key, const char * buffer, int len = -1);
 
 
+    /** Writes a long integer into the ini file
+    *
+    * This writes a given long integer into an ini file in the named section and key.
+    * 
+    * @param[in] section is the name of the section to search.
+    * @param[in] key is the name of the key to search.
+    * @param[in] value is the long integer.
+    *
+    * @return INI_SUCCESS if the file, section, key, and value are written.
+    * @return INI_NO_FILE_SPEC if the ini file was never set.
+    * @return INI_FILE_NOT_FOUND if the ini file was specified, but cannot be found as specified.
+    * @return INI_SECTION_NOT_FOUND if the section was not found.
+    * @return INI_KEY_NOT_FOUND if the key was not found.
+    * @return INI_BUF_TOO_SMALL if everything was found, but it could not fit into the specified buffer.
+    */
+    INI_Return WriteLongInt(const char * section, const char * key, long int value);
+
     /** Get Section, or Next Section name
     *
     * This can be used to walk the list of section names in a file.