1
0
mirror of https://github.com/moparisthebest/socat synced 2024-12-21 22:48:48 -05:00

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

This commit is contained in:
Gerhard Rieger 2008-09-24 09:05:39 +02:00
commit 674b0e608d
8 changed files with 34 additions and 8 deletions

View File

@ -91,6 +91,9 @@ corrections:
replaced the select() calls by poll() to cleanly fix the problems with
many file descriptors already open
socat did not compile on Solaris when configured without termios
feature (thanks to Pavan Gadi for reporting this bug)
porting:
socat should now build under MacOS X 10.4 (thanks to Camillo Lugaresi for
providing the patch)

View File

@ -412,6 +412,7 @@ int devinfo(int fd) {
int cdevan(int fd, FILE *outfile) {
int ret;
#if _WITH_TERMIOS
if ((ret = Isatty(fd)) < 0) {
Warn2("isatty(%d): %s", fd, strerror(errno));
return -1;
@ -458,6 +459,7 @@ int cdevan(int fd, FILE *outfile) {
}
}
}
#endif /* _WITH_TERMIOS */
return 0;
}

View File

@ -1271,6 +1271,7 @@ void *Realloc(void *ptr, size_t size) {
return result;
}
#if _WITH_TERMIOS
int Tcgetattr(int fd, struct termios *termios_p) {
int i, result, _errno;
char chars[5*NCCS], *cp = chars;
@ -1290,7 +1291,9 @@ int Tcgetattr(int fd, struct termios *termios_p) {
errno = _errno;
return result;
}
#endif /* _WITH_TERMIOS */
#if _WITH_TERMIOS
int Tcsetattr(int fd, int optional_actions, struct termios *termios_p) {
int i, result, _errno;
char chars[5*NCCS], *cp = chars;
@ -1308,6 +1311,7 @@ int Tcsetattr(int fd, int optional_actions, struct termios *termios_p) {
errno = _errno;
return result;
}
#endif /* _WITH_TERMIOS */
char *Ttyname(int fd) {
char *result;

View File

@ -34,7 +34,7 @@
#if HAVE_GRP_H
#include <grp.h> /* getgrnam() */
#endif
#if HAVE_PTY_H
#if HAVE_PTY_H && _WITH_TERMIOS
#include <pty.h>
#endif
#if HAVE_SYS_PARAM_H
@ -135,7 +135,7 @@
#include <linux/if_tun.h>
#endif
#if HAVE_TERMIOS_H && WITH_TERMIOS
#if HAVE_TERMIOS_H && _WITH_TERMIOS
#include <termios.h>
#endif
#if HAVE_SYS_UTSNAME_H

View File

@ -1,5 +1,5 @@
/* 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 */
/* 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) {
Read_history(xfd->stream.para.readline.history_file);
}
#if _WITH_TERMIOS
xiotermios_clrflag(xfd->stream.fd, 3, ICANON);
xiotermios_clrflag(xfd->stream.fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
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 &&
!regexec(&pipe->para.readline.noecho,
pipe->para.readline.dynprompt, 0, NULL, 0)) {
#if _WITH_TERMIOS
/* under these conditions, we do not echo input, thus we circumvent
readline */
struct termios saveterm, setterm;
@ -145,6 +148,7 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
setterm = saveterm;
setterm.c_lflag |= ICANON;
Tcsetattr(pipe->fd, TCSANOW, &setterm); /*!*/
#endif /* _WITH_TERMIOS */
do {
bytes = Read(pipe->fd, buff, bufsiz);
} while (bytes < 0 && errno == EINTR);
@ -155,16 +159,20 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
errno = _errno;
return -1;
}
#if _WITH_TERMIOS
setterm.c_lflag &= ~ICANON;
Tcgetattr(pipe->fd, &setterm); /*! error */
Tcsetattr(pipe->fd, TCSANOW, &saveterm); /*!*/
#endif /* _WITH_TERMIOS */
pipe->para.readline.dynend = pipe->para.readline.dynprompt;
/*Write(pipe->fd, "\n", 1);*/ /*!*/
return bytes;
}
#endif /* HAVE_REGEX_H */
#if _WITH_TERMIOS
xiotermios_setflag(pipe->fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
if (pipe->para.readline.prompt || pipe->para.readline.dynprompt) {
/* we must carriage return, because readline will first print the
prompt */
@ -191,7 +199,9 @@ ssize_t xioread_readline(struct single *pipe, void *buff, size_t bufsiz) {
if (line == NULL) {
return 0; /* EOF */
}
#if _WITH_TERMIOS
xiotermios_clrflag(pipe->fd, 3, ECHO);
#endif /* _WITH_TERMIOS */
Add_history(line);
bytes = strlen(line);
strncpy(buff, line, bufsiz);

View File

@ -1,5 +1,5 @@
/* 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 */
/* this file contains the source for terminal I/O options */
@ -10,6 +10,7 @@
#include "xio-termios.h"
/****** TERMIOS addresses ******/
#if _WITH_TERMIOS
#if WITH_TERMIOS
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;
}
#endif /* _WITH_TERMIOS */

View File

@ -1,5 +1,5 @@
/* 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 */
#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_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_clrflag(int fd, int word, tcflag_t mask);
extern int xiotermiosflag_applyopt(int fd, struct opt *opt);
#endif /* WITH_TERMIOS */
#endif /* _WITH_TERMIOS */
#endif /* !defined(__xio_termios_h_included) */

View File

@ -1,5 +1,5 @@
/* 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 */
#ifndef __xioconfig_h_included
@ -20,6 +20,10 @@
# define WITH_NAMED 1
#endif
#if WITH_TERMIOS || WITH_PTY || WITH_READLINE
# define _WITH_TERMIOS 1
#endif
#if WITH_SOCKS4A
# define WITH_SOCKS4 1
#endif