From e51cee378fd6a0f8d6f3af2a125715036d1f2f8c Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 22 Mar 2012 21:07:50 +0100 Subject: [PATCH] scansbr: Fixed scan and inc. Writing to /dev/null had it's sense, as for scanning mboxes, the message size had been determined this way and the file pointer had been pushed forward. This is now done using the input file pointer instead of the output fp. --- uip/scansbr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/uip/scansbr.c b/uip/scansbr.c index 9f6306d..299027a 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -78,6 +78,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, char deliverydate[BUFSIZ]; int incing = (outnum > 0); int scanfolder = (outnum == 0); + long fpos; /* first-time only initialization */ if (!scanl) { @@ -122,6 +123,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, dat[0] = innum ? innum : outnum; dat[1] = curflg; dat[4] = unseen; + fpos = ftell(inb); /* ** Get the first field. If the message is non-empty @@ -203,7 +205,16 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, case BODY: compnum = -1; if (!incing) { - state = FILEEOF; /* stop here if scan cmd */ + /* stop here if scan cmd */ + if (scanfolder) { + state = FILEEOF; + goto finished; + } + /* for mboxes: snarf the body */ + while (state == BODY) { + state = m_getfld(state, name, tmpbuf, + SBUFSIZ, inb); + } goto finished; } FPUTS("\n"); @@ -279,6 +290,10 @@ finished: if (incing) { if ((dat[2] = ftell(scnout)) == EOF) adios(scnmsg, "write error on"); + } else if (!scanfolder) { + if ((dat[2] = ftell(inb)) == EOF) + adios(scnmsg, "write error on"); + dat[2] -= fpos; } if ((datecomp && !datecomp->c_text) || scanfolder) { -- 1.7.10.4