code:ttystty - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 此函数 为 gtty 和 stty 的"公共部分"(名不副实...)
- 传入2个参数 atp , av
- atp : 指定 的 struct tty
- av : 一个缓存区,用来交换tty状态
- 对该函数作用说明如下
- av = 0 时,本函数由stty调用
- av != 0 时,本函数由gtty调用
8571 /* Common code for gtty and stty functions on typewriters.
8572 * If v is non-zero then gtty is being done and information
8573 * is passed back therein;
8574 * if it is zero stty is being done and the input inform-
8575 * ation is in the u_arg array.
8576 */
8577 ttystty(atp, av)
8578 int *atp, *av;
8579 {
8580 register *tp, *v;
8581 tp = atp;
8582 if(v = av) {
8583 *v++ = tp->t_speeds;
8584 v->lobyte = tp->t_erase;
8585 v->hibyte = tp->t_kill;
8586 v[1] = tp->t_flags;
8587 return(1);
gtty调用的部分8588 }
- 向v中 传入 tty 参数
- 返回1
8589 wflushtty(tp);
8590 v = u.u_arg;
8591 tp->t_speeds = *v++;
8592 tp->t_erase = v->lobyte;
8593 tp->t_kill = v->hibyte;
8594 tp->t_flags = v[1];
8595 return(0);
stty调用的部分8596 }
- "清空" tp 的队列
- 从v中 设置 tty 参数
- 返回0
8597 /* ------------------------- */
8598
8599