From b04eb35add26b5aa480d2ec4a54e7bea0ff0b861 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Tue, 30 Nov 2004 19:33:53 +0000 Subject: [PATCH] Changed terminal io defines --- config.h.in | 12 ++++ configure | 155 ++++++++++++++++++++++++++++++++++++++++++++- configure.in | 3 +- lib/mbselib.h | 45 ++++++++++++- mbsebbs/openport.c | 57 ++++++++++++++--- 5 files changed, 259 insertions(+), 13 deletions(-) diff --git a/config.h.in b/config.h.in index 83af80a0..fdad61fe 100644 --- a/config.h.in +++ b/config.h.in @@ -166,6 +166,15 @@ /* Define if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H +/* Define if you have the header file. */ +#undef HAVE_SYS_TERMIO_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIO_H + /* Define if you have the header file. */ #undef HAVE_TERMIOS_H @@ -175,6 +184,9 @@ /* Define if you have the header file. */ #undef HAVE_USERSEC_H +/* Define if you have the header file. */ +#undef HAVE_SGTTY_H + /* Define if you have the header file. */ #undef HAVE_UTMP_H diff --git a/configure b/configure index 040e2594..9b1262f4 100755 --- a/configure +++ b/configure @@ -5621,8 +5621,161 @@ fi +for ac_header in termios.h sys/termios.h termio.h sys/termio.h sgtty.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -for ac_header in sys/time.h termios.h sys/vfs.h unistd.h netinet/in.h regex.h +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_header in sys/time.h sys/vfs.h unistd.h netinet/in.h regex.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then diff --git a/configure.in b/configure.in index 55318b59..15a14753 100644 --- a/configure.in +++ b/configure.in @@ -223,7 +223,8 @@ AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(sys/time.h termios.h sys/vfs.h unistd.h netinet/in.h regex.h) +AC_CHECK_HEADERS(termios.h sys/termios.h termio.h sys/termio.h sgtty.h) +AC_CHECK_HEADERS(sys/time.h sys/vfs.h unistd.h netinet/in.h regex.h) AC_CHECK_HEADERS(sys/resource.h usersec.h gshadow.h shadow.h) AC_CHECK_HEADERS(limits.h utmp.h utmpx.h lastlog.h rpc/key_prot.h) AC_STRUCT_TIMEZONE diff --git a/lib/mbselib.h b/lib/mbselib.h index 5dc6ba77..3e2ad4bf 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -93,6 +92,50 @@ #include #include +/* used to use #elif, but native braindead hpux 9.00 c compiler didn't + * * understand it */ +#ifdef HAVE_TERMIOS_H +/* get rid of warnings on SCO ODT 3.2 */ +struct termios; +# include +# define USE_TERMIOS +#else +# if defined(HAVE_SYS_TERMIOS_H) +# include +# define USE_TERMIOS +# else +# if defined(HAVE_TERMIO_H) +# include +# define USE_TERMIO +# else +# if defined(HAVE_SYS_TERMIO_H) +# include +# define USE_TERMIO +# else +# if defined(HAVE_SGTTY_H) +# include +# define USE_SGTTY +# ifdef LLITOUT + extern long Locmode; /* Saved "local mode" for 4.x BSD "new driver" */ + extern long Locbit; /* Bit SUPPOSED to disable output translations */ +# endif +# else +# error neither termio.h nor sgtty.h found. Cannot continue. +# endif +# endif +# endif +# endif +#endif + +#ifdef USE_SGTTY +# ifdef TIOCSBRK +# define CANBREAK +# endif +#endif +#ifdef USE_TERMIO +# define CANBREAK +#endif + #include #include #if defined(__FreeBSD__) || defined(__NetBSD__) diff --git a/mbsebbs/openport.c b/mbsebbs/openport.c index d7849288..dc9c21a4 100644 --- a/mbsebbs/openport.c +++ b/mbsebbs/openport.c @@ -33,16 +33,37 @@ #include "openport.h" #include "zmmisc.h" +#ifdef USE_SGTTY +# ifdef LLITOUT +long Locmode; /* Saved "local mode" for 4.x BSD "new driver" */ +long Locbit = LLITOUT; /* Bit SUPPOSED to disable output translations */ +# endif +#endif + +#ifdef USE_TERMIOS +struct termios oldtty, tty; +#else +# if defined(USE_TERMIO) +struct termio oldtty, tty; +# else +struct sgttyb oldtty, tty; +struct tchars oldtch, tch; +# endif +#endif int hanged_up = 0; -static struct termios oldtty; /* Saved termios */ -static struct termios tty; unsigned Baudrate = 2400; /* Next is on compile commandline in lrzsz */ #define NFGVMIN 1 #define HOWMANY 255 +#if defined(HOWMANY) && HOWMANY > 255 +#ifndef NFGVMIN +Howmany must be 255 or less +#endif +#endif + static struct { unsigned baudr; @@ -164,6 +185,8 @@ int io_mode(int fd, int n) Syslog('t', "io_mode(%d, %d)", fd, n); switch(n) { + +#ifdef USE_TERMIOS case 2: if (!did0) { did0 = TRUE; @@ -246,6 +269,15 @@ int io_mode(int fd, int n) tcflow (fd,TCOON); /* restart output */ return 0; +#endif + +#ifdef USE_TERMIO +#error USE_TERMIO driver not coded +#endif + +#ifdef USE_SGTTY +#error USE_SGTTY driver not coded +#endif } return -1; } @@ -273,14 +305,19 @@ void sendbrk(void) Syslog('t', "Send break"); if (isatty(0)) { -#if (defined(TIOCSBRK)) - Syslog('t', "TIOCSBRK"); - ioctl(0, TIOCSBRK, 0L); -#elif (defined(TCSBRK)) - Syslog('t', "TCSBRK"); - ioctl(0, TCSBRK, 0L); -#else /* any ideas about BSD? */ - ; +#ifdef USE_TERMIOS + tcsendbreak(fd,0); +#endif +#ifdef USE_TERMIO + ioctl(fd, TCSBRK, 0); +#endif +#ifdef USE_SGTTY +#ifdef TIOCSBRK + sleep(1); + ioctl(fd, TIOCSBRK, 0); + sleep(1); + ioctl(fd, TIOCCBRK, 0); +#endif #endif } }