diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-01-16 03:29:34 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-01-16 03:29:34 +0000 |
commit | 2dd66a8c50f85adcd210b1d482ed1d5ef6e06142 (patch) | |
tree | 9aa0abbe1b7f3cc3e60e90f9c10fbba2dbeaed0f | |
parent | e89983bc0f308b578d025cc84ef85d00ac9b97fb (diff) | |
download | fetchmail-2dd66a8c50f85adcd210b1d482ed1d5ef6e06142.tar.gz fetchmail-2dd66a8c50f85adcd210b1d482ed1d5ef6e06142.tar.bz2 fetchmail-2dd66a8c50f85adcd210b1d482ed1d5ef6e06142.zip |
One step towards proper continuation handling.
svn path=/trunk/; revision=774
-rw-r--r-- | driver.c | 15 | ||||
-rw-r--r-- | socket.c | 12 | ||||
-rw-r--r-- | socket.h | 5 |
3 files changed, 28 insertions, 4 deletions
@@ -329,7 +329,7 @@ char *realname; /* real name of host */ char buf [MSGBUFSIZE+1]; char *bufp, *headers, *fromhdr,*tohdr,*cchdr,*bcchdr,*received_for,*envto; char *fromptr, *toptr; - int n, oldlen; + int n, oldlen, ch; int inheaders,lines,sizeticker; FILE *sinkfp; RETSIGTYPE (*sigchld)(); @@ -345,10 +345,17 @@ char *realname; /* real name of host */ oldlen = 0; while (delimited || len > 0) { - if (!SockGets(buf,sizeof(buf),sockfp)) - return(PS_SOCKET); + buf[0] = '\0'; + do { + if (!SockGets(buf+strlen(buf), sizeof(buf)-strlen(buf)-1, sockfp)) + return(PS_SOCKET); + vtalarm(ctl->server.timeout); + } while + /* we may need to grab RFC822 continuations */ + (inheaders && (ch = SockPeek(sockfp)) == ' ' || ch == '\t'); + + /* compute length *before* squeezing out CRs */ n = strlen(buf); - vtalarm(ctl->server.timeout); /* squeeze out all carriage returns */ for (fromptr = toptr = buf; *fromptr; fromptr++) @@ -136,6 +136,18 @@ char *SockGets(char *buf, int len, FILE *sockfp) return buf; } +int SockPeek(FILE *sockfp) +/* peek at the next socket character without actually reading it */ +{ + int n; + char ch; + + if ((n = recv(fileno(sockfp), &ch, 1, MSG_PEEK)) == -1) + return -1; + else + return(ch); +} + #ifdef MAIN /* * Use the chargen service to test input beuffering directly. @@ -19,6 +19,11 @@ returns buffer on success, NULL on failure. char *SockGets(char *buf, int len, FILE *sockfp); /* + * Peek at the next socket character without actually reading it. + */ +int SockPeek(FILE *sockfp); + +/* Write a chunk of bytes to the socket (matches interface of fwrite). Returns number of bytes successfully written. */ |