/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 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.
 * ====================================================================
 *
 */

#ifndef _HTTP_EXT_H_
#define _HTTP_EXT_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "httpd.h"

#define HTTP_EXT_VERSION	"0.5"
#define HTTP_EXT_URI		"http://www.w3.org/Protocols/HTTP/ietf-http-ext/"

typedef enum {
    HTTP_EXT_OK, 	/* OKY DOKY */
    HTTP_EXT_FAIL, 	/* general failure */
    HTTP_EXT_NOT_FOUND,	/* no http extension matched */
    HTTP_EXT_CONFLICT,	/* http extensions are vying for the same headers */
} httpExt_error_code;

typedef enum {
    HTTP_EXT_NAK, 	/* module cannot handle this extension */
    HTTP_EXT_EXCLUSIVE,	/* module wants exclusive rights to this extension */
    HTTP_EXT_SHARED,	/* module shares extension with other modules */
} httpExt_handler_contract;

/* HTTP EXTENSIONS API FUNCTIONS */

typedef httpExt_error_code httpExt_notify_t (request_rec *r, 
					     const char * const uri, 
					     apr_table_t * headers, 
					     apr_table_t * declExts);
httpExt_error_code httpExt_register_extension (apr_pool_t *p, 
					       const char * const declName, 
					       httpExt_notify_t * notify, 
					     httpExt_handler_contract contract);
apr_table_t * httpExt_get_headers_in(request_rec *r, const char * const uri);
httpExt_error_code httpExt_register_response (request_rec *r, 
					      const char * const declName, 
					      httpExt_handler_contract contract, 
					      int mandatory, int connection, 
					      apr_table_t * headers, 
					      apr_table_t * declExts, 
					      void **pContext);
void httpExt_set_header_out (void * context, request_rec * r, 
			     const char * const key, const char * const value);

/* ERROR-REPORTING HELPER FUNCTIONS */
int httpExt_header_error(request_rec *r, const char * const name, const char * const value);
int httpExt_parameter_error(request_rec *r, const char * const name, const char * const value);
int httpExt_required_error (request_rec *r, const char * const declName, const char * const ns);

#ifdef __cplusplus
}
#endif

#endif /* _HTTP_EXT_H_ */
