Here's a patch to change read_header and store_message_temp to use fread instead of fgets. There might also need to be code added to replace nul characters, but I don't remember if that code goes here or at another layer.
This patch has not been tested yet! Aaron
diff -r dbmail/header.c fread/header.c 71c71 < size_t allocated_blocks = 1; --- > size_t allocated_blocks = 1, i; 89,92c89,90 < /* fgets will read until \n occurs, and \n is *included* in tmpline */ < if (!fgets(tmpline, MAX_LINE_SIZE, instream)) < break; < linemem = strlen(tmpline); --- > /* fread may stop before finding a \n, or may continue reading past one. */ > linemem = fread(tmpline, sizeof(char), MAX_LINE_SIZE, instream); 95,101c93,104 < /* The RFC size assumes all lines end in \r\n, < * so if we have a newline (\n) but don't have < * a carriage return (\r), count it in rfcsize. */ < if (linemem > 0 && tmpline[linemem - 1] == '\n') < if (linemem == 1 < || (linemem > 1 < && tmpline[linemem - 2] != '\r')) --- > > /* Check to see if we're starting on a CR/NL boundary. */ > if (tmpline[0] == '\n' && tmpheader[usedmem] != '\r') > tmpheaderrfcsize++; > > /* Check to see if we read in any newlines. If so, look to > * see if they are preceded by carriage returns. > * If not, increment the rfcsize because rfc output > * automatically inserts carriage returns. */ > for (i = 1; i < linemem; i++) { > if (tmpline[i] == '\n' > && tmpline[i - 1] != '\r') 102a106 > } diff -r dbmail/pipe.c fread/pipe.c 464,475d463 < if (fgets(tmpline, MAX_LINE_SIZE, instream) == NULL) < break; < < linemem = strlen(tmpline); < /* The RFC size assumes all lines end in \r\n, < * so if we have a newline (\n) but don't have < * a carriage return (\r), count it in rfcsize. */ < if (linemem > 0 && tmpline[linemem - 1] == '\n') < if (linemem == 1 < || (linemem > 1 < && tmpline[linemem - 2] != '\r')) < rfclines++; 476a465,481 > linemem = fread(tmpline, sizeof(char), MAX_LINE_SIZE, instream); > totalmem += linemem; > > /* Check to see if we're starting on a CR/NL boundary. */ > if (tmpline[0] == '\n' && strblock[usedmem] != '\r') > rfclines++; > > /* Check to see if we read in any newlines. If so, look to > * see if they are preceded by carriage returns. > * If not, increment the rfcsize because rfc output > * automatically inserts carriage returns. */ > for (i = 1; i < linemem; i++) { > if (tmpline[i] == '\n' > && tmpline[i - 1] != '\r') > rfclines++; > } > Only in dbmail: THANKS Only in dbmail: TODO Only in dbmail: VERSION