|
a/src/httpfs.cxx |
|
b/src/httpfs.cxx |
|
... |
|
... |
204 |
* We strip white-space from beginning/ends of lines, and allow
|
204 |
* We strip white-space from beginning/ends of lines, and allow
|
205 |
* #-started comments (on a line alone only, comments after data not allowed).
|
205 |
* #-started comments (on a line alone only, comments after data not allowed).
|
206 |
*/
|
206 |
*/
|
207 |
static bool read_protocolinfo(const string& fn, bool enableL16, string& out)
|
207 |
static bool read_protocolinfo(const string& fn, bool enableL16, string& out)
|
208 |
{
|
208 |
{
|
|
|
209 |
LOGDEB1("read_protocolinfo: fn " << fn << "\n");
|
209 |
ifstream input;
|
210 |
ifstream input;
|
210 |
input.open(fn, ios::in);
|
211 |
input.open(fn, ios::in);
|
211 |
if (!input.is_open()) {
|
212 |
if (!input.is_open()) {
|
|
|
213 |
LOGERR("read_protocolinfo: open failed: " << fn << "\n");
|
212 |
return false;
|
214 |
return false;
|
213 |
}
|
215 |
}
|
214 |
bool eof = false;
|
216 |
bool eof = false;
|
215 |
for (;;) {
|
217 |
for (;;) {
|
216 |
string line;
|
218 |
string line;
|
217 |
getline(input, line);
|
219 |
getline(input, line);
|
218 |
if (!input.good()) {
|
220 |
if (!input.good()) {
|
219 |
if (input.bad()) {
|
221 |
if (input.bad()) {
|
|
|
222 |
LOGERR("read_protocolinfo: read error: " << fn << "\n");
|
220 |
return false;
|
223 |
return false;
|
221 |
}
|
224 |
}
|
222 |
// Must be eof ? But maybe we have a partial line which
|
225 |
// Must be eof ? But maybe we have a partial line which
|
223 |
// must be processed. This happens if the last line before
|
226 |
// must be processed. This happens if the last line before
|
224 |
// eof ends with a backslash, or there is no final \n
|
227 |
// eof ends with a backslash, or there is no final \n
|
225 |
eof = true;
|
228 |
eof = true;
|
226 |
}
|
229 |
}
|
227 |
trimstring(line, " \t\n\r,");
|
230 |
trimstring(line, " \t\n\r,");
|
228 |
line += ',';
|
231 |
if (!line.empty()) {
|
229 |
if (enableL16 && line[0] == '@') {
|
232 |
if (enableL16 && line[0] == '@') {
|
230 |
line = regsub1("@ENABLEL16@", line, "");
|
233 |
line = regsub1("@ENABLEL16@", line, "");
|
231 |
} else {
|
234 |
} else {
|
232 |
line = regsub1("@ENABLEL16@", line, "#");
|
235 |
line = regsub1("@ENABLEL16@", line, "#");
|
233 |
}
|
236 |
}
|
234 |
if (line[0] == '#')
|
237 |
if (line[0] == '#')
|
235 |
continue;
|
238 |
continue;
|
|
|
239 |
|
236 |
out += line;
|
240 |
out += line + ',';
|
|
|
241 |
}
|
237 |
if (eof)
|
242 |
if (eof)
|
238 |
break;
|
243 |
break;
|
239 |
}
|
244 |
}
|
|
|
245 |
trimstring(out, ",");
|
|
|
246 |
LOGDEB0("read_protocolinfo data: [" << out << "]\n");
|
240 |
return true;
|
247 |
return true;
|
241 |
}
|
248 |
}
|
242 |
|
249 |
|
243 |
|
250 |
|
244 |
// Read and setup our (mostly XML) data to make it available from the
|
251 |
// Read and setup our (mostly XML) data to make it available from the
|