You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2002/02/21 17:13:24 UTC

cvs commit: apache-1.3/src/modules/standard mod_userdir.c

coar        02/02/21 08:13:24

  Modified:    src/modules/standard mod_userdir.c
  Log:
  Style fixes only (noticed while checking on a bug report)
  
  Revision  Changes    Path
  1.53      +39 -32    apache-1.3/src/modules/standard/mod_userdir.c
  
  Index: mod_userdir.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_userdir.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -u -r1.52 -r1.53
  --- mod_userdir.c	30 Nov 2001 17:06:24 -0000	1.52
  +++ mod_userdir.c	21 Feb 2002 16:13:24 -0000	1.53
  @@ -101,7 +101,7 @@
       char *userdir;
       table *enabled_users;
       table *disabled_users;
  -}              userdir_config;
  +} userdir_config;
   
   /*
    * Server config for this module: global disablement flag, a list of usernames
  @@ -111,9 +111,9 @@
   
   static void *create_userdir_config(pool *p, server_rec *s)
   {
  -    userdir_config
  -    * newcfg = (userdir_config *) ap_pcalloc(p, sizeof(userdir_config));
  +    userdir_config *newcfg;
   
  +    newcfg = (userdir_config *) ap_pcalloc(p, sizeof(userdir_config));
       newcfg->globally_disabled = 0;
       newcfg->userdir = DEFAULT_USER_DIR;
       newcfg->enabled_users = ap_make_table(p, 4);
  @@ -127,18 +127,14 @@
   
   static const char *set_user_dir(cmd_parms *cmd, void *dummy, char *arg)
   {
  -    userdir_config
  -    * s_cfg = (userdir_config *) ap_get_module_config
  -    (
  -     cmd->server->module_config,
  -     &userdir_module
  -    );
  +    userdir_config *s_cfg;
       char *username;
  -    const char
  -        *usernames = arg;
  +    const char *usernames = arg;
       char *kw = ap_getword_conf(cmd->pool, &usernames);
       table *usertable;
   
  +    s_cfg = (userdir_config *) ap_get_module_config(cmd->server->module_config,
  +                                                    &userdir_module);
       /*
        * Let's do the comparisons once.
        */
  @@ -173,15 +169,17 @@
           const char *userdirs = arg;
           while (*userdirs) {
               char *thisdir = ap_getword_conf(cmd->pool, &userdirs);
  -            if (!ap_os_is_path_absolute(thisdir) && !strchr(thisdir, ':'))
  +            if (!ap_os_is_path_absolute(thisdir) && !strchr(thisdir, ':')) {
   #if defined(WIN32) || defined(NETWARE)
                   return "UserDir must specify an absolute redirect "
                          "or absolute file path";
   #else
  -                if (strchr(thisdir, '*'))
  +                if (strchr(thisdir, '*')) {
                        return "UserDir cannot specify '*' substitution within "
                               "a relative path";
  +                }
   #endif
  +            }
           }
           s_cfg->userdir = ap_pstrdup(cmd->pool, arg);
   #if defined(WIN32) || defined(OS2) || defined(NETWARE)
  @@ -190,8 +188,9 @@
            * change them to slash form.
            */
           arg = s_cfg->userdir;
  -        while (arg = strchr(arg, '\\'))
  +        while (arg = strchr(arg, '\\')) {
               *(arg++) = '/';
  +        }
   #endif
           return NULL;
       }
  @@ -206,9 +205,12 @@
       return NULL;
   }
   
  -static const command_rec userdir_cmds[] = {
  +static const command_rec userdir_cmds[] =
  +{
       {"UserDir", set_user_dir, NULL, RSRC_CONF, RAW_ARGS,
  -    "the public subdirectory in users' home directories, or 'disabled', or 'disabled username username...', or 'enabled username username...'"},
  +     "the public subdirectory in users' home directories, or "
  +     "'disabled', or 'disabled username username...', or "
  +     "'enabled username username...'"},
       {NULL}
   };
   
  @@ -227,11 +229,9 @@
        * If the URI doesn't match our basic pattern, we've nothing to do with
        * it.
        */
  -    if (
  -        (s_cfg->userdir == NULL) ||
  -        (name[0] != '/') ||
  -        (name[1] != '~')
  -        ) {
  +    if ((s_cfg->userdir == NULL)
  +        || (name[0] != '/')
  +        || (name[1] != '~')) {
           return DECLINED;
       }
   
  @@ -252,7 +252,10 @@
       /*
        * If there's no username, it's not for us.  Ignore . and .. as well.
        */
  -    if (w[0] == '\0' || (w[1] == '.' && (w[2] == '\0' || (w[2] == '.' && w[3] == '\0')))) {
  +    if ((w[0] == '\0')
  +        || ((w[1] == '.')
  +            && ((w[2] == '\0')
  +                || ((w[2] == '.') && (w[3] == '\0'))))) {
           return DECLINED;
       }
       /*
  @@ -265,10 +268,8 @@
        * If there's a global interdiction on UserDirs, check to see if this
        * name is one of the Blessed.
        */
  -    if (
  -        s_cfg->globally_disabled &&
  -        (ap_table_get(s_cfg->enabled_users, w) == NULL)
  -        ) {
  +    if (s_cfg->globally_disabled
  +        && (ap_table_get(s_cfg->enabled_users, w) == NULL)) {
           return DECLINED;
       }
   
  @@ -295,7 +296,8 @@
               else if (strchr(x, ':')) {
                   /* token '*' within a redirect path
                    * serves [UserDir arg-pre*][user][UserDir arg-post*]
  -                 * http://server/user/ * + /~smith/foo -> http://server/user/smith/foo
  +                 * http://server/user/ * + /~smith/foo ->
  +                 *   http://server/user/smith/foo
                    */
                   redirect = ap_pstrcat(r->pool, x, w, userdir, dname, NULL);
                   ap_table_setn(r->headers_out, "Location", redirect);
  @@ -325,10 +327,12 @@
                * serves [UserDir arg]/[user][dname]
                * http://server/ + /~smith/foo -> http://server/smith/foo
                */
  -            if (userdir[strlen(userdir) - 1] == '/')
  +            if (userdir[strlen(userdir) - 1] == '/') {
                   redirect = ap_pstrcat(r->pool, userdir, w, dname, NULL);
  -            else
  +            }
  +            else {
                   redirect = ap_pstrcat(r->pool, userdir, "/", w, dname, NULL);
  +            }
               ap_table_setn(r->headers_out, "Location", redirect);
               return REDIRECT;
           }
  @@ -347,9 +351,11 @@
               if ((pw = getpwnam(w))) {
   #ifdef OS2
                   /* Need to manually add user name for OS/2 */
  -                filename = ap_pstrcat(r->pool, pw->pw_dir, w, "/", userdir, NULL);
  +                filename = ap_pstrcat(r->pool, pw->pw_dir, w, "/",
  +                                      userdir, NULL);
   #else
  -                filename = ap_pstrcat(r->pool, pw->pw_dir, "/", userdir, NULL);
  +                filename = ap_pstrcat(r->pool, pw->pw_dir, "/",
  +                                      userdir, NULL);
   #endif
               }
   #endif                          /* WIN32 & NetWare */
  @@ -366,8 +372,9 @@
   	    /* when statbuf contains info on r->filename we can save a syscall
   	     * by copying it to r->finfo
   	     */
  -	    if (*userdirs && dname[0] == 0)
  +	    if (*userdirs && dname[0] == 0) {
   		r->finfo = statbuf;
  +            }
               return OK;
           }
       }