From 2065c80c50dcd792d299ec7b4ab4887e1cb67768 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Apr 2000 06:59:47 +0000 Subject: BeOS support. svn path=/trunk/; revision=2866 --- Makefile.in | 5 ++-- NEWS | 1 + README | 10 +++---- checkalias.c | 12 ++++++-- configure.in | 1 + driver.c | 8 ++++- env.c | 3 ++ etrn.c | 3 ++ fetchmail-features.html | 7 +++-- fetchmail.c | 5 +++- fetchmail.h | 2 +- getpass.c | 2 +- mxget.c | 13 ++++++++ rcfile_y.y | 2 ++ socket.c | 79 +++++++++++++++++++++++++++++++++++++------------ 15 files changed, 118 insertions(+), 35 deletions(-) diff --git a/Makefile.in b/Makefile.in index ab6b373f..29a1c86c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ # So just uncomment all the lines marked QNX. PACKAGE = fetchmail -VERSION = 5.3.5 +VERSION = 5.3.6 SUBDIRS = @INTLSUB@ @POSUB@ @@ -250,7 +250,8 @@ scripts = $(srcdir)/install.sh $(srcdir)/mkinstalldirs \ $(srcdir)/specgen.sh $(srcdir)/lsmgen.sh $(srcdir)/fetchmailconf all = $(docs) $(config) $(srcs) $(parser) $(headers) $(extra) $(scripts) \ $(srcdir)/rh-config/* $(srcdir)/debian/* $(srcdir)/contrib/*[A-Za-uw-z] \ - $(srcdir)/intl/* $(srcdir)/po/* ABOUT-NLS $(srcdir)/MANIFEST + $(srcdir)/intl/* $(srcdir)/po/* $(srcdir)/beos/* ABOUT-NLS \ + $(srcdir)/MANIFEST MANIFEST: $(srcdir) Makefile.in @echo $(all) | tr "[ \t]" '\n' | sed -e '/^\.\//s///' | sort >MANIFEST diff --git a/NEWS b/NEWS index e68fdea9..db40118a 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ * French internationalization update from Guy Brand. * IMAP PREAUTH fix from Todd Sabin . * Uwe Girlich's lexical fix for dealing with all-numeric usernames. +* Fetchmail now runs on BeOS, thanks to David Reid . fetchmail-5.3.5 (Wed Mar 29 18:17:19 EST 2000), 18840 lines: diff --git a/README b/README index 41cc71ab..5f967a14 100644 --- a/README +++ b/README @@ -19,12 +19,10 @@ extensively tested under the BSD variants, AIX, HP-UX versions 9 and 10, SunOS, Solaris, NEXTSTEP, OSF 3.2, IRIX, and Rhapsody. It should be readily portable to other Unix variants (it uses GNU -autoconf). It has been ported to LynxOS and will build there without -special action. It has also been ported to QNX; to build under QNX, -see the header comments in the Makefile. It is reported to build and -run under AmigaOS. - -Fetchmail is Y2K safe. +autoconf). It has been ported to LynxOS and BeOS and will build there +without special action. It has also been ported to QNX; to build +under QNX, see the header comments in the Makefile. It is reported to +build and run under AmigaOS. See the distribution files FEATURES for a full list of features, NEWS for detailed information on recent changes, NOTES for design notes, and diff --git a/checkalias.c b/checkalias.c index 28d7861f..5b8b6744 100644 --- a/checkalias.c +++ b/checkalias.c @@ -10,9 +10,15 @@ #include #include #include +#ifdef HAVE_NET_SOCKET_H +#include +#else #include +#endif #include +#ifdef HAVE_ARPA_INET_H #include +#endif #include #include "i18n.h" #include "mx.h" @@ -180,9 +186,10 @@ int is_host_alias(const char *name, struct query *ctl) switch (h_errno) { case HOST_NOT_FOUND: /* specified host is unknown */ +#ifndef __BEOS__ case NO_ADDRESS: /* valid, but does not have an IP address */ break; - +#endif case NO_RECOVERY: /* non-recoverable name server error */ case TRY_AGAIN: /* temporary error on authoritative server */ default: @@ -206,10 +213,11 @@ int is_host_alias(const char *name, struct query *ctl) switch (h_errno) { case HOST_NOT_FOUND: /* specified host is unknown */ +#ifndef __BEOS__ case NO_ADDRESS: /* valid, but does not have an IP address */ return(FALSE); break; - +#endif case NO_RECOVERY: /* non-recoverable name server error */ case TRY_AGAIN: /* temporary error on authoritative server */ default: diff --git a/configure.in b/configure.in index cec89b54..134e43dc 100644 --- a/configure.in +++ b/configure.in @@ -24,6 +24,7 @@ AC_TYPE_SIZE_T AC_TYPE_PID_T AC_TYPE_SIGNAL AC_CHECK_HEADERS(unistd.h termios.h termio.h sgtty.h stdarg.h alloca.h sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h) +AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h resolv.h net/socket.h) AC_C_CONST dnl getopt needs this. diff --git a/driver.c b/driver.c index 26ff2879..36a3fc88 100644 --- a/driver.c +++ b/driver.c @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_NET_SOCKET_H +#include +#endif + #ifdef HAVE_RES_SEARCH #include #include "mx.h" @@ -98,7 +102,7 @@ static int msglen; /* actual message length */ void set_timeout(int timeleft) /* reset the nonresponse-timeout */ { -#ifndef __EMX__ +#if !defined(__EMX__) && !defined(__BEOS__) struct itimerval ntimeout; if (timeleft == 0) @@ -1612,8 +1616,10 @@ const int maxfetch; /* maximum number of messages to fetch */ { if (h_errno == HOST_NOT_FOUND) strcpy(errbuf, _("host is unknown.")); +#ifndef __BEOS__ else if (h_errno == NO_ADDRESS) strcpy(errbuf, _("name is valid but has no IP address.")); +#endif else if (h_errno == NO_RECOVERY) strcpy(errbuf, _("unrecoverable name server error.")); else if (h_errno == TRY_AGAIN) diff --git a/env.c b/env.c index 355f3a16..6c455d58 100644 --- a/env.c +++ b/env.c @@ -16,6 +16,9 @@ #endif #include #include +#ifdef HAVE_NET_SOCKET_H +#include +#endif #ifdef HAVE_GETHOSTBYNAME #include #endif /* HAVE_GETHOSTBYNAME */ diff --git a/etrn.c b/etrn.c index 26035723..61e3fd9a 100644 --- a/etrn.c +++ b/etrn.c @@ -9,6 +9,9 @@ #include #include #include +#ifdef HAVE_NET_SOCKET_H /* BeOS needs this */ +#include +#endif #include #include #include diff --git a/fetchmail-features.html b/fetchmail-features.html index f9082515..794f3c18 100644 --- a/fetchmail-features.html +++ b/fetchmail-features.html @@ -10,7 +10,7 @@
Back to Fetchmail Home Page To Site Map -$Date: 2000/04/07 10:07:05 $ +$Date: 2000/04/08 06:59:44 $

