diff options
Diffstat (limited to 'ndb/src/common/mgmcommon/InitConfigFileParser.cpp')
-rw-r--r-- | ndb/src/common/mgmcommon/InitConfigFileParser.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp index d52bc54db52..7c842508491 100644 --- a/ndb/src/common/mgmcommon/InitConfigFileParser.cpp +++ b/ndb/src/common/mgmcommon/InitConfigFileParser.cpp @@ -43,10 +43,10 @@ InitConfigFileParser::~InitConfigFileParser() { // Read Config File //**************************************************************************** InitConfigFileParser::Context::Context(const ConfigInfo * info) - : m_configValues(1000, 20) { + : m_configValues(1000, 20), m_userProperties(true) { - m_config = new Properties(); - m_defaults = new Properties(); + m_config = new Properties(true); + m_defaults = new Properties(true); } InitConfigFileParser::Context::~Context(){ @@ -115,7 +115,7 @@ InitConfigFileParser::parseConfig(FILE * file) { snprintf(ctx.fname, sizeof(ctx.fname), section); free(section); ctx.type = InitConfigFileParser::DefaultSection; ctx.m_sectionLineno = ctx.m_lineno; - ctx.m_currentSection = new Properties(); + ctx.m_currentSection = new Properties(true); ctx.m_userDefaults = NULL; ctx.m_currentInfo = m_info->getInfo(ctx.fname); ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); @@ -137,7 +137,7 @@ InitConfigFileParser::parseConfig(FILE * file) { free(section); ctx.type = InitConfigFileParser::Section; ctx.m_sectionLineno = ctx.m_lineno; - ctx.m_currentSection = new Properties(); + ctx.m_currentSection = new Properties(true); ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); ctx.m_currentInfo = m_info->getInfo(ctx.fname); ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); @@ -222,6 +222,8 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { char tmpLine[MAX_LINE_LENGTH]; char fname[MAX_LINE_LENGTH], rest[MAX_LINE_LENGTH]; char* t; + const char *separator_list[]= {":", "=", 0}; + const char *separator= 0; if (ctx.m_currentSection == NULL){ ctx.reportError("Value specified outside section"); @@ -233,7 +235,14 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { // ************************************* // Check if a separator exists in line // ************************************* - if (!strchr(tmpLine, ':')) { + for(int i= 0; separator_list[i] != 0; i++) { + if(strchr(tmpLine, separator_list[i][0])) { + separator= separator_list[i]; + break; + } + } + + if (separator == 0) { ctx.reportError("Parse error"); return false; } @@ -241,13 +250,13 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { // ******************************************* // Get pointer to substring before separator // ******************************************* - t = strtok(tmpLine, ":"); + t = strtok(tmpLine, separator); // ***************************************** // Count number of tokens before separator // ***************************************** if (sscanf(t, "%120s%120s", fname, rest) != 1) { - ctx.reportError("Multiple names before \':\'"); + ctx.reportError("Multiple names before \'%c\'", separator[0]); return false; } if (!ctx.m_currentInfo->contains(fname)) { @@ -475,8 +484,24 @@ InitConfigFileParser::parseSectionHeader(const char* line) const { tmp[0] = ' '; trim(tmp); + // Convert section header to upper + for(int i= strlen(tmp)-1; i >= 0; i--) + tmp[i]= toupper(tmp[i]); + + // Get the correct header name if an alias + { + const char *tmp_alias= m_info->getAlias(tmp); + if (tmp_alias) { + free(tmp); + tmp= strdup(tmp_alias); + } + } + // Lookup token among sections - if(!m_info->isSection(tmp)) return NULL; + if(!m_info->isSection(tmp)) { + free(tmp); + return NULL; + } if(m_info->getInfo(tmp)) return tmp; free(tmp); @@ -497,7 +522,7 @@ InitConfigFileParser::parseDefaultSectionHeader(const char* line) const { if (no != 2) return NULL; // Not correct keyword at end - if (!strcmp(token2, "DEFAULT") == 0) return NULL; + if (!strcasecmp(token2, "DEFAULT") == 0) return NULL; if(m_info->getInfo(token1)){ return strdup(token1); |