Merge branch 'master' of ssh://marmaro.de:2022/var/git/mmh
authormarkus schnalke <meillo@marmaro.de>
Wed, 11 Apr 2012 09:24:33 +0000 (11:24 +0200)
committermarkus schnalke <meillo@marmaro.de>
Wed, 11 Apr 2012 09:24:33 +0000 (11:24 +0200)
15 files changed:
etc/scan.meillo [new file with mode: 0644]
h/scansbr.h
man/inc.man1
man/mhparam.man1
man/next.man1
man/prev.man1
man/send.man1
man/show.man1
man/spost.man8
man/whatnow.man1
sbr/m_getfld.c
uip/send.c
uip/show.c
uip/spost.c
uip/whatnow.c

diff --git a/etc/scan.meillo b/etc/scan.meillo
new file mode 100644 (file)
index 0000000..53f7bb9
--- /dev/null
@@ -0,0 +1,21 @@
+%; scan.meillo
+%;
+%; The listing format I use myself.
+%;
+%4(year{date})-%02(mon{date})-%02(mday{date}) %02(hour{date}):%02(min{date})\
+ \
+%<(unseen)u%| %>\
+%<{replied}r%| %>\
+%<{forwarded}f%| %>\
+%(void(msg))%<(gt 9999)%(msg)%|%4(msg)%>\
+ \
+%<(cur)*%| %>\
+ \
+%<(mymbox{from})%<{to}-> %17(decode(friendly{to}))%>%>\
+%<(zero)%20(decode(friendly{from}))%>\
+  \
+%;(void(size))%<(gt 1000)%4(divide 1000)%|%4(size)b%>)  
+%(void(size))%4(divide 1024)\
+%<{mime-version} %|~%>\
+ \
+%(decode{subject})
index 1f0d087..91b2ff6 100644 (file)
@@ -15,7 +15,7 @@ extern char *scanl;
 */
 # define FORMAT \
 "=%4(msg)%<(cur)+%| %>%<{replied}-%| %>\
-%4(year{date})-%02(mon{date})-%02(mday{date})  \
+%4(year{date})-%02(mon{date})-%02(mday{date}) %02(hour{date}):%02(min{date})  \
 %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
 %<(zero)%17(decode(friendly{from}))%>  %(decode{subject})\n"
 
index 26ec56e..334bcd7 100644 (file)
@@ -178,7 +178,7 @@ in the background and going on to other things.
 .fi
 
 .SH "SEE ALSO"
-mhmail(1), scan(1), mh\-mail(5), post(8)
+scan(1), mh\-mail(5)
 
 .SH DEFAULTS
 .nf
index 323bc24..6d7a4b0 100644 (file)
@@ -5,6 +5,7 @@
 .SH NAME
 mhparam \- print nmh profile and context components
 .SH SYNOPSIS
+.HP 5
 .na
 .B mhparam
 .RI [ components ]
