MCPcopy Create free account
hub / github.com/apache/trafficserver / remap_parse_config_bti

Function remap_parse_config_bti

src/proxy/http/remap/RemapConfig.cc:1035–1479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1033}
1034
1035bool
1036remap_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;

Callers 3

parse_remap_fragmentFunction · 0.85
remap_parse_configFunction · 0.85
test_RemapRules.ccFile · 0.85

Calls 15

tokLineFunction · 0.85
remap_check_optionFunction · 0.85
remap_parse_directiveFunction · 0.85
strcasecmpFunction · 0.85
process_filter_optFunction · 0.85
UrlWhackFunction · 0.85
ats_mallocFunction · 0.85
LowerCaseStrFunction · 0.85
ats_is_ipFunction · 0.85
ats_is_ip_anyFunction · 0.85
remap_load_pluginFunction · 0.85

Tested by

no test coverage detected