1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <termios.h>
#include "aix-termios.h"
int
tcgetattr (fd, linuxtermios_p)
int fd;
struct termios *linuxtermios_p;
{
struct aixtermios aixtermios;
int result;
result = /* make syscall */;
if (result != -1)
{
/* Convert the result. */
linuxtermios_p->c_cc[VINTR] = aixtermios.c_cc[AIX_VINTR];
linuxtermios_p->c_cc[VQUIT] = aixtermios.c_cc[AIX_VQUIT];
linuxtermios_p->c_cc[VERASE] = aixtermios.c_cc[AIX_VERASE];
linuxtermios_p->c_cc[VKILL] = aixtermios.c_cc[AIX_VKILL];
linuxtermios_p->c_cc[VEOF] = aixtermios.c_cc[AIX_VEOF];
// XXX VMIN has the same value as VEOF !?
linuxtermios_p->c_cc[VEOL] = aixtermios.c_cc[AIX_VEOL];
// XXX VTIME has the same value as VEOL !?
linuxtermios_p->c_cc[VEOL2] = aixtermios.c_cc[AIX_VEOL2];
linuxtermios_p->c_cc[VSTART] = aixtermios.c_cc[AIX_VSTART];
linuxtermios_p->c_cc[VSTOP] = aixtermios.c_cc[AIX_VSTOP];
linuxtermios_p->c_cc[VSUSP] = aixtermios.c_cc[AIX_VSUSP];
// XXX No Linux equivalent for VDSUSP !?
linuxtermios_p->c_cc[VREPRINT] = aixtermios.c_cc[AIX_VREPRINT];
linuxtermios_p->c_cc[VDISCARD] = aixtermios.c_cc[AIX_VDISCARD];
linuxtermios_p->c_cc[VWERASE] = aixtermios.c_cc[AIX_VWERASE];
linuxtermios_p->c_cc[VLNEXT] = aixtermios.c_cc[AIX_VLNEXT];
linuxtermios_p->c_cflag = aixtermios.c_c_flag & AIX_CBAUD;
/* Only the IUCLC, IXANY, and IMAXBEL values are different in the
c_iflag member. */
linuxtermios_p->c_iflag = aixtermios.c_iflag & 0x7ff;
if (aixtermios.c_iflag & AIX_IXANY)
linuxtermios_p->c_iflag |= IXANY;
if (aixtermios.c_iflag & AIX_IUCLC)
linuxtermios_p->c_iflag |= IUCLC;
if (aixtermios.c_iflag & AIX_IMAXBEL)
linuxtermios_p->c_iflag |= IMAXBEL;
/* Many of the c_oflag files differ. Bummer. */
linuxtermios_p->c_oflag = (aixtermios.c_oflag
& (OPOST | OCRNL | ONOCR | ONLRET | OFILL
| OFDEL | TABDLY));
if (aixtermios.c_oflag & AIX_OLCUC)
linuxtermios_p->c_oflag |= OLCUC;
if (aixtermios.c_oflag & AIX_ONLCR)
linuxtermios_p->c_oflag |= ONLCR;
if (aixtermiosc_oflag & AIX_NLDLY)
linuxtermios_p->c_oflag |= NL1;
if (aixtermiosc_oflag.c_oflag & AIX_TABDLY)
{
#define offset 2
#if AIX_TAB1 << offset != TAB1 || AIX_TAB3 << offset != TAB3
# error "Check the offset"
#endif
linuxtermios_p->c_oflag |= (aixtermios.c_oflag >> offset) & TABDLY;
#undef offset
}
if (aixtermios.c_oflag & AIX_FFDLY)
linuxtermios_p->c_oflag |= FF1;
if (aixtermios.c_oflag & AIX_BSDLY)
linuxtermios_p->c_oflag |= BS1;
if (aixtermios.c_oflag & AIX_VTDLY)
linuxtermios_p->c_oflag |= VT1;
/* A lot of the c_cflag member is also different. */
if (aixtermios.c_cflag & AIX_CSIZE)
{
#define offset 4
#if CSIZE >> offset != AIX_CSIZE
# error "Check the offset"
#endif
linuxtermios_p->c_cflag |= (aixtermios.c_cflag >> offset) & CSIZE;
#undef offset
}
if (aixtermios.c_cflag & AIX_STOPB)
linuxtermios_p->c_cflag |= STOPB;
if (aixtermios.c_cflag & AIX_CREAD)
linuxtermios_p->c_cflag |= CREAD;
if (aixtermios.cflag & AIX_PARENB)
linuxtermios_p->c_cflag |= PARENB;
if (aixtermios.cflag & AIX_PARODD)
linuxtermios_p->c_cflag |= PARODD;
if (aixtermios.c_cflag & AIX_HUPCL)
linuxtermios_p->c_cflag |= HUPCL;
if (aixtermios.c_cflag & AIX_CLOCAL)
linuxtermios_p->c_cflag |= CLOCAL;
/* The c_lflag is information is also different. */
aixtermios.c_lflag = 0;
if (aixtermios.c_lflag & AIX_ISIG)
linuxtermios_p->c_lflag |= ISIG;
if (aixtermios.c_lflag & AIX_ICANON)
linuxtermios_p->c_lflag |= ICANON;
if (aixtermios.c_lflag & AIX_XCASE)
linuxtermios_p->c_lflag |= XCASE;
if (aixtermios.c_lflag & AIX_ECHO)
linuxtermios_p->c_lflag |= ECHO;
if (aixtermios.c_lflag & AIX_ECHOE)
linuxtermios_p->c_lflag |= ECHOE;
if (aixtermios.c_lflag & AIX_ECHOK)
linuxtermios_p->c_lflag |= ECHOK;
if (aixtermios.c_lflag & AIX_ECHONL)
linuxtermios_p->c_lflag |= ECHONL;
if (aixtermios.c_lflag & AIX_NOFLSH)
linuxtermios_p->c_lflag |= NOFLSH;
if (aixtermios.c_lflag & AIX_TOSTOP)
linuxtermios_p->c_lflag |= TOSTOP;
if (aixtermios.c_lflag & AIX_ECHOCTL)
linuxtermios_p->c_lflag |= ECHOCTL;
if (aixtermios.c_lflag & AIX_ECHOPRT)
linuxtermios_p->c_lflag |= ECHOPRT;
if (aixtermios.c_lflag & AIX_ECHOKE)
linuxtermios_p->c_lflag |= ECHOKE;
if (aixtermios.c_lflag & AIX_FLUSHO)
linuxtermios_p->c_lflag |= FLUSHO;
if (aixtermios.c_lflag & AIX_PENDIN)
linuxtermios_p->c_lflag |= PENDIN;
if (aixtermios->c_lflag & AIX_IEXTEN)
linuxtermios_p->c_lflag |= IEXTEN;
}
else
// Convert error here or in syscall.
;
return result;
}
|