This allowed removal of the msg_count global, in turn allowing
removal of sbr/m_msgdef.c
27 files changed:
sbr/showfile.c sbr/signals.c sbr/smatch.c \
sbr/snprintb.c sbr/ssequal.c sbr/strcasecmp.c \
sbr/strindex.c sbr/trimcpy.c sbr/uprf.c sbr/vfgets.c \
sbr/showfile.c sbr/signals.c sbr/smatch.c \
sbr/snprintb.c sbr/ssequal.c sbr/strcasecmp.c \
sbr/strindex.c sbr/trimcpy.c sbr/uprf.c sbr/vfgets.c \
- sbr/fmt_def.c sbr/m_msgdef.c sbr/mf.c sbr/utils.c \
+ sbr/fmt_def.c sbr/mf.c sbr/utils.c \
sbr/m_mktemp.c sbr/getansreadline.c config/config.c \
config/version.c
sbr/m_mktemp.c sbr/getansreadline.c config/config.c \
config/version.c
#define MS_MMDF 3 /* string mmdlm2 */
#define MS_MSH 4 /* whacko msh */
#define MS_MMDF 3 /* string mmdlm2 */
#define MS_MSH 4 /* whacko msh */
-extern int msg_count; /* m_getfld() indicators */
-
#define NOUSE 0 /* draft being re-used */
#define TFOLDER 0 /* path() given a +folder */
#define NOUSE 0 /* draft being re-used */
#define TFOLDER 0 /* path() given a +folder */
int m_convert (struct msgs *, char *);
char *m_draft (char *, char *, int, int *);
void m_eomsbr (int (*)(int));
int m_convert (struct msgs *, char *);
char *m_draft (char *, char *, int, int *);
void m_eomsbr (int (*)(int));
-int m_getfld (int, unsigned char[NAMESZ], unsigned char *, int, FILE *);
+int m_getfld (int, unsigned char[NAMESZ], unsigned char *, int *, FILE *);
int m_gmprot (void);
char *m_maildir (char *);
char *m_mailpath (char *);
int m_gmprot (void);
char *m_maildir (char *);
char *m_mailpath (char *);
=======
name: header field name (array of size NAMESZ=999)
buf: either a header field body or message body
=======
name: header field name (array of size NAMESZ=999)
buf: either a header field body or message body
+bufsz: number of characters loaded into buf
(return value): message parse state on return from function
(return value): message parse state on return from function
-(global) int msg_count: number of characters loaded into buf
Functions (part of Inputs, really)
=========
Functions (part of Inputs, really)
=========
Along the way, I thought of these possible interface changes that we
might want to consider before rototilling the internals:
Along the way, I thought of these possible interface changes that we
might want to consider before rototilling the internals:
-1) To remove a global:
- Change bufsz to be in-out instead of in, and therefore int * instead of
- int, and use that instead of global msg_count. There are only 3 call
- sites that use msg_count so it wouldn't take much effort to remove use of
- it. Of course, all call sites would have to change to provide an int *
- instead of an int. Some now pass constants.
-
-2) To remove the state argument from the signature:
+1) To remove the state argument from the signature:
Given the Current usage and Restriction above, the state variable could
be removed from the signature and just retained internally.
Given the Current usage and Restriction above, the state variable could
be removed from the signature and just retained internally.
-3) To remove the Restriction above:
+2) To remove the Restriction above:
One approach would be for m_getfld() to retain multiple copies of that
state, one per iob that it sees. Another approach would be for the
caller to store it in an opaque struct, the address of which is passed
One approach would be for m_getfld() to retain multiple copies of that
state, one per iob that it sees. Another approach would be for the
caller to store it in an opaque struct, the address of which is passed
static unsigned char **pat_map;
static unsigned char **pat_map;
-/*
- * defined in sbr/m_msgdef.c = 0
- * This is a disgusting hack for "inc" so it can know how many
- * characters were stuffed in the buffer on the last call
- * (see comments in uip/scansbr.c).
- */
-extern int msg_count;
-
static int msg_style = MS_DEFAULT;
/*
static int msg_style = MS_DEFAULT;
/*
int
m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
int
m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
{
register unsigned char *bp, *cp, *ep, *sp;
register int cnt, c, i, j;
if ((c = Getc(iob)) < 0) {
{
register unsigned char *bp, *cp, *ep, *sp;
register int cnt, c, i, j;
if ((c = Getc(iob)) < 0) {
*buf = 0;
return FILEEOF;
}
*buf = 0;
return FILEEOF;
}
if (c >= 0)
ungetc(c, iob);
}
if (c >= 0)
ungetc(c, iob);
}
*buf = 0;
return FILEEOF;
}
*buf = 0;
return FILEEOF;
}
if (c >= 0)
ungetc(c, iob);
}
if (c >= 0)
ungetc(c, iob);
}
*buf = 0;
return FILEEOF;
}
*buf = 0;
return FILEEOF;
}
/* See if buf can hold this line, since we were assuming
* we had a buffer of NAMESZ, not bufsz. */
/* + 1 for the newline */
/* See if buf can hold this line, since we were assuming
* we had a buffer of NAMESZ, not bufsz. */
/* + 1 for the newline */
/* No, it can't. Oh well, guess we'll blow up. */
*cp = *buf = 0;
advise (NULL, "eol encountered in field \"%s\"", name);
/* No, it can't. Oh well, guess we'll blow up. */
*cp = *buf = 0;
advise (NULL, "eol encountered in field \"%s\"", name);
* characters up to the end of this field (newline
* followed by non-blank) or bufsz-1 characters.
*/
* characters up to the end of this field (newline
* followed by non-blank) or bufsz-1 characters.
*/
+ cp = buf; i = *bufsz-1;
for (;;) {
#ifdef LINUX_STDIO
cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
for (;;) {
#ifdef LINUX_STDIO
cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
* we assume that we were called to copy directly into
* the output buffer and we don't add an eos.
*/
* we assume that we were called to copy directly into
* the output buffer and we don't add an eos.
*/
- i = (bufsz < 0) ? -bufsz : bufsz-1;
+ i = (*bufsz < 0) ? -*bufsz : *bufsz-1;
#ifdef LINUX_STDIO
bp = (unsigned char *) --iob->_IO_read_ptr;
cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
#ifdef LINUX_STDIO
bp = (unsigned char *) --iob->_IO_read_ptr;
cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
iob->_cnt -= c;
iob->_ptr += c;
#endif
iob->_cnt -= c;
iob->_ptr += c;
#endif
- if (bufsz < 0) {
- msg_count = c;
+ if (*bufsz < 0) {
+ *bufsz = c;
return (state);
}
cp = buf + c;
return (state);
}
cp = buf + c;
+++ /dev/null
-
-/*
- * m_msgdef.c -- some defines for sbr/m_getfld.c
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
-
-#include <h/mh.h>
-
-/*
- * disgusting hack for "inc" so it can know how many characters
- * were stuffed in the buffer on the last call (see comments
- * in uip/scansbr.c)
- */
-int msg_count = 0;
- switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (state, name, field, &fieldsz, ib)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), ib);
+ fieldsz = sizeof field;
+ state = m_getfld (state, name, field, &fieldsz, ib);
cp = add (field, cp);
}
np->n_field = trimcpy (cp);
cp = add (field, cp);
}
np->n_field = trimcpy (cp);
/* Use m_getfld to scan sequence file */
for (state = FLD;;) {
/* Use m_getfld to scan sequence file */
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (state, name, field, &fieldsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), fp);
+ fieldsz = sizeof field;
+ state = m_getfld (state, name, field, &fieldsz, fp);
cp = add (field, cp);
}
seq_init (mp, getcpy (name), trimcpy (cp));
cp = add (field, cp);
}
seq_init (mp, getcpy (name), trimcpy (cp));
lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
cpydata (hdrfd, fileno (ofp), msgnam, drft);
lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
cpydata (hdrfd, fileno (ofp), msgnam, drft);
- for (state = FLD, resent = NULL;;)
- switch (state =
- m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+ for (state = FLD, resent = NULL;;) {
+ int buffersz = sizeof buffer;
+ switch (state = m_getfld (state, name, buffer, &buffersz, ifp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
resent = add (buffer, resent);
fprintf (ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
resent = add (buffer, resent);
fprintf (ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
+ buffersz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &buffersz, ifp);
resent = add (buffer, resent);
fputs (buffer, ofp);
}
resent = add (buffer, resent);
fputs (buffer, ofp);
}
default:
adios (NULL, "getfld() returned %d", state);
}
default:
adios (NULL, "getfld() returned %d", state);
}
process: ;
fclose (ifp);
fflush (ofp);
process: ;
fclose (ifp);
fflush (ofp);
adios (NULL, "no file descriptors -- you lose big");
unlink (tmpfil);
adios (NULL, "no file descriptors -- you lose big");
unlink (tmpfil);
- for (state = FLD;;)
- switch (state =
- m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+ for (state = FLD;;) {
+ int buffersz = sizeof buffer;
+ switch (state = m_getfld (state, name, buffer, &buffersz, ifp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
fprintf (ofp, "Prev-");
fprintf (ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
fprintf (ofp, "Prev-");
fprintf (ofp, "%s: %s", name, buffer);
while (state == FLDPLUS) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
+ buffersz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &buffersz, ifp);
fputs (buffer, ofp);
}
if (state == FLDEOF)
fputs (buffer, ofp);
}
if (state == FLDEOF)
unlink (tmpfil);
fprintf (ofp, "\n%s", buffer);
while (state == BODY) {
unlink (tmpfil);
fprintf (ofp, "\n%s", buffer);
while (state == BODY) {
- state = m_getfld (state, name,
- buffer, sizeof buffer, ifp);
+ buffersz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &buffersz, ifp);
fputs (buffer, ofp);
}
case FILEEOF:
fputs (buffer, ofp);
}
case FILEEOF:
default:
adios (NULL, "getfld() returned %d", state);
}
default:
adios (NULL, "getfld() returned %d", state);
}
process: ;
fclose (ifp);
fclose (ofp);
process: ;
fclose (ifp);
fclose (ofp);
- state = m_getfld(state, name, msgbuf, sizeof(msgbuf), tmp);
+ int msg_count = sizeof msgbuf;
+ state = m_getfld(state, name, msgbuf, &msg_count, tmp);
switch (state) {
case FLD:
case FLDPLUS:
switch (state) {
case FLD:
case FLDPLUS:
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
- state = m_getfld(state, name, msgbuf,
- sizeof(msgbuf), tmp);
+ msg_count = sizeof msgbuf;
+ state = m_getfld(state, name, msgbuf, &msg_count, tmp);
fmt_appendcomp(i, name, msgbuf);
char_read += msg_count;
}
}
while (state == FLDPLUS)
fmt_appendcomp(i, name, msgbuf);
char_read += msg_count;
}
}
while (state == FLDPLUS)
- state = m_getfld(state, name, msgbuf, sizeof(msgbuf), tmp);
+ msg_count = sizeof msgbuf;
+ state = m_getfld(state, name, msgbuf, &msg_count, tmp);
* the new MIME message.
*/
for (compnum = 1, state = FLD;;) {
* the new MIME message.
*/
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, in)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
/* ignore any Content-Type fields in the header */
if (!mh_strcasecmp (name, TYPE_FIELD)) {
/* ignore any Content-Type fields in the header */
if (!mh_strcasecmp (name, TYPE_FIELD)) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
+ }
/* if necessary, get rest of field */
while (state == FLDPLUS) {
/* if necessary, get rest of field */
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
vp = add (buf, vp); /* add to previous value */
}
vp = add (buf, vp); /* add to previous value */
}
for (state = FLD;;) {
int result;
char *cp, *dp;
for (state = FLD;;) {
int result;
char *cp, *dp;
+ int bufsz = sizeof buf;
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
else {
cp = add (buf, NULL);
while (state == FLDPLUS) {
else {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
bucket = fmt_addcomptext(name, buf);
for (ip = ignores; *ip; ip++)
if (!mh_strcasecmp (name, *ip)) {
while (state == FLDPLUS) {
case FLD:
case FLDPLUS:
bucket = fmt_addcomptext(name, buf);
for (ip = ignores; *ip; ip++)
if (!mh_strcasecmp (name, *ip)) {
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
fmt_appendcomp(bucket, name, buf);
}
break;
fmt_appendcomp(bucket, name, buf);
}
break;
if (c1 == NULL)
c1 = add_queue (&msghd, &msgtl, name, buf, 0);
while (state == FLDPLUS) {
if (c1 == NULL)
c1 = add_queue (&msghd, &msgtl, name, buf, 0);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
c1->c_text = add (buf, c1->c_text);
fmt_appendcomp(bucket, name, buf);
}
c1->c_text = add (buf, c1->c_text);
fmt_appendcomp(bucket, name, buf);
}
strncpy (holder.c_text, buf, sizeof(buf));
while (state == BODY) {
putcomp (c1, &holder, BODYCOMP);
strncpy (holder.c_text, buf, sizeof(buf));
while (state == BODY) {
putcomp (c1, &holder, BODYCOMP);
state = m_getfld (state, name, holder.c_text,
state = m_getfld (state, name, holder.c_text,
}
free (holder.c_text);
holder.c_text = NULL;
}
free (holder.c_text);
holder.c_text = NULL;
*/
while (state == BODY) {
*/
while (state == BODY) {
write(fdinput[1], buf, strlen(buf));
write(fdinput[1], buf, strlen(buf));
- state = m_getfld(state, name, buf, bufsz, fp);
+ state = m_getfld(state, name, buf, &bufsz2, fp);
* content into a linked list.
*/
for (compnum = 1, state = FLD;;) {
* content into a linked list.
*/
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, in)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
/* if necessary, get rest of field */
while (state == FLDPLUS) {
/* if necessary, get rest of field */
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
vp = add (buf, vp); /* add to previous value */
}
vp = add (buf, vp); /* add to previous value */
}
return Msgs[msgnum].m_bboard_id;
zp = msh_ready (msgnum, 0);
return Msgs[msgnum].m_bboard_id;
zp = msh_ready (msgnum, 0);
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof(buf), zp)) {
+ for (state = FLD;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, zp)) {
case FLD:
case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, BBoard_ID)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
case FLD:
case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, BBoard_ID)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), zp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
i = atoi (bp);
bp = add (buf, bp);
}
i = atoi (bp);
continue;
}
while (state == FLDPLUS)
continue;
}
while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), zp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, zp);
if (state != FLDEOF)
continue;
default:
return 0;
}
if (state != FLDEOF)
continue;
default:
return 0;
}
fp = msh_ready (msgnum, 1);
fp = msh_ready (msgnum, 1);
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+ for (state = FLD;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
cp = add (buf, NULL);
while (state == FLDPLUS) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
bp = cp;
cp = add (buf, cp);
}
bp = cp;
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
* Just skip the rest of this header
* field and go to next one.
*/
* Just skip the rest of this header
* field and go to next one.
*/
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
+ }
zp = msh_ready (msgnum, 0);
for (state = FLD;;) {
zp = msh_ready (msgnum, 0);
for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof buf, zp)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, zp)) {
case FLD:
case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, datesw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
case FLD:
case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (name, datesw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
if ((tw = dparsetime (bp)) == NULL)
bp = add (buf, bp);
}
if ((tw = dparsetime (bp)) == NULL)
else if (subjsw && !mh_strcasecmp(name, subjsw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
else if (subjsw && !mh_strcasecmp(name, subjsw)) {
bp = getcpy (buf);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, zp);
bp = add (buf, bp);
}
msgp->m_scanl = sosmash(subjsw, bp);
bp = add (buf, bp);
}
msgp->m_scanl = sosmash(subjsw, bp);
else
subjsw = (char *)0;/* subject done, need date */
} else {
else
subjsw = (char *)0;/* subject done, need date */
} else {
- while (state == FLDPLUS) /* flush this one */
- state = m_getfld (state, name, buf, sizeof buf, zp);
+ while (state == FLDPLUS) { /* flush this one */
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, zp);
+ }
/* copied from seq_read.c:seq_public */
for (state = FLD;;) {
/* copied from seq_read.c:seq_public */
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (state, name, field, &fieldsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
case FLD:
case FLDPLUS:
case FLDEOF:
if (state == FLDPLUS) {
cp = getcpy (field);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field,
- sizeof(field), fp);
+ fieldsz = sizeof field;
+ state = m_getfld (state, name, field, &fieldsz, fp);
fseek (fp, start, SEEK_SET);
for (state = FLD, bp = NULL;;) {
fseek (fp, start, SEEK_SET);
for (state = FLD, bp = NULL;;) {
- switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDEOF:
case FLDPLUS:
case FLD:
case FLDEOF:
case FLDPLUS:
free (bp), bp = NULL;
bp = add (buf, NULL);
while (state == FLDPLUS) {
free (bp), bp = NULL;
bp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof buf, fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
bp = add (buf, bp);
}
if (!mh_strcasecmp (name, n->n_datef))
bp = add (buf, bp);
}
if (!mh_strcasecmp (name, n->n_datef))
hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
for (compnum = 1, state = FLD;;) {
hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
compnum++;
cp = add (buf, NULL);
while (state == FLDPLUS) {
case FLD:
case FLDEOF:
case FLDPLUS:
compnum++;
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
cp = add (buf, cp);
}
putfmt (name, cp, out);
cp = add (buf, cp);
}
putfmt (name, cp, out);
break;
fprintf (out, "\n%s", buf);
while (state == BODY) {
break;
fprintf (out, "\n%s", buf);
while (state == BODY) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
fputs (buf, out);
}
break;
fputs (buf, out);
}
break;
* Loop through the lines of the draft skeleton.
*/
for (state = FLD;;) {
* Loop through the lines of the draft skeleton.
*/
for (state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (state, name, field, &fieldsz, in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
case FLD:
case FLDEOF:
case FLDPLUS:
printf ("%s:%s", name, field);
fprintf (out, "%s:%s", name, field);
while (state == FLDPLUS) {
printf ("%s:%s", name, field);
fprintf (out, "%s:%s", name, field);
while (state == FLDPLUS) {
- state =
- m_getfld (state, name, field, sizeof(field), in);
+ fieldsz = sizeof field;
+ state = m_getfld (state, name, field, &fieldsz, in);
printf ("%s", field);
fprintf (out, "%s", field);
}
printf ("%s", field);
fprintf (out, "%s", field);
}
if (!rapid && !sigint)
printf ("%s", field);
} while (state == BODY &&
if (!rapid && !sigint)
printf ("%s", field);
} while (state == BODY &&
- (state = m_getfld (state, name, field, sizeof(field), in)));
+ (fieldsz = sizeof field,
+ state = m_getfld (state, name, field, &fieldsz, in)));
if (prepend || !body)
break;
else
if (prepend || !body)
break;
else
cptr->c_text = addrs;
for (state = FLD;;) {
cptr->c_text = addrs;
for (state = FLD;;) {
- switch (state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb)) {
+ int msg_count = SBUFSIZ;
+ switch (state = m_getfld (state, name, tmpbuf, &msg_count, inb)) {
case FLD:
case FLDPLUS:
i = fmt_addcomptext(name, tmpbuf);
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
case FLD:
case FLDPLUS:
i = fmt_addcomptext(name, tmpbuf);
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ msg_count = SBUFSIZ;
+ state = m_getfld (state, name, tmpbuf, &msg_count, inb);
fmt_appendcomp(i, name, tmpbuf);
char_read += msg_count;
}
}
fmt_appendcomp(i, name, tmpbuf);
char_read += msg_count;
}
}
- while (state == FLDPLUS)
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ while (state == FLDPLUS) {
+ msg_count = SBUFSIZ;
+ state = m_getfld (state, name, tmpbuf, &msg_count, inb);
+ }
* pick any interesting stuff out of msg "inb"
*/
for (state = FLD;;) {
* pick any interesting stuff out of msg "inb"
*/
for (state = FLD;;) {
- state = m_getfld (state, name, tmpbuf, sizeof(tmpbuf), inb);
+ int msg_count = sizeof tmpbuf;
+ state = m_getfld (state, name, tmpbuf, &msg_count, inb);
switch (state) {
case FLD:
case FLDPLUS:
switch (state) {
case FLD:
case FLDPLUS:
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
if (i != -1) {
char_read += msg_count;
while (state == FLDPLUS) {
- state = m_getfld(state, name, tmpbuf,
- sizeof(tmpbuf), inb);
+ msg_count= sizeof tmpbuf;
+ state = m_getfld(state, name, tmpbuf, &msg_count, inb);
fmt_appendcomp(i, name, tmpbuf);
char_read += msg_count;
}
}
fmt_appendcomp(i, name, tmpbuf);
char_read += msg_count;
}
}
- while (state == FLDPLUS)
- state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+ while (state == FLDPLUS) {
+ msg_count= sizeof tmpbuf;
+ state = m_getfld (state, name, tmpbuf, &msg_count, inb);
+ }
char *scnmsg = NULL;
FILE *scnout = NULL;
char name[NAMESZ];
char *scnmsg = NULL;
FILE *scnout = NULL;
char name[NAMESZ];
static int rlwidth, slwidth;
static size_t scanl_size;
static int rlwidth, slwidth;
static size_t scanl_size;
* Get the first field. If the message is non-empty
* and we're doing an "inc", open the output file.
*/
* 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) {
+ bufsz = rlwidth;
+ if ((state = m_getfld (FLD, name, tmpbuf, &bufsz, inb)) == FILEEOF) {
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
return SCNFAT;
if (ferror(inb)) {
advise("read", "unable to"); /* "read error" */
return SCNFAT;
- for (compnum = 1; ; state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
+ for (compnum = 1; ;
+ bufsz = rlwidth, state = m_getfld (state, name, tmpbuf, &bufsz, inb)) {
switch (state) {
case FLD:
case FLDPLUS:
switch (state) {
case FLD:
case FLDPLUS:
}
while (state == FLDPLUS) {
}
while (state == FLDPLUS) {
- state = m_getfld (state, name, tmpbuf, rlwidth, inb);
+ bufsz = rlwidth;
+ state = m_getfld (state, name, tmpbuf, &bufsz, inb);
if (outnum)
FPUTS (tmpbuf);
}
if (outnum)
FPUTS (tmpbuf);
}
*/
if ((i = strlen(tmpbuf)) < rlwidth) {
*/
if ((i = strlen(tmpbuf)) < rlwidth) {
- state = m_getfld (state, name, tmpbuf + i,
- rlwidth - i, inb);
+ bufsz = rlwidth - i;
+ state = m_getfld (state, name, tmpbuf + i, &bufsz, inb);
}
while (state == BODY) {
}
while (state == BODY) {
- state = m_getfld(state, name, tmpbuf, rlwidth, inb);
+ bufsz = rlwidth;
+ state = m_getfld(state, name, tmpbuf, &bufsz, inb);
FPUTS(tmpbuf);
}
goto finished;
FPUTS(tmpbuf);
}
goto finished;
* as well as locate the beginning of the message body.
*/
for (compnum = 1, state = FLD;;) {
* as well as locate the beginning of the message body.
*/
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, name, buffer, sizeof(buffer), in)) {
+ int bufsz = sizeof buffer;
+ switch (state = m_getfld (state, name, buffer, &bufsz, in)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
* This header field is discarded.
*/
if (!mh_strcasecmp (name, "Message-ID")) {
* This header field is discarded.
*/
if (!mh_strcasecmp (name, "Message-ID")) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &bufsz, in);
+ }
} else if (uprf (name, XXX_FIELD_PRF)
|| !mh_strcasecmp (name, VRSN_FIELD)
|| !mh_strcasecmp (name, "Subject")
} else if (uprf (name, XXX_FIELD_PRF)
|| !mh_strcasecmp (name, VRSN_FIELD)
|| !mh_strcasecmp (name, "Subject")
dp = add (concat (name, ":", buffer, NULL), dp);
while (state == FLDPLUS) {
dp = add (concat (name, ":", buffer, NULL), dp);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
+ bufsz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &bufsz, in);
dp = add (buffer, dp);
}
} else {
dp = add (buffer, dp);
}
} else {
*/
cp = add (concat (name, ":", buffer, NULL), cp);
while (state == FLDPLUS) {
*/
cp = add (concat (name, ":", buffer, NULL), cp);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
+ bufsz = sizeof buffer;
+ state = m_getfld (state, name, buffer, &bufsz, in);
cp = add (buffer, cp);
}
}
cp = add (buffer, cp);
}
}
return 0;
for (state = FLD;;) {
return 0;
for (state = FLD;;) {
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
cp = add (buf, NULL);
while (state == FLDPLUS) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
bp = cp;
cp = add (buf, cp);
}
bp = cp;
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
if (!mh_strcasecmp (name, ENCODING_FIELD)) {
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
cp = add (buf, cp);
}
for (bp = cp; isspace (*bp); bp++)
* Just skip the rest of this header
* field and go to next one.
*/
* Just skip the rest of this header
* field and go to next one.
*/
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
+ }
* a lookup table.
*/
for (i = 0, state = FLD;;) {
* a lookup table.
*/
for (i = 0, state = FLD;;) {
- switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+ int fieldsz = sizeof field;
+ switch (state = m_getfld (state, name, field, &fieldsz, in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
lp = add (field, NULL);
while (state == FLDPLUS) {
case FLD:
case FLDEOF:
case FLDPLUS:
lp = add (field, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, field, sizeof(field), in);
+ fieldsz = sizeof field;
+ state = m_getfld (state, name, field, &fieldsz, in);
lp = add (field, lp);
}
for (p = hdrs; p->p_name; p++) {
lp = add (field, lp);
}
for (p = hdrs; p->p_name; p++) {
rewind (in);
for (state = FLD;;) {
rewind (in);
for (state = FLD;;) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ int bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
switch (state) {
case FLD:
case FLDPLUS:
case FLDEOF:
/* Search for the message ID */
if (mh_strcasecmp (name, "Message-ID")) {
switch (state) {
case FLD:
case FLDPLUS:
case FLDEOF:
/* Search for the message ID */
if (mh_strcasecmp (name, "Message-ID")) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
+ }
continue;
}
cp = add (buf, NULL);
while (state == FLDPLUS) {
continue;
}
cp = add (buf, NULL);
while (state == FLDPLUS) {
- state = m_getfld (state, name, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, in);
cp = add (buf, cp);
}
key.dptr = trimcpy (cp);
cp = add (buf, cp);
}
key.dptr = trimcpy (cp);
return (0);
}
for (compnum = 1, state = FLD;;) {
return (0);
}
for (compnum = 1, state = FLD;;) {
- switch (state = m_getfld (state, nam, buf, sizeof(buf), in)) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, nam, buf, &bufsz, in)) {
case FLD:
case FLDEOF:
case FLDPLUS:
case FLD:
case FLDEOF:
case FLDPLUS:
if (!mh_strcasecmp (nam, datesw)) {
datecomp = add (buf, datecomp);
while (state == FLDPLUS) {
if (!mh_strcasecmp (nam, datesw)) {
datecomp = add (buf, datecomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, nam, buf, &bufsz, in);
datecomp = add (buf, datecomp);
}
if (!subjsort || subjcomp)
datecomp = add (buf, datecomp);
}
if (!subjsort || subjcomp)
} else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
subjcomp = add (buf, subjcomp);
while (state == FLDPLUS) {
} else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
subjcomp = add (buf, subjcomp);
while (state == FLDPLUS) {
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ bufsz = sizeof buf;
+ state = m_getfld (state, nam, buf, &bufsz, in);
subjcomp = add (buf, subjcomp);
}
if (datecomp)
break;
} else {
/* just flush this guy */
subjcomp = add (buf, subjcomp);
}
if (datecomp)
break;
} else {
/* just flush this guy */
- while (state == FLDPLUS)
- state = m_getfld (state, nam, buf, sizeof(buf), in);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, nam, buf, &bufsz, in);
+ }
if ((fp = fopen (msgnam, "r")) == NULL)
return 0;
if ((fp = fopen (msgnam, "r")) == NULL)
return 0;
- for (state = FLD;;)
- switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+ for (state = FLD;;) {
+ int bufsz = sizeof buf;
+ switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
case FLD:
case FLDPLUS:
case FLDEOF:
case FLD:
case FLDPLUS:
case FLDEOF:
- while (state == FLDPLUS)
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ while (state == FLDPLUS) {
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
+ }
- state = m_getfld (state, name, buf, sizeof(buf), fp);
+ bufsz = sizeof buf;
+ state = m_getfld (state, name, buf, &bufsz, fp);
} while (state == BODY);
/* and fall... */
} while (state == BODY);
/* and fall... */