Signed-off by Robin Gilham:
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 2 Dec 2011 08:56:50 +0000 (08:56 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 2 Dec 2011 08:56:50 +0000 (08:56 +0000)
Improvement to the ini file reader to be able to be configured for case
sensitive or case insensitive matches.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5175 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cfg/cfg_ini_reader.h
bertos/mware/ini_reader.c

index d0be4389c550aa1c9dc9eda11ff9bdc5138f01b4..f3dea298700f6900bf43325da011a6ebae48de63 100644 (file)
@@ -45,4 +45,6 @@
  */
 #define CONFIG_INI_MAX_LINE_LEN 64
 
+#define CONFIG_INI_CASE_INSENSITIVE    0
+
 #endif /* CFG_INI_READER_H */
index b49198bbd7795fa1164f25225b076cb17f727478..2f1e3abedd4b6a060ea671ea8a2f5480bfd43c86 100644 (file)
@@ -65,7 +65,11 @@ static int findSection(KFile *fd, const char *section, size_t section_len, char
                        continue;
 
                /* did we find the correct section? */
+#if CONFIG_INI_CASE_INSENSITIVE
+               if(strncasecmp(&line[1], section, section_len))
+#else
                if(strncmp(&line[1], section, section_len))
+#endif
                        continue;
                else
                        return 0;
@@ -127,7 +131,11 @@ static int findKey(KFile *fd, const char *key, char *line, size_t size)
                char curr_key[30];
                getKey(line, curr_key, 30);
                /* check key */
+#if CONFIG_INI_CASE_INSENSITIVE
+               if (!strcasecmp(curr_key, key))
+#else
                if (!strcmp(curr_key, key))
+#endif
                        return 0;
        }
        while (err != EOF && *line != '[');