| 265 | -------------------------------------------------------------------------*/ |
| 266 | |
| 267 | LogFormat * |
| 268 | LogFormat::format_from_specification(char *spec, char **file_name, char **file_header, LogFileFormat *file_type) |
| 269 | { |
| 270 | LogFormat *format; |
| 271 | char *token; |
| 272 | int format_id; |
| 273 | char *format_name, *format_str; |
| 274 | |
| 275 | ink_assert(file_name != nullptr); |
| 276 | ink_assert(file_header != nullptr); |
| 277 | ink_assert(file_type != nullptr); |
| 278 | |
| 279 | SimpleTokenizer tok(spec, ':'); |
| 280 | |
| 281 | // |
| 282 | // Divide the specification string into tokens using the ':' as a |
| 283 | // field separator. There are currently eight (8) tokens that comprise |
| 284 | // a format specification. Verify each of the token values and if |
| 285 | // everything looks ok, then build the LogFormat object. |
| 286 | // |
| 287 | // First should be the "format" keyword that says this is a format spec. |
| 288 | // |
| 289 | token = tok.getNext(); |
| 290 | if (token == nullptr) { |
| 291 | Dbg(dbg_ctl_log_format, "token expected"); |
| 292 | return nullptr; |
| 293 | } |
| 294 | if (strcasecmp(token, "format") == 0) { |
| 295 | Dbg(dbg_ctl_log_format, "this is a format"); |
| 296 | } else { |
| 297 | Dbg(dbg_ctl_log_format, "should be 'format'"); |
| 298 | return nullptr; |
| 299 | } |
| 300 | |
| 301 | // |
| 302 | // Next should be the word "enabled" or "disabled", which indicates |
| 303 | // whether we should care about this format or not. |
| 304 | // |
| 305 | token = tok.getNext(); |
| 306 | if (token == nullptr) { |
| 307 | Dbg(dbg_ctl_log_format, "token expected"); |
| 308 | return nullptr; |
| 309 | } |
| 310 | if (!strcasecmp(token, "disabled")) { |
| 311 | Dbg(dbg_ctl_log_format, "format not enabled, skipping ..."); |
| 312 | return nullptr; |
| 313 | } else if (!strcasecmp(token, "enabled")) { |
| 314 | Dbg(dbg_ctl_log_format, "enabled format"); |
| 315 | } else { |
| 316 | Dbg(dbg_ctl_log_format, "should be 'enabled' or 'disabled', not %s", token); |
| 317 | return nullptr; |
| 318 | } |
| 319 | |
| 320 | // |
| 321 | // Next should be the numeric format identifier |
| 322 | // |
| 323 | token = tok.getNext(); |
| 324 | if (token == nullptr) { |
nothing calls this directly
no test coverage detected