| 71 | #define ERROR_PREFIX "error while parsing trace configuration\n\t" |
| 72 | |
| 73 | void TraceCfgReader::readConfig() |
| 74 | { |
| 75 | ConfigFile cfgFile(ConfigFile::USE_TEXT, m_text, ConfigFile::HAS_SUB_CONF | ConfigFile::NATIVE_ORDER |
| 76 | | ConfigFile::REGEXP_SUPPORT); |
| 77 | |
| 78 | m_subpatterns[0].start = 0; |
| 79 | m_subpatterns[0].end = m_databaseName.length(); |
| 80 | for (size_t i = 1; i < FB_NELEM(m_subpatterns); i++) |
| 81 | { |
| 82 | m_subpatterns[i].start = -1; |
| 83 | m_subpatterns[i].end = -1; |
| 84 | } |
| 85 | |
| 86 | bool defDB = false, defSvc = false, exactMatch = false; |
| 87 | const ConfigFile::Parameters& params = cfgFile.getParameters(); |
| 88 | for (FB_SIZE_T n = 0; n < params.getCount() && !exactMatch; ++n) |
| 89 | { |
| 90 | const ConfigFile::Parameter* section = ¶ms[n]; |
| 91 | |
| 92 | const bool isDatabase = (section->name == "database"); |
| 93 | if (!isDatabase && section->name != "services") |
| 94 | //continue; |
| 95 | fatal_exception::raiseFmt(ERROR_PREFIX |
| 96 | "line %d: wrong section header, \"database\" or \"service\" is expected", |
| 97 | section->line); |
| 98 | |
| 99 | const ConfigFile::String pattern = section->value; |
| 100 | bool match = false; |
| 101 | if (pattern.empty()) |
| 102 | { |
| 103 | if (isDatabase) |
| 104 | { |
| 105 | if (defDB) |
| 106 | { |
| 107 | fatal_exception::raiseFmt(ERROR_PREFIX |
| 108 | "line %d: second default database section is not allowed", |
| 109 | section->line); |
| 110 | } |
| 111 | |
| 112 | match = !m_databaseName.empty(); |
| 113 | //match = m_databaseName.empty(); |
| 114 | defDB = true; |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | if (defSvc) |
| 119 | { |
| 120 | fatal_exception::raiseFmt(ERROR_PREFIX |
| 121 | "line %d: second default service section is not allowed", |
| 122 | section->line); |
| 123 | } |
| 124 | match = m_databaseName.empty(); |
| 125 | defSvc = true; |
| 126 | } |
| 127 | } |
| 128 | else if (isDatabase && !m_databaseName.empty()) |
| 129 | { |
| 130 | PathName noQuotePattern = pattern.ToPathName(); |
no test coverage detected