aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-12-16 23:51:19 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-12-16 23:51:19 +0000
commit9cafaabdf600ad984c19f2b5e98d052c2f9c3e39 (patch)
tree9f32923aebc88628de90ee024aa6d8ceacef8844
parentf9fe7d50774c40e7bc637500188c9e130be0ea0a (diff)
downloadfetchmail-9cafaabdf600ad984c19f2b5e98d052c2f9c3e39.tar.gz
fetchmail-9cafaabdf600ad984c19f2b5e98d052c2f9c3e39.tar.bz2
fetchmail-9cafaabdf600ad984c19f2b5e98d052c2f9c3e39.zip
Yes! True stdio buffering at last!.
svn path=/trunk/; revision=632
-rw-r--r--socket.c57
-rw-r--r--socket.h18
2 files changed, 17 insertions, 58 deletions
diff --git a/socket.c b/socket.c
index baf4c70a..cfb93284 100644
--- a/socket.c
+++ b/socket.c
@@ -34,6 +34,18 @@
#endif
#endif
+/*
+ * In case we ever optimize this further,
+ * a note on Carl Harris's original implementation said:
+ *
+ * Size of buffer for internal buffering read function
+ * don't increase beyond the maximum atomic read/write size for
+ * your sockets, or you'll take a potentially huge performance hit
+ *
+ * #define INTERNAL_BUFSIZE 2048
+ *
+ */
+
FILE *Socket(char *host, int clientPort)
{
int sock;
@@ -68,51 +80,6 @@ FILE *Socket(char *host, int clientPort)
}
-#if defined(HAVE_STDARG_H)
-int SockPrintf(FILE *sockfp, char* format, ...)
-{
-#else
-int SockPrintf(sockfp,format,va_alist)
-FILE *sockfp;
-char *format;
-va_dcl {
-#endif
-
- va_list ap;
- char buf[8192];
-
-#if defined(HAVE_STDARG_H)
- va_start(ap, format) ;
-#else
- va_start(ap);
-#endif
- vsprintf(buf, format, ap);
- va_end(ap);
- return SockWrite(buf, strlen(buf), sockfp);
-
-}
-
-/*
- * In case we ever optimize this further,
- * a note on Carl Harris's original implementation said:
- *
- * Size of buffer for internal buffering read function
- * don't increase beyond the maximum atomic read/write size for
- * your sockets, or you'll take a potentially huge performance hit
- *
- * #define INTERNAL_BUFSIZE 2048
- *
- */
-
-int SockWrite(char *buf, int len, FILE *sockfp)
-{
- int n;
-
- if ((n = fwrite(buf, 1, len, sockfp)) < 1)
- return -1;
- return n;
-}
-
int SockGets(char *buf, int len, FILE *sockfp)
{
int rdlen = 0;
diff --git a/socket.h b/socket.h
index 10a0a974..1d9d05bc 100644
--- a/socket.h
+++ b/socket.h
@@ -23,21 +23,13 @@ returns 0 for success.
*/
int SockGets(char *buf, int len, FILE *sockfp);
-/*
-Write a chunk of bytes to the socket.
-Returns 0 for success.
-*/
-int SockWrite(char *buf, int len, FILE *sockfp);
+/* Ship a character array to the socket */
+#define SockWrite(buf, len, sockfp) fwrite(buf, 1, len, sockfp)
/*
Send formatted output to the socket, followed
-by a CR-LF.
-Returns 0 for success.
+by a CR-LF. Returns 0 for success.
*/
-#if defined(HAVE_STDARG_H)
-int SockPrintf(FILE *sockfp, char *format, ...) ;
-#else
-int SockPrintf();
-#endif
-
+#define SockPrintf fprintf
+
#endif /* SOCKET__ */