diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-05-13 23:42:04 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-05-13 23:42:04 +0000 |
commit | 451d98c467f141e7802b91d26869b6e38ee868fc (patch) | |
tree | 7db5f650940300bb81cd23ab9d41a312ece63e68 /pop3.c | |
parent | 2cbdef3efbe733325aea934ed3ffab9e9ba6175e (diff) | |
download | fetchmail-451d98c467f141e7802b91d26869b6e38ee868fc.tar.gz fetchmail-451d98c467f141e7802b91d26869b6e38ee868fc.tar.bz2 fetchmail-451d98c467f141e7802b91d26869b6e38ee868fc.zip |
Change type of socket descriptors from FILE * to int. Change SockGets
to SockRead a la read(2). This is all part of an attempt to deal with
embedded NULs in IMAP messages.
svn path=/trunk/; revision=992
Diffstat (limited to 'pop3.c')
-rw-r--r-- | pop3.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -25,14 +25,14 @@ extern char *strstr(); /* needed on sysV68 R3V7.1. */ static int last; -int pop3_ok (FILE *sockfp, char *argbuf) +int pop3_ok (int sock, char *argbuf) /* parse command response */ { int ok; char buf [POPBUFSIZE+1]; char *bufp; - if ((ok = gen_recv(sockfp, buf, sizeof(buf))) == 0) + if ((ok = gen_recv(sock, buf, sizeof(buf))) == 0) { bufp = buf; if (*bufp == '+' || *bufp == '-') @@ -58,7 +58,7 @@ int pop3_ok (FILE *sockfp, char *argbuf) return(ok); } -int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) +int pop3_getauth(int sock, struct query *ctl, char *greeting) /* apply for connection authorization */ { /* build MD5 digest from greeting timestamp + password */ @@ -96,24 +96,24 @@ int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) switch (ctl->server.protocol) { case P_POP3: - if ((gen_transact(sockfp, "USER %s", ctl->remotename)) != 0) + if ((gen_transact(sock, "USER %s", ctl->remotename)) != 0) PROTOCOL_ERROR - if ((gen_transact(sockfp, "PASS %s", ctl->password)) != 0) + if ((gen_transact(sock, "PASS %s", ctl->password)) != 0) PROTOCOL_ERROR break; case P_APOP: - if ((gen_transact(sockfp, "APOP %s %s", + if ((gen_transact(sock, "APOP %s %s", ctl->remotename, ctl->digest)) != 0) PROTOCOL_ERROR break; case P_RPOP: - if ((gen_transact(sockfp,"USER %s", ctl->remotename)) != 0) + if ((gen_transact(sock,"USER %s", ctl->remotename)) != 0) PROTOCOL_ERROR - if ((gen_transact(sockfp, "RPOP %s", ctl->password)) != 0) + if ((gen_transact(sock, "RPOP %s", ctl->password)) != 0) PROTOCOL_ERROR break; @@ -125,7 +125,7 @@ int pop3_getauth(FILE *sockfp, struct query *ctl, char *greeting) return(0); } -static int pop3_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp) +static int pop3_getrange(int sock, struct query *ctl, int*countp, int*newp) /* get range of messages to be fetched */ { int ok; @@ -135,8 +135,8 @@ static int pop3_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp) ctl->newsaved = (struct idlist *)NULL; /* get the total message count */ - gen_send(sockfp, "STAT"); - ok = pop3_ok(sockfp, buf); + gen_send(sock, "STAT"); + ok = pop3_ok(sock, buf); if (ok == 0) sscanf(buf,"%d %*d", countp); else @@ -154,8 +154,8 @@ static int pop3_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp) char id [IDLEN+1]; if (!ctl->server.uidl) { - gen_send(sockfp,"LAST"); - ok = pop3_ok(sockfp, buf); + gen_send(sock, "LAST"); + ok = pop3_ok(sock, buf); } else ok = 1; if (ok == 0) @@ -167,14 +167,14 @@ static int pop3_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp) else { /* grab the mailbox's UID list */ - if ((ok = gen_transact(sockfp, "UIDL")) != 0) + if ((ok = gen_transact(sock, "UIDL")) != 0) PROTOCOL_ERROR else { int num; *newp = 0; - while ((ok = gen_recv(sockfp, buf, sizeof(buf))) == 0) + while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0) { if (buf[0] == '.') break; @@ -194,18 +194,18 @@ static int pop3_getrange(FILE *sockfp, struct query *ctl, int*countp, int*newp) return(0); } -static int pop3_getsizes(FILE *sockfp, int count, int *sizes) +static int pop3_getsizes(int sock, int count, int *sizes) /* capture the sizes of all messages */ { int ok; - if ((ok = gen_transact(sockfp, "LIST")) != 0) + if ((ok = gen_transact(sock, "LIST")) != 0) return(ok); else { char buf [POPBUFSIZE+1]; - while ((ok = gen_recv(sockfp, buf, sizeof(buf))) == 0) + while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0) { int num, size; @@ -221,7 +221,7 @@ static int pop3_getsizes(FILE *sockfp, int count, int *sizes) } } -static int pop3_is_old(FILE *sockfp, struct query *ctl, int num) +static int pop3_is_old(int sock, struct query *ctl, int num) /* is the given message old? */ { if (!ctl->oldsaved) @@ -232,14 +232,14 @@ static int pop3_is_old(FILE *sockfp, struct query *ctl, int num) str_find (&ctl->newsaved, num))); } -static int pop3_fetch(FILE *sockfp, struct query *ctl, int number, int *lenp) +static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp) /* request nth message */ { int ok; char buf [POPBUFSIZE+1], *cp; - gen_send(sockfp, "RETR %d", number); - if ((ok = pop3_ok(sockfp, buf)) != 0) + gen_send(sock, "RETR %d", number); + if ((ok = pop3_ok(sock, buf)) != 0) return(ok); /* look for "nnn octets" -- there may or may not be preceding cruft */ if ((cp = strstr(buf, " octets")) == (char *)NULL) @@ -253,10 +253,10 @@ static int pop3_fetch(FILE *sockfp, struct query *ctl, int number, int *lenp) return(0); } -static int pop3_delete(FILE *sockfp, struct query *ctl, int number) +static int pop3_delete(int sock, struct query *ctl, int number) /* delete a given message */ { - return(gen_transact(sockfp, "DELE %d", number)); + return(gen_transact(sock, "DELE %d", number)); } const static struct method pop3 = |