@@ -18,6 +18,9 @@

Since 5.0:

    +
  • +Fetchmail now runs on BeOS, thanks to David Reid" . +
  • In IMAP, unseen-message counting and indexing is now done by SEARCH UNSEEN at the beginning of each poll or re-poll (rather than with @@ -208,7 +211,7 @@ get-mail, gwpop, pimp-1.0, pop-perl5-1.2, popc, popmail-1.6 and upop.

    Back to Fetchmail Home Page To Site Map -$Date: 2000/04/07 10:07:05 $ +$Date: 2000/04/08 06:59:44 $

    Eric S. Raymond <esr@snark.thyrsus.com>
    diff --git a/fetchmail.c b/fetchmail.c index f9db4261..f7428211 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -31,6 +31,9 @@ #endif /* HAVE_SETRLIMIT */ #include +#ifdef HAVE_NET_SOCKET_H +#include +#endif #ifdef HAVE_GETHOSTBYNAME #include #endif /* HAVE_GETHOSTBYNAME */ @@ -492,7 +495,7 @@ int main(int argc, char **argv) strlen(ctl->server.pollname) + 1); (void) sprintf(tmpbuf, password_prompt, ctl->remotename, ctl->server.pollname); - ctl->password = xstrdup((char *)getpassword(tmpbuf)); + ctl->password = xstrdup((char *)fm_getpassword(tmpbuf)); } } diff --git a/fetchmail.h b/fetchmail.h index cca85409..48e2dc63 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -507,7 +507,7 @@ int parsecmdline (int, char **, struct runctl *, struct query *); char *MD5Digest (unsigned char *); int POP3_auth_rpa(unsigned char *, unsigned char *, int socket); int daemonize(const char *, void (*)(int)); -char *getpassword(char *); +char *fm_getpassword(char *); void escapes(const char *, char *); char *visbuf(const char *); const char *showproto(int); diff --git a/getpass.c b/getpass.c index 8ec86a74..f89f32aa 100644 --- a/getpass.c +++ b/getpass.c @@ -60,7 +60,7 @@ void static disable_tty_echo(void); void static restore_tty_state(void); static RETSIGTYPE sigint_handler(int); -char *getpassword(prompt) +char *fm_getpassword(prompt) char *prompt; { #if !(defined(HAVE_TCSETATTR) || defined(HAVE_TERMIO_H) || defined(HAVE_STTY)) diff --git a/mxget.c b/mxget.c index 64e88f78..3bb6cd8c 100644 --- a/mxget.c +++ b/mxget.c @@ -9,11 +9,24 @@ #ifdef HAVE_RES_SEARCH #include #include +#ifdef HAVE_NET_SOCKET_H +#include +#endif #include #include #include + +#ifdef __BEOS__ +#include "beos/beos_nameser.h" +#endif + +#ifdef HAVE_ARPA_NAMESER_H #include +#endif +#ifdef HAVE_RESOLV_H #include +#endif + #include "mx.h" /* diff --git a/rcfile_y.y b/rcfile_y.y index d5633584..93d1c86e 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -405,12 +405,14 @@ int prc_filecheck(const char *pathname, const flag securecheck) return(PS_IOERR); } +#ifndef __BEOS__ if (statbuf.st_mode & ~(S_IFREG | S_IREAD | S_IWRITE | S_IEXEC | S_IXGRP)) { fprintf(stderr, "File %s must have no more than -rwx--x--- (0710) permissions.\n", pathname); return(PS_IOERR); } +#endif /* __BEOS__ */ #ifdef HAVE_GETEUID if (statbuf.st_uid != geteuid()) diff --git a/socket.c b/socket.c index 3d019e75..f95bae81 100644 --- a/socket.c +++ b/socket.c @@ -13,9 +13,15 @@ #include #endif /* HAVE_MEMORY_H */ #include +#ifndef HAVE_NET_SOCKET_H #include +#else +#include +#endif #include +#ifdef HAVE_ARPA_INET_H #include +#endif #include #if defined(STDC_HEADERS) #include @@ -32,6 +38,20 @@ #include "fetchmail.h" #include "i18n.h" +/* Defines to allow BeOS to play nice... */ +#ifdef __BEOS__ +static char peeked; +#define fm_close(a) closesocket(a) +#define fm_write(a,b,c) send(a,b,c,0) +#define fm_peek(a,b,c) recv(a,b,c,0) +#define fm_read(a,b,c) recv(a,b,c,0) +#else +#define fm_close(a) close(a) +#define fm_write(a,b,c) write(a,b,c) +#define fm_peek(a,b,c) recv(a,b,c, MSG_PEEK) +#define fm_read(a,b,c) read(a,b,c) +#endif + /* We need to define h_errno only if it is not already */ #ifndef h_errno @@ -164,7 +184,7 @@ int SockOpen(const char *host, const char *service, const char *options, if (i < 0) continue; if (connect(i, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) { - close(i); + fm_close(i); i = -1; continue; } @@ -230,7 +250,7 @@ int SockOpen(const char *host, int clientPort, const char *options, if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0) { int olderr = errno; - close(sock); /* don't use SockClose, no traffic yet */ + fm_close(sock); /* don't use SockClose, no traffic yet */ h_errno = 0; errno = olderr; return -1; @@ -276,19 +296,20 @@ int SockOpen(const char *host, int clientPort, const char *options, memcpy(&ad.sin_addr, *pptr, sizeof(struct in_addr)); if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) == 0) break; /* success */ - close(sock); /* don't use SockClose, no traffic yet */ + fm_close(sock); /* don't use SockClose, no traffic yet */ memset(&ad, 0, sizeof(ad)); ad.sin_family = AF_INET; } if(*pptr == NULL) { int olderr = errno; - close(sock); /* don't use SockClose, no traffic yet */ + fm_close(sock); /* don't use SockClose, no traffic yet */ h_errno = 0; errno = olderr; return -1; } } + return(sock); } #endif /* INET6_ENABLE */ @@ -347,9 +368,9 @@ int SockWrite(int sock, char *buf, int len) if( NULL != ( ssl = SSLGetContext( sock ) ) ) n = SSL_write(ssl, buf, len); else - n = write(sock, buf, len); + n = fm_write(sock, buf, len); #else - n = write(sock, buf, len); + n = fm_write(sock, buf, len); #endif if (n <= 0) return -1; @@ -370,6 +391,14 @@ int SockRead(int sock, char *buf, int len) if (--len < 1) return(-1); +#ifdef __BEOS__ + if (peeked != 0){ + (*bp) = peeked; + bp++; + len--; + peeked = 0; + } +#endif do { /* * The reason for these gymnastics is that we want two things: @@ -422,20 +451,27 @@ int SockRead(int sock, char *buf, int len) newline = bp; } } else { - if ((n = recv(sock, bp, len, MSG_PEEK)) <= 0) + if ((n = fm_peek(sock, bp, len)) <= 0) return(-1); if ((newline = memchr(bp, '\n', n)) != NULL) n = newline - bp + 1; - if ((n = read(sock, bp, n)) == -1) + if ((n = fm_read(sock, bp, n)) == -1) return(-1); } #else - if ((n = recv(sock, bp, len, MSG_PEEK)) <= 0) - return(-1); + +#ifdef __BEOS__ + if ((n = fm_read(sock, bp, 1)) <= 0) +#else + if ((n = fm_peek(sock, bp, len)) <= 0) +#endif + return (-1); if ((newline = memchr(bp, '\n', n)) != NULL) n = newline - bp + 1; - if ((n = read(sock, bp, n)) == -1) +#ifndef __BEOS__ + if ((n = fm_read(sock, bp, n)) == -1) return(-1); +#endif /* __BEOS__ */ #endif bp += n; len -= n; @@ -479,15 +515,20 @@ int SockPeek(int sock) return 0; /* Give him a '\0' character */ } } else { - n = recv(sock, &ch, 1, MSG_PEEK); + n = fm_peek(sock, &ch, 1); } #else - n = recv(sock, &ch, 1, MSG_PEEK); -#endif + + n = fm_peek(sock, &ch, 1); + +#endif /* SSL_ENABLE */ if (n == -1) return -1; - else - return(ch); + +#ifdef __BEOS__ + peeked = ch; +#endif + return(ch); } #ifdef SSL_ENABLE @@ -679,12 +720,12 @@ int SockClose(int sock) * or any error occurs. This makes sure all data sent by the other * side is acknowledged at the TCP level. */ - if (recv(sock, &ch, 1, MSG_PEEK) > 0) - while (read(sock, &ch, 1) > 0) + if (fm_peek(sock, &ch, 1) > 0) + while (fm_read(sock, &ch, 1) > 0) continue; /* if there's an error closing at this point, not much we can do */ - return(close(sock)); /* this is guarded */ + return(fm_close(sock)); /* this is guarded */ } #ifdef MAIN -- cgit v1.2.3