]> granicus.if.org Git - apache/commitdiff
complete the removal of the old dav_dyn crap. dav plugins are now
authorGreg Stein <gstein@apache.org>
Mon, 10 Jul 2000 07:49:48 +0000 (07:49 +0000)
committerGreg Stein <gstein@apache.org>
Mon, 10 Jul 2000 07:49:48 +0000 (07:49 +0000)
    implemented entirely through standard Apache modules, hooks, and some
    additional registration.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85803 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/fs/mod_dav_fs.c
modules/dav/fs/repos.c
modules/dav/fs/repos.h
modules/dav/main/config.m4
modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h
modules/dav/main/props.c

index 6f873b0efdd42e12a0417fee232a1dab8c26f4d4..3c89853a3837e2fbb5ab0d611e49ce91db677f55 100644 (file)
@@ -125,6 +125,11 @@ static void register_hooks(void)
     ap_hook_get_lock_hooks(dav_fs_get_lock_hooks, NULL, NULL, AP_HOOK_MIDDLE);
     ap_hook_get_propdb_hooks(dav_fs_get_propdb_hooks, NULL, NULL,
                              AP_HOOK_MIDDLE);
+    ap_hook_gather_propsets(dav_fs_gather_propsets, NULL, NULL,
+                            AP_HOOK_MIDDLE);
+    ap_hook_find_liveprop(dav_fs_find_liveprop, NULL, NULL, AP_HOOK_MIDDLE);
+    ap_hook_insert_all_liveprops(dav_fs_insert_all_liveprops, NULL, NULL,
+                                 AP_HOOK_MIDDLE);
 
     dav_fs_register_uris(NULL /* ### pconf */);
 }
index 466c7e60ba9aa123c9d293807715060a5855b444..a741637ba66d052ee1cf890d3c56543b142604ec 100644 (file)
@@ -2012,32 +2012,6 @@ static const dav_hooks_liveprop dav_hooks_liveprop_fs =
     dav_fs_patch_rollback,
 };
 
-/*
-** Note: we do not provide an is_active function at this point. In the
-** future, mod_dav may use that to determine if a particular provider is
-** active/enabled, but it doesn't now.
-*/
-static const dav_dyn_provider dav_dyn_providers_fs[] =
-{
-    /* liveprop provider */
-    {
-       DAV_FS_PROVIDER_ID,
-        DAV_DYN_TYPE_LIVEPROP,
-        &dav_hooks_liveprop_fs
-    },
-
-    /* must always be last */
-    DAV_DYN_END_MARKER
-};
-
-const dav_dyn_module dav_dyn_module_default =
-{
-    DAV_DYN_MAGIC,
-    DAV_DYN_VERSION,
-    "filesystem",
-
-    dav_dyn_providers_fs
-};
 
 int dav_fs_hook_get_resource(request_rec *r, const char *root_dir,
                              const char *workspace)
@@ -2062,6 +2036,32 @@ const dav_hooks_propdb *dav_fs_get_propdb_hooks(request_rec *r)
     return &dav_hooks_db_dbm;
 }
 
