#include <config.h>
#include <stdio.h>
+#if defined(STDC_HEADERS)
+#include <stdlib.h>
+#endif
#include "socket.h"
#include "fetchmail.h"
static int pound_arg, equal_arg;
-int pop2_ok (socket, argbuf)
+int pop2_ok (FILE *sockfp, char *argbuf)
/* parse POP2 command response */
-int socket;
-char *argbuf;
{
int ok;
char buf [POPBUFSIZE+1];
pound_arg = equal_arg = -1;
- if (SockGets(socket, buf, sizeof(buf)) >= 0) {
+ if (fgets(buf, sizeof(buf), sockfp)) {
if (outlevel == O_VERBOSE)
- fprintf(stderr,"%s\n",buf);
+ error(0, 0, "POP2< %s", buf);
if (buf[0] == '+')
ok = 0;
return(ok);
}
-int pop2_getauth(socket, queryctl, buf)
+int pop2_getauth(FILE *sockfp, struct query *ctl, char *buf)
/* apply for connection authorization */
-int socket;
-struct hostrec *queryctl;
-char *buf;
{
- return(gen_transact(socket,
+ return(gen_transact(sockfp,
"HELO %s %s",
- queryctl->remotename, queryctl->password));
+ ctl->remotename, ctl->password));
}
-static pop2_getrange(socket, queryctl, countp, newp)
+static int pop2_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp)
/* get range of messages to be fetched */
-int socket;
-struct hostrec *queryctl;
-int *countp, *newp;
{
/*
* We should have picked up a count of messages in the user's
return(PS_ERROR);
/* maybe the user wanted a non-default folder */
- if (queryctl->mailbox[0])
+ if (ctl->mailbox[0])
{
- int ok = gen_transact(socket, "FOLD %s", queryctl->mailbox);
+ int ok = gen_transact(sockfp, "FOLD %s", ctl->mailbox);
if (ok != 0)
return(ok);
return(0);
}
-static int pop2_fetch(socket, number, lenp)
+static int pop2_fetch(FILE *sockfp, int number, int *lenp)
/* request nth message */
-int socket;
-int number;
-int *lenp;
{
int ok;
*lenp = 0;
- ok = gen_transact(socket, "READ %d", number);
+ ok = gen_transact(sockfp, "READ %d", number);
if (ok)
return(0);
*lenp = equal_arg;
- gen_send(socket, "RETR");
+ gen_send(sockfp, "RETR");
return(ok);
}
-static pop2_trail(socket, queryctl, number)
+static int pop2_trail(FILE *sockfp, struct query *ctl, int number)
/* send acknowledgement for message data */
-int socket;
-struct hostrec *queryctl;
-int number;
{
- return(gen_transact(socket, queryctl->keep ? "ACKS" : "ACKD"));
+ return(gen_transact(sockfp, ctl->keep ? "ACKS" : "ACKD"));
}
const static struct method pop2 =
pop2_ok, /* parse command response */
pop2_getauth, /* get authorization */
pop2_getrange, /* query range of messages */
+ NULL, /* no way to get sizes */
NULL, /* messages are always new */
pop2_fetch, /* request given message */
pop2_trail, /* eat message trailer */
"QUIT", /* the POP2 exit command */
};
-int doPOP2 (queryctl)
+int doPOP2 (struct query *ctl)
/* retrieve messages using POP2 */
-struct hostrec *queryctl;
{
- return(do_protocol(queryctl, &pop2));
+ peek_capable = FALSE;
+ return(do_protocol(ctl, &pop2));
}
/* pop2.c ends here */