httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Behlendorf <br...@hyperreal.org>
Subject cvs commit: apachen/src/modules/standard mod_dir.c mod_env.c mod_expires.c mod_headers.c mod_imap.c mod_log_agent.c mod_log_referer.c
Date Thu, 18 Sep 1997 18:41:02 GMT
brian       97/09/18 11:41:00

  Modified:    src      INDENT
               src/modules/standard mod_dir.c mod_env.c mod_expires.c
                        mod_headers.c mod_imap.c mod_log_agent.c
                        mod_log_referer.c
  Log:
  Indenting all these... joy!
  
  Revision  Changes    Path
  1.32      +11 -11    apachen/src/INDENT
  
  Index: INDENT
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/INDENT,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- INDENT	1997/09/18 18:06:48	1.31
  +++ INDENT	1997/09/18 18:40:45	1.32
  @@ -69,19 +69,19 @@
      mod_cern_meta.c		DONE by Dean
      mod_cgi.c			DONE by Dean
      mod_digest.c			DONE by Dean
  -   mod_dir.c			RESERVED by Brian
  -   mod_dld.c
  -   mod_env.c			RESERVED by Brian
  -   mod_expires.c		RESERVED by Brian
  -   mod_headers.c		RESERVED by Brian
  -   mod_imap.c			RESERVED by Brian
  -   mod_include.c
  +   mod_dir.c			DONE by Brian
  +   mod_dld.c			RESERVED by Brian
  +   mod_env.c			DONE by Brian
  +   mod_expires.c		DONE by Brian
  +   mod_headers.c		DONE by Brian
  +   mod_imap.c			DONE by Brian
  +   mod_include.c		RESERVED by Brian
      mod_info.c			DONE by Ken
  -   mod_log_agent.c		RESERVED by Brian
  +   mod_log_agent.c		DONE by Brian
      mod_log_config.c		DONE by Ken
  -   mod_log_referer.c		RESERVED by Brian
  -   mod_mime.c
  -   mod_mime.h
  +   mod_log_referer.c		DONE by Brian
  +   mod_mime.c			RESERVED by Brian
  +   mod_mime.h			RESERVED by Brian
      mod_mime_magic.c		DONE by Brian
      mod_negotiation.c		DONE by Ken
      mod_rewrite.c
  
  
  
  1.41      +106 -102  apachen/src/modules/standard/mod_dir.c
  
  Index: mod_dir.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_dir.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- mod_dir.c	1997/08/18 13:12:11	1.40
  +++ mod_dir.c	1997/09/18 18:40:51	1.41
  @@ -71,53 +71,54 @@
   
   #define DIR_CMD_PERMS OR_INDEXES
   
  -static command_rec dir_cmds[] = {
  -{ "DirectoryIndex", set_string_slot,
  -    (void*)XtOffsetOf(dir_config_rec, index_names),
  -    DIR_CMD_PERMS, RAW_ARGS,
  -    "a list of file names" },
  -{ NULL }
  +static command_rec dir_cmds[] =
  +{
  +    {"DirectoryIndex", set_string_slot,
  +     (void *) XtOffsetOf(dir_config_rec, index_names),
  +     DIR_CMD_PERMS, RAW_ARGS,
  +     "a list of file names"},
  +    {NULL}
   };
   
  -static void *create_dir_config (pool *p, char *dummy)
  +static void *create_dir_config(pool *p, char *dummy)
   {
       dir_config_rec *new =
  -        (dir_config_rec *) pcalloc (p, sizeof(dir_config_rec));
  +    (dir_config_rec *) pcalloc(p, sizeof(dir_config_rec));
   
       new->index_names = NULL;
  -    return (void *)new;
  +    return (void *) new;
   }
   
  -static void *merge_dir_configs (pool *p, void *basev, void *addv)
  +static void *merge_dir_configs(pool *p, void *basev, void *addv)
   {
  -    dir_config_rec *new=(dir_config_rec*)pcalloc (p, sizeof(dir_config_rec));
  -    dir_config_rec *base = (dir_config_rec *)basev;
  -    dir_config_rec *add = (dir_config_rec *)addv;
  +    dir_config_rec *new = (dir_config_rec *) pcalloc(p, sizeof(dir_config_rec));
  +    dir_config_rec *base = (dir_config_rec *) basev;
  +    dir_config_rec *add = (dir_config_rec *) addv;
   
  -    new->index_names = add->index_names? add->index_names: base->index_names;
  +    new->index_names = add->index_names ? add->index_names : base->index_names;
       return new;
   }
   
  -static int handle_dir (request_rec *r)
  +static int handle_dir(request_rec *r)
   {
       dir_config_rec *d =
  -      (dir_config_rec *)get_module_config (r->per_dir_config,
  -      &dir_module);
  +    (dir_config_rec *) get_module_config(r->per_dir_config,
  +                                         &dir_module);
       const char *names_ptr = d->index_names ? d->index_names : DEFAULT_INDEX;
       int error_notfound = 0;
   
  -    if (r->uri[0] == '\0' || r->uri[strlen(r->uri)-1] != '/') {
  -	char* ifile;
  -	if (r->args != NULL)
  -        	ifile = pstrcat (r->pool, escape_uri(r->pool, r->uri),
  -			"/", "?", r->args, NULL);
  -	else
  -        	ifile = pstrcat (r->pool, escape_uri(r->pool, r->uri),
  -			 "/", NULL);
  -
  -	table_set (r->headers_out, "Location",
  -		   construct_url(r->pool, ifile, r->server)); 
  -	return HTTP_MOVED_PERMANENTLY;
  +    if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/') {
  +        char *ifile;
  +        if (r->args != NULL)
  +            ifile = pstrcat(r->pool, escape_uri(r->pool, r->uri),
  +                            "/", "?", r->args, NULL);
  +        else
  +            ifile = pstrcat(r->pool, escape_uri(r->pool, r->uri),
  +                            "/", NULL);
  +
  +        table_set(r->headers_out, "Location",
  +                  construct_url(r->pool, ifile, r->server));
  +        return HTTP_MOVED_PERMANENTLY;
       }
   
       /* KLUDGE --- make the sub_req lookups happen in the right directory.
  @@ -125,92 +126,95 @@
        * and would probably break virtual includes...
        */
   
  -    if (r->filename[strlen (r->filename) - 1] != '/') {
  -	r->filename = pstrcat (r->pool, r->filename, "/", NULL);
  +    if (r->filename[strlen(r->filename) - 1] != '/') {
  +        r->filename = pstrcat(r->pool, r->filename, "/", NULL);
       }
  -    
  +
       while (*names_ptr) {
  -          
  -	char *name_ptr = getword_conf (r->pool, &names_ptr);
  -	request_rec *rr = sub_req_lookup_uri (name_ptr, r);
  -           
  -	if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) {
  -	    char* new_uri = escape_uri(r->pool, rr->uri);
  -
  -	    if (rr->args != NULL)
  -		new_uri = pstrcat(r->pool, new_uri, "?", rr->args, NULL);
  -	    else if (r->args != NULL)
  -		new_uri = pstrcat(r->pool, new_uri, "?", r->args, NULL);
  -	
  -	    destroy_sub_req (rr);
  -	    internal_redirect (new_uri, r);
  -	    return OK;
  -	}
  -
  -	/* If the request returned a redirect, propagate it to the client */
  -
  -	if (is_HTTP_REDIRECT(rr->status) ||
  -	    (rr->status == HTTP_NOT_ACCEPTABLE && *names_ptr == '\0')) {
  -
  -	    error_notfound = rr->status;
  -	    r->notes = overlay_tables(r->pool, r->notes, rr->notes);
  -	    r->headers_out = overlay_tables(r->pool, r->headers_out,
  -	                                            rr->headers_out);
  -	    r->err_headers_out = overlay_tables(r->pool, r->err_headers_out,
  -	                                                rr->err_headers_out);
  -	    destroy_sub_req(rr);
  -	    return error_notfound;
  -	}
  -
  -	/* If the request returned something other than 404 (or 200),
  -	 * it means the module encountered some sort of problem. To be
  -	 * secure, we should return the error, rather than create
  -	 * along a (possibly unsafe) directory index.
  -	 *
  -	 * So we store the error, and if none of the listed files
  -	 * exist, we return the last error response we got, instead
  -	 * of a directory listing.
  -	 */
  -	if (rr->status && rr->status != HTTP_NOT_FOUND && rr->status != HTTP_OK)
  -	    error_notfound = rr->status;
   
  -        destroy_sub_req (rr);
  +        char *name_ptr = getword_conf(r->pool, &names_ptr);
  +        request_rec *rr = sub_req_lookup_uri(name_ptr, r);
  +
  +        if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) {
  +            char *new_uri = escape_uri(r->pool, rr->uri);
  +
  +            if (rr->args != NULL)
  +                new_uri = pstrcat(r->pool, new_uri, "?", rr->args, NULL);
  +            else if (r->args != NULL)
  +                new_uri = pstrcat(r->pool, new_uri, "?", r->args, NULL);
  +
  +            destroy_sub_req(rr);
  +            internal_redirect(new_uri, r);
  +            return OK;
  +        }
  +
  +        /* If the request returned a redirect, propagate it to the client */
  +
  +        if (is_HTTP_REDIRECT(rr->status) ||
  +            (rr->status == HTTP_NOT_ACCEPTABLE && *names_ptr == '\0')) {
  +
  +            error_notfound = rr->status;
  +            r->notes = overlay_tables(r->pool, r->notes, rr->notes);
  +            r->headers_out = overlay_tables(r->pool, r->headers_out,
  +                                            rr->headers_out);
  +            r->err_headers_out = overlay_tables(r->pool, r->err_headers_out,
  +                                                rr->err_headers_out);
  +            destroy_sub_req(rr);
  +            return error_notfound;
  +        }
  +
  +        /* If the request returned something other than 404 (or 200),
  +         * it means the module encountered some sort of problem. To be
  +         * secure, we should return the error, rather than create
  +         * along a (possibly unsafe) directory index.
  +         *
  +         * So we store the error, and if none of the listed files
  +         * exist, we return the last error response we got, instead
  +         * of a directory listing.
  +         */
  +        if (rr->status && rr->status != HTTP_NOT_FOUND && rr->status != HTTP_OK)
  +            error_notfound = rr->status;
  +
  +        destroy_sub_req(rr);
       }
   
       if (error_notfound)
  -	return error_notfound;
  +        return error_notfound;
  +
  +    if (r->method_number != M_GET)
  +        return NOT_IMPLEMENTED;
   
  -    if (r->method_number != M_GET) return NOT_IMPLEMENTED;
  -    
       /* nothing for us to do, pass on through */
   
       return DECLINED;
   }
   
   
  -static handler_rec dir_handlers[] = {
  -{ DIR_MAGIC_TYPE, handle_dir },
  -{ NULL }
  +static handler_rec dir_handlers[] =
  +{
  +    {DIR_MAGIC_TYPE, handle_dir},
  +    {NULL}
   };
   
  -module MODULE_VAR_EXPORT dir_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,			/* initializer */
  -   create_dir_config,		/* dir config creater */
  -   merge_dir_configs,		/* dir merger --- default is to override */
  -   NULL,			/* server config */
  -   NULL,			/* merge server config */
  -   dir_cmds,			/* command table */
  -   dir_handlers,		/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   NULL,			/* fixups */
  -   NULL,			/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module MODULE_VAR_EXPORT dir_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    create_dir_config,          /* dir config creater */
  +    merge_dir_configs,          /* dir merger --- default is to override */
  +    NULL,                       /* server config */
  +    NULL,                       /* merge server config */
  +    dir_cmds,                   /* command table */
  +    dir_handlers,               /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    NULL,                       /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.16      +93 -90    apachen/src/modules/standard/mod_env.c
  
  Index: mod_env.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_env.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mod_env.c	1997/08/18 13:12:12	1.15
  +++ mod_env.c	1997/09/18 18:40:52	1.16
  @@ -70,27 +70,27 @@
    *           2)  PassEnv FOO present, but $FOO not present in environment
    *           3)  no PassEnv directive present
    * 23.Dec.95 Now allows SetEnv directive with same semantics as 'sh' setenv:
  - *		SetEnv Var	sets Var to the empty string
  - *		SetEnv Var Val	sets Var to the value Val
  - *	     Values containing whitespace should be quoted, eg:
  - *		SetEnv Var "this is some text"
  - *	     Environment variables take their value from the last instance
  - *	     of PassEnv / SetEnv to be reached in the configuration file.
  - *	     For example, the sequence:
  - *		PassEnv FOO
  - *		SetEnv FOO override
  - *	     Causes FOO to take the value 'override'.
  + *              SetEnv Var      sets Var to the empty string
  + *              SetEnv Var Val  sets Var to the value Val
  + *           Values containing whitespace should be quoted, eg:
  + *              SetEnv Var "this is some text"
  + *           Environment variables take their value from the last instance
  + *           of PassEnv / SetEnv to be reached in the configuration file.
  + *           For example, the sequence:
  + *              PassEnv FOO
  + *              SetEnv FOO override
  + *           Causes FOO to take the value 'override'.
    * 23.Feb.96 Added UnsetEnv directive to allow environment variables
    *           to be removed.
    *           Virtual hosts now 'inherit' parent server environment which
  - *	     they're able to overwrite with their own directives or
  - *	     selectively ignore with UnsetEnv.
  + *           they're able to overwrite with their own directives or
  + *           selectively ignore with UnsetEnv.
    *       *** IMPORTANT - the way that virtual hosts inherit their ***
    *       *** environment variables from the default server's      ***
  - *	 *** configuration has changed.  You should test your     ***
  + *       *** configuration has changed.  You should test your     ***
    *       *** configuration carefully before accepting this        ***
    *       *** version of the module in a live webserver which used ***
  - *	 *** older versions of the module.                        ***
  + *       *** older versions of the module.                        ***
    */
   
   #include "httpd.h"
  @@ -104,22 +104,22 @@
   
   module MODULE_VAR_EXPORT env_module;
   
  -static void *create_env_server_config (pool *p, server_rec *dummy)
  +static void *create_env_server_config(pool *p, server_rec *dummy)
   {
       env_server_config_rec *new =
  -      (env_server_config_rec *) palloc (p, sizeof(env_server_config_rec));
  -    new->vars = make_table (p, 50);
  +    (env_server_config_rec *) palloc(p, sizeof(env_server_config_rec));
  +    new->vars = make_table(p, 50);
       new->unsetenv = "";
       new->vars_present = 0;
       return (void *) new;
   }
   
  -static void *merge_env_server_configs (pool *p, void *basev, void *addv)
  +static void *merge_env_server_configs(pool *p, void *basev, void *addv)
   {
  -    env_server_config_rec *base = (env_server_config_rec *)basev;
  -    env_server_config_rec *add = (env_server_config_rec *)addv;
  +    env_server_config_rec *base = (env_server_config_rec *) basev;
  +    env_server_config_rec *add = (env_server_config_rec *) addv;
       env_server_config_rec *new =
  -      (env_server_config_rec *)palloc (p, sizeof(env_server_config_rec));
  +    (env_server_config_rec *) palloc(p, sizeof(env_server_config_rec));
   
       table *new_table;
       table_entry *elts;
  @@ -127,29 +127,29 @@
       int i;
       const char *uenv, *unset;
   
  -      /* 
  -       * new_table = copy_table( p, base->vars );
  -       * foreach $element ( @add->vars ) {
  -       *     table_set( new_table, $element.key, $element.val );
  -       * };
  -       * foreach $unsetenv ( @UNSETENV ) {
  -       *     table_unset( new_table, $unsetenv );
  -       * }
  -       */
  +    /* 
  +     * new_table = copy_table( p, base->vars );
  +     * foreach $element ( @add->vars ) {
  +     *     table_set( new_table, $element.key, $element.val );
  +     * };
  +     * foreach $unsetenv ( @UNSETENV ) {
  +     *     table_unset( new_table, $unsetenv );
  +     * }
  +     */
   
  -    new_table = copy_table( p, base->vars );
  +    new_table = copy_table(p, base->vars);
   
       elts = (table_entry *) add->vars->elts;
   
  -    for ( i = 0; i < add->vars->nelts; ++i ) {
  -	table_set( new_table, elts[i].key, elts[i].val ); 
  +    for (i = 0; i < add->vars->nelts; ++i) {
  +        table_set(new_table, elts[i].key, elts[i].val);
       }
   
       unset = add->unsetenv;
  -    uenv = getword_conf( p, &unset );
  -    while ( uenv[0] != '\0' ) {
  -	table_unset( new_table, uenv );
  -	uenv = getword_conf( p, &unset );
  +    uenv = getword_conf(p, &unset);
  +    while (uenv[0] != '\0') {
  +        table_unset(new_table, uenv);
  +        uenv = getword_conf(p, &unset);
       }
   
       new->vars = new_table;
  @@ -159,106 +159,109 @@
       return new;
   }
   
  -static const char *add_env_module_vars_passed (cmd_parms *cmd, char *struct_ptr,
  -				  const char *arg)
  +static const char *add_env_module_vars_passed(cmd_parms *cmd, char *struct_ptr,
  +                                              const char *arg)
   {
       env_server_config_rec *sconf =
  -      get_module_config (cmd->server->module_config, &env_module);
  +    get_module_config(cmd->server->module_config, &env_module);
       table *vars = sconf->vars;
       char *env_var;
       char *name_ptr;
   
       while (*arg) {
  -        name_ptr = getword_conf (cmd->pool, &arg);
  +        name_ptr = getword_conf(cmd->pool, &arg);
           env_var = getenv(name_ptr);
  -        if ( env_var != NULL ) { 
  +        if (env_var != NULL) {
               sconf->vars_present = 1;
  -            table_set (vars, name_ptr, env_var);
  +            table_set(vars, name_ptr, env_var);
           }
       }
       return NULL;
   }
   
  -static const char *add_env_module_vars_set (cmd_parms *cmd, char *struct_ptr,
  -				     const char *arg)
  +static const char *add_env_module_vars_set(cmd_parms *cmd, char *struct_ptr,
  +                                           const char *arg)
   {
       env_server_config_rec *sconf =
  -      get_module_config (cmd->server->module_config, &env_module);
  +    get_module_config(cmd->server->module_config, &env_module);
       table *vars = sconf->vars;
       char *name, *value;
   
  -    name = getword_conf( cmd->pool, &arg );
  -    value = getword_conf( cmd->pool, &arg );
  +    name = getword_conf(cmd->pool, &arg);
  +    value = getword_conf(cmd->pool, &arg);
   
       /* name is mandatory, value is optional.  no value means
        * set the variable to an empty string
        */
   
   
  -    if ( (*name == '\0') || (*arg != '\0')) {
  -	return "SetEnv takes one or two arguments.  An environment variable name and an optional value to pass to CGI." ;
  +    if ((*name == '\0') || (*arg != '\0')) {
  +        return "SetEnv takes one or two arguments.  An environment variable name and an optional value to pass to CGI.";
       }
   
       sconf->vars_present = 1;
  -    table_set (vars, name, value);
  +    table_set(vars, name, value);
   
       return NULL;
   }
   
  -static const char *add_env_module_vars_unset (cmd_parms *cmd, char *struct_ptr,
  -				       char *arg)
  +static const char *add_env_module_vars_unset(cmd_parms *cmd, char *struct_ptr,
  +                                             char *arg)
   {
       env_server_config_rec *sconf =
  -      get_module_config (cmd->server->module_config, &env_module);
  -    sconf->unsetenv = sconf->unsetenv ? 
  -	pstrcat( cmd->pool, sconf->unsetenv, " ", arg, NULL ) : 
  -	pstrdup( cmd->pool, arg );
  +    get_module_config(cmd->server->module_config, &env_module);
  +    sconf->unsetenv = sconf->unsetenv ?
  +        pstrcat(cmd->pool, sconf->unsetenv, " ", arg, NULL) :
  +         pstrdup(cmd->pool, arg);
       return NULL;
   }
   
  -static command_rec env_module_cmds[] = {
  -{ "PassEnv", add_env_module_vars_passed, NULL,
  -    RSRC_CONF, RAW_ARGS, "a list of environment variables to pass to CGI." },
  -{ "SetEnv", add_env_module_vars_set, NULL,
  -    RSRC_CONF, RAW_ARGS, "an environment variable name and a value to pass to CGI." },
  -{ "UnsetEnv", add_env_module_vars_unset, NULL,
  -    RSRC_CONF, RAW_ARGS, "a list of variables to remove from the CGI environment." },
  -{ NULL },
  +static command_rec env_module_cmds[] =
  +{
  +    {"PassEnv", add_env_module_vars_passed, NULL,
  +     RSRC_CONF, RAW_ARGS, "a list of environment variables to pass to CGI."},
  +    {"SetEnv", add_env_module_vars_set, NULL,
  +     RSRC_CONF, RAW_ARGS, "an environment variable name and a value to pass to CGI."},
  +    {"UnsetEnv", add_env_module_vars_unset, NULL,
  +     RSRC_CONF, RAW_ARGS, "a list of variables to remove from the CGI environment."},
  +    {NULL},
   };
   
   static int fixup_env_module(request_rec *r)
   {
       table *e = r->subprocess_env;
       server_rec *s = r->server;
  -    env_server_config_rec *sconf = get_module_config (s->module_config,
  -						   &env_module);
  +    env_server_config_rec *sconf = get_module_config(s->module_config,
  +                                                     &env_module);
       table *vars = sconf->vars;
   
  -    if ( !sconf->vars_present ) return DECLINED;
  +    if (!sconf->vars_present)
  +        return DECLINED;
   
  -    r->subprocess_env = overlay_tables( r->pool, e, vars );
  +    r->subprocess_env = overlay_tables(r->pool, e, vars);
   
  -    return OK;  
  +    return OK;
   }
   
  -module MODULE_VAR_EXPORT env_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,			/* initializer */
  -   NULL,			/* dir config creater */
  -   NULL,			/* dir merger --- default is to override */
  -   create_env_server_config,	/* server config */
  -   merge_env_server_configs,	/* merge server configs */
  -   env_module_cmds,		/* command table */
  -   NULL,			/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   fixup_env_module,		/* fixups */
  -   NULL,			/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module MODULE_VAR_EXPORT env_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    NULL,                       /* dir config creater */
  +    NULL,                       /* dir merger --- default is to override */
  +    create_env_server_config,   /* server config */
  +    merge_env_server_configs,   /* merge server configs */
  +    env_module_cmds,            /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    fixup_env_module,           /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.18      +225 -211  apachen/src/modules/standard/mod_expires.c
  
  Index: mod_expires.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_expires.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- mod_expires.c	1997/08/31 23:11:27	1.17
  +++ mod_expires.c	1997/09/18 18:40:52	1.18
  @@ -72,12 +72,12 @@
    *
    * Valid values for <code> are:
    *
  - *     'M'	expires header shows file modification date + <seconds>
  - *     'A'	expires header shows access time + <seconds>
  + *     'M'      expires header shows file modification date + <seconds>
  + *     'A'      expires header shows access time + <seconds>
    *
    *              [I'm not sure which of these is best under different
    *              circumstances, I guess it's for other people to explore.
  - *		The effects may be indistinguishable for a number of cases]
  + *              The effects may be indistinguishable for a number of cases]
    *
    * <seconds> should be an integer value [acceptable to atoi()]
    *
  @@ -121,55 +121,55 @@
    *     ExpiresByType type/encoding "<base> [plus] {<num> <type>}*"
    *
    * where <base> is one of:
  - *	access	
  - *	now		equivalent to 'access'
  - *	modification
  + *      access  
  + *      now             equivalent to 'access'
  + *      modification
    *
    * where the 'plus' keyword is optional
    *
    * where <num> should be an integer value [acceptable to atoi()]
    *
    * where <type> is one of:
  - *	years
  - *	months
  - *	weeks
  - *	days
  - *	hours
  - *	minutes
  - *	seconds
  + *      years
  + *      months
  + *      weeks
  + *      days
  + *      hours
  + *      minutes
  + *      seconds
    *
    * For example, any of the following directives can be used to make
    * documents expire 1 month after being accessed, by default:
    *
  - *	ExpiresDefault "access plus 1 month"
  - *	ExpiresDefault "access plus 4 weeks"
  - *	ExpiresDefault "access plus 30 days"
  + *      ExpiresDefault "access plus 1 month"
  + *      ExpiresDefault "access plus 4 weeks"
  + *      ExpiresDefault "access plus 30 days"
    *
    * The expiry time can be fine-tuned by adding several '<num> <type>'
    * clauses:
    *
  - *	ExpiresByType text/html "access plus 1 month 15 days 2 hours"
  - *	ExpiresByType image/gif "modification plus 5 hours 3 minutes"
  + *      ExpiresByType text/html "access plus 1 month 15 days 2 hours"
  + *      ExpiresByType image/gif "modification plus 5 hours 3 minutes"
    *
    * ---
    *
    * Change-log:
  - * 29.Jan.96	Hardened the add_* functions.  Server will now bail out
  - *		if bad directives are given in the conf files.
  - * 02.Feb.96	Returns DECLINED if not 'ExpiresActive on', giving other
  - *		expires-aware modules a chance to play with the same
  - *		directives. [Michael Rutman]
  - * 03.Feb.96	Call tzset() before localtime().  Trying to get the module
  - *		to work properly in non GMT timezones.
  - * 12.Feb.96	Modified directive syntax to allow more readable commands:
  - *		  ExpiresDefault "now plus 10 days 20 seconds"
  - *		  ExpiresDefault "access plus 30 days"
  - *		  ExpiresDefault "modification plus 1 year 10 months 30 days"
  - * 13.Feb.96	Fix call to table_get() with NULL 2nd parameter [Rob Hartill]
  - * 19.Feb.96	Call gm_timestr_822() to get time formatted correctly, can't
  - *		rely on presence of HTTP_TIME_FORMAT in Apache 1.1+.
  - * 21.Feb.96	This version (0.0.9) reverses assumptions made in 0.0.8
  - *		about star/star handlers.  Reverting to 0.0.7 behaviour.
  + * 29.Jan.96    Hardened the add_* functions.  Server will now bail out
  + *              if bad directives are given in the conf files.
  + * 02.Feb.96    Returns DECLINED if not 'ExpiresActive on', giving other
  + *              expires-aware modules a chance to play with the same
  + *              directives. [Michael Rutman]
  + * 03.Feb.96    Call tzset() before localtime().  Trying to get the module
  + *              to work properly in non GMT timezones.
  + * 12.Feb.96    Modified directive syntax to allow more readable commands:
  + *                ExpiresDefault "now plus 10 days 20 seconds"
  + *                ExpiresDefault "access plus 30 days"
  + *                ExpiresDefault "modification plus 1 year 10 months 30 days"
  + * 13.Feb.96    Fix call to table_get() with NULL 2nd parameter [Rob Hartill]
  + * 19.Feb.96    Call gm_timestr_822() to get time formatted correctly, can't
  + *              rely on presence of HTTP_TIME_FORMAT in Apache 1.1+.
  + * 21.Feb.96    This version (0.0.9) reverses assumptions made in 0.0.8
  + *              about star/star handlers.  Reverting to 0.0.7 behaviour.
    * 08.Jun.96    allows ExpiresDefault to be used with responses that use 
    *              the DefaultType by not DECLINING, but instead skipping 
    *              the table_get check and then looking for an ExpiresDefault.
  @@ -181,7 +181,7 @@
    * proposal (in this case, a ttl of 20 seconds) [ask roy]
    * add per-file expiry and explicit expiry times - duplicates some
    * of the mod_cern_meta.c functionality.  eg:
  - * 		ExpiresExplicit index.html "modification plus 30 days"
  + *              ExpiresExplicit index.html "modification plus 30 days"
    *
    * BUGS
    * Hi, welcome to the internet.
  @@ -202,39 +202,39 @@
    */
   #define DIR_CMD_PERMS OR_INDEXES
   
  -#define ACTIVE_ON 	1
  -#define ACTIVE_OFF 	0
  +#define ACTIVE_ON       1
  +#define ACTIVE_OFF      0
   #define ACTIVE_DONTCARE 2
   
   module MODULE_VAR_EXPORT expires_module;
   
  -static void *create_dir_expires_config (pool *p, char *dummy)
  -{     
  +static void *create_dir_expires_config(pool *p, char *dummy)
  +{
       expires_dir_config *new =
  -        (expires_dir_config *) pcalloc (p, sizeof(expires_dir_config));
  +    (expires_dir_config *) pcalloc(p, sizeof(expires_dir_config));
       new->active = ACTIVE_DONTCARE;
       new->expiresdefault = "";
       new->expiresbytype = make_table(p, 4);
  -    return (void *)new;
  -}   
  +    return (void *) new;
  +}
   
  -static const char *set_expiresactive (cmd_parms *cmd, expires_dir_config *dir_config, int arg)
  +static const char *set_expiresactive(cmd_parms *cmd, expires_dir_config * dir_config, int arg)
   {
       /* if we're here at all it's because someone explicitly
        * set the active flag
        */
       dir_config->active = ACTIVE_ON;
  -    if ( arg == 0 ) {
  +    if (arg == 0) {
           dir_config->active = ACTIVE_OFF;
       };
       return NULL;
  -} 
  +}
   
   /* check_code() parse 'code' and return NULL or an error response
    * string.  If we return NULL then real_code contains code converted
    * to the cnnnn format.
    */
  -static char *check_code( pool *p, const char *code, char **real_code )
  +static char *check_code(pool *p, const char *code, char **real_code)
   {
       char *word;
       char base = 'X';
  @@ -245,9 +245,9 @@
   
       /* 0.0.4 compatibility?
        */
  -    if ( (code[0] == 'A') || (code[0] == 'M') ) {
  -	*real_code = pstrdup( p, code );
  -	return NULL;
  +    if ((code[0] == 'A') || (code[0] == 'M')) {
  +        *real_code = pstrdup(p, code);
  +        return NULL;
       };
   
       /* <base> [plus] {<num> <type>}*
  @@ -255,159 +255,172 @@
   
       /* <base>
        */
  -    word = getword_conf( p, &code );
  -    if ( !strncasecmp( word, "now", 1 ) ||
  -	 !strncasecmp( word, "access", 1 ) ) {
  -	base = 'A';
  -    } else if ( !strncasecmp( word, "modification", 1 ) ) {
  -	base = 'M';
  -    } else {
  -	return pstrcat( p, "bad expires code, unrecognised <base> '",
  -		word, "'", NULL);
  +    word = getword_conf(p, &code);
  +    if (!strncasecmp(word, "now", 1) ||
  +        !strncasecmp(word, "access", 1)) {
  +        base = 'A';
  +    }
  +    else if (!strncasecmp(word, "modification", 1)) {
  +        base = 'M';
  +    }
  +    else {
  +        return pstrcat(p, "bad expires code, unrecognised <base> '",
  +                       word, "'", NULL);
       };
   
       /* [plus]
        */
  -    word = getword_conf( p, &code );
  -    if ( !strncasecmp( word, "plus", 1 ) ) {
  -        word = getword_conf( p, &code );
  +    word = getword_conf(p, &code);
  +    if (!strncasecmp(word, "plus", 1)) {
  +        word = getword_conf(p, &code);
       };
   
       /* {<num> <type>}*
        */
  -    while ( word[0] ) {
  -	/* <num>
  -	 */
  -	if (isdigit(word[0])) {
  -	    num = atoi( word );
  -	} else {
  -            return pstrcat( p, "bad expires code, numeric value expected <num> '",
  -		word, "'", NULL);
  -	};
  -
  -	/* <type>
  -	 */
  -	word = getword_conf( p, &code );
  -	if ( word[0] ) {
  -	    /* do nothing */
  -	} else {
  -            return pstrcat( p, "bad expires code, missing <type>", NULL);
  -	};
  -
  -	factor = 0;
  -	if ( !strncasecmp( word, "years", 1 ) ) {
  -		factor = 60*60*24*365;
  -	} else if ( !strncasecmp( word, "months", 2 ) ) {
  -		factor = 60*60*24*30;
  -	} else if ( !strncasecmp( word, "weeks", 1 ) ) {
  -		factor = 60*60*24*7;
  -	} else if ( !strncasecmp( word, "days", 1 ) ) {
  -		factor = 60*60*24;
  -	} else if ( !strncasecmp( word, "hours", 1 ) ) {
  -		factor = 60*60;
  -	} else if ( !strncasecmp( word, "minutes", 2 ) ) {
  -		factor = 60;
  -	} else if ( !strncasecmp( word, "seconds", 1 ) ) {
  -		factor = 1;
  -	} else {
  -            return pstrcat( p, "bad expires code, unrecognised <type>", 
  -		"'", word, "'", NULL);
  -	};
  -
  -	modifier = modifier + factor * num;
  -
  -	/* next <num>
  -	 */
  -	word = getword_conf( p, &code );
  +    while (word[0]) {
  +        /* <num>
  +         */
  +        if (isdigit(word[0])) {
  +            num = atoi(word);
  +        }
  +        else {
  +            return pstrcat(p, "bad expires code, numeric value expected <num> '",
  +                           word, "'", NULL);
  +        };
  +
  +        /* <type>
  +         */
  +        word = getword_conf(p, &code);
  +        if (word[0]) {
  +            /* do nothing */
  +        }
  +        else {
  +            return pstrcat(p, "bad expires code, missing <type>", NULL);
  +        };
  +
  +        factor = 0;
  +        if (!strncasecmp(word, "years", 1)) {
  +            factor = 60 * 60 * 24 * 365;
  +        }
  +        else if (!strncasecmp(word, "months", 2)) {
  +            factor = 60 * 60 * 24 * 30;
  +        }
  +        else if (!strncasecmp(word, "weeks", 1)) {
  +            factor = 60 * 60 * 24 * 7;
  +        }
  +        else if (!strncasecmp(word, "days", 1)) {
  +            factor = 60 * 60 * 24;
  +        }
  +        else if (!strncasecmp(word, "hours", 1)) {
  +            factor = 60 * 60;
  +        }
  +        else if (!strncasecmp(word, "minutes", 2)) {
  +            factor = 60;
  +        }
  +        else if (!strncasecmp(word, "seconds", 1)) {
  +            factor = 1;
  +        }
  +        else {
  +            return pstrcat(p, "bad expires code, unrecognised <type>",
  +                           "'", word, "'", NULL);
  +        };
  +
  +        modifier = modifier + factor * num;
  +
  +        /* next <num>
  +         */
  +        word = getword_conf(p, &code);
       };
   
  -    ap_snprintf(foo, sizeof(foo), "%c%d", base, modifier );
  -    *real_code = pstrdup( p, foo );
  +    ap_snprintf(foo, sizeof(foo), "%c%d", base, modifier);
  +    *real_code = pstrdup(p, foo);
   
       return NULL;
   }
   
  -static const char *set_expiresbytype(cmd_parms *cmd, expires_dir_config *dir_config, char *mime, char *code)
  +static const char *set_expiresbytype(cmd_parms *cmd, expires_dir_config * dir_config, char *mime, char *code)
   {
       char *response, *real_code;
   
  -    if ( (response = check_code( cmd->pool, code, &real_code  )) == NULL ) {
  -        table_set (dir_config->expiresbytype, mime, real_code);
  -	return NULL;
  -    };
  -    return pstrcat( cmd->pool, 
  -	"'ExpiresByType ", mime, " ", code, "': ", response, NULL );
  -} 
  +    if ((response = check_code(cmd->pool, code, &real_code)) == NULL) {
  +        table_set(dir_config->expiresbytype, mime, real_code);
  +        return NULL;
  +    };
  +    return pstrcat(cmd->pool,
  +                 "'ExpiresByType ", mime, " ", code, "': ", response, NULL);
  +}
   
  -static const char *set_expiresdefault (cmd_parms *cmd, expires_dir_config *dir_config, char *code)
  +static const char *set_expiresdefault(cmd_parms *cmd, expires_dir_config * dir_config, char *code)
   {
       char *response, *real_code;
   
  -    if ( (response = check_code( cmd->pool, code, &real_code )) == NULL ) {
  -        dir_config->expiresdefault = pstrdup( cmd->pool, real_code );
  -	return NULL;
  -    };
  -    return pstrcat( cmd->pool, 
  -	"'ExpiresDefault ", code, "': ", response, NULL );
  -} 
  -
  -static command_rec expires_cmds[] = {
  -{ "ExpiresActive", set_expiresactive, NULL, DIR_CMD_PERMS, FLAG,
  -    "Limited to 'on' or 'off'"},
  -{ "ExpiresBytype", set_expiresbytype, NULL, DIR_CMD_PERMS, TAKE2,
  -    "a MIME type followed by an expiry date code"},
  -{ "ExpiresDefault", set_expiresdefault, NULL, DIR_CMD_PERMS, TAKE1,
  -    "an expiry date code"},
  -{ NULL }
  -};  
  +    if ((response = check_code(cmd->pool, code, &real_code)) == NULL) {
  +        dir_config->expiresdefault = pstrdup(cmd->pool, real_code);
  +        return NULL;
  +    };
  +    return pstrcat(cmd->pool,
  +                   "'ExpiresDefault ", code, "': ", response, NULL);
  +}
   
  -static void *merge_expires_dir_configs (pool *p, void *basev, void *addv)
  +static command_rec expires_cmds[] =
   {
  -    expires_dir_config *new= (expires_dir_config*)pcalloc (p, sizeof(expires_dir_config));
  -    expires_dir_config *base = (expires_dir_config *)basev;
  -    expires_dir_config *add = (expires_dir_config *)addv;
  +    {"ExpiresActive", set_expiresactive, NULL, DIR_CMD_PERMS, FLAG,
  +     "Limited to 'on' or 'off'"},
  +    {"ExpiresBytype", set_expiresbytype, NULL, DIR_CMD_PERMS, TAKE2,
  +     "a MIME type followed by an expiry date code"},
  +    {"ExpiresDefault", set_expiresdefault, NULL, DIR_CMD_PERMS, TAKE1,
  +     "an expiry date code"},
  +    {NULL}
  +};
   
  -    if ( add->active == ACTIVE_DONTCARE ) {
  -	new->active = base->active;
  -    } else {
  -	new->active = add->active;
  +static void *merge_expires_dir_configs(pool *p, void *basev, void *addv)
  +{
  +    expires_dir_config *new = (expires_dir_config *) pcalloc(p, sizeof(expires_dir_config));
  +    expires_dir_config *base = (expires_dir_config *) basev;
  +    expires_dir_config *add = (expires_dir_config *) addv;
  +
  +    if (add->active == ACTIVE_DONTCARE) {
  +        new->active = base->active;
  +    }
  +    else {
  +        new->active = add->active;
       };
   
  -    if ( add->expiresdefault != '\0' ) {
  +    if (add->expiresdefault != '\0') {
           new->expiresdefault = add->expiresdefault;
       };
   
  -    new->expiresbytype = overlay_tables (p, add->expiresbytype,
  -                                          base->expiresbytype);
  +    new->expiresbytype = overlay_tables(p, add->expiresbytype,
  +                                        base->expiresbytype);
       return new;
  -}  
  +}
   
   static int add_expires(request_rec *r)
   {
       expires_dir_config *conf;
       char *code;
  -    time_t base; 
  -    time_t additional; 
  -    time_t expires; 
  +    time_t base;
  +    time_t additional;
  +    time_t expires;
       char age[20];
   
  -    if (is_HTTP_ERROR(r->status))  /* Don't add Expires headers to errors */
  -	return DECLINED;
  +    if (is_HTTP_ERROR(r->status))       /* Don't add Expires headers to errors */
  +        return DECLINED;
   
  -    if (r->main != NULL)           /* Say no to subrequests */
  -	return DECLINED;
  +    if (r->main != NULL)        /* Say no to subrequests */
  +        return DECLINED;
   
  -    if ( r->finfo.st_mode == 0 )     /* no file ? shame. */
  -	return DECLINED;
  +    if (r->finfo.st_mode == 0)  /* no file ? shame. */
  +        return DECLINED;
   
  -    conf = (expires_dir_config *)get_module_config(r->per_dir_config, &expires_module);
  -    if ( conf == NULL ) {
  +    conf = (expires_dir_config *) get_module_config(r->per_dir_config, &expires_module);
  +    if (conf == NULL) {
           aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -		    "internal error: %s", r->filename);
  -	return SERVER_ERROR;
  +                    "internal error: %s", r->filename);
  +        return SERVER_ERROR;
       };
   
  -    if ( conf->active != ACTIVE_ON )
  +    if (conf->active != ACTIVE_ON)
           return DECLINED;
   
       /* we perhaps could use the default_type(r) in its place but that
  @@ -421,70 +434,71 @@
        *
        * Changed as of 08.Jun.96 don't DECLINE, look for an ExpiresDefault.
        */
  -    if ( r->content_type == NULL )
  -	code = NULL;
  +    if (r->content_type == NULL)
  +        code = NULL;
       else
  -	code = (char *) table_get( conf->expiresbytype, r->content_type );
  +        code = (char *) table_get(conf->expiresbytype, r->content_type);
   
  -    if ( code == NULL ) {
  -	/* no expires defined for that type, is there a default? */
  -	code = conf->expiresdefault;
  +    if (code == NULL) {
  +        /* no expires defined for that type, is there a default? */
  +        code = conf->expiresdefault;
   
  -        if ( code[0] == '\0' )
  -	    return OK;
  +        if (code[0] == '\0')
  +            return OK;
       };
   
       /* we have our code */
   
       switch (code[0]) {
  -	case 'M':
  -            base = r->finfo.st_mtime;
  -	    additional = atoi( &code[1] );
  -	    break;
  -	case 'A':
  -	    /* there's been some discussion and it's possible that 
  -	     * 'access time' will be stored in request structure
  -	     */
  -	    base = r->request_time;
  -	    additional = atoi( &code[1] );
  -	    break;
  -	default:
  -	    /* expecting the add_* routines to be case-hardened this 
  -	     * is just a reminder that module is beta
  -	     */
  -            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -			"internal error: bad expires code: %s", r->filename);
  -            return SERVER_ERROR;
  +    case 'M':
  +        base = r->finfo.st_mtime;
  +        additional = atoi(&code[1]);
  +        break;
  +    case 'A':
  +        /* there's been some discussion and it's possible that 
  +         * 'access time' will be stored in request structure
  +         */
  +        base = r->request_time;
  +        additional = atoi(&code[1]);
  +        break;
  +    default:
  +        /* expecting the add_* routines to be case-hardened this 
  +         * is just a reminder that module is beta
  +         */
  +        aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  +                    "internal error: bad expires code: %s", r->filename);
  +        return SERVER_ERROR;
       };
   
       expires = base + additional;
  -    ap_snprintf(age, sizeof(age), "max-age=%d", (int)expires - (int)r->request_time);
  -    table_set( r->headers_out, "Cache-Control", age);
  -    tzset();	/* redundant? called implicitly by localtime, at least 
  -		 * under FreeBSD
  -		 */
  -    table_set( r->headers_out, "Expires", gm_timestr_822( r->pool, expires ));
  +    ap_snprintf(age, sizeof(age), "max-age=%d", (int) expires - (int) r->request_time);
  +    table_set(r->headers_out, "Cache-Control", age);
  +    tzset();                    /* redundant? called implicitly by localtime, at least 
  +                                 * under FreeBSD
  +                                 */
  +    table_set(r->headers_out, "Expires", gm_timestr_822(r->pool, expires));
       return OK;
   }
   
  -module MODULE_VAR_EXPORT expires_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,			/* initializer */
  -   create_dir_expires_config,	/* dir config creater */
  -   merge_expires_dir_configs,	/* dir merger --- default is to override */
  -   NULL,			/* server config */
  -   NULL,			/* merge server configs */
  -   expires_cmds,		/* command table */
  -   NULL,			/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   add_expires,			/* fixups */
  -   NULL,			/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module MODULE_VAR_EXPORT expires_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    create_dir_expires_config,  /* dir config creater */
  +    merge_expires_dir_configs,  /* dir merger --- default is to override */
  +    NULL,                       /* server config */
  +    NULL,                       /* merge server configs */
  +    expires_cmds,               /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    add_expires,                /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.10      +74 -70    apachen/src/modules/standard/mod_headers.c
  
  Index: mod_headers.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_headers.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- mod_headers.c	1997/08/18 13:12:12	1.9
  +++ mod_headers.c	1997/09/18 18:40:53	1.10
  @@ -100,10 +100,10 @@
   #include "http_config.h"
   
   typedef enum {
  -    hdr_add = 'a',		/* add header (could mean multiple hdrs) */
  -    hdr_set = 's',		/* set (replace old value) */
  -    hdr_append = 'm',		/* append (merge into any old value) */
  -    hdr_unset = 'u'		/* unset header */
  +    hdr_add = 'a',              /* add header (could mean multiple hdrs) */
  +    hdr_set = 's',              /* set (replace old value) */
  +    hdr_append = 'm',           /* append (merge into any old value) */
  +    hdr_unset = 'u'             /* unset header */
   } hdr_actions;
   
   typedef struct {
  @@ -122,26 +122,25 @@
   
   module MODULE_VAR_EXPORT headers_module;
   
  -static void *create_headers_config (pool *p, server_rec *s)
  +static void *create_headers_config(pool *p, server_rec *s)
   {
       headers_conf *a =
  -      (headers_conf *)pcalloc (p, sizeof(headers_conf));
  +    (headers_conf *) pcalloc(p, sizeof(headers_conf));
   
  -    a->headers = make_array (p, 2, sizeof(header_entry));
  +    a->headers = make_array(p, 2, sizeof(header_entry));
       return a;
   }
   
  -static void *create_headers_dir_config (pool *p, char *d)
  +static void *create_headers_dir_config(pool *p, char *d)
   {
  -    return (headers_conf*)create_headers_config(p, NULL);
  +    return (headers_conf *) create_headers_config(p, NULL);
   }
   
  -static void *merge_headers_config (pool *p, void *basev, void *overridesv)
  +static void *merge_headers_config(pool *p, void *basev, void *overridesv)
   {
       headers_conf *a =
  -	(headers_conf *)pcalloc (p, sizeof(headers_conf));
  -    headers_conf *base = (headers_conf *)basev,
  -	*overrides = (headers_conf *)overridesv;
  +    (headers_conf *) pcalloc(p, sizeof(headers_conf));
  +    headers_conf *base = (headers_conf *) basev, *overrides = (headers_conf *) overridesv;
   
       a->headers = append_arrays(p, base->headers, overrides->headers);
   
  @@ -149,35 +148,38 @@
   }
   
   
  -static const char *header_cmd(cmd_parms *cmd, headers_conf *dirconf, char *action, char *hdr, char *value)
  +static const char *header_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value)
   {
       header_entry *new;
       server_rec *s = cmd->server;
       headers_conf *serverconf =
  -        (headers_conf *)get_module_config(s->module_config,&headers_module);
  +    (headers_conf *) get_module_config(s->module_config, &headers_module);
       char *colon;
   
  -    if ( cmd->path )
  -    {
  -	new = (header_entry*)push_array(dirconf->headers);
  +    if (cmd->path) {
  +        new = (header_entry *) push_array(dirconf->headers);
       }
  -    else
  -    {
  -	new = (header_entry*)push_array(serverconf->headers);
  +    else {
  +        new = (header_entry *) push_array(serverconf->headers);
       }
   
  -    if (!strcasecmp(action, "set")) new->action = hdr_set;
  -    else if (!strcasecmp(action, "add")) new->action = hdr_add;
  -    else if (!strcasecmp(action, "append")) new->action = hdr_append;
  -    else if (!strcasecmp(action, "unset")) new->action = hdr_unset;
  -    else 
  -	return "first argument must be add, set, append or unset.";
  +    if (!strcasecmp(action, "set"))
  +        new->action = hdr_set;
  +    else if (!strcasecmp(action, "add"))
  +        new->action = hdr_add;
  +    else if (!strcasecmp(action, "append"))
  +        new->action = hdr_append;
  +    else if (!strcasecmp(action, "unset"))
  +        new->action = hdr_unset;
  +    else
  +        return "first argument must be add, set, append or unset.";
   
       if (new->action == hdr_unset) {
  -	if (value) return "Header unset takes two arguments";
  +        if (value)
  +            return "Header unset takes two arguments";
       }
       else if (!value)
  -	return "Header requires three arguments";
  +        return "Header requires three arguments";
   
       if ((colon = strchr(hdr, ':')))
           *colon = '\0';
  @@ -188,10 +190,11 @@
       return NULL;
   }
   
  -static command_rec headers_cmds[] = {
  -{ "Header", header_cmd, NULL, OR_FILEINFO, TAKE23, 
  -    "an action, header and value"},
  -{ NULL }
  +static command_rec headers_cmds[] =
  +{
  +    {"Header", header_cmd, NULL, OR_FILEINFO, TAKE23,
  +     "an action, header and value"},
  +    {NULL}
   };
   
   static void do_headers_fixup(request_rec *r, array_header *headers)
  @@ -199,21 +202,21 @@
       int i;
   
       for (i = 0; i < headers->nelts; ++i) {
  -	header_entry *hdr = &((header_entry*)(headers->elts))[i];
  -	switch (hdr->action) {
  -	case hdr_add:
  -	    table_add(r->headers_out, hdr->header, hdr->value);
  -	    break;
  -	case hdr_append:
  -	    table_merge(r->headers_out, hdr->header, hdr->value);
  -	    break;
  -	case hdr_set:
  -	    table_set(r->headers_out, hdr->header, hdr->value);
  -	    break;
  -	case hdr_unset:
  -	    table_unset(r->headers_out, hdr->header);
  -	    break;
  -	}
  +        header_entry *hdr = &((header_entry *) (headers->elts))[i];
  +        switch (hdr->action) {
  +        case hdr_add:
  +            table_add(r->headers_out, hdr->header, hdr->value);
  +            break;
  +        case hdr_append:
  +            table_merge(r->headers_out, hdr->header, hdr->value);
  +            break;
  +        case hdr_set:
  +            table_set(r->headers_out, hdr->header, hdr->value);
  +            break;
  +        case hdr_unset:
  +            table_unset(r->headers_out, hdr->header);
  +            break;
  +        }
       }
   
   }
  @@ -222,10 +225,10 @@
   {
       void *sconf = r->server->module_config;
       headers_conf *serverconf =
  -        (headers_conf *)get_module_config(sconf, &headers_module);
  +    (headers_conf *) get_module_config(sconf, &headers_module);
       void *dconf = r->per_dir_config;
       headers_conf *dirconf =
  -        (headers_conf *)get_module_config(dconf, &headers_module);
  +    (headers_conf *) get_module_config(dconf, &headers_module);
   
       do_headers_fixup(r, serverconf->headers);
       do_headers_fixup(r, dirconf->headers);
  @@ -233,24 +236,25 @@
       return DECLINED;
   }
   
  -module MODULE_VAR_EXPORT headers_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,			/* initializer */
  -   create_headers_dir_config,	/* dir config creater */
  -   merge_headers_config,	/* dir merger --- default is to override */
  -   create_headers_config,	/* server config */
  -   merge_headers_config,	/* merge server configs */
  -   headers_cmds,		/* command table */
  -   NULL,			/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   fixup_headers,		/* fixups */
  -   NULL,			/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module MODULE_VAR_EXPORT headers_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    create_headers_dir_config,  /* dir config creater */
  +    merge_headers_config,       /* dir merger --- default is to override */
  +    create_headers_config,      /* server config */
  +    merge_headers_config,       /* merge server configs */
  +    headers_cmds,               /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    fixup_headers,              /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.31      +597 -579  apachen/src/modules/standard/mod_imap.c
  
  Index: mod_imap.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_imap.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- mod_imap.c	1997/08/31 23:15:52	1.30
  +++ mod_imap.c	1997/09/18 18:40:54	1.31
  @@ -107,53 +107,55 @@
   #define IMAP_BASE_DEFAULT "map"
   
   #ifdef SUNOS4
  -double strtod();   /* SunOS needed this */
  +double strtod();                /* SunOS needed this */
   #endif
   
   module MODULE_VAR_EXPORT imap_module;
   
  -typedef struct { 
  -  char *imap_menu;
  -  char *imap_default;
  -  char *imap_base;
  +typedef struct {
  +    char *imap_menu;
  +    char *imap_default;
  +    char *imap_base;
   } imap_conf_rec;
   
  -static void *create_imap_dir_config (pool *p, char *dummy) { 
  -  imap_conf_rec *icr = 
  -    (imap_conf_rec *)palloc(p, sizeof(imap_conf_rec));
  -
  -  icr->imap_menu = NULL;
  -  icr->imap_default = NULL;
  -  icr->imap_base = NULL;
  -
  -  return icr;
  -}
  -
  -static void *merge_imap_dir_configs (pool *p, void *basev, void *addv)
  -{
  -  imap_conf_rec *new=(imap_conf_rec *)pcalloc (p, sizeof(imap_conf_rec));
  -  imap_conf_rec *base = (imap_conf_rec *)basev;
  -  imap_conf_rec *add = (imap_conf_rec *)addv;
  - 
  -  new->imap_menu = add->imap_menu ? add->imap_menu : base->imap_menu;
  -  new->imap_default=add->imap_default ? add->imap_default : base->imap_default;
  -  new->imap_base =add-> imap_base ? add->imap_base : base->imap_base;
  -
  -  return new;
  +static void *create_imap_dir_config(pool *p, char *dummy)
  +{
  +    imap_conf_rec *icr =
  +    (imap_conf_rec *) palloc(p, sizeof(imap_conf_rec));
  +
  +    icr->imap_menu = NULL;
  +    icr->imap_default = NULL;
  +    icr->imap_base = NULL;
  +
  +    return icr;
  +}
  +
  +static void *merge_imap_dir_configs(pool *p, void *basev, void *addv)
  +{
  +    imap_conf_rec *new = (imap_conf_rec *) pcalloc(p, sizeof(imap_conf_rec));
  +    imap_conf_rec *base = (imap_conf_rec *) basev;
  +    imap_conf_rec *add = (imap_conf_rec *) addv;
  +
  +    new->imap_menu = add->imap_menu ? add->imap_menu : base->imap_menu;
  +    new->imap_default = add->imap_default ? add->imap_default : base->imap_default;
  +    new->imap_base = add->imap_base ? add->imap_base : base->imap_base;
  +
  +    return new;
   }
   
   
  -static command_rec imap_cmds[] = {
  -{ "ImapMenu", set_string_slot, 
  -    (void*)XtOffsetOf(imap_conf_rec, imap_menu), OR_INDEXES, TAKE1,
  -    "the type of menu generated: none, formatted, semiformatted, unformatted"},
  -{ "ImapDefault", set_string_slot, 
  -    (void*)XtOffsetOf(imap_conf_rec, imap_default), OR_INDEXES, TAKE1,
  -    "the action taken if no match: error, nocontent, referer, menu, URL" },
  -{ "ImapBase", set_string_slot, 
  -    (void*)XtOffsetOf(imap_conf_rec, imap_base), OR_INDEXES, TAKE1,
  -    "the base for all URL's: map, referer, URL (or start of)" },
  -{ NULL }
  +static command_rec imap_cmds[] =
  +{
  +    {"ImapMenu", set_string_slot,
  +     (void *) XtOffsetOf(imap_conf_rec, imap_menu), OR_INDEXES, TAKE1,
  + "the type of menu generated: none, formatted, semiformatted, unformatted"},
  +    {"ImapDefault", set_string_slot,
  +     (void *) XtOffsetOf(imap_conf_rec, imap_default), OR_INDEXES, TAKE1,
  +     "the action taken if no match: error, nocontent, referer, menu, URL"},
  +    {"ImapBase", set_string_slot,
  +     (void *) XtOffsetOf(imap_conf_rec, imap_base), OR_INDEXES, TAKE1,
  +     "the base for all URL's: map, referer, URL (or start of)"},
  +    {NULL}
   };
   
   static int pointinrect(double point[2], double coords[MAXVERTS][2])
  @@ -162,7 +164,8 @@
       if (coords[0][X] > coords[1][X]) {
           max[0] = coords[0][X];
           min[0] = coords[1][X];
  -    } else {
  +    }
  +    else {
           max[0] = coords[1][X];
           min[0] = coords[0][X];
       }
  @@ -170,13 +173,14 @@
       if (coords[0][Y] > coords[1][Y]) {
           max[1] = coords[0][Y];
           min[1] = coords[1][Y];
  -    } else {
  +    }
  +    else {
           max[1] = coords[1][Y];
           min[1] = coords[0][Y];
       }
   
       return ((point[X] >= min[0] && point[X] <= max[0]) &&
  -	    (point[Y] >= min[1] && point[Y] <= max[1]));
  +            (point[Y] >= min[1] && point[Y] <= max[1]));
   }
   
   static int pointincircle(double point[2], double coords[MAXVERTS][2])
  @@ -184,10 +188,10 @@
       double radius1, radius2;
   
       radius1 = ((coords[0][Y] - coords[1][Y]) * (coords[0][Y] - coords[1][Y]))
  -	+ ((coords[0][X] - coords[1][X]) * (coords[0][X] - coords[1][X]));
  -    
  +        + ((coords[0][X] - coords[1][X]) * (coords[0][X] - coords[1][X]));
  +
       radius2 = ((coords[0][Y] - point[Y]) * (coords[0][Y] - point[Y]))
  -	+ ((coords[0][X] - point[X]) * (coords[0][X] - point[X]));
  +        + ((coords[0][X] - point[X]) * (coords[0][X] - point[X]));
   
       return (radius2 <= radius1);
   }
  @@ -211,54 +215,54 @@
       p = (double *) pgon + 1;
       if ((y >= ty) != (*p >= ty)) {
   
  -	if ((xflag0 = (pgon[numverts - 1][X] >= tx)) == (*(double *) pgon >= tx)) {
  -	    if (xflag0)
  -		crossings++;
  -	}
  -	else {
  -	    crossings += (pgon[numverts - 1][X] - (y - ty) *
  -			  (*(double *) pgon - pgon[numverts - 1][X]) /
  -			  (*p - y)) >= tx;
  -	}
  +        if ((xflag0 = (pgon[numverts - 1][X] >= tx)) == (*(double *) pgon >= tx)) {
  +            if (xflag0)
  +                crossings++;
  +        }
  +        else {
  +            crossings += (pgon[numverts - 1][X] - (y - ty) *
  +                          (*(double *) pgon - pgon[numverts - 1][X]) /
  +                          (*p - y)) >= tx;
  +        }
       }
   
       stop = pgon[numverts];
   
       for (y = *p, p += 2; p < stop; y = *p, p += 2) {
  -	
  -	if (y >= ty) {
  -        
  -	    while ((p < stop) && (*p >= ty))
  -		p += 2;
  -	    
  -	    if (p >= stop)
  -		break;
  -	    if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
  -		
  -		if (xflag0)
  -		    crossings++;
  -	    }
  -	    else {
  -		crossings += (*(p - 3) - (*(p - 2) - ty) *
  -			      (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
  -	    }
  -	}
  -	else {
  -	    while ((p < stop) && (*p < ty))
  -		p += 2;
  -
  -	    if (p >= stop)
  -		break;
  -
  -	    if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
  -		if (xflag0)
  -		    crossings++;
  -	    }
  -	    else {
  -		crossings += (*(p - 3) - (*(p - 2) - ty) *
  -			      (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
  -	    }
  -	}
  +
  +        if (y >= ty) {
  +
  +            while ((p < stop) && (*p >= ty))
  +                p += 2;
  +
  +            if (p >= stop)
  +                break;
  +            if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
  +
  +                if (xflag0)
  +                    crossings++;
  +            }
  +            else {
  +                crossings += (*(p - 3) - (*(p - 2) - ty) *
  +                              (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
  +            }
  +        }
  +        else {
  +            while ((p < stop) && (*p < ty))
  +                p += 2;
  +
  +            if (p >= stop)
  +                break;
  +
  +            if ((xflag0 = (*(p - 3) >= tx)) == (*(p - 1) >= tx)) {
  +                if (xflag0)
  +                    crossings++;
  +            }
  +            else {
  +                crossings += (*(p - 3) - (*(p - 2) - ty) *
  +                              (*(p - 1) - *(p - 3)) / (*p - *(p - 2))) >= tx;
  +            }
  +        }
       }
   
       inside_flag = crossings & 0x01;
  @@ -268,580 +272,594 @@
   
   static int is_closer(double point[2], double coords[MAXVERTS][2], double *closest)
   {
  -  double dist_squared =((point[X] - coords[0][X]) * (point[X] - coords[0][X]))
  -	     + ((point[Y] - coords[0][Y]) * (point[Y] - coords[0][Y]));
  +    double dist_squared = ((point[X] - coords[0][X]) * (point[X] - coords[0][X]))
  +    + ((point[Y] - coords[0][Y]) * (point[Y] - coords[0][Y]));
   
  -  if (point[X] < 0 || point[Y] < 0 ) 
  -    return(0);          /* don't mess around with negative coordinates */
  +    if (point[X] < 0 || point[Y] < 0)
  +        return (0);             /* don't mess around with negative coordinates */
  +
  +    if (*closest < 0 || dist_squared < *closest) {
  +        *closest = dist_squared;
  +        return (1);             /* if this is the first point or is the closest yet
  +                                   set 'closest' equal to this distance^2 */
  +    }
   
  -  if ( *closest < 0 || dist_squared < *closest ) {
  -    *closest = dist_squared;
  -    return(1);         /* if this is the first point or is the closest yet
  -			  set 'closest' equal to this distance^2 */
  -  }
  -  
  -  return(0);           /* if it's not the first or closest */
  +    return (0);                 /* if it's not the first or closest */
   
   }
   
  -static double get_x_coord(char *args) 
  +static double get_x_coord(char *args)
   {
  -  char *endptr;           /* we want it non-null */
  -  double x_coord = -1;    /* -1 is returned if no coordinate is given */
  +    char *endptr;               /* we want it non-null */
  +    double x_coord = -1;        /* -1 is returned if no coordinate is given */
   
  -  if (args == NULL)
  -    return(-1);           /* in case we aren't passed anything */
  +    if (args == NULL)
  +        return (-1);            /* in case we aren't passed anything */
   
  -  while( *args && !isdigit(*args) && *args != ',') 
  -    args++;   /* jump to the first digit, but not past a comma or end */
  +    while (*args && !isdigit(*args) && *args != ',')
  +        args++;                 /* jump to the first digit, but not past a comma or end */
   
  -  x_coord = strtod(args, &endptr);
  +    x_coord = strtod(args, &endptr);
   
  -  if (endptr > args)   /* if a conversion was made */
  -    return(x_coord); 
  +    if (endptr > args)          /* if a conversion was made */
  +        return (x_coord);
   
  -  return(-1);  /* else if no conversion was made, or if no args was given */
  +    return (-1);                /* else if no conversion was made, or if no args was given */
   }
   
  -static double get_y_coord(char *args) 
  +static double get_y_coord(char *args)
   {
  -  char *endptr;        /* we want it non-null */
  -  char *start_of_y = NULL;
  -  double y_coord = -1;    /* -1 is returned on error */
  +    char *endptr;               /* we want it non-null */
  +    char *start_of_y = NULL;
  +    double y_coord = -1;        /* -1 is returned on error */
   
  -  if (args == NULL)
  -    return(-1);           /* in case we aren't passed anything */
  +    if (args == NULL)
  +        return (-1);            /* in case we aren't passed anything */
   
  -  start_of_y = strchr(args, ',');  /* the comma */
  +    start_of_y = strchr(args, ',');     /* the comma */
   
  -  if (start_of_y) {
  -    
  -    start_of_y++;    /* start looking at the character after the comma */
  +    if (start_of_y) {
   
  -    while( *start_of_y && !isdigit(*start_of_y))  
  -      start_of_y++;  /* jump to the first digit, but not past the end */
  +        start_of_y++;           /* start looking at the character after the comma */
   
  -    y_coord = strtod(start_of_y, &endptr);
  +        while (*start_of_y && !isdigit(*start_of_y))
  +            start_of_y++;       /* jump to the first digit, but not past the end */
   
  -    if (endptr > start_of_y) 
  -      return(y_coord); 
  -  }
  -  
  -  return(-1);   /* if no conversion was made, or no comma was found in args */
  +        y_coord = strtod(start_of_y, &endptr);
  +
  +        if (endptr > start_of_y)
  +            return (y_coord);
  +    }
  +
  +    return (-1);                /* if no conversion was made, or no comma was found in args */
   }
  -  
  +
   
   static int read_quoted(char *string, char *quoted_part)
  -{ 
  -  char *starting_pos = string;
  -  
  -  while ( isspace(*string) )
  -    string++;    /* go along string until non-whitespace */
  +{
  +    char *starting_pos = string;
   
  -  if ( *string == '"' ) { /* if that character is a double quote */
  +    while (isspace(*string))
  +        string++;               /* go along string until non-whitespace */
   
  -    string++;  /* step over it */
  +    if (*string == '"') {       /* if that character is a double quote */
   
  -    while ( *string && *string != '"' ) {
  -      *quoted_part++ = *string++;  /* copy the quoted portion */
  -    }
  +        string++;               /* step over it */
  +
  +        while (*string && *string != '"') {
  +            *quoted_part++ = *string++;         /* copy the quoted portion */
  +        }
   
  -    *quoted_part = '\0';  /* end the string with a SNUL */
  -	
  -    string++;  /* step over the last double quote */
  -  }
  +        *quoted_part = '\0';    /* end the string with a SNUL */
  +
  +        string++;               /* step over the last double quote */
  +    }
   
  -  return(string - starting_pos); /* return the total characters read */
  +    return (string - starting_pos);     /* return the total characters read */
   }
   
   /*
    * url needs to point to a string with at least SMALLBUF memory allocated
    */
  -static void imap_url(request_rec *r, char *base, char *value, char *url) 
  +static void imap_url(request_rec *r, char *base, char *value, char *url)
   {
   /* translates a value into a URL. */
  -  int slen, clen;
  -  char *string_pos = NULL;
  -  char *directory = NULL;
  -  char *referer = NULL;
  -  char my_base[SMALLBUF] = {'\0'};
  -
  -  if ( ! strcasecmp(value, "map" ) || ! strcasecmp(value, "menu") ) {
  -    if (r->server->port == DEFAULT_PORT ) { 
  -      ap_snprintf(url, SMALLBUF,
  -		"http://%s%s", r->server->server_hostname, r->uri);
  -    }
  -    else {
  -      ap_snprintf(url, SMALLBUF, "http://%s:%d%s", r->server->server_hostname,
  -	      r->server->port, r->uri);      
  -    }
  -    return;  
  -  }
  +    int slen, clen;
  +    char *string_pos = NULL;
  +    char *directory = NULL;
  +    char *referer = NULL;
  +    char my_base[SMALLBUF] =
  +    {'\0'};
  +
  +    if (!strcasecmp(value, "map") || !strcasecmp(value, "menu")) {
  +        if (r->server->port == DEFAULT_PORT) {
  +            ap_snprintf(url, SMALLBUF,
  +                        "http://%s%s", r->server->server_hostname, r->uri);
  +        }
  +        else {
  +            ap_snprintf(url, SMALLBUF, "http://%s:%d%s", r->server->server_hostname,
  +                        r->server->port, r->uri);
  +        }
  +        return;
  +    }
  +
  +    if (!strcasecmp(value, "nocontent") || !strcasecmp(value, "error")) {
  +        strncpy(url, value, SMALLBUF - 1);
  +        url[SMALLBUF - 1] = '\0';
  +        return;                 /* these are handled elsewhere, so just copy them */
  +    }
  +
  +    if (!strcasecmp(value, "referer")) {
  +        referer = table_get(r->headers_in, "Referer");
  +        if (referer && *referer) {
  +            strncpy(url, referer, SMALLBUF - 1);
  +            url[SMALLBUF - 1] = '\0';
  +            return;
  +        }
  +        else {
  +            *value = '\0';      /* if 'referer' but no referring page, null the value */
  +        }
  +    }
  +
  +    string_pos = value;
  +    while (isalpha(*string_pos))
  +        string_pos++;           /* go along the URL from the map until a non-letter */
  +    if (*string_pos == ':') {
  +        strncpy(url, value, SMALLBUF - 1);      /* if letters and then a colon (like http:) */
  +        url[SMALLBUF - 1] = '\0';
  +        return;                 /* it's an absolute URL, so use it! */
  +    }
  +
  +    if (!base || !*base) {
  +        if (value && *value) {
  +            strncpy(url, value, SMALLBUF - 1);  /* no base: use what is given */
  +            url[SMALLBUF - 1] = '\0';
  +        }
  +        else {
  +            if (r->server->port == DEFAULT_PORT) {
  +                ap_snprintf(url, SMALLBUF, "http://%s/", r->server->server_hostname);
  +            }
  +            if (r->server->port != DEFAULT_PORT) {
  +                ap_snprintf(url, SMALLBUF, "http://%s:%d/",
  +                            r->server->server_hostname, r->server->port);
  +            }                   /* no base, no value: pick a simple default */
  +        }
  +        return;
  +    }
  +
  +    /* must be a relative URL to be combined with base */
  +    strncpy(my_base, base, sizeof(my_base) - 1);
  +    my_base[sizeof(my_base) - 1] = '\0';
  +    if (strchr(my_base, '/') == NULL && (!strncmp(value, "../", 3) || !strcmp(value, ".."))) {
  +        url[0] = '\0';
  +        aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  +                    "invalid base directive in map file: %s", r->uri);
  +        return;
  +    }
  +    string_pos = my_base;
  +    while (*string_pos) {
  +        if (*string_pos == '/' && *(string_pos + 1) == '/') {
  +            string_pos += 2;    /* if there are two slashes, jump over them */
  +            continue;
  +        }
  +        if (*string_pos == '/') {       /* the first single slash */
  +            if (value[0] == '/') {
  +                *string_pos = '\0';
  +            }                   /* if the URL from the map starts from root, end the
  +                                   base URL string at the first single slash */
  +            else {
  +                directory = string_pos;         /* save the start of the directory portion */
  +
  +                string_pos = strrchr(string_pos, '/');  /* now reuse string_pos */
  +                string_pos++;   /* step over that last slash */
  +                *string_pos = '\0';
  +            }                   /* but if the map url is relative, leave the
  +                                   slash on the base (if there is one) */
  +            break;
  +        }
  +        string_pos++;           /* until we get to the end of my_base without finding
  +                                   a slash by itself */
  +    }
  +
  +    while (!strncmp(value, "../", 3) || !strcmp(value, "..")) {
  +
  +        if (directory && (slen = strlen(directory))) {
  +
  +            /* for each '..',  knock a directory off the end 
  +               by ending the string right at the last slash.
  +               But only consider the directory portion: don't eat
  +               into the server name.  And only try if a directory
  +               portion was found */
  +
  +            clen = slen - 1;
  +
  +            while ((slen - clen) == 1) {
  +
  +                if ((string_pos = strrchr(directory, '/')))
  +                    *string_pos = '\0';
  +                clen = strlen(directory);
  +                if (clen == 0)
  +                    break;
  +            }
  +
  +            value += 2;         /* jump over the '..' that we found in the value */
  +        }
  +        else if (directory) {
  +            url[0] = '\0';
  +            aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  +                        "invalid directory name in map file: %s", r->uri);
  +            return;
  +        }
  +
  +        if (!strncmp(value, "/../", 4) || !strcmp(value, "/.."))
  +            value++;            /* step over the '/' if there are more '..' to do.
  +                                   this way, we leave the starting '/' on value after
  +                                   the last '..', but get rid of it otherwise */
   
  -  if ( ! strcasecmp(value, "nocontent") || ! strcasecmp(value, "error") ) {
  -    strncpy(url, value, SMALLBUF-1);
  -    url[SMALLBUF-1] = '\0';
  -    return;    /* these are handled elsewhere, so just copy them */
  -  }
  -
  -  if ( ! strcasecmp(value, "referer" ) ) {
  -    referer = table_get(r->headers_in, "Referer");
  -    if ( referer && *referer ) {
  -      strncpy(url, referer, SMALLBUF-1);
  -      url[SMALLBUF-1] = '\0';
  -      return;
  +    }                           /* by this point, value does not start with '..' */
  +
  +    if (value && *value) {
  +        ap_snprintf(url, SMALLBUF, "%s%s", my_base, value);
       }
       else {
  -      *value = '\0';  /* if 'referer' but no referring page, null the value */
  -    }                 
  -  }         
  -
  -  string_pos = value;
  -  while ( isalpha(*string_pos) )
  -    string_pos++;    /* go along the URL from the map until a non-letter */
  -  if ( *string_pos == ':' ) { 
  -    strncpy(url, value, SMALLBUF-1);        /* if letters and then a colon (like http:) */
  -    url[SMALLBUF-1] = '\0';
  -    return;                    /* it's an absolute URL, so use it! */
  -  }
  -
  -  if ( ! base || ! *base ) {
  -    if ( value && *value ) {  
  -      strncpy(url, value, SMALLBUF-1);   /* no base: use what is given */
  -      url[SMALLBUF-1] = '\0';
  -    }         
  -    else {                  
  -      if (r->server->port == DEFAULT_PORT ) {  
  -	ap_snprintf(url, SMALLBUF, "http://%s/", r->server->server_hostname);
  -      }            
  -      if (r->server->port != DEFAULT_PORT ) {
  -	ap_snprintf(url, SMALLBUF, "http://%s:%d/",
  -		r->server->server_hostname, r->server->port);
  -      }                     /* no base, no value: pick a simple default */
  -    }
  -    return;  
  -  }
  -
  -  /* must be a relative URL to be combined with base */
  -  strncpy(my_base, base, sizeof(my_base)-1);
  -  my_base[sizeof(my_base)-1] = '\0';
  -  if (strchr(my_base, '/') == NULL && (!strncmp(value, "../", 3) || !strcmp(value, "..")) ) {
  -    url[0] = '\0';
  -    aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -		"invalid base directive in map file: %s", r->uri);
  +        ap_snprintf(url, SMALLBUF, "%s", my_base);
  +    }
       return;
  -  }
  -  string_pos = my_base; 
  -  while (*string_pos) {  
  -    if (*string_pos == '/' && *(string_pos+1) == '/') {
  -      string_pos += 2;  /* if there are two slashes, jump over them */
  -      continue;
  -    }
  -    if (*string_pos == '/') {  /* the first single slash */
  -	if ( value[0] == '/' ) {
  -	  *string_pos = '\0';  
  -	}              /* if the URL from the map starts from root, end the
  -			  base URL string at the first single slash */
  -	else {
  -	  directory = string_pos; /* save the start of the directory portion */
  -
  -	  string_pos = strrchr(string_pos, '/');  /* now reuse string_pos */
  -	  string_pos++;  /* step over that last slash */
  -	  *string_pos = '\0';
  -	}              /* but if the map url is relative, leave the
  -			slash on the base (if there is one) */
  -	break;
  -      }
  -    string_pos++;   /* until we get to the end of my_base without finding
  -		       a slash by itself */
  -  }
  -
  -  while ( ! strncmp(value, "../", 3) || ! strcmp(value, "..") ) { 
  -
  -      if (directory && (slen = strlen (directory))) {
  -
  -	  /* for each '..',  knock a directory off the end 
  -	     by ending the string right at the last slash.
  -	     But only consider the directory portion: don't eat
  -	     into the server name.  And only try if a directory
  -	     portion was found */    
  -	  
  -	  clen = slen - 1;
  -	
  -	  while ((slen - clen) == 1) {
  -	
  -	      if ((string_pos = strrchr(directory, '/')))
  -		  *string_pos = '\0';
  -	      clen = strlen (directory);
  -	      if (clen == 0) break;
  -	  }
  -
  -	  value += 2;      /* jump over the '..' that we found in the value */
  -      } else if (directory) {
  -	url[0] = '\0';
  -	aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  -		    "invalid directory name in map file: %s", r->uri);
  -	return;
  -      }
  -      
  -      if (! strncmp(value, "/../", 4) || ! strcmp(value, "/..") )
  -
  -	  value++;       /* step over the '/' if there are more '..' to do.
  -			   this way, we leave the starting '/' on value after
  -			   the last '..', but get rid of it otherwise */ 
  -     
  -  }                   /* by this point, value does not start with '..' */
  -
  -  if ( value && *value ) {
  -    ap_snprintf(url, SMALLBUF, "%s%s", my_base, value);   
  -  }
  -  else {
  -    ap_snprintf(url, SMALLBUF, "%s", my_base);   
  -  }
  -  return;
   }
   
   static int imap_reply(request_rec *r, char *redirect)
  -{ 
  -  if ( ! strcasecmp(redirect, "error") ) {
  -    return SERVER_ERROR;  /* they actually requested an error! */
  -  }
  -  if ( ! strcasecmp(redirect, "nocontent") ) {
  -    return HTTP_NO_CONTENT; /* tell the client to keep the page it has */
  -  }
  -  if (redirect && *redirect ) { 
  -    table_set(r->headers_out, "Location", redirect);
  -    return REDIRECT;      /* must be a URL, so redirect to it */
  -  }    
  -  return SERVER_ERROR;
  +{
  +    if (!strcasecmp(redirect, "error")) {
  +        return SERVER_ERROR;    /* they actually requested an error! */
  +    }
  +    if (!strcasecmp(redirect, "nocontent")) {
  +        return HTTP_NO_CONTENT; /* tell the client to keep the page it has */
  +    }
  +    if (redirect && *redirect) {
  +        table_set(r->headers_out, "Location", redirect);
  +        return REDIRECT;        /* must be a URL, so redirect to it */
  +    }
  +    return SERVER_ERROR;
   }
   
   static void menu_header(request_rec *r, char *menu)
   {
  -  r->content_type = "text/html";
  -  send_http_header(r);
  -  hard_timeout("send menu", r);   /* killed in menu_footer */
  -
  -  rvputs(r, "<html><head>\n<title>Menu for ", r->uri,
  -	    "</title>\n</head><body>\n", NULL);
  -
  -  if (!strcasecmp(menu, "formatted")) {
  -    rvputs(r, "<h1>Menu for ", r->uri, "</h1>\n<hr>\n\n", NULL);
  -  } 
  +    r->content_type = "text/html";
  +    send_http_header(r);
  +    hard_timeout("send menu", r);       /* killed in menu_footer */
   
  -  return;
  +    rvputs(r, "<html><head>\n<title>Menu for ", r->uri,
  +           "</title>\n</head><body>\n", NULL);
  +
  +    if (!strcasecmp(menu, "formatted")) {
  +        rvputs(r, "<h1>Menu for ", r->uri, "</h1>\n<hr>\n\n", NULL);
  +    }
  +
  +    return;
   }
   
   static void menu_blank(request_rec *r, char *menu)
   {
  -  if (! strcasecmp(menu, "formatted") ) {
  -    rputs("\n", r);
  -  }
  -  if (! strcasecmp(menu, "semiformatted") ) {
  -    rputs("<br>\n", r);
  -  }
  -  if (! strcasecmp(menu, "unformatted") ) {
  -    rputs("\n", r);  
  -  }
  -  return;  
  +    if (!strcasecmp(menu, "formatted")) {
  +        rputs("\n", r);
  +    }
  +    if (!strcasecmp(menu, "semiformatted")) {
  +        rputs("<br>\n", r);
  +    }
  +    if (!strcasecmp(menu, "unformatted")) {
  +        rputs("\n", r);
  +    }
  +    return;
   }
   
   static void menu_comment(request_rec *r, char *menu, char *comment)
   {
  -  if (! strcasecmp(menu, "formatted") ) {
  -    rputs("\n", r);  /* print just a newline if 'formatted' */
  -  }
  -  if (! strcasecmp(menu, "semiformatted") && *comment ) {
  -    rvputs(r, comment, "\n", NULL);
  -  }             
  -  if (! strcasecmp(menu, "unformatted") && *comment ) {
  -    rvputs(r, comment, "\n", NULL);
  -  }             
  -  return;    /* comments are ignored in the 'formatted' form */
  +    if (!strcasecmp(menu, "formatted")) {
  +        rputs("\n", r);         /* print just a newline if 'formatted' */
  +    }
  +    if (!strcasecmp(menu, "semiformatted") && *comment) {
  +        rvputs(r, comment, "\n", NULL);
  +    }
  +    if (!strcasecmp(menu, "unformatted") && *comment) {
  +        rvputs(r, comment, "\n", NULL);
  +    }
  +    return;                     /* comments are ignored in the 'formatted' form */
   }
   
   static void menu_default(request_rec *r, char *menu, char *href, char *text)
   {
  -  if ( ! strcasecmp(href, "error") || ! strcasecmp(href, "nocontent") ) {
  -    return;   /* don't print such lines, these aren'te really href's */
  -  }
  -  if ( ! strcasecmp(menu, "formatted" ) ) {
  -    rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text, "</a></pre>\n",
  -	   NULL);
  -  }
  -  if ( ! strcasecmp(menu, "semiformatted" ) ) {
  -    rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text, "</a></pre>\n",
  -	   NULL);
  -  }
  -  if ( ! strcasecmp(menu, "unformatted" ) ) {
  -    rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
  -  }
  -  return;
  +    if (!strcasecmp(href, "error") || !strcasecmp(href, "nocontent")) {
  +        return;                 /* don't print such lines, these aren'te really href's */
  +    }
  +    if (!strcasecmp(menu, "formatted")) {
  +        rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text, "</a></pre>\n",
  +               NULL);
  +    }
  +    if (!strcasecmp(menu, "semiformatted")) {
  +        rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text, "</a></pre>\n",
  +               NULL);
  +    }
  +    if (!strcasecmp(menu, "unformatted")) {
  +        rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
  +    }
  +    return;
   }
   
   static void menu_directive(request_rec *r, char *menu, char *href, char *text)
   {
  -  if ( ! strcasecmp(href, "error") || ! strcasecmp(href, "nocontent") ) {
  -    return;   /* don't print such lines, as this isn't really an href */
  -  }
  -  if ( ! strcasecmp(menu, "formatted" ) ) {
  -    rvputs(r, "<pre>          <a href=\"", href, "\">", text, "</a></pre>\n",
  -	   NULL);
  -  }
  -  if ( ! strcasecmp(menu, "semiformatted" ) ) {
  -    rvputs(r, "<pre>          <a href=\"", href, "\">", text, "</a></pre>\n",
  -	   NULL);
  -  }
  -  if ( ! strcasecmp(menu, "unformatted" ) ) {
  -    rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
  -  }
  -  return;
  +    if (!strcasecmp(href, "error") || !strcasecmp(href, "nocontent")) {
  +        return;                 /* don't print such lines, as this isn't really an href */
  +    }
  +    if (!strcasecmp(menu, "formatted")) {
  +        rvputs(r, "<pre>          <a href=\"", href, "\">", text, "</a></pre>\n",
  +               NULL);
  +    }
  +    if (!strcasecmp(menu, "semiformatted")) {
  +        rvputs(r, "<pre>          <a href=\"", href, "\">", text, "</a></pre>\n",
  +               NULL);
  +    }
  +    if (!strcasecmp(menu, "unformatted")) {
  +        rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
  +    }
  +    return;
   }
   
   static void menu_footer(request_rec *r)
   {
  -  rputs("\n\n</body>\n</html>\n", r);  /* finish the menu */
  -  kill_timeout(r);
  +    rputs("\n\n</body>\n</html>\n", r);         /* finish the menu */
  +    kill_timeout(r);
   }
   
   static int imap_handler(request_rec *r)
   {
  -  char input[LARGEBUF] = {'\0'};
  -	/* size of input can not be lowered without changing hard-coded
  -	 * checks
  -	 */
  -  char href_text[SMALLBUF] = {'\0'};
  -  char base[SMALLBUF] = {'\0'};
  -  char redirect[SMALLBUF] = {'\0'};
  -  char directive[SMALLBUF] = {'\0'};
  -  char value[SMALLBUF] = {'\0'};
  -  char mapdflt[SMALLBUF] = {'\0'};
  -  char closest[SMALLBUF] = {'\0'};
  -  double closest_yet = -1;
  -
  -  double testpoint[2] = { -1,-1 }; 
  -  double pointarray[MAXVERTS + 1][2] = { {-1,-1} };
  -  int vertex = 0;
  -
  -  char *string_pos = NULL;
  -  int chars_read = 0;
  -  int showmenu = 0;
  +    char input[LARGEBUF] =
  +    {'\0'};
  +    /* size of input can not be lowered without changing hard-coded
  +     * checks
  +     */
  +    char href_text[SMALLBUF] =
  +    {'\0'};
  +    char base[SMALLBUF] =
  +    {'\0'};
  +    char redirect[SMALLBUF] =
  +    {'\0'};
  +    char directive[SMALLBUF] =
  +    {'\0'};
  +    char value[SMALLBUF] =
  +    {'\0'};
  +    char mapdflt[SMALLBUF] =
  +    {'\0'};
  +    char closest[SMALLBUF] =
  +    {'\0'};
  +    double closest_yet = -1;
  +
  +    double testpoint[2] =
  +    {-1, -1};
  +    double pointarray[MAXVERTS + 1][2] =
  +    {
  +        {-1, -1}};
  +    int vertex = 0;
  +
  +    char *string_pos = NULL;
  +    int chars_read = 0;
  +    int showmenu = 0;
   
  -  imap_conf_rec *icr = get_module_config(r->per_dir_config, &imap_module);
  +    imap_conf_rec *icr = get_module_config(r->per_dir_config, &imap_module);
   
  -  char *imap_menu = icr->imap_menu ? 
  +    char *imap_menu = icr->imap_menu ?
       icr->imap_menu : IMAP_MENU_DEFAULT;
  -  char *imap_default = icr->imap_default ? 
  +    char *imap_default = icr->imap_default ?
       icr->imap_default : IMAP_DEFAULT_DEFAULT;
  -  char *imap_base = icr->imap_base ?
  +    char *imap_base = icr->imap_base ?
       icr->imap_base : IMAP_BASE_DEFAULT;
   
  -  FILE *imap = pfopen(r->pool, r->filename, "r"); 
  +    FILE *imap = pfopen(r->pool, r->filename, "r");
   
  -  if ( ! imap ) 
  -    return NOT_FOUND;
  +    if (!imap)
  +        return NOT_FOUND;
   
  -  imap_url(r, NULL, imap_base, base);       /* set base according to default */
  -  imap_url(r, NULL, imap_default, mapdflt); /* and default to global default */
  +    imap_url(r, NULL, imap_base, base);         /* set base according to default */
  +    imap_url(r, NULL, imap_default, mapdflt);   /* and default to global default */
   
  -  testpoint[X] = get_x_coord(r->args);
  -  testpoint[Y] = get_y_coord(r->args);
  -
  -  if ((testpoint[X] == -1 || testpoint[Y] == -1) ||
  -      (testpoint[X] == 0  && testpoint[Y] == 0) ) {
  -              /* if either is -1 or if both are zero (new Lynx) */
  -              /* we don't have valid coordinates */
  -    testpoint[X] = -1;
  -    testpoint[Y] = -1;
  -    if ( strncasecmp(imap_menu, "none", 2) )
  -      showmenu = 1;    /* show the menu _unless_ ImapMenu is 'none' or 'no' */
  -  }
  -
  -  if (showmenu) {        /* send start of imagemap menu if we're going to */
  -    menu_header(r, imap_menu);
  -  }
  -
  -  while (!cfg_getline(input, LARGEBUF, imap)) {
  -    string_pos = input;   /* always start at the beginning of line */
  -
  -    directive[0] = '\0';
  -    value[0] = '\0';  
  -    href_text[0] = '\0';
  -    redirect[0] = '\0';
  -    chars_read = 0; /* clear these before using */
  -
  -    if ( ! input[0] ) {     
  -      if (showmenu) {
  -	menu_blank(r, imap_menu);
  -      }
  -      continue;                           
  -    }
  -
  -    if ( input[0] == '#' ) {
  -      if (showmenu) {
  -	menu_comment(r, imap_menu, input + 1); 
  -      }           
  -      continue;
  -    } /* blank lines and comments are ignored if we aren't printing a menu */
  -
  -
  -    if (sscanf(input, "%255s %255s", directive, value) != 2) {
  -      continue;                           /* make sure we read two fields */
  -    }
  -    /* Now skip what we just read... we can't use ANSIism %n */
  -    while (!(isspace(*string_pos)))	/* past directive */
  -	string_pos++;
  -    while (isspace(*string_pos))	/* and whitespace */
  -	string_pos++;
  -    while (!(isspace(*string_pos)))	/* and value... have to watch it */
  -	string_pos++;			/* can have punctuation and stuff */
  -    
  -    if ( ! strncasecmp(directive, "base", 4 ) ) {       /* base, base_uri */
  -      imap_url(r, NULL, value, base);
  -      continue; /* base is never printed to a menu */
  -    }	
  -
  -    chars_read = read_quoted(string_pos, href_text);
  -    string_pos += chars_read;      /* read the quoted href text if present */
  -
  -    if ( ! strcasecmp(directive, "default" ) ) {        /* default */
  -      imap_url(r, NULL, value, mapdflt);
  -      if (showmenu) {              /* print the default if there's a menu */
  -	if (! *href_text) {           /* if we didn't find a "href text" */
  -	  strncpy(href_text, mapdflt, sizeof(href_text)-1); /* use the href itself as text */
  -	  href_text[sizeof(href_text)-1] = '\0';
  -	}
  -	imap_url(r, base, mapdflt, redirect); 
  -	menu_default(r, imap_menu, redirect, href_text);
  -      }
  -      continue;
  -    }
  -
  -    vertex = 0;
  -    while ( vertex < MAXVERTS &&  
  -     sscanf(string_pos, "%lf%*[, ]%lf",
  -     &pointarray[vertex][X], &pointarray[vertex][Y])   == 2)
  -    {
  -	/* Now skip what we just read... we can't use ANSIism %n */
  -	while(isspace(*string_pos))	/* past whitespace */
  -	    string_pos++;
  -	while(isdigit(*string_pos))	/* and the 1st number */
  -	    string_pos++;
  -	string_pos++;			/* skip the ',' */
  -	while(isspace(*string_pos))	/* past any more whitespace */
  -	    string_pos++;
  -	while(isdigit(*string_pos))	/* 2nd number */
  -	    string_pos++;
  -	vertex++;
  -    }                /* so long as there are more vertices to read, and
  -			we have room, read them in.  We start where we left
  -			off of the last sscanf, not at the beginning.*/
  -                  
  -    pointarray[vertex][X] = -1;  /* signals the end of vertices */
  +    testpoint[X] = get_x_coord(r->args);
  +    testpoint[Y] = get_y_coord(r->args);
  +
  +    if ((testpoint[X] == -1 || testpoint[Y] == -1) ||
  +        (testpoint[X] == 0 && testpoint[Y] == 0)) {
  +        /* if either is -1 or if both are zero (new Lynx) */
  +        /* we don't have valid coordinates */
  +        testpoint[X] = -1;
  +        testpoint[Y] = -1;
  +        if (strncasecmp(imap_menu, "none", 2))
  +            showmenu = 1;       /* show the menu _unless_ ImapMenu is 'none' or 'no' */
  +    }
  +
  +    if (showmenu) {             /* send start of imagemap menu if we're going to */
  +        menu_header(r, imap_menu);
  +    }
  +
  +    while (!cfg_getline(input, LARGEBUF, imap)) {
  +        string_pos = input;     /* always start at the beginning of line */
  +
  +        directive[0] = '\0';
  +        value[0] = '\0';
  +        href_text[0] = '\0';
  +        redirect[0] = '\0';
  +        chars_read = 0;         /* clear these before using */
  +
  +        if (!input[0]) {
  +            if (showmenu) {
  +                menu_blank(r, imap_menu);
  +            }
  +            continue;
  +        }
  +
  +        if (input[0] == '#') {
  +            if (showmenu) {
  +                menu_comment(r, imap_menu, input + 1);
  +            }
  +            continue;
  +        }                       /* blank lines and comments are ignored if we aren't printing a menu */
  +
  +
  +        if (sscanf(input, "%255s %255s", directive, value) != 2) {
  +            continue;           /* make sure we read two fields */
  +        }
  +        /* Now skip what we just read... we can't use ANSIism %n */
  +        while (!(isspace(*string_pos)))         /* past directive */
  +            string_pos++;
  +        while (isspace(*string_pos))    /* and whitespace */
  +            string_pos++;
  +        while (!(isspace(*string_pos)))         /* and value... have to watch it */
  +            string_pos++;       /* can have punctuation and stuff */
  +
  +        if (!strncasecmp(directive, "base", 4)) {       /* base, base_uri */
  +            imap_url(r, NULL, value, base);
  +            continue;           /* base is never printed to a menu */
  +        }
  +
  +        chars_read = read_quoted(string_pos, href_text);
  +        string_pos += chars_read;       /* read the quoted href text if present */
  +
  +        if (!strcasecmp(directive, "default")) {        /* default */
  +            imap_url(r, NULL, value, mapdflt);
  +            if (showmenu) {     /* print the default if there's a menu */
  +                if (!*href_text) {      /* if we didn't find a "href text" */
  +                    strncpy(href_text, mapdflt, sizeof(href_text) - 1);         /* use the href itself as text */
  +                    href_text[sizeof(href_text) - 1] = '\0';
  +                }
  +                imap_url(r, base, mapdflt, redirect);
  +                menu_default(r, imap_menu, redirect, href_text);
  +            }
  +            continue;
  +        }
  +
  +        vertex = 0;
  +        while (vertex < MAXVERTS &&
  +               sscanf(string_pos, "%lf%*[, ]%lf",
  +                      &pointarray[vertex][X], &pointarray[vertex][Y]) == 2) {
  +            /* Now skip what we just read... we can't use ANSIism %n */
  +            while (isspace(*string_pos))        /* past whitespace */
  +                string_pos++;
  +            while (isdigit(*string_pos))        /* and the 1st number */
  +                string_pos++;
  +            string_pos++;       /* skip the ',' */
  +            while (isspace(*string_pos))        /* past any more whitespace */
  +                string_pos++;
  +            while (isdigit(*string_pos))        /* 2nd number */
  +                string_pos++;
  +            vertex++;
  +        }                       /* so long as there are more vertices to read, and
  +                                   we have room, read them in.  We start where we left
  +                                   off of the last sscanf, not at the beginning. */
  +
  +        pointarray[vertex][X] = -1;     /* signals the end of vertices */
  +
  +        if (showmenu) {
  +            read_quoted(string_pos, href_text);         /* href text could be here instead */
  +            if (!*href_text) {  /* if we didn't find a "href text" */
  +                strncpy(href_text, value, sizeof(href_text) - 1);       /* use the href itself in the menu */
  +                href_text[sizeof(href_text) - 1] = '\0';
  +            }
  +            imap_url(r, base, value, redirect);
  +            menu_directive(r, imap_menu, redirect, href_text);
  +            continue;
  +        }
  +        /* note that we don't make it past here if we are making a menu */
  +
  +        if (testpoint[X] == -1 || pointarray[0][X] == -1)
  +            continue;           /* don't try the following tests if testpoints
  +                                   are invalid, or if there are no coordinates */
  +
  +        if (!strcasecmp(directive, "poly")) {   /* poly */
  +
  +            if (pointinpoly(testpoint, pointarray)) {
  +                pfclose(r->pool, imap);
  +                imap_url(r, base, value, redirect);
  +                return (imap_reply(r, redirect));
  +            }
  +            continue;
  +        }
  +
  +        if (!strcasecmp(directive, "circle")) {         /* circle */
  +
  +            if (pointincircle(testpoint, pointarray)) {
  +                pfclose(r->pool, imap);
  +                imap_url(r, base, value, redirect);
  +                return (imap_reply(r, redirect));
  +            }
  +            continue;
  +        }
  +
  +        if (!strcasecmp(directive, "rect")) {   /* rect */
  +
  +            if (pointinrect(testpoint, pointarray)) {
  +                pfclose(r->pool, imap);
  +                imap_url(r, base, value, redirect);
  +                return (imap_reply(r, redirect));
  +            }
  +            continue;
  +        }
  +
  +        if (!strcasecmp(directive, "point")) {  /* point */
  +
  +            if (is_closer(testpoint, pointarray, &closest_yet)) {
  +                strncpy(closest, value, sizeof(closest) - 1);   /* if the closest point yet save it */
  +                closest[sizeof(closest) - 1] = '\0';
  +            }
  +
  +            continue;
  +        }                       /* move on to next line whether it's closest or not */
  +
  +    }                           /* nothing matched, so we get another line! */
  +
  +    pfclose(r->pool, imap);     /* we are done with the map file, so close it */
   
       if (showmenu) {
  -      read_quoted(string_pos, href_text); /* href text could be here instead */
  -      if (! *href_text) {           /* if we didn't find a "href text" */
  -	strncpy(href_text, value, sizeof(href_text)-1);  /* use the href itself in the menu */
  -	href_text[sizeof(href_text)-1] = '\0';
  -      }
  -      imap_url(r, base, value, redirect); 
  -      menu_directive(r, imap_menu, redirect, href_text);
  -      continue;
  -    }
  -    /* note that we don't make it past here if we are making a menu */
  -
  -    if (testpoint[X] == -1 || pointarray[0][X] == -1 )
  -      continue;    /* don't try the following tests if testpoints
  -		    are invalid, or if there are no coordinates */
  -
  -    if ( ! strcasecmp(directive, "poly" ) ) {        /* poly */
  -
  -      if (pointinpoly (testpoint, pointarray) ) {
  -	pfclose(r->pool, imap); 
  -	imap_url(r, base, value, redirect);     
  -	return (imap_reply(r, redirect));
  -      }
  -      continue;
  -    }
  -
  -    if ( ! strcasecmp(directive, "circle" ) ) {        /* circle */
  -	
  -      if (pointincircle (testpoint, pointarray) ) {
  -	pfclose(r->pool, imap); 
  -	imap_url(r, base, value, redirect);     
  -	return (imap_reply(r, redirect));
  -      }
  -      continue;
  -    }
  -    
  -    if ( ! strcasecmp(directive, "rect" ) ) {        /* rect */
  -      
  -      if (pointinrect (testpoint, pointarray) ) {
  -	pfclose(r->pool, imap); 
  -	imap_url(r, base, value, redirect);     
  -	return (imap_reply(r, redirect));
  -      }
  -      continue;
  -    }
  -    
  -    if ( ! strcasecmp(directive, "point" ) ) {         /* point */
  -      
  -      if (is_closer(testpoint, pointarray, &closest_yet) ) {
  -	strncpy(closest, value, sizeof(closest)-1);  /* if the closest point yet save it */
  -	closest[sizeof(closest)-1] = '\0';
  -      }
  -      
  -      continue;    
  -    }     /* move on to next line whether it's closest or not */
  -    
  -  }       /* nothing matched, so we get another line! */
  -
  -  pfclose(r->pool, imap);   /* we are done with the map file, so close it */
  -
  -  if (showmenu) {
  -    menu_footer(r);   /* finish the menu and we are done */
  -    return OK;                
  -  }
  -
  -  if (*closest) {    /* if a 'point' directive has been seen */
  -    imap_url(r, base, closest, redirect);     
  -    return (imap_reply(r, redirect));
  -  }    
  -
  -  if (*mapdflt ) {   /* a default should be defined, even if only 'nocontent'*/
  -    imap_url(r, base, mapdflt, redirect);
  -    return(imap_reply(r, redirect));
  -  }    
  -
  -  return SERVER_ERROR;   /* If we make it this far, we failed. They lose! */
  -}
  -
  -
  -static handler_rec imap_handlers[] = {
  -{ IMAP_MAGIC_TYPE, imap_handler },
  -{ "imap-file", imap_handler },
  -{ NULL }
  +        menu_footer(r);         /* finish the menu and we are done */
  +        return OK;
  +    }
  +
  +    if (*closest) {             /* if a 'point' directive has been seen */
  +        imap_url(r, base, closest, redirect);
  +        return (imap_reply(r, redirect));
  +    }
  +
  +    if (*mapdflt) {             /* a default should be defined, even if only 'nocontent' */
  +        imap_url(r, base, mapdflt, redirect);
  +        return (imap_reply(r, redirect));
  +    }
  +
  +    return SERVER_ERROR;        /* If we make it this far, we failed. They lose! */
  +}
  +
  +
  +static handler_rec imap_handlers[] =
  +{
  +    {IMAP_MAGIC_TYPE, imap_handler},
  +    {"imap-file", imap_handler},
  +    {NULL}
   };
   
  -module MODULE_VAR_EXPORT imap_module = {
  -   STANDARD_MODULE_STUFF,
  -   NULL,			/* initializer */
  -   create_imap_dir_config,	/* dir config creater */
  -   merge_imap_dir_configs,	/* dir merger --- default is to override */
  -   NULL,			/* server config */
  -   NULL,			/* merge server config */
  -   imap_cmds,			/* command table */
  -   imap_handlers,		/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   NULL,			/* fixups */
  -   NULL,			/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module MODULE_VAR_EXPORT imap_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    NULL,                       /* initializer */
  +    create_imap_dir_config,     /* dir config creater */
  +    merge_imap_dir_configs,     /* dir merger --- default is to override */
  +    NULL,                       /* server config */
  +    NULL,                       /* merge server config */
  +    imap_cmds,                  /* command table */
  +    imap_handlers,              /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    NULL,                       /* fixups */
  +    NULL,                       /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.17      +90 -87    apachen/src/modules/standard/mod_log_agent.c
  
  Index: mod_log_agent.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_log_agent.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- mod_log_agent.c	1997/08/18 13:12:14	1.16
  +++ mod_log_agent.c	1997/09/18 18:40:55	1.17
  @@ -56,12 +56,12 @@
   
   module agent_log_module;
   
  -static int xfer_flags = ( O_WRONLY | O_APPEND | O_CREAT );
  +static int xfer_flags = (O_WRONLY | O_APPEND | O_CREAT);
   #ifdef __EMX__
   /* OS/2 dosen't support users and groups */
  -static mode_t xfer_mode = ( S_IREAD | S_IWRITE );
  +static mode_t xfer_mode = (S_IREAD | S_IWRITE);
   #else
  -static mode_t xfer_mode = ( S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
  +static mode_t xfer_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
   #endif
   
   typedef struct {
  @@ -69,34 +69,35 @@
       int agent_fd;
   } agent_log_state;
   
  -void *make_agent_log_state (pool *p, server_rec *s)
  +void *make_agent_log_state(pool *p, server_rec *s)
   {
       agent_log_state *cls =
  -      (agent_log_state *)palloc (p, sizeof (agent_log_state));
  +    (agent_log_state *) palloc(p, sizeof(agent_log_state));
   
       cls->fname = "";
       cls->agent_fd = -1;
   
   
  -    return (void *)cls;
  +    return (void *) cls;
   }
   
  -const char *set_agent_log (cmd_parms *parms, void *dummy, char *arg)
  +const char *set_agent_log(cmd_parms *parms, void *dummy, char *arg)
   {
  -    agent_log_state *cls = get_module_config (parms->server->module_config,
  -					       &agent_log_module);
  -  
  +    agent_log_state *cls = get_module_config(parms->server->module_config,
  +                                             &agent_log_module);
  +
       cls->fname = arg;
       return NULL;
   }
   
  -command_rec agent_log_cmds[] = {
  -{ "AgentLog", set_agent_log, NULL, RSRC_CONF, TAKE1,
  -    "the filename of the agent log" },
  -{ NULL }
  +command_rec agent_log_cmds[] =
  +{
  +    {"AgentLog", set_agent_log, NULL, RSRC_CONF, TAKE1,
  +     "the filename of the agent log"},
  +    {NULL}
   };
   
  -static int agent_log_child (void *cmd)
  +static int agent_log_child(void *cmd)
   {
       /* Child process code for 'AgentLog "|..."';
        * may want a common framework for this, since I expect it will
  @@ -105,101 +106,103 @@
       int child_pid = 1;
   
       cleanup_for_exec();
  -    signal (SIGHUP, SIG_IGN);
  +    signal(SIGHUP, SIG_IGN);
   #if defined(WIN32)
  -    child_pid = spawnl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL);
  -    return(child_pid);
  -#elif defined(__EMX__)    
  +    child_pid = spawnl(SHELL_PATH, SHELL_PATH, "/c", (char *) cmd, NULL);
  +    return (child_pid);
  +#elif defined(__EMX__)
       /* For OS/2 we need to use a '/' */
  -    execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL);
  -#else    
  -    execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
  -#endif    
  -    perror ("exec");
  -    fprintf (stderr, "Exec of shell for logging failed!!!\n");
  -    return(child_pid);
  -}
  -
  -void open_agent_log (server_rec *s, pool *p)
  -{
  -    agent_log_state *cls = get_module_config (s->module_config,
  -					       &agent_log_module);
  -  
  -    char *fname = server_root_relative (p, cls->fname);
  -    
  -    if (cls->agent_fd > 0) return; /* virtual log shared w/main server */
  -    
  +    execl(SHELL_PATH, SHELL_PATH, "/c", (char *) cmd, NULL);
  +#else
  +    execl(SHELL_PATH, SHELL_PATH, "-c", (char *) cmd, NULL);
  +#endif
  +    perror("exec");
  +    fprintf(stderr, "Exec of shell for logging failed!!!\n");
  +    return (child_pid);
  +}
  +
  +void open_agent_log(server_rec *s, pool *p)
  +{
  +    agent_log_state *cls = get_module_config(s->module_config,
  +                                             &agent_log_module);
  +
  +    char *fname = server_root_relative(p, cls->fname);
  +
  +    if (cls->agent_fd > 0)
  +        return;                 /* virtual log shared w/main server */
  +
       if (*cls->fname == '|') {
  -	FILE *dummy;
  -	
  -	if (!spawn_child (p, agent_log_child, (void *)(cls->fname+1),
  -		    kill_after_timeout, &dummy, NULL)) {
  -	    perror ("spawn_child");
  -	    fprintf (stderr, "Couldn't fork child for AgentLog process\n");
  -	    exit (1);
  -	}
  +        FILE *dummy;
   
  -	cls->agent_fd = fileno (dummy);
  +        if (!spawn_child(p, agent_log_child, (void *) (cls->fname + 1),
  +                         kill_after_timeout, &dummy, NULL)) {
  +            perror("spawn_child");
  +            fprintf(stderr, "Couldn't fork child for AgentLog process\n");
  +            exit(1);
  +        }
  +
  +        cls->agent_fd = fileno(dummy);
       }
  -    else if(*cls->fname != '\0') {
  -      if((cls->agent_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
  -        perror("open");
  -        fprintf(stderr,"httpd: could not open agent log file %s.\n", fname);
  -        exit(1);
  -      }
  +    else if (*cls->fname != '\0') {
  +        if ((cls->agent_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
  +            perror("open");
  +            fprintf(stderr, "httpd: could not open agent log file %s.\n", fname);
  +            exit(1);
  +        }
       }
   }
   
  -void init_agent_log (server_rec *s, pool *p)
  +void init_agent_log(server_rec *s, pool *p)
   {
  -    for (; s; s = s->next) open_agent_log (s, p);
  +    for (; s; s = s->next)
  +        open_agent_log(s, p);
   }
   
   int agent_log_transaction(request_rec *orig)
   {
  -    agent_log_state *cls = get_module_config (orig->server->module_config,
  -					       &agent_log_module);
  -  
  +    agent_log_state *cls = get_module_config(orig->server->module_config,
  +                                             &agent_log_module);
  +
       char str[HUGE_STRING_LEN];
       char *agent;
       request_rec *r;
   
  -    if(cls->agent_fd <0)
  -      return OK;
  +    if (cls->agent_fd < 0)
  +        return OK;
   
       for (r = orig; r->next; r = r->next)
           continue;
  -    if (*cls->fname == '\0')	/* Don't log agent */
  -	return DECLINED;
  +    if (*cls->fname == '\0')    /* Don't log agent */
  +        return DECLINED;
   
       agent = table_get(orig->headers_in, "User-Agent");
  -    if(agent != NULL) 
  -      {
  -	ap_snprintf(str, sizeof(str), "%s\n", agent);
  -	write(cls->agent_fd, str, strlen(str));
  -      }
  -    
  +    if (agent != NULL) {
  +        ap_snprintf(str, sizeof(str), "%s\n", agent);
  +        write(cls->agent_fd, str, strlen(str));
  +    }
  +
       return OK;
   }
   
  -module agent_log_module = {
  -   STANDARD_MODULE_STUFF,
  -   init_agent_log,		/* initializer */
  -   NULL,			/* create per-dir config */
  -   NULL,			/* merge per-dir config */
  -   make_agent_log_state,	/* server config */
  -   NULL,			/* merge server config */
  -   agent_log_cmds,		/* command table */
  -   NULL,			/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   NULL,			/* fixups */
  -   agent_log_transaction,	/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module agent_log_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    init_agent_log,             /* initializer */
  +    NULL,                       /* create per-dir config */
  +    NULL,                       /* merge per-dir config */
  +    make_agent_log_state,       /* server config */
  +    NULL,                       /* merge server config */
  +    agent_log_cmds,             /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    NULL,                       /* fixups */
  +    agent_log_transaction,      /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  
  1.17      +116 -114  apachen/src/modules/standard/mod_log_referer.c
  
  Index: mod_log_referer.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_log_referer.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- mod_log_referer.c	1997/08/18 13:12:14	1.16
  +++ mod_log_referer.c	1997/09/18 18:40:55	1.17
  @@ -56,13 +56,13 @@
   
   module referer_log_module;
   
  -static int xfer_flags = ( O_WRONLY | O_APPEND | O_CREAT );
  +static int xfer_flags = (O_WRONLY | O_APPEND | O_CREAT);
   
   #ifdef __EMX__
   /* OS/2 lacks support for users and groups */
  -static mode_t xfer_mode = ( S_IREAD | S_IWRITE );
  +static mode_t xfer_mode = (S_IREAD | S_IWRITE);
   #else
  -static mode_t xfer_mode = ( S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
  +static mode_t xfer_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
   #endif
   
   typedef struct {
  @@ -71,46 +71,47 @@
       array_header *referer_ignore_list;
   } referer_log_state;
   
  -void *make_referer_log_state (pool *p, server_rec *s)
  +void *make_referer_log_state(pool *p, server_rec *s)
   {
       referer_log_state *cls =
  -      (referer_log_state *)palloc (p, sizeof (referer_log_state));
  +    (referer_log_state *) palloc(p, sizeof(referer_log_state));
   
       cls->fname = "";
       cls->referer_fd = -1;
       cls->referer_ignore_list = make_array(p, 1, sizeof(char *));
  -    return (void *)cls;
  +    return (void *) cls;
   }
   
  -const char *set_referer_log (cmd_parms *parms, void *dummy, char *arg)
  +const char *set_referer_log(cmd_parms *parms, void *dummy, char *arg)
   {
  -    referer_log_state *cls = get_module_config (parms->server->module_config,
  -					       &referer_log_module);
  -  
  +    referer_log_state *cls = get_module_config(parms->server->module_config,
  +                                               &referer_log_module);
  +
       cls->fname = arg;
       return NULL;
   }
   
  -const char *add_referer_ignore (cmd_parms *parms, void *dummy, char *arg)
  +const char *add_referer_ignore(cmd_parms *parms, void *dummy, char *arg)
  +{
  +    char **addme;
  +    referer_log_state *cls = get_module_config(parms->server->module_config,
  +                                               &referer_log_module);
  +
  +    addme = push_array(cls->referer_ignore_list);
  +    *addme = pstrdup(cls->referer_ignore_list->pool, arg);
  +    return NULL;
  +}
  +
  +command_rec referer_log_cmds[] =
   {
  -  char **addme;
  -  referer_log_state *cls = get_module_config (parms->server->module_config,
  -					      &referer_log_module);
  -
  -  addme = push_array(cls->referer_ignore_list);
  -  *addme = pstrdup(cls->referer_ignore_list->pool, arg);
  -  return NULL;
  -}
  -
  -command_rec referer_log_cmds[] = {
  -{ "RefererLog", set_referer_log, NULL, RSRC_CONF, TAKE1,
  -    "the filename of the referer log" },
  -{ "RefererIgnore", add_referer_ignore, NULL, RSRC_CONF, ITERATE,
  -    "referer hostnames to ignore" },
  -{ NULL }
  +    {"RefererLog", set_referer_log, NULL, RSRC_CONF, TAKE1,
  +     "the filename of the referer log"},
  +    {"RefererIgnore", add_referer_ignore, NULL, RSRC_CONF, ITERATE,
  +     "referer hostnames to ignore"},
  +    {NULL}
   };
   
  -static int referer_log_child (void *cmd)
  +static int referer_log_child(void *cmd)
   {
       /* Child process code for 'RefererLog "|..."';
        * may want a common framework for this, since I expect it will
  @@ -119,125 +120,126 @@
       int child_pid = 1;
   
       cleanup_for_exec();
  -    signal (SIGHUP, SIG_IGN);
  +    signal(SIGHUP, SIG_IGN);
   #if defined(WIN32)
       /* For OS/2 we need to use a '/' */
  -    child_pid = spawnl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL);
  -    return(child_pid);
  +    child_pid = spawnl(SHELL_PATH, SHELL_PATH, "/c", (char *) cmd, NULL);
  +    return (child_pid);
   #elif defined(__EMX__)
       /* For OS/2 we need to use a '/' */
  -    execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL);
  +    execl(SHELL_PATH, SHELL_PATH, "/c", (char *) cmd, NULL);
   #else
  -    execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
  +    execl(SHELL_PATH, SHELL_PATH, "-c", (char *) cmd, NULL);
   #endif
  -    perror ("execl");
  -    fprintf (stderr, "Exec of shell for logging failed!!!\n");
  -    return(child_pid);
  +    perror("execl");
  +    fprintf(stderr, "Exec of shell for logging failed!!!\n");
  +    return (child_pid);
   }
   
  -void open_referer_log (server_rec *s, pool *p)
  -{
  -    referer_log_state *cls = get_module_config (s->module_config,
  -					       &referer_log_module);
  -  
  -    char *fname = server_root_relative (p, cls->fname);
  -    
  -    if (cls->referer_fd > 0) return; /* virtual log shared w/main server */
  -    
  +void open_referer_log(server_rec *s, pool *p)
  +{
  +    referer_log_state *cls = get_module_config(s->module_config,
  +                                               &referer_log_module);
  +
  +    char *fname = server_root_relative(p, cls->fname);
  +
  +    if (cls->referer_fd > 0)
  +        return;                 /* virtual log shared w/main server */
  +
       if (*cls->fname == '|') {
  -	FILE *dummy;
  -	
  -	if (!spawn_child (p, referer_log_child, (void *)(cls->fname+1),
  -		    kill_after_timeout, &dummy, NULL)) {
  -	    perror ("spawn_child");
  -	    fprintf (stderr, "Couldn't fork child for RefererLog process\n");
  -	    exit (1);
  -	}
  +        FILE *dummy;
   
  -	cls->referer_fd = fileno (dummy);
  +        if (!spawn_child(p, referer_log_child, (void *) (cls->fname + 1),
  +                         kill_after_timeout, &dummy, NULL)) {
  +            perror("spawn_child");
  +            fprintf(stderr, "Couldn't fork child for RefererLog process\n");
  +            exit(1);
  +        }
  +
  +        cls->referer_fd = fileno(dummy);
       }
  -    else if(*cls->fname != '\0') {
  -      if((cls->referer_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
  -        perror("open");
  -        fprintf(stderr,"httpd: could not open referer log file %s.\n", fname);
  -        exit(1);
  -      }
  +    else if (*cls->fname != '\0') {
  +        if ((cls->referer_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
  +            perror("open");
  +            fprintf(stderr, "httpd: could not open referer log file %s.\n", fname);
  +            exit(1);
  +        }
       }
   }
   
  -void init_referer_log (server_rec *s, pool *p)
  +void init_referer_log(server_rec *s, pool *p)
   {
  -    for (; s; s = s->next) open_referer_log (s, p);
  +    for (; s; s = s->next)
  +        open_referer_log(s, p);
   }
   
   int referer_log_transaction(request_rec *orig)
   {
       char **ptrptr, **ptrptr2;
  -    referer_log_state *cls = get_module_config (orig->server->module_config,
  -					       &referer_log_module);
  -  
  +    referer_log_state *cls = get_module_config(orig->server->module_config,
  +                                               &referer_log_module);
  +
       char *str;
       char *referer;
       request_rec *r;
   
  -    if(cls->referer_fd <0)
  -      return OK;
  +    if (cls->referer_fd < 0)
  +        return OK;
   
       for (r = orig; r->next; r = r->next)
           continue;
  -    if (*cls->fname == '\0')	/* Don't log referer */
  -	return DECLINED;
  -    
  +    if (*cls->fname == '\0')    /* Don't log referer */
  +        return DECLINED;
  +
       referer = table_get(orig->headers_in, "Referer");
  -    if(referer != NULL)
  -      {
  +    if (referer != NULL) {
  +
  +
  +        /* The following is an upsetting mess of pointers, I'm sorry
  +           Anyone with the motiviation and/or the time should feel free
  +           to make this cleaner... */
   
  +        ptrptr2 = (char **) (cls->referer_ignore_list->elts +
  +                             (cls->referer_ignore_list->nelts *
  +                              cls->referer_ignore_list->elt_size));
   
  -	  /* The following is an upsetting mess of pointers, I'm sorry
  -	     Anyone with the motiviation and/or the time should feel free
  -	     to make this cleaner... */
  -
  -	  ptrptr2 = (char **) (cls->referer_ignore_list->elts + 
  -		     (cls->referer_ignore_list->nelts *
  -		      cls->referer_ignore_list->elt_size));
  -	  
  -	  /* Go through each element of the ignore list and compare it to the
  -	     referer_host.  If we get a match, return without logging */
  -
  -	  for(ptrptr = (char **) cls->referer_ignore_list->elts;
  -	      ptrptr < ptrptr2;
  -	      ptrptr = (char **)((char *)ptrptr + cls->referer_ignore_list->elt_size)) 
  -	    {
  -		if(strstr(referer, *ptrptr))
  -		  return OK;
  -	    }
  -	  
  -	  
  -	  str = pstrcat(orig->pool, referer, " -> ", r->uri, "\n", NULL);
  -	  write(cls->referer_fd, str, strlen(str));
  -      }
  +        /* Go through each element of the ignore list and compare it to the
  +           referer_host.  If we get a match, return without logging */
  +
  +        for (ptrptr = (char **) cls->referer_ignore_list->elts;
  +             ptrptr < ptrptr2;
  +             ptrptr = (char **) ((char *) ptrptr + cls->referer_ignore_list->elt_size)) {
  +            if (strstr(referer, *ptrptr))
  +                return OK;
  +        }
  +
  +
  +        str = pstrcat(orig->pool, referer, " -> ", r->uri, "\n", NULL);
  +        write(cls->referer_fd, str, strlen(str));
  +    }
   
       return OK;
   }
   
  -module referer_log_module = {
  -   STANDARD_MODULE_STUFF,
  -   init_referer_log,		/* initializer */
  -   NULL,			/* create per-dir config */
  -   NULL,			/* merge per-dir config */
  -   make_referer_log_state,	/* server config */
  -   NULL,			/* merge server config */
  -   referer_log_cmds,		/* command table */
  -   NULL,			/* handlers */
  -   NULL,			/* filename translation */
  -   NULL,			/* check_user_id */
  -   NULL,			/* check auth */
  -   NULL,			/* check access */
  -   NULL,			/* type_checker */
  -   NULL,			/* fixups */
  -   referer_log_transaction,	/* logger */
  -   NULL,			/* header parser */
  -   NULL,			/* child_init */
  -   NULL,			/* child_exit */
  -   NULL				/* post read-request */
  +module referer_log_module =
  +{
  +    STANDARD_MODULE_STUFF,
  +    init_referer_log,           /* initializer */
  +    NULL,                       /* create per-dir config */
  +    NULL,                       /* merge per-dir config */
  +    make_referer_log_state,     /* server config */
  +    NULL,                       /* merge server config */
  +    referer_log_cmds,           /* command table */
  +    NULL,                       /* handlers */
  +    NULL,                       /* filename translation */
  +    NULL,                       /* check_user_id */
  +    NULL,                       /* check auth */
  +    NULL,                       /* check access */
  +    NULL,                       /* type_checker */
  +    NULL,                       /* fixups */
  +    referer_log_transaction,    /* logger */
  +    NULL,                       /* header parser */
  +    NULL,                       /* child_init */
  +    NULL,                       /* child_exit */
  +    NULL                        /* post read-request */
   };
  
  
  

Mime
View raw message