+void dav_fs_gather_propsets(ap_array_header_t *uris)
+{
+#ifndef WIN32
+    *(const char **)ap_push_array(uris) =
+        "<http://apache.org/dav/propset/fs/1>";
+#endif
+}
+
+int dav_fs_find_liveprop(request_rec *r, const char *ns_uri, const char *name,
+                         const dav_hooks_liveprop **hooks)
+{
+    int propid = dav_fs_find_prop(ns_uri, name);
+
+    if (propid == 0)
+        return 0;
+
+    *hooks = &dav_hooks_liveprop_fs;
+    return propid;
+}
+
+void dav_fs_insert_all_liveprops(request_rec *r, const dav_resource *resource,
+                                 int insvalue, ap_text_header *phdr)
+{
+    dav_fs_insert_all(resource, insvalue, phdr);
+}
+
 void dav_fs_register_uris(ap_pool_t *p)
 {
     const char * const * uris = dav_fs_namespace_uris;
index 217af69df296307b1054e45a763b4667c8b24ea3..2ecf314f5974aa497cf6ea4679c8959caeb5dc1e 100644 (file)
@@ -100,6 +100,12 @@ int dav_fs_hook_get_resource(request_rec *r, const char *root_dir,
 const dav_hooks_locks *dav_fs_get_lock_hooks(request_rec *r);
 const dav_hooks_propdb *dav_fs_get_propdb_hooks(request_rec *r);
 
+void dav_fs_gather_propsets(ap_array_header_t *uris);
+int dav_fs_find_liveprop(request_rec *r, const char *ns_uri, const char *name,
+                         const dav_hooks_liveprop **hooks);
+void dav_fs_insert_all_liveprops(request_rec *r, const dav_resource *resource,
+                                 int insvalue, ap_text_header *phdr);
+
 void dav_fs_register_uris(ap_pool_t *p);
 
 #endif /* _DAV_FS_REPOS_H_ */
index 7ea2654339dac6add21b0a3fee48c4181f68742e..41c640a756fadf4ce554825dbdd15f680980dfef 100644 (file)
@@ -13,13 +13,5 @@ if test "$enable_dav" = "yes"; then
   INCLUDES="$INCLUDES -I\$(top_srcdir)/$modpath_current"
 fi
 
-dnl ### hack. we reference a symbol from the dav_fs "library", but that lib
-dnl ### appears on the link line first. nothing refers to the variable, so
-dnl ### it doesn't get sucked in. we will add the lib one more time *after*
-dnl ### our location on the link line, so we pick the thing up.
-if test "$enable_dav" = "yes"; then
-  BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/../fs/libapachemod_dav_fs.la"
-fi
-
 
 APACHE_MODPATH_FINISH
index b2b35d4ae7dd6b002edfe8e63f4e80e3af0422bd..9b03b41d544aa0a3ced57515a77973edb4d1ec1a 100644 (file)
@@ -110,9 +110,7 @@ typedef struct {
     long limit_xml_body;
 
     ap_table_t *d_params;      /* per-directory DAV config parameters */
-    struct dav_dyn_mod_ctx *dmc;
 
-    dav_dyn_hooks *liveprop;
 } dav_dir_conf;
 
 /* per-server configuration */
@@ -132,27 +130,6 @@ typedef struct {
 /* forward-declare for use in configuration lookup */
 extern module MODULE_VAR_EXPORT dav_module;
 
-/* copy a module's providers into our per-directory configuration state */
-static void dav_copy_providers(ap_pool_t *p, const char *name, dav_dir_conf *conf)
-{
-    extern const dav_dyn_module dav_dyn_module_default;
-
-    const dav_dyn_module *mod;
-    const dav_dyn_provider *provider;
-    dav_dyn_hooks *ddh;
-
-    /* ### just hard-code this stuff for now */
-
-    /* mod = dav_find_module(name); */
-    mod = &dav_dyn_module_default;
-
-    provider = mod->providers;
-
-    ddh = ap_pcalloc(p, sizeof(*ddh));
-    ddh->hooks = provider->hooks;
-    conf->liveprop = ddh;
-}
-
 static void dav_init_handler(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp,
                              server_rec *s)
 {
@@ -200,14 +177,6 @@ static void *dav_create_dir_config(ap_pool_t *p, char *dir)
     conf->d_params = ap_make_table(p, 1);
     conf->limit_xml_body = DAV_LIMIT_UNSET;
 
-    /* DBG1("dav_create_dir_config: %08lx", (long)conf); */
-
-    /*
-    ** Locate the appropriate module (NULL == default) and copy the module's
-    ** providers' hooks into our configuration state.
-    */
-    dav_copy_providers(p, NULL, conf);
-
     return conf;
 }
 
@@ -235,11 +204,6 @@ static void *dav_merge_dir_config(ap_pool_t *p, void *base, void *overrides)
     ap_overlap_tables(newconf->d_params, child->d_params,
                      AP_OVERLAP_TABLES_SET);
 
-    if (child->liveprop != NULL)
-        newconf->liveprop = child->liveprop;
-    else
-        newconf->liveprop = parent->liveprop;
-
     return newconf;
 }
 
@@ -318,14 +282,6 @@ const dav_hooks_vsn *dav_get_vsn_hooks(request_rec *r)
     return hooks;
 }
 
-const dav_dyn_hooks *dav_get_liveprop_hooks(request_rec *r)
-{
-    dav_dir_conf *conf;
-
-    conf = ap_get_module_config(r->per_dir_config, &dav_module);
-    return conf->liveprop;
-}
-
 /*
  * Command handler for the DAV directive, which is FLAG.
  */
@@ -1335,8 +1291,8 @@ static int dav_method_options(request_rec *r)
     const char *dav_level;
     const char *vsn_level;
     int result;
-    const dav_dir_conf *conf;
-    const dav_dyn_hooks *lp;
+    ap_array_header_t *uri_ary;
+    const char *uris;
 
     /* per HTTP/1.1 S9.2, we can discard this body */
     if ((result = ap_discard_request_body(r)) != OK) {
@@ -1362,17 +1318,12 @@ static int dav_method_options(request_rec *r)
         vsn_level = (*vsn_hooks->get_vsn_header)();
     }
 
-    /*
-    ** Iterate through the live property providers; add their URIs to
-    ** the dav_level string.
-    */
-    conf = (dav_dir_conf *) ap_get_module_config(r->per_dir_config,
-                                                &dav_module);
-    for (lp = conf->liveprop; lp != NULL; lp = lp->next) {
-        const char *uri = DAV_AS_HOOKS_LIVEPROP(lp)->propset_uri;
-
-        if (uri != NULL)
-            dav_level = ap_pstrcat(r->pool, dav_level, ",<", uri, ">", NULL);
+    /* gather property set URIs from all the liveprop providers */
+    uri_ary = ap_make_array(r->pool, 5, sizeof(const char *));
+    ap_run_gather_propsets(uri_ary);
+    uris = ap_array_pstrcat(r->pool, uri_ary, ',');
+    if (*uris) {
+        dav_level = ap_pstrcat(r->pool, dav_level, ",", uris, NULL);
     }
 
     /* this tells MSFT products to skip looking for FrontPage extensions */
@@ -3220,6 +3171,7 @@ AP_HOOK_STRUCT(
     AP_HOOK_LINK(get_lock_hooks)
     AP_HOOK_LINK(get_propdb_hooks)
     AP_HOOK_LINK(get_vsn_hooks)
+    AP_HOOK_LINK(gather_propsets)
     AP_HOOK_LINK(find_liveprop)
     AP_HOOK_LINK(insert_all_liveprops)
     )
@@ -3233,3 +3185,13 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(const dav_hooks_db *, get_propdb_hooks,
                             (request_rec *r), (r), NULL);
 AP_IMPLEMENT_HOOK_RUN_FIRST(const dav_hooks_vsn *, get_vsn_hooks,
                             (request_rec *r), (r), NULL);
+AP_IMPLEMENT_HOOK_VOID(gather_propsets, (ap_array_header_t *uris), (uris))
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, find_liveprop,
+                            (request_rec *r,
+                             const char *ns_uri, const char *name,
+                             const dav_hooks_liveprop **hooks),
+                            (r, ns_uri, name, hooks), 0);
+AP_IMPLEMENT_HOOK_VOID(insert_all_liveprops,
+                       (request_rec *r, const dav_resource *resource,
+                        int insvalue, ap_text_header *phdr),
+                       (r, resource, insvalue, phdr));
index 0fa0a9d96be3936940ecf6a50aac5041c03ebdf6..12b625ee9fb41ccd85219c03644011d58df5b6db 100644 (file)
@@ -393,6 +393,7 @@ AP_DECLARE_HOOK(const dav_hooks_locks *, get_lock_hooks, (request_rec *r))
 AP_DECLARE_HOOK(const dav_hooks_propdb *, get_propdb_hooks, (request_rec *r))
 AP_DECLARE_HOOK(const dav_hooks_vsn *, get_vsn_hooks, (request_rec *r))
 
+AP_DECLARE_HOOK(void, gather_propsets, (ap_array_header_t *uris))
 AP_DECLARE_HOOK(int, find_liveprop, (request_rec *r,
                                      const char *ns_uri, const char *name,
                                      const dav_hooks_liveprop **hooks))
@@ -416,121 +417,11 @@ int dav_get_liveprop_ns_count(void);
 void dav_add_all_liveprop_xmlns(ap_pool_t *p, ap_text_header *phdr);
 
 
-/* --------------------------------------------------------------------
-**
-** ====> DEPRECATED <====
-**
-** DYNAMIC EXTENSIONS
-*/
-
-/* ### docco goes here... */
-
-
-/*
-** This structure is used to specify a set of hooks and its associated
-** context, on a per-directory/location basis.
-**
-** Note: the context is assembled from various sources. dav_dyn_hooks
-** structures will typically have the same pointer values within the
-** context (e.g. ctx.m_context is shared across all providers in a module).
-*/
-typedef struct dav_dyn_hooks
-{
-    const void *hooks;         /* the type-specific hooks */
-
-    struct dav_dyn_hooks *next;        /* next set of hooks, if applicable */
-
-} dav_dyn_hooks;
-
-/*
-** These enumerated values define the different types of functionality that
-** a provider can implement.
-*/
-enum
-{
-    DAV_DYN_TYPE_SENTINEL,
-
-    DAV_DYN_TYPE_PROPDB,       /* property database (1 per dir) */
-    DAV_DYN_TYPE_LOCKS,                /* lock handling (1 per dir) */
-    DAV_DYN_TYPE_QUERY_GRAMMAR,        /* DASL search grammar (N per dir) */
-    DAV_DYN_TYPE_ACL,          /* ACL handling (1 per dir) */
-    DAV_DYN_TYPE_VSN,          /* versioning (1 per dir) */
-    DAV_DYN_TYPE_LIVEPROP,     /* live property handler (N per dir) */
-
-    DAV_DYN_TYPE_MAX
-};
-
-/*
-** This structure defines a provider for a particular type of functionality.
-**
-** The ID is private to a provider and can be used to differentiate between
-** different subclasses of functionality which are implemented using the
-** same set of hooks. For example, a hook function could perform two entirely
-** different operations based on the ID which is passed.
-**
-** is_active() is used by the system to determine whether a particular
-** provider is "active" for the given context. It is possible that a provider
-** is configured for a directory, but has not been enabled -- the is_active()
-** function is used to determine that information.
-**
-** ### is_active is not used right now
-**
-** Note: dav_dyn_provider structures are always treated as "const" by mod_dav.
-*/
-typedef struct dav_dyn_provider
-{
-    int id;                    /* provider ID */
-
-    int type;                  /* provider's functionality type */
-    const void *hooks;         /* pointer to type-specific hooks */
-
-} dav_dyn_provider;
-
-#define DAV_DYN_END_MARKER     { 0, DAV_DYN_TYPE_SENTINEL, NULL }
-
-/*
-** This structure defines a module (a set of providers).
-**
-** The friendly name should be a single word. It is used with the "DAV"
-** directive to specify the module to use for a particular directory/location.
-**
-** The module_open/close functions are used to initialize per-module "global"
-** data. The functions are expected to update ctx->m_context.
-**
-** ### module_open/close are not used at the moment
-** ### dir_* are not well-defined, nor are they used
-**
-** Note: The DAV_DYN_VERSION specifies the version of the dav_dyn_module
-**       structure itself. It will be updated if changes in the structure
-**       are made. There are no provisions for forward or backward
-**       compatible changes.
-**
-** Note: dav_dyn_module structures are always treated as "const" by mod_dav.
-*/
-typedef struct
-{
-    int magic;
-#define DAV_DYN_MAGIC          0x44415621      /* "DAV!" */
-
-    int version;
-#define DAV_DYN_VERSION                1               /* must match exactly */
-
-    const char *name;                          /* friendly name */
-
-    const dav_dyn_provider *providers;         /* providers in this module */
-
-} dav_dyn_module;
-
 /* ### deprecated */
 #define DAV_GET_HOOKS_PROPDB(r)         dav_get_propdb_hooks(r)
 #define DAV_GET_HOOKS_LOCKS(r)          dav_get_lock_hooks(r)
 #define DAV_GET_HOOKS_VSN(r)            dav_get_vsn_hooks(r)
 
-/* ### temporary; this semantic won't apply in the new scheme */
-const dav_dyn_hooks *dav_get_liveprop_hooks(request_rec *r);
-#define DAV_AS_HOOKS_LIVEPROP(ph)      ((const dav_hooks_liveprop *)((ph)->hooks))
-#define DAV_GET_HOOKS_LIVEPROP(r)       DAV_AS_HOOKS_LIVEPROP(dav_get_liveprop_hooks(r))
-
 
 /* --------------------------------------------------------------------
 **
index 535bea20a26e16e7f84d887688818d3c420e745e..dc2592516644fa952f96f3ec8b0881eaf3065db6 100644 (file)
@@ -268,7 +268,6 @@ struct dav_propdb {
     const dav_hooks_db *db_hooks;
     const dav_hooks_vsn *vsn_hooks;
 
-    const dav_dyn_hooks *liveprop;     /* head of list */
 };
 
 /* ### move these into a "core" liveprop provider? */
