2 * pop2.c -- POP@ protocol methods
4 * Copyright 1996 by Eric S. Raymond
6 * For license terms, see the file COPYING in this directory.
11 #if defined(STDC_HEADERS)
15 #include "fetchmail.h"
17 static int pound_arg, equal_arg;
19 int pop2_ok (socket, argbuf)
20 /* parse POP2 command response */
25 char buf [POPBUFSIZE+1];
27 pound_arg = equal_arg = -1;
28 if (SockGets(socket, buf, sizeof(buf)) >= 0) {
29 if (outlevel == O_VERBOSE)
30 fprintf(stderr,"%s\n",buf);
34 else if (buf[0] == '#')
36 pound_arg = atoi(buf+1);
39 else if (buf[0] == '=')
41 equal_arg = atoi(buf+1);
44 else if (buf[0] == '-')
58 int pop2_getauth(socket, ctl, buf)
59 /* apply for connection authorization */
64 return(gen_transact(socket,
66 ctl->remotename, ctl->password));
69 static int pop2_getrange(socket, ctl, countp, newp)
70 /* get range of messages to be fetched */
76 * We should have picked up a count of messages in the user's
77 * default inbox from the pop2_getauth() response.
82 /* maybe the user wanted a non-default folder */
85 int ok = gen_transact(socket, "FOLD %s", ctl->mailbox);
99 static int pop2_fetch(socket, number, lenp)
100 /* request nth message */
108 ok = gen_transact(socket, "READ %d", number);
113 gen_send(socket, "RETR");
118 static int pop2_trail(socket, ctl, number)
119 /* send acknowledgement for message data */
124 return(gen_transact(socket, ctl->keep ? "ACKS" : "ACKD"));
127 const static struct method pop2 =
129 "POP2", /* Post Office Protocol v2 */
130 109, /* standard POP2 port */
131 0, /* this is not a tagged protocol */
132 0, /* does not use message delimiter */
133 pop2_ok, /* parse command response */
134 pop2_getauth, /* get authorization */
135 pop2_getrange, /* query range of messages */
136 NULL, /* no way to get sizes */
137 NULL, /* messages are always new */
138 pop2_fetch, /* request given message */
139 pop2_trail, /* eat message trailer */
140 NULL, /* no POP2 delete method */
141 NULL, /* no POP2 expunge command */
142 "QUIT", /* the POP2 exit command */
146 /* retrieve messages using POP2 */
149 return(do_protocol(ctl, &pop2));
152 /* pop2.c ends here */