--- src/osdep/unix/env_unix.c.orig 2011-07-23 02:20:10.000000000 +0200 +++ src/osdep/unix/env_unix.c 2014-08-29 22:53:25.000000000 +0200 @@ -28,6 +28,10 @@ #include #include +#include +#include +#include + /* in case stat.h is ancient */ @@ -66,7 +70,7 @@ static char *myServerName = NIL;/* server name */ static char *myLocalHost = NIL; /* local host name */ static char *myNewsrc = NIL; /* newsrc file name */ -static char *mailsubdir = NIL; /* mailbox subdirectory name */ +static char *mailsubdir = ((char*)-1); /* mailbox subdirectory name */ static char *sysInbox = NIL; /* system inbox name */ static char *newsActive = NIL; /* news active file */ static char *newsSpool = NIL; /* news spool */ @@ -965,7 +969,32 @@ char *home = myhomedir (); /* initialize if first time */ if (!myMailboxDir && myHomeDir) { - if (mailsubdir) { + if (mailsubdir == ((char*)-1) ) { + char *rcfile = NULL; + FILE *fp; + asprintf( &rcfile, "%s/.imap/MailboxDir.rc", home ); + if( rcfile && (fp = fopen( rcfile, "r" )) ){ + char dirnm[MAXPATHLEN]; + if( fgets( dirnm, MAXPATHLEN, fp ) > 0 ){ + if( dirnm[strlen(dirnm)-1] == '\n' ){ + dirnm[strlen(dirnm)-1] = '\0'; + } + myMailboxDir = cpystr(dirnm); + snprintf( dirnm, MAXPATHLEN, "Mailbox dir set to %s", myMailboxDir ); + MM_LOG( dirnm, WARN ); + } + fclose(fp); + } + if( rcfile ){ + free(rcfile); + } + if( !myMailboxDir ){ + mailsubdir = "Mail"; + goto useMail; + } + } + else if (mailsubdir) { +useMail:; char tmp[MAILTMPLEN]; sprintf (tmp,"%s/%s",home,mailsubdir); myMailboxDir = cpystr (tmp);/* use pre-defined subdirectory of home */