home *** CD-ROM | disk | FTP | other *** search
- /*
- * Change the communication line settings to the new values.
- */
-
- #include <stdio.h>
- #include <termio.h>
- #include "dial_dir.h"
- #include "param.h"
-
- void
- line_set()
- {
- extern int fd;
- struct termio tbuf;
-
- /*
- * The manual dial entry also serves to store the previous
- * line settings. How else would the manual dial entry
- * know what line setting to use?
- */
- if (dir->d_cur != 0) {
- dir->baud[0] = dir->baud[dir->d_cur];
- dir->parity[0] = dir->parity[dir->d_cur];
- dir->dbits[0] = dir->dbits[dir->d_cur];
- dir->sbits[0] = dir->sbits[dir->d_cur];
- }
- /* nothing to do! */
- if (fd == -1)
- return;
- /* get the current settings */
- ioctl(fd, TCGETA, &tbuf);
- /* set some beginning values */
- tbuf.c_cc[4] = 1; /* VMIN */
- tbuf.c_cc[5] = 0; /* VTIME */
- tbuf.c_oflag = 0;
- tbuf.c_iflag = 0;
- tbuf.c_cflag = (CREAD|HUPCL|CLOCAL);
- tbuf.c_lflag = 0;
-
- if (*param->flow == 'X')
- tbuf.c_iflag |= IXON|IXOFF;
- /* strip high bit? */
- if (*param->strip == 'Y')
- tbuf.c_iflag |= ISTRIP;
- /* the baud rate */
- switch (dir->baud[dir->d_cur]) {
- case 300:
- tbuf.c_cflag |= B300;
- break;
- case 1200:
- tbuf.c_cflag |= B1200;
- break;
- case 2400:
- tbuf.c_cflag |= B2400;
- break;
- case 4800:
- tbuf.c_cflag |= B4800;
- break;
- case 9600:
- tbuf.c_cflag |= B9600;
- break;
- case 19200:
- #ifdef B19200
- tbuf.c_cflag |= B19200;
- #else /* B19200 */
- #ifdef EXTA
- tbuf.c_cflag |= EXTA;
- #endif /* EXTA */
- #endif /* B19200 */
- break;
- }
- /* the parity */
- switch (dir->parity[dir->d_cur]) {
- case 'N':
- break;
- case 'O':
- tbuf.c_cflag |= (PARENB|PARODD);
- break;
- case 'E':
- tbuf.c_cflag |= PARENB;
- break;
- }
- /* the data bits */
- if (dir->dbits[dir->d_cur] == 8)
- tbuf.c_cflag |= CS8;
- else
- tbuf.c_cflag |= CS7;
- /* the stop bits */
- if (dir->sbits[dir->d_cur] == 2)
- tbuf.c_cflag |= CSTOPB;
-
- /* now set 'em! */
- ioctl(fd, TCSETA, &tbuf);
- ioctl(fd, TCFLSH, 2);
- return;
- }
-