You're already changing the API ... why not simply introduce
insert_prop_v2() with the appropriate parameters? This concept of "pass
parameters via the pool" is very disturbing.
Cheers,
-g
On Wed, Jul 15, 2020 at 8:56 AM <minfrin@apache.org> wrote:
> Author: minfrin
> Date: Wed Jul 15 13:56:55 2020
> New Revision: 1879889
>
> URL: http://svn.apache.org/viewvc?rev=1879889&view=rev
> Log:
> mod_dav: Some DAV extensions, like CalDAV, specify both document
> elements and property elements that need to be taken into account
> when generating a property. The document element and property element
> are made available in the dav_liveprop_elem structure under the
> DAV_PROP_ELEMENT key in the resource pool.
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/include/ap_mmn.h
> httpd/httpd/trunk/modules/dav/main/mod_dav.h
> httpd/httpd/trunk/modules/dav/main/props.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Jul 15 13:56:55 2020
> @@ -1,6 +1,12 @@
> -*- coding:
> utf-8 -*-
> Changes with Apache 2.5.1
>
> + *) mod_dav: Some DAV extensions, like CalDAV, specify both document
> + elements and property elements that need to be taken into account
> + when generating a property. The document element and property element
> + are made available in the dav_liveprop_elem structure under the
> + DAV_PROP_ELEMENT key in the resource pool. [Graham Leggett]
> +
> *) mod_dav: Add utility functions dav_validate_root_ns(),
> dav_find_child_ns(), dav_find_next_ns(), dav_find_attr_ns() and
> dav_find_attr() so that other modules get to play too.
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Wed Jul 15 13:56:55 2020
> @@ -657,6 +657,8 @@
> * 20200705.1 (2.5.1-dev) Add dav_validate_root_ns(),
> dav_find_child_ns(),
> * dav_find_next_ns(), dav_find_attr_ns() and
> * dav_find_attr().
> + * 20200705.2 (2.5.1-dev) Add dav_liveprop_elem structure and
> + * DAV_PROP_ELEMENT key.
> */
>
> #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
> @@ -664,7 +666,7 @@
> #ifndef MODULE_MAGIC_NUMBER_MAJOR
> #define MODULE_MAGIC_NUMBER_MAJOR 20200705
> #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */
>
> /**
> * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/trunk/modules/dav/main/mod_dav.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/mod_dav.h?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/mod_dav.h (original)
> +++ httpd/httpd/trunk/modules/dav/main/mod_dav.h Wed Jul 15 13:56:55 2020
> @@ -913,6 +913,14 @@ struct dav_hooks_liveprop
> ** property, and does not want it handled as a dead property, it
> should
> ** return DAV_PROP_INSERT_NOTSUPP.
> **
> + ** Some DAV extensions, like CalDAV, specify both document elements
> + ** and property elements that need to be taken into account when
> + ** generating a property. The document element and property element
> + ** are made available in the dav_liveprop_elem structure under the
> + ** DAV_PROP_ELEMENT key in the resource pool, accessible as follows:
> + **
> + ** apr_pool_userdata_get(&elem, DAV_PROP_ELEMENT, resource->pool);
> + **
> ** Returns one of DAV_PROP_INSERT_* based on what happened.
> **
> ** ### we may need more context... ie. the lock database
> @@ -1061,6 +1069,20 @@ DAV_DECLARE(void) dav_add_all_liveprop_x
> apr_text_header *phdr);
>
> /*
> + ** When calling insert_prop(), the request element is associated with
> + ** the pool userdata attached to the resource. Access as follows:
> + **
> + ** apr_pool_userdata_get(&elem, DAV_PROP_ELEMENT, resource->pool);
> + **
> + */
> +#define DAV_PROP_ELEMENT "mod_dav-element"
> +
> +typedef struct {
> + const apr_xml_doc *doc;
> + const apr_xml_elem *elem;
> +} dav_liveprop_elem;
> +
> +/*
> ** The following three functions are part of mod_dav's internal handling
> ** for the core WebDAV properties. They are not part of mod_dav's API.
> */
>
> Modified: httpd/httpd/trunk/modules/dav/main/props.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/props.c?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/props.c (original)
> +++ httpd/httpd/trunk/modules/dav/main/props.c Wed Jul 15 13:56:55 2020
> @@ -795,10 +795,18 @@ DAV_DECLARE(dav_get_props_result) dav_ge
> apr_text_header hdr_ns = { 0 };
> int have_good = 0;
> dav_get_props_result result = { 0 };
> + dav_liveprop_elem *element;
> char *marks_liveprop;
> dav_xmlns_info *xi;
> int xi_filled = 0;
>
> + /* we lose both the document and the element when calling
> (insert_prop),
> + * make these available in the pool.
> + */
> + element = apr_pcalloc(propdb->resource->pool,
> sizeof(dav_liveprop_elem));
> + element->doc = doc;
> + apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL,
> propdb->resource->pool);
> +
> /* ### NOTE: we should pass in TWO buffers -- one for keys, one for
> the marks */
>
> @@ -822,6 +830,8 @@ DAV_DECLARE(dav_get_props_result) dav_ge
> dav_prop_insert inserted;
> dav_prop_name name;
>
> + element->elem = elem;
> +
> /*
> ** First try live property providers; if they don't handle
> ** the property, then try looking it up in the propdb.
>
>
>
insert_prop_v2() with the appropriate parameters? This concept of "pass
parameters via the pool" is very disturbing.
Cheers,
-g
On Wed, Jul 15, 2020 at 8:56 AM <minfrin@apache.org> wrote:
> Author: minfrin
> Date: Wed Jul 15 13:56:55 2020
> New Revision: 1879889
>
> URL: http://svn.apache.org/viewvc?rev=1879889&view=rev
> Log:
> mod_dav: Some DAV extensions, like CalDAV, specify both document
> elements and property elements that need to be taken into account
> when generating a property. The document element and property element
> are made available in the dav_liveprop_elem structure under the
> DAV_PROP_ELEMENT key in the resource pool.
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/include/ap_mmn.h
> httpd/httpd/trunk/modules/dav/main/mod_dav.h
> httpd/httpd/trunk/modules/dav/main/props.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Jul 15 13:56:55 2020
> @@ -1,6 +1,12 @@
> -*- coding:
> utf-8 -*-
> Changes with Apache 2.5.1
>
> + *) mod_dav: Some DAV extensions, like CalDAV, specify both document
> + elements and property elements that need to be taken into account
> + when generating a property. The document element and property element
> + are made available in the dav_liveprop_elem structure under the
> + DAV_PROP_ELEMENT key in the resource pool. [Graham Leggett]
> +
> *) mod_dav: Add utility functions dav_validate_root_ns(),
> dav_find_child_ns(), dav_find_next_ns(), dav_find_attr_ns() and
> dav_find_attr() so that other modules get to play too.
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Wed Jul 15 13:56:55 2020
> @@ -657,6 +657,8 @@
> * 20200705.1 (2.5.1-dev) Add dav_validate_root_ns(),
> dav_find_child_ns(),
> * dav_find_next_ns(), dav_find_attr_ns() and
> * dav_find_attr().
> + * 20200705.2 (2.5.1-dev) Add dav_liveprop_elem structure and
> + * DAV_PROP_ELEMENT key.
> */
>
> #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
> @@ -664,7 +666,7 @@
> #ifndef MODULE_MAGIC_NUMBER_MAJOR
> #define MODULE_MAGIC_NUMBER_MAJOR 20200705
> #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */
>
> /**
> * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/trunk/modules/dav/main/mod_dav.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/mod_dav.h?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/mod_dav.h (original)
> +++ httpd/httpd/trunk/modules/dav/main/mod_dav.h Wed Jul 15 13:56:55 2020
> @@ -913,6 +913,14 @@ struct dav_hooks_liveprop
> ** property, and does not want it handled as a dead property, it
> should
> ** return DAV_PROP_INSERT_NOTSUPP.
> **
> + ** Some DAV extensions, like CalDAV, specify both document elements
> + ** and property elements that need to be taken into account when
> + ** generating a property. The document element and property element
> + ** are made available in the dav_liveprop_elem structure under the
> + ** DAV_PROP_ELEMENT key in the resource pool, accessible as follows:
> + **
> + ** apr_pool_userdata_get(&elem, DAV_PROP_ELEMENT, resource->pool);
> + **
> ** Returns one of DAV_PROP_INSERT_* based on what happened.
> **
> ** ### we may need more context... ie. the lock database
> @@ -1061,6 +1069,20 @@ DAV_DECLARE(void) dav_add_all_liveprop_x
> apr_text_header *phdr);
>
> /*
> + ** When calling insert_prop(), the request element is associated with
> + ** the pool userdata attached to the resource. Access as follows:
> + **
> + ** apr_pool_userdata_get(&elem, DAV_PROP_ELEMENT, resource->pool);
> + **
> + */
> +#define DAV_PROP_ELEMENT "mod_dav-element"
> +
> +typedef struct {
> + const apr_xml_doc *doc;
> + const apr_xml_elem *elem;
> +} dav_liveprop_elem;
> +
> +/*
> ** The following three functions are part of mod_dav's internal handling
> ** for the core WebDAV properties. They are not part of mod_dav's API.
> */
>
> Modified: httpd/httpd/trunk/modules/dav/main/props.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/props.c?rev=1879889&r1=1879888&r2=1879889&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/props.c (original)
> +++ httpd/httpd/trunk/modules/dav/main/props.c Wed Jul 15 13:56:55 2020
> @@ -795,10 +795,18 @@ DAV_DECLARE(dav_get_props_result) dav_ge
> apr_text_header hdr_ns = { 0 };
> int have_good = 0;
> dav_get_props_result result = { 0 };
> + dav_liveprop_elem *element;
> char *marks_liveprop;
> dav_xmlns_info *xi;
> int xi_filled = 0;
>
> + /* we lose both the document and the element when calling
> (insert_prop),
> + * make these available in the pool.
> + */
> + element = apr_pcalloc(propdb->resource->pool,
> sizeof(dav_liveprop_elem));
> + element->doc = doc;
> + apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL,
> propdb->resource->pool);
> +
> /* ### NOTE: we should pass in TWO buffers -- one for keys, one for
> the marks */
>
> @@ -822,6 +830,8 @@ DAV_DECLARE(dav_get_props_result) dav_ge
> dav_prop_insert inserted;
> dav_prop_name name;
>
> + element->elem = elem;
> +
> /*
> ** First try live property providers; if they don't handle
> ** the property, then try looking it up in the propdb.
>
>
>