@@ -326,8 +325,8 @@ static void dav_find_liveprop(dav_propdb *propdb, ap_xml_elem *elem)
 {
     int propid;
     const char *ns_uri;
-    const dav_dyn_hooks *ddh;
     dav_elem_private *priv = elem->private;
+    const dav_hooks_liveprop *hooks;
 
     if (elem->ns == AP_XML_NS_DAV_ID) {
        const char * const *p = dav_core_props;
@@ -346,25 +345,24 @@ static void dav_find_liveprop(dav_propdb *propdb, ap_xml_elem *elem)
        return;
     }
 
+    /* get the URI for the element's namespace id */
     ns_uri = AP_XML_GET_URI_ITEM(propdb->ns_xlate, elem->ns);
 
-    for (ddh = propdb->liveprop; ddh != NULL; ddh = ddh->next) {
-       propid = (*DAV_AS_HOOKS_LIVEPROP(ddh)->find_prop)(ns_uri, elem->name);
-       if (propid != 0) {
-           priv->propid = propid;
-           priv->provider = DAV_AS_HOOKS_LIVEPROP(ddh);
-           return;
-       }
+    /* is there a liveprop provider for this property? */
+    propid = ap_run_find_liveprop(propdb->r, ns_uri, elem->name, &hooks);
+    if (propid != 0) {
+        priv->propid = propid;
+        priv->provider = hooks;
+        return;
     }
 
     priv->propid = DAV_PROPID_CORE_UNKNOWN;
 }
 
 /* is the live property read/write? */
-static int dav_rw_liveprop(dav_propdb *propdb, int propid)
+static int dav_rw_liveprop(dav_propdb *propdb, dav_elem_private *priv)
 {
-    dav_prop_rw rw;
-    const dav_dyn_hooks *ddh;
+    int propid = priv->propid;
 
     /* these are defined as read-only */
     if (propid == DAV_PROPID_CORE_lockdiscovery
@@ -389,13 +387,14 @@ static int dav_rw_liveprop(dav_propdb *propdb, int propid)
     /*
     ** Check the liveprop providers
     */
-    for (ddh = propdb->liveprop; ddh != NULL; ddh = ddh->next) {
-       rw = (*DAV_AS_HOOKS_LIVEPROP(ddh)->is_writeable)(propdb->resource,
-                                                        propid);
-       if (rw == DAV_PROP_RW_YES)
-           return 1;
-       if (rw == DAV_PROP_RW_NO)
-           return 0;
+    if (priv->provider != NULL) {
+        dav_prop_rw rw;
+
+        rw = (*priv->provider->is_writeable)(propdb->resource, propid);
+        if (rw == DAV_PROP_RW_YES)
+            return 1;
+        if (rw == DAV_PROP_RW_NO)
+            return 0;
     }
 
     /*
@@ -971,9 +970,6 @@ dav_error *dav_open_propdb(request_rec *r, dav_lockdb *lockdb,
     propdb->db_hooks = DAV_GET_HOOKS_PROPDB(r);
     propdb->vsn_hooks = DAV_GET_HOOKS_VSN(r);
 
-    /* ### this will need to change */
-    propdb->liveprop = dav_get_liveprop_hooks(r);
-
     propdb->lockdb = lockdb;
 
     if (!ro) {
@@ -1030,7 +1026,6 @@ dav_get_props_result dav_get_allprops(dav_propdb *propdb, int getvals)
     int found_contenttype = 0;
     int found_contentlang = 0;
     int unused_inserted;
-    const dav_dyn_hooks *ddh;
 
     /* generate all the namespaces that are in the propdb */
     dav_get_propdb_xmlns(propdb, &hdr_ns);
@@ -1124,10 +1119,7 @@ dav_get_props_result dav_get_allprops(dav_propdb *propdb, int getvals)
     dav_add_all_liveprop_xmlns(propdb->p, &hdr_ns);
     
     /* ask the liveprop providers to insert their properties */
-    for (ddh = propdb->liveprop; ddh != NULL; ddh = ddh->next) {
-       (*DAV_AS_HOOKS_LIVEPROP(ddh)->insert_all)(propdb->resource, getvals,
-                                                 &hdr);
-    }
+    ap_run_insert_all_liveprops(propdb->r, propdb->resource, getvals, &hdr);
 
     /* insert the standard properties */
     /* ### should be handling the return errors here */
@@ -1374,7 +1366,7 @@ void dav_prop_validate(dav_prop_ctx *ctx)
        ctx->is_liveprop = priv->provider != NULL;
     }
 
-    if (!dav_rw_liveprop(propdb, priv->propid)) {
+    if (!dav_rw_liveprop(propdb, priv)) {
        ctx->err = dav_new_error(propdb->p, HTTP_CONFLICT,
                                 DAV_ERR_PROP_READONLY,
                                 "Property is read-only.");