X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fm_getfld.c;h=a3852feb2640386a36e685b489e3ae788d6f170a;hb=2abb9a7cfb0930e27062088734d306e7d78e4cc2;hp=85a323b965677cf6a06ab9c8008283b2fdbb0c50;hpb=59fa35679d83dd2e4d0cf13c2a1d2cf8fbb9de76;p=mmh diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 85a323b..a3852fe 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -8,6 +8,7 @@ #include #include +#include /* ** This module has a long and checkered history. @@ -154,14 +155,6 @@ static int (*eom_action)(int) = NULL; # define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC #endif -#ifdef SCO_5_STDIO -# define _ptr __ptr -# define _cnt __cnt -# define _base __base -# define _filbuf(fp) ((fp)->__cnt = 0, __filbuf(fp)) -# define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC -#endif - #ifndef DEFINED__FILBUF_TO_SOMETHING_SPECIFIC extern int _filbuf(FILE*); #endif @@ -431,8 +424,8 @@ m_getfld(int state, unsigned char *name, unsigned char *buf, *cp++ = j = *(iob->_ptr + c); c = _filbuf(iob); #endif - if (c == EOF || - ((j == '\0' || j == '\n') && c != ' ' && c != '\t')) { + if (c == EOF || ((j == '\0' || j == '\n') + && c != ' ' && c != '\t')) { if (c != EOF) { #ifdef LINUX_STDIO --iob->_IO_read_ptr; @@ -578,17 +571,21 @@ finish: return (state); } -static char fromline[BUFSIZ] = ""; void thisisanmbox(FILE *iob) { register int c; - register long pos; char text[10]; register char *cp; register char *delimstr; + c = getc(iob); + if (feof(iob)) { + return; + } + ungetc(c, iob); + /* ** Figure out what the message delimitter string is for this ** maildrop. (This used to be part of m_Eom but I didn't like @@ -601,7 +598,6 @@ thisisanmbox(FILE *iob) ** abort. */ - pos = ftell(iob); if (fread(text, sizeof(*text), 5, iob) != 5) { adios(NULL, "Read error"); } @@ -610,11 +606,9 @@ thisisanmbox(FILE *iob) } ismbox = TRUE; delimstr = "\nFrom "; - cp = fromline; - while ((c = getc(iob)) != '\n' && cp - fromline < BUFSIZ - 1) - *cp++ = c; - *cp = '\0'; - + while ((c = getc(iob)) != '\n' && c >= 0) { + continue; + } c = strlen(delimstr); fdelim = (unsigned char *) mh_xmalloc((size_t) (c + 3)); *fdelim++ = '\0'; @@ -650,7 +644,6 @@ m_Eom(int c, FILE *iob) register long pos = 0L; register int i; char text[10]; - register char *cp; pos = ftell(iob); if ((i = fread(text, sizeof *text, edelimlen, iob)) != edelimlen || @@ -668,43 +661,15 @@ m_Eom(int c, FILE *iob) } if (ismbox) { - cp = fromline; - while ((c = getc(iob)) != '\n' && c >= 0 && cp - fromline < BUFSIZ - 1) - *cp++ = c; - *cp = '\0'; + while ((c = getc(iob)) != '\n' && c >= 0) { + continue; + } } return 1; } -/* -** Return the Return-Path and Delivery-Date header information. -** -** Currently, I'm assuming that the "From " line takes the following form: -** "From" sender@host date (sendmail delivery) -*/ -int -get_returnpath(char *rp, int rplen, char *dd, int ddlen) -{ - char *cp; - - if (!(cp = strchr(fromline, ' '))) { - return 0; - } - /* Extract the Return-Path. */ - snprintf(rp, rplen, "%.*s\n", (int)(cp - fromline), fromline); - /* Advance over the whitespace. */ - while (*cp == ' ' || *cp == '\t') { - cp++; - } - /* Extract the Delivery-Date. */ - snprintf(dd, ddlen, "%.*s\n", 24, cp); - *fromline = '\0'; - return 1; -} - - static unsigned char * matchc(int patln, char *pat, int strln, char *str) {