#ifdef MHRC
char *pp;
struct passwd *pw;
-#endif
-#ifdef MHRC
context_read();
-#endif
-
- switch (*file) {
- case '/':
- /* If already absolute pathname, return it */
- return file;
-
-#ifdef MHRC
- case '~':
+ if (*file == '~') {
/* Expand ~username */
if ((cp = strchr(pp = file + 1, '/')))
*cp++ = '\0';
if (access (epath, R_OK) != NOTOK)
return epath; /* else fall */
+ }
try_it:
#endif /* MHRC */
- default:
- /* Check nmh Mail directory */
- if (access ((cp = m_mailpath (file)), R_OK) != NOTOK)
- return cp;
+ if (*file == '/') {
+ /* If already absolute pathname, return it */
+ return file;
}
+ /* Check nmh Mail directory */
+ strncpy(epath, toabsdir(file), sizeof epath);
+ if (access (epath, R_OK) != NOTOK)
+ return epath;
+
/* Check nmh `etc' directory */
snprintf (epath, sizeof(epath), NMHETCDIR"/%s", file);
return (access (epath, R_OK) != NOTOK ? epath : file);
char *mhlreply = "mhl.reply"; /* repl -filter */
char *mhlforward = "mhl.forward"; /* forw -filter */
-char *draftfolder = "drafts";
+char *draftfolder = "+drafts";
char *inbox = "Inbox";
-char *defaultfolder = "inbox";
+char *defaultfolder = "+inbox";
char *pfolder = "Current-Folder";
char *usequence = "Unseen-Sequence";
#define NOUSE 0 /* draft being re-used */
-#define TFOLDER 0 /* path() given a +folder */
-#define TFILE 1 /* path() given a file */
-#define TSUBCWF 2 /* path() given a @folder */
-
-#define FDEF 0 /* getfolder() want default */
-#define FCUR 1 /* getfolder() want current */
-
#define OUTPUTLINELEN 72 /* default line length for headers */
/*
int decode_rfc2047(char *, char *, size_t);
void discard(FILE *);
int default_done(int);
+char *expandfol(char *);
+char *expanddir(char *);
int ext_hook(char *, char *, char *);
int fdcompare(int, int);
int folder_addmsg(struct msgs **, char *, int, int, int, int, char *);
char **getarguments(char *, int, char **, int);
char *get_charset();
char *getcpy(char *);
-char *getfolder(int);
+char *getcurfol(void);
+char *getdeffol(void);
int lkclose(int, char*);
int lkfclose(FILE *, char *);
FILE *lkfopen(char *, char *);
char *m_draft(char *);
int m_getfld(int, unsigned char *, unsigned char *, int, FILE *);
int m_gmprot(void);
-char *m_maildir(char *);
-char *m_mailpath(char *);
char *m_name(int);
int m_putenv(char *, char *);
char *m_mktemp(const char *, int *, FILE **);
char *nmh_getpass(const char *);
char *norm_charmap(char *);
char *new_fs(char *, char *, char *);
-char *path(char *, int);
int peekc(FILE *ib);
int pidwait(pid_t, int);
int pidstatus(int, FILE *, char *);
-char *pluspath(char *);
void print_help(char *, struct swit *, int);
void print_sw(char *, struct swit *, char *, FILE *);
void print_version(char *);
char *snprintb(char *, size_t, unsigned, char *);
int isprefix(char *, char *);
int stringdex(char *, char *);
+char *toabsdir(char *);
char *trimcpy(unsigned char *);
int unputenv(char *);
int uprf(char *, char *);
information to keep an exact correspondence
history.
.RI \*(lq Audit\-file \*(rq
-will be in the user's nmh directory unless a full path is specified.
+will be in the current directory unless a full path is specified.
.PP
.B Inc
will incorporate even improperly formatted messages into the
error.c ext_hook.c fdcompare.c folder_addmsg.c folder_delmsgs.c \
folder_free.c folder_pack.c folder_read.c \
folder_realloc.c gans.c getans.c getanswer.c \
- getarguments.c getcpy.c getfolder.c getpass.c \
+ getarguments.c getcpy.c getpass.c \
fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c \
fmt_scan.c lock_file.c m_atoi.c m_backup.c \
m_convert.c m_draft.c m_getfld.c m_gmprot.c \
- m_maildir.c m_name.c \
+ m_name.c \
makedir.c mts.c norm_charmap.c \
path.c peekc.c pidwait.c pidstatus.c \
print_help.c print_sw.c print_version.c push.c \
*/
if ((cp = getenv("MH")) && *cp != '\0') {
- defpath = path(cp, TFILE);
+ defpath = getcpy(expanddir(cp));
- if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0)
- adios((char *)0, "`%s' specified by your MH environment variable is not a normal file", cp);
+ if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0)
+ adios((char *)0, "`%s' specified by your MH environment variable is not a normal file", cp);
- if ((ib = fopen(defpath, "r")) == (FILE *)0)
- adios((char *)0, "unable to read the `%s' profile specified by your MH environment variable", defpath);
+ if ((ib = fopen(defpath, "r")) == (FILE *)0)
+ adios((char *)0, "unable to read the `%s' profile specified by your MH environment variable", defpath);
} else {
defpath = concat(mypath, "/", mh_profile, NULL);
return;
}
- ctxpath = getcpy(m_maildir(cp));
+ ctxpath = getcpy(toabsdir(cp));
if ((ib = lkfopen(ctxpath, "r"))) {
readconfig((struct node **) 0, ib, cp, 1);
/*
-** copy.c -- copy a string and return pointer to NULL terminator
+** copy.c -- copy a string and return pointer to null byte terminator
**
** This code is Copyright (c) 2002, by the authors of nmh. See the
** COPYRIGHT file in the root directory of the nmh distribution for
struct dirent *dp;
DIR *dd;
- name = m_mailpath(name);
+ name = getcpy(toabsdir(name));
if (!(dd = opendir(name))) {
free(name);
return NULL;
+++ /dev/null
-/*
-** getfolder.c -- get the current or default folder
-**
-** 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 <h/mh.h>
-
-
-/*
-** Return the default (=inbox) or current folder.
-** E.g. `getfolder(FDEF)' usually returns ``inbox''.
-*/
-char *
-getfolder(int wantcurrent)
-{
- char *folder;
-
- if (wantcurrent &&
- (folder = context_find(pfolder)) && *folder != '\0') {
- /* If wantcurrent, then try the current folder first */
- return folder;
-
- } else if ((folder = context_find(inbox)) && *folder != '\0') {
- /* try the Inbox profile entry */
- return folder;
-
- } else {
- /* return the compile time default */
- return defaultfolder;
- }
-}
static char buffer[BUFSIZ];
char *folder;
- folder = pluspath(draftfolder);
+ folder = getcpy(expandfol(draftfolder));
- chdir(m_maildir(""));
- strncpy(buffer, m_maildir(folder), sizeof(buffer));
+ chdir(toabsdir("+"));
+ strncpy(buffer, toabsdir(folder), sizeof(buffer));
create_folder(buffer, 0, done);
+++ /dev/null
-/*
-** 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 <h/mh.h>
-
-#define CWD "./"
-#define NCWD (sizeof(CWD) - 1)
-#define DOT "."
-#define DOTDOT ".."
-#define PWD "../"
-#define NPWD (sizeof(PWD) - 1)
-
-static char mailfold[BUFSIZ];
-
-/*
-** static prototypes
-*/
-static char *exmaildir(char *);
-
-
-char *
-m_maildir(char *folder)
-{
- register char *cp, *ep;
-
- if ((cp = exmaildir(folder))
- && (ep = cp + strlen(cp) - 1) > cp
- && *ep == '/')
- *ep = '\0';
-
- return cp;
-}
-
-
-char *
-m_mailpath(char *folder)
-{
- register char *cp;
- char maildir[BUFSIZ];
-
- if (*folder != '/'
- && strncmp(folder, CWD, NCWD)
- && strcmp(folder, DOT)
- && strcmp(folder, DOTDOT)
- && strncmp(folder, PWD, NPWD)) {
- strncpy(maildir, mailfold, sizeof(maildir)); /* preserve... */
- cp = getcpy(m_maildir(folder));
- strncpy(mailfold, maildir, sizeof(mailfold));
- } else {
- cp = path(folder, TFOLDER);
- }
-
- return cp;
-}
-
-
-static char *
-exmaildir(char *folder)
-{
- register char *cp, *pp;
-
- /* use current folder if none is specified */
- if (folder == NULL)
- folder = getfolder(FCUR);
-
- if (!(*folder != '/' && strncmp(folder, CWD, NCWD)
- && strcmp(folder, DOT) && strcmp(folder, DOTDOT)
- && strncmp(folder, PWD, NPWD))) {
- strncpy(mailfold, folder, sizeof(mailfold));
- return mailfold;
- }
-
- cp = mailfold;
- if ((pp = context_find("path")) && *pp) {
- if (*pp != '/') {
- sprintf(cp, "%s/", mypath);
- cp += strlen(cp);
- }
- cp = copy(pp, cp);
- } else {
- cp = copy(path("./", TFOLDER), cp);
- }
- if (cp[-1] != '/')
- *cp++ = '/';
- strcpy(cp, folder);
-
- return mailfold;
-}
tmpdir = getenv("TMP");
if (tmpdir != NULL && *tmpdir != '\0') return tmpdir;
}
- return m_maildir("");
+ return toabsdir("+");
}
/*
-** path.c -- return a pathname
+** path.c -- return or convert paths
**
** This code is Copyright (c) 2002, by the authors of nmh. See the
** COPYRIGHT file in the root directory of the nmh distribution for
#include <h/mh.h>
-static char *pwds;
-
/*
-** Compactify an absolute path name by removing unneccessary parts.
-** Removes trailing slashes, but not if it would empty the string then.
-** Modifies f.
+** Compactify a path name by removing unneccessary parts.
+** Removes trailing slashes. Cares to never remove all characters.
+** Modifies f (never enlarges it).
+**
+** FIXME: Cannot use strcpy() as the areas overlap!
*/
static void
packpath(char *f)
}
+
+
/*
-**
+** Get the default folder
+** Return the Inbox profile entry or, as fallback, the compile time default
+** Returns a pointer to the abs folpath
*/
-static char *
-expath(char *name, int type)
+char *
+getdeffol(void)
{
- char *cp, *ep;
- char buffer[BUFSIZ];
-
- if (type == TSUBCWF) {
- /* convert TSUBCWF to TFOLDER */
- snprintf(buffer, sizeof(buffer), "%s/%s",
- getfolder(FCUR), name);
- name = m_mailpath(buffer);
- packpath(name);
- snprintf(buffer, sizeof(buffer), "%s/", m_maildir(""));
- if (isprefix(buffer, name)) {
- cp = name;
- name = getcpy(name + strlen(buffer));
- free(cp);
- }
- type = TFOLDER;
- }
+ char *folder = context_find(inbox);
- if (*name == '/') {
- return getcpy(name);
+ if (!folder || !*folder) {
+ folder = defaultfolder; /* the compile time default */
}
-
- if (type == TFOLDER &&
- (strncmp(name, "./", 2) && strcmp(name, ".") &&
- strcmp(name, "..") && strncmp(name, "../", 3))) {
- /*
- ** FIXME: Seems as if this check does not catch names like:
- ** ``foo/../../..''.
- */
- return getcpy(name);
+ if (*folder == '+') {
+ folder++;
}
+ return folder;
+}
- if (pwds == NULL) {
- pwds = pwd();
- }
- if (strcmp(name, ".") == 0 || strcmp(name, "./") == 0) {
- return getcpy(pwds);
- }
+/*
+** Get the current folder
+** Return the Current-Folder context entry or, as fallback, the default folder
+** Returns a pointer to the abs folpath
+**
+** Equivalent to: expandfol("@")
+*/
+char *
+getcurfol(void)
+{
+ char *folder = context_find(pfolder);
- ep = pwds + strlen(pwds);
- if ((cp = strrchr(pwds, '/')) == NULL) {
- cp = ep;
- } else if (cp == pwds) {
- cp++;
+ if (!folder || !*folder) {
+ folder = getdeffol();
}
+ return folder;
+}
- if (strncmp(name, "./", 2) == 0) {
- name += 2;
- }
- if (strcmp(name, "..") == 0 || strcmp(name, "../") == 0) {
- snprintf(buffer, sizeof(buffer), "%.*s",
- (int)(cp - pwds), pwds);
- return getcpy(buffer);
- }
+/*
+** Expand folder path
+** Convert rel folpaths (@) into abs folpaths
+** dir paths are simply passed through
+** Returns the abs folpath (without prefix), in static mem
+**
+** TODO: Always copy into the static buffer, or just return the pointer?
+*/
+char *
+expandfol(char *f)
+{
+ static char buf[BUFSIZ];
+
+ if (*f == '@') {
+ /* f = concat(getcurfol(), "/", f+1, NULL); */
+ snprintf(buf, sizeof buf, "%s/%s", getcurfol(), f+1);
+
+ } else if (*f == '+') {
+ strcpy(buf, f+1);
- if (strncmp(name, "../", 3) == 0) {
- name += 3;
} else {
- cp = ep;
+ strcpy(buf, f);
}
-
- snprintf(buffer, sizeof(buffer), "%.*s/%s",
- (int)(cp - pwds), pwds, name);
- return getcpy(buffer);
+ packpath(buf);
+ return buf;
}
/*
-** Return a path name
+** Expand directory path
+** Convert rel dirpath into abs dirpath
+** The argument is assumed to be a dir path relative to the cwd,
+** except when beginning with '/' (then it will be passed through).
+** Returns the abs dirpath, in static mem
+**
+** TODO: Always copy into the static buffer, or just return the pointer?
*/
char *
-path(char *name, int type)
+expanddir(char *d)
{
- char *cp, *ep;
+ static char buf[BUFSIZ];
- if ((cp = expath(name, type)) &&
- (ep = cp+strlen(cp)-1) > cp &&
- *ep == '/') {
- *ep = '\0';
+ if (*d == '/') {
+ strcpy(buf, d);
+ } else {
+ getcwd(buf, sizeof buf);
+ int len = strlen(buf);
+ snprintf(buf+len, sizeof buf - len, "/%s", d);
}
-
- return cp;
+ packpath(buf);
+ return buf;
}
/*
-** Call path() appropriately for ``+folder'' or ``@folder''
+** Anypath to absolute directory path
+** Convert any kind of path into an abs dirpath
+** A path without distinguishing prefix is assumed to be an abs folpath
+** Abs dirpaths are passed unchanged
+** Rel dirpaths ('.') get prefixed with the (abs) cwd
+** Return pointer to static memory
+**
+** To get the dir path of the mail storage root, call: toabsdir("+")
+**
+** TODO: check lengths for copies
*/
char *
-pluspath(char *name)
+toabsdir(char *path)
{
- switch (*name) {
- case '+':
- return path(name+1, TFOLDER);
- case '@':
- return path(name+1, TSUBCWF);
- default:
- return path(name, TFILE);
+ static char buf[BUFSIZ];
+
+ if (*path == '/') {
+ /* nothing to do */
+ strncpy(buf, path, sizeof buf);
+ packpath(buf);
+ return buf;
+
+ } else if (*path == '.') {
+ /* rel dir path */
+ strncpy(buf, expanddir(path), sizeof buf);
+ return buf;
+
+ } else {
+ /* folder path */
+ char *cp=buf, *pp;
+
+ if (!(pp = context_find("path")) || !*pp) {
+ adios(NULL, "Non-empty profile entry `Path' required");
+ }
+ if (*pp != '/') {
+ /* Path is relative to $HOME */
+ snprintf(buf, sizeof buf, "%s/", mypath);
+ cp += strlen(buf);
+ }
+ strcpy(cp, pp);
+ packpath(buf);
+ /* append the mail folder */
+ cp = buf + strlen(buf);
+ *cp++ = '/';
+ strcpy(cp, expandfol(path));
+ return buf;
}
}
/*
** add -- If "s1" is NULL, this routine just creates a
** -- copy of "s2" into newly malloc'ed memory.
+** -- (use getcpy() instead in this case)
** --
** -- If "s1" is not NULL, then copy the concatenation
** -- of "s1" and "s2" (note the order) into newly
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
if (msg)
adios(NULL, "only one message at a time!");
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- file = path(cp, TFILE);
+ file = getcpy(expanddir(cp));
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
if (msg)
adios(NULL, "only one message at a time!");
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
foldersToDo = (char **) mh_xrealloc(foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo)));
}
if (*cp == '+' || *cp == '@') {
- foldersToDo[numfolders++] = pluspath(cp);
+ foldersToDo[numfolders++] = getcpy(expandfol(cp));
} else
foldersToDo[numfolders++] = cp;
}
}
/* get current folder */
- strncpy(curfolder, getfolder(FCUR), sizeof(curfolder));
+ strncpy(curfolder, getcurfol(), sizeof(curfolder));
/* get nmh base directory */
- nmhdir = m_maildir("");
+ nmhdir = toabsdir("+");
/*
** If we didn't specify any sequences, we search
if (argfolder)
adios(NULL, "only one folder at a time!");
else
- argfolder = pluspath(cp);
+ argfolder = getcpy(expandfol(cp));
} else {
if (msg)
adios(NULL, "only one (current) message at a time!");
}
}
- nmhdir = concat(m_maildir(""), "/", NULL);
+ nmhdir = concat(toabsdir("+"), "/", NULL);
/*
** If we aren't working with the folder stack
} else {
adios(NULL, "no other folder");
}
- for (cp = getcpy(getfolder(FCUR)); *ap; ap++)
+ for (cp = getcpy(getcurfol()); *ap; ap++)
cp = add(*ap, add(" ", cp));
free(dp);
context_replace(stack, cp); /* update folder stack */
} else {
/* update folder stack */
context_replace(stack, (cp = context_find (stack)) ?
- concat(getfolder(FCUR), " ", cp, NULL) :
- getcpy(getfolder(FCUR)));
+ concat(getcurfol(), " ", cp, NULL) :
+ getcpy(getcurfol()));
}
}
free(dp);
}
if (pushsw || popsw) {
- cp = m_maildir(argfolder);
+ cp = toabsdir(argfolder);
if (access(cp, F_OK) == NOTOK)
adios(cp, "unable to find folder");
/* update current folder */
/* Listing the folder stack */
if (listsw) {
- printf("%s", argfolder ? argfolder : getfolder(FCUR));
+ printf("%s", argfolder ? argfolder : getcurfol());
if ((cp = context_find(stack))) {
dp = getcpy(cp);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
NULL);
}
} else {
- strncpy(folder, argfolder ? argfolder : getfolder (1),
+ strncpy(folder, argfolder ? argfolder : getcurfol(),
sizeof(folder));
/*
** Check if folder exists. If not, then see if
** we should create it, or just exit.
*/
- create_folder(m_maildir(folder), fcreat, done);
+ create_folder(toabsdir(folder), fcreat, done);
if (get_folder_info(folder, msg) && argfolder) {
/* update current folder */
adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- file = path(cp, TFILE);
+ file = getcpy(expanddir(cp));
continue;
case FILTSW:
if (!(cp = *argp++) || *cp == '-')
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
adios(NULL, "can't mix files and folders/msgs");
#ifdef MHE
- strncpy(drft, buildsw ? m_maildir("draft")
+ strncpy(drft, buildsw ? toabsdir("draft")
: m_draft("new"), sizeof(drft));
#else
strncpy(drft, m_draft("new"), sizeof(drft));
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
case AUDSW:
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- audfile = getcpy(m_maildir(cp));
+ audfile = getcpy(expanddir(cp));
continue;
case NAUDSW:
audfile = NULL;
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- from = path(cp, TFILE);
+ from = getcpy(expanddir(cp));
/*
** If the truncate file is in default state,
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
if (from)
newmail = from;
else if ((newmail = getenv("MAILDROP")) && *newmail)
- newmail = m_mailpath(newmail);
+ newmail = toabsdir(newmail);
else if ((newmail = context_find("maildrop")) && *newmail)
- newmail = m_mailpath(newmail);
+ newmail = toabsdir(newmail);
else {
newmail = concat(MAILDIR, "/", MAILFIL, NULL);
}
newmail = cp;
if (!folder)
- folder = getfolder(FDEF);
- maildir = m_maildir(folder);
+ folder = getdeffol();
+ maildir = toabsdir(folder);
if ((maildir_copy = strdup(maildir)) == (char *)0)
adios(maildir, "error allocating memory to copy maildir");
*/
if ((cp = getenv("MH")) && *cp != '\0')
- defpath = path(cp, TFILE);
+ defpath = getcpy(expanddir(cp));
else
defpath = concat(mypath, "/", mh_profile, NULL);
fclose(in);
}
- ctxpath = getcpy(m_maildir(context = "context"));
+ ctxpath = getcpy(toabsdir(context = "context"));
/* Initialize current folder to default */
context_replace(pfolder, defaultfolder);
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!msgs.size)
app_msgarg(&msgs, listsw ? "all" :"cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
/* Check for private cache location */
if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy(m_maildir(cache_private));
+ cache_private = getcpy(toabsdir(cache_private));
/*
** Check for storage directory. If defined, we
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add(m_maildir(invo_name), NULL);
+ tmp = getcpy(toabsdir(invo_name));
/* Check if we have a file to process */
if (!compfile)
}
/* get copies of the buffers */
- np = add(name, NULL);
- vp = add(buf, NULL);
+ np = getcpy(name);
+ vp = getcpy(buf);
/* if necessary, get rest of field */
while (state == FLDPLUS) {
** Now add the MIME-Version header field
** to the list of header fields.
*/
- np = add(VRSN_FIELD, NULL);
+ np = getcpy(VRSN_FIELD);
vp = concat(" ", VRSN_VALUE, "\n", NULL);
add_header(ct, np, vp);
done(1);
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_MIXED;
- ct->c_file = add(infile, NULL);
+ ct->c_file = getcpy(infile);
if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
adios(NULL, "out of memory");
adios("mhbuildsbr", "unable to create temporary file");
/* use a temp file to collect the plain text lines */
- ce->ce_file = add(cp, NULL);
+ ce->ce_file = getcpy(cp);
ce->ce_unlink = 1;
if (buf[0] == '#' && buf[1] == '<') {
continue;
if (!*cp)
adios(NULL, "empty pipe command for #%s directive", ci->ci_type);
- cp = add(cp, NULL);
+ cp = getcpy(cp);
free(ci->ci_magic);
ci->ci_magic = cp;
} else {
done(1);
}
}
- ci->ci_magic = add(cp, NULL);
+ ci->ci_magic = getcpy(cp);
return OK;
}
if (folder)
adios(NULL, "only one folder per #forw directive");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
}
}
/* else, use the current folder */
if (!folder)
- folder = add(getfolder(FCUR), NULL);
+ folder = getcpy(getcurfol());
if (!(mp = folder_read(folder)))
adios(NULL, "unable to read folder %s", folder);
snprintf(buffer, sizeof(buffer),
"%s/%d", mp->foldpath,
msgnum);
- pe->ce_file = add(buffer, NULL);
+ pe->ce_file = getcpy(buffer);
if (listsw && stat(pe->ce_file, &st)
!= NOTOK)
p->c_end = (long) st.st_size;
msgnum = mp->lowsel;
snprintf(buffer, sizeof(buffer), "%s/%d",
mp->foldpath, msgnum);
- ce->ce_file = add(buffer, NULL);
+ ce->ce_file = getcpy(buffer);
if (listsw && stat(ce->ce_file, &st) != NOTOK)
ct->c_end = (long) st.st_size;
}
CT p = part->mp_part;
sprintf(pp, "%d", partnum);
- p->c_partno = add(partnam, NULL);
+ p->c_partno = getcpy(partnam);
if (compose_content(p) == NOTOK)
return NOTOK;
}
if (tfile == NULL) {
adios("mhbuildsbr", "unable to create temporary file");
}
- ce->ce_file = add(tfile, NULL);
+ ce->ce_file = getcpy(tfile);
ce->ce_unlink = 1;
xstdout = 0;
NULL);
} else {
t->tx_charset = CHARSET_USASCII;
- *ap = add("charset=us-ascii", NULL);
+ *ap = getcpy("charset=us-ascii");
}
cp = strchr(*ap++, '=');
ep = ci->ci_values;
snprintf(buffer, sizeof(buffer), "boundary=%s%d",
prefix, level++);
- cp = strchr(*ap++ = add(buffer, NULL), '=');
+ cp = strchr(*ap++ = getcpy(buffer), '=');
*ap = NULL;
*cp++ = '\0';
*ep = cp;
/*
** output the content type and subtype
*/
- np = add(TYPE_FIELD, NULL);
+ np = getcpy(TYPE_FIELD);
vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
/* keep track of length of line */
** output the Content-ID, unless disabled by -nocontentid
*/
if (contentidsw && ct->c_id) {
- np = add(ID_FIELD, NULL);
+ np = getcpy(ID_FIELD);
vp = concat(" ", ct->c_id, NULL);
add_header(ct, np, vp);
}
** output the Content-Description
*/
if (ct->c_descr) {
- np = add(DESCR_FIELD, NULL);
+ np = getcpy(DESCR_FIELD);
vp = concat(" ", ct->c_descr, NULL);
add_header(ct, np, vp);
}
** output the Content-Disposition
*/
if (ct->c_dispo) {
- np = add(DISPO_FIELD, NULL);
+ np = getcpy(DISPO_FIELD);
vp = concat(" ", ct->c_dispo, NULL);
add_header(ct, np, vp);
}
** output the Content-MD5
*/
if (checksw) {
- np = add(MD5_FIELD, NULL);
+ np = getcpy(MD5_FIELD);
vp = calculate_digest(ct, (ct->c_encoding == CE_QUOTED) ?
1 : 0);
add_header(ct, np, vp);
case CE_7BIT:
/* Nothing to output */
#if 0
- np = add(ENCODING_FIELD, NULL);
+ np = getcpy(ENCODING_FIELD);
vp = concat(" ", "7bit", "\n", NULL);
add_header(ct, np, vp);
#endif
if (ct->c_type == CT_MESSAGE)
adios(NULL, "internal error, invalid encoding");
- np = add(ENCODING_FIELD, NULL);
+ np = getcpy(ENCODING_FIELD);
vp = concat(" ", "8bit", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(NULL, "internal error, invalid encoding");
- np = add(ENCODING_FIELD, NULL);
+ np = getcpy(ENCODING_FIELD);
vp = concat(" ", "quoted-printable", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(NULL, "internal error, invalid encoding");
- np = add(ENCODING_FIELD, NULL);
+ np = getcpy(ENCODING_FIELD);
vp = concat(" ", "base64", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE)
adios(NULL, "internal error, invalid encoding");
- np = add(ENCODING_FIELD, NULL);
+ np = getcpy(ENCODING_FIELD);
vp = concat(" ", "binary", "\n", NULL);
add_header(ct, np, vp);
break;
if (state != FLDPLUS)
cp = buf;
else {
- cp = add(buf, NULL);
+ cp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf, sizeof(buf), fp);
cp = add(buf, cp);
case FILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
- adios(NULL, "missing argument to %s", argp[-2]);
- file = *cp == '-' ? cp : path(cp, TFILE);
+ adios(NULL, "missing argument to %s",
+ argp[-2]);
+ file = *cp == '-' ? cp : getcpy(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/* Check for private cache location */
if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy(m_maildir(cache_private));
+ cache_private = getcpy(toabsdir(cache_private));
/*
** Check for storage directory. If specified,
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add(m_maildir(invo_name), NULL);
+ tmp = getcpy(toabsdir(invo_name));
if (file && msgs.size)
adios(NULL, "cannot specify msg and file at same time!");
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
if (ct->c_descr) {
char *dp;
- dp = trimcpy(cp = add(ct->c_descr, NULL));
+ dp = trimcpy(cp = getcpy(ct->c_descr));
free(cp);
printf(LSTFMT2d1, dp);
free(dp);
if (verbose && ci->ci_comment) {
char *dp;
- dp = trimcpy(cp = add(ci->ci_comment, NULL));
+ dp = trimcpy(cp = getcpy(ci->ci_comment));
free(cp);
snprintf(buffer, sizeof(buffer), "(%s)", dp);
free(dp);
advise("mhparse", "unable to create temporary file");
return NULL;
}
- file = add(tfile, NULL);
+ file = getcpy(tfile);
chmod(file, 0600);
while (fgets(buffer, sizeof(buffer), stdin))
adios(NULL, "out of memory");
ct->c_fp = in;
- ct->c_file = add(file, NULL);
+ ct->c_file = getcpy(file);
ct->c_begin = ftell(ct->c_fp) + 1;
/*
compnum++;
/* get copies of the buffers */
- np = add(name, NULL);
- vp = add(buf, NULL);
+ np = getcpy(name);
+ vp = getcpy(buf);
/* if necessary, get rest of field */
while (state == FLDPLUS) {
advise(NULL, "message %s has multiple %s: fields", ct->c_file, VRSN_FIELD);
goto next_header;
}
- ct->c_vrsn = add(hp->value, NULL);
+ ct->c_vrsn = getcpy(hp->value);
/* Now, cleanup this field */
cp = ct->c_vrsn;
}
/* get copy of this field */
- ct->c_celine = cp = add(hp->value, NULL);
+ ct->c_celine = cp = getcpy(hp->value);
while (isspace(*cp))
cp++;
goto next_header;
}
- ep = cp = add(hp->value, NULL); /* get a copy */
+ ep = cp = getcpy(hp->value);
while (isspace(*cp))
cp++;
** Insert at first semicolon, if any.
** If none, append to end.
*/
- prefix = add(buf, NULL);
+ prefix = getcpy(buf);
if ((cp = strchr(prefix, ';'))) {
suffix = concat(cp, NULL);
*cp = '\0';
i = strlen(invo_name) + 2;
/* store copy of Content-Type line */
- cp = ct->c_ctline = add(cp, NULL);
+ cp = ct->c_ctline = getcpy(cp);
while (isspace(*cp)) /* trim leading spaces */
cp++;
for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_type = add(cp, NULL); /* store content type */
+ ci->ci_type = getcpy(cp); /* store content type */
*dp = c, cp = dp;
if (!*ci->ci_type) {
if (*cp != '/') {
if (!magic)
- ci->ci_subtype = add("", NULL);
+ ci->ci_subtype = getcpy("");
goto magic_skip;
}
for (dp = cp; istoken(*dp); dp++)
continue;
c = *dp, *dp = '\0';
- ci->ci_subtype = add(cp, NULL); /* store the content subtype */
+ ci->ci_subtype = getcpy(cp); /* store the content subtype */
*dp = c, cp = dp;
if (!*ci->ci_subtype) {
return NOTOK;
}
- vp = (*ap = add(cp, NULL)) + (up - cp);
+ vp = (*ap = getcpy(cp)) + (up - cp);
*vp = '\0';
for (dp++; isspace(*dp);)
dp++;
*/
if (*cp) {
if (magic) {
- ci->ci_magic = add(cp, NULL);
+ ci->ci_magic = getcpy(cp);
/*
** If there is a Content-Disposition header and
ci->ci_comment = concat(dp, " ", buffer, NULL);
free(dp);
} else {
- ci->ci_comment = add(buffer, NULL);
+ ci->ci_comment = getcpy(buffer);
}
}
p = part->mp_part;
sprintf(pp, "%d", partnum);
- p->c_partno = add(partnam, NULL);
+ p->c_partno = getcpy(partnam);
/* initialize the content of the subparts */
if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) {
*/
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!mh_strcasecmp(*ap, "id")) {
- p->pm_partid = add(*ep, NULL);
+ p->pm_partid = getcpy(*ep);
continue;
}
if (!mh_strcasecmp(*ap, "number")) {
}
if (*file == NULL) {
- ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = add(*file, NULL);
+ ce->ce_file = getcpy(*file);
ce->ce_unlink = 0;
}
}
if (*file == NULL) {
- ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = add(*file, NULL);
+ ce->ce_file = getcpy(*file);
ce->ce_unlink = 0;
}
}
if (*file == NULL) {
- ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = add(*file, NULL);
+ ce->ce_file = getcpy(*file);
ce->ce_unlink = 0;
}
}
if (*file)
- ce->ce_file = add(*file, NULL);
+ ce->ce_file = getcpy(*file);
else if (caching)
- ce->ce_file = add(cachefile, NULL);
+ ce->ce_file = getcpy(cachefile);
else
- ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) {
content_error (ce->ce_file, ct,
}
if (*file == NULL) {
- ce->ce_file = add(m_mktemp(tmp, NULL, NULL), NULL);
+ ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
ce->ce_unlink = 1;
} else {
- ce->ce_file = add(*file, NULL);
+ ce->ce_file = getcpy(*file);
ce->ce_unlink = 0;
}
*/
if (ct->c_showproc)
free(ct->c_showproc);
- ct->c_showproc = add("true", NULL);
+ ct->c_showproc = getcpy("true");
fseek(ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
/* If no messages are given, print folder pathname */
if (!msgs.size) {
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : path(cp, TFILE);
+ file = *cp == '-' ? cp : getcpy(expanddir(cp));
continue;
case FORMSW:
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/* Check for private cache location */
if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy(m_maildir(cache_private));
+ cache_private = getcpy(toabsdir(cache_private));
/*
** Check for storage directory. If specified,
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add(m_maildir(invo_name), NULL);
+ tmp = getcpy(toabsdir(invo_name));
if (file && msgs.size)
adios(NULL, "cannot specify msg and file at same time!");
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
snprintf(buffer, sizeof(buffer), "%%p%s '%%F'",
progsw ? progsw : moreproc && *moreproc ?
moreproc : "more");
- cp = (ct->c_showproc = add(buffer, NULL));
+ cp = (ct->c_showproc = getcpy(buffer));
return show_content_aux(ct, serial, alternate, cp, NULL);
}
return NOTOK;
/* I'm not sure if this is necessary? */
- p->c_storage = add(file, NULL);
+ p->c_storage = getcpy(file);
if (p->c_showproc && !strcmp(p->c_showproc, "true"))
return (alternate ? DONE : OK);
/* default method for message/rfc822 */
if (ct->c_subtype == MESSAGE_RFC822) {
- cp = (ct->c_showproc = add("%pshow -file '%F'", NULL));
+ cp = (ct->c_showproc = getcpy("%pshow -file '%F'"));
return show_content_aux(ct, serial, alternate, cp, NULL);
}
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : path(cp, TFILE);
+ file = *cp == '-' ? cp : getcpy(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
/* null terminate the list of acceptable parts/types */
/* Check for private cache location */
if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy(m_maildir(cache_private));
+ cache_private = getcpy(toabsdir(cache_private));
/*
** Cache the current directory before we do any chdirs()'s.
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add(m_maildir(invo_name), NULL);
+ tmp = getcpy(toabsdir(invo_name));
if (file && msgs.size)
adios(NULL, "cannot specify msg and file at same time!");
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
}
if (tarP) {
- ct->c_showproc = add(zP ? "%euncompress | tar tvf -" : (gzP ? "%egzip -dc | tar tvf -" : "%etar tvf -"), NULL);
+ ct->c_showproc = getcpy(zP ? "%euncompress | tar tvf -" : (gzP ? "%egzip -dc | tar tvf -" : "%etar tvf -"));
if (!ct->c_storeproc) {
if (autosw) {
- ct->c_storeproc = add(zP ? "| uncompress | tar xvpf -" : (gzP ? "| gzip -dc | tar xvpf -" : "| tar xvpf -"), NULL);
+ ct->c_storeproc = getcpy(zP ? "| uncompress | tar xvpf -" : (gzP ? "| gzip -dc | tar xvpf -" : "| tar xvpf -"));
ct->c_umask = 0022;
} else {
- ct->c_storeproc= add(zP ? "%m%P.tar.Z" : (gzP ? "%m%P.tar.gz" : "%m%P.tar"), NULL);
+ ct->c_storeproc= getcpy(zP ? "%m%P.tar.Z" : (gzP ? "%m%P.tar.gz" : "%m%P.tar"));
}
}
}
if ((cp = e->eb_name) && *cp != '/' && *cp != '.' &&
*cp != '|' && *cp != '!' && !strchr(cp, '%')) {
if (!ct->c_storeproc)
- ct->c_storeproc = add(cp, NULL);
+ ct->c_storeproc = getcpy(cp);
if (!p->c_storeproc)
- p->c_storeproc = add(cp, NULL);
+ p->c_storeproc = getcpy(cp);
}
}
*/
if (p) {
appending = 1;
- ct->c_storage = add(p->c_storage, NULL);
+ ct->c_storage = getcpy(p->c_storage);
/* record the folder name */
if (p->c_folder) {
- ct->c_folder = add(p->c_folder, NULL);
+ ct->c_folder = getcpy(p->c_folder);
}
goto got_filename;
}
/* Store content in temporary file for now */
tmpfilenam = m_mktemp(invo_name, NULL, NULL);
- ct->c_storage = add(tmpfilenam, NULL);
+ ct->c_storage = getcpy(tmpfilenam);
/* Get the folder name */
if (cp[1])
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
else
- folder = getfolder(FCUR);
+ folder = getcurfol();
/* Check if folder exists */
- create_folder(m_mailpath(folder), 0, exit);
+ create_folder(toabsdir(folder), 0, exit);
/* Record the folder name */
- ct->c_folder = add(folder, NULL);
+ ct->c_folder = getcpy(folder);
if (cp[1])
free(folder);
return show_content_aux(ct, 1, 0, buffer + 1, dir);
/* record the filename */
- ct->c_storage = add(buffer, NULL);
+ ct->c_storage = getcpy(buffer);
got_filename:
/* flush the output stream */
if (!mh_strcasecmp(*ap, "name") && *(cp = *ep) != '/' &&
*cp != '.' && *cp != '|' && *cp != '!' &&
!strchr(cp, '%')) {
- ct->c_storeproc = add(cp, NULL);
+ ct->c_storeproc = getcpy(cp);
return;
}
}
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : path(cp, TFILE);
+ file = *cp == '-' ? cp : getcpy(expanddir(cp));
continue;
case OUTFILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(NULL, "missing argument to %s",
argp[-2]);
- outfile = *cp == '-' ? cp : path(cp, TFILE);
+ outfile = *cp == '-' ? cp : getcpy(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/* Check for private cache location */
if (!(cache_private = context_find(nmhprivcache)))
cache_private = ".cache";
- cache_private = getcpy(m_maildir(cache_private));
+ cache_private = getcpy(toabsdir(cache_private));
/*
** Check for storage directory. If specified,
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = add(m_maildir(invo_name), NULL);
+ tmp = getcpy(toabsdir(invo_name));
if (file && msgs.size)
adios(NULL, "cannot specify msg and file at same time!");
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
static char *
get_msgnums(char *folder, char *sequences[])
{
- char *seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL);
+ char *seqfile = concat(toabsdir(folder), "/", mh_seq, (void *)NULL);
FILE *fp = fopen(seqfile, "r");
int state;
char name[NAMESZ], field[BUFSIZ];
b.sequences = sequences;
if (folders == NULL) {
- chdir(m_maildir(""));
+ chdir(toabsdir("+"));
crawl_folders(".", crawl_callback, &b);
} else {
fp = fopen(folders, "r");
/* will flists */
} else {
if (folders[0] != '/') {
- folders = m_maildir(folders);
+ folders = toabsdir(folders);
}
}
if (*cp == '+' || *cp == '@') {
if (folder)
adios(NULL, "only one folder at a time!");
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!file)
file = "./msgbox";
- file = path(file, TFILE);
+ file = getcpy(expanddir(file));
/*
** Check if file to be created (or appended to)
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to ");
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
case FLDPLUS:
if (bp != NULL)
free(bp), bp = NULL;
- bp = add(buf, NULL);
+ bp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof buf, fp);
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
/* if no folder is given, use default folder */
if (!folder)
- folder = getfolder(FDEF);
- maildir = m_maildir(folder);
+ folder = getdeffol();
+ maildir = toabsdir(folder);
/* check if folder exists */
if (stat(maildir, &st) == NOTOK) {
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
continue;
case FILESW:
if (filep > NFOLDERS)
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- files[filep++] = path(cp, TFILE);
+ files[filep++] = getcpy(expanddir(cp));
continue;
case RPROCSW:
if (foldp > NFOLDERS)
adios(NULL, "only %d folders allowed!",
NFOLDERS);
- folders[foldp++].f_name =
- pluspath(cp);
+ folders[foldp++].f_name = getcpy(expandfol(cp));
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
if (foldp == 0)
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- strncpy(maildir, m_maildir(folder), sizeof(maildir));
+ folder = getcurfol();
+ strncpy(maildir, toabsdir(folder), sizeof(maildir));
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
register struct msgs *mp;
for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
- chdir(m_maildir(""));
- strncpy(nmaildir, m_maildir(fp->f_name), sizeof(nmaildir));
+ chdir(toabsdir("+"));
+ strncpy(nmaildir, toabsdir(fp->f_name), sizeof(nmaildir));
create_folder(nmaildir, 0, done);
adios(NULL, "missing argument to %s", argp[-2]);
dp = NULL;
if (*cp == '@')
- cp = dp = pluspath(cp);
+ cp = dp = getcpy(expandfol(cp));
if (fcc)
fcc = add(", ", fcc);
fcc = add(cp, fcc);
adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- file = path(cp, TFILE);
+ file = getcpy(expanddir(cp));
continue;
case FILTSW:
if (!(cp = *argp++) || *cp == '-')
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
if (msg)
adios(NULL, "only one message at a time!");
adios(NULL, "can't mix files and folders/msgs");
#ifdef MHE
- strncpy(drft, buildsw ? m_maildir("reply")
+ strncpy(drft, buildsw ? toabsdir("reply")
: m_draft("new"), sizeof(drft));
#else
strncpy(drft, m_draft("new"), sizeof(drft));
if (!msg)
msg = "cur";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else {
adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
}
if (!folder) {
- folder = getfolder(FCUR);
+ folder = getcurfol();
defolder++;
}
- if (strcmp(m_mailpath(folder), pwd()) == 0)
- adios(NULL, "sorry, you can't remove the current working directory");
+ if (strcmp(toabsdir(folder), pwd()) == 0)
+ adios(NULL, "You can't remove the current working directory");
if (interactive == -1)
interactive = defolder;
if (cp > newfolder)
*cp = '\0';
else
- strncpy(newfolder, getfolder(FDEF), sizeof(newfolder));
+ strncpy(newfolder, getdeffol(), sizeof(newfolder));
} else {
- strncpy(newfolder, getfolder(FDEF), sizeof(newfolder));
+ strncpy(newfolder, getdeffol(), sizeof(newfolder));
}
if (interactive) {
register struct dirent *dp;
register DIR *dd;
- switch (i = chdir(maildir = m_maildir(folder))) {
+ switch (i = chdir(maildir = toabsdir(folder))) {
case OK:
if (access(".", W_OK) != NOTOK &&
access("..", W_OK) != NOTOK)
case NOTOK:
snprintf(cur, sizeof(cur), "atr-%s-%s",
- current, m_mailpath(folder));
+ current, toabsdir(folder));
if (!context_del(cur)) {
printf("[+%s de-referenced]\n", folder);
return OK;
register struct node *np, *pp;
alen = strlen("atr-");
- plen = strlen(cp = m_mailpath(folder)) + 1;
+ plen = strlen(cp = getcpy(toabsdir(folder))) + 1;
/*
** Search context list for keys that look like
pp = np;
}
}
+ free(cp);
}
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!msgs.size)
app_msgarg(&msgs, "cur");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
case FILESW:
if (!(cp = *argp++) || (cp[0] == '-' && cp[1]))
adios(NULL, "missing argument to %s", argp[-2]);
- if (strcmp(file = cp, "-"))
- file = path(cp, TFILE);
+ if (strcmp(file = cp, "-")!=0)
+ file = getcpy(expanddir(cp));
continue;
}
}
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
- app_msgarg(&msgs, cp);
+ app_msgarg(&msgs, cp);
}
/*
if (strcmp(file, "-") == 0) {
in = stdin;
file = "stdin";
- } else {
- if ((in = fopen(file, "r")) == NULL)
- adios(file, "unable to open");
+ } else if (!(in = fopen(file, "r"))) {
+ adios(file, "unable to open");
}
#ifndef JLR
if (!msgs.size)
app_msgarg(&msgs, "all");
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
argp = arguments;
vec[vecp++] = "-library";
- vec[vecp++] = getcpy(m_maildir(""));
+ vec[vecp++] = getcpy(toabsdir("+"));
while ((cp = *argp++)) {
if (*cp == '-') {
if (!msgp)
msgs[msgp++] = "cur";
- maildir = m_maildir(draftfolder);
+ maildir = toabsdir(draftfolder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
*/
(void)strncpy(body_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
+ m_mktemp(toabsdir(invo_name), NULL, NULL),
sizeof (body_file_name));
(void)strncpy(composition_file_name,
- m_mktemp(m_maildir(invo_name), NULL, NULL),
+ m_mktemp(toabsdir(invo_name), NULL, NULL),
sizeof (composition_file_name));
if (has_body)
break;
case 1:
- if (stringdex(m_maildir(invo_name), file_name) == 0) {
+ if (stringdex(toabsdir(invo_name), file_name) == 0) {
/*
** Content had been placed by send into a temp file.
** Don't generate Content-Disposition header, because
break;
case 2:
- if (stringdex(m_maildir(invo_name), file_name) == 0) {
+ if (stringdex(toabsdir(invo_name), file_name) == 0) {
/*
** Content had been placed by send into a temp file.
** Don't generate Content-Disposition header, because
admonish(NULL, "$mhfolder not set");
return;
}
- maildir = m_maildir(folder);
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK) {
if (debugsw)
admonish(maildir, "unable to change directory to");
adios(NULL, "only one file at a time!");
if (!(cp = *argp++) || *cp == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- file = path(cp, TFILE);
+ file = getcpy(expanddir(cp));
continue;
case HEADSW:
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else if (mode != SHOW) {
goto usage;
} else {
}
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
if (!strcmp(mhbasename(proc), "mhl")
&& !file
&& chdir(maildir =
- concat(m_maildir(""), "/", NULL)) != NOTOK) {
+ concat(toabsdir("+"), "/", NULL)) != NOTOK) {
mp->foldpath = concat(mp->foldpath, "/", NULL);
cp = isprefix(maildir, mp->foldpath)
? mp->foldpath + strlen(maildir)
int passno;
char c;
- cp = add(buf, NULL);
+ cp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), fp);
** Check Content-Transfer-Encoding field
*/
if (!mh_strcasecmp(name, ENCODING_FIELD)) {
- cp = add(buf, NULL);
+ cp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), fp);
case FLD:
case FLDEOF:
case FLDPLUS:
- lp = add(field, NULL);
+ lp = getcpy(field);
while (state == FLDPLUS) {
state = m_getfld(state, name, field,
sizeof(field), in);
continue;
}
- cp = add(buf, NULL);
+ cp = getcpy(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf, sizeof(buf), in);
cp = add(buf, cp);
if (folder)
adios(NULL, "only one folder at a time!");
else
- folder = pluspath(cp);
+ folder = getcpy(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (!datesw)
datesw = "date";
if (!folder)
- folder = getfolder(FCUR);
- maildir = m_maildir(folder);
+ folder = getcurfol();
+ maildir = toabsdir(folder);
if (chdir(maildir) == NOTOK)
adios(maildir, "unable to change directory to");
vecp = 1; /* we'll get the zero'th element later */
vec[vecp++] = "-library";
- vec[vecp++] = getcpy(m_maildir(""));
+ vec[vecp++] = getcpy(toabsdir("+"));
while ((cp = *argp++)) {
if (*cp == '-') {