From 0fbe10e845265ca868969afcfd867ced865be804 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 1 Apr 2010 01:22:44 +0200 Subject: [PATCH] Remove some obsolete constructs... such as STDC_HEADERS, HAVE_UNISTD_H, termio.h, sgtty.h. --- conf.c | 4 --- configure.ac | 8 +++--- cram.c | 2 -- daemon.c | 55 +--------------------------------------- driver.c | 4 --- env.c | 4 --- fetchmail.c | 4 --- getpass.c | 71 +++------------------------------------------------- gssapi.c | 2 -- imap.c | 2 -- interface.c | 4 --- kerberos.c | 2 -- lock.c | 6 ----- md5ify.c | 3 --- opie.c | 2 -- options.c | 40 ----------------------------- pop3.c | 4 --- rcfile_y.y | 4 --- sink.c | 4 --- socket.c | 4 --- transact.c | 4 --- uid.c | 4 --- xmalloc.c | 2 -- 23 files changed, 7 insertions(+), 232 deletions(-) diff --git a/conf.c b/conf.c index 5b834be0..d21dec1c 100644 --- a/conf.c +++ b/conf.c @@ -9,12 +9,8 @@ #include #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #include #include diff --git a/configure.ac b/configure.ac index 44756c4d..99a45479 100644 --- a/configure.ac +++ b/configure.ac @@ -57,12 +57,11 @@ if test "x$SHELL" = "x" ; then fi -AC_HEADER_STDC AC_HEADER_TIME AC_TYPE_SIZE_T AC_TYPE_PID_T AC_TYPE_SIGNAL -AC_CHECK_HEADERS([unistd.h termios.h termio.h sgtty.h stdarg.h \ +AC_CHECK_HEADERS([stdarg.h \ sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h \ arpa/inet.h arpa/nameser.h netinet/in.h net/socket.h netdb.h \ sys/select.h sys/socket.h sys/time.h langinfo.h md5.h]) @@ -261,7 +260,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include #ifdef WEXITSTATUS /* Some POSIXoid systems have both the new-style macros and the old union wait type, and they do not work together. If union wait - conflicts with WEXITSTATUS et al, we don't want to use it at all. */ + conflicts with WEXITSTATUS et al, we do not want to use it at all. */ if (WEXITSTATUS (status) != 0) pid = -1; #endif #ifdef HAVE_WAITPID @@ -273,9 +272,8 @@ pid = waitpid (-1, &status, 0); AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include /* NetBSD declares sys_siglist in . */ -#ifdef HAVE_UNISTD_H #include -#endif]], [[char *msg = *(sys_siglist + 1);]])],[AC_DEFINE(SYS_SIGLIST_DECLARED,1,[Define if 'sys_siglist' is declared by .]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]) +]], [[char *msg = *(sys_siglist + 1);]])],[AC_DEFINE(SYS_SIGLIST_DECLARED,1,[Define if 'sys_siglist' is declared by .]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]) # Find the right directory to put the root-mode PID file in for dir in "/var/run" "/etc" diff --git a/cram.c b/cram.c index cf33393e..3c5630df 100644 --- a/cram.c +++ b/cram.c @@ -8,9 +8,7 @@ #include #include #include -#if defined(STDC_HEADERS) #include -#endif #include "fetchmail.h" #include "socket.h" diff --git a/daemon.c b/daemon.c index e96abb4b..696d5332 100644 --- a/daemon.c +++ b/daemon.c @@ -23,27 +23,11 @@ #endif /* !HAVE_FCNTL_H */ #include /* get umask(2) prototyped */ -#if defined(HAVE_UNISTD_H) #include -#endif -#if defined(STDC_HEADERS) #include -#endif - -#if defined(QNX) -#include -#endif -#if !defined(HAVE_SETSID) && defined(SIGTSTP) -#if defined(HAVE_TERMIOS_H) -# include /* for TIOCNOTTY under Linux */ -#endif - -#if !defined(TIOCNOTTY) && defined(HAVE_SGTTY_H) -# include /* for TIOCNOTTY under NEXTSTEP */ -#endif -#endif /* !defined(HAVE_SETSID) && defined(SIGTSTP) */ +#include /* for TIOCNOTTY under Linux */ /* BSD portability hack */ #if !defined(SIGCHLD) && defined(SIGCLD) @@ -92,37 +76,23 @@ SIGHANDLERTYPE set_signal_handler(int sig, SIGHANDLERTYPE handler) */ { SIGHANDLERTYPE rethandler; -#ifdef HAVE_SIGACTION struct sigaction sa_new, sa_old; memset (&sa_new, 0, sizeof sa_new); sigemptyset (&sa_new.sa_mask); sa_new.sa_handler = handler; sa_new.sa_flags = 0; -#ifdef SA_RESTART /* SunOS 4.1 portability hack */ /* system call should restart on all signals except SIGALRM */ if (sig != SIGALRM) sa_new.sa_flags |= SA_RESTART; -#endif -#ifdef SA_NOCLDSTOP /* SunOS 4.1 portability hack */ if (sig == SIGCHLD) sa_new.sa_flags |= SA_NOCLDSTOP; -#endif sigaction(sig, &sa_new, &sa_old); rethandler = sa_old.sa_handler; #if defined(SIGPWR) if (sig == SIGCHLD) sigaction(SIGPWR, &sa_new, NULL); #endif -#else /* HAVE_SIGACTION */ - rethandler = signal(sig, handler); -#if defined(SIGPWR) - if (sig == SIGCHLD) - signal(SIGPWR, handler); -#endif - /* system call should restart on all signals except SIGALRM */ - siginterrupt(sig, sig == SIGALRM); -#endif /* HAVE_SIGACTION */ return rethandler; } @@ -170,34 +140,11 @@ daemonize (const char *logfile) /* Make ourselves the leader of a new process group with no controlling terminal */ -#if defined(HAVE_SETSID) /* POSIX */ /* POSIX makes this soooo easy to do */ if (setsid() < 0) { report(stderr, "setsid (%s)\n", strerror(errno)); return(PS_IOERR); } -#elif defined(SIGTSTP) /* BSD */ - /* change process group */ - setpgrp(0, getpid()); - /* lose controlling tty */ - if ((fd = open("/dev/tty", O_RDWR)) >= 0) { - ioctl(fd, TIOCNOTTY, (char *) 0); - close(fd); /* not checking should be safe, there were no writes */ - } -#else /* SVR3 and older */ - /* change process group */ - setpgrp(); - - /* lose controlling tty */ - set_signal_handler(SIGHUP, SIG_IGN); - if ((childpid = fork()) < 0) { - report(stderr, "fork (%s)\n", strerror(errno)); - return(PS_IOERR); - } - else if (childpid > 0) { - exit(0); /* parent */ - } -#endif nottyDetach: diff --git a/driver.c b/driver.c index 2e4169cb..a086d150 100644 --- a/driver.c +++ b/driver.c @@ -13,13 +13,9 @@ #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ -#if defined(STDC_HEADERS) #include #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #if defined(HAVE_SYS_ITIMER_H) #include #endif diff --git a/env.c b/env.c index 3795460d..8293ad5f 100644 --- a/env.c +++ b/env.c @@ -8,12 +8,8 @@ #include "config.h" #include #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #include #ifdef HAVE_NET_SOCKET_H diff --git a/fetchmail.c b/fetchmail.c index 2523f2bc..4d1e7134 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -6,12 +6,8 @@ #include "config.h" #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #include #include diff --git a/getpass.c b/getpass.c index 3c19ba7c..c3e9723e 100644 --- a/getpass.c +++ b/getpass.c @@ -18,43 +18,18 @@ #include #include #include -#if defined(HAVE_UNISTD_H) #include -#endif #include "fetchmail.h" #include "i18n.h" #define INPUT_BUF_SIZE PASSWORDLEN -#if defined(HAVE_TERMIOS_H) && defined(HAVE_TCSETATTR) -# include -#else -#if defined(HAVE_TERMIO_H) -# include -# include -#else -#if defined(HAVE_SGTTY_H) -# include -#endif -#endif -#endif +#include static int ttyfd; -#if defined(HAVE_TCSETATTR) - static struct termios termb; - static tcflag_t flags; -#else -#if defined(HAVE_TERMIO_H) - static struct termio termb; - static unsigned short flags; -#else -#if defined(HAVE_STTY) - static struct sgttyb ttyb; - static int flags; -#endif -#endif -#endif +static struct termios termb; +static tcflag_t flags; static void save_tty_state(void); static void disable_tty_echo(void); @@ -63,15 +38,6 @@ static RETSIGTYPE sigint_handler(int); char *fm_getpassword(char *prompt) { -#if !(defined(HAVE_TCSETATTR) || defined(HAVE_TERMIO_H) || defined(HAVE_STTY)) -#if defined(HAVE_GETPASS) - char *getpass(); - return getpass(prompt); -#else - fputs(GT_("ERROR: no support for getpassword() routine\n"),stderr); - exit(1); -#endif -#else register char *p; register int c; FILE *fi; @@ -133,57 +99,26 @@ char *fm_getpassword(char *prompt) fclose(fi); /* not checking should be safe, file mode was "r" */ return(pbuf); -#endif /* !(defined(HAVE_TCSETATTR) || ... */ } static void save_tty_state (void) { -#if defined(HAVE_TCSETATTR) tcgetattr(ttyfd, &termb); flags = termb.c_lflag; -#else -#if defined(HAVE_TERMIO_H) - ioctl(ttyfd, TCGETA, (char *) &termb); - flags = termb.c_lflag; -#else /* we HAVE_STTY */ - gtty(ttyfd, &ttyb); - flags = ttyb.sg_flags; -#endif -#endif } static void disable_tty_echo(void) { /* turn off echo on the tty */ -#if defined(HAVE_TCSETATTR) termb.c_lflag &= ~ECHO; tcsetattr(ttyfd, TCSAFLUSH, &termb); -#else -#if defined(HAVE_TERMIO_H) - termb.c_lflag &= ~ECHO; - ioctl(ttyfd, TCSETA, (char *) &termb); -#else /* we HAVE_STTY */ - ttyb.sg_flags &= ~ECHO; - stty(ttyfd, &ttyb); -#endif -#endif } static void restore_tty_state(void) { /* restore previous tty echo state */ -#if defined(HAVE_TCSETATTR) termb.c_lflag = flags; tcsetattr(ttyfd, TCSAFLUSH, &termb); -#else -#if defined(HAVE_TERMIO_H) - termb.c_lflag = flags; - ioctl(ttyfd, TCSETA, (char *) &termb); -#else /* we HAVE_STTY */ - ttyb.sg_flags = flags; - stty(ttyfd, &ttyb); -#endif -#endif } static RETSIGTYPE sigint_handler(int signum) diff --git a/gssapi.c b/gssapi.c index 5a05ff8f..57eb7bc7 100644 --- a/gssapi.c +++ b/gssapi.c @@ -8,9 +8,7 @@ #include #include #include -#if defined(STDC_HEADERS) #include -#endif #include "fetchmail.h" #include "socket.h" diff --git a/imap.c b/imap.c index 1364027f..39411e85 100644 --- a/imap.c +++ b/imap.c @@ -10,11 +10,9 @@ #include #include #include -#if defined(STDC_HEADERS) #include #include #include -#endif #include "fetchmail.h" #include "socket.h" diff --git a/interface.c b/interface.c index 8c36bc8c..f2e70969 100644 --- a/interface.c +++ b/interface.c @@ -24,12 +24,8 @@ #include #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #include #include diff --git a/kerberos.c b/kerberos.c index a57616a8..1125ec9c 100644 --- a/kerberos.c +++ b/kerberos.c @@ -10,9 +10,7 @@ #include #include #include -#if defined(STDC_HEADERS) #include -#endif #include "fetchmail.h" #include "socket.h" #include "kerberos.h" diff --git a/lock.c b/lock.c index 213969f1..b6c1109f 100644 --- a/lock.c +++ b/lock.c @@ -6,15 +6,9 @@ #include "config.h" #include -#ifdef HAVE_STRING_H #include /* strcat() */ -#endif -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #include #include diff --git a/md5ify.c b/md5ify.c index 5affe316..7634b089 100644 --- a/md5ify.c +++ b/md5ify.c @@ -12,10 +12,7 @@ #include #include - -#if defined(STDC_HEADERS) #include -#endif #include "fm_md5.h" diff --git a/opie.c b/opie.c index 06756121..d3eabb98 100644 --- a/opie.c +++ b/opie.c @@ -8,9 +8,7 @@ #include #include #include -#if defined(STDC_HEADERS) #include -#endif #include "fetchmail.h" #include "socket.h" diff --git a/options.c b/options.c index 7f0d061d..6d7e87a2 100644 --- a/options.c +++ b/options.c @@ -11,12 +11,8 @@ #include #include #include -#if defined(STDC_HEADERS) #include #include -#else -#include -#endif #include "getopt.h" #include "fetchmail.h" @@ -159,7 +155,6 @@ static const struct option longoptions[] = { static int xatoi(char *s, int *errflagptr) /* do safe conversion from string to number */ { -#if defined (STDC_HEADERS) && defined (LONG_MAX) && defined (INT_MAX) /* parse and convert numbers, but also check for invalid characters in * numbers */ @@ -190,41 +185,6 @@ static int xatoi(char *s, int *errflagptr) } return (int) value; /* shut up, I know what I'm doing */ -#else - int i; - char *dp; -# if defined (STDC_HEADERS) - size_t len; -# else - int len; -# endif - - /* We do only base 10 conversions here (atoi)! */ - - len = strlen(s); - /* check for leading white spaces */ - for (i = 0; (i < len) && isspace((unsigned char)s[i]); i++) - ; - - dp = &s[i]; - - /* check for +/- */ - if (i < len && (s[i] == '+' || s[i] == '-')) i++; - - /* skip over digits */ - for ( /* no init */ ; (i < len) && isdigit((unsigned char)s[i]); i++) - ; - - /* check for trailing garbage */ - if (i != len) { - (void) fprintf(stderr, GT_("String '%s' is not a valid number string.\n"), s); - (*errflagptr)++; - return 0; - } - - /* atoi should be safe by now, except for number range over/underflow */ - return atoi(dp); -#endif } /** parse and validate the command line options */ diff --git a/pop3.c b/pop3.c index a9b6b8bb..be7315bb 100644 --- a/pop3.c +++ b/pop3.c @@ -10,12 +10,8 @@ #include #include #include -#if defined(HAVE_UNISTD_H) #include -#endif -#if defined(STDC_HEADERS) #include -#endif #include #include "fetchmail.h" diff --git a/rcfile_y.y b/rcfile_y.y index c06a0fd4..32ead41c 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -14,12 +14,8 @@ #endif #include #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include #if defined(__CYGWIN__) diff --git a/sink.c b/sink.c index 92f7b433..1fa16892 100644 --- a/sink.c +++ b/sink.c @@ -18,12 +18,8 @@ #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #if defined(HAVE_STDARG_H) #include #else diff --git a/socket.c b/socket.c index f974602a..8a66d69a 100644 --- a/socket.c +++ b/socket.c @@ -26,12 +26,8 @@ #include #endif #include -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #if defined(HAVE_STDARG_H) #include #else diff --git a/transact.c b/transact.c index 0b942e25..b401663d 100644 --- a/transact.c +++ b/transact.c @@ -12,12 +12,8 @@ #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ -#if defined(STDC_HEADERS) #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #if defined(HAVE_STDARG_H) #include #else diff --git a/uid.c b/uid.c index 8a775b9c..5c70d812 100644 --- a/uid.c +++ b/uid.c @@ -10,13 +10,9 @@ #include #include #include -#if defined(STDC_HEADERS) #include #include -#endif -#if defined(HAVE_UNISTD_H) #include -#endif #include "fetchmail.h" #include "i18n.h" diff --git a/xmalloc.c b/xmalloc.c index c2ca4a66..bcb62553 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -10,9 +10,7 @@ #include #include #include -#if defined(STDC_HEADERS) #include -#endif #include "fetchmail.h" #include "i18n.h" -- 2.43.2