/* * /dev/ptyXX (A first version for pseudo-terminals) * * Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) * May 2001 * * This program 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. * * $Id$ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /*-----------------------------------------*/ #include #include #include #include #include /*-----------------------------------------*/ #include #include #include #include /*-----------------------------------------*/ #define IAC_ESC 255 #define IAC_DONT 254 #define IAC_DO 253 #define IAC_WONT 252 #define IAC_WILL 251 #define IAC_SB 250 #define IAC_GA 249 #define IAC_EL 248 #define IAC_EC 247 #define IAC_AYT 246 #define IAC_AO 245 #define IAC_IP 244 #define IAC_BRK 243 #define IAC_DMARK 242 #define IAC_NOP 241 #define IAC_SE 240 #define IAC_EOR 239 struct pty_tt; typedef struct pty_tt pty_t; struct pty_tt { char *devname; struct rtems_termios_tty *ttyp; tcflag_t c_cflag; int opened; int socket; int last_cr; int iac_mode; }; int ptys_initted=FALSE; pty_t ptys[MAX_PTYS]; /* This procedure returns the devname for a pty slot free. * If not slot availiable (field socket>=0) * then the socket argument is closed */ char * get_pty(int socket) { int ndx; if (!ptys_initted) return NULL; for (ndx=0;ndxc_cflag; } else { return -1; }; return 0; } /*-----------------------------------------------------------*/ static int ptyPollInitialize(int major,int minor,void * arg) { rtems_libio_open_close_args_t * args = arg; struct termios t; if (minoriop->data1; t.c_cflag=B9600|CS8;/* termios default */ return ptySetAttributes(minor,&t); } else { return -1; }; } /*-----------------------------------------------------------*/ static int ptyShutdown(int major,int minor,void * arg) { if (minor=0) close(ptys[minor].socket); ptys[minor].socket=-1; chown(ptys[minor].devname,2,0); } else { return -1; }; return 0; } /*-----------------------------------------------------------*/ /* Write Characters into pty device */ /*-----------------------------------------------------------*/ static int ptyPollWrite(int minor, const char * buf,int len) { int count; if (minor