pier        00/12/06 03:21:14

  Modified:    connectors Makedefs.orig Makefile
               connectors/apache-1.3 Makefile mod_webapp.c
               connectors/webapplib Makefile wa.c wa.h wa_callback.c
                        wa_callback.h wa_connection.c wa_connection.h
                        wa_host.c wa_provider.c wa_provider.h
                        wa_provider_info.c wa_provider_warp.c wa_request.c
                        wa_request.h
  Log:
  Modified wa_request structure to store new request items.
  Modified how callbacks work from a WebAppLib perspective.
  Added a new callback (serverinfo).
  The wa_provider_info now dumps more interesting informations.
  Disabled warp since it makes the Apache process go around in loop. (Will fix)
  Modified how the library should be initialized.
  Fixed a couple of memory leaks (after 50.000 requests the process doesn't grow)
  Documented a couple of functions left undocumented.
  Added mapping on how servlet methods are reflected in the library.
  Added name and version.
  
  Revision  Changes    Path
  1.3       +2 -3      jakarta-tomcat-4.0/connectors/Makedefs.orig
  
  Index: Makedefs.orig
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/Makedefs.orig,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makedefs.orig     2000/11/29 09:01:34     1.2
  +++ Makedefs.orig     2000/12/06 11:20:13     1.3
  @@ -55,16 +55,15 @@
   #                                                                           #
   # ========================================================================= #
   
  -# CVS $Id: Makedefs.orig,v 1.2 2000/11/29 09:01:34 pier Exp $
  +# CVS $Id: Makedefs.orig,v 1.3 2000/12/06 11:20:13 pier Exp $
   # Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   CC       = gcc
   AR       = ar
   APXS     = apxs
  -CFLAGS   = -O6 -Wall -Wstrict-prototypes
  +CFLAGS   = -O6 -Wall -Wstrict-prototypes # -DDEBUG
   INCLUDES = -I../webapplib
   LIBS     = -L../webapplib -lwebapp
   
   .c.o:
        $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
  -
  
  
  
  1.2       +13 -6     jakarta-tomcat-4.0/connectors/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/Makefile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile  2000/11/29 09:01:34     1.1
  +++ Makefile  2000/12/06 11:20:16     1.2
  @@ -55,7 +55,7 @@
   #                                                                           #
   # ========================================================================= #
   
  -# CVS $Id: Makefile,v 1.1 2000/11/29 09:01:34 pier Exp $
  +# CVS $Id: Makefile,v 1.2 2000/12/06 11:20:16 pier Exp $
   # Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   DIRS =    webapplib apache-1.3
  @@ -63,7 +63,15 @@
   
   all: Makedefs $(MODULES)
   
  -recompile: clean all
  +recompile:
  +     @echo "$(MAKE): ***"
  +     @echo "$(MAKE): *** Cleaning up previous compilation"
  +     @echo "$(MAKE): ***"
  +     @$(MAKE) clean
  +     @echo "$(MAKE): ***"
  +     @echo "$(MAKE): *** Recompiling from sources"
  +     @echo "$(MAKE): ***"
  +     @$(MAKE) all
   
   Makedefs:
        @cp Makedefs.orig Makedefs
  @@ -71,10 +79,10 @@
        @exit 1
   
   webapplib/libwebapp.a: Makedefs
  -     @make -C webapplib libwebapp.a
  +     @$(MAKE) -C webapplib libwebapp.a
   
   apache-1.3/mod_webapp.so: Makedefs webapplib/libwebapp.a
  -     @make -C apache-1.3 mod_webapp.so
  +     @$(MAKE) -C apache-1.3 mod_webapp.so
   
   clean: Makedefs
        @for DIR in $(DIRS) ; do \
  @@ -82,7 +90,7 @@
                        echo "$(MAKE): *** Cannot find directory '$$DIR'" ; \
                        exit 1 ; \
                fi ; \
  -             make -C $$DIR clean ; \
  +             $(MAKE) -C $$DIR clean ; \
                RET="$$?" ; \
                if [ "$$RET" != "0" ] ; then \
                        exit $$RET ; \
  @@ -91,4 +99,3 @@
   
   distclean: clean
        rm -f Makedefs
  -
  
  
  
  1.2       +1 -2      jakarta-tomcat-4.0/connectors/apache-1.3/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/apache-1.3/Makefile,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile  2000/11/29 09:01:36     1.1
  +++ Makefile  2000/12/06 11:20:23     1.2
  @@ -55,7 +55,7 @@
   #                                                                           #
   # ========================================================================= #
   
  -# CVS $Id: Makefile,v 1.1 2000/11/29 09:01:36 pier Exp $
  +# CVS $Id: Makefile,v 1.2 2000/12/06 11:20:23 pier Exp $
   # Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   include ../Makedefs
  @@ -67,4 +67,3 @@
   
   clean:
        rm -f mod_webapp.o mod_webapp.so
  -
  
  
  
  1.5       +154 -89   jakarta-tomcat-4.0/connectors/apache-1.3/mod_webapp.c
  
  Index: mod_webapp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/apache-1.3/mod_webapp.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_webapp.c      2000/11/29 12:22:43     1.4
  +++ mod_webapp.c      2000/12/06 11:20:25     1.5
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: mod_webapp.c,v 1.4 2000/11/29 12:22:43 pier Exp $
  +// CVS $Id: mod_webapp.c,v 1.5 2000/12/06 11:20:25 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <httpd.h>
  @@ -75,7 +75,9 @@
   /* Module declaration */
   module webapp_module;
   /* Callback structure declaration */
  -static wa_callbacks webapp_callbacks;
  +static wa_callback webapp_callbacks;
  +/* Our server (used to log error messages from the library) */
  +static server_rec *webapp_server=NULL;
   
   
   /* ************************************************************************* */
  @@ -168,8 +170,10 @@
    * @param r The Apache request structure.
    */
   static int webapp_handler(request_rec *r) {
  -    const char *message=NULL;
  +    conn_rec *c = r->connection;
  +    const char *msg=NULL;
       wa_request *req=NULL;
  +    int ret=0;
   
       // Try to get a hold on the webapp request structure
       req=(wa_request *)ap_get_module_config(r->request_config, &webapp_module);
  @@ -181,6 +185,15 @@
       req->ruri=r->uri;
       req->args=r->args;
       req->prot=r->protocol;
  +    req->schm=ap_http_method(r);
  +    req->name=(char *)r->hostname;
  +    req->port=ap_get_server_port(r);
  +    req->rhst=(char *)ap_get_remote_host(c, r->per_dir_config, REMOTE_HOST);
  +    req->radr=c->remote_ip;
  +    req->user=c->user;
  +    req->auth=c->ap_auth_type;
  +    req->clen=0;
  +    req->rlen=0;
   
       // Copy headers into webapp request structure
       if (r->headers_in!=NULL) {
  @@ -199,20 +212,25 @@
               if (ele[x].key==NULL) continue;
               req->hnam[x]=ele[x].key;
               req->hval[x]=ele[x].val;
  +            if (strcasecmp(ele[x].key,"Content-Length")==0)
  +                req->clen=atol(req->hval[x]);
           }
       } else {
  -        fprintf(stderr,"NO HEADERS\n");
           req->hnum=0;
           req->hnam=NULL;
           req->hval=NULL;
       }
   
  +    // Check if we can read something from the request
  +    ret=ap_setup_client_block(r,REQUEST_CHUNKED_DECHUNK);
  +    if (ret!=OK) return(ret);
  +
       // Try to handle the request
  -    message=wa_request_handle(req,&webapp_callbacks);
  +    msg=wa_request_handle(req);
   
       // We got an error message (critical error, not from providers)
  -    if (message!=NULL) {
  -        ap_log_error(APLOG_MARK,APLOG_CRIT,r->server,"%s",message);
  +    if (msg!=NULL) {
  +        ap_log_error(APLOG_MARK,APLOG_NOERRNO|APLOG_ERR,r->server,"%s",msg);
           return(HTTP_INTERNAL_SERVER_ERROR);
       }
   
  @@ -220,14 +238,14 @@
   }
   
   /**
  - * Initialize webapp connections.
  + * Initialize the webapp library.
    *
    * @param s The server_rec structure associated with the main server.
    * @param p The pool for memory allocation (it never gets cleaned).
    */
  -static void webapp_exit(server_rec *s, pool *p) {
  -    // Destroy connections
  -    wa_connection_destroy();
  +static void webapp_init(server_rec *s, pool *p) {
  +    webapp_server=s;
  +    wa_init(&webapp_callbacks);
   }
   
   /**
  @@ -236,9 +254,8 @@
    * @param s The server_rec structure associated with the main server.
    * @param p The pool for memory allocation (it never gets cleaned).
    */
  -static void webapp_init(server_rec *s, pool *p) {
  -    // Initialize connections
  -    wa_connection_init();
  +static void webapp_exit(server_rec *s, pool *p) {
  +    wa_destroy();
   }
   
   /* ************************************************************************* */
  @@ -246,80 +263,141 @@
   /* ************************************************************************* */
   
   /**
  - * Log data on the web server log file.
  + * Add a component to the the current SERVER_SOFTWARE string and return the
  + * new value.
    *
  - * @param file The source file of this log entry.
  - * @param line The line number within the source file of this log entry.
  - * @param data The web-server specific data (wa_request->data).
  - * @param fmt The format string (printf style).
  - * @param ... All other parameters (if any) depending on the format.
  - */
  -static void webapp_callback_log(void *data, const char *file, int line,
  -                                const char *fmt, ...) {
  -    request_rec *r=(request_rec *)data;
  -    va_list ap;
  + * @param component The new component to add to the SERVER_SOFTWARE string
  + *                  or NULL if no modification is necessary.
  + * @return The updated SERVER_SOFTWARE string.
  + */
  +const char *webapp_callback_serverinfo(const char *component) {
  +    const char *ret=NULL;
   
  -    va_start (ap,fmt);
  -    if (r==NULL) {
  -        fprintf(stderr,"[%s:%d] ",file,line);
  -        vfprintf(stderr,fmt,ap);
  -        fprintf(stderr,"\n");
  +    if (component!=NULL) ap_add_version_component(component);
  +
  +    ret=ap_get_server_version();
  +    if (ret==NULL) return("Unknown");
  +    return(ret);
  +}
  +
  +/**
  + * Print a debug or log message to the apache error log file.
  + *
  + * @param f The source file of this log entry.
  + * @param l The line number within the source file of this log entry.
  + * @param r The wa_request structure associated with the current request,
  + *          or NULL.
  + * @param msg The message to be logged.
  + */
  +static void webapp_callback_log(const char *f,int l,wa_request *r,char *msg) {
  +    server_rec *s=webapp_server;
  +
  +    // Try to get the current request server_rec member.
  +    if (r!=NULL)
  +        if (r->data!=NULL)
  +            s=((request_rec *)r->data)->server;
  +
  +    if (s==NULL) {
  +        // We don't yet know our server_rec, simply dump to stderr and hope :)
  +#ifdef DEBUG
  +        fprintf(stderr,"[%s:%l] %s\n",f,l,msg);
  +#else
  +        fprintf(stderr,"%s\n",msg);
  +#endif
       } else {
  -        char *message=ap_pvsprintf(r->pool,fmt,ap);
  -        ap_log_error(file,line,APLOG_ERR,r->server,"%s",message);
  +#ifdef DEBUG
  +        // We are debugging, so we want to make sure that file and line are in
  +        // our error message.
  +        ap_log_error(f,l,APLOG_NOERRNO|APLOG_ERR,s,"[%s:%l] %s",f,l,msg);
  +#else
  +        // We are not debugging, so let Apache handle the file and line
  +        ap_log_error(f,l,APLOG_NOERRNO|APLOG_ERR,s,"%s",msg);
  +#endif
       }
   }
   
   /**
  + * Return the current request_rec structure from a wa_request structure and log
  + * if we weren't able to retrieve it.
  + *
  + * @param f The file from where this function was called.
  + * @param l The line from where this function was called.
  + * @param r The wa_request structure.
  + * @return A request_rec pointer or NULL.
  + */
  +static request_rec *webapp_callback_check(const char *f,int l,wa_request *r) {
  +    if (r==NULL) {
  +        webapp_callback_log(f,l,r, "Invalid wa_request member (NULL)");
  +        return(NULL);
  +    }
  +    if (r->data==NULL) {
  +        webapp_callback_log(f,l,r, "Invalid wa_request->data member (NULL)");
  +        return(NULL);
  +    }
  +    return((request_rec *)r->data);
  +}
  +
  +/**
    * Allocate memory while processing a request.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @param size The size in bytes of the memory to allocate.
    * @return A pointer to the allocated memory or NULL.
    */
  -static void *webapp_callback_alloc(void *data, int size) {
  -    request_rec *r=(request_rec *)data;
  +static void *webapp_callback_alloc(wa_request *req, int size) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(NULL);
  -    }
  +    if (r==NULL) return(NULL);
       return(ap_palloc(r->pool,size));
   }
   
   /**
    * Read part of the request content.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @param buf The buffer that will hold the data.
    * @param len The buffer length.
    * @return The number of bytes read, 0 on end of file or -1 on error.
    */
  -static int webapp_callback_read(void *data, char *buf, int len) {
  -    request_rec *r=(request_rec *)data;
  -
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  +static int webapp_callback_read(wa_request *req, char *buf, int len) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
  +    long ret=0;
  +
  +    if (r==NULL) return(-1);
  +
  +    // Check if we have something to read.
  +    if (req->clen==0) return(0);
  +
  +    // Check if we had an error previously.
  +    if (req->rlen==-1) return(-1);
  +
  +    // Send HTTP_CONTINUE to client when we're ready to read for the first time.
  +    if (req->rlen==0)
  +        if (ap_should_client_block(r)==0) return(0);
  +
  +    // Read some data from the client and fill the buffer.
  +    ret=ap_get_client_block(r,buf,len);
  +    if (ret==-1) {
  +        req->rlen=-1;
           return(-1);
       }
   
  -    return((int)ap_get_client_block(r,buf,len));
  +    // We did read some bytes, increment the current rlen counter and return.
  +    req->rlen+=ret;
  +    return((int)ret);
   }
   
   /**
    * Set the HTTP response status code.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @param status The HTTP status code for the response.
    * @return TRUE on success, FALSE otherwise
    */
  -static boolean webapp_callback_setstatus(void *data, int status) {
  -    request_rec *r=(request_rec *)data;
  +static boolean webapp_callback_setstatus(wa_request *req, int status) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(FALSE);
   
       r->status=status;
       return(TRUE);
  @@ -328,17 +406,14 @@
   /**
    * Set the HTTP response mime content type.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @param type The mime content type of the HTTP response.
    * @return TRUE on success, FALSE otherwise
    */
  -static boolean webapp_callback_settype(void *data, char *type) {
  -    request_rec *r=(request_rec *)data;
  +static boolean webapp_callback_settype(wa_request *req, char *type) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(FALSE);
   
       r->content_type=type;
       return(TRUE);
  @@ -347,18 +422,16 @@
   /**
    * Set an HTTP mime header.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @param name The mime header name.
    * @param value The mime header value.
    * @return TRUE on success, FALSE otherwise
    */
  -static boolean webapp_callback_setheader(void *data, char *name, char *value) {
  -    request_rec *r=(request_rec *)data;
  +static boolean webapp_callback_setheader(wa_request *req, char *name,
  +                                         char *value) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(FALSE);
   
       ap_table_add(r->headers_out, name, value);
       return(TRUE);
  @@ -367,16 +440,13 @@
   /**
    * Commit the first part of the response (status and headers).
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @return TRUE on success, FALSE otherwise
    */
  -static boolean webapp_callback_commit(void *data) {
  -    request_rec *r=(request_rec *)data;
  +static boolean webapp_callback_commit(wa_request *req) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(FALSE);
   
       ap_send_http_header(r);
       return(TRUE);
  @@ -385,17 +455,14 @@
   /**
    * Write part of the response data back to the client.
    *
  - * @param buf The buffer holding the data to be written.
  + * @param req The request member associated with this call.
    * @param len The number of characters to be written.
    * @return The number of characters written to the client or -1 on error.
    */
  -static int webapp_callback_write(void *data, char *buf, int len) {
  -    request_rec *r=(request_rec *)data;
  +static int webapp_callback_write(wa_request *req, char *buf, int len) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(-1);
   
       return(ap_rwrite(buf, len, r));
   }
  @@ -403,16 +470,13 @@
   /**
    * Flush any unwritten response data to the client.
    *
  - * @param data The web-server specific data (wa_request->data).
  + * @param req The request member associated with this call.
    * @return TRUE on success, FALSE otherwise
    */
  -static boolean webapp_callback_flush(void *data) {
  -    request_rec *r=(request_rec *)data;
  +static boolean webapp_callback_flush(wa_request *req) {
  +    request_rec *r=webapp_callback_check(WA_LOG,req);
   
  -    if (r==NULL) {
  -        webapp_callback_log(r,WA_LOG,"Apache request_rec pointer is NULL");
  -        return(FALSE);
  -    }
  +    if (r==NULL) return(FALSE);
   
       ap_rflush(r);
       return(TRUE);
  @@ -424,7 +488,8 @@
   /* ************************************************************************* */
   
   /* Our callback functions structure */
  -static wa_callbacks webapp_callbacks = {
  +static wa_callback webapp_callbacks = {
  +    webapp_callback_serverinfo,
       webapp_callback_log,
       webapp_callback_alloc,
       webapp_callback_read,
  
  
  
  1.4       +3 -4      jakarta-tomcat-4.0/connectors/webapplib/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/Makefile,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile  2000/11/29 12:22:57     1.3
  +++ Makefile  2000/12/06 11:20:30     1.4
  @@ -55,13 +55,13 @@
   #                                                                           #
   # ========================================================================= #
   
  -# CVS $Id: Makefile,v 1.3 2000/11/29 12:22:57 pier Exp $
  +# CVS $Id: Makefile,v 1.4 2000/12/06 11:20:30 pier Exp $
   # Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   include ../Makedefs
   
  -OBJS = wa_callback.o wa_connection.o wa_host.o wa_provider.o wa_request.o \
  -       wa_provider_info.o wa_provider_warp.o
  +OBJS = wa.o wa_callback.o wa_connection.o wa_host.o wa_request.o \
  +       wa_provider.o wa_provider_info.o # wa_provider_warp.o
   
   all: libwebapp.a
   
  @@ -70,4 +70,3 @@
   
   clean:
        rm -f $(OBJS) libwebapp.a
  -
  
  
  
  1.3       +48 -4     jakarta-tomcat-4.0/connectors/webapplib/wa.c
  
  Index: wa.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- wa.c      2000/11/27 03:49:14     1.2
  +++ wa.c      2000/12/06 11:20:31     1.3
  @@ -55,9 +55,53 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa.c,v 1.2 2000/11/27 03:49:14 pier Exp $
  +// CVS $Id: wa.c,v 1.3 2000/12/06 11:20:31 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
  -int main(int argc, char *argv[]) {
  -    return(0);
  -}
  \ No newline at end of file
  +#include <wa.h>
  +
  +/**
  + * Initialize the webapp library and all connections.
  + *
  + * @param cb The wa_callback structure specified by the web server.
  + */
  +void wa_init(wa_callback *cb) {
  +    wa_connection *curr=wa_connections;
  +    const char *ret;
  +
  +    // Set our callbacks structure
  +    if (cb==NULL) return;
  +    wa_callbacks=cb;
  +
  +    // Set the SERVER_SOFTWARE string.
  +    wa_callback_serverinfo(WA_NAME "/" WA_VERSION);
  +
  +    // Iterate thru our connections chain
  +    while(curr!=NULL) {
  +        ret=(*curr->prov->init)(curr);
  +        if (ret!=NULL) wa_callback_log(WA_LOG,NULL,ret);
  +        else wa_callback_debug(WA_LOG,NULL,"Connection \"%s\" initialized",
  +                                curr->name);
  +        curr=curr->next;
  +    }
  +    return;
  +}
  +
  +/**
  + * Reset the webapp library and all connections.
  + */
  +void wa_destroy(void) {
  +    wa_connection *curr=wa_connections;
  +    const char *ret;
  +
  +    // Iterate thru our hosts chain
  +    while(curr!=NULL) {
  +        ret=(*curr->prov->destroy)(curr);
  +        if (ret!=NULL) wa_callback_log(WA_LOG,NULL,ret);
  +        else wa_callback_debug(WA_LOG,NULL,"Connection \"%s\" destroyed",
  +                                curr->name);
  +        curr=curr->next;
  +    }
  +
  +    wa_callbacks=NULL;
  +}
  
  
  
  1.6       +40 -2     jakarta-tomcat-4.0/connectors/webapplib/wa.h
  
  Index: wa.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- wa.h      2000/11/30 17:39:08     1.5
  +++ wa.h      2000/12/06 11:20:33     1.6
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa.h,v 1.5 2000/11/30 17:39:08 pier Exp $
  +// CVS $Id: wa.h,v 1.6 2000/12/06 11:20:33 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #ifndef _WA_H_
  @@ -69,11 +69,20 @@
   #include <string.h>
   #include <netdb.h>
   #include <errno.h>
  +#include <time.h>
   #include <sys/errno.h>
   #include <sys/types.h>
   #include <sys/socket.h>
   #include <netinet/in.h>
   
  +/* Our name and version */
  +#ifndef WA_NAME
  +#define WA_NAME "WebApp"
  +#endif
  +#ifndef WA_VERSION
  +#define WA_VERSION "0.5-dev"
  +#endif
  +
   /* Define TRUE and FALSE */
   #ifndef TRUE
   #define TRUE 1
  @@ -94,7 +103,7 @@
   typedef struct wa_provider wa_provider;
   typedef struct wa_header wa_header;
   typedef struct wa_request wa_request;
  -typedef struct wa_callbacks wa_callbacks;
  +typedef struct wa_callback wa_callback;
   
   /* Other includes from the webapp lib */
   #include <wa_host.h>
  @@ -103,4 +112,33 @@
   #include <wa_request.h>
   #include <wa_callback.h>
   
  +/* Function prototype declaration */
  +// Initialize the webapp library and all connections.
  +void wa_init(wa_callback *);
  +// Reset the webapp library and all connections.
  +void wa_destroy(void);
  +
  +//
   #endif // ifdef _WA_H_
  +
  +/* Where are the different servlet methods in our wa_request structure?
  + * (Comparison between methods, CGI variables and wa_request pointers
  + *
  + *   c.getServerInfo()       SERVER_SOFTWARE         wa_callback->serverinfo()
  + *   r.getProtocol()         SERVER_PROTOCOL         r->prot
  + *   r.getMethod()           REQUEST_METHOD          r->meth
  + *   r.getScheme()           -                       r->schm
  + *   r.getQueryString()      QUERY_STRING            r->args
  + *   r.getPathInfo()         PATH_INFO               -
  + *   r.getPathTranslated()   PATH_TRANSLATED         -
  + *   r.getServletPath()      SCRIPT_NAME             -
  + *   r.isSecure()            -                       -
  + *   r.getContentType()      CONTENT_TYPE            [header]
  + *   r.getContentLength()    CONTENT_LENGTH          r->clen
  + *   r.getServerName()       SERVER_NAME             r->name
  + *   r.getServerPort()       SERVER_PORT             r->port
  + *   r.getRemoteHost()       REMOTE_HOST             r->rhst
  + *   r.getRemoteAddr()       REMOTE_ADDR             r->radr
  + *   r.getRemoteUser()       REMOTE_USER             r->user
  + *   r.getAuthType()         AUTH_TYPE               r->auth
  + */
  
  
  
  1.3       +247 -34   jakarta-tomcat-4.0/connectors/webapplib/wa_callback.c
  
  Index: wa_callback.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_callback.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- wa_callback.c     2000/11/30 17:34:15     1.2
  +++ wa_callback.c     2000/12/06 11:20:34     1.3
  @@ -55,64 +55,277 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_callback.c,v 1.2 2000/11/30 17:34:15 pier Exp $
  +// CVS $Id: wa_callback.c,v 1.3 2000/12/06 11:20:34 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
   
  -// Allocate memory while processing a request.
  -void *wa_callback_alloc(wa_callbacks *c, wa_request *r, int size) {
  -    return((*c->alloc)(r->data, size));
  +/* The list of configured hosts */
  +wa_callback *wa_callbacks=NULL;
  +
  +/**
  + * Add a component to the the current SERVER_SOFTWARE string and return the
  + * new value.
  + *
  + * @param component The new component to add to the SERVER_SOFTWARE string
  + *                  or NULL if no modification is necessary.
  + * @return The updated SERVER_SOFTWARE string.
  + */
  +const char *wa_callback_serverinfo(const char *component) {
  +    if (wa_callbacks==NULL) return("Unknown");
  +    return((*wa_callbacks->serverinfo)(component));
  +}
  +
  +/**
  + * Log data on the web server log file.
  + *
  + * @param f The source file of this log entry.
  + * @param l The line number within the source file of this log entry.
  + * @param r The wa_request structure associated with the current request,
  + *          or NULL.
  + * @param fmt The format string (printf style).
  + * @param ... All other parameters (if any) depending on the format.
  + */
  +void wa_callback_log(const char *f,int l,wa_request *r,const char *fmt,...) {
  +    va_list ap;
  +    char buf[1024];
  +    int ret;
  +
  +    if (wa_callbacks==NULL) return;
  +
  +    va_start(ap,fmt);
  +    ret=vsnprintf(buf,1024,fmt,ap);
  +    if (ret<1) {
  +        (*wa_callbacks->log)(WA_LOG,r,"Cannot format log message");
  +    } else if (ret>1023) {
  +        (*wa_callbacks->log)(WA_LOG,r,"Log message too long");
  +    } else {
  +        (*wa_callbacks->log)(f,l,r,buf);
  +    }
  +    va_end(ap);
  +}
  +
  +/**
  + * Log debugging informations data on the web server log file.
  + *
  + * @param f The source file of this log entry.
  + * @param l The line number within the source file of this log entry.
  + * @param r The wa_request structure associated with the current request,
  + *          or NULL.
  + * @param fmt The format string (printf style).
  + * @param ... All other parameters (if any) depending on the format.
  + */
  +void wa_callback_debug(const char *f,int l,wa_request *r,const char *fmt,...) {
  +#ifdef DEBUG
  +    va_list ap;
  +    char buf[1024];
  +    int ret;
  +
  +    if (wa_callbacks==NULL) return;
  +
  +    va_start(ap,fmt);
  +    ret=vsnprintf(buf,1024,fmt,ap);
  +    if (ret<1) {
  +        wa_callback_log(WA_LOG,r,"[%s:%d] Cannot format log message",WA_LOG);
  +    } else if (ret>1023) {
  +        wa_callback_log(WA_LOG,r,"[%s:%d] Log message too long",WA_LOG);
  +    } else {
  +        wa_callback_log(f,l,r,"[%s:%d] %s",f,l,buf);
  +    }
  +    va_end(ap);
  +#endif
  +}
  +
  +/**
  + * Allocate memory while processing a request. (The memory allocated by
  + * this fuction must be released after the request is processed).
  + *
  + * @param r The request member associated with this call.
  + * @param size The size in bytes of the memory to allocate.
  + * @return A pointer to the allocated memory or NULL.
  + */
  +void *wa_callback_alloc(wa_request *r, int size) {
  +    if (wa_callbacks==NULL) return(NULL);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(NULL);
  +    }
  +    return((*wa_callbacks->alloc)(r, size));
   }
   
  -// Read part of the request content.
  -int wa_callback_read(wa_callbacks *c, wa_request *r, char *buf, int size) {
  -    return((*c->read)(r->data,buf,size));
  +/**
  + * Read part of the request content.
  + *
  + * @param r The request member associated with this call.
  + * @param buf The buffer that will hold the data.
  + * @param size The buffer length.
  + * @return The number of bytes read, 0 on end of file or -1 on error.
  + */
  +int wa_callback_read(wa_request *r, char *buf, int size) {
  +    if (wa_callbacks==NULL) return(-1);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(-1);
  +    }
  +    return((*wa_callbacks->read)(r,buf,size));
   }
   
  -// Set the HTTP response status code.
  -boolean wa_callback_setstatus(wa_callbacks *c, wa_request *r, int status) {
  -    return((*c->setstatus)(r->data,status));
  +/**
  + * Set the HTTP response status code.
  + *
  + * @param r The request member associated with this call.
  + * @param status The HTTP status code for the response.
  + * @return TRUE on success, FALSE otherwise
  + */
  +boolean wa_callback_setstatus(wa_request *r, int status) {
  +    if (wa_callbacks==NULL) return(FALSE);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +    return((*wa_callbacks->setstatus)(r,status));
   }
   
  -// Set the HTTP response mime content type.
  -boolean wa_callback_settype(wa_callbacks *c, wa_request *r, char *type) {
  -    return((*c->settype)(r->data,type));
  +/**
  + * Set the HTTP response mime content type.
  + *
  + * @param r The request member associated with this call.
  + * @param type The mime content type of the HTTP response.
  + * @return TRUE on success, FALSE otherwise
  + */
  +boolean wa_callback_settype(wa_request *r, char *type) {
  +    if (wa_callbacks==NULL) return(FALSE);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +    return((*wa_callbacks->settype)(r,type));
   }
   
  -// Set an HTTP mime header.
  -boolean wa_callback_setheader(wa_callbacks *c,wa_request *r,char *n,char *v) {
  -    return((*c->setheader)(r->data,n,v));
  +/**
  + * Set an HTTP mime header.
  + *
  + * @param r The request member associated with this call.
  + * @param n The mime header name.
  + * @param v The mime header value.
  + * @return TRUE on success, FALSE otherwise
  + */
  +boolean wa_callback_setheader(wa_request *r, char *n, char *v) {
  +    if (wa_callbacks==NULL) return(FALSE);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +    return((*wa_callbacks->setheader)(r,n,v));
   }
   
  +
  +/**
  + * Commit the first part of the response (status and headers).
  + *
  + * @param r The request member associated with this call.
  + * @return TRUE on success, FALSE otherwise
  + */
  +boolean wa_callback_commit(wa_request *r) {
  +    if (wa_callbacks==NULL) return(FALSE);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +    return((*wa_callbacks->commit)(r));
  +}
   
  -// Commit the first part of the response (status and headers).
  -boolean wa_callback_commit(wa_callbacks *c, wa_request *r) {
  -    return((*c->commit)(r->data));
  +/**
  + * Write part of the response data back to the client.
  + *
  + * @param r The request member associated with this call.
  + * @param buf The buffer containing the data to be written.
  + * @param len The number of characters to be written.
  + * @return The number of characters written to the client or -1 on error.
  + */
  +int wa_callback_write(wa_request *r, char *buf, int size) {
  +    if (wa_callbacks==NULL) return(-1);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(-1);
  +    }
  +    return((*wa_callbacks->write)(r,buf,size));
   }
   
  -// Write part of the response data back to the client.
  -int wa_callback_write(wa_callbacks *c, wa_request *r, char *buf, int size) {
  -    return((*c->write)(r->data,buf,size));
  +/**
  + * Flush any unwritten response data to the client.
  + *
  + * @param r The request member associated with this call.
  + * @return TRUE on success, FALSE otherwise
  + */
  +boolean wa_callback_flush(wa_request *r) {
  +    if (wa_callbacks==NULL) return(FALSE);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +    return((*wa_callbacks->flush)(r));
   }
   
  -// Write part of the response data back to the client.
  -int wa_callback_printf(wa_callbacks *c, wa_request *r, const char *fmt, ...) {
  +/**
  + * Print a message back to the client using the printf standard.
  + *
  + * @param r The request member associated with this call.
  + * @param fmt The format string (printf style).
  + * @param ... All other parameters (if any) depending on the format.
  + * @return The number of characters written to the client or -1 on error.
  + */
  +int wa_callback_printf(wa_request *r, const char *fmt, ...) {
       va_list ap;
  -    char buf[1024];
  +    char *buf=NULL;
       int ret;
   
  +    if (wa_callbacks==NULL) return(-1);
  +    if (r==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Null wa_request member specified");
  +        return(FALSE);
  +    }
  +
  +    // Allocate some data for the buffer
  +    buf=(char *)(*wa_callbacks->alloc)(r,1024*sizeof(char));
  +    if (buf==NULL) {
  +        wa_callback_debug(WA_LOG,r,"Cannot allocate buffer");
  +        return(-1);
  +    }
  +
  +    // Check if we can write some data.
  +    if (wa_callbacks==NULL) {
  +        return(-1);
  +    }
  +
  +    // Try to fill our buffer with printf data
       va_start(ap,fmt);
       ret=vsnprintf(buf,1024,fmt,ap);
  -    va_end(ap);
   
  -    if (ret<0) return(-1);
  +    // If vsnprintf returned null, we weren't able to format the message
  +    if (ret<0) {
  +        wa_callback_log(WA_LOG,r,"Cannot format message");
  +        va_end(ap);
  +        return(-1);
  +
  +    // If vsnprintf is greater than 1024 the buffer was too small
  +    } else if (ret>1024) {
  +        // Reallocate the buffer for the bigger message and check if we were
  +        // able to print the message.
  +        buf=(char *)(*wa_callbacks->alloc)(r,(ret+1)*sizeof(char));
  +        if (buf==NULL) {
  +            va_end(ap);
  +            wa_callback_debug(WA_LOG,r,"Cannot allocate buffer");
  +            return(-1);
  +        }
  +        ret=vsnprintf(buf,ret+1,fmt,ap);
  +        if (ret<0) {
  +            wa_callback_log(WA_LOG,r,"Cannot format message");
  +            va_end(ap);
  +            return(-1);
  +        }
  +    }
   
  -    return(wa_callback_write(c,r,buf,ret));
  -}
  -
  -// Flush any unwritten response data to the client.
  -boolean wa_callback_flush(wa_callbacks *c, wa_request *r) {
  -    return((*c->flush)(r->data));
  +    va_end(ap);
  +    return(wa_callback_write(r,buf,ret));
   }
  -
  
  
  
  1.2       +56 -35    jakarta-tomcat-4.0/connectors/webapplib/wa_callback.h
  
  Index: wa_callback.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_callback.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- wa_callback.h     2000/11/27 12:48:09     1.1
  +++ wa_callback.h     2000/12/06 11:20:35     1.2
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_callback.h,v 1.1 2000/11/27 12:48:09 pier Exp $
  +// CVS $Id: wa_callback.h,v 1.2 2000/12/06 11:20:35 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #ifndef _WA_CALLBACK_H_
  @@ -65,109 +65,130 @@
    * The wa_callbacks structure contains function pointers for callbacks to the
    * web server.
    */
  -struct wa_callbacks {
  +struct wa_callback {
       /**
  +     * Add a component to the the current SERVER_SOFTWARE string and return the
  +     * new value.
  +     *
  +     * @param component The new component to add to the SERVER_SOFTWARE string
  +     *                  or NULL if no modification is necessary.
  +     * @return The updated SERVER_SOFTWARE string.
  +     */
  +    const char *(*serverinfo)(const char *component);
  +
  +    /**
        * Log data on the web server log file.
        *
  -     * @param file The source file of this log entry.
  -     * @param line The line number within the source file of this log entry.
  -     * @param data The web-server specific data (wa_request->data).
  -     * @param fmt The format string (printf style).
  -     * @param ... All other parameters (if any) depending on the format.
  +     * @param f The source file of this log entry.
  +     * @param l The line number within the source file of this log entry.
  +     * @param r The wa_request structure associated with the current request,
  +     *          or NULL.
  +     * @param msg The message to be logged.
        */
  -    void (*log)(void *data, const char *file, int line, const char *fmt, ...);
  +    void (*log)(const char *f, int l, wa_request *r, char *msg);
   
       /**
  -     * Allocate memory while processing a request.
  +     * Allocate memory while processing a request. (The memory allocated by
  +     * this fuction must be released after the request is processed).
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @param size The size in bytes of the memory to allocate.
        * @return A pointer to the allocated memory or NULL.
        */
  -    void *(*alloc)(void *data, int size);
  +    void *(*alloc)(wa_request *req, int size);
   
       /**
        * Read part of the request content.
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @param buf The buffer that will hold the data.
        * @param len The buffer length.
        * @return The number of bytes read, 0 on end of file or -1 on error.
        */
  -    int (*read)(void *data, char *buf, int len);
  +    int (*read)(wa_request *req, char *buf, int len);
   
       /**
        * Set the HTTP response status code.
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @param status The HTTP status code for the response.
        * @return TRUE on success, FALSE otherwise
        */
  -    boolean (*setstatus)(void *data, int status);
  +    boolean (*setstatus)(wa_request *req, int status);
   
       /**
        * Set the HTTP response mime content type.
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @param type The mime content type of the HTTP response.
        * @return TRUE on success, FALSE otherwise
        */
  -    boolean (*settype)(void *data, char *type);
  +    boolean (*settype)(wa_request *req, char *type);
   
       /**
        * Set an HTTP mime header.
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @param name The mime header name.
        * @param value The mime header value.
        * @return TRUE on success, FALSE otherwise
        */
  -    boolean (*setheader)(void *data, char *name, char *value);
  +    boolean (*setheader)(wa_request *req, char *name, char *value);
   
       /**
        * Commit the first part of the response (status and headers).
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @return TRUE on success, FALSE otherwise
        */
  -    boolean (*commit)(void *data);
  +    boolean (*commit)(wa_request *req);
   
       /**
        * Write part of the response data back to the client.
        *
  -     * @param buf The buffer holding the data to be written.
  +     * @param req The request member associated with this call.
  +     * @param buf The buffer containing the data to be written.
        * @param len The number of characters to be written.
        * @return The number of characters written to the client or -1 on error.
        */
  -    int (*write)(void *data, char *buf, int len);
  +    int (*write)(wa_request *req, char *buf, int len);
   
       /**
        * Flush any unwritten response data to the client.
        *
  -     * @param data The web-server specific data (wa_request->data).
  +     * @param req The request member associated with this call.
        * @return TRUE on success, FALSE otherwise
        */
  -    boolean (*flush)(void *);
  +    boolean (*flush)(wa_request *req);
   };
   
  +/* The list of configured hosts */
  +extern wa_callback *wa_callbacks;
  +
   /* Function prototype declaration */
  +// Add a component to the the current SERVER_SOFTWARE string.
  +const char *wa_callback_serverinfo(const char *);
  +// Log data on the web server log file.
  +void wa_callback_log(const char *, int, wa_request *, const char *, ...);
  +// Log debugging informations data on the web server log file.
  +void wa_callback_debug(const char * ,int, wa_request *, const char *, ...);
   // Allocate memory while processing a request.
  -void *wa_callback_alloc(wa_callbacks *, wa_request *, int);
  +void *wa_callback_alloc(wa_request *, int);
   // Read part of the request content.
  -int wa_callback_read(wa_callbacks *, wa_request *, char *, int);
  +int wa_callback_read(wa_request *, char *, int);
   // Set the HTTP response status code.
  -boolean wa_callback_setstatus(wa_callbacks *, wa_request *, int);
  +boolean wa_callback_setstatus(wa_request *, int);
   // Set the HTTP response mime content type.
  -boolean wa_callback_settype(wa_callbacks *, wa_request *, char *);
  +boolean wa_callback_settype(wa_request *, char *);
   // Set an HTTP mime header.
  -boolean wa_callback_setheader(wa_callbacks *, wa_request *, char *, char *);
  +boolean wa_callback_setheader(wa_request *, char *, char *);
   // Commit the first part of the response (status and headers).
  -boolean wa_callback_commit(wa_callbacks *, wa_request *);
  -// Write part of the response data back to the client.
  -int wa_callback_write(wa_callbacks *, wa_request *, char *, int);
  +boolean wa_callback_commit(wa_request *);
   // Write part of the response data back to the client.
  -int wa_callback_printf(wa_callbacks *, wa_request *, const char *, ...);
  +int wa_callback_write(wa_request *, char *, int);
   // Flush any unwritten response data to the client.
  -boolean wa_callback_flush(wa_callbacks *, wa_request *);
  +boolean wa_callback_flush(wa_request *);
  +// Print a message back to the client using the printf standard.
  +int wa_callback_printf(wa_request *, const char *, ...);
   
   #endif // ifdef _WA_CALLBACK_H_
  
  
  
  1.3       +1 -28     jakarta-tomcat-4.0/connectors/webapplib/wa_connection.c
  
  Index: wa_connection.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_connection.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- wa_connection.c   2000/11/27 03:49:15     1.2
  +++ wa_connection.c   2000/12/06 11:20:37     1.3
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_connection.c,v 1.2 2000/11/27 03:49:15 pier Exp $
  +// CVS $Id: wa_connection.c,v 1.3 2000/12/06 11:20:37 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -134,30 +134,3 @@
       // No host found, sorry!
       return(NULL);
   }
  -
  -/**
  - * Initialize all configured connections.
  - */
  -void wa_connection_init(void) {
  -    wa_connection *curr=wa_connections;
  -
  -    // Iterate thru our hosts chain
  -    while(curr!=NULL) {
  -        (*curr->prov->init)(curr);
  -        curr=curr->next;
  -    }
  -}
  -
  -/**
  - * Initialize all configured connections.
  - */
  -void wa_connection_destroy(void) {
  -    wa_connection *curr=wa_connections;
  -
  -    // Iterate thru our hosts chain
  -    while(curr!=NULL) {
  -        (*curr->prov->destroy)(curr);
  -        curr=curr->next;
  -    }
  -}
  -
  
  
  
  1.3       +1 -5      jakarta-tomcat-4.0/connectors/webapplib/wa_connection.h
  
  Index: wa_connection.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_connection.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- wa_connection.h   2000/11/27 03:49:17     1.2
  +++ wa_connection.h   2000/12/06 11:20:37     1.3
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_connection.h,v 1.2 2000/11/27 03:49:17 pier Exp $
  +// CVS $Id: wa_connection.h,v 1.3 2000/12/06 11:20:37 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #ifndef _WA_CONNECTION_H_
  @@ -79,9 +79,5 @@
   const char *wa_connection_create(char *, char *, char *);
   // Get a specific webapp connection.
   wa_connection *wa_connection_get(char *);
  -// Initialize all configured connections.
  -void wa_connection_init(void);
  -// Initialize all configured connections.
  -void wa_connection_destroy(void);
   
   #endif // ifdef _WA_CONNECTION_H_
  
  
  
  1.5       +2 -1      jakarta-tomcat-4.0/connectors/webapplib/wa_host.c
  
  Index: wa_host.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_host.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- wa_host.c 2000/11/30 16:20:54     1.4
  +++ wa_host.c 2000/12/06 11:20:39     1.5
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_host.c,v 1.4 2000/11/30 16:20:54 pier Exp $
  +// CVS $Id: wa_host.c,v 1.5 2000/12/06 11:20:39 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -160,6 +160,7 @@
       appl->name=strdup(name);
       appl->conn=conn;
       appl->conf=NULL;
  +    appl->next=NULL;
   
       // Check for leading/trailing slashes. Set slashes to 1 if the leading
       // slash is missing, to 2 if the trailing one is missing or to 3 in case
  
  
  
  1.4       +2 -3      jakarta-tomcat-4.0/connectors/webapplib/wa_provider.c
  
  Index: wa_provider.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wa_provider.c     2000/11/29 12:27:02     1.3
  +++ wa_provider.c     2000/12/06 11:20:40     1.4
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider.c,v 1.3 2000/11/29 12:27:02 pier Exp $
  +// CVS $Id: wa_provider.c,v 1.4 2000/12/06 11:20:40 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -82,7 +82,6 @@
   /* The list of all compiled in providers */
   wa_provider *wa_providers[] = {
       &wa_provider_info,
  -    &wa_provider_warp,
  +//    &wa_provider_warp,
       NULL,
   };
  -
  
  
  
  1.6       +58 -16    jakarta-tomcat-4.0/connectors/webapplib/wa_provider.h
  
  Index: wa_provider.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- wa_provider.h     2000/11/30 16:20:54     1.5
  +++ wa_provider.h     2000/12/06 11:20:41     1.6
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider.h,v 1.5 2000/11/30 16:20:54 pier Exp $
  +// CVS $Id: wa_provider.h,v 1.6 2000/12/06 11:20:41 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #ifndef _WA_PROVIDER_H_
  @@ -65,20 +65,62 @@
    * The wa_provider structure describes a connection provider.
    */
   struct wa_provider {
  -    // The name of the current provider
  +    /**
  +     * The name of this provider.
  +     */
       const char *name;
  -    // Configure a connection
  -    const char *(*configure) (wa_connection *, char *);
  -    // Initialize a connection
  -    void (*init) (wa_connection *);
  -    // Clean up a connection
  -    void (*destroy) (wa_connection *);
  -    // Handle an HTTP request
  -    void (*handle) (wa_request *, wa_callbacks *);
  -    // Get a descriptive string on a connection (based on wa_connection->conf)
  -    int (*conninfo) (wa_connection *, char *, int);
  -    // Get a descriptive string on a connection (based on wa_application->conf)
  -    int (*applinfo) (wa_application *, char *, int);
  +
  +    /**
  +     * 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 *(*configure) (wa_connection *conn, char *param);
  +
  +    /**
  +     * Initialize a connection.
  +     *
  +     * @param conn The connection to initialize.
  +     */
  +    const char *(*init) (wa_connection *conn);
  +
  +    /**
  +     * Destroys a connection.
  +     *
  +     * @param conn The connection to destroy.
  +     */
  +    const char *(*destroy) (wa_connection *conn);
  +
  +    /**
  +     * 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);
   };
   
   /* The list of all compiled in providers */
  @@ -86,10 +128,10 @@
   
   /* Pointers to the different providers */
   extern wa_provider wa_provider_info;
  -extern wa_provider wa_provider_warp;
  +//extern wa_provider wa_provider_warp;
   
   /* Function prototype declaration */
   // Retrieve a provider.
   wa_provider *wa_provider_get(char *);
   
  -#endif // ifndef _WA_PROVIDER_H_
  \ No newline at end of file
  +#endif // ifndef _WA_PROVIDER_H_
  
  
  
  1.7       +133 -70   jakarta-tomcat-4.0/connectors/webapplib/wa_provider_info.c
  
  Index: wa_provider_info.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider_info.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- wa_provider_info.c        2000/11/30 17:34:15     1.6
  +++ wa_provider_info.c        2000/12/06 11:20:43     1.7
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider_info.c,v 1.6 2000/11/30 17:34:15 pier Exp $
  +// CVS $Id: wa_provider_info.c,v 1.7 2000/12/06 11:20:43 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -70,12 +70,30 @@
    */
   static const char *wa_info_configure(wa_connection *conn, char *param) {
       if(conn==NULL) return("Connection not specified");
  -    if (param==NULL) conn->conf=strdup("[No data supplied]");
  +    if (param==NULL) conn->conf=NULL;
       else conn->conf=strdup(param);
       return(NULL);
   }
   
   /**
  + * Initialize a connection.
  + *
  + * @param conn The connection to initialize.
  + */
  +static const char *wa_info_init(wa_connection *conn) {
  +    return(NULL);
  +}
  +
  +/**
  + * Destroys a connection.
  + *
  + * @param conn The connection to destroy.
  + */
  +static const char *wa_info_destroy(wa_connection *conn) {
  +    return(NULL);
  +}
  +
  +/**
    * Describe the configuration member found in a connection.
    *
    * @param conn The connection for wich a description must be produced.
  @@ -86,9 +104,11 @@
   static int wa_info_conninfo(wa_connection *conn, char *buf, int len) {
       int x=0;
       char *msg="Null connection specified\0";
  +    return(0);
   
       if ((buf==NULL)||(len==0)) return(0);
       if(conn!=NULL) msg=(char *)conn->conf;
  +    if (msg==NULL) msg="No extra parameters specified for this connection\0";
   
       // Copy the message string in the buffer and return
       for (x=0; x<len; x++) {
  @@ -112,118 +132,161 @@
   }
   
   /**
  - * Initialize a connection.
  - *
  - * @param conn The connection to initialize.
  - */
  -static void wa_info_init(wa_connection *conn) {
  -    return;
  -}
  -
  -/**
  - * Destroys a connection.
  - *
  - * @param conn The connection to destroy.
  - */
  -static void wa_info_destroy(wa_connection *conn) {
  -    return;
  -}
  -
  -/**
    * Handle a connection from the web server.
    *
    * @param req The request data.
  - * @param cb The web-server callback information.
    */
  -void wa_info_handle(wa_request *req, wa_callbacks *cb) {
  +void wa_info_handle(wa_request *req) {
       int x=0;
  +    int ret=0;
  +    char *buf;
  +    time_t t=0;
  +    char *ts=NULL;
       wa_connection *conn=wa_connections;
       wa_host *host=wa_hosts;
   
  -    wa_callback_setstatus(cb,req,200);
  -    wa_callback_settype(cb,req,"text/html");
  -    wa_callback_commit(cb,req);
  -    wa_callback_printf(cb,req,"<html>\n");
  -    wa_callback_printf(cb,req," <head>\n");
  -    wa_callback_printf(cb,req,"  <title>mod_webapp: status</title>\n");
  -    wa_callback_printf(cb,req," </head>\n");
  -    wa_callback_printf(cb,req," <body>\n");
  +    time(&t);
  +    ts=ctime(&t);
  +    if (ts==NULL) ts=strdup("[Unknown generation time]");
  +    else ts[24]='\0';
  +
  +    wa_callback_setstatus(req,200);
  +    wa_callback_settype(req,"text/html");
  +    wa_callback_commit(req);
  +    wa_callback_printf(req,"<html>\n");
  +    wa_callback_printf(req," <head>\n");
  +    wa_callback_printf(req,"  <title>mod_webapp: status</title>\n");
  +    wa_callback_printf(req," </head>\n");
  +    wa_callback_printf(req," <body>\n");
  +    wa_callback_printf(req,"  <form action=\"%s://%s:%d%s\"",req->schm,
  +                       req->name,req->port,req->ruri);
  +    wa_callback_printf(req," method=\"post\">\n");
  +    wa_callback_printf(req,"   <input type=\"submit\" value=\"Refresh\">\n");
  +    wa_callback_printf(req,"   <input type=\"hidden\" name=\"lastcall\"");
  +    wa_callback_printf(req," value=\"%s\">\n",ts);
  +    wa_callback_printf(req,"   Generated on %s<br>\n",ts);
  +    wa_callback_printf(req,"  </form>\n");
  +    free(ts);
  +    wa_callback_flush(req);
   
  +    wa_callback_printf(req,"  <dl>\n");
  +    wa_callback_printf(req,"   <dt><b>Connections:</b></dt>\n");
       // Dump configured connections
       while (conn!=NULL) {
           char desc[1024];
   
  -        wa_callback_printf(cb,req,"  <dl>\n");
  -        wa_callback_printf(cb,req,"   <dt><b>Connection: %s</b></dt>\n",
  -                           conn->name);
  -        wa_callback_printf(cb,req,"   <dd>\n");
  -        wa_callback_printf(cb,req,"    Provider &quot;%s&quot;\n",
  -                           conn->prov->name);
  +        wa_callback_printf(req,"   <dd>\n");
  +        wa_callback_printf(req,"    Connection &quot;%s&quot;\n",conn->name);
  +        wa_callback_printf(req,"    Prov. &quot;%s&quot;\n",conn->prov->name);
           if ((*conn->prov->conninfo)(conn,desc,1024)>0)
  -            wa_callback_printf(cb,req,"    (Descr.: &quot;%s&quot;)\n",desc);
  +            wa_callback_printf(req,"    (%s)\n",desc);
           else
  -            wa_callback_printf(cb,req,"    (No description available)\n");
  -        wa_callback_printf(cb,req,"   </dd>\n");
  +            wa_callback_printf(req,"    [No description available]\n");
  +        wa_callback_printf(req,"   </dd>\n");
  +        wa_callback_flush(req);
           conn=conn->next;
  -        wa_callback_printf(cb,req,"  </dl>\n");
       }
  -
  +    wa_callback_printf(req,"  </dl>\n");
  +    wa_callback_flush(req);
   
       // Dump configured hosts and applications
       while (host!=NULL) {
           wa_application *appl=host->apps;
   
  -        wa_callback_printf(cb,req,"  <dl>\n");
  -        wa_callback_printf(cb,req,"   <dt><b>Host: %s:%d</b></dt>\n",
  +        wa_callback_printf(req,"  <dl>\n");
  +        wa_callback_printf(req,"   <dt><b>Host: %s:%d</b></dt>\n",
                              host->name,host->port);
  +        wa_callback_printf(req,"   <dd>\n");
           while (appl!=NULL) {
               char d[1024];
   
  -            wa_callback_printf(cb,req,"   <dd>\n");
  -            wa_callback_printf(cb,req,"    Application &quot;%s&quot;\n",
  +            wa_callback_printf(req,"    Application &quot;%s&quot;\n",
                                  appl->name);
  -            wa_callback_printf(cb,req,"    mounted under &quot;%s&quot;\n",
  +            wa_callback_printf(req,"    mounted under &quot;%s&quot;\n",
                                  appl->path);
  -            wa_callback_printf(cb,req,"    using connection &quot;%s&quot;\n",
  +            wa_callback_printf(req,"    using connection &quot;%s&quot;\n",
                                  appl->conn->name);
  +            wa_callback_flush(req);
   
               // Get provider specific description of the application
               if ((*appl->conn->prov->applinfo)(appl,d,1024)>0)
  -                wa_callback_printf(cb,req,"    (Descr.: &quot;%s&quot;)\n",d);
  +                wa_callback_printf(req,"    (%s)\n",d);
               else
  -                wa_callback_printf(cb,req,"    (No description available)\n");
  +                wa_callback_printf(req,"    [No description available]\n");
   
  -            wa_callback_printf(cb,req,"   </dd>\n");
  +            wa_callback_printf(req,"   </dd>\n");
  +            wa_callback_flush(req);
               appl=appl->next;
           }
  +        wa_callback_printf(req,"  </dl>\n");
  +        wa_callback_flush(req);
           host=host->next;
  -        wa_callback_printf(cb,req,"  </dl>\n");
       }
  +    wa_callback_flush(req);
   
       // Dump the first line of the request
  -    wa_callback_printf(cb,req,"  <dl>\n");
  -    wa_callback_printf(cb,req,"   <dt><b>This request:</b></dt>\n");
  -    wa_callback_printf(cb,req,"   <dd>\n");
  -    wa_callback_printf(cb,req,"    <code>\n");
  -    wa_callback_printf(cb,req,"     %s",req->meth);
  -    wa_callback_printf(cb,req," %s",req->ruri);
  -    if (req->args!=NULL) wa_callback_printf(cb,req,"?%s",req->args);
  -    wa_callback_printf(cb,req," %s<br>\n",req->prot);
  -
  -    // Dump the first line of the request
  -    for (x=0; x<req->hnum; x++)
  -        wa_callback_printf(cb,req,"     %s: %s<br>",req->hnam[x],
  +    wa_callback_printf(req,"  <dl>\n");
  +    wa_callback_printf(req,"   <dt><b>This Request (%d bytes):</b></dt>\n",
  +                       req->clen);
  +    wa_callback_printf(req,"   <dd>\n");
  +    wa_callback_printf(req,"    Request URI: &quot;%s://%s:%d%s",
  +                       req->schm,req->name,req->port,req->ruri);
  +    if (req->args==NULL) wa_callback_printf(req,"&quot;<br>\n");
  +    else wa_callback_printf(req,"?%s&quot;<br>\n",req->args);
  +    wa_callback_printf(req,"    Configured Host: &quot;%s:%d&quot;<br>\n",
  +                       req->host->name,req->host->port);
  +    wa_callback_printf(req,"    Requested Host: &quot;%s:%d&quot;<br>\n",
  +                       req->name,req->port);
  +    wa_callback_printf(req,"    Remote Host: &quot;%s&quot;<br>\n",
  +                       req->rhst==NULL?"[NULL]":req->rhst);
  +    wa_callback_printf(req,"    Remote Address: &quot;%s&quot;<br>\n",
  +                       req->radr==NULL?"[NULL]":req->radr);
  +    wa_callback_printf(req,"    Remote User: &quot;%s&quot;<br>\n",
  +                       req->user==NULL?"[NULL]":req->user);
  +    wa_callback_printf(req,"    Authentication Method: &quot;%s&quot;<br>\n",
  +                       req->auth==NULL?"[NULL]":req->auth);
  +    wa_callback_printf(req,"    <br>\n");
  +    wa_callback_printf(req,"    <code>\n");
  +    wa_callback_printf(req,"     %s",req->meth);
  +    wa_callback_printf(req," %s",req->ruri);
  +    if (req->args!=NULL) wa_callback_printf(req,"?%s",req->args);
  +    wa_callback_printf(req," %s<br>\n",req->prot);
  +    wa_callback_printf(req,"    <br>\n");
  +    wa_callback_flush(req);
  +
  +    // Dump the request headers
  +    for (x=0; x<req->hnum; x++) {
  +        wa_callback_printf(req,"     %s: %s<br>\n",req->hnam[x],
                                                       req->hval[x]);
  +    }
  +    wa_callback_flush(req);
   
  +    // Dump the request body
  +    wa_callback_printf(req,"    </code>\n");
  +    if (req->clen>0) {
  +        wa_callback_printf(req,"<pre>\n");
  +        buf=(char *)wa_callback_alloc(req,1024*sizeof(char));
  +        ret=1;
  +        while (ret>0) {
  +            ret=wa_callback_read(req,buf,1024);
  +            if (ret>0) {
  +                wa_callback_write(req,buf,ret);
  +                wa_callback_flush(req);
  +            } else if (ret<0) {
  +                wa_callback_printf(req,">\n<b>TRANSFER INTERRUPTED</b>\n");
  +            }
  +        }
  +        wa_callback_printf(req,"\n</pre>\n");
  +    }
  +
       // Finish the request dump
  -    wa_callback_printf(cb,req,"    </code>\n");
  -    wa_callback_printf(cb,req,"   </dd>\n");
  -    wa_callback_printf(cb,req,"  </dl>\n");
  +    wa_callback_printf(req,"   </dd>\n");
  +    wa_callback_printf(req,"  </dl>\n");
   
       // Finish the page
  -    wa_callback_printf(cb,req," </body>\n");
  -    wa_callback_printf(cb,req,"<html>\n");
  -    wa_callback_flush(cb,req);
  +    wa_callback_printf(req," </body>\n");
  +    wa_callback_printf(req,"<html>\n");
  +    wa_callback_flush(req);
   }
   
   /** WebAppLib plugin description. */
  @@ -232,7 +295,7 @@
       wa_info_configure,
       wa_info_init,
       wa_info_destroy,
  -    wa_info_handle,
       wa_info_conninfo,
       wa_info_applinfo,
  +    wa_info_handle,
   };
  
  
  
  1.5       +8 -8      jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.c
  
  Index: wa_provider_warp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- wa_provider_warp.c        2000/11/30 21:58:59     1.4
  +++ wa_provider_warp.c        2000/12/06 11:20:44     1.5
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider_warp.c,v 1.4 2000/11/30 21:58:59 pier Exp $
  +// CVS $Id: wa_provider_warp.c,v 1.5 2000/12/06 11:20:44 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -581,11 +581,11 @@
                                    const char *fmt, ...) {
       char buf[1024];
       va_list ap;
  -    
  +
       va_start(ap,fmt);
       vsprintf(buf,fmt,ap);
       va_end(ap);
  -    
  +
       wa_callback_setstatus(cb,req,500);
       wa_callback_settype(cb,req,"text/html");
       wa_callback_commit(cb,req);
  @@ -600,8 +600,8 @@
       wa_callback_printf(cb,req,"</html>\n");
       wa_callback_flush(cb,req);
       return;
  -}    
  -    
  +}
  +
   /**
    * Handle a connection from the web server.
    *
  @@ -662,19 +662,19 @@
       }
       rid=wa_warp_packet_get_short(in);
       wa_warp_packet_free(in);
  -    
  +
       // Send the request method
       wa_warp_packet_reset(out);
       out->typ=TYP_REQINIT_MET;
       wa_warp_packet_set_string(out,req->meth);
       wa_warp_send(cc,rid,out);
  -    
  +
       // Send the request URI
       wa_warp_packet_reset(out);
       out->typ=TYP_REQINIT_URI;
       wa_warp_packet_set_string(out,req->ruri);
       wa_warp_send(cc,rid,out);
  -    
  +
       // Send the request arguments
       wa_warp_packet_reset(out);
       out->typ=TYP_REQINIT_ARG;
  
  
  
  1.4       +19 -12    jakarta-tomcat-4.0/connectors/webapplib/wa_request.c
  
  Index: wa_request.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_request.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wa_request.c      2000/11/29 12:23:07     1.3
  +++ wa_request.c      2000/12/06 11:20:47     1.4
  @@ -55,22 +55,29 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_request.c,v 1.3 2000/11/29 12:23:07 pier Exp $
  +// CVS $Id: wa_request.c,v 1.4 2000/12/06 11:20:47 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
   
  -/* Function prototype declaration */
  -// Handle a request.
  -const char *wa_request_handle(wa_request *req, wa_callbacks *cb) {
  -    if (cb==NULL) return("Callback structure pointer is NULL");
  -    if (req==NULL) return("Request structure pointer is NULL");
  -    if (req->host==NULL) return("Web application host is NULL");
  -    if (req->appl==NULL) return("Web application structure is NULL");
  -    if (req->meth==NULL) return("Request method is NULL");
  -    if (req->ruri==NULL) return("Request URI is NULL ");
  -    if (req->prot==NULL) return("Request protocol is NULL");
  +/**
  + * Handle a request.
  + *
  + * @param r The wa_request structure describing the current request.
  + * @return An error message if something went wrong or NULL.
  + */
  +const char *wa_request_handle(wa_request *r) {
  +    // Primary parameter check
  +    if (wa_callbacks==NULL) return("WebApp library not initialized");
  +    if (r==NULL) return("Request structure pointer is NULL");
  +    if (r->host==NULL) return("Web application host is NULL");
  +    if (r->appl==NULL) return("Web application structure is NULL");
  +    if (r->meth==NULL) return("Request method is NULL");
  +    if (r->ruri==NULL) return("Request URI is NULL ");
  +    if (r->prot==NULL) return("Request protocol is NULL");
   
  -    (*req->appl->conn->prov->handle)(req,cb);
  +    wa_callback_debug(WA_LOG,r,"Dispatching for %s%s to provider %s",
  +                      r->host->name,r->ruri,r->appl->conn->prov->name);
  +    (*r->appl->conn->prov->handle)(r);
       return(NULL);
   }
  
  
  
  1.4       +11 -2     jakarta-tomcat-4.0/connectors/webapplib/wa_request.h
  
  Index: wa_request.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_request.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wa_request.h      2000/11/29 12:23:09     1.3
  +++ wa_request.h      2000/12/06 11:20:49     1.4
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_request.h,v 1.3 2000/11/29 12:23:09 pier Exp $
  +// CVS $Id: wa_request.h,v 1.4 2000/12/06 11:20:49 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #ifndef _WA_REQUEST_H_
  @@ -72,6 +72,15 @@
       char *ruri;             // The HTTP URI requested
       char *args;             // The HTTP query arguments
       char *prot;             // The HTTP protocol (HTTP/1.0, HTTP/1.1)
  +    char *schm;             // The HTTP scheme info (http, https)
  +    char *name;             // The requested name of the server
  +    int port;               // The requested port of the server
  +    char *rhst;             // The remote client host name
  +    char *radr;             // The remote client address
  +    char *user;             // The user name, if authenticated by the web server
  +    char *auth;             // The authentication metod used by the web server
  +    long clen;              // The Content-Length of the request
  +    long rlen;              // The number of bytes read out of this request
       int hnum;               // The number of headers in this request
       char **hnam;            // The array of header names
       char **hval;            // The array of header values
  @@ -79,6 +88,6 @@
   
   /* Function prototype declaration */
   // Handle a request.
  -const char *wa_request_handle(wa_request *, wa_callbacks *);
  +const char *wa_request_handle(wa_request *);
   
   #endif // ifdef _WA_HOST_H_
  
  
  

Reply via email to