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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
/*
* PCTMOD.C - terminal mode control routines for PPC
*
* Source Version: 2.0
* Software Release #92-0043
*
*/
#include "cpyright.h"
#include "ppc.h"
#ifdef SYSV_TERMINAL
#define IS(flag, x) (trm.flag & x) ? "ON" : "OFF"
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* PC_SET_RAW_STATE - set the RAW processing on the given descriptor
* - don't do anything else if you can't get the
* - parameters for the stream
* - this also weeds out descriptors (e.g. sockets
* - and pipes) for which this is inappropriate
* - (TTY's and PTY's need this stuff)
*/
int PC_set_raw_state(fd, trap)
int fd, trap;
{TERMINAL trm;
#ifndef OPENNT
#ifdef UNIX
if (trap)
{PC_ERR_TRAP(FALSE);};
if (ioctl(fd, TIOCGETP, &trm) > -1)
{
# ifdef BSD_TERMINAL
trm.sg_flags |= RAW;
/* trm.sg_flags &= ~ECHO; */
# endif
# ifdef SYSV_TERMINAL
trm.c_iflag = ICRNL;
/* trm.c_iflag = 0; */
trm.c_oflag &= ~OPOST;
trm.c_lflag &= ~( ISIG | ICANON | XCASE );
/* trm.c_lflag &= ~(ISIG | ICANON | ECHO | XCASE); */
trm.c_cflag &= ~(CSIZE | PARENB);
trm.c_cflag |= CS8;
trm.c_cc[VMIN] = 1; /* Force at least one character to be read */
trm.c_cc[VTIME] = 1; /* 10th second between chars */
# endif
if (ioctl(fd, TIOCSETN, &trm) < 0)
PC_error("COULDN'T SET I/O FLAGS %d - PC_SET_RAW_STATE",
errno);};
#endif
return(TRUE);}
#else
return(FALSE);}
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* PC_SET_COOKED_STATE - set the COOKED processing on the given descriptor
* - don't do anything else if you can't get the
* - parameters for the stream
* - this also weeds out descriptors (e.g. sockets
* - and pipes) for which this is inappropriate
* - (TTY's and PTY's need this stuff)
*/
int PC_set_cooked_state(fd, trap)
int fd, trap;
{TERMINAL trm;
#ifndef OPENNT
#ifdef UNIX
if (trap)
{PC_ERR_TRAP(FALSE);};
if (ioctl(fd, TIOCGETP, &trm) > -1)
{
#ifdef BSD_TERMINAL
/* this is cooked */
trm.sg_flags |= ( ECHO | CRMOD | CBREAK | TANDEM | ALLDELAY );
#endif
#ifdef SYSV_TERMINAL
trm.c_iflag |= ( ICRNL | IXON );
/* trm.c_oflag |= ( OPOST | ONLCR ); */
trm.c_oflag |= ( OPOST | OCRNL );
trm.c_oflag |= ( NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY );
trm.c_lflag |= ( ISIG | ICANON | ECHO );
trm.c_cflag |= ( CREAD | PARENB | CS7 );
trm.c_cc[VMIN] = 1; /* Force at least one character to be read */
trm.c_cc[VTIME] = 1; /* 10th second between chars */
#endif
if (ioctl(fd, TIOCSETN, &trm) < 0)
PC_error("COULDN'T SET I/O FLAGS %d - PC_SET_COOKED_STATE",
errno);};
#endif
return(TRUE);}
#else
return(FALSE);}
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* PC_GET_TERM_STATE - get the terminal state on the given descriptor
* - allocate and return a TERMINAL_STATE
* - containing the old state
* - don't do anything else if you can't get the
* - parameters for the stream
* - this also weeds out descriptors (e.g. sockets and
* - pipes) for which this is inappropriate (PTY's need
* - this stuff)
*/
TERMINAL_STATE *PC_get_term_state(fd)
int fd;
{TERMINAL_STATE *t;
#ifndef OPENNT
#ifdef UNIX
t = FMAKE(TERMINAL_STATE, "PC_GET_TERM_STATE:t");
t->fd = fd;
t->full_info = TRUE;
if (ioctl(fd, TIOCGETP, &(t->term)) < 0)
return(NULL);
#ifdef BSD
if (ioctl(fd, TIOCGETC, &(t->tch)) < 0)
return(NULL);
if (ioctl(fd, TIOCGLTC, &(t->ltc)) < 0)
return(NULL);
if (ioctl(fd, TIOCLGET, &(t->localmode)) < 0)
return(NULL);
if (ioctl(fd, TIOCGETD, &(t->discipline)) < 0)
return(NULL);
if (ioctl(fd, TIOCGWINSZ, &(t->window_size)) < 0)
return(NULL);
#endif
#endif
return(t);}
#else
return(NULL);}
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* PC_SET_TERM_STATE - set the terminal state on the given descriptor
* - don't do anything else if you can't get the
* - parameters for the stream
* - this also weeds out descriptors (e.g. sockets and
* - pipes) for which this is inappropriate (PTY's need
* - this stuff)
*/
int PC_set_term_state(t, trmfd)
TERMINAL_STATE *t;
int trmfd;
{int fd;
#ifndef OPENNT
#ifdef UNIX
if (t == NULL)
return(FALSE);
if (trmfd >= 0)
fd = trmfd;
else
fd = t->fd;
if (ioctl(fd, TIOCSETP, &(t->term)) < 0)
return(FALSE);
#ifdef BSD
if (t->full_info)
{if (ioctl(fd, TIOCSETC, &(t->tch)) < 0)
return(FALSE);
if (ioctl(fd, TIOCSLTC, &(t->ltc)) < 0)
return(FALSE);
if (ioctl(fd, TIOCLSET, &(t->localmode)) < 0)
return(FALSE);
if (ioctl(fd, TIOCSETD, &(t->discipline)) < 0)
return(FALSE);
if (ioctl(fd, TIOCSWINSZ, &(t->window_size)) < 0)
return(FALSE);};
#endif
#endif
return(TRUE);}
#else
return(FALSE);}
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* PC_PRINT_TERM_STATE - print to the specified file the state of the
* - specified file descriptor
*/
void PC_print_term_state(fp, fd)
FILE *fp;
int fd;
{return;}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
|