/[inetutils]/inetutils/telnetd/termstat.c
ViewVC logotype

Diff of /inetutils/telnetd/termstat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by alainm, Wed Jul 19 04:08:39 2000 UTC revision 1.7 by gray, Fri Apr 5 00:04:12 2002 UTC
# Line 31  Line 31 
31  static char sccsid[] = "@(#)termstat.c  8.2 (Berkeley) 5/30/95";  static char sccsid[] = "@(#)termstat.c  8.2 (Berkeley) 5/30/95";
32  #endif /* not lint */  #endif /* not lint */
33    
 #ifdef HAVE_CONFIG_H  
 #include <config.h>  
 #endif  
   
34  #include "telnetd.h"  #include "telnetd.h"
35    
36  /*  /*
# Line 44  int def_tspeed = -1, def_rspeed = -1; Line 40  int def_tspeed = -1, def_rspeed = -1;
40  #ifdef  TIOCSWINSZ  #ifdef  TIOCSWINSZ
41  int def_row = 0, def_col = 0;  int def_row = 0, def_col = 0;
42  #endif  #endif
 #ifdef  LINEMODE  
43  static int _terminit = 0;  static int _terminit = 0;
 #endif  /* LINEMODE */  
44    
45  #if     defined(CRAY2) && defined(UNICOS5)  #if     defined(CRAY2) && defined(UNICOS5)
46  int     newmap = 1;     /* nonzero if \n maps to ^M^J */  int     newmap = 1;     /* nonzero if \n maps to ^M^J */
47  #endif  #endif
48    
 #ifdef  LINEMODE  
49  /*  /*
50   * localstat   * localstat
51   *   *
# Line 224  localstat() Line 217  localstat()
217                          send_wont(TELOPT_ECHO, 1);                          send_wont(TELOPT_ECHO, 1);
218                  else                  else
219                          need_will_echo = 1;                          need_will_echo = 1;
 #ifdef  KLUDGELINEMODE  
220                  if (lmodetype == KLUDGE_OK)                  if (lmodetype == KLUDGE_OK)
221                          lmodetype = KLUDGE_LINEMODE;                          lmodetype = KLUDGE_LINEMODE;
 #endif  
222          }          }
223    
224          /*          /*
# Line 235  localstat() Line 226  localstat()
226           * command and then we're all done.           * command and then we're all done.
227           */           */
228           if (!uselinemode && linemode) {           if (!uselinemode && linemode) {
 # ifdef KLUDGELINEMODE  
229                  if (lmodetype == REAL_LINEMODE) {                  if (lmodetype == REAL_LINEMODE) {
 # endif /* KLUDGELINEMODE */  
230                          send_dont(TELOPT_LINEMODE, 1);                          send_dont(TELOPT_LINEMODE, 1);
 # ifdef KLUDGELINEMODE  
231                  } else if (lmodetype == KLUDGE_LINEMODE)                  } else if (lmodetype == KLUDGE_LINEMODE)
232                          send_will(TELOPT_SGA, 1);                          send_will(TELOPT_SGA, 1);
 # endif /* KLUDGELINEMODE */  
233                  send_will(TELOPT_ECHO, 1);                  send_will(TELOPT_ECHO, 1);
234                  linemode = uselinemode;                  linemode = uselinemode;
235                  goto done;                  goto done;
236          }          }
237    
 # ifdef KLUDGELINEMODE  
238          /*          /*
239           * If using real linemode check edit modes for possible later use.           * If using real linemode check edit modes for possible later use.
240           * If we are in kludge linemode, do the SGA negotiation.           * If we are in kludge linemode, do the SGA negotiation.
241           */           */
242          if (lmodetype == REAL_LINEMODE) {          if (lmodetype == REAL_LINEMODE) {
 # endif /* KLUDGELINEMODE */  
243                  useeditmode = 0;                  useeditmode = 0;
244                  if (tty_isediting())                  if (tty_isediting())
245                          useeditmode |= MODE_EDIT;                          useeditmode |= MODE_EDIT;
# Line 264  localstat() Line 249  localstat()
249                          useeditmode |= MODE_SOFT_TAB;                          useeditmode |= MODE_SOFT_TAB;
250                  if (tty_islitecho())                  if (tty_islitecho())
251                          useeditmode |= MODE_LIT_ECHO;                          useeditmode |= MODE_LIT_ECHO;
 # ifdef KLUDGELINEMODE  
252          } else if (lmodetype == KLUDGE_LINEMODE) {          } else if (lmodetype == KLUDGE_LINEMODE) {
253                  if (tty_isediting() && uselinemode)                  if (tty_isediting() && uselinemode)
254                          send_wont(TELOPT_SGA, 1);                          send_wont(TELOPT_SGA, 1);
255                  else                  else
256                          send_will(TELOPT_SGA, 1);                          send_will(TELOPT_SGA, 1);
257          }          }
 # endif /* KLUDGELINEMODE */  
