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)
14 #include "fetchmail.h"
16 static int pound_arg, equal_arg;
18 int pop2_ok (sockfp, argbuf)
19 /* parse POP2 command response */
24 char buf [POPBUFSIZE+1];
26 pound_arg = equal_arg = -1;
27 if (fgets(buf, sizeof(buf), sockfp) != (char *)NULL) {
28 if (outlevel == O_VERBOSE)
29 fprintf(stderr,"%s",buf);
33 else if (buf[0] == '#')
35 pound_arg = atoi(buf+1);
38 else if (buf[0] == '=')
40 equal_arg = atoi(buf+1);
43 else if (buf[0] == '-')
57 int pop2_getauth(sockfp, ctl, buf)
58 /* apply for connection authorization */
63 return(gen_transact(sockfp,
65 ctl->remotename, ctl->password));
68 static int pop2_getrange(sockfp, ctl, countp, newp)
69 /* get range of messages to be fetched */
75 * We should have picked up a count of messages in the user's
76 * default inbox from the pop2_getauth() response.
81 /* maybe the user wanted a non-default folder */
84 int ok = gen_transact(sockfp, "FOLD %s", ctl->mailbox);
98 static int pop2_fetch(sockfp, number, lenp)
99 /* request nth message */
107 ok = gen_transact(sockfp, "READ %d", number);
112 gen_send(sockfp, "RETR");
117 static int pop2_trail(sockfp, ctl, number)
118 /* send acknowledgement for message data */
123 return(gen_transact(sockfp, ctl->keep ? "ACKS" : "ACKD"));
126 const static struct method pop2 =
128 "POP2", /* Post Office Protocol v2 */
129 109, /* standard POP2 port */
130 0, /* this is not a tagged protocol */
131 0, /* does not use message delimiter */
132 pop2_ok, /* parse command response */
133 pop2_getauth, /* get authorization */
134 pop2_getrange, /* query range of messages */
135 NULL, /* no way to get sizes */
136 NULL, /* messages are always new */
137 pop2_fetch, /* request given message */
138 pop2_trail, /* eat message trailer */
139 NULL, /* no POP2 delete method */
140 NULL, /* no POP2 expunge command */
141 "QUIT", /* the POP2 exit command */
145 /* retrieve messages using POP2 */
148 return(do_protocol(ctl, &pop2));
151 /* pop2.c ends here */