diff options
-rw-r--r-- | driver.c | 10 | ||||
-rw-r--r-- | socket.c | 17 |
2 files changed, 11 insertions, 16 deletions
@@ -473,7 +473,7 @@ struct query *ctl; /* if no socket to this host is already set up, try to open one */ if (ctl->smtp_sockfp == (FILE *)NULL) { - if ((ctl->smtp_sockfp = fdopen(Socket(ctl->smtphost, SMTP_PORT), "r+")) == (FILE *)NULL) + if ((ctl->smtp_sockfp = Socket(ctl->smtphost, SMTP_PORT)) == (FILE *)NULL) return((FILE *)NULL); else if (SMTP_ok(ctl->smtp_sockfp, NULL) != SM_OK || SMTP_helo(ctl->smtp_sockfp, ctl->servername) != SM_OK) @@ -854,11 +854,11 @@ const struct method *proto; /* protocol method table */ else { char buf [POPBUFSIZE+1]; - int *msgsizes, socket, len, num, count, new, deletions = 0; + int *msgsizes, len, num, count, new, deletions = 0; FILE *sockfp; /* open a socket to the mail server */ - if ((socket = Socket(ctl->servername, + if ((sockfp = Socket(ctl->servername, ctl->port ? ctl->port : protocol->port))<0) { perror("fetchmail, connecting to host"); @@ -866,12 +866,10 @@ const struct method *proto; /* protocol method table */ goto closeUp; } - sockfp = fdopen(socket, "r+"); - #ifdef KERBEROS_V4 if (ctl->authenticate == A_KERBEROS) { - ok = (kerberos_auth (socket, ctl->canonical_name)); + ok = (kerberos_auth (fileno(sockfp), ctl->canonical_name)); vtalarm(ctl->timeout); if (ok != 0) goto cleanUp; @@ -4,11 +4,8 @@ * These were designed and coded by Carl Harris <ceharris@mal.com> * and are essentially unchanged from the ancestral popclient. * - * Actually, this library shouldn't exist. We ought to be using - * stdio to buffer the socket descriptors. If that worked, we - * could have separate buffers for the mailserver and SMTP sockets, - * and we'd be able to handle responses longer than the socket - * atomic read size. + * The file pointer arguments are currently misleading -- there + * is only one shared internal buffer for all sockets. * * For license terms, see the file COPYING in this directory. */ @@ -45,7 +42,7 @@ #define INTERNAL_BUFSIZE 2048 -int Socket(host, clientPort) +FILE *Socket(host, clientPort) char *host; int clientPort; { @@ -64,17 +61,17 @@ int clientPort; { hp = gethostbyname(host); if (hp == NULL) - return -1; + return (FILE *)NULL; memcpy(&ad.sin_addr, hp->h_addr, hp->h_length); } ad.sin_port = htons(clientPort); sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) - return sock; + return (FILE *)NULL; if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) - return -1; - return sock; + return (FILE *)NULL; + return fdopen(sock, "r+"); } int SockPuts(buf, sockfp) |