| 521 | } |
| 522 | |
| 523 | void parse_lrl_file(const std::string& lrlpath, |
| 524 | std::string* p_dbname, |
| 525 | std::string* p_dbdir, |
| 526 | std::list<std::string>* p_support_files, |
| 527 | std::set<std::string>* p_table_names, |
| 528 | std::set<std::string>* p_queue_names, |
| 529 | bool* p_nonames, |
| 530 | bool* has_cluster_info) |
| 531 | { |
| 532 | /* SSL certificates */ |
| 533 | std::string certdir, cert, key, ca; |
| 534 | |
| 535 | #if HAVE_CRL |
| 536 | std::string crl; |
| 537 | #endif |
| 538 | |
| 539 | // First, load the lrl file into memory. |
| 540 | std::ifstream lrlstream(lrlpath.c_str()); |
| 541 | if(!lrlstream.is_open()) { |
| 542 | throw LRLError(lrlpath, 0, "cannot open file"); |
| 543 | } |
| 544 | int lineno = 0; |
| 545 | while(!lrlstream.eof()) { |
| 546 | std::string line; |
| 547 | std::getline(lrlstream, line); |
| 548 | lineno++; |
| 549 | |
| 550 | // Parse the line that we just read. First strip off comments. |
| 551 | size_t pos = line.find_first_of('#'); |
| 552 | if(pos != std::string::npos) { |
| 553 | line.resize(pos); |
| 554 | } |
| 555 | std::istringstream liness(line); |
| 556 | |
| 557 | std::string tok; |
| 558 | if(liness >> tok) { |
| 559 | |
| 560 | if(tok == "name") { |
| 561 | if(!(liness >> tok)) { |
| 562 | throw LRLError(lrlpath, lineno, "missing database name"); |
| 563 | } |
| 564 | *p_dbname = tok; |
| 565 | |
| 566 | } else if(tok == "dir") { |
| 567 | if(!(liness >> tok)) { |
| 568 | throw LRLError(lrlpath, lineno, "missing database directory"); |
| 569 | } |
| 570 | *p_dbdir = tok; |
| 571 | } else if(tok == "table") { |
| 572 | std::string name; |
| 573 | std::string schema_path; |
| 574 | if(!(liness >> name)) { |
| 575 | throw LRLError(lrlpath, lineno, "missing table name"); |
| 576 | } |
| 577 | if(!(liness >> schema_path)) { |
| 578 | throw LRLError(lrlpath, lineno, "missing table schema path"); |
| 579 | } |
| 580 | p_table_names->insert(name); |
no test coverage detected