|
|
1.1 ! root 1: /* %W% ! 2: */ ! 3: #include "uucp.h" ! 4: VERSION(%W%); ! 5: ! 6: static struct sg_spds { ! 7: int sp_val, ! 8: sp_name; ! 9: } spds[] = { ! 10: { 300, B300}, ! 11: { 600, B600}, ! 12: {1200, B1200}, ! 13: {2400, B2400}, ! 14: {4800, B4800}, ! 15: {9600, B9600}, ! 16: #ifdef EXTA ! 17: {19200, EXTA}, ! 18: #endif ! 19: #ifdef B19200 ! 20: {19200, B19200}, ! 21: #endif ! 22: #ifdef B38400 ! 23: {38400, B38400}, ! 24: #endif ! 25: {0, 0} ! 26: }; ! 27: ! 28: #define PACKSIZE 64 ! 29: #define HEADERSIZE 6 ! 30: #define SNDFILE 'S' ! 31: #define RCVFILE 'R' ! 32: #define RESET 'X' ! 33: ! 34: int linebaudrate = 0; /* for speedup hook in pk (unused in ATTSV) */ ! 35: ! 36: #ifdef ATTSV ! 37: ! 38: static struct termio Savettyb; ! 39: /* ! 40: * set speed/echo/mode... ! 41: * tty -> terminal name ! 42: * spwant -> speed ! 43: * type -> type ! 44: * ! 45: * if spwant == 0, speed is untouched ! 46: * type is unused, but needed for compatibility ! 47: * ! 48: * return: ! 49: * none ! 50: */ ! 51: fixline(tty, spwant, type) ! 52: int tty, spwant, type; ! 53: { ! 54: register struct sg_spds *ps; ! 55: struct termio ttbuf; ! 56: int speed = -1; ! 57: ! 58: DEBUG(6, "fixline(%d, ", tty); ! 59: DEBUG(6, "%d)\n", spwant); ! 60: if (ioctl(tty, TCGETA, &ttbuf) != 0) ! 61: return; ! 62: if (spwant > 0) { ! 63: for (ps = spds; ps->sp_val; ps++) ! 64: if (ps->sp_val == spwant) { ! 65: speed = ps->sp_name; ! 66: break; ! 67: } ! 68: ASSERT(speed >= 0, "BAD SPEED", "", speed); ! 69: ttbuf.c_cflag = speed; ! 70: } else ! 71: ttbuf.c_cflag &= CBAUD; ! 72: ttbuf.c_iflag = ttbuf.c_oflag = ttbuf.c_lflag = (ushort)0; ! 73: ! 74: #ifdef NO_MODEM_CTRL ! 75: /* CLOCAL may cause problems on pdp11s with DHs */ ! 76: if (type == D_DIRECT) { ! 77: DEBUG(4, "fixline - direct\n", ""); ! 78: ttbuf.c_cflag |= CLOCAL; ! 79: } else ! 80: #endif NO_MODEM_CTRL ! 81: ! 82: ttbuf.c_cflag &= ~CLOCAL; ! 83: ttbuf.c_cflag |= (CS8 | CREAD | (speed ? HUPCL : 0)); ! 84: ttbuf.c_cc[VMIN] = HEADERSIZE; ! 85: ttbuf.c_cc[VTIME] = 1; ! 86: ! 87: ASSERT(ioctl(tty, TCSETA, &ttbuf) >= 0, ! 88: "RETURN FROM fixline ioctl", "", errno); ! 89: return; ! 90: } ! 91: ! 92: sethup(dcf) ! 93: int dcf; ! 94: { ! 95: struct termio ttbuf; ! 96: ! 97: if (ioctl(dcf, TCGETA, &ttbuf) != 0) ! 98: return; ! 99: if (!(ttbuf.c_cflag & HUPCL)) { ! 100: ttbuf.c_cflag |= HUPCL; ! 101: (void) ioctl(dcf, TCSETA, &ttbuf); ! 102: } ! 103: } ! 104: ! 105: genbrk(fn) ! 106: register int fn; ! 107: { ! 108: if (isatty(fn)) ! 109: (void) ioctl(fn, TCSBRK, 0); ! 110: } ! 111: ! 112: ! 113: /* ! 114: * optimize line setting for sending or receiving files ! 115: * return: ! 116: * none ! 117: */ ! 118: setline(type) ! 119: register char type; ! 120: { ! 121: static struct termio tbuf; ! 122: ! 123: if (ioctl(Ifn, TCGETA, &tbuf) != 0) ! 124: return; ! 125: DEBUG(2, "setline - %c\n", type); ! 126: switch (type) { ! 127: case RCVFILE: ! 128: if (tbuf.c_cc[VMIN] != PACKSIZE) { ! 129: tbuf.c_cc[VMIN] = PACKSIZE; ! 130: (void) ioctl(Ifn, TCSETAW, &tbuf); ! 131: } ! 132: break; ! 133: ! 134: case SNDFILE: ! 135: case RESET: ! 136: if (tbuf.c_cc[VMIN] != HEADERSIZE) { ! 137: tbuf.c_cc[VMIN] = HEADERSIZE; ! 138: (void) ioctl(Ifn, TCSETAW, &tbuf); ! 139: } ! 140: break; ! 141: } ! 142: } ! 143: ! 144: savline() ! 145: { ! 146: int ret; ! 147: ! 148: ret = ioctl(0, TCGETA, &Savettyb); ! 149: Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7; ! 150: Savettyb.c_oflag |= OPOST; ! 151: Savettyb.c_lflag |= (ISIG|ICANON|ECHO); ! 152: return(ret); ! 153: } ! 154: ! 155: /*** ! 156: * sytfixline(tty, spwant) set speed/echo/mode... ! 157: * int tty, spwant; ! 158: * ! 159: * return codes: none ! 160: */ ! 161: ! 162: sytfixline(tty, spwant) ! 163: int tty, spwant; ! 164: { ! 165: struct termio ttbuf; ! 166: struct sg_spds *ps; ! 167: int speed = -1; ! 168: int ret; ! 169: ! 170: for (ps = spds; ps->sp_val >= 0; ps++) ! 171: if (ps->sp_val == spwant) ! 172: speed = ps->sp_name; ! 173: DEBUG(4, "sytfixline - speed= %d\n", speed); ! 174: ASSERT(speed >= 0, "BAD SPEED", "", speed); ! 175: (void) ioctl(tty, TCGETA, &ttbuf); ! 176: ttbuf.c_iflag = (ushort)0; ! 177: ttbuf.c_oflag = (ushort)0; ! 178: ttbuf.c_lflag = (ushort)0; ! 179: ttbuf.c_cflag = speed; ! 180: ttbuf.c_cflag |= (CS8|CLOCAL); ! 181: ttbuf.c_cc[VMIN] = 6; ! 182: ttbuf.c_cc[VTIME] = 1; ! 183: ret = ioctl(tty, TCSETAW, &ttbuf); ! 184: ASSERT(ret >= 0, "RETURN FROM sytfixline", "", ret); ! 185: return; ! 186: } ! 187: ! 188: sytfix2line(tty) ! 189: int tty; ! 190: { ! 191: struct termio ttbuf; ! 192: int ret; ! 193: ! 194: (void) ioctl(tty, TCGETA, &ttbuf); ! 195: ttbuf.c_cflag &= ~CLOCAL; ! 196: ttbuf.c_cflag |= CREAD|HUPCL; ! 197: ret = ioctl(tty, TCSETAW, &ttbuf); ! 198: ASSERT(ret >= 0, "RETURN FROM sytfix2line", "", ret); ! 199: return; ! 200: } ! 201: ! 202: ! 203: restline() ! 204: { ! 205: return(ioctl(0, TCSETA, &Savettyb)); ! 206: } ! 207: ! 208: #else !ATTSV ! 209: ! 210: static struct sgttyb Savettyb; ! 211: ! 212: /*** ! 213: * fixline(tty, spwant, type) set speed/echo/mode... ! 214: * int tty, spwant; ! 215: * ! 216: * if spwant == 0, speed is untouched ! 217: * type is unused, but needed for compatibility ! 218: * ! 219: * return codes: none ! 220: */ ! 221: ! 222: /*ARGSUSED*/ ! 223: fixline(tty, spwant, type) ! 224: int tty, spwant, type; ! 225: { ! 226: struct sgttyb ttbuf; ! 227: struct sg_spds *ps; ! 228: int speed = -1; ! 229: ! 230: DEBUG(6, "fixline(%d, ", tty); ! 231: DEBUG(6, "%d)\n", spwant); ! 232: ! 233: if (ioctl(tty, TIOCGETP, &ttbuf) != 0) ! 234: return; ! 235: if (spwant > 0) { ! 236: for (ps = spds; ps->sp_val; ps++) ! 237: if (ps->sp_val == spwant) { ! 238: speed = ps->sp_name; ! 239: break; ! 240: } ! 241: ASSERT(speed >= 0, "BAD SPEED", "", speed); ! 242: ttbuf.sg_ispeed = ttbuf.sg_ospeed = speed; ! 243: } else { ! 244: for (ps = spds; ps->sp_val; ps++) ! 245: if (ps->sp_name == ttbuf.sg_ispeed) { ! 246: spwant = ps->sp_val; ! 247: break; ! 248: } ! 249: ASSERT(spwant >= 0, "BAD SPEED", "", spwant); ! 250: } ! 251: ttbuf.sg_flags = (ANYP | RAW); ! 252: (void) ioctl(tty, TIOCSETP, &ttbuf); ! 253: (void) ioctl(tty, TIOCHPCL, STBNULL); ! 254: (void) ioctl(tty, TIOCEXCL, STBNULL); ! 255: linebaudrate = spwant; /* for hacks in pk driver */ ! 256: return; ! 257: } ! 258: ! 259: sethup(dcf) ! 260: int dcf; ! 261: { ! 262: if (isatty(dcf)) ! 263: (void) ioctl(dcf, TIOCHPCL, STBNULL); ! 264: } ! 265: ! 266: /*** ! 267: * genbrk send a break ! 268: * ! 269: * return codes; none ! 270: */ ! 271: ! 272: genbrk(fn) ! 273: { ! 274: if (isatty(fn)) { ! 275: (void) ioctl(fn, TIOCSBRK, 0); ! 276: #ifndef V8 ! 277: nap(HZ/10); /* 0.1 second break */ ! 278: (void) ioctl(fn, TIOCCBRK, 0); ! 279: #endif ! 280: } ! 281: return; ! 282: } ! 283: ! 284: /* ! 285: * V7 and RT aren't smart enough for this -- linebaudrate is the best ! 286: * they can do. ! 287: */ ! 288: /*ARGSUSED*/ ! 289: setline(dummy) { } ! 290: ! 291: savline() ! 292: { ! 293: int ret; ! 294: ! 295: ret = ioctl(0, TIOCGETP, &Savettyb); ! 296: Savettyb.sg_flags |= ECHO; ! 297: Savettyb.sg_flags &= ~RAW; ! 298: return(ret); ! 299: } ! 300: ! 301: restline() ! 302: { ! 303: return(ioctl(0, TIOCSETP, &Savettyb)); ! 304: } ! 305: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.