Implementation of -style conditional sections. Callback * to test condition must be in cmd->info, matching function type * test_cond_section_fn. */
| 2855 | * to test condition must be in cmd->info, matching function type |
| 2856 | * test_cond_section_fn. */ |
| 2857 | static const char *start_cond_section(cmd_parms *cmd, void *mconfig, const char *arg) |
| 2858 | { |
| 2859 | const char *endp = ap_strrchr_c(arg, '>'); |
| 2860 | int result, not = (arg[0] == '!'); |
| 2861 | test_cond_section_fn testfn = (test_cond_section_fn)cmd->info; |
| 2862 | const char *arg1; |
| 2863 | |
| 2864 | if (endp == NULL) { |
| 2865 | return unclosed_directive(cmd); |
| 2866 | } |
| 2867 | |
| 2868 | arg = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg); |
| 2869 | |
| 2870 | if (not) { |
| 2871 | arg++; |
| 2872 | } |
| 2873 | |
| 2874 | arg1 = ap_getword_conf(cmd->temp_pool, &arg); |
| 2875 | |
| 2876 | if (!arg1[0]) { |
| 2877 | return missing_container_arg(cmd); |
| 2878 | } |
| 2879 | |
| 2880 | result = testfn(cmd, arg1); |
| 2881 | |
| 2882 | if ((!not && result) || (not && !result)) { |
| 2883 | ap_directive_t *parent = NULL; |
| 2884 | ap_directive_t *current = NULL; |
| 2885 | const char *retval; |
| 2886 | |
| 2887 | retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd, |
| 2888 | ¤t, &parent, (char *)cmd->cmd->name); |
| 2889 | *(ap_directive_t **)mconfig = current; |
| 2890 | return retval; |
| 2891 | } |
| 2892 | else { |
| 2893 | *(ap_directive_t **)mconfig = NULL; |
| 2894 | return ap_soak_end_container(cmd, (char *)cmd->cmd->name); |
| 2895 | } |
| 2896 | } |
| 2897 | |
| 2898 | /* Callback to implement <IfModule> test for start_cond_section. */ |
| 2899 | static int test_ifmod_section(cmd_parms *cmd, const char *arg) |
nothing calls this directly
no test coverage detected