You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2001/02/18 11:21:26 UTC

cvs commit: apr-util/xml apr_xml.c

gstein      01/02/18 02:21:26

  Modified:    include  apr_xml.h
               xml      apr_xml.c
  Log:
  first pass of changes to build within APRUTIL.
  
  Note: apr_xml.[ch] came from httpd-2.0/.../util_xml.[ch] through a
        repository copy.
  
  Revision  Changes    Path
  1.8       +81 -78    apr-util/include/apr_xml.h
  
  Index: apr_xml.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_xml.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- apr_xml.h	2001/02/16 04:26:31	1.7
  +++ apr_xml.h	2001/02/18 10:21:25	1.8
  @@ -55,13 +55,15 @@
   #ifndef UTIL_XML_H
   #define UTIL_XML_H
   
  +#include "apr_pools.h"
  +#include "apr_tables.h"
  +
  +#include "apu.h"
  +
   #ifdef __cplusplus
   extern "C" {
   #endif
   
  -#include "httpd.h"
  -#include "apr_lib.h"
  -
   /**
    * @package Apache XML library
    */
  @@ -71,25 +73,25 @@
   /* ### these will need to move at some point to a more logical spot */
   
   /* simple strutures to keep a linked list of pieces of text */
  -typedef struct ap_text ap_text;
  +typedef struct apr_text apr_text;
   
   /** Structure to keep a linked list of pieces of text */
  -struct ap_text {
  +struct apr_text {
       /** The current piece of text */
       const char *text;
       /** a pointer to the next piece of text 
  -     *  @defvar ap_text *next */
  -    struct ap_text *next;
  +     *  @defvar apr_text *next */
  +    struct apr_text *next;
   };
   
  -typedef struct ap_text_header ap_text_header;
  +typedef struct apr_text_header apr_text_header;
   
   /** A list of pieces of text */
  -struct ap_text_header {
  +struct apr_text_header {
       /** The first piece of text in the list */
  -    ap_text *first;
  +    apr_text *first;
       /** The last piece of text in the list */
  -    ap_text *last;
  +    apr_text *last;
   };
   
   /**
  @@ -97,10 +99,10 @@
    * @param p The pool to allocate out of
    * @param hdr The text header to append to
    * @param text The new text to append
  - * @deffunc void ap_text_append(apr_pool_t *p, ap_text_header *hdr, const char *text)
  + * @deffunc void apr_text_append(apr_pool_t *p, apr_text_header *hdr, const char *text)
    */
  -AP_DECLARE(void) ap_text_append(apr_pool_t *p, ap_text_header *hdr,
  -                                const char *text);
  +APU_DECLARE(void) apr_text_append(apr_pool_t *p, apr_text_header *hdr,
  +                                  const char *text);
   
   
   /* --------------------------------------------------------------------
  @@ -111,12 +113,12 @@
   /*
   ** Qualified namespace values
   **
  -** AP_XML_NS_DAV_ID
  +** APR_XML_NS_DAV_ID
   **    We always insert the "DAV:" namespace URI at the head of the
   **    namespace array. This means that it will always be at ID==0,
   **    making it much easier to test for.
   **
  -** AP_XML_NS_NONE
  +** APR_XML_NS_NONE
   **    This special ID is used for two situations:
   **
   **    1) The namespace prefix begins with "xml" (and we do not know
  @@ -152,22 +154,22 @@
   **
   ** Note: currently, mod_dav understands the "xmlns" prefix and the
   **     "xml:lang" attribute. These are handled specially (they aren't
  -**     left within the XML tree), so the AP_XML_NS_NONE value won't ever
  +**     left within the XML tree), so the APR_XML_NS_NONE value won't ever
   **     really apply to these values.
   */
  -#define AP_XML_NS_DAV_ID	0	/* namespace ID for "DAV:" */
  -#define AP_XML_NS_NONE		-10	/* no namespace for this elem/attr */
  +#define APR_XML_NS_DAV_ID	0	/* namespace ID for "DAV:" */
  +#define APR_XML_NS_NONE		-10	/* no namespace for this elem/attr */
   
  -#define AP_XML_NS_ERROR_BASE	-100	/* used only during processing */
  -#define AP_XML_NS_IS_ERROR(e)	((e) <= AP_XML_NS_ERROR_BASE)
  +#define APR_XML_NS_ERROR_BASE	-100	/* used only during processing */
  +#define APR_XML_NS_IS_ERROR(e)	((e) <= APR_XML_NS_ERROR_BASE)
   
   
  -typedef struct ap_xml_attr ap_xml_attr;
  -typedef struct ap_xml_elem ap_xml_elem;
  -typedef struct ap_xml_doc ap_xml_doc;
  +typedef struct apr_xml_attr apr_xml_attr;
  +typedef struct apr_xml_elem apr_xml_elem;
  +typedef struct apr_xml_doc apr_xml_doc;
   
  -/** ap_xml_attr: holds a parsed XML attribute */
  -struct ap_xml_attr {
  +/** apr_xml_attr: holds a parsed XML attribute */
  +struct apr_xml_attr {
       /** attribute name */
       const char *name;
       /** index into namespace array */
  @@ -177,12 +179,12 @@
       const char *value;
   
       /** next attribute
  -     *  @defvar ap_xml_attr *next */
  -    struct ap_xml_attr *next;
  +     *  @defvar apr_xml_attr *next */
  +    struct apr_xml_attr *next;
   };
   
  -/** ap_xml_elem: holds a parsed XML element */
  -struct ap_xml_elem {
  +/** apr_xml_elem: holds a parsed XML element */
  +struct apr_xml_elem {
       /** element name */
       const char *name;
       /** index into namespace array */
  @@ -191,56 +193,57 @@
       const char *lang;
   
       /** cdata right after start tag */
  -    ap_text_header first_cdata;
  +    apr_text_header first_cdata;
       /** cdata after MY end tag */
  -    ap_text_header following_cdata;
  +    apr_text_header following_cdata;
   
       /** parent element 
  -     *  @defvar ap_xml_elem *parent */
  -    struct ap_xml_elem *parent;	
  +     *  @defvar apr_xml_elem *parent */
  +    struct apr_xml_elem *parent;	
       /** next (sibling) element 
  -     *  @defvar ap_xml_elem *next */
  -    struct ap_xml_elem *next;	
  +     *  @defvar apr_xml_elem *next */
  +    struct apr_xml_elem *next;	
       /** first child element 
  -     *  @defvar ap_xml_elem *first_child */
  -    struct ap_xml_elem *first_child;
  +     *  @defvar apr_xml_elem *first_child */
  +    struct apr_xml_elem *first_child;
       /** first attribute 
  -     *  @defvar ap_xml_attr *attr */
  -    struct ap_xml_attr *attr;		
  +     *  @defvar apr_xml_attr *attr */
  +    struct apr_xml_attr *attr;		
   
       /* used only during parsing */
       /** last child element 
  -     *  @defvar ap_xml_elem *last_child */
  -    struct ap_xml_elem *last_child;
  +     *  @defvar apr_xml_elem *last_child */
  +    struct apr_xml_elem *last_child;
       /** namespaces scoped by this elem 
  -     *  @defvar ap_xml_ns_scope *ns_scope */
  -    struct ap_xml_ns_scope *ns_scope;
  +     *  @defvar apr_xml_ns_scope *ns_scope */
  +    struct apr_xml_ns_scope *ns_scope;
   
       /* used by modules during request processing */
       /** Place for modules to store private data */
       void *private;
   };
   
  -#define AP_XML_ELEM_IS_EMPTY(e)	((e)->first_child == NULL && \
  -				 (e)->first_cdata.first == NULL)
  +#define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \
  +                                  (e)->first_cdata.first == NULL)
   
  -/** ap_xml_doc: holds a parsed XML document */
  -struct ap_xml_doc {
  +/** apr_xml_doc: holds a parsed XML document */
  +struct apr_xml_doc {
       /** root element */
  -    ap_xml_elem *root;	
  +    apr_xml_elem *root;	
       /** array of namespaces used */
       apr_array_header_t *namespaces;
   };
   
  +#if 0
   /**
    * Get XML post data and parse it
    * @param r The current request
    * @param pdoc The XML post data
    * @return HTTP status code
  - * @deffunc int ap_xml_parse_input(request_rec *r, ap_xml_doc **pdoc)
  + * @deffunc int ap_xml_parse_input(request_rec *r, apr_xml_doc **pdoc)
    */
  -AP_DECLARE(int) ap_xml_parse_input(request_rec *r, ap_xml_doc **pdoc);
  -
  +APU_DECLARE(int) ap_xml_parse_input(request_rec *r, apr_xml_doc **pdoc);
  +#endif
   
   /**
    * Converts an XML element tree to flat text 
  @@ -248,37 +251,37 @@
    * @param elem The XML element to convert
    * @param style How to covert the XML.  One of:
    * <PRE>
  - *     AP_XML_X2T_FULL                start tag, contents, end tag 
  - *     AP_XML_X2T_INNER               contents only 
  - *     AP_XML_X2T_LANG_INNER          xml:lang + inner contents 
  - *     AP_XML_X2T_FULL_NS_LANG        FULL + ns defns + xml:lang 
  + *     APR_XML_X2T_FULL                start tag, contents, end tag 
  + *     APR_XML_X2T_INNER               contents only 
  + *     APR_XML_X2T_LANG_INNER          xml:lang + inner contents 
  + *     APR_XML_X2T_FULL_NS_LANG        FULL + ns defns + xml:lang 
    * </PRE>
    * @param namespaces The namespace of the current XML element
    * @param ns_map Namespace mapping
    * @param pbuf Buffer to put the converted text into
    * @param psize Size of the converted text
  - * @deffunc void ap_xml_to_text(apr_pool_t *p, const ap_xml_elem *elem, int style, apr_array_header_t *namespaces, int *ns_map, const char **pbuf, size_t *psize);
  + * @deffunc void apr_xml_to_text(apr_pool_t *p, const apr_xml_elem *elem, int style, apr_array_header_t *namespaces, int *ns_map, const char **pbuf, size_t *psize);
    */
  -AP_DECLARE(void) ap_xml_to_text(apr_pool_t *p, const ap_xml_elem *elem,
  -				int style, apr_array_header_t *namespaces,
  -				int *ns_map, const char **pbuf,
  -                                apr_size_t *psize);
  +APU_DECLARE(void) apr_xml_to_text(apr_pool_t *p, const apr_xml_elem *elem,
  +                                  int style, apr_array_header_t *namespaces,
  +                                  int *ns_map, const char **pbuf,
  +                                  apr_size_t *psize);
   
   /* style argument values: */
  -#define AP_XML_X2T_FULL		0	/* start tag, contents, end tag */
  -#define AP_XML_X2T_INNER 	1	/* contents only */
  -#define AP_XML_X2T_LANG_INNER	2	/* xml:lang + inner contents */
  -#define AP_XML_X2T_FULL_NS_LANG	3	/* FULL + ns defns + xml:lang */
  +#define APR_XML_X2T_FULL         0	/* start tag, contents, end tag */
  +#define APR_XML_X2T_INNER        1	/* contents only */
  +#define APR_XML_X2T_LANG_INNER   2	/* xml:lang + inner contents */
  +#define APR_XML_X2T_FULL_NS_LANG 3	/* FULL + ns defns + xml:lang */
   
   /**
    * empty XML element
    * @param p The pool to allocate out of
    * @param elem The XML element to empty
    * @return the string that was stored in the XML element
  - * @deffunc const char *ap_xml_empty_elem(apr_pool_t *p, const ap_xml_elem *elem)
  + * @deffunc const char *apr_xml_empty_elem(apr_pool_t *p, const apr_xml_elem *elem)
    */
  -AP_DECLARE(const char *) ap_xml_empty_elem(apr_pool_t *p,
  -                                           const ap_xml_elem *elem);
  +APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t *p,
  +                                             const apr_xml_elem *elem);
   
   /**
    * quote an XML string
  @@ -287,31 +290,31 @@
    * @param s The string to quote
    * @param quotes If quotes is true, then replace '"' with '&quot;'.
    * @return The quoted string
  - * @deffunc const char *ap_xml_quote_string(apr_pool_t *p, const char *s, int quotes)
  + * @deffunc const char *apr_xml_quote_string(apr_pool_t *p, const char *s, int quotes)
    */
  -AP_DECLARE(const char *) ap_xml_quote_string(apr_pool_t *p, const char *s,
  -                                             int quotes);
  +APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
  +                                               int quotes);
   
   /**
    * Quote an XML element
    * @param p The pool to allocate out of
    * @param elem The element to quote
  - * @deffunc void ap_xml_quote_elem(apr_pool_t *p, ap_xml_elem *elem)
  + * @deffunc void apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
    */
  -AP_DECLARE(void) ap_xml_quote_elem(apr_pool_t *p, ap_xml_elem *elem);
  +APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem);
   
  -/* manage an array of unique URIs: ap_xml_insert_uri() and AP_XML_URI_ITEM() */
  +/* manage an array of unique URIs: apr_xml_insert_uri() and APR_XML_URI_ITEM() */
   
   /**
    * return the URI's (existing) index, or insert it and return a new index 
    * @param uri_array array to insert into
    * @param uri The uri to insert
    * @return int The uri's index
  - * @deffunc int ap_xml_insert_uri(apr_array_header_t *uri_array, const char *uri)
  + * @deffunc int apr_xml_insert_uri(apr_array_header_t *uri_array, const char *uri)
    */
  -AP_DECLARE(int) ap_xml_insert_uri(apr_array_header_t *uri_array,
  -                                  const char *uri);
  -#define AP_XML_GET_URI_ITEM(ary, i)    (((const char * const *)(ary)->elts)[i])
  +APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
  +                                    const char *uri);
  +#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i])
   
   #ifdef __cplusplus
   }
  
  
  
  1.16      +110 -109  apr-util/xml/apr_xml.c
  
  Index: apr_xml.c
  ===================================================================
  RCS file: /home/cvs/apr-util/xml/apr_xml.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -u -r1.15 -r1.16
  --- apr_xml.c	2001/02/16 04:26:48	1.15
  +++ apr_xml.c	2001/02/18 10:21:26	1.16
  @@ -67,60 +67,55 @@
   #define APR_WANT_STRFUNC
   #include "apr_want.h"
   
  -#include "httpd.h"
  -#include "http_protocol.h"
  -#include "http_log.h"
  -#include "http_core.h"
  +#include "apr_xml.h"
   
  -#include "util_xml.h"
   
  -
   #define DEBUG_CR "\r\n"
   
  -#define AP_XML_READ_BLOCKSIZE	2048	/* used for reading input blocks */
  +#define APR_XML_READ_BLOCKSIZE	2048	/* used for reading input blocks */
   
   /* errors related to namespace processing */
  -#define AP_XML_NS_ERROR_UNKNOWN_PREFIX	(AP_XML_NS_ERROR_BASE)
  +#define APR_XML_NS_ERROR_UNKNOWN_PREFIX	(APR_XML_NS_ERROR_BASE)
   
   /* test for a namespace prefix that begins with [Xx][Mm][Ll] */
  -#define AP_XML_NS_IS_RESERVED(name) \
  +#define APR_XML_NS_IS_RESERVED(name) \
   	( (name[0] == 'X' || name[0] == 'x') && \
   	  (name[1] == 'M' || name[1] == 'm') && \
   	  (name[2] == 'L' || name[2] == 'l') )
   
   
   /* content for parsing */
  -typedef struct ap_xml_ctx {
  -    ap_xml_doc *doc;		/* the doc we're parsing */
  +typedef struct apr_xml_ctx {
  +    apr_xml_doc *doc;		/* the doc we're parsing */
       apr_pool_t *p;		/* the pool we allocate from */
  -    ap_xml_elem *cur_elem;	/* current element */
  +    apr_xml_elem *cur_elem;	/* current element */
   
       int error;			/* an error has occurred */
  -    /* errors may be AP_XML_NS_ERROR_* or other private errors which will
  +    /* errors may be APR_XML_NS_ERROR_* or other private errors which will
          be defined here (none yet) */
   
  -} ap_xml_ctx;
  +} apr_xml_ctx;
   
   /* struct for scoping namespace declarations */
  -typedef struct ap_xml_ns_scope {
  +typedef struct apr_xml_ns_scope {
       const char *prefix;		/* prefix used for this ns */
       int ns;			/* index into namespace table */
       int emptyURI;		/* the namespace URI is the empty string */
  -    struct ap_xml_ns_scope *next;	/* next scoped namespace */
  -} ap_xml_ns_scope;
  +    struct apr_xml_ns_scope *next;	/* next scoped namespace */
  +} apr_xml_ns_scope;
   
   
   /* return namespace table index for a given prefix */
  -static int find_prefix(ap_xml_ctx *ctx, const char *prefix)
  +static int find_prefix(apr_xml_ctx *ctx, const char *prefix)
   {
  -    ap_xml_elem *elem = ctx->cur_elem;
  +    apr_xml_elem *elem = ctx->cur_elem;
   
       /*
       ** Walk up the tree, looking for a namespace scope that defines this
       ** prefix.
       */
       for (; elem; elem = elem->parent) {
  -	ap_xml_ns_scope *ns_scope = elem->ns_scope;
  +	apr_xml_ns_scope *ns_scope = elem->ns_scope;
   
   	for (ns_scope = elem->ns_scope; ns_scope; ns_scope = ns_scope->next) {
   	    if (strcmp(prefix, ns_scope->prefix) == 0) {
  @@ -131,7 +126,7 @@
   		    ** to mean "no namespace." We just found the prefix
   		    ** refers to an empty URI, so return "no namespace."
   		    */
  -		    return AP_XML_NS_NONE;
  +		    return APR_XML_NS_NONE;
   		}
   
   		return ns_scope->ns;
  @@ -147,19 +142,19 @@
        * has "no namespace". We have a reserved value for this.
        */
       if (*prefix == '\0') {
  -	return AP_XML_NS_NONE;
  +	return APR_XML_NS_NONE;
       }
   
       /* not found */
  -    return AP_XML_NS_ERROR_UNKNOWN_PREFIX;
  +    return APR_XML_NS_ERROR_UNKNOWN_PREFIX;
   }
   
   static void start_handler(void *userdata, const char *name, const char **attrs)
   {
  -    ap_xml_ctx *ctx = userdata;
  -    ap_xml_elem *elem;
  -    ap_xml_attr *attr;
  -    ap_xml_attr *prev;
  +    apr_xml_ctx *ctx = userdata;
  +    apr_xml_elem *elem;
  +    apr_xml_attr *attr;
  +    apr_xml_attr *prev;
       char *colon;
       const char *quoted;
       char *elem_name;
  @@ -212,7 +207,7 @@
   	 attr = attr->next) {
   	if (strncmp(attr->name, "xmlns", 5) == 0) {
   	    const char *prefix = &attr->name[5];
  -	    ap_xml_ns_scope *ns_scope;
  +	    apr_xml_ns_scope *ns_scope;
   
   	    /* test for xmlns:foo= form and xmlns= form */
   	    if (*prefix == ':')
  @@ -224,12 +219,12 @@
   	    }
   
   	    /* quote the URI before we ever start working with it */
  -	    quoted = ap_xml_quote_string(ctx->p, attr->value, 1);
  +	    quoted = apr_xml_quote_string(ctx->p, attr->value, 1);
   
   	    /* build and insert the new scope */
   	    ns_scope = apr_pcalloc(ctx->p, sizeof(*ns_scope));
   	    ns_scope->prefix = prefix;
  -	    ns_scope->ns = ap_xml_insert_uri(ctx->doc->namespaces, quoted);
  +	    ns_scope->ns = apr_xml_insert_uri(ctx->doc->namespaces, quoted);
   	    ns_scope->emptyURI = *quoted == '\0';
   	    ns_scope->next = elem->ns_scope;
   	    elem->ns_scope = ns_scope;
  @@ -244,7 +239,7 @@
   	}
   	else if (strcmp(attr->name, "xml:lang") == 0) {
   	    /* save away the language (in quoted form) */
  -	    elem->lang = ap_xml_quote_string(ctx->p, attr->value, 1);
  +	    elem->lang = apr_xml_quote_string(ctx->p, attr->value, 1);
   
   	    /* remove this attribute from the element */
   	    if (prev == NULL)
  @@ -270,7 +265,7 @@
   	elem->lang = elem->parent->lang;
   
       /* adjust the element's namespace */
  -    colon = ap_strchr(elem_name, ':');
  +    colon = strchr(elem_name, ':');
       if (colon == NULL) {
   	/*
   	 * The element is using the default namespace, which will always
  @@ -279,15 +274,15 @@
   	 */
   	elem->ns = find_prefix(ctx, "");
       }
  -    else if (AP_XML_NS_IS_RESERVED(elem->name)) {
  -	elem->ns = AP_XML_NS_NONE;
  +    else if (APR_XML_NS_IS_RESERVED(elem->name)) {
  +	elem->ns = APR_XML_NS_NONE;
       }
       else {
   	*colon = '\0';
   	elem->ns = find_prefix(ctx, elem->name);
   	elem->name = colon + 1;
   
  -	if (AP_XML_NS_IS_ERROR(elem->ns)) {
  +	if (APR_XML_NS_IS_ERROR(elem->ns)) {
   	    ctx->error = elem->ns;
   	    return;
   	}
  @@ -296,29 +291,29 @@
       /* adjust all remaining attributes' namespaces */
       for (attr = elem->attr; attr; attr = attr->next) {
           /*
  -         * ap_xml_attr defines this as "const" but we dup'd it, so we
  +         * apr_xml_attr defines this as "const" but we dup'd it, so we
            * know that we can change it. a bit hacky, but the existing
            * structure def is best.
            */
           char *attr_name = (char *)attr->name;
   
  -	colon = ap_strchr(attr_name, ':');
  +	colon = strchr(attr_name, ':');
   	if (colon == NULL) {
   	    /*
   	     * Attributes do NOT use the default namespace. Therefore,
   	     * we place them into the "no namespace" category.
   	     */
  -	    attr->ns = AP_XML_NS_NONE;
  +	    attr->ns = APR_XML_NS_NONE;
   	}
  -	else if (AP_XML_NS_IS_RESERVED(attr->name)) {
  -	    attr->ns = AP_XML_NS_NONE;
  +	else if (APR_XML_NS_IS_RESERVED(attr->name)) {
  +	    attr->ns = APR_XML_NS_NONE;
   	}
   	else {
   	    *colon = '\0';
   	    attr->ns = find_prefix(ctx, attr->name);
   	    attr->name = colon + 1;
   
  -	    if (AP_XML_NS_IS_ERROR(attr->ns)) {
  +	    if (APR_XML_NS_IS_ERROR(attr->ns)) {
   		ctx->error = attr->ns;
   		return;
   	    }
  @@ -328,7 +323,7 @@
   
   static void end_handler(void *userdata, const char *name)
   {
  -    ap_xml_ctx *ctx = userdata;
  +    apr_xml_ctx *ctx = userdata;
   
       /* punt once we find an error */
       if (ctx->error)
  @@ -340,9 +335,9 @@
   
   static void cdata_handler(void *userdata, const char *data, int len)
   {
  -    ap_xml_ctx *ctx = userdata;
  -    ap_xml_elem *elem;
  -    ap_text_header *hdr;
  +    apr_xml_ctx *ctx = userdata;
  +    apr_xml_elem *elem;
  +    apr_text_header *hdr;
       const char *s;
   
       /* punt once we find an error */
  @@ -361,13 +356,16 @@
   	hdr = &elem->last_child->following_cdata;
       }
   
  -    ap_text_append(ctx->p, hdr, s);
  +    apr_text_append(ctx->p, hdr, s);
   }
  +
  +
  +#if 0
   
  -AP_DECLARE(int) ap_xml_parse_input(request_rec * r, ap_xml_doc **pdoc)
  +APU_DECLARE(int) apr_xml_parse_input(request_rec * r, apr_xml_doc **pdoc)
   {
       int result;
  -    ap_xml_ctx ctx = { 0 };
  +    apr_xml_ctx ctx = { 0 };
       XML_Parser parser;
   
       if ((result = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) != OK)
  @@ -382,7 +380,7 @@
       ctx.doc = apr_pcalloc(ctx.p, sizeof(*ctx.doc));
   
       ctx.doc->namespaces = apr_array_make(ctx.p, 5, sizeof(const char *));
  -    ap_xml_insert_uri(ctx.doc->namespaces, "DAV:");
  +    apr_xml_insert_uri(ctx.doc->namespaces, "DAV:");
   
       /* ### we should get the encoding from Content-Encoding */
       parser = XML_ParserCreate(NULL);
  @@ -405,10 +403,10 @@
   	apr_size_t limit_xml_body = ap_get_limit_xml_body(r);
   
   	/* allocate our working buffer */
  -	buffer = apr_palloc(r->pool, AP_XML_READ_BLOCKSIZE);
  +	buffer = apr_palloc(r->pool, APR_XML_READ_BLOCKSIZE);
   
   	/* read the body, stuffing it into the parser */
  -	while ((len = ap_get_client_block(r, buffer, AP_XML_READ_BLOCKSIZE)) > 0) {
  +	while ((len = ap_get_client_block(r, buffer, APR_XML_READ_BLOCKSIZE)) > 0) {
   	    total_read += len;
   	    if (limit_xml_body && total_read > limit_xml_body) {
   		ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
  @@ -436,7 +434,7 @@
   
       if (ctx.error) {
   	switch (ctx.error) {
  -	case AP_XML_NS_ERROR_UNKNOWN_PREFIX:
  +	case APR_XML_NS_ERROR_UNKNOWN_PREFIX:
   	    ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
   			  "An undefined namespace prefix was used.");
   	    break;
  @@ -478,11 +476,14 @@
       /* Apache will supply a default error, plus whatever was logged. */
       return HTTP_BAD_REQUEST;
   }
  +
  +#endif /* 0 */
  +
   
  -AP_DECLARE(void) ap_text_append(apr_pool_t * p, ap_text_header *hdr,
  -                                const char *text)
  +APU_DECLARE(void) apr_text_append(apr_pool_t * p, apr_text_header *hdr,
  +                                  const char *text)
   {
  -    ap_text *t = apr_palloc(p, sizeof(*t));
  +    apr_text *t = apr_palloc(p, sizeof(*t));
   
       t->text = text;
       t->next = NULL;
  @@ -505,7 +506,7 @@
   */
   
   /*
  -** ap_xml_quote_string: quote an XML string
  +** apr_xml_quote_string: quote an XML string
   **
   ** Replace '<', '>', and '&' with '&lt;', '&gt;', and '&amp;'.
   ** If quotes is true, then replace '"' with '&quot;'.
  @@ -513,8 +514,8 @@
   ** quotes is typically set to true for XML strings that will occur within
   ** double quotes -- attribute values.
   */
  -AP_DECLARE(const char *) ap_xml_quote_string(apr_pool_t *p, const char *s,
  -                                             int quotes)
  +APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
  +                                               int quotes)
   {
       const char *scan;
       apr_size_t len = 0;
  @@ -575,12 +576,12 @@
   }
   
   /* how many characters for the given integer? */
  -#define AP_XML_NS_LEN(ns) ((ns) < 10 ? 1 : (ns) < 100 ? 2 : (ns) < 1000 ? 3 : \
  -			 (ns) < 10000 ? 4 : (ns) < 100000 ? 5 : \
  -			 (ns) < 1000000 ? 6 : (ns) < 10000000 ? 7 : \
  -			 (ns) < 100000000 ? 8 : (ns) < 1000000000 ? 9 : 10)
  +#define APR_XML_NS_LEN(ns) ((ns) < 10 ? 1 : (ns) < 100 ? 2 : (ns) < 1000 ? 3 : \
  +                            (ns) < 10000 ? 4 : (ns) < 100000 ? 5 : \
  +                            (ns) < 1000000 ? 6 : (ns) < 10000000 ? 7 : \
  +                            (ns) < 100000000 ? 8 : (ns) < 1000000000 ? 9 : 10)
   
  -static apr_size_t text_size(const ap_text *t)
  +static apr_size_t text_size(const apr_text *t)
   {
       apr_size_t size = 0;
   
  @@ -589,17 +590,17 @@
       return size;
   }
   
  -static apr_size_t elem_size(const ap_xml_elem *elem, int style,
  +static apr_size_t elem_size(const apr_xml_elem *elem, int style,
                               apr_array_header_t *namespaces, int *ns_map)
   {
       apr_size_t size;
   
  -    if (style == AP_XML_X2T_FULL || style == AP_XML_X2T_FULL_NS_LANG) {
  -	const ap_xml_attr *attr;
  +    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) {
  +	const apr_xml_attr *attr;
   
   	size = 0;
   
  -	if (style == AP_XML_X2T_FULL_NS_LANG) {
  +	if (style == APR_XML_X2T_FULL_NS_LANG) {
   	    int i;
   
   	    /*
  @@ -609,8 +610,8 @@
   
   	    for (i = namespaces->nelts; i--;) {
   		/* compute size of: ' xmlns:ns%d="%s"' */
  -		size += (9 + AP_XML_NS_LEN(i) + 2 +
  -			 strlen(AP_XML_GET_URI_ITEM(namespaces, i)) + 1);
  +		size += (9 + APR_XML_NS_LEN(i) + 2 +
  +			 strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1);
   	    }
   
   	    if (elem->lang != NULL) {
  @@ -619,7 +620,7 @@
   	    }
   	}
   
  -	if (elem->ns == AP_XML_NS_NONE) {
  +	if (elem->ns == APR_XML_NS_NONE) {
   	    /* compute size of: <%s> */
   	    size += 1 + strlen(elem->name) + 1;
   	}
  @@ -627,10 +628,10 @@
   	    int ns = ns_map ? ns_map[elem->ns] : elem->ns;
   
   	    /* compute size of: <ns%d:%s> */
  -	    size += 3 + AP_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
  +	    size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1;
   	}
   
  -	if (AP_XML_ELEM_IS_EMPTY(elem)) {
  +	if (APR_XML_ELEM_IS_EMPTY(elem)) {
   	    /* insert a closing "/" */
   	    size += 1;
   	}
  @@ -644,13 +645,13 @@
   	}
   
   	for (attr = elem->attr; attr; attr = attr->next) {
  -	    if (attr->ns == AP_XML_NS_NONE) {
  +	    if (attr->ns == APR_XML_NS_NONE) {
   		/* compute size of: ' %s="%s"' */
   		size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
   	    }
   	    else {
   		/* compute size of: ' ns%d:%s="%s"' */
  -		size += 3 + AP_XML_NS_LEN(attr->ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
  +		size += 3 + APR_XML_NS_LEN(attr->ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1;
   	    }
   	}
   
  @@ -666,7 +667,7 @@
   	    size += 11 + strlen(elem->lang) + 1;
   	}
       }
  -    else if (style == AP_XML_X2T_LANG_INNER) {
  +    else if (style == APR_XML_X2T_LANG_INNER) {
   	/*
   	 * This style prepends the xml:lang value plus a null terminator.
   	 * If a lang value is not present, then we insert a null term.
  @@ -680,14 +681,14 @@
   
       for (elem = elem->first_child; elem; elem = elem->next) {
   	/* the size of the child element plus the CDATA that follows it */
  -	size += (elem_size(elem, AP_XML_X2T_FULL, NULL, ns_map) +
  +	size += (elem_size(elem, APR_XML_X2T_FULL, NULL, ns_map) +
   		 text_size(elem->following_cdata.first));
       }
   
       return size;
   }
   
  -static char *write_text(char *s, const ap_text *t)
  +static char *write_text(char *s, const apr_text *t)
   {
       for (; t; t = t->next) {
   	apr_size_t len = strlen(t->text);
  @@ -697,18 +698,18 @@
       return s;
   }
   
  -static char *write_elem(char *s, const ap_xml_elem *elem, int style,
  +static char *write_elem(char *s, const apr_xml_elem *elem, int style,
   			apr_array_header_t *namespaces, int *ns_map)
   {
  -    const ap_xml_elem *child;
  +    const apr_xml_elem *child;
       apr_size_t len;
       int ns;
   
  -    if (style == AP_XML_X2T_FULL || style == AP_XML_X2T_FULL_NS_LANG) {
  -	int empty = AP_XML_ELEM_IS_EMPTY(elem);
  -	const ap_xml_attr *attr;
  +    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) {
  +	int empty = APR_XML_ELEM_IS_EMPTY(elem);
  +	const apr_xml_attr *attr;
   
  -	if (elem->ns == AP_XML_NS_NONE) {
  +	if (elem->ns == APR_XML_NS_NONE) {
   	    len = sprintf(s, "<%s", elem->name);
   	}
   	else {
  @@ -718,7 +719,7 @@
   	s += len;
   
   	for (attr = elem->attr; attr; attr = attr->next) {
  -	    if (attr->ns == AP_XML_NS_NONE)
  +	    if (attr->ns == APR_XML_NS_NONE)
   		len = sprintf(s, " %s=\"%s\"", attr->name, attr->value);
   	    else
   		len = sprintf(s, " ns%d:%s=\"%s\"", attr->ns, attr->name, attr->value);
  @@ -727,7 +728,7 @@
   
   	/* add the xml:lang value if necessary */
   	if (elem->lang != NULL &&
  -	    (style == AP_XML_X2T_FULL_NS_LANG ||
  +	    (style == APR_XML_X2T_FULL_NS_LANG ||
   	     elem->parent == NULL ||
   	     elem->lang != elem->parent->lang)) {
   	    len = sprintf(s, " xml:lang=\"%s\"", elem->lang);
  @@ -735,12 +736,12 @@
   	}
   
   	/* add namespace definitions, if required */
  -	if (style == AP_XML_X2T_FULL_NS_LANG) {
  +	if (style == APR_XML_X2T_FULL_NS_LANG) {
   	    int i;
   
   	    for (i = namespaces->nelts; i--;) {
   		len = sprintf(s, " xmlns:ns%d=\"%s\"", i,
  -			      AP_XML_GET_URI_ITEM(namespaces, i));
  +			      APR_XML_GET_URI_ITEM(namespaces, i));
   		s += len;
   	    }
   	}
  @@ -755,7 +756,7 @@
   	/* just close it */
   	*s++ = '>';
       }
  -    else if (style == AP_XML_X2T_LANG_INNER) {
  +    else if (style == APR_XML_X2T_LANG_INNER) {
   	/* prepend the xml:lang value */
   	if (elem->lang != NULL) {
   	    len = strlen(elem->lang);
  @@ -768,12 +769,12 @@
       s = write_text(s, elem->first_cdata.first);
   
       for (child = elem->first_child; child; child = child->next) {
  -	s = write_elem(s, child, AP_XML_X2T_FULL, NULL, ns_map);
  +	s = write_elem(s, child, APR_XML_X2T_FULL, NULL, ns_map);
   	s = write_text(s, child->following_cdata.first);
       }
   
  -    if (style == AP_XML_X2T_FULL || style == AP_XML_X2T_FULL_NS_LANG) {
  -	if (elem->ns == AP_XML_NS_NONE) {
  +    if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) {
  +	if (elem->ns == APR_XML_NS_NONE) {
   	    len = sprintf(s, "</%s>", elem->name);
   	}
   	else {
  @@ -786,44 +787,44 @@
       return s;
   }
   
  -AP_DECLARE(void) ap_xml_quote_elem(apr_pool_t *p, ap_xml_elem *elem)
  +APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem)
   {
  -    ap_text *scan_txt;
  -    ap_xml_attr *scan_attr;
  -    ap_xml_elem *scan_elem;
  +    apr_text *scan_txt;
  +    apr_xml_attr *scan_attr;
  +    apr_xml_elem *scan_elem;
   
       /* convert the element's text */
       for (scan_txt = elem->first_cdata.first;
   	 scan_txt != NULL;
   	 scan_txt = scan_txt->next) {
  -	scan_txt->text = ap_xml_quote_string(p, scan_txt->text, 0);
  +	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
       }
       for (scan_txt = elem->following_cdata.first;
   	 scan_txt != NULL;
   	 scan_txt = scan_txt->next) {
  -	scan_txt->text = ap_xml_quote_string(p, scan_txt->text, 0);
  +	scan_txt->text = apr_xml_quote_string(p, scan_txt->text, 0);
       }
   
       /* convert the attribute values */
       for (scan_attr = elem->attr;
   	 scan_attr != NULL;
   	 scan_attr = scan_attr->next) {
  -	scan_attr->value = ap_xml_quote_string(p, scan_attr->value, 1);
  +	scan_attr->value = apr_xml_quote_string(p, scan_attr->value, 1);
       }
   
       /* convert the child elements */
       for (scan_elem = elem->first_child;
   	 scan_elem != NULL;
   	 scan_elem = scan_elem->next) {
  -	ap_xml_quote_elem(p, scan_elem);
  +	apr_xml_quote_elem(p, scan_elem);
       }
   }
   
   /* convert an element to a text string */
  -AP_DECLARE(void) ap_xml_to_text(apr_pool_t * p, const ap_xml_elem *elem,
  -                                int style, apr_array_header_t *namespaces,
  -                                int *ns_map, const char **pbuf,
  -                                apr_size_t *psize)
  +APU_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem,
  +                                  int style, apr_array_header_t *namespaces,
  +                                  int *ns_map, const char **pbuf,
  +                                  apr_size_t *psize)
   {
       /* get the exact size, plus a null terminator */
       apr_size_t size = elem_size(elem, style, namespaces, ns_map) + 1;
  @@ -837,10 +838,10 @@
   	*psize = size;
   }
   
  -AP_DECLARE(const char *) ap_xml_empty_elem(apr_pool_t * p,
  -                                           const ap_xml_elem *elem)
  +APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t * p,
  +                                             const apr_xml_elem *elem)
   {
  -    if (elem->ns == AP_XML_NS_NONE) {
  +    if (elem->ns == APR_XML_NS_NONE) {
   	/*
   	 * The prefix (xml...) is already within the prop name, or
   	 * the element simply has no prefix.
  @@ -852,14 +853,14 @@
   }
   
   /* return the URI's (existing) index, or insert it and return a new index */
  -AP_DECLARE(int) ap_xml_insert_uri(apr_array_header_t *uri_array,
  -                                  const char *uri)
  +APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
  +                                    const char *uri)
   {
       int i;
       const char **pelt;
   
       for (i = uri_array->nelts; i--;) {
  -	if (strcmp(uri, AP_XML_GET_URI_ITEM(uri_array, i)) == 0)
  +	if (strcmp(uri, APR_XML_GET_URI_ITEM(uri_array, i)) == 0)
   	    return i;
       }