index 2b44d9f..b756c04 100644 (file)
@@ -1,92 +1 @@
-.\"
-.\" %nmhwarning%
-.\"
-.TH NEXT %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
-.SH NAME
-next \- show the next message
-.SH SYNOPSIS
-.HP 5
-.na
-.B next
-.RI [ +folder ]
-.RB [\-showproc
-.IR program ]
-.RB [ \-showmimeproc
-.IR program ]
-.RB [ \-header " | " \-noheader ]
-.RB [ \-checkmime " | " \-nocheckmime ]
-[switches\ for
-.I showproc
-or
-.IR showmimeproc ]
-.RB [ \-version ]
-.RB [ \-help ]
-.ad
-.SH DESCRIPTION
-.B Next
-performs a
-.B show
-on the next message in the specified
-(or current) folder.  Like
-.BR show ,
-it passes any switches on to
-the program
-.I showproc
-or
-.IR showmimeproc ,
-which is called to list
-the message.  This command is almost exactly equivalent to
-.RB \*(lq show
-.BR next \*(rq.
-Consult the manual entry for
-.BR show (1)
-for all the
-details.
-
-.SH FILES
-.fc ^ ~
-.nf
-.ta \w'%etcdir%/ExtraBigFileName  'u
-^$HOME/.mmh/profile~^The user profile
-.fi
-
-.SH "PROFILE COMPONENTS"
-.fc ^ ~
-.nf
-.ta 2.4i
-.ta \w'ExtraBigProfileName  'u
-^Path:~^To determine the user's mail storage
-^Current\-Folder:~^To find the default current folder
-.fi
-
-.SH "SEE ALSO"
-show(1), prev(1), mhshow(1)
-
-.SH DEFAULTS
-.nf
-.RB ` +folder "' defaults to the current folder"
-.RB ` \-checkmime '
-.RB ` \-header '
-
-.SH CONTEXT
-If a folder is specified, it will become the current folder.  The message
-that is shown (i.e., the next message in sequence) will become the
-current message.
-
-.SH BUGS
-.B next
-is really a link to the
-.B show
-program.  As a result, if
-you make a link to
-.B next
-and that link is not called
-.BR next ,
-your link will act like
-.B show
-instead.  To circumvent this, add a
-profile\-entry for the link to your
-.B nmh
-profile and add the argument
-.I next
-to the entry.
+.so man1/show.1
index 06464d4..b756c04 100644 (file)
@@ -1,91 +1 @@
-.\"
-.\" %nmhwarning%
-.\"
-.TH PREV %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
-.SH NAME
-prev \- show the previous message
-.SH SYNOPSIS
-.HP 5
-.na
-.B prev
-.RI [ +folder ]
-.RB [\-showproc
-.IR program ]
-.RB [ \-showmimeproc
-.IR program ]
-.RB [ \-header " | " \-noheader ]
-.RB [ \-checkmime " | " \-nocheckmime ]
-[switches\ for
-.I showproc
-or
-.IR showmimeproc ]
-.RB [ \-version ]
-.RB [ \-help ]
-.ad
-.SH DESCRIPTION
-.B Prev
-performs a
-.B show
-on the previous message in the specified
-(or current) folder.  Like
-.BR show ,
-it passes any switches on to
-the program named by
-.I showproc
-or
-.IR showmimeproc ,
-which is called
-to list the message.  This command is almost exactly equivalent to
-.RB \*(lq "show prev" \*(rq.
-Consult the manual entry for
-.BR show (1)
-for all the details.
-
-.SH FILES
-.fc ^ ~
-.nf
-.ta \w'%etcdir%/ExtraBigFileName  'u
-^$HOME/.mmh/profile~^The user profile
-.fi
-
-.SH "PROFILE COMPONENTS"
-.fc ^ ~
-.nf
-.ta 2.4i
-.ta \w'ExtraBigProfileName  'u
-^Path:~^To determine the user's mail storage
-^Current\-Folder:~^To find the default current folder
-.fi
-
-.SH "SEE ALSO"
-show(1), next(1), mhshow(1)
-
-.SH DEFAULTS
-.nf
-.RB ` +folder "' defaults to the current folder"
-.RB ` \-checkmime '
-.RB ` \-header '
-.fi
-
-.SH CONTEXT
-If a folder is specified, it will become the current folder.  The message
-that is shown (i.e., the previous message in sequence) will become the
-current message.
-
-.SH BUGS
-.B prev
-is really a link to the
-.B show
-program.  As a result, if
-you make a link to
-.B prev
-and that link is not called
-.BR prev ,
-your link will act like
-.B show
-instead.  To circumvent this, add a
-profile\-entry for the link to your
-.B nmh
-profile and add the argument
-.B prev
-to the entry.
+.so man1/show.1
index 09e3f40..a61fc37 100644 (file)
@@ -10,8 +10,6 @@ send \- send a message
 .B send
 .RB [ \-alias
 .IR aliasfile ]
-.RB [ \-forward " | " \-noforward ]
-.RB [ \-push " | " \-nopush ]
 .RB [ \-verbose " | " \-noverbose ]
 .RB [ \-watch " | " \-nowatch ]
 .RB [ msg
@@ -70,26 +68,6 @@ Content-Disposition: attachment; filename="VERSION"
 .fi
 .PP
 If
-.B \-push
-is specified,
-.B send
-will detach itself from the user's
-terminal and perform its actions in the background.  If
-.BR push 'd
-and the draft can't be sent, then an error message will be sent (using
-.BR mhmail )
-back to the user.  If
-.B \-forward
-is given, then a copy
-of the draft will be attached to this failure notice.  Using
-.B \-push
-differs from putting
-.B send
-in the background because the output is
-trapped and analyzed by
-.BR nmh .
-.PP
-If
 .B \-verbose
 is specified,
 .B send
@@ -211,8 +189,6 @@ comp(1), dist(1), forw(1), repl(1), mh\-alias(5), spost(8)
 .SH DEFAULTS
 .nf
 .RB ` msg "' defaults to the current message in the draft folder"
-.RB ` \-forward '
-.RB ` \-nopush '
 .RB ` \-noverbose '
 .RB ` \-nowatch '
 .fi
index 047baf5..b467122 100644 (file)
@@ -4,6 +4,10 @@
 .TH SHOW %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
 show \- show (display) messages
+.PP
+next \- show the next message
+.PP
+prev \- show the previous message
 .SH SYNOPSIS
 .HP 5
 .na
@@ -22,11 +26,29 @@ or
 .IR showmimeproc ]
 .RB [ \-version ]
 .RB [ \-help ]
+.PP
+.HP 5
+.B next
+is equivalent to
+.B show n
+.PP
+.HP 5
+.B prev
+is equivalent to
+.B show p
 .ad
+
 .SH DESCRIPTION
 .B Show
 lists each of the specified messages to the standard output
 (typically, the terminal).
+.B Next
+and
+.B prev
+perform a
+.B show
+on the next or previous message in the specified
+(or current) folder, respectively.
 .PP
 By default, text (non-MIME) messages are filtered and displayed by
 the
@@ -52,8 +74,7 @@ will cause the
 .B more
 program to list the messages with no reformatting.
 .PP
-By default, non-text messages (MIME messages with multi-media
-contents) are processed and displayed by the
+By default, MIME messages are processed and displayed by the
 .B nmh
 command
 .BR mhshow .
@@ -70,31 +91,18 @@ default, use the
 .I program
 switch.
 .PP
-Note that in some cases,
+Note that,
 .B show
-may invoke the
+will invoke the
 .I showmimeproc
-even for textual contents.  This will happen for text messages that
-specify a transfer encoding (such as MIME quoted-printable or
-base64) or specify a character set that
-.B show
-doesn't believe
-can be displayed natively.  The environment variable
-.B $MM_CHARSET
-should be set to the terminal's native character set to avoid
-gratuitous invocations of the
-.IR showmimeproc .
-See the
-.BR mh-profile (5)
-man page for details about this environment variable.
+even for textual contents if the message has a MIME-Version header.
 .PP
 The option
 .B \-checkmime
 (set by default) instructs
 .B show
-to
-test if any of the messages to be displayed are non-text (MIME)
-messages.  If any are non-text, they are displayed by the
+to check if any of the messages contains a MIME-Version header.
+If so, they are displayed by the
 .IR showmimeproc ,
 else they are displayed by the
 .BR showproc .
@@ -105,7 +113,7 @@ disables this test and instructs
 to use
 .IR showproc ,
 regardless of whether
-any of the messages are non-text (MIME) messages.
+any of the messages are MIME messages.
 .PP
 The
 .B \-header
@@ -115,18 +123,10 @@ to display a one\-line
 description of the message being shown.  This description includes
 the folder and the message number.
 .PP
-If no `msgs' are specified, the current message is used.  Although
-it depends on the specific
-.I showproc
-or
-.IR showmimeproc ,
-in the default setup when more than one message is specified, you
-will be prompted for a <RETURN> prior to listing each message.
-Each message will be listed a page at a time, and when the end of
-page is reached, the program will wait for a <SPACE> or <RETURN>.
-If a <RETURN> is entered, it will print the next line, whereas
-<SPACE> will print the next screenful.
+If no `msgs' are specified, the current message is used.
 .PP
+If the standard output is a terminal, output will be piped through
+a pager.
 If the standard output is not a terminal, no queries are made, and
 each file is listed with a one\-line header and two lines of
 separation.
@@ -155,7 +155,7 @@ from each sequence named by the profile entry.
 .fi
 
 .SH "SEE ALSO"
-mhl(1), mhshow(1), more(1), next(1), prev(1), scan(1)
+mhl(1), mhshow(1), more(1), scan(1)
 
 .SH DEFAULTS
 .nf
@@ -224,3 +224,28 @@ For users of
 .RS 5
 show 2>&1 | imprint &
 .RE
+.PP
+.B Next
+and
+.B prev
+are really links to the
+.B show
+program.  As a result, if
+you make a link to
+.B next
+or
+.B prev
+and that link is not called
+.B next
+or
+.BR prev ,
+your link will act like
+.B show
+instead.  To circumvent this, add a
+profile\-entry for the link to your
+.B nmh
+profile and add the argument
+.I n
+or
+.I p
+to the entry.
index 00f1d7b..1e0429d 100644 (file)
@@ -13,7 +13,6 @@ spost \- feed a message to sendmail
 .IR aliasfile
 .RB " | " \-noalias ]
 .RB [ \-dist ]
-.RB [ \-push " | " \-nopush ]
 .RB [ \-verbose " | " \-noverbose ]
 .RB [ \-watch " | " \-nowatch ]
 .I file
@@ -122,8 +121,7 @@ does
 consult the user's profile.
 
 .SH "SEE ALSO"
-mhmail(1), send(1), mh\-mail(5), mh\-alias(5), mh\-tailor(5),
-refile(1),
+send(1), mh\-mail(5), mh\-alias(5), mh\-tailor(5), refile(1),
 .I "Standard for the Format of ARPA Internet Text Messages"
 (RFC\-822)
 
@@ -131,7 +129,6 @@ refile(1),
 .nf
 .RB ` \-noverbose '
 .RB ` \-nowatch '
-.RB ` \-nopush '
 .fi
 
 .SH CONTEXT
index 0406e45..ce6c9c2 100644 (file)
@@ -64,9 +64,6 @@ send the message
 .B send \-watch
 send the message and monitor the delivery process
 .TP \w'refilezzzzfolderz'u
-.B push
-send the message in the background
-.TP \w'refilezzzzfolderz'u
 .B quit
 preserve the draft and exit
 .TP \w'refilezzzzfolderz'u
@@ -101,17 +98,9 @@ response, any valid switch to the editor is valid.
 .PP
 For the
 .B send
-and
-.B push
-responses, any valid switch to
+response, any valid switch to
 .BR send (1)
-is valid (as
-.B push
-merely invokes
-.B send
-with the
-.B \-push
-option).
+is valid.
 .PP
 For the
 .B refile
index c7f4279..5bd6bbb 100644 (file)
@@ -575,11 +575,16 @@ void
 thisisanmbox(FILE *iob)
 {
        register int c;
-       register long pos;
        char text[10];
        register char *cp;
        register char *delimstr;
 
+       c = getc(iob); 
+       if (feof(iob)) {
+               return;
+       }
+       ungetc(c, iob);
+
        /*
        ** Figure out what the message delimitter string is for this
        ** maildrop.  (This used to be part of m_Eom but I didn't like
@@ -592,7 +597,6 @@ thisisanmbox(FILE *iob)
        ** abort.
        */
 
-       pos = ftell(iob);
        if (fread(text, sizeof(*text), 5, iob) != 5) {
                adios(NULL, "Read error");
        }
index a2e9932..ed4aca0 100644 (file)
@@ -22,8 +22,6 @@
 #include <time.h>
 
 int debugsw = 0;  /* global */
-int forwsw  = 1;
-int pushsw  = 0;
 int verbsw  = 0;
 char *altmsg   = NULL;
 char *annotext = NULL;
@@ -46,8 +44,6 @@ static FILE *composition_file;  /* composition file pointer */
 */
 static int sendsbr(char **, int, char *, struct stat *, int);
 static void armed_done(int) NORETURN;
-static void alert(char *, int);
-static int tmp_fd(void);
 static void anno(struct stat *);
 static int sendaux(char **, int, char *, struct stat *);
 static int attach(char *);
@@ -61,25 +57,17 @@ static struct swit switches[] = {
        { "alias aliasfile", 0 },
 #define DEBUGSW  1
        { "debug", -5 },
-#define FORWSW  2
-       { "forward", 0 },
-#define NFORWSW  3
-       { "noforward", 0 },
-#define PUSHSW  4
-       { "push", 0 },
-#define NPUSHSW  5
-       { "nopush", 0 },
-#define VERBSW  6
+#define VERBSW  2
        { "verbose", 0 },
-#define NVERBSW  7
+#define NVERBSW  3
        { "noverbose", 0 },
-#define WATCSW  8
+#define WATCSW  4
        { "watch", 0 },
-#define NWATCSW  9
+#define NWATCSW  5
        { "nowatch", 0 },
-#define VERSIONSW  10
+#define VERSIONSW  6
        { "version", 0 },
-#define HELPSW  11
+#define HELPSW  7
        { "help", 0 },
        { NULL, 0 }
 };
@@ -134,20 +122,6 @@ main(int argc, char **argv)
                                print_version(invo_name);
                                done(1);
 
-                       case PUSHSW:
-                               pushsw++;
-                               continue;
-                       case NPUSHSW:
-                               pushsw = 0;
-                               continue;
-
-                       case FORWSW:
-                               forwsw++;
-                               continue;
-                       case NFORWSW:
-                               forwsw = 0;
-                               continue;
-
                        case VERBSW:
                                verbsw++;
                                vec[vecp++] = --cp;
@@ -267,36 +241,6 @@ main(int argc, char **argv)
                st.st_dev = 0;
                st.st_ino = 0;
        }
-       if (pushsw) {
-               /* push a fork into the background */
-               pid_t pid;
-
-               switch (pid = fork()) {
-               case -1:
-                       /* fork error */
-                       advise(NULL, "unable to fork, so can't push...");
-                       break;
-
-               default:
-                       /* parent, just exit */
-                       done(0);
-
-               case 0:
-                       /* child, block a few signals and continue */
-                       SIGNAL(SIGHUP, SIG_IGN);
-                       SIGNAL(SIGINT, SIG_IGN);
-                       SIGNAL(SIGQUIT, SIG_IGN);
-                       SIGNAL(SIGTERM, SIG_IGN);
-#ifdef SIGTSTP
-                       SIGNAL(SIGTSTP, SIG_IGN);
-                       SIGNAL(SIGTTIN, SIG_IGN);
-                       SIGNAL(SIGTTOU, SIG_IGN);
-#endif
-                       freopen("/dev/null", "r", stdin);
-                       freopen("/dev/null", "w", stdout);
-                       break;
-               }
-       }
        status = 0;
        vec[0] = "spost";
        for (n=3; n<OPEN_MAX; n++) {
@@ -641,15 +585,9 @@ static int
 sendaux(char **vec, int vecp, char *drft, struct stat *st)
 {
        pid_t child_id;
-       int status, fd;
+       int status;
        char backup[BUFSIZ];
 
-       /*
-       ** fd collects the output of spost, and is used for the
-       ** failure notice if we need to send one in alert().
-       */
-       fd = pushsw ? tmp_fd() : NOTOK;
-
        vec[vecp++] = drft;
        if (distfile && distout(drft, distfile, backup) == NOTOK) {
                done(1);
@@ -663,17 +601,7 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                break;  /* NOT REACHED */
 
        case 0:
-               /*
-               ** child process -- send it
-               **
-               ** If fd is ok, then we are pushing and fd points to temp
-               ** file, so capture anything on stdout and stderr there.
-               */
-               if (fd != NOTOK) {
-                       dup2(fd, fileno(stdout));
-                       dup2(fd, fileno(stderr));
-                       close(fd);
-               }
+               /* child process -- send it */
                execvp(*vec, vec);
                fprintf(stderr, "unable to exec ");
                perror(*vec);
@@ -687,17 +615,8 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                                anno(st);
                        }
                } else {
-                       /*
-                       ** If spost failed, and we have good fd (which
-                       ** means we pushed), then mail error message
-                       ** (and possibly the draft) back to the user.
-                       */
-                       if (fd != NOTOK) {
-                               alert(drft, fd);
-                               close(fd);
-                       } else {
-                               advise(NULL, "message not delivered to anyone");
-                       }
+                       /* spost failed */
+                       advise(NULL, "message not delivered to anyone");
                        if (distfile) {
                                unlink(drft);
                                if (rename(backup, drft) == NOTOK) {
@@ -713,86 +632,6 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
 }
 
 
-/*
-** Mail error notification (and possibly a copy of the
-** message) back to the user, using mhmail(1).
-*/
-static void
-alert(char *file, int out)
-{
-       pid_t child_id;
-       int in;
-       char buf[BUFSIZ];
-
-       switch (child_id = fork()) {
-       case NOTOK:
-               /* oops -- fork error */
-               advise("fork", "unable to");
-
-       case OK:
-               /* child process -- send it */
-               SIGNAL(SIGHUP, SIG_IGN);
-               SIGNAL(SIGINT, SIG_IGN);
-               SIGNAL(SIGQUIT, SIG_IGN);
-               SIGNAL(SIGTERM, SIG_IGN);
-               if (forwsw) {
-                       if ((in = open(file, O_RDONLY)) == NOTOK) {
-                               admonish(file, "unable to re-open");
-                       } else {
-                               lseek(out, (off_t) 0, SEEK_END);
-                               strncpy(buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
-                               write(out, buf, strlen(buf));
-                               strncpy(buf, "\n------- Unsent Draft\n\n", sizeof(buf));
-                               write(out, buf, strlen(buf));
-                               cpydgst(in, out, file, "temporary file");
-                               close(in);
-                               strncpy(buf, "\n------- End of Unsent Draft\n", sizeof(buf));
-                               write(out, buf, strlen(buf));
-                               if (rename(file, strncpy(buf, m_backup(file), sizeof(buf))) == NOTOK) {
-                                       admonish(buf, "unable to rename %s to", file);
-                               }
-                       }
-               }
-               lseek(out, (off_t) 0, SEEK_SET);
-               dup2(out, fileno(stdin));
-               close(out);
-               /* create subject for error notification */
-               snprintf(buf, sizeof(buf), "send failed on %s",
-                               forwsw ? "enclosed draft" : file);
-               execlp("mhmail", "mhmail", getusername(),
-                               "-subject", buf, NULL);
-               fprintf(stderr, "unable to exec ");
-               perror("mhmail");
-               _exit(-1);
-
-       default:  /* no waiting... */
-               break;
-       }
-}
-
-
-static int
-tmp_fd(void)
-{
-       int fd;
-       char *tfile = NULL;
-
-       tfile = m_mktemp2(NULL, invo_name, &fd, NULL);
-       if (tfile == NULL) return NOTOK;
-       fchmod(fd, 0600);
-
-       if (debugsw) {
-               advise(NULL, "temporary file %s selected", tfile);
-       } else {
-               if (unlink(tfile) == NOTOK) {
-                       advise(tfile, "unable to remove");
-               }
-       }
-
-       return fd;
-}
-
-
 static void
 anno(struct stat *st)
 {
index a0178fe..34fa826 100644 (file)
@@ -37,7 +37,7 @@ static struct swit switches[] = {
 /*
 ** static prototypes
 */
-static int is_nontext(char *);
+static int is_mime(char *);
 
 #define SHOW  0
 #define NEXT  1
@@ -228,22 +228,22 @@ go_to_it: ;
        /* check if any messages are non-text MIME messages */
        if (checkmime) {
                if (file) {
-                       /* check the file for MIME */
-                       if (is_nontext(vec[vecp - 1])) {
+                       if (is_mime(vec[vecp - 1])) {
                                mime = 1;
                        }
                } else {
-                       /*
-                       ** loop through selected messages
-                       ** and check for MIME
-                       */
                        for (msgnum = mp->lowsel; msgnum <= mp->hghsel;
-                                       msgnum++)
-                               if (is_selected(mp, msgnum) &&
-                                               is_nontext(m_name(msgnum))) {
+                                       msgnum++) {
+                               if (!is_selected(mp, msgnum)) {
+                                       continue;
+                               }
+                               snprintf(buf, sizeof buf, "%s/%d",
+                                               toabsdir(folder), msgnum);
+                               if (is_mime(buf)) {
                                        mime = 1;
                                        break;
                                }
+                       }
                }
        }
 
@@ -279,174 +279,38 @@ go_to_it: ;
 }
 
 /*
-** Check if a message or file contains any non-text parts
+** Check if a message or file contains MIME.
 */
 static int
-is_nontext(char *msgnam)
+is_mime(char *msgnam)
 {
-       int result, state;
-       unsigned char *bp, *dp;
-       char *cp;
+       int state = FLD;
        char buf[BUFSIZ], name[NAMESZ];
        FILE *fp;
 
        if ((fp = fopen(msgnam, "r")) == NULL)
                return 0;
 
-       for (state = FLD;;) {
+       while (1) {
                switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
                case FLD:
                case FLDPLUS:
                case FLDEOF:
-                       /*
-                       ** Check Content-Type field
-                       */
-                       if (!mh_strcasecmp(name, TYPE_FIELD)) {
-                               int passno = 1;
-                               char c;
-
-                               cp = getcpy(buf);
-                               while (state == FLDPLUS) {
-                                       state = m_getfld(state, name, buf,
-                                                       sizeof(buf), fp);
-                                       cp = add(buf, cp);
-                               }
-                               bp = cp;
-
-again:
-                               for (; isspace(*bp); bp++)
-                                       continue;
-                               if (*bp == '(') {
-                                       int i;
-
-                                       for (bp++, i = 0;;) {
-                                               switch (*bp++) {
-                                               case '\0':
-invalid:
-                                                       result = 0;
-                                                       goto out;
-                                               case '\\':
-                                                       if (*bp++ == '\0')
-                                                               goto invalid;
-                                                       continue;
-                                               case '(':
-                                                       i++;
-                                                       /* and fall... */
-                                               default:
-                                                       continue;
-                                               case ')':
-                                                       if (--i < 0)
-                                                               break;
-                                                       continue;
-                                               }
-                                               break;
-                                       }
-                               }
-                               if (passno == 2) {
-                                       if (*bp != '/')
-                                               goto invalid;
-                                       bp++;
-                                       passno = 3;
-                                       goto again;
-                               }
-                               for (dp = bp; istoken(*dp); dp++)
-                                       continue;
-                               c = *dp;
-                               *dp = '\0';
-                               if (!*bp)
-                                       goto invalid;
-                               if (passno == 1) {
-                                       if (!(result = (mh_strcasecmp(bp, "text") != 0))) {
-                                               *dp = c;
-                                               bp = dp;
-                                               passno = 2;
-                                               goto again;
-                                       }
-                               } else {
-                                       if ((result = (mh_strcasecmp(bp,
-                                                       "plain") != 0)))
-                                               goto out;
-                                       *dp = c;
-                                       for (dp++; isspace(*dp); dp++)
-                                               continue;
-                                       if (*dp) {
-                                               if ((result = !uprf(dp,
-                                                               "charset")))
-                                                       goto out;
-                                               dp += sizeof("charset") - 1;
-                                               while (isspace(*dp))
-                                                       dp++;
-                                               if (*dp++ != '=')
-                                                       goto invalid;
-                                               while (isspace(*dp))
-                                                       dp++;
-                                               if (*dp == '"') {
-                                                       if ((bp = strchr(++dp, '"')))
-                                                               *bp = '\0';
-                                               } else {
-                                                       for (bp = dp; *bp; bp++)
-                                                               if (!istoken(*bp)) {
-                                                                       *bp = '\0';
-                                                                       break;
-                                                               }
-                                               }
-                                       } else {
-                                               /* Default character set */
-                                               dp = "US-ASCII";
-                                       }
-                                       /* Check the character set */
-                                       result = !check_charset(dp, strlen(dp));
-                               }
-out:
-                               free(cp);
-                               if (result) {
-                                       fclose(fp);
-                                       return result;
-                               }
-                               break;
+                       /* Does it have a Mime-Version header? */
+                       if (mh_strcasecmp(name, VRSN_FIELD)==0) {
+                               fclose(fp);
+                               return 1;
                        }
 
-                       /*
-                       ** Check Content-Transfer-Encoding field
-                       */
-                       if (!mh_strcasecmp(name, ENCODING_FIELD)) {
-                               cp = getcpy(buf);
-                               while (state == FLDPLUS) {
-                                       state = m_getfld(state, name, buf,
-                                                       sizeof(buf), fp);
-                                       cp = add(buf, cp);
-                               }
-                               for (bp = cp; isspace(*bp); bp++)
-                                       continue;
-                               for (dp = bp; istoken(*dp); dp++)
-                                       continue;
-                               *dp = '\0';
-                               result = (mh_strcasecmp(bp, "7bit")
-                                          && mh_strcasecmp(bp, "8bit")
-                                          && mh_strcasecmp(bp, "binary"));
-
-                               free(cp);
-                               if (result) {
-                                       fclose(fp);
-                                       return result;
-                               }
-                               break;
-                       }
-
-                       /*
-                       ** Just skip the rest of this header
-                       ** field and go to next one.
-                       */
-                       while (state == FLDPLUS)
+                       /* else skip the rest of this header field and go on */
+                       while (state == FLDPLUS) {
                                state = m_getfld(state, name, buf, sizeof(buf),
                                                fp);
+                       }
                        break;
 
-                       /*
-                       ** We've passed the message header,
-                       ** so message is just text.
-                       */
                default:
+                       /* We've passed the header, so message is just text */
                        fclose(fp);
                        return 0;
                }
index 369f03e..093bad5 100644 (file)
@@ -40,11 +40,7 @@ struct swit switches[] = {
        { "debug", -5 },
 #define DISTSW  9
        { "dist", -4 },  /* interface from dist */
-#define PUSHSW  10  /* fork to sendmail then exit */
-       { "push", -4 },
-#define NPUSHSW  11  /* exec sendmail */
-       { "nopush", -6 },
-#define LIBSW  12
+#define LIBSW  10
        { "library directory", -7 },
        { NULL, 0 }
 };
@@ -113,7 +109,6 @@ static int badmsg = 0;  /* message has bad semantics */
 static int verbose = 0;  /* spell it out */
 static int debug = 0;  /* debugging post */
 static int watch = 0;  /* watch the delivery process */
-static int pushflg = 0;  /* if going to fork to sendmail */
 static int aliasflg = 0;  /* if going to process aliases */
 
 static unsigned msgflags = 0;  /* what we've seen */
@@ -205,13 +200,6 @@ main(int argc, char **argv)
                                watch = 0;
                                continue;
 
-                       case PUSHSW:
-                               pushflg++;
-                               continue;
-                       case NPUSHSW:
-                               pushflg = 0;
-                               continue;
-
                        case ALIASW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(NULL, "missing argument to %s",
@@ -319,7 +307,6 @@ main(int argc, char **argv)
        *argp++ = "-i";  /* don't stop on "." */
        if (watch || verbose) {
                *argp++ = "-v";
-               pushflg = 0;
        }
        *argp = NULL;
 
@@ -341,21 +328,6 @@ main(int argc, char **argv)
        }
        unlink(tmpfil);
 
-       if (pushflg) {
-               /* fork to a child to run sendmail */
-               switch (fork()) {
-               case NOTOK:
-                       fprintf(verbose ? stdout : stderr,
-                                       "%s: can't fork to %s\n",
-                                       invo_name, sendmail);
-                       exit(-1);
-               case OK:
-                       /* we're the child .. */
-                       break;
-               default:
-                       exit(0);
-               }
-       }
        execv(sendmail, sargv);
        adios(sendmail, "can't exec");
        return -1;
@@ -694,8 +666,7 @@ process_bccs(char *origmsg)
                fprintf(out, "------------\n");
                fclose(out);
 
-               snprintf(buf, sizeof buf, "send%s %s",
-                               pushflg ? " -push" : "", bccdraft);
+               snprintf(buf, sizeof buf, "send %s", bccdraft);
                if (system(buf) != 0) {
                        admonish(invo_name, "Problems to send Bcc to %s",
                                        mp->m_text);
index 0576ff8..efdf02d 100644 (file)
@@ -70,23 +70,21 @@ static struct swit aleqs[] = {
        { "list", 0 },
 #define SENDSW  4
        { "send [<switches>]", 0 },
-#define PUSHSW  5
-       { "push [<switches>]", 0 },
-#define QUITSW  6
+#define QUITSW  5
        { "quit", 0 },
-#define DELETESW  7
+#define DELETESW  6
        { "delete", 0 },
-#define CDCMDSW  8
+#define CDCMDSW  7
        { "cd [directory]", 0 },
-#define PWDCMDSW  9
+#define PWDCMDSW  8
        { "pwd", 0 },
-#define LSCMDSW  10
+#define LSCMDSW  9
        { "ls", 0 },
-#define ATTACHCMDSW  11
+#define ATTACHCMDSW  10
        { "attach", 0 },
-#define DETACHCMDSW  12
+#define DETACHCMDSW  11
        { "detach [-n]", 0 },
-#define ALISTCMDSW  13
+#define ALISTCMDSW  12
        { "alist", 0 },
        { NULL, 0 }
 };
@@ -98,7 +96,7 @@ static char *myprompt = "\nWhat now? ";
 */
 static int editfile(char **, char **, char *, int, struct msgs *,
        char *, char *, int);
-static int sendfile(char **, char *, int);
+static int sendfile(char **, char *);
 static int refile(char **, char *);
 static int removefile(char *);
 static void writelscmd(char *, int, char **);
@@ -253,15 +251,9 @@ main(int argc, char **argv)
                        removefile(drft);
                        done(1);
 
-               case PUSHSW:
-                       /* Send draft in background */
-                       if (sendfile(++argp, drft, 1))
-                               done(1);
-                       break;
-
                case SENDSW:
                        /* Send draft */
-                       sendfile(++argp, drft, 0);
+                       sendfile(++argp, drft);
                        break;
 
                case REFILEOPT:
@@ -752,7 +744,7 @@ copyf(char *ifile, char *ofile)
 */
 
 static int
-sendfile(char **arg, char *file, int pushsw)
+sendfile(char **arg, char *file)
 {
        pid_t child_id;
        int vecp;
@@ -768,8 +760,6 @@ sendfile(char **arg, char *file, int pushsw)
        case OK:
                vecp = 0;
                vec[vecp++] = invo_name;
-               if (pushsw)
-                       vec[vecp++] = "-push";
                if (arg)
                        while (*arg)
                                vec[vecp++] = *arg++;