Introduced FDEF and FCUR for speaking arguments to getfolder().
authormarkus schnalke <meillo@marmaro.de>
Sat, 5 Nov 2011 16:56:07 +0000 (17:56 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sat, 5 Nov 2011 16:56:07 +0000 (17:56 +0100)
Maybe it would be better to two separate functions, but I cannot
imagine good names for them ... :-(

29 files changed:
h/mh.h
sbr/m_maildir.c
sbr/path.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/mark.c
uip/mhbuildsbr.c
uip/mhlist.c
uip/mhpath.c
uip/mhshow.c
uip/mhstore.c
uip/mhstoresbr.c
uip/mhtest.c
uip/packf.c
uip/pick.c
uip/rcvstore.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/show.c
uip/sortm.c

diff --git a/h/mh.h b/h/mh.h
index 2e3be95..59b5c0f 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -257,6 +257,9 @@ extern char *msg_delim;      /*  .. */
 #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 95f72af..957e44b 100644 (file)
@@ -66,7 +66,7 @@ exmaildir(char *folder)
 
        /* use current folder if none is specified */
        if (folder == NULL)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
 
        if (!(*folder != '/' && strncmp(folder, CWD, NCWD)
                        && strcmp(folder, DOT) && strcmp(folder, DOTDOT)
index 8802eaa..b3a8fff 100644 (file)
@@ -101,7 +101,8 @@ expath(char *name, int type)
 
        if (type == TSUBCWF) {
                /* @folder to +folder */
-               snprintf(buffer, sizeof(buffer), "%s/%s", getfolder(1), name);
+               snprintf(buffer, sizeof(buffer), "%s/%s",
+                               getfolder(FCUR), name);
                name = m_mailpath(buffer);
                packpath(name);
                snprintf(buffer, sizeof(buffer), "%s/", m_maildir(""));
index b7c1563..3a0fa8c 100644 (file)
@@ -213,7 +213,7 @@ main(int argc, char **argv)
        if (!msgs.size)
                app_msgarg(&msgs, "cur");
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index a8f42d0..032c5b5 100644 (file)
@@ -118,7 +118,7 @@ main(int argc, char **argv)
        if (!msgp)
                msgs[msgp++] = "cur";
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index 7a49362..9f0929d 100644 (file)
@@ -148,7 +148,7 @@ main(int argc, char **argv)
                if (!msg)
                        msg = "cur";
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index 5ff0d6c..131cda9 100644 (file)
@@ -166,7 +166,7 @@ main(int argc, char **argv)
                if (!msg)
                        msg = "cur";
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index 4bf3f82..5d9dfcc 100644 (file)
@@ -240,7 +240,7 @@ main(int argc, char **argv)
                free(path("./", TFOLDER));
 
        /* get current folder */
-       strncpy(curfolder, getfolder(1), sizeof(curfolder));
+       strncpy(curfolder, getfolder(FCUR), sizeof(curfolder));
 
        /* get nmh base directory */
        nmhdir = m_maildir("");
index 25ab068..4fa9424 100644 (file)
@@ -273,15 +273,15 @@ main(int argc, char **argv)
                        } else {
                                adios(NULL, "no other folder");
                        }
-                       for (cp = getcpy(getfolder(1)); *ap; ap++)
+                       for (cp = getcpy(getfolder(FCUR)); *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(1), " ", cp, NULL) :
-                                       getcpy(getfolder(1)));
+                                       concat(getfolder(FCUR), " ", cp, NULL) :
+                                       getcpy(getfolder(FCUR)));
                }
        }
 
