Completely reworked the path convertion functions
authormarkus schnalke <meillo@marmaro.de>
Fri, 9 Dec 2011 15:34:57 +0000 (16:34 +0100)
committermarkus schnalke <meillo@marmaro.de>
Fri, 9 Dec 2011 15:34:57 +0000 (16:34 +0100)
Moved everything (from sbr/getfolder.c and sbr/m_maildir.c) into
sbr/path.c, but actually replaced the code almost completely.
See h/prototypes.h for the function changes.
sbr/path.c provides explaining comments on the functions.
None of them allocates memory automatically.

Additionally:
- Like for other ``files'', `inc -audit file' places file relative
  to the cwd, not relative to the mh-dir. This is for consistency.
- Replaced add(foo, NULL) with getcpy(foo), which ist clearer.

52 files changed:
config/config.c
h/mh.h
h/prototypes.h
man/inc.man
sbr/Makefile.in
sbr/context_read.c
sbr/copy.c
sbr/folder_read.c
sbr/getfolder.c [deleted file]
sbr/m_draft.c
sbr/m_maildir.c [deleted file]
sbr/m_mktemp.c
sbr/path.c
sbr/utils.c
uip/anno.c
uip/burst.c
uip/comp.c
uip/dist.c
uip/flist.c
uip/folder.c
uip/forw.c
uip/inc.c
uip/install-mh.c
uip/mark.c
uip/mhbuild.c
uip/mhbuildsbr.c
uip/mhcachesbr.c
uip/mhlist.c
uip/mhlistsbr.c
uip/mhparse.c
uip/mhpath.c
uip/mhshow.c
uip/mhshowsbr.c
uip/mhstore.c
uip/mhstoresbr.c
uip/mhtest.c
uip/new.c
uip/packf.c
uip/pick.c
uip/picksbr.c
uip/rcvstore.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/send.c
uip/sendsbr.c
uip/show.c
uip/slocal.c
uip/sortm.c
uip/whatnowsbr.c

index 24827e9..cc12128 100644 (file)
@@ -31,19 +31,9 @@ etcpath (char *file)
 #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';
@@ -65,15 +55,20 @@ etcpath (char *file)
 
                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);
@@ -117,10 +112,10 @@ char *mhlformat = "mhl.format";            /* show         */
 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";
diff --git a/h/mh.h b/h/mh.h
index 59b5c0f..4b846cf 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -253,13 +253,6 @@ extern char *msg_delim;      /*  .. */
 
 #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 */
 
 /*
index 15031ea..b7d6bfb 100644 (file)
@@ -45,6 +45,8 @@ void cpydgst(int, int, char *, char *);
 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 *);
@@ -59,7 +61,8 @@ int getanswer(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 *);
@@ -70,8 +73,6 @@ int m_convert(struct msgs *, 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 **);
@@ -81,11 +82,9 @@ int makedir(char *);
 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 *);
@@ -115,6 +114,7 @@ int smatch(char *, struct swit *);
 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 *);
index b581ec2..817d98f 100644 (file)
@@ -89,7 +89,7 @@ may also produce audits to this (or another) file, perhaps with
 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
index ad54a95..7780970 100644 (file)
@@ -59,11 +59,11 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c  \
        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  \
index 0995d4f..4f74499 100644 (file)
@@ -64,13 +64,13 @@ context_read(void)
        */
 
        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);
 
@@ -134,7 +134,7 @@ context_read(void)
                return;
        }
 
-       ctxpath = getcpy(m_maildir(cp));
+       ctxpath = getcpy(toabsdir(cp));
 
        if ((ib = lkfopen(ctxpath, "r"))) {
                readconfig((struct node **) 0, ib, cp, 1);
index 0e013ab..80a1e54 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** 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
index 222b490..c28b430 100644 (file)
@@ -30,7 +30,7 @@ folder_read(char *name)
        struct dirent *dp;
        DIR *dd;
 
-       name = m_mailpath(name);
+       name = getcpy(toabsdir(name));
        if (!(dd = opendir(name))) {
                free(name);
                return NULL;
diff --git a/sbr/getfolder.c b/sbr/getfolder.c
deleted file mode 100644 (file)
index fc87e1e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-** 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;
-       }
-}
index df767ef..38584e4 100644 (file)
@@ -22,10 +22,10 @@ m_draft(char *which)
        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);
 
diff --git a/sbr/m_maildir.c b/sbr/m_maildir.c
deleted file mode 100644 (file)
index 957e44b..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-** 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;
-}
index 68f1a54..4a1eed1 100644 (file)
@@ -144,5 +144,5 @@ get_temp_dir()
                tmpdir = getenv("TMP");
                if (tmpdir != NULL && *tmpdir != '\0') return tmpdir;
        }
-       return m_maildir("");
+       return toabsdir("+");
 }
index 3dd552c..4132896 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** 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
@@ -8,13 +8,13 @@
 
 #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)
@@ -90,111 +90,147 @@ 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;
        }
 }
index 55be77c..1cd3dc9 100644 (file)
@@ -89,6 +89,7 @@ pwd(void)
 /*
 ** 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
index 66d8a0d..ec3590c 100644 (file)
@@ -198,7 +198,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -211,8 +211,8 @@ main(int argc, char **argv)
        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");
index 44f6bfe..b5414ad 100644 (file)
@@ -107,7 +107,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else {
                        msgs[msgp++] = cp;
                }
@@ -116,8 +116,8 @@ main(int argc, char **argv)
        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");
index 95b5c94..676ff23 100644 (file)
@@ -124,7 +124,7 @@ main(int argc, char **argv)
                        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!");
@@ -145,8 +145,8 @@ main(int argc, char **argv)
                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");
index d31c5c9..991f5cd 100644 (file)
@@ -108,7 +108,7 @@ main(int argc, char **argv)
                                                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 == '-')
@@ -127,7 +127,7 @@ main(int argc, char **argv)
                        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!");
@@ -164,8 +164,8 @@ main(int argc, char **argv)
                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");
index aef291a..d85ad61 100644 (file)
@@ -229,17 +229,17 @@ main(int argc, char **argv)
                                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
index 735b5e7..70f497d 100644 (file)
@@ -241,7 +241,7 @@ main(int argc, char **argv)
                        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!");
@@ -250,7 +250,7 @@ main(int argc, char **argv)
                }
        }
 
-       nmhdir = concat(m_maildir(""), "/", NULL);
+       nmhdir = concat(toabsdir("+"), "/", NULL);
 
        /*
        ** If we aren't working with the folder stack
@@ -271,15 +271,15 @@ main(int argc, char **argv)
                        } 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()));
                }
        }
 
@@ -307,7 +307,7 @@ main(int argc, char **argv)
                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   */
@@ -318,7 +318,7 @@ main(int argc, char **argv)
 
        /* 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++)
@@ -371,14 +371,14 @@ main(int argc, char **argv)
                                                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 */
index 666228b..3f940f7 100644 (file)
@@ -168,7 +168,7 @@ main(int argc, char **argv)
                                                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 == '-')
@@ -233,7 +233,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else {
                        msgs[msgp++] = cp;
                }
@@ -245,7 +245,7 @@ main(int argc, char **argv)
                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));
@@ -263,8 +263,8 @@ main(int argc, char **argv)
                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");
index 9e6fb6f..2a866e9 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -192,7 +192,7 @@ main(int argc, char **argv)
                        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;
@@ -223,7 +223,7 @@ main(int argc, char **argv)
                                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,
@@ -265,7 +265,7 @@ main(int argc, char **argv)
                        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);
@@ -286,9 +286,9 @@ main(int argc, char **argv)
        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);
        }
@@ -301,8 +301,8 @@ main(int argc, char **argv)
        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");
index 11f7bc5..1fb6834 100644 (file)
@@ -102,7 +102,7 @@ main(int argc, char **argv)
        */
 
        if ((cp = getenv("MH")) && *cp != '\0')
-               defpath = path(cp, TFILE);
+               defpath = getcpy(expanddir(cp));
        else
                defpath = concat(mypath, "/", mh_profile, NULL);
 
@@ -198,7 +198,7 @@ query:
                fclose(in);
        }
 
-       ctxpath = getcpy(m_maildir(context = "context"));
+       ctxpath = getcpy(toabsdir(context = "context"));
 
        /* Initialize current folder to default */
        context_replace(pfolder, defaultfolder);
index 03818f3..5fd27f6 100644 (file)
@@ -134,7 +134,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -154,8 +154,8 @@ main(int argc, char **argv)
        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");
index 5055265..bf6f646 100644 (file)
@@ -283,7 +283,7 @@ main(int argc, char **argv)
        /* 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
@@ -293,7 +293,7 @@ main(int argc, char **argv)
        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)
index 94c1ce7..873b0e3 100644 (file)
@@ -171,8 +171,8 @@ build_mime(char *infile)
                        }
 
                        /* 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) {
@@ -214,7 +214,7 @@ finish_field:
        ** 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);
 
@@ -227,7 +227,7 @@ finish_field:
                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");
@@ -424,7 +424,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp)
                        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] == '<') {
@@ -652,7 +652,7 @@ use_forw:
                                        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 {
@@ -682,7 +682,7 @@ use_forw:
                                done(1);
                        }
                }
-               ci->ci_magic = add(cp, NULL);
+               ci->ci_magic = getcpy(cp);
                return OK;
        }
 
@@ -715,13 +715,13 @@ use_forw:
                                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);
@@ -773,7 +773,7 @@ use_forw:
                                        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;
@@ -795,7 +795,7 @@ use_forw:
                        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;
                }
@@ -966,7 +966,7 @@ compose_content(CT ct)
                        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;
                }
@@ -1032,7 +1032,7 @@ compose_content(CT ct)
                        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;
@@ -1369,7 +1369,7 @@ scan_content(CT ct)
                                                NULL);
                        } else {
                                t->tx_charset = CHARSET_USASCII;
-                               *ap = add("charset=us-ascii", NULL);
+                               *ap = getcpy("charset=us-ascii");
                        }
 
                        cp = strchr(*ap++, '=');
@@ -1438,7 +1438,7 @@ build_headers(CT ct)
                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;
@@ -1457,7 +1457,7 @@ build_headers(CT ct)
        /*
        ** 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 */
@@ -1514,7 +1514,7 @@ build_headers(CT ct)
        ** 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);
        }
@@ -1523,7 +1523,7 @@ build_headers(CT ct)
        ** 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);
        }
@@ -1532,7 +1532,7 @@ build_headers(CT ct)
        ** 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);
        }
@@ -1550,7 +1550,7 @@ skip_headers:
        ** 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);
@@ -1563,7 +1563,7 @@ skip_headers:
        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
@@ -1573,7 +1573,7 @@ skip_headers:
                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;
@@ -1582,7 +1582,7 @@ skip_headers:
                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;
@@ -1591,7 +1591,7 @@ skip_headers:
                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;
@@ -1600,7 +1600,7 @@ skip_headers:
                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;
index 91affaa..c365470 100644 (file)
@@ -422,7 +422,7 @@ find_cache_aux2(char *mapfile, char *id, char *mapname, int namelen)
                                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);
index 92169a0..b87e522 100644 (file)
@@ -219,8 +219,9 @@ do_cache:
 
                        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:
@@ -238,7 +239,7 @@ do_cache:
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -256,7 +257,7 @@ do_cache:
        /* 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,
@@ -266,7 +267,7 @@ do_cache:
        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!");
@@ -288,8 +289,8 @@ do_cache:
                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");
index 7830173..ecd6bac 100644 (file)
@@ -207,7 +207,7 @@ list_content(CT ct, int toplevel, int realsize, int verbose, int debug)
        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);
@@ -222,7 +222,7 @@ list_content(CT ct, int toplevel, int realsize, int verbose, int debug)
        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);
index 6553ac3..3aeb351 100644 (file)
@@ -205,7 +205,7 @@ parse_mime(char *file)
                        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))
@@ -281,7 +281,7 @@ get_content(FILE *in, char *file, int toplevel)
                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;
 
        /*
@@ -296,8 +296,8 @@ get_content(FILE *in, char *file, int toplevel)
                        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) {
@@ -357,7 +357,7 @@ get_content(FILE *in, char *file, int toplevel)
                                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;
@@ -429,7 +429,7 @@ get_content(FILE *in, char *file, int toplevel)
                        }
 
                        /* get copy of this field */
-                       ct->c_celine = cp = add(hp->value, NULL);
+                       ct->c_celine = cp = getcpy(hp->value);
 
                        while (isspace(*cp))
                                cp++;
@@ -467,7 +467,7 @@ get_content(FILE *in, char *file, int toplevel)
                                goto next_header;
                        }
 
-                       ep = cp = add(hp->value, NULL);  /* get a copy */
+                       ep = cp = getcpy(hp->value);
 
                        while (isspace(*cp))
                                cp++;
@@ -615,7 +615,7 @@ incl_name_value(unsigned char *buf, char *name, char *value) {
                        ** 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';
@@ -688,7 +688,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        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++;
@@ -712,7 +712,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        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) {
@@ -734,7 +734,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
 
        if (*cp != '/') {
                if (!magic)
-                       ci->ci_subtype = add("", NULL);
+                       ci->ci_subtype = getcpy("");
                goto magic_skip;
        }
 
@@ -748,7 +748,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        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) {
@@ -805,7 +805,7 @@ magic_skip:
                        return NOTOK;
                }
 
-               vp = (*ap = add(cp, NULL)) + (up - cp);
+               vp = (*ap = getcpy(cp)) + (up - cp);
                *vp = '\0';
                for (dp++; isspace(*dp);)
                        dp++;
@@ -941,7 +941,7 @@ bad_quote:
        */
        if (*cp) {
                if (magic) {
-                       ci->ci_magic = add(cp, NULL);
+                       ci->ci_magic = getcpy(cp);
 
                        /*
                        ** If there is a Content-Disposition header and
@@ -1010,7 +1010,7 @@ invalid:
                        ci->ci_comment = concat(dp, " ", buffer, NULL);
                        free(dp);
                } else {
-                       ci->ci_comment = add(buffer, NULL);
+                       ci->ci_comment = getcpy(buffer);
                }
        }
 
@@ -1276,7 +1276,7 @@ last_part:
                        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) {
@@ -1384,7 +1384,7 @@ InitMessage(CT ct)
                                */
                                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")) {
@@ -1740,10 +1740,10 @@ openBase64(CT ct, char **file)
        }
 
        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;
        }
 
@@ -1960,10 +1960,10 @@ openQuoted(CT ct, char **file)
        }
 
        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;
        }
 
@@ -2195,10 +2195,10 @@ open7Bit(CT ct, char **file)
        }
 
        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;
        }
 
@@ -2583,11 +2583,11 @@ openFTP(CT ct, char **file)
        }
 
        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,
@@ -2786,10 +2786,10 @@ openMail(CT ct, char **file)
        }
 
        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;
        }
 
@@ -2805,7 +2805,7 @@ openMail(CT ct, char **file)
        */
        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;
index eb3b618..5009a2f 100644 (file)
@@ -63,14 +63,14 @@ main(int argc, char **argv)
                        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) {
index 42e0ee0..3510120 100644 (file)
@@ -238,7 +238,7 @@ do_cache:
                                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:
@@ -284,7 +284,7 @@ do_cache:
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -328,7 +328,7 @@ do_cache:
        /* 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,
@@ -338,7 +338,7 @@ do_cache:
        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!");
@@ -360,8 +360,8 @@ do_cache:
                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");
index 0a527ad..7f3ef70 100644 (file)
@@ -669,7 +669,7 @@ show_text(CT ct, int serial, int alternate)
                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);
        }
 
@@ -884,7 +884,7 @@ show_multi_aux(CT ct, int serial, int alternate, char *cp)
                                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);
@@ -1098,7 +1098,7 @@ show_message_rfc822(CT ct, int serial, int alternate)
 
        /* 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);
        }
 
index 4a17547..1fbd50e 100644 (file)
@@ -209,7 +209,7 @@ do_cache:
                                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:
@@ -227,9 +227,9 @@ do_cache:
                        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 */
@@ -266,7 +266,7 @@ do_cache:
        /* 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.
@@ -281,7 +281,7 @@ do_cache:
        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!");
@@ -303,8 +303,8 @@ do_cache:
                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");
index 0fa70ca..44fd19a 100644 (file)
@@ -249,13 +249,13 @@ store_application(CT ct)
                }
 
                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"));
                                }
                        }
                }
@@ -417,9 +417,9 @@ store_external(CT ct)
                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);
                }
        }
 
@@ -506,11 +506,11 @@ store_content(CT ct, CT p)
                */
                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;
                }
@@ -550,19 +550,19 @@ store_content(CT ct, CT p)
 
                /* 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);
@@ -584,7 +584,7 @@ store_content(CT ct, CT p)
                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 */
@@ -1033,7 +1033,7 @@ get_storeproc(CT ct)
                if (!mh_strcasecmp(*ap, "name") && *(cp = *ep) != '/' &&
                                *cp != '.' && *cp != '|' && *cp != '!' &&
                                !strchr(cp, '%')) {
-                       ct->c_storeproc = add(cp, NULL);
+                       ct->c_storeproc = getcpy(cp);
                        return;
                }
        }
index 454fa1d..df5985f 100644 (file)
@@ -203,14 +203,14 @@ do_cache:
                                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:
@@ -228,7 +228,7 @@ do_cache:
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -249,7 +249,7 @@ do_cache:
        /* 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,
@@ -259,7 +259,7 @@ do_cache:
        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!");
@@ -281,8 +281,8 @@ do_cache:
                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");
index c1ae0cc..fc87b3a 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -94,7 +94,7 @@ seq_in_list(char *name, char *sequences[])
 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];
@@ -252,7 +252,7 @@ check_folders(struct node **first, struct node **last,
        b.sequences = sequences;
 
        if (folders == NULL) {
-               chdir(m_maildir(""));
+               chdir(toabsdir("+"));
                crawl_folders(".", crawl_callback, &b);
        } else {
                fp = fopen(folders, "r");
@@ -497,7 +497,7 @@ main(int argc, char **argv)
                /* will flists */
        } else {
                if (folders[0] != '/') {
-                       folders = m_maildir(folders);
+                       folders = toabsdir(folders);
                }
        }
 
index 5e17147..b48a92d 100644 (file)
@@ -98,14 +98,14 @@ main(int argc, char **argv)
                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)
@@ -125,8 +125,8 @@ main(int argc, char **argv)
                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 ");
index f0dcec3..2efac42 100644 (file)
@@ -182,7 +182,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -196,8 +196,8 @@ main(int argc, char **argv)
                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");
index f95ddbc..ffacb5d 100644 (file)
@@ -955,7 +955,7 @@ plist
                        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);
index 5ed378a..99ec48c 100644 (file)
@@ -135,7 +135,7 @@ main(int argc, char **argv)
                        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);
@@ -146,8 +146,8 @@ main(int argc, char **argv)
 
        /* 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) {
index 690b55b..32b7f15 100644 (file)
@@ -128,7 +128,7 @@ main(int argc, char **argv)
                                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)
@@ -137,7 +137,7 @@ main(int argc, char **argv)
                                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:
@@ -154,10 +154,9 @@ main(int argc, char **argv)
                        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)
@@ -187,8 +186,8 @@ main(int argc, char **argv)
        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");
@@ -275,8 +274,8 @@ opnfolds(struct st_fold *folders, int nfolders)
        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);
 
index fd92101..058b536 100644 (file)
@@ -199,7 +199,7 @@ main(int argc, char **argv)
                                                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);
@@ -212,7 +212,7 @@ main(int argc, char **argv)
                                                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 == '-')
@@ -267,7 +267,7 @@ main(int argc, char **argv)
                        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!");
@@ -289,7 +289,7 @@ main(int argc, char **argv)
                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));
@@ -307,8 +307,8 @@ main(int argc, char **argv)
                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");
index 3b532e0..7d81a39 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -74,7 +74,7 @@ main(int argc, char **argv)
                        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);
@@ -82,11 +82,11 @@ main(int argc, char **argv)
        }
 
        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;
@@ -98,9 +98,9 @@ main(int argc, char **argv)
                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) {
@@ -132,7 +132,7 @@ rmf(char *folder)
        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)
@@ -140,7 +140,7 @@ rmf(char *folder)
 
                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;
@@ -232,7 +232,7 @@ rma(char *folder)
        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
@@ -257,4 +257,5 @@ rma(char *folder)
                        pp = np;
                }
        }
+       free(cp);
 }
index b90b43e..e599f6f 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -73,7 +73,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -81,8 +81,8 @@ main(int argc, char **argv)
        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");
index 80addfc..1276d5b 100644 (file)
@@ -143,8 +143,8 @@ main(int argc, char **argv)
                                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;
                        }
                }
@@ -152,9 +152,9 @@ main(int argc, char **argv)
                        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);
        }
 
        /*
@@ -175,9 +175,8 @@ main(int argc, char **argv)
                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
@@ -204,8 +203,8 @@ main(int argc, char **argv)
        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");
index 8163385..a9ae46d 100644 (file)
@@ -127,7 +127,7 @@ main(int argc, char **argv)
        argp = arguments;
 
        vec[vecp++] = "-library";
-       vec[vecp++] = getcpy(m_maildir(""));
+       vec[vecp++] = getcpy(toabsdir("+"));
 
        while ((cp = *argp++)) {
                if (*cp == '-') {
@@ -259,7 +259,7 @@ main(int argc, char **argv)
 
        if (!msgp)
                msgs[msgp++] = "cur";
-       maildir = m_maildir(draftfolder);
+       maildir = toabsdir(draftfolder);
 
        if (chdir(maildir) == NOTOK)
                adios(maildir, "unable to change directory to");
index 4670345..a8e0964 100644 (file)
@@ -258,10 +258,10 @@ attach(char *attachment_header_field_name, char *draft_file_name,
        */
 
        (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)
@@ -512,7 +512,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
 
                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
@@ -534,7 +534,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat)
 
                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
@@ -806,7 +806,7 @@ annoaux(int fd)
                        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");
index fb517d1..977b0e4 100644 (file)
@@ -112,7 +112,7 @@ usage:
                                                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:
@@ -164,7 +164,7 @@ usage:
                        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 {
@@ -203,8 +203,8 @@ usage:
        }
 
        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");
@@ -333,7 +333,7 @@ go_to_it: ;
        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)
@@ -375,7 +375,7 @@ is_nontext(char *msgnam)
                                int passno;
                                char c;
 
-                               cp = add(buf, NULL);
+                               cp = getcpy(buf);
                                while (state == FLDPLUS) {
                                        state = m_getfld(state, name, buf,
                                                        sizeof(buf), fp);
@@ -481,7 +481,7 @@ out:
                        ** 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);
index 8b8d554..fde4107 100644 (file)
@@ -792,7 +792,7 @@ parse(int fd)
                        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);
@@ -1586,7 +1586,7 @@ suppress_duplicates(int fd, char *file)
                                        continue;
                                }
 
-                               cp = add(buf, NULL);
+                               cp = getcpy(buf);
                                while (state == FLDPLUS) {
                                        state = m_getfld(state, name, buf, sizeof(buf), in);
                                        cp = add(buf, cp);
index f9a4cff..5132c1f 100644 (file)
@@ -159,7 +159,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -169,8 +169,8 @@ main(int argc, char **argv)
        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");
index a5f8839..8687815 100644 (file)
@@ -1126,7 +1126,7 @@ sendit(char *sp, char **arg, char *file, int pushed)
 
        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 == '-') {