| 749 | } |
| 750 | |
| 751 | static bool ha_path_contains_mode(const char *root, const char *candidate, bool case_insensitive) { |
| 752 | if (!root || !candidate) { |
| 753 | return false; |
| 754 | } |
| 755 | size_t root_len = strlen(root); |
| 756 | size_t candidate_len = strlen(candidate); |
| 757 | if (root_len == 0U || candidate_len < root_len) { |
| 758 | return false; |
| 759 | } |
| 760 | bool prefix = true; |
| 761 | for (size_t i = 0U; i < root_len; i++) { |
| 762 | unsigned char left = (unsigned char)root[i]; |
| 763 | unsigned char right = (unsigned char)candidate[i]; |
| 764 | if (case_insensitive) { |
| 765 | left = (unsigned char)tolower(left); |
| 766 | right = (unsigned char)tolower(right); |
| 767 | } |
| 768 | if (left != right) { |
| 769 | prefix = false; |
| 770 | break; |
| 771 | } |
| 772 | } |
| 773 | return prefix && |
| 774 | (candidate_len == root_len || root[root_len - 1U] == '/' || candidate[root_len] == '/'); |
| 775 | } |
| 776 | |
| 777 | static bool ha_path_contains(const char *root, const char *candidate) { |
| 778 | #ifdef _WIN32 |
no outgoing calls
no test coverage detected