| 1033 | } |
| 1034 | |
| 1035 | bool |
| 1036 | remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti) |
| 1037 | { |
| 1038 | char errBuf[1024]; |
| 1039 | char errStrBuf[1024]; |
| 1040 | const char *errStr; |
| 1041 | |
| 1042 | Tokenizer whiteTok(" \t"); |
| 1043 | |
| 1044 | // Vars to parse line in file |
| 1045 | char *tok_state, *cur_line, *cur_line_tmp; |
| 1046 | int rparse, cur_line_size, cln = 0; // Our current line number |
| 1047 | |
| 1048 | // Vars to build the mapping |
| 1049 | const char *fromScheme, *toScheme; |
| 1050 | int fromSchemeLen, toSchemeLen; |
| 1051 | const char *fromHost, *toHost; |
| 1052 | int fromHostLen, toHostLen; |
| 1053 | char *map_from, *map_from_start; |
| 1054 | char *map_to, *map_to_start; |
| 1055 | const char *tmp; // Appease the DEC compiler |
| 1056 | char *fromHost_lower = nullptr; |
| 1057 | char *fromHost_lower_ptr = nullptr; |
| 1058 | char fromHost_lower_buf[1024]; |
| 1059 | url_mapping *new_mapping = nullptr; |
| 1060 | mapping_type maptype; |
| 1061 | referer_info *ri; |
| 1062 | int origLength; |
| 1063 | int length; |
| 1064 | int tok_count; |
| 1065 | |
| 1066 | UrlRewrite::RegexMapping *reg_map; |
| 1067 | bool is_cur_mapping_regex; |
| 1068 | const char *type_id_str; |
| 1069 | |
| 1070 | std::error_code ec; |
| 1071 | std::string content{swoc::file::load(swoc::file::path{path}, ec)}; |
| 1072 | if (ec.value() == ENOENT) { // a missing file is ok - treat as empty, no rules. |
| 1073 | return true; |
| 1074 | } |
| 1075 | if (ec.value()) { |
| 1076 | Warning("Failed to open remapping configuration file %s - %s", path, strerror(ec.value())); |
| 1077 | return false; |
| 1078 | } |
| 1079 | |
| 1080 | Dbg(dbg_ctl_url_rewrite, "[BuildTable] UrlRewrite::BuildTable()"); |
| 1081 | |
| 1082 | ACLBehaviorPolicy behavior_policy = ACLBehaviorPolicy::ACL_BEHAVIOR_LEGACY; |
| 1083 | if (!UrlRewrite::get_acl_behavior_policy(behavior_policy)) { |
| 1084 | Warning("Failed to get ACL matching policy."); |
| 1085 | return false; |
| 1086 | } |
| 1087 | bti->behavior_policy = behavior_policy; |
| 1088 | |
| 1089 | for (cur_line = tokLine(content.data(), &tok_state, '\\'); cur_line != nullptr;) { |
| 1090 | reg_map = nullptr; |
| 1091 | new_mapping = nullptr; |
| 1092 | errStrBuf[0] = 0; |
no test coverage detected