MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / parseExternalValue

Function parseExternalValue

src/jrd/replication/Config.cpp:123–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

parseSyncReplicaFunction · 0.85

Calls 11

readenvFunction · 0.85
configErrorFunction · 0.85
getPrefixFunction · 0.85
equalsMethod · 0.80
LoadFromFileMethod · 0.80
alltrimMethod · 0.80
fopenFunction · 0.50
rfindMethod · 0.45
c_strMethod · 0.45
substrMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected