MCPcopy Create free account
hub / github.com/apache/trafficserver / Parse

Method Parse

plugins/compress/configuration.cc:294–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294Configuration *
295Configuration::Parse(const char *path)
296{
297 string pathstring(path);
298
299 // If we have a path and it's not an absolute path, make it relative to the
300 // configuration directory.
301 if (!pathstring.empty() && pathstring[0] != '/') {
302 pathstring.assign(TSConfigDirGet());
303 pathstring.append("/");
304 pathstring.append(path);
305 }
306
307 trim_if(pathstring, isspace);
308
309 Configuration *c = new Configuration();
310 HostConfiguration *current_host_configuration = new HostConfiguration("");
311
312 c->add_host_configuration(current_host_configuration);
313
314 if (pathstring.empty()) {
315 return c;
316 }
317
318 path = pathstring.c_str();
319 info("Parsing file \"%s\"", path);
320 std::ifstream f;
321
322 size_t lineno = 0;
323
324 f.open(path, std::ios::in);
325
326 if (!f.is_open()) {
327 warning("could not open file [%s], skip", path);
328 return c;
329 }
330
331 enum ParserState state = kParseStart;
332
333 while (!f.eof()) {
334 std::string line;
335 getline(f, line);
336 ++lineno;
337
338 trim_if(line, isspace);
339 if (line.empty()) {
340 continue;
341 }
342
343 for (;;) {
344 string token = extractFirstToken(line, isspace);
345
346 if (token.empty()) {
347 break;
348 }
349
350 // once a comment is encountered, we are done processing the line
351 if (token[0] == '#') {

Callers

nothing calls this directly

Calls 15

TSConfigDirGetFunction · 0.85
trim_ifFunction · 0.85
extractFirstTokenFunction · 0.85
eofMethod · 0.80
update_defaultsMethod · 0.80
set_cacheMethod · 0.80
set_range_requestMethod · 0.80

Tested by

no test coverage detected