| 186 | // |
| 187 | template <class Data, class MatchResult> |
| 188 | Result |
| 189 | HostMatcher<Data, MatchResult>::NewEntry(matcher_line *line_info) |
| 190 | { |
| 191 | Data *cur_d; |
| 192 | Result error = Result::ok(); |
| 193 | char *match_data; |
| 194 | |
| 195 | // Make sure space has been allocated |
| 196 | ink_assert(num_el >= 0); |
| 197 | ink_assert(array_len >= 0); |
| 198 | |
| 199 | // Make sure we do not overrun the array; |
| 200 | ink_assert(num_el < array_len); |
| 201 | |
| 202 | match_data = line_info->line[1][line_info->dest_entry]; |
| 203 | |
| 204 | // Make sure that the line_info is not bogus |
| 205 | ink_assert(line_info->dest_entry < MATCHER_MAX_TOKENS); |
| 206 | ink_assert(match_data != nullptr); |
| 207 | |
| 208 | // Remove our consumed label from the parsed line |
| 209 | line_info->line[0][line_info->dest_entry] = nullptr; |
| 210 | line_info->num_el--; |
| 211 | |
| 212 | // Fill in the parameter info |
| 213 | cur_d = data_array + num_el; |
| 214 | error = cur_d->Init(line_info); |
| 215 | if (error.failed()) { |
| 216 | // There was a problem so undo the effects this function |
| 217 | new (cur_d) Data(); // reconstruct |
| 218 | } else { |
| 219 | // Fill in the matching info |
| 220 | host_lookup->NewEntry(match_data, (line_info->type == MATCH_DOMAIN) ? true : false, cur_d); |
| 221 | num_el++; |
| 222 | } |
| 223 | |
| 224 | return error; |
| 225 | } |
| 226 | |
| 227 | /************************************************************* |
| 228 | * End class HostMatcher |