]>
diplodocus.org Git - nmh/blob - sbr/m_maildir.c
1 /* m_maildir.c -- get the path for the mail directory
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
10 #include "m_maildir.h"
17 static char mailfold
[BUFSIZ
];
22 static char *exmaildir (char *);
25 /* Returns static char[], never NULL. */
27 m_maildir (char *folder
)
31 if ((cp
= exmaildir (folder
))
32 && (ep
= cp
+ strlen (cp
) - 1) > cp
40 /* Return value must be free(3)'d. */
42 m_mailpath (char *folder
)
48 && !has_prefix(folder
, CWD
)
49 && strcmp (folder
, DOT
)
50 && strcmp (folder
, DOTDOT
)
51 && !has_prefix(folder
, PWD
)) {
52 strncpy (maildir
, mailfold
, sizeof(maildir
)); /* preserve... */
53 cp
= getcpy (m_maildir (folder
));
54 strncpy (mailfold
, maildir
, sizeof(mailfold
));
56 cp
= path (folder
, TFOLDER
);
63 /* Returns static char[], never NULL. */
65 exmaildir (char *folder
)
69 /* use current folder if none is specified */
71 folder
= getfolder(1);
74 && !has_prefix(folder
, CWD
)
75 && strcmp (folder
, DOT
)
76 && strcmp (folder
, DOTDOT
)
77 && !has_prefix(folder
, PWD
))) {
78 strncpy (mailfold
, folder
, sizeof(mailfold
));
83 if ((pp
= context_find ("path")) && *pp
) {
85 snprintf(cp
, sizeof mailfold
, "%s/", mypath
);
90 char *p
= path("./", TFOLDER
);