258    
259          /*          /*
260           * Negotiate linemode on if pty state has changed to turn it on.           * Negotiate linemode on if pty state has changed to turn it on.
261           * Send appropriate command and send along edit mode, then all done.           * Send appropriate command and send along edit mode, then all done.
262           */           */
263          if (uselinemode && !linemode) {          if (uselinemode && !linemode) {
 # ifdef KLUDGELINEMODE  
264                  if (lmodetype == KLUDGE_LINEMODE) {                  if (lmodetype == KLUDGE_LINEMODE) {
265                          send_wont(TELOPT_SGA, 1);                          send_wont(TELOPT_SGA, 1);
266                  } else if (lmodetype == REAL_LINEMODE) {                  } else if (lmodetype == REAL_LINEMODE) {
 # endif /* KLUDGELINEMODE */  
267                          send_do(TELOPT_LINEMODE, 1);                          send_do(TELOPT_LINEMODE, 1);
268                          /* send along edit modes */                          /* send along edit modes */
269                          (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,                          net_output_data("%c%c%c%c%c%c%c", IAC, SB,
270                                  TELOPT_LINEMODE, LM_MODE, useeditmode,                                  TELOPT_LINEMODE, LM_MODE, useeditmode,
271                                  IAC, SE);                                  IAC, SE);
                         nfrontp += 7;  
272                          editmode = useeditmode;                          editmode = useeditmode;
 # ifdef KLUDGELINEMODE  
273                  }                  }
 # endif /* KLUDGELINEMODE */  
274                  linemode = uselinemode;                  linemode = uselinemode;
275                  goto done;                  goto done;
276          }          }
277    
 # ifdef KLUDGELINEMODE  
278          /*          /*
279           * None of what follows is of any value if not using           * None of what follows is of any value if not using
280           * real linemode.           * real linemode.
281           */           */
282          if (lmodetype < REAL_LINEMODE)          if (lmodetype < REAL_LINEMODE)
283                  goto done;                  goto done;
 # endif /* KLUDGELINEMODE */  
284    
285          if (linemode && his_state_is_will(TELOPT_LINEMODE)) {          if (linemode && his_state_is_will(TELOPT_LINEMODE)) {
286                  /*                  /*
# Line 314  localstat() Line 290  localstat()
290                          /*                          /*
291                           * Send along appropriate edit mode mask.                           * Send along appropriate edit mode mask.
292                           */                           */
293                          (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,                          net_output_data("%c%c%c%c%c%c%c", IAC, SB,
294                                  TELOPT_LINEMODE, LM_MODE, useeditmode,                                  TELOPT_LINEMODE, LM_MODE, useeditmode,
295                                  IAC, SE);                                  IAC, SE);
                         nfrontp += 7;  
296                          editmode = useeditmode;                          editmode = useeditmode;
297                  }                  }
298    
# Line 348  done: Line 323  done:
323          return;          return;
324    
325  }  /* end of localstat */  }  /* end of localstat */
 #endif  /* LINEMODE */  
