Dropped old show(1) and renamed mhshow(1) to show(1).
[mmh] / uip / mhshowsbr.c
index 4a7fc0c..2a8bbf9 100644 (file)
@@ -22,7 +22,6 @@ extern int debugsw;
 
 int nolist   = 0;
 char *formsw = NULL;
-pid_t xpid = 0;
 
 
 /* mhparse.c */
@@ -86,9 +85,16 @@ show_all_messages(CT *cts)
        for (ctp = cts; *ctp; ctp++) {
                ct = *ctp;
 
-               /* if top-level type is ok, then display message */
-               if (type_ok(ct, 1))
-                       show_single_message(ct, formsw);
+               if (!type_ok(ct, 1)) {  /* top-level type */
+                       continue;
+               }
+               if (cts[1]) {
+                       if (ctp != cts) {
+                               printf("\n\n");
+                       }
+                       printf(">>> Message %s\n\n", ct->c_file);
+               }
+               show_single_message(ct, formsw);
        }
 }
 
@@ -100,9 +106,6 @@ show_all_messages(CT *cts)
 static void
 show_single_message(CT ct, char *form)
 {
-       sigset_t set, oset;
-       int status;
-
        /*
        ** Allow user executable bit so that temporary directories created by
        ** the viewer (e.g., lynx) are going to be accessible
@@ -115,8 +118,6 @@ show_single_message(CT ct, char *form)
        */
        if (form)
                DisplayMsgHeader(ct, form);
-       else
-               xpid = 0;
 
        /* Show the body of the message */
        show_switch(ct, 0);
@@ -128,23 +129,6 @@ show_single_message(CT ct, char *form)
        if (ct->c_ceclosefnx)
                (*ct->c_ceclosefnx) (ct);
 
-       /* block a few signals */
-       sigemptyset(&set);
-       sigaddset(&set, SIGHUP);
-       sigaddset(&set, SIGINT);
-       sigaddset(&set, SIGQUIT);
-       sigaddset(&set, SIGTERM);
-       sigprocmask(SIG_BLOCK, &set, &oset);
-
-       while (wait(&status) != NOTOK) {
-               pidcheck(status);
-               continue;
-       }
-
-       /* reset the signal mask */
-       sigprocmask(SIG_SETMASK, &oset, &set);
-
-       xpid = 0;
        flush_errors();
 }
 
@@ -182,7 +166,7 @@ DisplayMsgHeader(CT ct, char *form)
                /* NOTREACHED */
 
        default:
-               xpid = child_id;
+               pidcheck(pidwait(child_id, NOTOK));
                break;
        }
 }
@@ -249,13 +233,13 @@ show_content(CT ct, int alternate)
        CI ci = &ct->c_ctinfo;
 
        /* Check for mhshow-show-type/subtype */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
-                               invo_name, ci->ci_type, ci->ci_subtype);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s/%s",
+                               ci->ci_type, ci->ci_subtype);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);
 
        /* Check for mhshow-show-type */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s", ci->ci_type);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);
 
@@ -335,9 +319,8 @@ show_content_aux(CT ct, int alternate, char *cp, char *cracked)
 
                        case 'c':
                                /* insert charset */
-                               if (ct->c_charset) {
-                                       strncpy(bp, ct->c_charset, buflen);
-                               }
+                               strncpy(bp, ct->c_charset ? ct->c_charset :
+                                               "US-ASCII", buflen);
                                break;
 
                        case 'd':
@@ -459,11 +442,6 @@ show_content_aux2(CT ct, int alternate, char *cracked,
 {
        pid_t child_id;
 
-       if (xpid) {
-               pidcheck(pidwait(xpid, NOTOK));
-               xpid = 0;
-       }
-
        if (debugsw || cracked) {
                fflush(stdout);
 
@@ -526,13 +504,13 @@ show_text(CT ct, int alternate)
        CI ci = &ct->c_ctinfo;
 
        /* Check for mhshow-show-type/subtype */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
-                       invo_name, ci->ci_type, ci->ci_subtype);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s/%s",
+                       ci->ci_type, ci->ci_subtype);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);
 
        /* Check for mhshow-show-type */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s", ci->ci_type);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);
 
@@ -541,7 +519,8 @@ show_text(CT ct, int alternate)
        ** if it is not a text part of a multipart/alternative
        */
        if (!alternate || ct->c_subtype == TEXT_PLAIN) {
-               if (!check_charset(ct->c_charset, strlen(ct->c_charset))) {
+               if (ct->c_charset && !check_charset(ct->c_charset,
+                               strlen(ct->c_charset))) {
                        snprintf(buffer, sizeof(buffer), "%%liconv -f '%s'",
                                        ct->c_charset);
                } else {
@@ -566,13 +545,13 @@ show_multi(CT ct, int alternate)
        CI ci = &ct->c_ctinfo;
 
        /* Check for mhshow-show-type/subtype */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
-                       invo_name, ci->ci_type, ci->ci_subtype);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s/%s",
+                       ci->ci_type, ci->ci_subtype);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_multi_aux(ct, alternate, cp);
 
        /* Check for mhshow-show-type */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s", ci->ci_type);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_multi_aux(ct, alternate, cp);
 
@@ -742,9 +721,8 @@ show_multi_aux(CT ct, int alternate, char *cp)
 
                        case 'c':
                                /* insert charset */
-                               if (ct->c_charset) {
-                                       strncpy(bp, ct->c_charset, buflen);
-                               }
+                               strncpy(bp, ct->c_charset ? ct->c_charset :
+                                               "US-ASCII", buflen);
                                break;
 
                        case 'd':
@@ -872,13 +850,13 @@ show_message_rfc822(CT ct, int alternate)
        CI ci = &ct->c_ctinfo;
 
        /* Check for mhshow-show-type/subtype */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
-                               invo_name, ci->ci_type, ci->ci_subtype);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s/%s",
+                               ci->ci_type, ci->ci_subtype);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);
 
        /* Check for mhshow-show-type */
-       snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
+       snprintf(buffer, sizeof(buffer), "mhshow-show-%s", ci->ci_type);
        if ((cp = context_find(buffer)) && *cp != '\0')
                return show_content_aux(ct, alternate, cp, NULL);