]> Pileus Git - ~andy/fetchmail/blobdiff - smtp.c
Drop back to using SockGets/SockWrite.
[~andy/fetchmail] / smtp.c
diff --git a/smtp.c b/smtp.c
index 877e2e5ce0d9af85d17365b672605473cd23404d..a5be092779cde4c5d15985ae2c037dfd2b8f2f8c 100644 (file)
--- a/smtp.c
+++ b/smtp.c
 
 #include <stdio.h>
 #include <config.h>
-#include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
-#include "socket.h"
 #include "fetchmail.h"
+#include "socket.h"
 #include "smtp.h"
 
 int smtp_response;     /* numeric value of SMTP response code */
@@ -25,7 +24,7 @@ int SMTP_helo(FILE *sockfp,char *host)
 {
   int ok;
 
-  fprintf(sockfp,"HELO %s\r\n", host);
+  SockPrintf(sockfp,"HELO %s\r\n", host);
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP> HELO %s", host);
   ok = SMTP_ok(sockfp);
@@ -37,7 +36,7 @@ int SMTP_from(FILE *sockfp, char *from)
 {
   int ok;
 
-  fprintf(sockfp,"MAIL FROM:<%s>\r\n", from);
+  SockPrintf(sockfp,"MAIL FROM:<%s>\r\n", from);
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP> MAIL FROM:<%s>", from);
   ok = SMTP_ok(sockfp);
@@ -49,7 +48,7 @@ int SMTP_rcpt(FILE *sockfp, char *to)
 {
   int ok;
 
-  fprintf(sockfp,"RCPT TO:<%s>\r\n", to);
+  SockPrintf(sockfp,"RCPT TO:<%s>\r\n", to);
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP> RCPT TO:<%s>", to);
   ok = SMTP_ok(sockfp);
@@ -61,7 +60,7 @@ int SMTP_data(FILE *sockfp)
 {
   int ok;
 
-  fprintf(sockfp,"DATA\r\n");
+  SockPrintf(sockfp,"DATA\r\n");
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP> DATA");
   ok = SMTP_ok(sockfp);
@@ -73,7 +72,7 @@ int SMTP_quit(FILE *sockfp)
 {
   int ok;
 
-  fprintf(sockfp,"QUIT\r\n");
+  SockPrintf(sockfp,"QUIT\r\n");
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP> QUIT");
   ok = SMTP_ok(sockfp);
@@ -85,7 +84,7 @@ int SMTP_eom(FILE *sockfp)
 {
   int ok;
 
-  fprintf(sockfp,".\r\n");
+  SockPrintf(sockfp,".\r\n");
   if (outlevel == O_VERBOSE)
       error(0, 0, "SMTP>. (EOM)");
   ok = SMTP_ok(sockfp);
@@ -97,10 +96,14 @@ int SMTP_ok(FILE *sockfp)
 {
     char buf[SMTPBUFSIZE], *ip;
   
-    while ((ip = fgets(buf, sizeof(buf)-1, sockfp)))
+    while ((ip = SockGets(buf, sizeof(buf)-1, sockfp)))
     {
        int  n = strlen(ip);
 
+       if (buf[strlen(buf)-1] == '\n')
+           buf[strlen(buf)-1] = '\0';
+       if (buf[strlen(buf)-1] == '\r')
+           buf[strlen(buf)-1] = '\r';
        if (n < 4)
            return SM_ERROR;
        buf[n] = '\0';