1: /* m_maildir.c - get the path for the mail directory */
   2: 
   3: #include "../h/mh.h"
   4: #include <stdio.h>
   5: 
   6: #define CWD "./"
   7: #define NCWD    (sizeof CWD - 1)
   8: #define DOT "."
   9: #define DOTDOT  ".."
  10: #define PWD "../"
  11: #define NPWD    (sizeof PWD - 1)
  12: 
  13: 
  14: static char mailfold[BUFSIZ];
  15: 
  16: char   *exmaildir ();
  17: 
  18: 
  19: char   *m_maildir (folder)
  20: register char   *folder;
  21: {
  22:     register char  *cp,
  23:                    *ep;
  24: 
  25:     if ((cp = exmaildir (folder))
  26:         && (ep = cp + strlen (cp) - 1) > cp
  27:         && *ep == '/')
  28:     *ep = NULL;
  29: 
  30:     return cp;
  31: }
  32: 
  33: /*  */
  34: 
  35: char   *m_mailpath (folder)
  36: register char   *folder;
  37: {
  38:     register char  *cp;
  39:     char    maildir[BUFSIZ];
  40: 
  41:     if (*folder == '/'
  42:         || strncmp (folder, CWD, NCWD) == 0
  43:         || strcmp (folder, DOT) == 0
  44:         || strcmp (folder, DOTDOT) == 0
  45:         || strncmp (folder, PWD, NPWD) == 0)
  46:     cp = path (folder, TFOLDER);
  47:     else {
  48:     (void) strcpy (maildir, mailfold);/* preserve... */
  49:     cp = getcpy (m_maildir (folder));
  50:     (void) strcpy (mailfold, maildir);
  51:     }
  52: 
  53:     return cp;
  54: }
  55: 
  56: /*  */
  57: 
  58: static char *exmaildir (folder)
  59: register char   *folder;
  60: {
  61:     register char  *cp,
  62:                    *pp;
  63: 
  64:     if (folder == NULL)
  65:     folder = m_getfolder ();
  66:     if (*folder == '/'
  67:         || strncmp (folder, CWD, NCWD) == 0
  68:         || strcmp (folder, DOT) == 0
  69:         || strcmp (folder, DOTDOT) == 0
  70:         || strncmp (folder, PWD, NPWD) == 0) {
  71:     (void) strcpy (mailfold, folder);
  72:     return mailfold;
  73:     }
  74: 
  75:     cp = mailfold;
  76:     if ((pp = m_find ("path")) != NULL && *pp) {
  77:     if (*pp != '/') {
  78:         (void) sprintf (cp, "%s/", mypath);
  79:         cp += strlen (cp);
  80:     }
  81:     cp = copy (pp, cp);
  82:     }
  83:     else
  84:     cp = copy (path ("./", TFOLDER), cp);
  85:     if (cp[-1] != '/')
  86:     *cp++ = '/';
  87:     (void) strcpy (cp, folder);
  88: 
  89:     return mailfold;
  90: }

Defined functions

exmaildir defined in line 58; used 2 times
m_maildir defined in line 19; used 7 times
m_mailpath defined in line 35; used 2 times

Defined variables

mailfold defined in line 14; used 6 times

Defined macros

CWD defined in line 6; used 3 times
DOT defined in line 8; used 2 times
DOTDOT defined in line 9; used 2 times
NCWD defined in line 7; used 2 times
NPWD defined in line 11; used 2 times
PWD defined in line 10; used 3 times
Last modified: 1986-02-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1149
Valid CSS Valid XHTML 1.0 Strict