LOCKING: must be called with lock taken
| 639 | |
| 640 | // LOCKING: must be called with lock taken |
| 641 | HttpBodyTemplate * |
| 642 | HttpBodyFactory::find_template(const char *set, const char *type, HttpBodySet **body_set_return) |
| 643 | { |
| 644 | Dbg(dbg_ctl_body_factory, "calling find_template(%s,%s)", set, type); |
| 645 | |
| 646 | *body_set_return = nullptr; |
| 647 | |
| 648 | if (table_of_sets == nullptr || !set || !type) { |
| 649 | return nullptr; |
| 650 | } |
| 651 | if (auto it = table_of_sets->find(set); it != table_of_sets->end()) { |
| 652 | HttpBodySet *body_set = static_cast<HttpBodySet *>(it->second); |
| 653 | if (body_set->table_of_pages == nullptr) { |
| 654 | return nullptr; |
| 655 | } |
| 656 | |
| 657 | if (auto it_page = body_set->table_of_pages->find(type); it_page != body_set->table_of_pages->end()) { |
| 658 | HttpBodyTemplate *t = it_page->second; |
| 659 | if ((t == nullptr) || (!t->is_sane())) { |
| 660 | return nullptr; |
| 661 | } |
| 662 | *body_set_return = body_set; |
| 663 | |
| 664 | Dbg(dbg_ctl_body_factory, "find_template(%s,%s) -> (file %s, length %" PRId64 ", lang '%s', charset '%s')", set, type, |
| 665 | t->template_pathname, t->byte_count, body_set->content_language, body_set->content_charset); |
| 666 | |
| 667 | return t; |
| 668 | } |
| 669 | } |
| 670 | Dbg(dbg_ctl_body_factory, "find_template(%s,%s) -> NULL", set, type); |
| 671 | |
| 672 | return nullptr; |
| 673 | } |
| 674 | |
| 675 | // LOCKING: must be called with lock taken |
| 676 | bool |