X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0c9b09a8a9fca687adf2859976fba7df439ab000..ca079bfa8e3812ebf21ffec1c27edeaa03cb9280:/sbr/m_maildir.c diff --git a/sbr/m_maildir.c b/sbr/m_maildir.c index c574c161..5edc9360 100644 --- a/sbr/m_maildir.c +++ b/sbr/m_maildir.c @@ -1,21 +1,21 @@ - -/* - * m_maildir.c -- get the path for the mail directory +/* m_maildir.c -- get the path for the mail directory * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ -#include -#include +#include "h/mh.h" +#include "getfolder.h" +#include "context_find.h" +#include "path.h" +#include "h/utils.h" +#include "m_maildir.h" #define CWD "./" -#define NCWD (sizeof(CWD) - 1) #define DOT "." #define DOTDOT ".." #define PWD "../" -#define NPWD (sizeof(PWD) - 1) static char mailfold[BUFSIZ]; @@ -25,6 +25,7 @@ static char mailfold[BUFSIZ]; static char *exmaildir (char *); +/* Returns static char[], never NULL. */ char * m_maildir (char *folder) { @@ -39,6 +40,7 @@ m_maildir (char *folder) } +/* Return value must be free(3)'d. */ char * m_mailpath (char *folder) { @@ -46,12 +48,12 @@ m_mailpath (char *folder) char maildir[BUFSIZ]; if (*folder != '/' - && !HasPrefix(folder, CWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && !HasPrefix(folder, PWD)) { + && !has_prefix(folder, PWD)) { strncpy (maildir, mailfold, sizeof(maildir)); /* preserve... */ - cp = getcpy (m_maildir (folder)); + cp = mh_xstrdup(m_maildir(folder)); strncpy (mailfold, maildir, sizeof(mailfold)); } else { cp = path (folder, TFOLDER); @@ -61,6 +63,7 @@ m_mailpath (char *folder) } +/* Returns static char[], never NULL. */ static char * exmaildir (char *folder) { @@ -71,10 +74,10 @@ exmaildir (char *folder) folder = getfolder(1); if (!(*folder != '/' - && !HasPrefix(folder, CWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && !HasPrefix(folder, PWD))) { + && !has_prefix(folder, PWD))) { strncpy (mailfold, folder, sizeof(mailfold)); return mailfold; } @@ -85,9 +88,11 @@ exmaildir (char *folder) snprintf(cp, sizeof mailfold, "%s/", mypath); cp += strlen (cp); } - cp = copy (pp, cp); + cp = stpcpy(cp, pp); } else { - cp = copy (path ("./", TFOLDER), cp); + char *p = path("./", TFOLDER); + cp = stpcpy(cp, p); + free(p); } if (cp[-1] != '/') *cp++ = '/';