From 45cc66a611304748f4f2e2d38d8eb00527c93d3e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 4 Nov 1996 17:00:46 +0000 Subject: Eliminated socket.h. svn path=/trunk/; revision=480 --- Makefile.in | 2 +- driver.c | 24 ++++++++++++++++++++++-- fetchmail.h | 2 ++ imap.c | 1 - pop2.c | 1 - pop3.c | 1 - smtp.c | 1 - socket.c | 30 ++++++------------------------ 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Makefile.in b/Makefile.in index a1524a0a..96c4013e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -204,7 +204,7 @@ $(srcdir)/rcfile_l.c: $(srcdir)/rcfile_l.l $(srcdir)/rcfile_y.c: $(srcdir)/rcfile_y.y parser = $(srcdir)/rcfile_l.l $(srcdir)/rcfile_y.y -headers = $(srcdir)/fetchmail.h $(srcdir)/socket.h $(srcdir)/smtp.h \ +headers = $(srcdir)/fetchmail.h $(srcdir)/smtp.h \ $(srcdir)/mx.h $(srcdir)/md5.h $(srcdir)/md5global.h extra = $(srcdir)/alloca.c $(srcdir)/getopt.[ch] $(srcdir)/getopt1.c \ $(srcdir)/strcasecmp.c diff --git a/driver.c b/driver.c index 58a0dfa8..0c20746b 100644 --- a/driver.c +++ b/driver.c @@ -36,7 +36,6 @@ #include /* must be included before "socket.h".*/ #include #endif /* KERBEROS_V4 */ -#include "socket.h" #include "fetchmail.h" #include "smtp.h" @@ -486,6 +485,27 @@ struct query *ctl; return(ctl->smtp_sockfp); } +static int strip_gets(buf, len, sockfp) +/* get a line of input, stripping out \r and \n */ +char *buf; +int len; +FILE *sockfp; +{ + if (fgets(buf, len, sockfp) == (char *)NULL) + return(-1); + else + { + char *sp, *tp; + + for (tp = sp = buf; *sp; sp++) + if (*sp != '\r' && *sp != '\n') + *tp++ = *sp; + *tp++ = '\0'; + + return(strlen(buf)); + } +} + static int gen_readmsg (sockfp, len, delimited, ctl) /* read message content and ship to SMTP or MDA */ FILE *sockfp; /* to which the server is connected */ @@ -507,7 +527,7 @@ struct query *ctl; /* query control record */ oldlen = 0; while (delimited || len > 0) { - if ((n = SockGets(buf,sizeof(buf),sockfp)) < 0) + if ((n = strip_gets(buf,sizeof(buf),sockfp)) < 0) return(PS_SOCKET); vtalarm(ctl->timeout); diff --git a/fetchmail.h b/fetchmail.h index eaf11fb0..ee28098a 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -186,6 +186,8 @@ int openmailpipe (char **); int closemailpipe(int); int daemonize(const char *, void (*)(int)); +FILE *Socket(char *, int); + int prc_parse_file(const char *); int prc_filecheck(const char *); diff --git a/imap.c b/imap.c index bb2e01bd..3ff1a57c 100644 --- a/imap.c +++ b/imap.c @@ -13,7 +13,6 @@ #if defined(STDC_HEADERS) #include #endif -#include "socket.h" #include "fetchmail.h" static int count, seen, recent, unseen; diff --git a/pop2.c b/pop2.c index 075ef22e..2a7d4839 100644 --- a/pop2.c +++ b/pop2.c @@ -11,7 +11,6 @@ #if defined(STDC_HEADERS) #include #endif -#include "socket.h" #include "fetchmail.h" static int pound_arg, equal_arg; diff --git a/pop3.c b/pop3.c index 4f8f35f7..4e5afe4b 100644 --- a/pop3.c +++ b/pop3.c @@ -15,7 +15,6 @@ #include #endif -#include "socket.h" #include "fetchmail.h" #define PROTOCOL_ERROR {fputs("fetchmail: protocol error\n", stderr); return(PS_ERROR);} diff --git a/smtp.c b/smtp.c index 66d47f81..1f509a48 100644 --- a/smtp.c +++ b/smtp.c @@ -13,7 +13,6 @@ #include #include #include -#include "socket.h" #include "fetchmail.h" #include "smtp.h" diff --git a/socket.c b/socket.c index 974fd70e..08f660ad 100644 --- a/socket.c +++ b/socket.c @@ -17,12 +17,14 @@ #if defined(HAVE_UNISTD_H) #include #endif -#if defined(HAVE_STDARG_H) -#include + +#ifndef INADDR_NONE +#ifdef INADDR_BROADCAST +#define INADDR_NONE INADDR_BROADCAST #else -#include +#define INADDR_NONE -1 +#endif #endif -#include "socket.h" #define INTERNAL_BUFSIZE 2048 @@ -66,24 +68,4 @@ int clientPort; return sockfp; } -int SockGets(buf, len, sockfp) -char *buf; -int len; -FILE *sockfp; -{ - if (fgets(buf, len, sockfp) == (char *)NULL) - return(-1); - else - { - char *sp, *tp; - - for (tp = sp = buf; *sp; sp++) - if (*sp != '\r' && *sp != '\n') - *tp++ = *sp; - *tp++ = '\0'; - - return(strlen(buf)); - } -} - /* socket.c ends here */ -- cgit v1.2.3