| 826 | } |
| 827 | |
| 828 | static bool ha_path_contains_mode(const char *root, const char *candidate, bool case_insensitive) { |
| 829 | if (!root || !candidate) { |
| 830 | return false; |
| 831 | } |
| 832 | size_t root_len = strlen(root); |
| 833 | size_t candidate_len = strlen(candidate); |
| 834 | if (root_len == 0U || candidate_len < root_len) { |
| 835 | return false; |
| 836 | } |
| 837 | bool prefix = true; |
| 838 | for (size_t i = 0U; i < root_len; i++) { |
| 839 | unsigned char left = (unsigned char)root[i]; |
| 840 | unsigned char right = (unsigned char)candidate[i]; |
| 841 | if (case_insensitive) { |
| 842 | left = (unsigned char)tolower(left); |
| 843 | right = (unsigned char)tolower(right); |
| 844 | } |
| 845 | if (left != right) { |
| 846 | prefix = false; |
| 847 | break; |
| 848 | } |
| 849 | } |
| 850 | return prefix && |
| 851 | (candidate_len == root_len || root[root_len - 1U] == '/' || candidate[root_len] == '/'); |
| 852 | } |
| 853 | |
| 854 | static bool ha_path_contains(const char *root, const char *candidate) { |
| 855 | #ifdef _WIN32 |
no outgoing calls
no test coverage detected