From: batt Date: Fri, 2 Dec 2011 08:56:50 +0000 (+0000) Subject: Signed-off by Robin Gilham: X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=1265029d73dae859ad9dc37fb41b908338c7cff8;p=bertos.git Signed-off by Robin Gilham: 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 --- diff --git a/bertos/cfg/cfg_ini_reader.h b/bertos/cfg/cfg_ini_reader.h index d0be4389..f3dea298 100644 --- a/bertos/cfg/cfg_ini_reader.h +++ b/bertos/cfg/cfg_ini_reader.h @@ -45,4 +45,6 @@ */ #define CONFIG_INI_MAX_LINE_LEN 64 +#define CONFIG_INI_CASE_INSENSITIVE 0 + #endif /* CFG_INI_READER_H */ diff --git a/bertos/mware/ini_reader.c b/bertos/mware/ini_reader.c index b49198bb..2f1e3abe 100644 --- a/bertos/mware/ini_reader.c +++ b/bertos/mware/ini_reader.c @@ -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 != '[');