1
0
mirror of https://github.com/moparisthebest/socat synced 2024-12-22 06:58:47 -05:00

socat socat did not compile on Solaris when configured with --disable-termios

This commit is contained in:
Gerhard Rieger 2008-09-24 08:31:00 +02:00
parent d37e8acc5f
commit b7dc45661e
9 changed files with 39 additions and 12 deletions

View File

@ -1,4 +1,8 @@
corrections:
socat did not compile on Solaris when configured without termios
feature (thanks to Pavan Gadi for reporting this bug)
####################### V 1.6.0.1: ####################### V 1.6.0.1:
new features: new features:

View File

@ -1 +1 @@
"1.6.0.1" "1.6.0.1+disable_termios"

View File

@ -1,5 +1,5 @@
/* source: filan.c */ /* source: filan.c */
/* Copyright Gerhard Rieger 2001-2007 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* the subroutine filan makes a "FILe descriptor ANalysis". It checks the /* the subroutine filan makes a "FILe descriptor ANalysis". It checks the
@ -412,6 +412,7 @@ int devinfo(int fd) {
int cdevan(int fd, FILE *outfile) { int cdevan(int fd, FILE *outfile) {
int ret; int ret;
#if _WITH_TERMIOS
if ((ret = Isatty(fd)) < 0) { if ((ret = Isatty(fd)) < 0) {
Warn2("isatty(%d): %s", fd, strerror(errno)); Warn2("isatty(%d): %s", fd, strerror(errno));
return -1; return -1;
@ -458,6 +459,7 @@ int cdevan(int fd, FILE *outfile) {
} }
} }
} }
#endif /* _WITH_TERMIOS */
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* source: sycls.c */ /* source: sycls.c */
/* Copyright Gerhard Rieger 2001-2007 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* explicit system call and C library trace function, for those who miss strace /* explicit system call and C library trace function, for those who miss strace
@ -1233,6 +1233,7 @@ void *Realloc(void *ptr, size_t size) {
return result; return result;
} }
#if _WITH_TERMIOS
int Tcgetattr(int fd, struct termios *termios_p) { int Tcgetattr(int fd, struct termios *termios_p) {
int i, result, _errno; int i, result, _errno;
char chars[5*NCCS], *cp = chars; char chars[5*NCCS], *cp = chars;
@ -1252,7 +1253,9 @@ int Tcgetattr(int fd, struct termios *termios_p) {
errno = _errno; errno = _errno;
return result; return result;
} }
#endif /* _WITH_TERMIOS */
#if _WITH_TERMIOS
int Tcsetattr(int fd, int optional_actions, struct termios *termios_p) { int Tcsetattr(int fd, int optional_actions, struct termios *termios_p) {
int i, result, _errno; int i, result, _errno;
char chars[5*NCCS], *cp = chars; char chars[5*NCCS], *cp = chars;
@ -1270,6 +1273,7 @@ int Tcsetattr(int fd, int optional_actions, struct termios *termios_p) {
errno = _errno; errno = _errno;
return result; return result;
} }
#endif /* _WITH_TERMIOS */
char *Ttyname(int fd) { char *Ttyname(int fd) {
char *result; char *result;

View File

@ -1,5 +1,5 @@
/* source: sysincludes.h */ /* source: sysincludes.h */
/* Copyright Gerhard Rieger 2001-2007 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
#ifndef __sysincludes_h_included #ifndef __sysincludes_h_included
@ -34,7 +34,7 @@
#if HAVE_GRP_H #if HAVE_GRP_H
#include <grp.h> /* getgrnam() */ #include <grp.h> /* getgrnam() */
#endif #endif
#if HAVE_PTY_H #if HAVE_PTY_H && _WITH_TERMIOS
#include <pty.h> #include <pty.h>
#endif #endif
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -120,7 +120,7 @@
#include <linux/if_tun.h> #include <linux/if_tun.h>
#endif #endif
#if HAVE_TERMIOS_H && WITH_TERMIOS #if HAVE_TERMIOS_H && _WITH_TERMIOS
#include <termios.h> #include <termios.h>
#endif #endif
#if HAVE_SYS_UTSNAME_H #if HAVE_SYS_UTSNAME_H

View File

@ -1,5 +1,5 @@
/* source: xio-readline.c */ /* source: xio-readline.c */
/* Copyright Gerhard Rieger 2002-2007 */ /* Copyright Gerhard Rieger 2002-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for opening the readline address */ /* this file contains the source for opening the readline address */
@ -120,8 +120,10 @@ static int xioopen_readline(int argc, const char *argv[], struct opt *opts,
if (xfd->stream.para.readline.history_file) { if (xfd->stream.para.readline.history_file) {
Read_history(xfd->stream.para.readline.history_file); Read_history(xfd->stream.para.readline.history_file);
} }
#if _WITH_TERMIOS
xiotermios_clrflag(xfd->stream.fd, 3, ICANON); xiotermios_clrflag(xfd->stream.fd, 3, ICANON);
xiotermios_clrflag(xfd->stream.fd, 3, ECHO); xiotermios_clrflag(xfd->stream.fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
return _xio_openlate(&xfd->stream, opts); return _xio_openlate(&xfd->stream, opts);
} }
@ -137,6 +139,7 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
pipe->para.readline.hasnoecho && pipe->para.readline.hasnoecho &&
!regexec(&pipe->para.readline.noecho, !regexec(&pipe->para.readline.noecho,
pipe->para.readline.dynprompt, 0, NULL, 0)) { pipe->para.readline.dynprompt, 0, NULL, 0)) {
#if _WITH_TERMIOS
/* under these conditions, we do not echo input, thus we circumvent /* under these conditions, we do not echo input, thus we circumvent
readline */ readline */
struct termios saveterm, setterm; struct termios saveterm, setterm;
@ -145,6 +148,7 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
setterm = saveterm; setterm = saveterm;
setterm.c_lflag |= ICANON; setterm.c_lflag |= ICANON;
Tcsetattr(pipe->fd, TCSANOW, &setterm); /*!*/ Tcsetattr(pipe->fd, TCSANOW, &setterm); /*!*/
#endif /* _WITH_TERMIOS */
do { do {
bytes = Read(pipe->fd, buff, bufsiz); bytes = Read(pipe->fd, buff, bufsiz);
} while (bytes < 0 && errno == EINTR); } while (bytes < 0 && errno == EINTR);
@ -155,16 +159,20 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
errno = _errno; errno = _errno;
return -1; return -1;
} }
#if _WITH_TERMIOS
setterm.c_lflag &= ~ICANON; setterm.c_lflag &= ~ICANON;
Tcgetattr(pipe->fd, &setterm); /*! error */ Tcgetattr(pipe->fd, &setterm); /*! error */
Tcsetattr(pipe->fd, TCSANOW, &saveterm); /*!*/ Tcsetattr(pipe->fd, TCSANOW, &saveterm); /*!*/
#endif /* _WITH_TERMIOS */
pipe->para.readline.dynend = pipe->para.readline.dynprompt; pipe->para.readline.dynend = pipe->para.readline.dynprompt;
/*Write(pipe->fd, "\n", 1);*/ /*!*/ /*Write(pipe->fd, "\n", 1);*/ /*!*/
return bytes; return bytes;
} }
#endif /* HAVE_REGEX_H */ #endif /* HAVE_REGEX_H */
#if _WITH_TERMIOS
xiotermios_setflag(pipe->fd, 3, ECHO); xiotermios_setflag(pipe->fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
if (pipe->para.readline.prompt || pipe->para.readline.dynprompt) { if (pipe->para.readline.prompt || pipe->para.readline.dynprompt) {
/* we must carriage return, because readline will first print the /* we must carriage return, because readline will first print the
prompt */ prompt */
@ -191,7 +199,9 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
if (line == NULL) { if (line == NULL) {
return 0; /* EOF */ return 0; /* EOF */
} }
#if _WITH_TERMIOS
xiotermios_clrflag(pipe->fd, 3, ECHO); xiotermios_clrflag(pipe->fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
Add_history(line); Add_history(line);
bytes = strlen(line); bytes = strlen(line);
strncpy(buff, line, bufsiz); strncpy(buff, line, bufsiz);

View File

@ -1,5 +1,5 @@
/* source: xio-termios.c */ /* source: xio-termios.c */
/* Copyright Gerhard Rieger 2001-2006 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for terminal I/O options */ /* this file contains the source for terminal I/O options */
@ -10,6 +10,7 @@
#include "xio-termios.h" #include "xio-termios.h"
/****** TERMIOS addresses ******/ /****** TERMIOS addresses ******/
#if _WITH_TERMIOS
#if WITH_TERMIOS #if WITH_TERMIOS
const struct optdesc opt_tiocsctty={ "tiocsctty", "ctty",OPT_TIOCSCTTY, GROUP_TERMIOS, PH_LATE2, TYPE_BOOL, OFUNC_SPEC }; const struct optdesc opt_tiocsctty={ "tiocsctty", "ctty",OPT_TIOCSCTTY, GROUP_TERMIOS, PH_LATE2, TYPE_BOOL, OFUNC_SPEC };
@ -324,3 +325,5 @@ int xiotermios_clrflag(int fd, int word, tcflag_t mask) {
return 0; return 0;
} }
#endif /* _WITH_TERMIOS */

View File

@ -1,5 +1,5 @@
/* source: xio-termios.h */ /* source: xio-termios.h */
/* Copyright Gerhard Rieger 2001-2006 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
#ifndef __xio_termios_h_included #ifndef __xio_termios_h_included
@ -138,10 +138,10 @@ extern const struct optdesc opt_sane;
extern const struct optdesc opt_ispeed; extern const struct optdesc opt_ispeed;
extern const struct optdesc opt_ospeed; extern const struct optdesc opt_ospeed;
#if WITH_TERMIOS /* otherwise tcflag_t might be reported undefined */ #if _WITH_TERMIOS /* otherwise tcflag_t might be reported undefined */
extern int xiotermios_setflag(int fd, int word, tcflag_t mask); extern int xiotermios_setflag(int fd, int word, tcflag_t mask);
extern int xiotermios_clrflag(int fd, int word, tcflag_t mask); extern int xiotermios_clrflag(int fd, int word, tcflag_t mask);
extern int xiotermiosflag_applyopt(int fd, struct opt *opt); extern int xiotermiosflag_applyopt(int fd, struct opt *opt);
#endif /* WITH_TERMIOS */ #endif /* _WITH_TERMIOS */
#endif /* !defined(__xio_termios_h_included) */ #endif /* !defined(__xio_termios_h_included) */

View File

@ -1,5 +1,5 @@
/* source: xioconfig.h */ /* source: xioconfig.h */
/* Copyright Gerhard Rieger 2001-2007 */ /* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
#ifndef __xioconfig_h_included #ifndef __xioconfig_h_included
@ -20,6 +20,10 @@
# define WITH_NAMED 1 # define WITH_NAMED 1
#endif #endif
#if WITH_TERMIOS || WITH_PTY || WITH_READLINE
# define _WITH_TERMIOS 1
#endif
#if WITH_SOCKS4A #if WITH_SOCKS4A
# define WITH_SOCKS4 1 # define WITH_SOCKS4 1
#endif #endif