static struct format *fmt;
static struct comp *datecomp; /* pntr to "date" comp */
-static struct comp *bodycomp; /* pntr to "body" pseudo-comp (if referenced) */
static int ncomps = 0; /* # of interesting components */
static char **compbuffers = NULL; /* buffers for component text */
static struct comp **used_buf = NULL; /* stack for comp that use buffers */
int i, compnum, state;
unsigned char *cp, *tmpbuf;
char **nxtbuf;
- char *saved_c_text = NULL;
struct comp *cptr;
struct comp **savecomp;
char *scnmsg = NULL;
FILE *scnout = NULL;
char name[NAMESZ];
- static int rlwidth, slwidth;
+ static int slwidth;
char returnpath[BUFSIZ];
char deliverydate[BUFSIZ];
int incing = (outnum > 0);
/* Compile format string */
ncomps = fmt_compile(fmtstr, &fmt) + 1;
- FINDCOMP(bodycomp, "body");
FINDCOMP(datecomp, "date");
nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
sizeof(char *));
if (used_buf == NULL)
adios(NULL, "unable to allocate component buffer stack");
used_buf += ncomps+1; *--used_buf = 0;
- rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ;
for (i = ncomps; i--; )
- *nxtbuf++ = mh_xmalloc(rlwidth);
+ *nxtbuf++ = mh_xmalloc(SBUFSIZ);
}
/*
** Get the first field. If the message is non-empty
** and we're doing an "inc", open the output file.
*/
- if ((state = m_getfld(FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) {
+ if ((state = m_getfld(FLD, name, tmpbuf, SBUFSIZ, inb)) == FILEEOF) {
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
return SCNFAT;
/* scan - main loop */
for (compnum = 1; ;
- state = m_getfld(state, name, tmpbuf, rlwidth, inb)) {
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb)) {
switch (state) {
case FLD:
case FLDPLUS:
}
while (state == FLDPLUS) {
- state = m_getfld(state, name, tmpbuf, rlwidth,
+ state = m_getfld(state, name, tmpbuf, SBUFSIZ,
inb);
if (incing)
FPUTS(tmpbuf);
return SCNFAT;
}
- /* Save and restore buffer so we don't trash our dynamic pool! */
- if (bodycomp) {
- saved_c_text = bodycomp->c_text;
- bodycomp->c_text = tmpbuf;
- }
-
if (incing) {
if ((dat[2] = ftell(scnout)) == EOF)
adios(scnmsg, "write error on");
if (fmtstr)
fputs(scanl, stdout);
- if (bodycomp)
- bodycomp->c_text = saved_c_text;
-
/* return dynamically allocated buffers to pool */
while ((cptr = *savecomp++)) {
*--nxtbuf = cptr->c_text;