]> Pileus Git - ~andy/fetchmail/commitdiff
Yes! True stdio buffering at last!.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 16 Dec 1996 23:51:19 +0000 (23:51 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 16 Dec 1996 23:51:19 +0000 (23:51 -0000)
svn path=/trunk/; revision=632

socket.c
socket.h

index baf4c70aebebbd6bfc48cb2ca04d5f14f412cc6d..cfb93284bd50384ba2690c111f279587862d481d 100644 (file)
--- a/socket.c
+++ b/socket.c
 #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;
index 10a0a974728a3a10ad4dc143aa2eb22e38c111d8..1d9d05bcdf71a535e513acdc84e298441215599e 100644 (file)
--- 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__ */