326    
327  /*  /*
328   * flowstat   * flowstat
# Line 361  flowstat() Line 335  flowstat()
335          if (his_state_is_will(TELOPT_LFLOW)) {          if (his_state_is_will(TELOPT_LFLOW)) {
336                  if (tty_flowmode() != flowmode) {                  if (tty_flowmode() != flowmode) {
337                          flowmode = tty_flowmode();                          flowmode = tty_flowmode();
338                          (void) sprintf(nfrontp, "%c%c%c%c%c%c",                          net_output_data ("%c%c%c%c%c%c",
339                                          IAC, SB, TELOPT_LFLOW,                                          IAC, SB, TELOPT_LFLOW,
340                                          flowmode ? LFLOW_ON : LFLOW_OFF,                                          flowmode ? LFLOW_ON : LFLOW_OFF,
341                                          IAC, SE);                                          IAC, SE);
                         nfrontp += 6;  
342                  }                  }
343                  if (tty_restartany() != restartany) {                  if (tty_restartany() != restartany) {
344                          restartany = tty_restartany();                          restartany = tty_restartany();
345                          (void) sprintf(nfrontp, "%c%c%c%c%c%c",                          net_output_data ("%c%c%c%c%c%c",
346                                          IAC, SB, TELOPT_LFLOW,                                          IAC, SB, TELOPT_LFLOW,
347                                          restartany ? LFLOW_RESTART_ANY                                          restartany ? LFLOW_RESTART_ANY
348                                                     : LFLOW_RESTART_XON,                                                     : LFLOW_RESTART_XON,
349                                          IAC, SE);                                          IAC, SE);
                         nfrontp += 6;  
350                  }                  }
351          }          }
352  }  }
# Line 401  clientstat(register int code, register i Line 373  clientstat(register int code, register i
373           * Process request from client. code tells what it is.           * Process request from client. code tells what it is.
374           */           */
375          switch (code) {          switch (code) {
 #ifdef  LINEMODE  
376          case TELOPT_LINEMODE:          case TELOPT_LINEMODE:
377                  /*                  /*
378                   * Don't do anything unless client is asking us to change                   * Don't do anything unless client is asking us to change
# Line 409  clientstat(register int code, register i Line 380  clientstat(register int code, register i
380                   */                   */
381                  uselinemode = (parm1 == WILL);                  uselinemode = (parm1 == WILL);
382                  if (uselinemode != linemode) {                  if (uselinemode != linemode) {
 # ifdef KLUDGELINEMODE  
383                          /*                          /*
384                           * If using kludge linemode, make sure that                           * If using kludge linemode, make sure that
385                           * we can do what the client asks.                           * we can do what the client asks.
# Line 433  clientstat(register int code, register i Line 403  clientstat(register int code, register i
403                           * turned on, send along the edit mode mask.                           * turned on, send along the edit mode mask.
404                           */                           */
405                          if (lmodetype == REAL_LINEMODE && uselinemode)                          if (lmodetype == REAL_LINEMODE && uselinemode)
 # else  /* KLUDGELINEMODE */  
406                          if (uselinemode)                          if (uselinemode)
 # endif /* KLUDGELINEMODE */  
407                          {                          {
408                                  useeditmode = 0;                                  useeditmode = 0;
409                                  if (tty_isediting())                                  if (tty_isediting())
# Line 446  clientstat(register int code, register i Line 414  clientstat(register int code, register i
414                                          useeditmode |= MODE_SOFT_TAB;                                          useeditmode |= MODE_SOFT_TAB;
415                                  if (tty_islitecho())                                  if (tty_islitecho())
416                                          useeditmode |= MODE_LIT_ECHO;                                          useeditmode |= MODE_LIT_ECHO;
417                                  (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,                                  net_output_data ("%c%c%c%c%c%c%c", IAC,
418                                          SB, TELOPT_LINEMODE, LM_MODE,                                          SB, TELOPT_LINEMODE, LM_MODE,
419                                                          useeditmode, IAC, SE);                                                          useeditmode, IAC, SE);
                                 nfrontp += 7;  
420                                  editmode = useeditmode;                                  editmode = useeditmode;
421                          }                          }
422    
# Line 505  clientstat(register int code, register i Line 472  clientstat(register int code, register i
472                          set_termbuf();                          set_termbuf();
473    
474                          if (!ack) {                          if (!ack) {
475                                  (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,                                  net_output_data ("%c%c%c%c%c%c%c", IAC,
476                                          SB, TELOPT_LINEMODE, LM_MODE,                                          SB, TELOPT_LINEMODE, LM_MODE,
477                                          useeditmode|MODE_ACK,                                          useeditmode|MODE_ACK,
478                                          IAC, SE);                                          IAC, SE);
                                 nfrontp += 7;  
479                          }                          }
480    
481                          editmode = useeditmode;                          editmode = useeditmode;
# Line 518  clientstat(register int code, register i Line 484  clientstat(register int code, register i
484                  break;                  break;
485    
486              }  /* end of case LM_MODE */              }  /* end of case LM_MODE */
 #endif  /* LINEMODE */  
487    
488          case TELOPT_NAWS:          case TELOPT_NAWS:
489  #ifdef  TIOCSWINSZ  #ifdef  TIOCSWINSZ
# Line 527  clientstat(register int code, register i Line 492  clientstat(register int code, register i
492    
493                  def_col = parm1;                  def_col = parm1;
494                  def_row = parm2;                  def_row = parm2;
 #ifdef  LINEMODE  
495                  /*                  /*
496                   * Defer changing window size until after terminal is                   * Defer changing window size until after terminal is
497                   * initialized.                   * initialized.
498                   */                   */
499                  if (terminit() == 0)                  if (terminit() == 0)
500                          return;                          return;
 #endif  /* LINEMODE */  
501    
502                  /*                  /*
503                   * Change window size as requested by client.                   * Change window size as requested by client.
# Line 552  clientstat(register int code, register i Line 515  clientstat(register int code, register i
515              {              {
516                  def_tspeed = parm1;                  def_tspeed = parm1;
517                  def_rspeed = parm2;                  def_rspeed = parm2;
 #ifdef  LINEMODE  
518                  /*                  /*
519                   * Defer changing the terminal speed.                   * Defer changing the terminal speed.
520                   */                   */
521                  if (terminit() == 0)                  if (terminit() == 0)
522                          return;                          return;
 #endif  /* LINEMODE */  
523                  /*                  /*
524                   * Change terminal speed as requested by client.                   * Change terminal speed as requested by client.
525                   * We set the receive speed first, so that if we can't                   * We set the receive speed first, so that if we can't
# Line 606  _termstat() Line 567  _termstat()
567  }  }
568  #endif  /* defined(CRAY2) && defined(UNICOS5) */  #endif  /* defined(CRAY2) && defined(UNICOS5) */
569    
 #ifdef  LINEMODE  
570  /*  /*
571   * defer_terminit   * defer_terminit
572   *   *
# Line 656  terminit() Line 616  terminit()
616          return(_terminit);          return(_terminit);
617    
618  }  /* end of terminit */  }  /* end of terminit */
 #endif  /* LINEMODE */  

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26