From 04fdca88243f7c19378104764157026d74ce8a6c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 4 Nov 1996 15:58:08 +0000 Subject: True internal buffering with stdio! svn path=/trunk/; revision=478 --- driver.c | 13 ++++++------- smtp.c | 16 ++++++++-------- socket.c | 32 -------------------------------- 3 files changed, 14 insertions(+), 47 deletions(-) diff --git a/driver.c b/driver.c index 9063e865..58a0dfa8 100644 --- a/driver.c +++ b/driver.c @@ -621,8 +621,7 @@ struct query *ctl; /* query control record */ /* * We go through this in order to be able to handle very - * long lists of users and (re -)implement %s. + * long lists of users and (re)implement %s. */ for (idp = xmit_names; idp; idp = idp->next) nlocals++; @@ -713,7 +712,7 @@ struct query *ctl; /* query control record */ if (ctl->mda[0]) n = write(mboxfd,headers,oldlen); else - n = SockWrite(headers, oldlen, sinkfp); + n = fwrite(headers, sizeof(char), oldlen, sinkfp); if (n < 0) { @@ -730,7 +729,7 @@ struct query *ctl; /* query control record */ /* SMTP byte-stuffing */ if (*bufp == '.' && ctl->mda[0] == 0) - SockWrite(".", 1, sinkfp); + fwrite(".", sizeof(char), 1, sinkfp); /* replace all LFs with CR-LF in the line */ if (!ctl->mda[0]) @@ -747,7 +746,7 @@ struct query *ctl; /* query control record */ if (ctl->mda[0]) n = write(mboxfd,bufp,strlen(bufp)); else - n = SockWrite(bufp, strlen(bufp), sinkfp); + n = fwrite(bufp, sizeof(char), strlen(bufp), sinkfp); if (!ctl->mda[0]) free(bufp); @@ -1092,7 +1091,7 @@ va_dcl { va_end(ap); strcat(buf, "\r\n"); - SockWrite(buf, strlen(buf), sockfp); + fputs(buf, sockfp); if (outlevel == O_VERBOSE) { @@ -1134,7 +1133,7 @@ va_dcl { va_end(ap); strcat(buf, "\r\n"); - SockWrite(buf, strlen(buf), sockfp); + fputs(buf, sockfp); if (outlevel == O_VERBOSE) { char *cp; diff --git a/smtp.c b/smtp.c index f1908f81..558c32b5 100644 --- a/smtp.c +++ b/smtp.c @@ -22,7 +22,7 @@ int SMTP_helo(FILE *sockfp,char *host) { int ok; - SockPrintf(sockfp,"HELO %s\r\n", host); + fprintf(sockfp,"HELO %s\r\n", host); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> HELO %s\n", host); ok = SMTP_ok(sockfp,NULL); @@ -34,7 +34,7 @@ int SMTP_from(FILE *sockfp, char *from) { int ok; - SockPrintf(sockfp,"MAIL FROM:<%s>\r\n", from); + fprintf(sockfp,"MAIL FROM:<%s>\r\n", from); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> MAIL FROM:<%s>\n", from); ok = SMTP_ok(sockfp,NULL); @@ -46,7 +46,7 @@ int SMTP_rcpt(FILE *sockfp, char *to) { int ok; - SockPrintf(sockfp,"RCPT TO:<%s>\r\n", to); + fprintf(sockfp,"RCPT TO:<%s>\r\n", to); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> RCPT TO:<%s>\n", to); ok = SMTP_ok(sockfp,NULL); @@ -58,7 +58,7 @@ int SMTP_data(FILE *sockfp) { int ok; - SockPrintf(sockfp,"DATA\r\n"); + fprintf(sockfp,"DATA\r\n"); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> DATA\n"); ok = SMTP_ok(sockfp,NULL); @@ -70,7 +70,7 @@ int SMTP_quit(FILE *sockfp) { int ok; - SockPrintf(sockfp,"QUIT\r\n"); + fprintf(sockfp,"QUIT\r\n"); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> QUIT\n"); ok = SMTP_ok(sockfp,NULL); @@ -82,7 +82,7 @@ int SMTP_eom(FILE *sockfp) { int ok; - SockPrintf(sockfp,".\r\n"); + fprintf(sockfp,".\r\n"); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP>. (EOM)\n"); ok = SMTP_ok(sockfp,NULL); @@ -92,7 +92,7 @@ int SMTP_eom(FILE *sockfp) void SMTP_rset(FILE *sockfp) /* send a "RSET" message to the SMTP listener */ { - SockPrintf(sockfp,"RSET\r\n"); + fprintf(sockfp,"RSET\r\n"); if (outlevel == O_VERBOSE) fprintf(stderr, "SMTP> RSET\n"); } @@ -106,7 +106,7 @@ static int SMTP_check(FILE *sockfp,char *argbuf) if ((ok = SockGets(buf, sizeof(buf)-1, sockfp)) > 0) { buf[ok] = '\0'; if (outlevel == O_VERBOSE) - fprintf(stderr, "SMTP< %s", buf); + fprintf(stderr, "SMTP< %s\n", buf); if (argbuf) strcpy(argbuf,buf); if (buf[0] == '1' || buf[0] == '2' || buf[0] == '3') diff --git a/socket.c b/socket.c index c4ef1513..974fd70e 100644 --- a/socket.c +++ b/socket.c @@ -66,38 +66,6 @@ int clientPort; return sockfp; } -#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); - -} - -int SockWrite(buf,len,sockfp) -char *buf; -int len; -FILE *sockfp; -{ - return(fputs(buf, sockfp)); -} - int SockGets(buf, len, sockfp) char *buf; int len; -- cgit v1.2.3