* A format string consists of white space, text and optional format * tags in any order. E.g., * * Header add MyHeader "Free form text %D %t more text" * * Decompose the format string into its tags. Each tag (struct format_tag) * contains a pointer to the function used to format the tag. Then save each * tag in the tag array anchored in the header_entry. */
| 380 | * tag in the tag array anchored in the header_entry. |
| 381 | */ |
| 382 | static char *parse_format_string(cmd_parms *cmd, header_entry *hdr, const char *s) |
| 383 | { |
| 384 | apr_pool_t *p = cmd->pool; |
| 385 | char *res; |
| 386 | |
| 387 | /* No string to parse with unset and echo commands */ |
| 388 | if (hdr->action == hdr_unset || hdr->action == hdr_echo) { |
| 389 | return NULL; |
| 390 | } |
| 391 | /* Tags are in the replacement value for edit */ |
| 392 | else if (hdr->action == hdr_edit || hdr->action == hdr_edit_r ) { |
| 393 | s = hdr->subs; |
| 394 | } |
| 395 | |
| 396 | if (!strncmp(s, "expr=", 5)) { |
| 397 | const char *err; |
| 398 | hdr->expr_out = ap_expr_parse_cmd(cmd, s+5, |
| 399 | AP_EXPR_FLAG_STRING_RESULT, |
| 400 | &err, NULL); |
| 401 | if (err) { |
| 402 | return apr_pstrcat(cmd->pool, |
| 403 | "Can't parse value expression : ", err, NULL); |
| 404 | } |
| 405 | return NULL; |
| 406 | } |
| 407 | |
| 408 | hdr->ta = apr_array_make(p, 10, sizeof(format_tag)); |
| 409 | |
| 410 | while (*s) { |
| 411 | if ((res = parse_format_tag(p, (format_tag *) apr_array_push(hdr->ta), &s))) { |
| 412 | return res; |
| 413 | } |
| 414 | } |
| 415 | return NULL; |
| 416 | } |
| 417 | |
| 418 | /* handle RequestHeader and Header directive */ |
| 419 | static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd, |
no test coverage detected