tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/connectors/apache-1.3 mod_webapp.c
Date Thu, 10 May 2001 06:21:27 GMT
pier        01/05/09 23:21:27

  Modified:    connectors/apache-1.3 mod_webapp.c
  Log:
  Sources reformatted
  
  Revision  Changes    Path
  1.12      +124 -125  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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- mod_webapp.c	2001/05/10 06:07:33	1.11
  +++ mod_webapp.c	2001/05/10 06:21:25	1.12
  @@ -57,7 +57,7 @@
   
   /**
    * @author  Pier Fumagalli <mailto:pier.fumagalli@eng.sun.com>
  - * @version $Id: mod_webapp.c,v 1.11 2001/05/10 06:07:33 pier Exp $
  + * @version $Id: mod_webapp.c,v 1.12 2001/05/10 06:21:25 pier Exp $
    */
   
   #include <httpd.h>
  @@ -114,26 +114,26 @@
       int port=(int)svr->port;
       const char *ret=NULL;
   
  -    /* Attempt to retrieve the wa_virtualhost structure and create it 
  +    /* Attempt to retrieve the wa_virtualhost structure and create it
          if necessary, storing it into the server_rec structure. */
       host=ap_get_module_config(svr->module_config,&webapp_module);
  -    
  -	/* If we already configured the wa_virtualhost, simply return it */
  -	if (host!=NULL) {
  -		*h=host;
  -	    return(NULL);
  -	}
   
  -	/* The wa_virtualhost was not found in the per-server module configuration
  -	   so we'll try to create it. */
  +    /* If we already configured the wa_virtualhost, simply return it */
  +    if (host!=NULL) {
  +        *h=host;
  +        return(NULL);
  +    }
  +
  +    /* The wa_virtualhost was not found in the per-server module configuration
  +       so we'll try to create it. */
       ret=wa_cvirtualhost(&host,name,port);
       if (ret!=NULL) {
  -    	*h=NULL;
  -    	return(ret);
  +        *h=NULL;
  +        return(ret);
       }
   
  -	/* We successfully created a wa_virtualhost structure, store it in the
  -	   per-server configuration member and return it. */
  +    /* We successfully created a wa_virtualhost structure, store it in the
  +       per-server configuration member and return it. */
       ap_set_module_config(svr->module_config,&webapp_module,host);
       *h=host;
       return(NULL);
  @@ -148,25 +148,25 @@
   
       /* Initialize the library */
       if ((ret=wam_init(cmd->pool))!=NULL) return(ret);
  -    
  +
       /* Attempt to create a new wa_connection structure */
       if ((ret=wa_cconnection(&conn,name,prov,p))!=NULL) return(ret);
   
       /* Check if we have a duplicate connection with this name */
       elem=wam_connections;
  -	while (elem!=NULL) {
  -		wa_connection *curr=(wa_connection *)elem->curr;
  -    	if (strcasecmp(conn->name,curr->name)==0)
  -    		return("Duplicate connection name");
  -    	elem=elem->next;
  +    while (elem!=NULL) {
  +        wa_connection *curr=(wa_connection *)elem->curr;
  +        if (strcasecmp(conn->name,curr->name)==0)
  +            return("Duplicate connection name");
  +        elem=elem->next;
       }
   
  -	/* We don't have a duplicate connection, store it locally */
  -	elem=apr_palloc(wa_pool,sizeof(wa_chain));
  -	elem->curr=conn;
  -	elem->next=wam_connections;
  -	wam_connections=elem;
  -	return(NULL);
  +    /* We don't have a duplicate connection, store it locally */
  +    elem=apr_palloc(wa_pool,sizeof(wa_chain));
  +    elem->curr=conn;
  +    elem->next=wam_connections;
  +    wam_connections=elem;
  +    return(NULL);
   }
   
   /* Process the WebAppDeploy directive */
  @@ -182,24 +182,24 @@
       if ((ret=wam_init(cmd->pool))!=NULL) return(ret);
       if ((ret=wam_server(cmd->server,&host))!=NULL) return(ret);
   
  -	/* Retrieve the connection */
  -	elem=wam_connections;
  -	while(elem!=NULL) {
  -		wa_connection *curr=(wa_connection *)elem->curr;
  -		if (strcasecmp(curr->name,cnam)==0) {
  -			conn=curr;
  -			break;
  -		}
  -		elem=elem->next;
  -	}
  -	if (conn==NULL) return("Specified connection not configured");
  +    /* Retrieve the connection */
  +    elem=wam_connections;
  +    while(elem!=NULL) {
  +        wa_connection *curr=(wa_connection *)elem->curr;
  +        if (strcasecmp(curr->name,cnam)==0) {
  +            conn=curr;
  +            break;
  +        }
  +        elem=elem->next;
  +    }
  +    if (conn==NULL) return("Specified connection not configured");
   
  -	/* Create a new wa_application member */
  +    /* Create a new wa_application member */
       if ((ret=wa_capplication(&appl,name,path))!=NULL) return(ret);
  -    
  +
       /* Deploy the web application */
       if ((ret=wa_deploy(appl,host,conn))!=NULL) return(ret);
  -    
  +
       /* Done */
       return(NULL);
   }
  @@ -208,25 +208,25 @@
   static const char *wam_directive_info(cmd_parms *cmd, void *mconfig,
                                         char *path) {
       const char *ret;
  +
  +    /* We simply divert this call to a WebAppConnection and a WebAppDeploy
  +       calls */
  +    if ((ret=wam_directive_connection(cmd,mconfig,"_INFO_","info",""))!=NULL)
  +        return(ret);
  +    if ((ret=wam_directive_deploy(cmd,mconfig,"_INFO_","_INFO_",path))!=NULL)
  +        return(ret);
   
  -	/* We simply divert this call to a WebAppConnection and a WebAppDeploy
  -	   calls */
  -	if ((ret=wam_directive_connection(cmd,mconfig,"_INFO_","info",""))!=NULL)
  -		return(ret);
  -	if ((ret=wam_directive_deploy(cmd,mconfig,"_INFO_","_INFO_",path))!=NULL)
  -		return(ret);
  -	
  -	return(NULL);
  +    return(NULL);
   }
   
   /* The list of Directives for the WebApp module */
   static const command_rec wam_directives[] = {
       {
  -        "WebAppInfo",       		/* directive name */
  -        wam_directive_info, 		/* config action routine */
  -        NULL,               		/* argument to include in call */
  -        OR_OPTIONS,         		/* where available */
  -        TAKE1,              		/* arguments */
  +        "WebAppInfo",               /* directive name */
  +        wam_directive_info,         /* config action routine */
  +        NULL,                       /* argument to include in call */
  +        OR_OPTIONS,                 /* where available */
  +        TAKE1,                      /* arguments */
           "<uri-path>"
       },{
           "WebAppConnection",         /* directive name */
  @@ -252,94 +252,95 @@
   
   /* Log a message associated with a request */
   void wam_handler_log(wa_request *r, const char *f, const int l, char *msg) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
   
  -	ap_log_error(f,l,APLOG_NOERRNO|APLOG_ERR,svr,"%s",msg);
  +    ap_log_error(f,l,APLOG_NOERRNO|APLOG_ERR,svr,"%s",msg);
   }
   
   /* Set the HTTP status of the response. */
   void wam_handler_setstatus(wa_request *r, int status) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  -	
  -	req->status=status;
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
  +
  +    req->status=status;
   }
   
   /* Set the MIME Content-Type of the response. */
   void wam_handler_setctype(wa_request *r, char *type) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
   
  -	if (type==NULL) return;
  -	
  -	req->content_type=ap_pstrdup(req->pool,type);
  -	ap_table_add(req->headers_out,"Content-Type",ap_pstrdup(req->pool,type));
  +    if (type==NULL) return;
  +
  +    req->content_type=ap_pstrdup(req->pool,type);
  +    ap_table_add(req->headers_out,"Content-Type",ap_pstrdup(req->pool,type));
   }
   
   /* Set a header in the HTTP response. */
   void wam_handler_setheader(wa_request *r, char *name, char *value) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
  +
  +    if (name==NULL) return;
  +    if (value==NULL) value="";
   
  -	if (name==NULL) return;
  -	if (value==NULL) value="";
  -	
  -	ap_table_add(req->headers_out,ap_pstrdup(req->pool,name),
  -	             ap_pstrdup(req->pool,value));
  +    ap_table_add(req->headers_out,ap_pstrdup(req->pool,name),
  +                 ap_pstrdup(req->pool,value));
   }
   
   /* Commit the first part of the response (status and headers) */
   void wam_handler_commit(wa_request *r) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  -	
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
  +
       ap_send_http_header(req);
  -//    ap_rflush(req);
  +    ap_rflush(req);
   }
   
   /* Flush all data in the response buffer */
   void wam_handler_flush(wa_request *r) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  -	
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
  +
       ap_rflush(req);
   }
   
   /* Read a chunk of text from the request body */
   int wam_handler_read(wa_request *r, char *buf, int len) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
       long ret=0;
   
  -    // Check if we have something to read.
  +    /* Check if we have something to read. */
       if (r->clen==0) return(0);
   
  -    // Check if we had an error previously.
  +    /* Check if we had an error previously. */
       if (r->rlen==-1) return(-1);
   
  -    // Send HTTP_CONTINUE to client when we're ready to read for the first time.
  +    /* Send HTTP_CONTINUE to client when we're ready to read for the first
  +       time. */
       if (r->rlen==0) {
           if (ap_should_client_block(req)==0) return(0);
       }
   
  -    // Read some data from the client and fill the buffer.
  +    /* Read some data from the client and fill the buffer. */
       ret=ap_get_client_block(req,buf,len);
       if (ret==-1) {
           r->rlen=-1;
           return(-1);
       }
   
  -    // We did read some bytes, increment the current rlen counter and return.
  +    /* We did read some bytes, increment the current rlen and return. */
       r->rlen+=ret;
       return((int)ret);
   }
   
   /* Write a chunk of text into the response body. */
   int wam_handler_write(wa_request *r, char *buf, int len) {
  -	request_rec *req=(request_rec *)r->data;
  -	server_rec *svr=req->server;
  -	
  +    request_rec *req=(request_rec *)r->data;
  +    server_rec *svr=req->server;
  +
       return(ap_rwrite(buf, len, req));
   }
   
  @@ -363,7 +364,7 @@
   static int wam_match(request_rec *r) {
       wa_virtualhost *host=NULL;
       wa_application *appl=NULL;
  -	wa_chain *elem=NULL;
  +    wa_chain *elem=NULL;
   
       /* Check if this host was recognized */
       host=ap_get_module_config(r->server->module_config,&webapp_module);
  @@ -372,11 +373,11 @@
       /* Check if the uri is contained in one of our applications root path */
       elem=host->apps;
       while(elem!=NULL) {
  -    	appl=(wa_application *)elem->curr;
  -    	if (strncmp(appl->rpth,r->uri,strlen(appl->rpth))==0) break;
  -    	
  -    	appl=NULL;
  -    	elem=elem->next;
  +        appl=(wa_application *)elem->curr;
  +        if (strncmp(appl->rpth,r->uri,strlen(appl->rpth))==0) break;
  +
  +        appl=NULL;
  +        elem=elem->next;
       }
       if (appl==NULL) return(DECLINED);
   
  @@ -402,33 +403,33 @@
   
       /* Try to get a hold on the webapp request structure */
       appl=(wa_application *)ap_get_module_config(r->request_config,
  -    										 	&webapp_module);
  +                                                &webapp_module);
       if (appl==NULL) return(DECLINED);
  +
  +    /* Allocate the webapp request structure */
  +    if ((msg=wa_ralloc(&req, &wam_handler, r))!=NULL) {
  +        ap_log_error(APLOG_MARK,APLOG_NOERRNO|APLOG_ERR,svr,"%s",msg);
  +        return(HTTP_INTERNAL_SERVER_ERROR);
  +    }
   
  -	/* Allocate the webapp request structure */
  -	if ((msg=wa_ralloc(&req, &wam_handler, r))!=NULL) {
  -		ap_log_error(APLOG_MARK,APLOG_NOERRNO|APLOG_ERR,svr,"%s",msg);
  -		return(HTTP_INTERNAL_SERVER_ERROR);
  -	}
  -
  -	/* Set up the WebApp Library request structure client and server host
  -	   data (from the connection */
  -	stmp=(char *)r->hostname;
  -	ctmp=(char *)ap_get_remote_host(con,r->per_dir_config, REMOTE_HOST);
  -	req->serv->host=apr_pstrdup(req->pool,stmp);
  -	req->clnt->host=apr_pstrdup(req->pool,ctmp);
  +    /* Set up the WebApp Library request structure client and server host
  +       data (from the connection */
  +    stmp=(char *)r->hostname;
  +    ctmp=(char *)ap_get_remote_host(con,r->per_dir_config, REMOTE_HOST);
  +    req->serv->host=apr_pstrdup(req->pool,stmp);
  +    req->clnt->host=apr_pstrdup(req->pool,ctmp);
       req->serv->addr=apr_pstrdup(req->pool,con->local_ip);
  -	req->clnt->addr=apr_pstrdup(req->pool,con->remote_ip);
  +    req->clnt->addr=apr_pstrdup(req->pool,con->remote_ip);
       req->serv->port=con->local_addr.sin_port;
  -	req->clnt->port=con->remote_addr.sin_port;
  +    req->clnt->port=con->remote_addr.sin_port;
   
  -	/* Set up all other members of the request structure */
  -	req->meth=apr_pstrdup(req->pool,(char *)r->method);
  -	req->ruri=apr_pstrdup(req->pool,r->uri);
  +    /* Set up all other members of the request structure */
  +    req->meth=apr_pstrdup(req->pool,(char *)r->method);
  +    req->ruri=apr_pstrdup(req->pool,r->uri);
       req->args=apr_pstrdup(req->pool,r->args);
       req->prot=apr_pstrdup(req->pool,r->protocol);
       req->schm=apr_pstrdup(req->pool,ap_http_method(r));
  -	req->user=apr_pstrdup(req->pool,con->user);
  +    req->user=apr_pstrdup(req->pool,con->user);
       req->auth=apr_pstrdup(req->pool,con->ap_auth_type);
       req->clen=0;
       req->rlen=0;
  @@ -439,29 +440,27 @@
           table_entry *ele=(table_entry *)arr->elts;
           int x=0;
   
  -        // Copy header pointers one by one
  +        /* Copy headers one by one */
           for (x=0; x<arr->nelts;x++) {
               if (ele[x].key==NULL) continue;
               if (ele[x].val==NULL) continue;
               apr_table_add(req->hdrs,apr_pstrdup(req->pool,ele[x].key),
  -            						apr_pstrdup(req->pool,ele[x].val));
  +                                    apr_pstrdup(req->pool,ele[x].val));
               if (strcasecmp(ele[x].key,"Content-Length")==0)
                   req->clen=atol(ele[x].val);
           }
       }
   
  -	/* Invoke the request */
  +    /* Invoke the request */
       ret=wa_rinvoke(req,appl);
  -    
  +
       /* Destroy the request member */
       wa_rfree(req);
       ap_rflush(r);
  -    
  +
       return(OK);
   }
   
  -
  -
   /* List of all available Apache handlers */
   static const handler_rec wam_handlers[] = {
       {"webapp-handler", wam_invoke},
  @@ -477,7 +476,7 @@
       NULL,                               /* server config creator */
       NULL,                               /* server config merger */
       wam_directives,                     /* command table */
  -    wam_handlers,            			/* [9] list of handlers */
  +    wam_handlers,                       /* [9] list of handlers */
       wam_match,                          /* [2] filename-to-URI translation */
       NULL,                               /* [5] check/validate user_id */
       NULL,                               /* [6] check user_id is valid *here* */
  @@ -486,7 +485,7 @@
       NULL,                               /* [8] fixups */
       NULL,                               /* [10] logger */
       NULL,                               /* [3] header parser */
  -    NULL, //webapp_init,                /* child initializer */
  -    NULL, //webapp_exit,                /* child exit/cleanup */
  +    NULL,                               /* child initializer */
  +    NULL,                               /* child exit/cleanup */
       NULL                                /* [1] post read_request handling */
   };
  
  
  

Mime
View raw message