Sorry, I forgot to include the attachment.

Cheers.

On Sun, Feb 01, 2004 at 05:59:13PM -0500, Matt Selsky wrote:
> > My feeling about hashed spool directories is that this functionality is
> > site-specific, with no obvious single definition of how it is to be
> > implemented that applies in all instances.  Consequently, I consider it to
> > be something that should always be of the form of a third-party patch
> > rather than an official part of c-client.  I do encourage you to continue
> > distributing this patch since it's likely to be useful for some people
> 
> Thank you for your feedback.
> 
> Procmail has included support for hashed spool directories since 3.13,
> so I don't think the feature is that site specific. (see
> procmail/src/authenticate.c "#define MAILSPOOLHASH 0")
> 
> > For what it's worth, I suggest the following alternative implementation of
> > your patch, which avoids needless rescans of the string:
> > 
> >    int i;
> >    char *u,*s;
> >    strcpy (tmp,MAILSPOOL);
> >    for (i = 0, u = myusername (), s = tmp + strlen (tmp);
> >         (*s++ = '/') && (i < spool_hash_depth) && u[i];
> >         *s++ = u[i++]);
> >    strcpy (s,u);
> 
> See my new patch against imap-2004rc6.  Further comments are welcome.
> 
> 
> Cheers.
--- imap-2004.RC6/src/osdep/unix/env_unix.c     2004/02/01 21:30:40     1.2
+++ imap-2004.RC6/src/osdep/unix/env_unix.c     2004/02/01 22:55:31
@@ -92,6 +92,8 @@
                                /* block notification */
 static blocknotify_t mailblocknotify = mm_blocknotify;
 
+static short spool_hash_depth = 0; /* 2 means spool is /var/mail/f/o/foo */
+
 /* Note: setting disableLockWarning means that you assert that the
  * so-modified copy of this software will NEVER be used:
  *  1) in conjunction with any software which expects .lock files
@@ -818,7 +820,23 @@
 {
   char tmp[MAILTMPLEN];
   if (!sysInbox) {             /* initialize if first time */
-    sprintf (tmp,"%s/%s",MAILSPOOL,myusername ());
+    int i;
+    char *u,*s, c;
+    static short endofstring = NIL;
+
+    strcpy (tmp,MAILSPOOL);
+    for (i = 0, u = myusername (), s = tmp + strlen (tmp);
+        (*s++ = '/') && (i < spool_hash_depth);
+        i++) {
+      /* deal with usernames shorter than hash depth */
+      if (u[i] && !endofstring)
+       c = u[i];
+      else
+       endofstring = T;
+      *s++ = c;
+    }
+    strcpy (s,u);
+
     sysInbox = cpystr (tmp);   /* system inbox is from mail spool */
   }
   return sysInbox;

Reply via email to