MCPcopy Create free account
hub / github.com/apache/httpd / cmd_parseflagfield

Function cmd_parseflagfield

modules/mappers/mod_rewrite.c:3441–3494  ·  view source on GitHub ↗

* generic lexer for RewriteRule and RewriteCond flags. * The parser will be passed in as a function pointer * and called if a flag was found */

Source from the content-addressed store, hash-verified

3439 * and called if a flag was found
3440 */
3441static const char *cmd_parseflagfield(apr_pool_t *p, void *cfg, char *key,
3442 const char *(*parse)(apr_pool_t *,
3443 void *,
3444 char *, char *))
3445{
3446 char *val, *nextp, *endp;
3447 const char *err;
3448
3449 endp = key + strlen(key) - 1;
3450 if (*key != '[' || *endp != ']') {
3451 return "bad flag delimiters";
3452 }
3453
3454 *endp = ','; /* for simpler parsing */
3455 ++key;
3456
3457 while (*key) {
3458 /* skip leading spaces */
3459 while (apr_isspace(*key)) {
3460 ++key;
3461 }
3462
3463 if (!*key || (nextp = ap_strchr(key, ',')) == NULL) { /* NULL should not
3464 * happen, but ...
3465 */
3466 break;
3467 }
3468
3469 /* strip trailing spaces */
3470 endp = nextp - 1;
3471 while (apr_isspace(*endp)) {
3472 --endp;
3473 }
3474 *++endp = '\0';
3475
3476 /* split key and val */
3477 val = ap_strchr(key, '=');
3478 if (val) {
3479 *val++ = '\0';
3480 }
3481 else {
3482 val = endp;
3483 }
3484
3485 err = parse(p, cfg, key, val);
3486 if (err) {
3487 return err;
3488 }
3489
3490 key = nextp + 1;
3491 }
3492
3493 return NULL;
3494}
3495
3496static const char *cmd_rewritecond_setflag(apr_pool_t *p, void *_cfg,
3497 char *key, char *val)

Callers 2

cmd_rewritecondFunction · 0.85
cmd_rewriteruleFunction · 0.85

Calls 2

ap_strchrFunction · 0.85
parseFunction · 0.85

Tested by

no test coverage detected