X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fm_getfld.c;h=26707a27671e15eb3b7bc5c2dc342c9bc2465f6a;hp=1ce52b6beba93a8bdf451d2439229ba08ed5f3f5;hb=714b5c530ece27ea2835a313013f5b770163403c;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 1ce52b6..26707a2 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -42,7 +42,7 @@ ** This worked fine, until one day: a message with no body portion arrived. ** Then the ** -** while (eom (c = Getc (iob), iob)) +** while (eom(c = Getc(iob), iob)) ** continue; ** ** loop caused m_getfld() to return FMTERR. So, that logic was changed to @@ -141,7 +141,7 @@ /* ** static prototypes */ -static int m_Eom (int, FILE *); +static int m_Eom(int, FILE *); static unsigned char *matchc(int, char *, int, char *); static unsigned char *locc(int, unsigned char *, unsigned char); @@ -207,7 +207,7 @@ extern int _filbuf(FILE*); int -m_getfld (int state, unsigned char *name, unsigned char *buf, +m_getfld(int state, unsigned char *name, unsigned char *buf, int bufsz, FILE *iob) { register unsigned char *bp, *cp, *ep, *sp; @@ -218,10 +218,10 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, *buf = 0; return FILEEOF; } - if (eom (c, iob)) { + if (eom(c, iob)) { if (! eom_action) { /* flush null messages */ - while ((c = Getc(iob)) >= 0 && eom (c, iob)) + while ((c = Getc(iob)) >= 0 && eom(c, iob)) ; if (c >= 0) ungetc(c, iob); @@ -240,10 +240,10 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, while (c != '\n' && (c = Getc(iob)) >= 0) ; - if (c < 0 || (c = Getc(iob)) < 0 || eom (c, iob)) { + if (c < 0 || (c = Getc(iob)) < 0 || eom(c, iob)) { if (! eom_action) { /* flush null messages */ - while ((c = Getc(iob)) >= 0 && eom (c, iob)) + while ((c = Getc(iob)) >= 0 && eom(c, iob)) ; if (c >= 0) ungetc(c, iob); @@ -288,7 +288,7 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, if (_filbuf(iob) == EOF) { #endif *cp = *buf = 0; - advise (NULL, "eof encountered in field \"%s\"", name); + advise(NULL, "eof encountered in field \"%s\"", name); return FMTERR; } #ifdef LINUX_STDIO @@ -339,11 +339,11 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, ** guess we'll blow up. */ *cp = *buf = 0; - advise (NULL, "eol encountered in field \"%s\"", name); + advise(NULL, "eol encountered in field \"%s\"", name); state = FMTERR; goto finish; } - memcpy (buf, name, j - 1); + memcpy(buf, name, j - 1); buf[j - 1] = '\n'; buf[j] = '\0'; /* @@ -360,18 +360,18 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, ** should be harmless enough, right? ** This is a corrupt message anyway. */ - fseek (iob, ftell (iob) - 2, SEEK_SET); + fseek(iob, ftell(iob) - 2, SEEK_SET); return BODY; } if ((i -= j) <= 0) { *cp = *buf = 0; - advise (NULL, "field name \"%s\" exceeds %d bytes", name, NAMESZ - 2); + advise(NULL, "field name \"%s\" exceeds %d bytes", name, NAMESZ - 2); state = LENERR; goto finish; } } - while (isspace (*--cp) && cp >= name) + while (isspace(*--cp) && cp >= name) ; *++cp = 0; /* fall through */ @@ -403,16 +403,16 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, if ((j = *++ep) != ' ' && j != '\t') { #ifdef LINUX_STDIO j = ep - (unsigned char *) iob->_IO_read_ptr; - memcpy (cp, iob->_IO_read_ptr, j); + memcpy(cp, iob->_IO_read_ptr, j); iob->_IO_read_ptr = ep; #elif defined(__DragonFly__) j = ep - (unsigned char *) ((struct __FILE_public *)iob)->_p; - memcpy (cp, ((struct __FILE_public *)iob)->_p, j); + memcpy(cp, ((struct __FILE_public *)iob)->_p, j); ((struct __FILE_public *)iob)->_p = ep; ((struct __FILE_public *)iob)->_r -= j; #else j = ep - (unsigned char *) iob->_ptr; - memcpy (cp, iob->_ptr, j); + memcpy(cp, iob->_ptr, j); iob->_ptr = ep; iob->_cnt -= j; #endif @@ -429,13 +429,13 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, */ #ifdef LINUX_STDIO c += bp - (unsigned char *) iob->_IO_read_ptr; - memcpy( cp, iob->_IO_read_ptr, c); + memcpy(cp, iob->_IO_read_ptr, c); #elif defined(__DragonFly__) c += bp - (unsigned char *) ((struct __FILE_public *)iob)->_p; - memcpy( cp, ((struct __FILE_public *)iob)->_p, c); + memcpy(cp, ((struct __FILE_public *)iob)->_p, c); #else c += bp - (unsigned char *) iob->_ptr; - memcpy( cp, iob->_ptr, c); + memcpy(cp, iob->_ptr, c); #endif i -= c; cp += c; @@ -628,7 +628,7 @@ m_getfld (int state, unsigned char *name, unsigned char *buf, break; default: - adios (NULL, "m_getfld() called with bogus state of %d", state); + adios(NULL, "m_getfld() called with bogus state of %d", state); } finish: *cp = 0; @@ -665,29 +665,29 @@ m_unknown(FILE *iob) msg_style = MS_UNKNOWN; - pos = ftell (iob); - if (fread (text, sizeof(*text), 5, iob) == 5 - && strncmp (text, "From ", 5) == 0) { + pos = ftell(iob); + if (fread(text, sizeof(*text), 5, iob) == 5 + && strncmp(text, "From ", 5) == 0) { msg_style = MS_MBOX; delimstr = "\nFrom "; #ifndef RPATHS - while ((c = getc (iob)) != '\n' && c >= 0) + while ((c = getc(iob)) != '\n' && c >= 0) ; #else /* RPATHS */ cp = unixbuf; - while ((c = getc (iob)) != '\n' && cp - unixbuf < BUFSIZ - 1) + while ((c = getc(iob)) != '\n' && cp - unixbuf < BUFSIZ - 1) *cp++ = c; *cp = 0; #endif /* RPATHS */ } else { /* not a Unix style maildrop */ - fseek (iob, pos, SEEK_SET); + fseek(iob, pos, SEEK_SET); if (mmdlm2 == NULL || *mmdlm2 == 0) mmdlm2 = "\001\001\001\001\n"; delimstr = mmdlm2; msg_style = MS_MMDF; } - c = strlen (delimstr); + c = strlen(delimstr); fdelim = (unsigned char *) mh_xmalloc((size_t) (c + 3)); *fdelim++ = '\0'; *fdelim = '\n'; @@ -695,24 +695,24 @@ m_unknown(FILE *iob) edelim = (unsigned char *)msg_delim+1; fdelimlen = c + 1; edelimlen = c - 1; - strcpy (msg_delim, delimstr); + strcpy(msg_delim, delimstr); delimend = (unsigned char *)msg_delim + edelimlen; if (edelimlen <= 1) - adios (NULL, "maildrop delimiter must be at least 2 bytes"); + adios(NULL, "maildrop delimiter must be at least 2 bytes"); /* ** build a Boyer-Moore end-position map for the matcher in m_getfld. ** N.B. - we don't match just the first char (since it's the newline ** separator) or the last char (since the matchc would have found it ** if it was a real delim). */ - pat_map = (unsigned char **) calloc (256, sizeof(unsigned char *)); + pat_map = (unsigned char **) calloc(256, sizeof(unsigned char *)); for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ ) pat_map[(unsigned char)*cp] = (unsigned char *) cp; if (msg_style == MS_MMDF) { /* flush extra msg hdrs */ - while ((c = Getc(iob)) >= 0 && eom (c, iob)) + while ((c = Getc(iob)) >= 0 && eom(c, iob)) ; if (c >= 0) ungetc(c, iob); @@ -725,7 +725,7 @@ m_unknown(FILE *iob) */ static int -m_Eom (int c, FILE *iob) +m_Eom(int c, FILE *iob) { register long pos = 0L; register int i; @@ -734,9 +734,9 @@ m_Eom (int c, FILE *iob) register char *cp; #endif /* RPATHS */ - pos = ftell (iob); - if ((i = fread (text, sizeof *text, edelimlen, iob)) != edelimlen - || strncmp (text, (char *)edelim, edelimlen)) { + pos = ftell(iob); + if ((i = fread(text, sizeof *text, edelimlen, iob)) != edelimlen + || strncmp(text, (char *)edelim, edelimlen)) { if (i == 0 && msg_style == MS_MBOX) /* ** the final newline in the (brain damaged) unix-format @@ -745,22 +745,22 @@ m_Eom (int c, FILE *iob) return 1; #if 0 - fseek (iob, pos, SEEK_SET); + fseek(iob, pos, SEEK_SET); #endif - fseek (iob, (long)(pos-1), SEEK_SET); - getc (iob); /* should be OK */ + fseek(iob, (long)(pos-1), SEEK_SET); + getc(iob); /* should be OK */ return 0; } if (msg_style == MS_MBOX) { #ifndef RPATHS - while ((c = getc (iob)) != '\n') + while ((c = getc(iob)) != '\n') if (c < 0) break; #else /* RPATHS */ cp = unixbuf; - while ((c = getc (iob)) != '\n' && c >= 0 && cp - unixbuf < BUFSIZ - 1) + while ((c = getc(iob)) != '\n' && c >= 0 && cp - unixbuf < BUFSIZ - 1) *cp++ = c; *cp = 0; #endif /* RPATHS */ @@ -783,7 +783,7 @@ m_Eom (int c, FILE *iob) */ int -get_returnpath (char *rp, int rplen, char *dd, int ddlen) +get_returnpath(char *rp, int rplen, char *dd, int ddlen) { char *ap, *bp, *cp, *dp; @@ -796,8 +796,8 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) ** if this message uses UUCP style addressing */ while ((cp = strchr(++cp, 'r'))) { - if (strncmp (cp, "remote from", 11) == 0) { - cp = strrchr (cp, ' '); + if (strncmp(cp, "remote from", 11) == 0) { + cp = strrchr(cp, ' '); break; } } @@ -808,11 +808,11 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) */ if (cp) { /* return path for UUCP style addressing */ - dp = strchr (++cp, '\n'); - snprintf (rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap); + dp = strchr(++cp, '\n'); + snprintf(rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap); } else { /* return path for standard domain addressing */ - snprintf (rp, rplen, "%.*s\n", (int)(bp - ap), ap); + snprintf(rp, rplen, "%.*s\n", (int)(bp - ap), ap); } /* @@ -823,7 +823,7 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) bp++; /* Now get delivery date from envelope */ - snprintf (dd, ddlen, "%.*s\n", 24, bp); + snprintf(dd, ddlen, "%.*s\n", 24, bp); unixbuf[0] = 0; return 1;