@@ -320,7 +320,7 @@ main(int argc, char **argv)
 
        /* Listing the folder stack */
        if (listsw) {
-               printf("%s", argfolder ? argfolder : getfolder(1));
+               printf("%s", argfolder ? argfolder : getfolder(FCUR));
                if ((cp = context_find(stack))) {
                        dp = getcpy(cp);
                        for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
index 13aaaa9..002bb67 100644 (file)
@@ -265,7 +265,7 @@ main(int argc, char **argv)
                if (!msgp)
                        msgs[msgp++] = "cur";
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index c06c57c..d23bf32 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -303,7 +303,7 @@ main(int argc, char **argv)
        if (!context_find("path"))
                free(path("./", TFOLDER));
        if (!folder)
-               folder = getfolder(0);
+               folder = getfolder(FDEF);
        maildir = m_maildir(folder);
 
        if ((maildir_copy = strdup(maildir)) == (char *)0)
index fa5c2cb..d56a161 100644 (file)
@@ -156,7 +156,7 @@ main(int argc, char **argv)
        if (!msgs.size)
                app_msgarg(&msgs, listsw ? "all" :"cur");
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index 23163f7..94c1ce7 100644 (file)
@@ -721,7 +721,7 @@ use_forw:
 
                /* else, use the current folder */
                if (!folder)
-                       folder = add(getfolder(1), NULL);
+                       folder = add(getfolder(FCUR), NULL);
 
                if (!(mp = folder_read(folder)))
                        adios(NULL, "unable to read folder %s", folder);
index f33e39b..5eb0937 100644 (file)
@@ -291,7 +291,7 @@ do_cache:
                if (!msgs.size)
                        app_msgarg(&msgs, "cur");
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index bce976d..2281ba0 100644 (file)
@@ -72,7 +72,7 @@ main(int argc, char **argv)
                free(path("./", TFOLDER));
 
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        /* If no messages are given, print folder pathname */
index ba5c037..bb7a8e7 100644 (file)
@@ -363,7 +363,7 @@ do_cache:
                if (!msgs.size)
                        app_msgarg(&msgs, "cur");
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index 7be9163..f61a5c0 100644 (file)
@@ -306,7 +306,7 @@ do_cache:
                if (!msgs.size)
                        app_msgarg(&msgs, "cur");
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index 027dac6..0fa70ca 100644 (file)
@@ -556,7 +556,7 @@ store_content(CT ct, CT p)
                if (cp[1])
                        folder = pluspath(cp);
                else
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
 
                /* Check if folder exists */
                create_folder(m_mailpath(folder), 0, exit);
index 17ca1ab..581349f 100644 (file)
@@ -284,7 +284,7 @@ do_cache:
                if (!msgs.size)
                        app_msgarg(&msgs, "cur");
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index d4df05c..727298c 100644 (file)
@@ -128,7 +128,7 @@ main(int argc, char **argv)
                app_msgarg(&msgs, "all");
 
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index 93a2400..69b9415 100644 (file)
@@ -199,7 +199,7 @@ main(int argc, char **argv)
                app_msgarg(&msgs, "all");
 
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index 06b8b69..a120c66 100644 (file)
@@ -149,7 +149,7 @@ main(int argc, char **argv)
 
        /* if no folder is given, use default folder */
        if (!folder)
-               folder = getfolder(0);
+               folder = getfolder(FDEF);
        maildir = m_maildir(folder);
 
        /* check if folder exists */
index a79e8be..f391f61 100644 (file)
@@ -192,7 +192,7 @@ main(int argc, char **argv)
        if (!msgs.size)
                app_msgarg(&msgs, "cur");
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        strncpy(maildir, m_maildir(folder), sizeof(maildir));
 
        if (chdir(maildir) == NOTOK)
index 61ba08c..006cabe 100644 (file)
@@ -310,7 +310,7 @@ main(int argc, char **argv)
                if (!msg)
                        msg = "cur";
                if (!folder)
-                       folder = getfolder(1);
+                       folder = getfolder(FCUR);
                maildir = m_maildir(folder);
 
                if (chdir(maildir) == NOTOK)
index 71fd017..94198d0 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -84,7 +84,7 @@ main(int argc, char **argv)
        if (!context_find("path"))
                free(path("./", TFOLDER));
        if (!folder) {
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
                defolder++;
        }
        if (strcmp(m_mailpath(folder), pwd()) == 0)
@@ -100,9 +100,9 @@ main(int argc, char **argv)
                if (cp > newfolder)
                        *cp = '\0';
                else
-                       strncpy(newfolder, getfolder(0), sizeof(newfolder));
+                       strncpy(newfolder, getfolder(FDEF), sizeof(newfolder));
        } else {
-               strncpy(newfolder, getfolder(0), sizeof(newfolder));
+               strncpy(newfolder, getfolder(FDEF), sizeof(newfolder));
        }
 
        if (interactive) {
index 7f77340..aca436a 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -83,7 +83,7 @@ main(int argc, char **argv)
        if (!msgs.size)
                app_msgarg(&msgs, "cur");
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index b42d8a2..4b0b338 100644 (file)
@@ -207,7 +207,7 @@ main(int argc, char **argv)
        if (!msgs.size)
                app_msgarg(&msgs, "all");
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index b19f762..ceb9018 100644 (file)
@@ -206,7 +206,7 @@ usage:
        }
 
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)
index ffe14f8..5151889 100644 (file)
@@ -171,7 +171,7 @@ main(int argc, char **argv)
        if (!datesw)
                datesw = "date";
        if (!folder)
-               folder = getfolder(1);
+               folder = getfolder(FCUR);
        maildir = m_maildir(folder);
 
        if (chdir(maildir) == NOTOK)