From 0ba9411d4fa6e17ef377ea7602dd35166229e8f7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Jun 2000 08:56:07 +0000 Subject: Better file check for progress-to control. svn path=/trunk/; revision=2909 --- NEWS | 1 + daemon.c | 12 ++++++++++++ driver.c | 12 ++++++------ fetchmail.h | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index d71b5311..399e164c 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ * Julian Haight's fix for his 5.4.1 patch, which created a potential memory leak. * Minor bug fixes for SSL by Wolfram Kleff. +* Be more clever about when we suppress progress dots. fetchmail-5.4.1 (Tue Jun 6 23:24:22 EDT 2000), 19051 lines: diff --git a/daemon.c b/daemon.c index c588ae47..db6ee78b 100644 --- a/daemon.c +++ b/daemon.c @@ -205,4 +205,16 @@ nottyDetach: return(0); } +flag isafile(int fd) +/* is the given fd attached to a file? (used to control logging) */ +{ + struct stat stbuf; + + if (fstat(fd, &stbuf)) + return(0); + else if (stbuf.st_mode & (S_IFREG | S_IFBLK)) + return(1); + return(0); +} + /* daemon.c ends here */ diff --git a/driver.c b/driver.c index 1e80c2b8..267b33c1 100644 --- a/driver.c +++ b/driver.c @@ -533,7 +533,7 @@ static int readheaders(int sock, sizeticker += linelen; while (sizeticker >= SIZETICKER) { - if (!run.use_syslog && isatty(1)) + if (!run.use_syslog && !isafile(1)) { fputc('.', stdout); fflush(stdout); @@ -1060,7 +1060,7 @@ static int readheaders(int sock, free_str_list(&msgblk.recipients); return(PS_IOERR); } - else if ((run.poll_interval == 0 || nodetach) && outlevel >= O_VERBOSE && isatty(2)) + else if ((run.poll_interval == 0 || nodetach) && outlevel >= O_VERBOSE && !isafile(2)) fputs("#", stderr); /* write error notifications */ @@ -1170,7 +1170,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len) sizeticker += linelen; while (sizeticker >= SIZETICKER) { - if ((run.poll_interval == 0 || nodetach) && outlevel > O_SILENT && isatty(1)) + if ((run.poll_interval == 0 || nodetach) && outlevel > O_SILENT && !isafile(1)) { fputc('.', stdout); fflush(stdout); @@ -1228,7 +1228,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len) release_sink(ctl); return(PS_IOERR); } - else if (outlevel >= O_VERBOSE && isatty(1)) + else if (outlevel >= O_VERBOSE && !isafile(1)) { fputc('*', stdout); fflush(stdout); @@ -2050,7 +2050,7 @@ const int maxfetch; /* maximum number of messages to fetch */ */ if (protocol->fetch_body && !suppress_readbody) { - if (outlevel >= O_VERBOSE && isatty(1)) + if (outlevel >= O_VERBOSE && !isafile(1)) { fputc('\n', stdout); fflush(stdout); @@ -2104,7 +2104,7 @@ const int maxfetch; /* maximum number of messages to fetch */ /* tell server we got it OK and resynchronize */ if (protocol->trail) { - if (outlevel >= O_VERBOSE && isatty(1)) + if (outlevel >= O_VERBOSE && !isafile(1)) { fputc('\n', stdout); fflush(stdout); diff --git a/fetchmail.h b/fetchmail.h index fd5403ed..efb16e47 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -518,6 +518,7 @@ void dump_config(struct runctl *runp, struct query *querylist); int is_host_alias(const char *, struct query *); char *host_fqdn(void); char *rfc822timestamp(void); +flag isafile(int); void yyerror(const char *); int yylex(void); -- cgit v1.2.3