--- pop3dserver.c.old 2008-01-05 03:58:36.000000000 +0100 +++ pop3dserver.c 2009-05-11 16:25:30.000000000 +0200 @@ -121,10 +121,33 @@ static void calcsize(struct msglist *m) { +char *p; +long s; +struct stat st; + + /* + * try to get messagesize from filename, + * if not possible, do a stat on the file, + * if that fails fall back to default behaviour + */ + m->size=0; + + if( (p=strstr(m->filename,",S=")) && (s=atol(p+3))>0 ) + { + m->size=(off_t)s; + return; + } + if(stat(m->filename,&st)==0) + { + m->size=(off_t)st.st_size; + return; + } + + fprintf(stderr,"bytecounting messagesize\n"); + FILE *f=fopen(m->filename, "r"); int c, lastc; - m->size=0; if (f == 0) { perror("calcsize fopen");