</usage>
</directivesynopsis>
+<directivesynopsis type="section">
+<name>IfFile</name>
+<description>Encloses directives that will be processed only
+if file exists at startup</description>
+<syntax><IfFile [!]<var>parameter-name</var>> ...
+ </IfFile></syntax>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context><context>.htaccess</context>
+</contextlist>
+
+<usage>
+ <p>The <code><IfFile <var>filename</var>>...</IfFile>
+ </code> section is used to mark directives that are conditional on
+ the existence of a file on disk. The directives within an
+ <directive type="section">IfFile</directive> section are only
+ processed if the <var>filename</var> exists. If <var> filename</var>
+ doesn't exist, everything between the start and end markers is
+ ignored. <var>filename</var> can be an absolute path or a path
+ relative to the server root.</p>
+
+ <p>The <var>filename</var> in the <directive type="section">IfFile
+ </directive> section directive can take the same forms as the
+ <var>test</var> variable in the <directive type="section">IfDefine
+ </directive> section, i.e. the test can be negated if the <code>
+ !</code> character is placed directly before <var>filename</var>.
+ </p>
+
+ <p>If a relative <var>filename</var> is supplied, the check is
+ <directive>ServerRoot</directive> relative. In the case where
+ this directive occurs before the <directive>ServerRoot</directive>,
+ the path will be checked relative to the compiled-in server root or
+ the server root passed in on the command line via the <code>-d</code>
+ parameter.</p>
+
+</usage>
+</directivesynopsis>
+
<directivesynopsis type="section">
<name>IfModule</name>
<description>Encloses directives that are processed conditional on the
}
}
+static const char *start_iffile(cmd_parms *cmd, void *dummy, const char *arg)
+{
+ apr_finfo_t sb;
+ const char *endp;
+ int file_exists = 0;
+ int not = 0;
+ const char *relative;
+
+ endp = ap_strrchr_c(arg, '>');
+ if (endp == NULL) {
+ return unclosed_directive(cmd);
+ }
+
+ arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
+
+ if (arg[0] == '!') {
+ not = 1;
+ arg++;
+ }
+
+ if (!arg[0]) {
+ return missing_container_arg(cmd);
+ }
+
+ relative = ap_server_root_relative(cmd->temp_pool, arg);
+ file_exists = (apr_stat(&sb, relative, 0, cmd->pool) == APR_SUCCESS);
+
+ if ((!not && file_exists) || (not && !file_exists)) {
+ ap_directive_t *parent = NULL;
+ ap_directive_t *current = NULL;
+ const char *retval;
+
+ retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
+ ¤t, &parent, "<IfFile");
+ *(ap_directive_t **)dummy = current;
+ return retval;
+ }
+ else {
+ *(ap_directive_t **)dummy = NULL;
+ return ap_soak_end_container(cmd, "<IfFile");
+ }
+}
+
/* httpd.conf commands... beginning with the <VirtualHost> business */
static const char *virtualhost_section(cmd_parms *cmd, void *dummy,
"Container for directives based on existence of specified modules"),
AP_INIT_TAKE1("<IfDefine", start_ifdefine, NULL, EXEC_ON_READ | OR_ALL,
"Container for directives based on existence of command line defines"),
+AP_INIT_TAKE1("<IfFile", start_iffile, NULL, EXEC_ON_READ | OR_ALL,
+ "Container for directives based on existence of files on disk"),
AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
"Container for directives affecting resources located in the "
"specified directories"),