From 8c92d2353e7df8b0d32de363739cf845cc087a01 Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Fri, 7 Jul 2000 07:58:14 +0000 Subject: [PATCH] turn dav/fs/ into a real module move the DAVLockDB directive to the dav_fs module git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85783 13f79535-47bb-0310-9956-ffa450edef68 --- modules/dav/fs/Makefile.in | 2 +- modules/dav/fs/config.m4 | 22 +----- modules/dav/fs/mod_dav_fs.c | 137 ++++++++++++++++++++++++++++++++++++ modules/dav/fs/repos.h | 3 + modules/dav/main/mod_dav.c | 40 ++--------- modules/dav/main/mod_dav.h | 1 - 6 files changed, 147 insertions(+), 58 deletions(-) create mode 100644 modules/dav/fs/mod_dav_fs.c diff --git a/modules/dav/fs/Makefile.in b/modules/dav/fs/Makefile.in index d149b757bf..4504eb1eeb 100644 --- a/modules/dav/fs/Makefile.in +++ b/modules/dav/fs/Makefile.in @@ -1,5 +1,5 @@ LTLIBRARY_NAME = libapachemod_dav_fs.la -LTLIBRARY_SOURCES = dbm.c lock.c repos.c +LTLIBRARY_SOURCES = mod_dav_fs.c dbm.c lock.c repos.c include $(top_srcdir)/build/ltlib.mk diff --git a/modules/dav/fs/config.m4 b/modules/dav/fs/config.m4 index 64c6f16a7e..e31988aa8e 100644 --- a/modules/dav/fs/config.m4 +++ b/modules/dav/fs/config.m4 @@ -2,29 +2,9 @@ dnl modules enabled in this directory by default APACHE_MODPATH_INIT(dav/fs) -dnl ### dav_fs is not a module, but we want to have it enabled/disabled -dnl ### like one. with a bit o' work, dav_fs *will* become a true module. - -dnl ### this is snarfed from APACHE_MODULE. it does not allow dav_fs to be -dnl ### shared, and it does not add it into MODLIST. basically... it is -dnl ### just a static library to link into Apache at this point -AC_DEFUN(DAV_FS_MODULE,[ - AC_MSG_CHECKING(whether to enable mod_$1) - define([optname],[ --]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl - AC_ARG_ENABLE(translit($1,_,-),optname() substr([ ],len(optname()))$2,,enable_$1=ifelse($5,,no,$5)) - undefine([optname])dnl - AC_MSG_RESULT($enable_$1) - if test "$enable_$1" != "no"; then - APACHE_MODPATH_ADD($1, , $3) - fi -])dnl - - dnl ### we want to default this based on whether dav is being used... dnl ### but there is no ordering to the config.m4 files right now... -DAV_FS_MODULE(dav_fs, DAV provider for the filesystem, , , no) - - +APACHE_MODULE(dav_fs, DAV provider for the filesystem, , , no) if test "$enable_dav_fs" = "yes"; then apache_need_sdbm=yes fi diff --git a/modules/dav/fs/mod_dav_fs.c b/modules/dav/fs/mod_dav_fs.c new file mode 100644 index 0000000000..0fc9fecd05 --- /dev/null +++ b/modules/dav/fs/mod_dav_fs.c @@ -0,0 +1,137 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +#include "httpd.h" +#include "http_config.h" + +#include "mod_dav.h" +#include "repos.h" + +/* per-server configuration */ +typedef struct { + const char *lockdb_path; + +} dav_fs_server_conf; + +extern module MODULE_VAR_EXPORT dav_fs_module; + +const char *dav_get_lockdb_path(const request_rec *r) +{ + dav_fs_server_conf *conf; + + conf = ap_get_module_config(r->server->module_config, &dav_fs_module); + return conf->lockdb_path; +} + +static void *dav_fs_create_server_config(ap_pool_t *p, server_rec *s) +{ + return ap_pcalloc(p, sizeof(dav_fs_server_conf)); +} + +static void *dav_fs_merge_server_config(ap_pool_t *p, + void *base, void *overrides) +{ + dav_fs_server_conf *parent = base; + dav_fs_server_conf *child = overrides; + dav_fs_server_conf *newconf; + + newconf = ap_pcalloc(p, sizeof(*newconf)); + + newconf->lockdb_path = + child->lockdb_path ? child->lockdb_path : parent->lockdb_path; + + return newconf; +} + +/* + * Command handler for the DAVLockDB directive, which is TAKE1 + */ +static const char *dav_fs_cmd_davlockdb(cmd_parms *cmd, void *config, + const char *arg1) +{ + dav_fs_server_conf *conf; + + conf = ap_get_module_config(cmd->server->module_config, + &dav_fs_module); + arg1 = ap_os_canonical_filename(cmd->pool, arg1); + conf->lockdb_path = ap_server_root_relative(cmd->pool, arg1); + + return NULL; +} + +static const command_rec dav_fs_cmds[] = +{ + /* per server */ + AP_INIT_TAKE1("DAVLockDB", dav_fs_cmd_davlockdb, NULL, RSRC_CONF, + "specify a lock database"), + + { NULL } +}; + +static void register_hooks(void) +{ + /* nothing yet */ +} + +module MODULE_VAR_EXPORT dav_fs_module = +{ + STANDARD20_MODULE_STUFF, + NULL, /* dir config creater */ + NULL, /* dir merger --- default is to override */ + dav_fs_create_server_config, /* server config */ + dav_fs_merge_server_config, /* merge server config */ + dav_fs_cmds, /* command table */ + NULL, /* handlers */ + register_hooks, /* register hooks */ +}; diff --git a/modules/dav/fs/repos.h b/modules/dav/fs/repos.h index e309924f01..6386064d46 100644 --- a/modules/dav/fs/repos.h +++ b/modules/dav/fs/repos.h @@ -92,5 +92,8 @@ dav_error * dav_dbm_open_direct(ap_pool_t *p, const char *pathname, int ro, void dav_dbm_get_statefiles(ap_pool_t *p, const char *fname, const char **state1, const char **state2); +/* where is the lock database located? */ +const char *dav_get_lockdb_path(const request_rec *r); + #endif /* _DAV_FS_REPOS_H_ */ diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index a320a9a179..3ea0cf2122 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -121,8 +121,6 @@ typedef struct { /* per-server configuration */ typedef struct { - const char *lockdb_path; /* lock database path */ - uuid_state st; /* UUID state for opaquelocktoken */ } dav_server_conf; @@ -218,7 +216,6 @@ static void *dav_create_server_config(ap_pool_t *p, server_rec *s) newconf = (dav_server_conf *) ap_pcalloc(p, sizeof(*newconf)); - newconf->lockdb_path = NULL; dav_create_uuid_state(&newconf->st); return newconf; @@ -226,14 +223,16 @@ static void *dav_create_server_config(ap_pool_t *p, server_rec *s) static void *dav_merge_server_config(ap_pool_t *p, void *base, void *overrides) { - dav_server_conf *parent = base; dav_server_conf *child = overrides; dav_server_conf *newconf; newconf = (dav_server_conf *) ap_pcalloc(p, sizeof(*newconf)); - newconf->lockdb_path = DAV_INHERIT_VALUE(parent, child, lockdb_path); - + /* ### hmm. we should share the uuid state rather than copy it. if we + ### do another merge, then we'll just get the old one, rather than + ### an updated state. + ### of course... the UUID generation should move into APR + */ memcpy(&newconf->st, &child->st, sizeof(newconf->st)); return newconf; @@ -325,14 +324,6 @@ uuid_state *dav_get_uuid_state(const request_rec *r) return &conf->st; } -const char *dav_get_lockdb_path(const request_rec *r) -{ - dav_server_conf *conf; - - conf = ap_get_module_config(r->server->module_config, &dav_module); - return conf->lockdb_path; -} - ap_table_t *dav_get_dir_params(const request_rec *r) { dav_dir_conf *conf; @@ -357,7 +348,6 @@ const dav_dyn_hooks *dav_get_provider_hooks(request_rec *r, int provider_type) const dav_dyn_hooks *hooks; static const dav_dyn_hooks null_hooks = { { 0 } }; - /* Call repository hook to resolve resource */ conf = (dav_dir_conf *) ap_get_module_config(r->per_dir_config, &dav_module); switch (provider_type) { @@ -430,22 +420,6 @@ static const char *dav_cmd_davdepthinfinity(cmd_parms *cmd, void *config, return NULL; } -/* - * Command handler for the DAVLockDB directive, which is TAKE1 - */ -static const char *dav_cmd_davlockdb(cmd_parms *cmd, void *config, - const char *arg1) -{ - dav_server_conf *conf; - - conf = (dav_server_conf *) ap_get_module_config(cmd->server->module_config, - &dav_module); - arg1 = ap_os_canonical_filename(cmd->pool, arg1); - conf->lockdb_path = ap_server_root_relative(cmd->pool, arg1); - - return NULL; -} - /* * Command handler for DAVMinTimeout directive, which is TAKE1 */ @@ -3266,10 +3240,6 @@ static const command_rec dav_cmds[] = AP_INIT_FLAG("DAV", dav_cmd_dav, NULL, ACCESS_CONF, "turn DAV on/off for a directory or location"), - /* per server */ - AP_INIT_TAKE1("DAVLockDB", dav_cmd_davlockdb, NULL, RSRC_CONF, - "specify a lock database"), - /* per directory/location, or per server */ AP_INIT_TAKE1("DAVMinTimeout", dav_cmd_davmintimeout, NULL, ACCESS_CONF|RSRC_CONF, diff --git a/modules/dav/main/mod_dav.h b/modules/dav/main/mod_dav.h index 1b6493aa09..fdc8a70ad5 100644 --- a/modules/dav/main/mod_dav.h +++ b/modules/dav/main/mod_dav.h @@ -933,7 +933,6 @@ const char *dav_lock_get_activelock(request_rec *r, dav_lock *locks, dav_buffer *pbuf); /* LockDB-related public lock functions */ -const char *dav_get_lockdb_path(const request_rec *r); dav_error * dav_lock_parse_lockinfo(request_rec *r, const dav_resource *resrouce, dav_lockdb *lockdb, -- 2.40.0