]> diplodocus.org Git - nmh/blobdiff - uip/show.c
Match `NORETURN' function prototypes by adding it to definition.
[nmh] / uip / show.c
index e5b71eff0a24a7246bfb0d58ca778b563a50fd00..d5afcad18f45626886aa5359c5b6259ba6271041 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * show.c -- show/list messages
+/* show.c -- show/list messages
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
     /*                         \
      * switches for mhlproc    \
      */                                \
-    X("concat", -6, CONCATSW) \
-    X("noconcat", -8, NCONCATSW) \
+    X("concat", 0, CONCATSW) \
+    X("noconcat", 0, NCONCATSW) \
+    /*                         \
+     * switches for mhshow     \
+     */                                \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("prefer content", 0, PREFERSW) \
+    X("markform file", 0, MARKFORMSW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
 
 #define X(sw, minchars, id) id,
 DEFINE_SWITCH_ENUM(SHOW);
@@ -79,23 +86,30 @@ main (int argc, char **argv)
     while ((cp = *argp++)) {
        if (*cp == '-') {
            switch (smatch (++cp, switches)) {
-               case AMBIGSW: 
+               case AMBIGSW:
                    ambigsw (cp, switches);
                    done (1);
 
+               case HEADSW:
+                   headersw = 1;
+                   goto non_mhl_switches;
+               case NHEADSW:
+                   headersw = 0;
+                   /* FALLTHRU */
                case CONCATSW:
                case NCONCATSW:
+non_mhl_switches:
                    /* mhl can't handle these, so keep them separate. */
                    app_msgarg(&non_mhl_vec, --cp);
                    continue;
 
-               case UNKWNSW: 
+               case UNKWNSW:
                case NPROGSW:
                case NFMTPROCSW:
                    app_msgarg(&vec, --cp);
                    continue;
 
-               case HELPSW: 
+               case HELPSW:
                    snprintf (buf, sizeof(buf),
                        "%s [+folder] %s[switches] [switches for showproc]",
                        invo_name, mode == SHOW ? "[msgs] ": "");
@@ -105,7 +119,7 @@ main (int argc, char **argv)
                    print_version(invo_name);
                    done (0);
 
-               case DRFTSW: 
+               case DRFTSW:
                    if (file)
                        adios (NULL, "only one file at a time!");
                    draftsw++;
@@ -115,7 +129,7 @@ usage:
                    adios (NULL,
                            "usage: %s [+folder] [switches] [switches for showproc]",
                            invo_name);
-               case FILESW: 
+               case FILESW:
                    if (mode != SHOW)
                        goto usage;
                    if (draftsw || file)
@@ -125,13 +139,6 @@ usage:
                    file = path (cp, TFILE);
                    continue;
 
-               case HEADSW: 
-                   headersw++;
-                   continue;
-               case NHEADSW: 
-                   headersw = 0;
-                   continue;
-
                case FORMSW:
                    app_msgarg(&vec, --cp);
                    if (!(cp = *argp++) || *cp == '-')
@@ -143,18 +150,24 @@ usage:
                case LENSW:
                case WIDTHSW:
                case FMTPROCSW:
+               case PARTSW:
+               case TYPESW:
+               case PREFERSW:
+               case MARKFORMSW:
+               case RCACHESW:
+               case WCACHESW:
                    app_msgarg(&vec, --cp);
                    if (!(cp = *argp++) || *cp == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
                    app_msgarg(&vec, cp);
                    continue;
 
-               case SHOWSW: 
+               case SHOWSW:
                    if (!(showproc = *argp++) || *showproc == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
                    nshow = 0;
                    continue;
-               case NSHOWSW: 
+               case NSHOWSW:
                    nshow++;
                    continue;
 
@@ -179,8 +192,7 @@ usage:
        } else {
            if (mode != SHOW)
                goto usage;
-           else
-               app_msgarg(&msgs, cp);
+            app_msgarg(&msgs, cp);
        }
     }
 
@@ -194,6 +206,7 @@ usage:
            app_msgarg(&vec, getcpy (m_draft (folder, NULL, 1, &isdf)));
        else
            app_msgarg(&vec, file);
+       headersw = 0;
        goto go_to_it;
     }
 
@@ -245,18 +258,14 @@ usage:
 
     for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
        if (is_selected(mp, msgnum))
-           app_msgarg(&vec, getcpy (m_name (msgnum)));
+           app_msgarg(&vec, mh_xstrdup(m_name (msgnum)));
 
     seq_setcur (mp, mp->hghsel);       /* update current message  */
     seq_save (mp);                     /* synchronize sequences   */
     context_replace (pfolder, folder); /* update current folder   */
     context_save ();                   /* save the context file   */
 
-    if (headersw && vec.size == 1)
-       printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
-
 go_to_it: ;
-    fflush (stdout);
 
     /*
      * Decide which "proc" to use
@@ -288,14 +297,24 @@ go_to_it: ;
     }
 
     if (folder && !draftsw && !file)
-       m_putenv ("mhfolder", folder);
+       setenv("mhfolder", folder, 1);
+
+    if (strcmp (r1bindex (proc, '/'), "cat") == 0) {
+
+       if (headersw && vec.size == 1)
+           printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
+
+    } else if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
+
+       if (headersw && vec.size == 1)
+           printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
 
-    if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
        /* If "mhl", then run it internally */
        argsplit_insert(&vec, "mhl", &program);
        app_msgarg(&vec, NULL);
        mhl (vec.size, vec.msgs);
        done (0);
+
     } else {
        int i;
        char **mp;
@@ -324,9 +343,14 @@ go_to_it: ;
                app_msgarg(&vec, vec.msgs[vec.size - 1]);
                vec.msgs[vec.size - 2] = "-file";
            }
+       } else {
+           if (headersw && vec.size == 1)
+               printf ("(Message %s:%s)\n", folder, vec.msgs[0]);
        }
     }
 
+    fflush (stdout);
+
     argsplit_insert(&vec, proc, &program);
     app_msgarg(&vec, NULL);
     execvp (program, vec.msgs);
@@ -343,7 +367,7 @@ is_nontext (char *msgnam)
 {
     int        result, state;
     char *bp, *dp, *cp;
-    char buf[BUFSIZ], name[NAMESZ];
+    char buf[NMH_BUFSIZ], name[NAMESZ];
     FILE *fp;
     m_getfld_state_t gstate = 0;
 
@@ -362,7 +386,7 @@ is_nontext (char *msgnam)
                int passno;
                char c;
 
-               cp = add (buf, NULL);
+               cp = mh_xstrdup(buf);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
                    state = m_getfld (&gstate, name, buf, &bufsz, fp);
@@ -389,7 +413,7 @@ invalid:
                            continue;
                        case '(':
                            i++;
-                           /* and fall... */
+                           /* FALLTHRU */
                        default:
                            continue;
                        case ')':
@@ -422,7 +446,7 @@ invalid:
                    if (*dp) {
                        if ((result = !uprf (dp, "charset")))
                            goto out;
-                       dp += sizeof("charset") - 1;
+                       dp += LEN("charset");
                        while (isspace ((unsigned char) *dp))
                            dp++;
                        if (*dp++ != '=')
@@ -467,7 +491,7 @@ out:
             * Check Content-Transfer-Encoding field
             */
            if (!strcasecmp (name, ENCODING_FIELD)) {
-               cp = add (buf, NULL);
+               cp = mh_xstrdup(buf);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
                    state = m_getfld (&gstate, name, buf, &bufsz, fp);