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

Function ifsection

server/core.c:2723–2804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2721#define COND_ELSEIF ((void *)3)
2722
2723static const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
2724{
2725 const char *errmsg;
2726 const char *endp = ap_strrchr_c(arg, '>');
2727 int old_overrides = cmd->override;
2728 char *old_path = cmd->path;
2729 core_dir_config *conf;
2730 const command_rec *thiscmd = cmd->cmd;
2731 ap_conf_vector_t *new_if_conf = ap_create_per_dir_config(cmd->pool);
2732 const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
2733 const char *condition;
2734 const char *expr_err;
2735
2736 if (err != NULL) {
2737 return err;
2738 }
2739
2740 if (endp == NULL) {
2741 return unclosed_directive(cmd);
2742 }
2743
2744 arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
2745
2746 /*
2747 * Set a dummy value so that other directives notice that they are inside
2748 * a config section.
2749 */
2750 cmd->path = "*If";
2751 /* Only if not an .htaccess file */
2752 if (!old_path) {
2753 cmd->override = OR_ALL|ACCESS_CONF;
2754 }
2755
2756 /* initialize our config and fetch it */
2757 conf = ap_set_config_vectors(cmd->server, new_if_conf, cmd->path,
2758 &core_module, cmd->pool);
2759
2760 if (cmd->cmd->cmd_data == COND_IF)
2761 conf->condition_ifelse = AP_CONDITION_IF;
2762 else if (cmd->cmd->cmd_data == COND_ELSEIF)
2763 conf->condition_ifelse = AP_CONDITION_ELSEIF;
2764 else if (cmd->cmd->cmd_data == COND_ELSE)
2765 conf->condition_ifelse = AP_CONDITION_ELSE;
2766 else
2767 ap_assert(0);
2768
2769 if (conf->condition_ifelse == AP_CONDITION_ELSE) {
2770 if (arg[0])
2771 return "<Else> does not take an argument";
2772 }
2773 else {
2774 if (!arg[0])
2775 return missing_container_arg(cmd);
2776 condition = ap_getword_conf(cmd->pool, &arg);
2777 conf->condition = ap_expr_parse_cmd(cmd, condition, 0, &expr_err, NULL);
2778 if (expr_err)
2779 return apr_psprintf(cmd->pool, "Cannot parse condition clause: %s",
2780 expr_err);

Callers

nothing calls this directly

Calls 9

ap_strrchr_cFunction · 0.85
ap_create_per_dir_configFunction · 0.85
ap_check_cmd_contextFunction · 0.85
unclosed_directiveFunction · 0.85
ap_set_config_vectorsFunction · 0.85
missing_container_argFunction · 0.85
ap_getword_confFunction · 0.85
ap_walk_configFunction · 0.85
ap_add_if_confFunction · 0.85

Tested by

no test coverage detected