home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.eterna.com.au
/
2014.06.ftp.eterna.com.au.tar
/
ftp.eterna.com.au
/
netbsd
/
mh-6.8.3-diff
< prev
next >
Wrap
Text File
|
1996-03-18
|
5KB
|
174 lines
These diffs to MH 6.8.3 fix two problems: the define of si_value in one
of the system .h files makes the compiler bail out on mhn.
The second is an added feature ``CONTENT_LENGTH''. All changes related
to this feature are isolated with #ifdef CONTENT_LENGTH. If you wish
to use this feature, you have to add ``options CONTENT_LENGTH''
to your MH config file.
This additional feature will try to use the Content-Length: header generated
by the SVR4 mail deliverer. This Header gives the length in bytes of the
of an e-mail message, minus the headers and the line seperating header
and body. This feature is used to do out-of-band message boundary
detection, making escaping "From " lines unnecessary.
Casper
*** mh-6.8.3/uip/mhn.c.org Wed Dec 1 05:01:36 1993
--- mh-6.8.3/uip/mhn.c Fri Jun 3 12:38:04 1994
***************
*** 1014,1019 ****
--- 1014,1020 ----
#include "../h/mhn.h"
+ #undef si_value
struct str2init {
char *si_key;
int si_value;
*** mh-6.8.3/sbr/m_getfld.c.org Wed Dec 1 05:01:24 1993
--- mh-6.8.3/sbr/m_getfld.c Tue Jun 7 10:54:14 1994
***************
*** 169,174 ****
--- 169,179 ----
static unsigned char *edelim;
static int edelimlen;
+ #ifdef CONTENT_LENGTH
+ static int content_length = -1;
+ static long end_of_contents = -1;
+ #endif
+
static int (*eom_action) () = NULL;
#ifdef _FSTDIO
***************
*** 195,200 ****
--- 200,216 ----
register int i;
register int j;
+ #ifdef CONTENT_LENGTH
+ /*
+ * When starting to read from a new file, we have to reset the state,
+ * but only if the state wasn't reset. That may save us a number of
+ * lseeks.
+ */
+ if (state == FLD &&
+ (content_length != -1 || end_of_contents != -1) &&
+ ftell(iob) == 0)
+ end_of_contents = content_length = -1;
+ #endif
if ((c = Getc(iob)) < 0) {
msg_count = 0;
*buf = 0;
***************
*** 222,227 ****
--- 238,276 ----
while (c != '\n' && (c = Getc(iob)) >= 0)
;
+ #ifdef CONTENT_LENGTH
+ /*
+ * When we've found a content-length header, we're
+ * going to use it to tell where the message boundary
+ * is, if it is a valid mesage boundary.
+ * There can be a number of cases:
+ * - no bytes after <content-length> bytes: the usual format
+ * of a message in an MH folder.
+ * - only a newline - last message in mail drop.
+ * - "\nFrom " - beginning of next message
+ * - other - ignore Content-Length header, but issue warning
+ */
+ if (content_length != -1) {
+ long here = ftell(iob);
+ static char delim[] = "\nFrom ";
+ char buf[sizeof(delim)-1];
+ int cnt;
+
+ /* compute position of character after file */
+ end_of_contents = here + content_length + 1;
+ content_length = -1;
+ /* And see whether this is a From header or eof. */
+ fseek(iob, end_of_contents - 1, 0);
+ cnt = fread(buf, sizeof(char), sizeof(buf), iob);
+ if (cnt != 0 && (cnt != 1 || buf[0] != '\n') &&
+ (cnt != sizeof(buf) ||
+ strncmp(buf,delim, sizeof(buf)) != 0)) {
+ advise (NULLCP, "invalid Content-Length: header\n");
+ end_of_contents = -1;
+ }
+ fseek(iob, here, 0);
+ }
+ #endif
if (c < 0 || (c = Getc(iob)) < 0 || eom (c, iob)) {
if (! eom_action) {
/* flush null messages */
***************
*** 425,430 ****
--- 474,489 ----
finish:;
*cp = 0;
msg_count = cp - buf;
+
+ #ifdef CONTENT_LENGTH
+ /* Check whether this was a Content-Length header */
+ if (state == FLD &&
+ strcasecmp((char*)"content-length", (char*) name) == 0) {
+ content_length = atoi(buf);
+ /* This value is computed when end-of-headers is detected */
+ end_of_contents = -1;
+ }
+ #endif
return (state);
}
***************
*** 544,549 ****
--- 603,626 ----
#endif /* RPATHS */
pos = ftell (iob);
+
+ #ifdef CONTENT_LENGTH
+ if (end_of_contents != -1) {
+ if (end_of_contents == pos) {
+ end_of_contents = -1;
+ return 1;
+ }
+ /* we've read past the end of a message, this should never happen
+ * because of the other checks we do */
+ if (end_of_contents < pos) {
+ end_of_contents = -1;
+ adios(NULLCP,
+ "Content-Length: header broken, can't read mailbox\n");
+ }
+ return 0;
+ }
+ #endif
+
if ((i = fread (text, sizeof *text, edelimlen, iob)) != edelimlen
|| strncmp (text, (char *)edelim, edelimlen)) {
if (i == 0 && msg_style == MS_UUCP)
***************
*** 560,565 ****
--- 637,654 ----
#endif /* !notdef */
return 0;
}
+
+ #ifdef CONTENT_LENGTH
+ /* There's one extra special case to be considered here:
+ * content_length > 0. That we got here is because the
+ * message body starts with "From "
+ */
+ if (content_length > 0) {
+ (void) fseek (iob, (long)(pos-1), 0);
+ (void) getc (iob); /* should be OK */
+ return 0;
+ }
+ #endif
if (msg_style == MS_UUCP) {
#ifndef RPATHS