aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-07-25 14:20:54 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-07-25 14:20:54 +0000
commit3673babe2a47d43fce7e4472fe08917e68b88ff6 (patch)
treef3ad85ad82372c9fca0c27083d680124ad64d523
parent01abcfe2305f3b7a367acbd394e615e6051e5c6b (diff)
downloadfetchmail-3673babe2a47d43fce7e4472fe08917e68b88ff6.tar.gz
fetchmail-3673babe2a47d43fce7e4472fe08917e68b88ff6.tar.bz2
fetchmail-3673babe2a47d43fce7e4472fe08917e68b88ff6.zip
SockClose() abstraction.
svn path=/trunk/; revision=2021
-rw-r--r--driver.c10
-rw-r--r--imap.c13
-rw-r--r--socket.c7
-rw-r--r--socket.h6
4 files changed, 25 insertions, 11 deletions
diff --git a/driver.c b/driver.c
index 1ce13b5d..f0099158 100644
--- a/driver.c
+++ b/driver.c
@@ -406,7 +406,7 @@ static int smtp_open(struct query *ctl)
* RFC 1869 warns that some listeners hang up on a failed EHLO,
* so it's safest not to assume the socket will still be good.
*/
- close(ctl->smtp_socket);
+ SockClose(ctl->smtp_socket);
ctl->smtp_socket = -1;
/* if opening for ESMTP failed, try SMTP */
@@ -417,7 +417,7 @@ static int smtp_open(struct query *ctl)
SMTP_helo(ctl->smtp_socket, id_me) == SM_OK)
break; /* success */
- close(ctl->smtp_socket);
+ SockClose(ctl->smtp_socket);
ctl->smtp_socket = -1;
}
set_timeout(0);
@@ -1780,7 +1780,7 @@ const struct method *proto; /* protocol method table */
if (ctl->smtp_socket != -1)
close(ctl->smtp_socket);
if (sock != -1)
- close(sock);
+ SockClose(sock);
if (sinkfp)
pclose(sinkfp);
ok = PS_ERROR;
@@ -2305,13 +2305,13 @@ const struct method *proto; /* protocol method table */
*/
if (ok == 0)
ok = (fetches > 0) ? PS_SUCCESS : PS_NOMAIL;
- close(sock);
+ SockClose(sock);
goto closeUp;
cleanUp:
if (ok != 0 && ok != PS_SOCKET)
(protocol->logout_cmd)(sock, ctl);
- close(sock);
+ SockClose(sock);
}
msg = (char *)NULL; /* sacrifice to -Wall */
diff --git a/imap.c b/imap.c
index 412e1dc8..c1187cf6 100644
--- a/imap.c
+++ b/imap.c
@@ -607,7 +607,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
{
imap_version = IMAP4;
if (outlevel == O_VERBOSE)
- error(0, 0, "Protocol identified as IMAP4 rev 0");
+ error(0, 0, "Protocol identified as IMAP4 rev 0");
}
}
else if (ok == PS_ERROR)
@@ -622,11 +622,12 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
peek_capable = (imap_version >= IMAP4);
#if OPIE
- if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP")) {
- if (outlevel == O_VERBOSE)
- error(0, 0, "OTP authentication is supported");
- if (do_otp(sock, ctl) == PS_SUCCESS)
- return PS_SUCCESS;
+ if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP"))
+ {
+ if (outlevel == O_VERBOSE)
+ error(0, 0, "OTP authentication is supported");
+ if (do_otp(sock, ctl) == PS_SUCCESS)
+ return(PS_SUCCESS);
};
#endif /* OPIE */
diff --git a/socket.c b/socket.c
index 3ba58696..24f64af7 100644
--- a/socket.c
+++ b/socket.c
@@ -220,6 +220,12 @@ int SockPeek(int sock)
return(ch);
}
+int SockClose(int sock)
+/* close a socket (someday we may do other cleanup here) */
+{
+ return(close(sock));
+}
+
#ifdef MAIN
/*
* Use the chargen service to test input beuffering directly.
@@ -233,6 +239,7 @@ main()
while (SockRead(sock, buf, sizeof(buf)-1))
SockWrite(1, buf, strlen(buf));
+ SockClose(sock);
}
#endif /* MAIN */
diff --git a/socket.h b/socket.h
index 7e8441a8..89907745 100644
--- a/socket.h
+++ b/socket.h
@@ -43,4 +43,10 @@ int SockPrintf(int sock, char *format, ...) ;
int SockPrintf();
#endif
+/*
+Close a socket previously opened by SockOpen. This allows for some
+additional clean-up if necessary.
+*/
+int SockClose(int sock);
+
#endif /* SOCKET__ */