aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-31 06:29:49 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-31 06:29:49 +0000
commita2278043c64feb80565c1a6bf6456c687f5a5923 (patch)
treee3d0624b23dd944f88fefb3e2de4b2f0d8359515
parentb3c486c6c25027081cdc4015cd7b2e5d6f05ab8d (diff)
downloadfetchmail-a2278043c64feb80565c1a6bf6456c687f5a5923.tar.gz
fetchmail-a2278043c64feb80565c1a6bf6456c687f5a5923.tar.bz2
fetchmail-a2278043c64feb80565c1a6bf6456c687f5a5923.zip
STEP 3: File pointer arguments in SockGets()/SockPuts().
svn path=/trunk/; revision=446
-rw-r--r--driver.c6
-rw-r--r--imap.c8
-rw-r--r--pop2.c2
-rw-r--r--pop3.c6
-rw-r--r--socket.c73
5 files changed, 18 insertions, 77 deletions
diff --git a/driver.c b/driver.c
index 9e5b6f56..5402fba9 100644
--- a/driver.c
+++ b/driver.c
@@ -506,7 +506,7 @@ struct query *ctl; /* query control record */
oldlen = 0;
while (delimited || len > 0)
{
- if ((n = SockGets(fileno(sockfp),buf,sizeof(buf))) < 0)
+ if ((n = SockGets(buf,sizeof(buf),sockfp)) < 0)
return(PS_SOCKET);
vtalarm(ctl->timeout);
@@ -1073,7 +1073,7 @@ va_dcl {
vsprintf(buf + strlen(buf), fmt, ap);
va_end(ap);
- SockPuts(fileno(sockfp), buf);
+ SockPuts(buf, sockfp);
if (outlevel == O_VERBOSE)
{
@@ -1114,7 +1114,7 @@ va_dcl {
vsprintf(buf + strlen(buf), fmt, ap);
va_end(ap);
- SockPuts(fileno(sockfp), buf);
+ SockPuts(buf, sockfp);
if (outlevel == O_VERBOSE)
{
char *cp;
diff --git a/imap.c b/imap.c
index 1c64bdc6..b0e39936 100644
--- a/imap.c
+++ b/imap.c
@@ -27,7 +27,7 @@ FILE *sockfp;
seen = 0;
do {
- if (SockGets(fileno(sockfp), buf, sizeof(buf)) < 0)
+ if (SockGets(buf, sizeof(buf), sockfp) < 0)
return(PS_SOCKET);
if (outlevel == O_VERBOSE)
@@ -121,7 +121,7 @@ int *sizes;
char buf [POPBUFSIZE+1];
gen_send(sockfp, "FETCH 1:%d RFC822.SIZE", count);
- while (SockGets(fileno(sockfp), buf, sizeof(buf)) >= 0)
+ while (SockGets(buf, sizeof(buf), sockfp) >= 0)
{
int num, size;
@@ -165,7 +165,7 @@ int *lenp;
/* looking for FETCH response */
do {
- if (SockGets(fileno(sockfp), buf,sizeof(buf)) < 0)
+ if (SockGets(buf, sizeof(buf), sockfp) < 0)
return(PS_SOCKET);
} while
(sscanf(buf+2, "%d FETCH (RFC822 {%d}", &num, lenp) != 2);
@@ -184,7 +184,7 @@ int number;
{
char buf [POPBUFSIZE+1];
- if (SockGets(fileno(sockfp), buf,sizeof(buf)) < 0)
+ if (SockGets(buf, sizeof(buf), sockfp) < 0)
return(PS_SOCKET);
else
return(0);
diff --git a/pop2.c b/pop2.c
index 67313f88..a501c624 100644
--- a/pop2.c
+++ b/pop2.c
@@ -25,7 +25,7 @@ char *argbuf;
char buf [POPBUFSIZE+1];
pound_arg = equal_arg = -1;
- if (SockGets(fileno(sockfp), buf, sizeof(buf)) >= 0) {
+ if (SockGets(buf, sizeof(buf), sockfp) >= 0) {
if (outlevel == O_VERBOSE)
fprintf(stderr,"%s\n",buf);
diff --git a/pop3.c b/pop3.c
index 74173c1f..0960085d 100644
--- a/pop3.c
+++ b/pop3.c
@@ -31,7 +31,7 @@ char *argbuf;
char buf [POPBUFSIZE+1];
char *bufp;
- if (SockGets(fileno(sockfp), buf, sizeof(buf)) >= 0) {
+ if (SockGets(buf, sizeof(buf), sockfp) >= 0) {
if (outlevel == O_VERBOSE)
fprintf(stderr,"%s\n",buf);
@@ -171,7 +171,7 @@ int *countp, *newp;
int num;
*newp = 0;
- while (SockGets(fileno(sockfp), buf, sizeof(buf)) >= 0)
+ while (SockGets(buf, sizeof(buf), sockfp) >= 0)
{
if (outlevel == O_VERBOSE)
fprintf(stderr,"%s\n",buf);
@@ -205,7 +205,7 @@ int *sizes;
{
char buf [POPBUFSIZE+1];
- while (SockGets(fileno(sockfp), buf, sizeof(buf)) >= 0)
+ while (SockGets(buf, sizeof(buf), sockfp) >= 0)
{
int num, size;
diff --git a/socket.c b/socket.c
index 5033ed45..dff4be58 100644
--- a/socket.c
+++ b/socket.c
@@ -77,15 +77,15 @@ int clientPort;
return sock;
}
-int SockPuts(socket,buf)
-int socket;
+int SockPuts(buf, sockfp)
char *buf;
+FILE *sockfp;
{
int rc;
- if ((rc = SockWrite(socket, buf, strlen(buf))) != 0)
+ if ((rc = SockWrite(fileno(sockfp), buf, strlen(buf))) != 0)
return rc;
- return SockWrite(socket, "\r\n", 2);
+ return SockWrite(fileno(sockfp), "\r\n", 2);
}
int SockWrite(socket,buf,len)
@@ -172,16 +172,16 @@ int len;
return 0;
}
-int SockGets(socket,buf,len)
-int socket;
+int SockGets(buf, len, sockfp)
char *buf;
int len;
+FILE *sockfp;
{
int rdlen = 0;
while (--len)
{
- if (SockInternalRead(socket, buf, 1) != 1)
+ if (SockInternalRead(fileno(sockfp), buf, 1) != 1)
return -1;
else
rdlen++;
@@ -194,65 +194,6 @@ int len;
return rdlen;
}
-/* SockDataWaiting: Return a non-zero value if this socket is waiting
- for data. */
-int SockDataWaiting(int socket)
-{
- int flags;
- char sbuf[INTERNAL_BUFSIZE];
- int n;
- flags = fcntl(socket,F_GETFL,0);
-
- /* set it to non-block */
- if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
- return -1;
-
- n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK);
-
- /* reset it to block (or, whatever it was). */
- fcntl(socket,F_SETFL,flags);
-
- if (n == -1)
- {
- /* No data to read. */
- if (errno == EWOULDBLOCK)
- return(0);
- else
- return(-1);
- }
- else
- return(n);
-}
-
-
-/* SockClearHeader: call this procedure in order to kill off any
- forthcoming Header info from the socket that we no longer want.
- */
-int SockClearHeader(socket)
-int socket;
-{
- char *bufp;
- static char sbuf[INTERNAL_BUFSIZE];
- int res;
-
- if ((res = SockDataWaiting(socket)) <= 0)
- return res;
-
- while (1)
- {
- if (SockGets(socket,sbuf,INTERNAL_BUFSIZE) < 0)
- return 0;
- bufp = sbuf;
- if (*bufp == '.') {
- bufp++;
- if (*bufp == 0)
- break;
- }
- }
- sbuflen = 0;
- return 0;
-}
-
#if defined(HAVE_STDARG_H)
int SockPrintf(int socket, char* format, ...)
{