| 121 | } |
| 122 | |
| 123 | bool parseExternalValue(CheckStatusWrapper* status, const string& key, const string& value, string& output) |
| 124 | { |
| 125 | const auto pos = key.rfind('_'); |
| 126 | if (pos == string::npos) |
| 127 | { |
| 128 | output = value.c_str(); |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | string temp; |
| 133 | const string key_source = key.substr(pos + 1); |
| 134 | |
| 135 | if (key_source.equals(KEY_SUFFIX_ENV)) |
| 136 | { |
| 137 | fb_utils::readenv(value.c_str(), temp); |
| 138 | if (temp.isEmpty()) |
| 139 | { |
| 140 | configError(status, "missing environment variable", key, value); |
| 141 | return false; |
| 142 | } |
| 143 | } |
| 144 | else if (key_source.equals(KEY_SUFFIX_FILE)) |
| 145 | { |
| 146 | PathName filename = value.c_str(); |
| 147 | PathUtils::fixupSeparators(filename); |
| 148 | if (PathUtils::isRelative(filename)) |
| 149 | filename = fb_utils::getPrefix(IConfigManager::DIR_CONF, filename.c_str()); |
| 150 | |
| 151 | AutoPtr<FILE> file(os_utils::fopen(filename.c_str(), "rt")); |
| 152 | if (!file) |
| 153 | { |
| 154 | configError(status, "missing or inaccessible file", key, filename.c_str()); |
| 155 | return false; |
| 156 | } |
| 157 | |
| 158 | if (temp.LoadFromFile(file)) |
| 159 | temp.alltrim("\r"); |
| 160 | |
| 161 | if (temp.isEmpty()) |
| 162 | { |
| 163 | configError(status, "first empty line of file", key, filename.c_str()); |
| 164 | return false; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | output = temp.c_str(); |
| 169 | return true; |
| 170 | } |
| 171 | |
| 172 | bool parseSyncReplica(CheckStatusWrapper* status, const ConfigFile::Parameters& params, SyncReplica& output) |
| 173 | { |
no test coverage detected