1 16 package org.apache.commons.net.telnet; 17 18 23 public class TerminalTypeOptionHandler extends TelnetOptionHandler 24 { 25 28 private String termType = null; 29 30 33 protected static final int TERMINAL_TYPE = 24; 34 35 38 protected static final int TERMINAL_TYPE_SEND = 1; 39 40 43 protected static final int TERMINAL_TYPE_IS = 0; 44 45 57 public TerminalTypeOptionHandler(String termtype, 58 boolean initlocal, 59 boolean initremote, 60 boolean acceptlocal, 61 boolean acceptremote) 62 { 63 super(TelnetOption.TERMINAL_TYPE, initlocal, initremote, 64 acceptlocal, acceptremote); 65 termType = termtype; 66 } 67 68 74 public TerminalTypeOptionHandler(String termtype) 75 { 76 super(TelnetOption.TERMINAL_TYPE, false, false, false, false); 77 termType = termtype; 78 } 79 80 88 public int[] answerSubnegotiation(int suboptionData[], int suboptionLength) 89 { 90 if ((suboptionData != null) && (suboptionLength > 1) 91 && (termType != null)) 92 { 93 if ((suboptionData[0] == TERMINAL_TYPE) 94 && (suboptionData[1] == TERMINAL_TYPE_SEND)) 95 { 96 int response[] = new int[termType.length() + 2]; 97 98 response[0] = TERMINAL_TYPE; 99 response[1] = TERMINAL_TYPE_IS; 100 101 for (int ii = 0; ii < termType.length(); ii++) 102 { 103 response[ii + 2] = (int) termType.charAt(ii); 104 } 105 106 return response; 107 } 108 } 109 return null; 110 } 111 112 117 public int[] startSubnegotiationLocal() 118 { 119 return null; 120 } 121 122 127 public int[] startSubnegotiationRemote() 128 { 129 return null; 130 } 131 } 132 | Popular Tags |