Ticket #44811: patch-env_unix.c.diff

File patch-env_unix.c.diff, 1.8 KB (added by RJVB (René Bertin), 10 years ago)
  • src/osdep/unix/env_unix.c

    old new  
    2828#include <signal.h>
    2929#include <sys/wait.h>
    3030
     31#include <stdio.h>
     32#include <string.h>
     33#include <sys/param.h>
     34
    3135
    3236/* in case stat.h is ancient */
    3337
     
    6670static char *myServerName = NIL;/* server name */
    6771static char *myLocalHost = NIL; /* local host name */
    6872static char *myNewsrc = NIL;    /* newsrc file name */
    69 static char *mailsubdir = NIL;  /* mailbox subdirectory name */
     73static char *mailsubdir = ((char*)-1);  /* mailbox subdirectory name */
    7074static char *sysInbox = NIL;    /* system inbox name */
    7175static char *newsActive = NIL;  /* news active file */
    7276static char *newsSpool = NIL;   /* news spool */
     
    965969  char *home = myhomedir ();
    966970                                /* initialize if first time */
    967971  if (!myMailboxDir && myHomeDir) {
    968     if (mailsubdir) {
     972    if (mailsubdir == ((char*)-1) ) {
     973      char *rcfile = NULL;
     974      FILE *fp;
     975      asprintf( &rcfile, "%s/.imap/MailboxDir.rc", home );
     976      if( rcfile && (fp = fopen( rcfile, "r" )) ){
     977        char dirnm[MAXPATHLEN];
     978        if( fgets( dirnm, MAXPATHLEN, fp ) > 0 ){
     979          if( dirnm[strlen(dirnm)-1] == '\n' ){
     980              dirnm[strlen(dirnm)-1] = '\0';
     981          }
     982          myMailboxDir = cpystr(dirnm);
     983          snprintf( dirnm, MAXPATHLEN, "Mailbox dir set to %s", myMailboxDir );
     984          MM_LOG( dirnm, WARN );
     985        }
     986        fclose(fp);
     987      }
     988      if( rcfile ){
     989        free(rcfile);
     990      }
     991      if( !myMailboxDir ){
     992        mailsubdir = "Mail";
     993        goto useMail;
     994      }
     995    }
     996    else if (mailsubdir) {
     997useMail:;
    969998      char tmp[MAILTMPLEN];
    970999      sprintf (tmp,"%s/%s",home,mailsubdir);
    9711000      myMailboxDir = cpystr (tmp);/* use pre-defined subdirectory of home */