copymt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 2.1 */
/*
NAME
copymt - copy mail (f1) to temp (f2)
SYNOPSIS
void copymt(FILE *f1, FILE *f2)
DESCRIPTION
the temp file. The file pointers f1 and f2 point
to the files, respectively.
*/
#include "mail.h"
{
static char pn[] = "copymt";
long nextadr;
int n, newline = 1;
int StartNewMsg = TRUE;
int mesg = 0;
long clen = (long)0;
int hdr = 0;
int cflg = 0; /* found Content-length in header */
} else {
}
if (!newline) {
goto putout;
}
if (clen < n) { /* read too much */
/* NB: this only can happen if the content-length
* says a smaller number than what's seen on the
* first non-header line.
*/
nlet-1,
}
"Write error in copymt()");
done(0);
}
n -= clen;
cflg = 0;
goto dohdr;
}
/* here, clen >= n */
clen++; /* cheat */
}
for (;;) {
nlet-1,
}
"Write error in copymt()");
done(0);
}
clen -= n;
if (clen <= 0) {
break;
}
"%c%s:\tYour mailfile was found to be corrupted.\n",
"\t(Unexpected end-of-file).\n");
"\tMessage #%d may be truncated.%c\n\n",
clen = 0; /* stop the loop */
}
}
/* All done, go to top for next message */
cflg = 0;
StartNewMsg = TRUE;
continue;
}
switch (hdr) {
case H_FROM:
if (!mesg) {
mesg++;
}
} else {
}
StartNewMsg = FALSE;
break;
case H_CLEN:
if (cflg) {
break;
}
break;
default:
break;
}
if (nlet == 0) {
done(0);
}
nextadr += n;
}
done(0);
}
newline = 1;
if (n == 1) { /* Blank line. Skip StartNewMsg */
/* check below */
continue;
}
} else {
newline = 0;
}
"%c%s:\tYour mailfile was found to be corrupted\n",
nlet);
"\twith another message concatenated to it.%c\n\n",
BELL);
}
}
/*
last plus 1
*/
}