pier 01/04/17 06:13:51 Added: connectors/include wa.h wa_general.h wa_provider.h wa_request.h Log: New header files for the WebApp Library. Revision Changes Path 1.1 jakarta-tomcat-4.0/connectors/include/wa.h Index: wa.h =================================================================== /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2001 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * 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 acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "WebApp", 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 <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names 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 indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /** * @author Pier Fumagalli <mailto:[EMAIL PROTECTED]> * @version $Id: wa.h,v 1.1 2001/04/17 13:13:48 pier Exp $ */ #ifndef _WA_H_ #define _WA_H_ /* C standard includes */ #include <stdio.h> #include <stdarg.h> #include <string.h> /* APR Library includes */ #include <apr_general.h> #include <apr_pools.h> #include <apr_strings.h> #include <apr_tables.h> /* WebApp Library type definitions. */ typedef int boolean; typedef struct wa_connection wa_connection; typedef struct wa_application wa_application; typedef struct wa_deployer wa_deployer; typedef struct wa_request wa_request; typedef void wa_provider; /* WebApp Library includes */ #include <wa_general.h> #include <wa_request.h> #endif /* ifndef _WA_H_ */ 1.1 jakarta-tomcat-4.0/connectors/include/wa_general.h Index: wa_general.h =================================================================== /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2001 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * 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 acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "WebApp", 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 <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names 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 indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /** * @package WebApp General Package * @author Pier Fumagalli <mailto:[EMAIL PROTECTED]> * @version $Id: wa_general.h,v 1.1 2001/04/17 13:13:49 pier Exp $ */ #ifndef _WA_GENERAL_H_ #define _WA_GENERAL_H_ /** * The WebApp Library connection structure. * <br> * This structure holds all required data required by a connection provider * to connect to a web-application container and to handle HTTP requests. */ struct wa_connection { /** The APR memory pool where this connections is allocated. */ apr_pool_t *pool; /** The connection provider. */ void *prov; /** The provider-specific configuration member for this connection. */ void *conf; }; /** * The WebApp Library application structure. * <br> * This structure holds all informations associated with an application. * Applications are not grouped in virtual hosts inside the library as in * specific cases (like when load balancing is in use), multiple applications * can share the same root URL path, or (like when applications are shared), * a single web application can be shared across multiple virtual host. */ struct wa_application { /** The APR memory pool where this application is allocated. */ apr_pool_t *pool; /** The application connection. */ wa_connection *conn; /** The provider-specific configuration member for this application. */ void *conf; /** The application name. */ char *name; /** The application root URL path. */ char *rpth; /** The local expanded application path (if any). */ char *lpth; }; /** * Initialize the WebApp Library. * <br> * This function must be called <b>before</b> any other calls to any other * function to set up the APR and WebApp Library internals. If any other * function is called before this function has been invoked will result in * impredictable results. * * @return <b>NULL</b> on success or an error message on faliure. */ const char *wa_init(void); /** * Clean up the WebApp Library. * <br> * This function releases all memory and resouces used by the WebApp library * and must be called before the underlying web server process exits. Any call * to any other WebApp Library function after this function has been invoked * will result in impredictable results. * * @return <b>NULL</b> on success or an error message on faliure. */ const char *wa_destroy(void); /** * Allocate and set up a <code>wa_connection</code> member. * * @param c Where the pointer to where the <code>wa_connection</code> member * must be stored. * @param p The connection provider name. * @param a The connection argument from a configuration file. * @return <b>NULL</b> on success or an error message on faliure. */ const char *wa_connect(wa_connection **c, const char *p, const char *a); /** * Allocate, set up and deploy a <code>wa_application</code> member. * * @param a Where the pointer to where the <code>wa_application</code> member * must be stored. * @param c The <code>wa_connection</code> where the application is deployed. * @param n The application name. This parameter will be passed to the * application container as its unique selection key within its * array of deployable applications (for example the .war file name). * @param p The root URL path of the web application to deploy. * @return <b>NULL</b> on success or an error message on faliure. */ const char *wa_deploy(wa_application **a, wa_connection *c, const char *n, const char *p); #endif /* ifndef _WA_GENERAL_H_ */ 1.1 jakarta-tomcat-4.0/connectors/include/wa_provider.h Index: wa_provider.h =================================================================== /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2001 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * 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 acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "WebApp", 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 <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names 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 indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /** * @package WebApp General Package * @author Pier Fumagalli <mailto:[EMAIL PROTECTED]> * @version $Id: wa_provider.h,v 1.1 2001/04/17 13:13:49 pier Exp $ */ #ifndef _WA_GENERAL_H_ #define _WA_GENERAL_H_ /** * The WebApp Library connection provider structure. * <br> * This structure contains all data and function pointers to be implemented * by a connection provider. */ struct wa_provider { /** * The name of this provider. */ const char *name; /** * The version of this provider. */ const char *vers; /** * The description of this provider. */ const char *desc; /** * Configure a connection with the parameter from the web server * configuration file. * * @param conn The connection to configure. * @param param The extra parameter from web server configuration. * @return An error message or NULL. */ const char *(*connect)(wa_connection *conn, char *param); /** * Configure a connection with the parameter from the web server * configuration file. * * @param conn The connection to configure. * @param param The extra parameter from web server configuration. * @return An error message or NULL. */ const char *(*deploy)(wa_application *appl); /** * Initialize a provider. * * @return An error message or NULL. */ const char *(*init)(void); /** * Cleans up all resources allocated by the provider. * * @return An error message or NULL. */ const char *(*destroy)(void); /** * Describe the configuration member found in a connection. * * @param conn The connection for wich a description must be produced. * @param buf The buffer where the description must be stored. * @param len The buffer length. * @return The number of bytes written to the buffer (terminator included). */ int (*conninfo) (wa_connection *conn, char *buf, int len); /** * Describe the configuration member found in a web application. * * @param appl The application for wich a description must be produced. * @param buf The buffer where the description must be stored. * @param len The buffer length. * @return The number of bytes written to the buffer (terminator included). */ int (*applinfo) (wa_application *appl, char *buf, int len); /** * Handle a connection from the web server. * * @param req The request data. */ void (*handle) (wa_request *req); }; #endif /* ifndef _WA_GENERAL_H_ */ 1.1 jakarta-tomcat-4.0/connectors/include/wa_request.h Index: wa_request.h =================================================================== /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2001 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * 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 acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "WebApp", 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 <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names 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 indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /** * @package WebApp Request Package * @author Pier Fumagalli <mailto:[EMAIL PROTECTED]> * @version $Id: wa_request.h,v 1.1 2001/04/17 13:13:50 pier Exp $ */ #ifndef _WA_REQUEST_H_ #define _WA_REQUEST_H_ /* The host description data type. */ typedef struct wa_hostdata wa_hostdata; /** * The host description structure. */ struct wa_hostdata { /** * The host name. */ char *host; /** * The host address (as string so that we don't have to deal with * IPv4/IPv6 differences). */ char *addr; /** * The port number. */ int port; }; /** * The WebApp Library HTTP request structure. * <br> * This structure encapsulates an HTTP request to be handled within the scope * of one of the configured applications. */ struct wa_request { /** * The APR memory pool where this request is allocated. */ apr_pool_t *pool; /* The web-server specific callback data passed when the functions * specified in the <code>wa_callback</code> structure given at * initialization are accessed. */ void *data; /** * The HTTP method (ex. GET, POST...). */ char *meth; /** * The HTTP request URI (ex. /webapp/index.html). */ char *ruri; /** * The URL-encoded list of HTTP query arguments from the request. */ char *args; /** * The HTTP protocol name and version (ex. HTTP/1.0, HTTP/1.1...). */ char *prot; /** * The HTTP request URL scheme (the part before ://, ex http, https). */ char *schm; /** * The server host data. */ wa_hostdata *serv; /** * The client host data. */ wa_hostdata *clnt; /** * The remote user name, if this request was authenticated by the web * server, or <b>NULL</b>. */ char *user; /** * The authentication method used by the web server to authenticate the * remote user, or <b>NULL</b>. */ char *auth; /** * The content length of this request. */ long clen; /** * The number of bytes read out of this request body. */ long rlen; /** * The current headers table. */ apr_table_t *hdrs; }; /** * Attempt to match an URL against a web application. * <br> * This function will return <b>TRUE</b> only if the root URL path of the * application matches the beginning of the specified URL. * * @param u The request URL to be matched against the web application. * @param a The application against which the URL must be matched. * @return <b>TRUE</b> if the URL can be handled by the web application without * raising a "404 Not Found" error, <b>FALSE</b> otherwise. */ boolean wa_match(const char *u, wa_application *a); /** * Invoke a request in a web application. * <br> * @param r The WebApp Library request structure. * @return The HTTP result code of this operation. */ int wa_invoke(wa_request *r, wa_application *a); #endif /* ifndef _WA_REQUEST_H_ */