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"
- #include "status.h"
-
- void
- line_set()
- {
- 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 (status->fd == -1)
- return;
- /* get the current settings */
- ioctl(status->fd, TCGETA, &tbuf);
- /* set some beginning values */
- tbuf.c_cc[4] = 1;
- tbuf.c_cc[5] = 0;
- tbuf.c_oflag = 0;
- tbuf.c_iflag = 0;
- tbuf.c_cflag = (CREAD|HUPCL);
- tbuf.c_lflag = 0;
-
- /*
- * I don't think there's any need for output flow control... (I don't
- * know about you guys, but I can't type faster than the host can
- * receive!) Besides, the file transfers reset this anyway.
- */
- if (*param->flow == 'X')
- tbuf.c_iflag |= 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:
- /*
- * Be careful here... some systems use EXTA in lieu
- * of B19200.
- */
- tbuf.c_cflag |= 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(status->fd, TCSETA, &tbuf);
- ioctl(status->fd, TCFLSH, 2);
- return;
- }
-