source: trunk/third/nmh/sbr/m_maildir.c @ 12455

Revision 12455, 1.7 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * m_maildir.c -- get the path for the mail directory
4 *
5 * $Id: m_maildir.c,v 1.1.1.1 1999-02-07 18:14:09 danw Exp $
6 */
7
8#include <h/mh.h>
9
10#define CWD     "./"
11#define NCWD    (sizeof(CWD) - 1)
12#define DOT     "."
13#define DOTDOT  ".."
14#define PWD     "../"
15#define NPWD    (sizeof(PWD) - 1)
16
17static char mailfold[BUFSIZ];
18
19/*
20 * static prototypes
21 */
22static char *exmaildir (char *);
23
24
25char *
26m_maildir (char *folder)
27{
28    register char *cp, *ep;
29
30    if ((cp = exmaildir (folder))
31            && (ep = cp + strlen (cp) - 1) > cp
32            && *ep == '/')
33        *ep = '\0';
34
35    return cp;
36}
37
38
39char *
40m_mailpath (char *folder)
41{
42    register char *cp;
43    char maildir[BUFSIZ];
44
45    if (*folder != '/'
46            && strncmp (folder, CWD, NCWD)
47            && strcmp (folder, DOT)
48            && strcmp (folder, DOTDOT)
49            && strncmp (folder, PWD, NPWD)) {
50        strncpy (maildir, mailfold, sizeof(maildir));   /* preserve... */
51        cp = getcpy (m_maildir (folder));
52        strncpy (mailfold, maildir, sizeof(mailfold));
53    } else {
54        cp = path (folder, TFOLDER);
55    }
56
57    return cp;
58}
59
60
61static char *
62exmaildir (char *folder)
63{
64    register char *cp, *pp;
65
66    /* use current folder if none is specified */
67    if (folder == NULL)
68        folder = getfolder(1);
69
70    if (!(*folder != '/'
71            && strncmp (folder, CWD, NCWD)
72            && strcmp (folder, DOT)
73            && strcmp (folder, DOTDOT)
74            && strncmp (folder, PWD, NPWD))) {
75        strncpy (mailfold, folder, sizeof(mailfold));
76        return mailfold;
77    }
78
79    cp = mailfold;
80    if ((pp = context_find ("path")) && *pp) {
81        if (*pp != '/') {
82            sprintf (cp, "%s/", mypath);
83            cp += strlen (cp);
84        }
85        cp = copy (pp, cp);
86    } else {
87        cp = copy (path ("./", TFOLDER), cp);
88    }
89    if (cp[-1] != '/')
90        *cp++ = '/';
91    strcpy (cp, folder);
92
93    return mailfold;
94}
Note: See TracBrowser for help on using the repository browser.