diff options
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | driver.c | 6 | ||||
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | imap.c | 41 | ||||
-rw-r--r-- | pop3.c | 13 |
5 files changed, 31 insertions, 33 deletions
diff --git a/Makefile.in b/Makefile.in index 9348df72..01710b87 100644 --- a/Makefile.in +++ b/Makefile.in @@ -204,7 +204,7 @@ $(srcdir)/rcfile_y.c: $(srcdir)/rcfile_y.y parser = $(srcdir)/rcfile_l.l $(srcdir)/rcfile_y.y headers = $(srcdir)/fetchmail.h $(srcdir)/socket.h $(srcdir)/smtp.h \ - $(srcdir)/md5.h $(srcdir)/md5global.h + $(srcdir)/mx.h $(srcdir)/md5.h $(srcdir)/md5global.h extra = $(srcdir)/alloca.c $(srcdir)/getopt.[ch] $(srcdir)/getopt1.c \ $(srcdir)/strcasecmp.c docs = $(srcdir)/COPYING $(srcdir)/README $(srcdir)/INSTALL $(srcdir)/NEWS \ @@ -838,8 +838,12 @@ struct method *proto; /* protocol method table */ /* we may need to get sizes in order to check message limits */ msgsizes = (int *)NULL; if (!ctl->fetchall && proto->getsizes && ctl->limit) - if ((msgsizes = (proto->getsizes)(socket, count)) == (int *)NULL) + { + msgsizes = (int *)alloca(sizeof(int) * count); + + if ((ok = (proto->getsizes)(socket, count, msgsizes)) != 0) return(PS_ERROR); + } if (check_only) { diff --git a/fetchmail.h b/fetchmail.h index a34b0e43..34df7079 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -109,7 +109,7 @@ struct method int (*parse_response)(); /* response_parsing function */ int (*getauth)(); /* authorization fetcher */ int (*getrange)(); /* get message range to fetch */ - int *(*getsizes)(); /* get sizes of messages */ + int (*getsizes)(); /* get sizes of messages */ int (*is_old)(); /* check for old message */ int (*fetch)(); /* fetch a given message */ int (*trail)(); /* eat trailer of a message */ @@ -111,39 +111,34 @@ int *countp, *newp; return(0); } -static int *imap_getsizes(socket, count) +static int imap_getsizes(socket, count, sizes) /* capture the sizes of all messages */ int socket; int count; +int *sizes; { - int ok, *sizes; + char buf [POPBUFSIZE+1]; - if ((sizes = (int *)malloc(sizeof(int) * count)) == (int *)NULL) - return((int *)NULL); - else + gen_send(socket, "FETCH 1:%d RFC822.SIZE", count); + while (SockGets(socket, buf, sizeof(buf)) >= 0) { - char buf [POPBUFSIZE+1]; - - gen_send(socket, "FETCH 1:%d RFC822.SIZE", count); - while (SockGets(socket, buf, sizeof(buf)) >= 0) - { - int num, size; - - if (outlevel == O_VERBOSE) - fprintf(stderr,"%s\n",buf); - if (strstr(buf, "OK")) - break; - else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2) - sizes[num - 1] = size; - else - sizes[num - 1] = -1; - } + int num, size; - return(sizes); + if (outlevel == O_VERBOSE) + fprintf(stderr,"%s\n",buf); + if (strstr(buf, "OK")) + break; + else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2) + sizes[num - 1] = size; + else + sizes[num - 1] = -1; } + + return(0); } static imap_is_old(socket, ctl, num) +/* is the given message old? */ int socket; struct query *ctl; int num; @@ -182,7 +177,7 @@ int *lenp; } static imap_trail(socket, ctl, number) -/* discard tail of FETCH response */ +/* discard tail of FETCH response after reading message text */ int socket; struct query *ctl; int number; @@ -186,17 +186,16 @@ int *countp, *newp; return(0); } -static int *pop3_getsizes(socket, count) +static int pop3_getsizes(socket, count, sizes) /* capture the sizes of all messages */ int socket; int count; +int *sizes; { - int ok, *sizes; + int ok; if ((ok = gen_transact(socket, "LIST")) != 0) - return((int *)NULL); - else if ((sizes = (int *)malloc(sizeof(int) * count)) == (int *)NULL) - return((int *)NULL); + return(ok); else { char buf [POPBUFSIZE+1]; @@ -215,12 +214,12 @@ int count; sizes[num - 1] = -1; } - return(sizes); + return(0); } } static int pop3_is_old(socket, ctl, num) -/* is the goiven message old? */ +/* is the given message old? */ int socket; struct query *ctl; int num; |