From b50b1d74d09bbb4f981f83157cf6acd7c4201c11 Mon Sep 17 00:00:00 2001 From: verhaegs Date: Wed, 18 Apr 2012 19:32:03 +0000 Subject: [PATCH] termios.h: Put some non-standard fields in a private struct. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@44645 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/clib/__arosc_termios.h | 25 +++++++++++++++++++++++++ compiler/clib/cfgetispeed.c | 7 +++++-- compiler/clib/cfgetospeed.c | 7 +++++-- compiler/clib/cfsetispeed.c | 16 ++++++++++++++-- compiler/clib/cfsetospeed.c | 16 ++++++++++++++-- compiler/clib/include/termios.h | 11 ++++------- 6 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 compiler/clib/__arosc_termios.h diff --git a/compiler/clib/__arosc_termios.h b/compiler/clib/__arosc_termios.h new file mode 100644 index 0000000000..6c0dd560c4 --- /dev/null +++ b/compiler/clib/__arosc_termios.h @@ -0,0 +1,25 @@ +#ifndef __AROSC_TERMIOS_H +#define __AROSC_TERMIOS_H + +/* + * Copyright © 1995-2012, The AROS Development Team. All rights reserved. + * $Id$ + * + * internal header file for POSIX.1-2008 termios.h support + */ + +#include + +struct termios_intern { + /* Public part; needs to be backwards compatible */ + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_cc[NCCS]; /* control characters */ + /* Internal part; may be changed */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +#endif /* __AROSC_TERMIOS_H */ diff --git a/compiler/clib/cfgetispeed.c b/compiler/clib/cfgetispeed.c index dcb8a86ffa..06827a3247 100644 --- a/compiler/clib/cfgetispeed.c +++ b/compiler/clib/cfgetispeed.c @@ -1,10 +1,13 @@ -#include +#include "__arosc_termios.h" /* FIXME: Add autodocs */ speed_t cfgetispeed(const struct termios *__termios_p) { if (__termios_p) - return __termios_p->c_ispeed; + { + struct termios_intern *t = (struct termios_intern *)__termios_p; + return t->c_ispeed; + } /* According to man pages and online standard documents providing an * invalid pointer does not result in an error. Tests on Linux resulted diff --git a/compiler/clib/cfgetospeed.c b/compiler/clib/cfgetospeed.c index e3bc9cee82..550c72aa8c 100644 --- a/compiler/clib/cfgetospeed.c +++ b/compiler/clib/cfgetospeed.c @@ -1,10 +1,13 @@ -#include +#include "__arosc_termios.h" /* FIXME: Add autodocs */ speed_t cfgetospeed(const struct termios *__termios_p) { if (__termios_p) - return __termios_p->c_ospeed; + { + struct termios_intern * t = (struct termios_intern *)__termios_p; + return t->c_ospeed; + } /* According to man pages and online standard documents providing an * invalid pointer does not result in an error. Tests on Linux resulted diff --git a/compiler/clib/cfsetispeed.c b/compiler/clib/cfsetispeed.c index b224f60be5..e66530fb8b 100644 --- a/compiler/clib/cfsetispeed.c +++ b/compiler/clib/cfsetispeed.c @@ -1,7 +1,19 @@ -#include +#include + +#include "__arosc_termios.h" /* FIXME: Add autodoc */ int cfsetispeed(struct termios *__termios_p, speed_t speed) { - return 0; + if (__termios_p) + { + struct termios_intern *t = (struct termios_intern *)__termios_p; + t->c_ispeed = speed; + return 0; + } + else + { + errno = EINVAL; + return -1; + } } diff --git a/compiler/clib/cfsetospeed.c b/compiler/clib/cfsetospeed.c index 7a7bf18eab..ce05db324a 100644 --- a/compiler/clib/cfsetospeed.c +++ b/compiler/clib/cfsetospeed.c @@ -1,7 +1,19 @@ -#include +#include + +#include "__arosc_termios.h" /* FIXME: Add autodoc */ int cfsetospeed(struct termios *__termios_p, speed_t speed) { - return 0; + if (__termios_p) + { + struct termios_intern * t = (struct termios_intern *)__termios_p; + t->c_ospeed = speed; + return 0; + } + else + { + errno = EINVAL; + return -1; + } } diff --git a/compiler/clib/include/termios.h b/compiler/clib/include/termios.h index 15d78bf769..c346420b7b 100644 --- a/compiler/clib/include/termios.h +++ b/compiler/clib/include/termios.h @@ -2,12 +2,13 @@ #define _TERMIOS_H 1 /* - * Copyright © 1995-2001, The AROS Development Team. All rights reserved. + * Copyright © 1995-2012, The AROS Development Team. All rights reserved. * $Id$ * - * POSIX Standard: 7.1-2 General Terminal Interface + * POSIX.1-2008 header file */ +/* FIXME: Are these OK ? */ typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t; @@ -18,12 +19,8 @@ struct termios { tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ -#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 -#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 + char internal[64]; /* Private */ }; /* c_cc characters */ -- 2.11.4.GIT