| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Putty
Revision: 8156
Author: simon
Date: 31 Aug 2008 13:12:37
Changes:Minor code cleanup: I just happened to be looking at this file for
other reasons and I noticed that the list of TELOPTs is given twice
and hence needs to be kept in sync. Replace with my now-standard
second-order-macro approach which allows the list to be maintained
in only one place.
| ... | ...@@ -36,60 +36,65 @@ | |
| 36 | 36 | #define SUSP 237 /* Suspend process */ |
| 37 | 37 | #define xEOF 236 /* End of file: EOF is already used... */ |
| 38 | 38 | |
| 39 | #define TELOPT_BINARY 0 /* 8-bit data path */ | |
| 40 | #define TELOPT_ECHO 1 /* echo */ | |
| 41 | #define TELOPT_RCP 2 /* prepare to reconnect */ | |
| 42 | #define TELOPT_SGA 3 /* suppress go ahead */ | |
| 43 | #define TELOPT_NAMS 4 /* approximate message size */ | |
| 44 | #define TELOPT_STATUS 5 /* give status */ | |
| 45 | #define TELOPT_TM 6 /* timing mark */ | |
| 46 | #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ | |
| 47 | #define TELOPT_NAOL 8 /* negotiate about output line width */ | |
| 48 | #define TELOPT_NAOP 9 /* negotiate about output page size */ | |
| 49 | #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ | |
| 50 | #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ | |
| 51 | #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ | |
| 52 | #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ | |
| 53 | #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ | |
| 54 | #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ | |
| 55 | #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ | |
| 56 | #define TELOPT_XASCII 17 /* extended ascic character set */ | |
| 57 | #define TELOPT_LOGOUT 18 /* force logout */ | |
| 58 | #define TELOPT_BM 19 /* byte macro */ | |
| 59 | #define TELOPT_DET 20 /* data entry terminal */ | |
| 60 | #define TELOPT_SUPDUP 21 /* supdup protocol */ | |
| 61 | #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ | |
| 62 | #define TELOPT_SNDLOC 23 /* send location */ | |
| 63 | #define TELOPT_TTYPE 24 /* terminal type */ | |
| 64 | #define TELOPT_EOR 25 /* end or record */ | |
| 65 | #define TELOPT_TUID 26 /* TACACS user identification */ | |
| 66 | #define TELOPT_OUTMRK 27 /* output marking */ | |
| 67 | #define TELOPT_TTYLOC 28 /* terminal location number */ | |
| 68 | #define TELOPT_3270REGIME 29 /* 3270 regime */ | |
| 69 | #define TELOPT_X3PAD 30 /* X.3 PAD */ | |
| 70 | #define TELOPT_NAWS 31 /* window size */ | |
| 71 | #define TELOPT_TSPEED 32 /* terminal speed */ | |
| 72 | #define TELOPT_LFLOW 33 /* remote flow control */ | |
| 73 | #define TELOPT_LINEMODE 34 /* Linemode option */ | |
| 74 | #define TELOPT_XDISPLOC 35 /* X Display Location */ | |
| 75 | #define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ | |
| 76 | #define TELOPT_AUTHENTICATION 37 /* Authenticate */ | |
| 77 | #define TELOPT_ENCRYPT 38 /* Encryption option */ | |
| 78 | #define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ | |
| 79 | #define TELOPT_TN3270E 40 /* TN3270 enhancements */ | |
| 80 | #define TELOPT_XAUTH 41 | |
| 81 | #define TELOPT_CHARSET 42 /* Character set */ | |
| 82 | #define TELOPT_RSP 43 /* Remote serial port */ | |
| 83 | #define TELOPT_COM_PORT_OPTION 44 /* Com port control */ | |
| 84 | #define TELOPT_SLE 45 /* Suppress local echo */ | |
| 85 | #define TELOPT_STARTTLS 46 /* Start TLS */ | |
| 86 | #define TELOPT_KERMIT 47 /* Automatic Kermit file transfer */ | |
| 87 | #define TELOPT_SEND_URL 48 | |
| 88 | #define TELOPT_FORWARD_X 49 | |
| 89 | #define TELOPT_PRAGMA_LOGON 138 | |
| 90 | #define TELOPT_SSPI_LOGON 139 | |
| 91 | #define TELOPT_PRAGMA_HEARTBEAT 140 | |
| 92 | #define TELOPT_EXOPL 255 /* extended-options-list */ | |
| 39 | #define TELOPTS(X) \ | |
| 40 | X(BINARY, 0) /* 8-bit data path */ \ | |
| 41 | X(ECHO, 1) /* echo */ \ | |
| 42 | X(RCP, 2) /* prepare to reconnect */ \ | |
| 43 | X(SGA, 3) /* suppress go ahead */ \ | |
| 44 | X(NAMS, 4) /* approximate message size */ \ | |
| 45 | X(STATUS, 5) /* give status */ \ | |
| 46 | X(TM, 6) /* timing mark */ \ | |
| 47 | X(RCTE, 7) /* remote controlled transmission and echo */ \ | |
| 48 | X(NAOL, 8) /* negotiate about output line width */ \ | |
| 49 | X(NAOP, 9) /* negotiate about output page size */ \ | |
| 50 | X(NAOCRD, 10) /* negotiate about CR disposition */ \ | |
| 51 | X(NAOHTS, 11) /* negotiate about horizontal tabstops */ \ | |
| 52 | X(NAOHTD, 12) /* negotiate about horizontal tab disposition */ \ | |
| 53 | X(NAOFFD, 13) /* negotiate about formfeed disposition */ \ | |
| 54 | X(NAOVTS, 14) /* negotiate about vertical tab stops */ \ | |
| 55 | X(NAOVTD, 15) /* negotiate about vertical tab disposition */ \ | |
| 56 | X(NAOLFD, 16) /* negotiate about output LF disposition */ \ | |
| 57 | X(XASCII, 17) /* extended ascic character set */ \ | |
| 58 | X(LOGOUT, 18) /* force logout */ \ | |
| 59 | X(BM, 19) /* byte macro */ \ | |
| 60 | X(DET, 20) /* data entry terminal */ \ | |
| 61 | X(SUPDUP, 21) /* supdup protocol */ \ | |
| 62 | X(SUPDUPOUTPUT, 22) /* supdup output */ \ | |
| 63 | X(SNDLOC, 23) /* send location */ \ | |
| 64 | X(TTYPE, 24) /* terminal type */ \ | |
| 65 | X(EOR, 25) /* end or record */ \ | |
| 66 | X(TUID, 26) /* TACACS user identification */ \ | |
| 67 | X(OUTMRK, 27) /* output marking */ \ | |
| 68 | X(TTYLOC, 28) /* terminal location number */ \ | |
| 69 | X(3270REGIME, 29) /* 3270 regime */ \ | |
| 70 | X(X3PAD, 30) /* X.3 PAD */ \ | |
| 71 | X(NAWS, 31) /* window size */ \ | |
| 72 | X(TSPEED, 32) /* terminal speed */ \ | |
| 73 | X(LFLOW, 33) /* remote flow control */ \ | |
| 74 | X(LINEMODE, 34) /* Linemode option */ \ | |
| 75 | X(XDISPLOC, 35) /* X Display Location */ \ | |
| 76 | X(OLD_ENVIRON, 36) /* Old - Environment variables */ \ | |
| 77 | X(AUTHENTICATION, 37) /* Authenticate */ \ | |
| 78 | X(ENCRYPT, 38) /* Encryption option */ \ | |
| 79 | X(NEW_ENVIRON, 39) /* New - Environment variables */ \ | |
| 80 | X(TN3270E, 40) /* TN3270 enhancements */ \ | |
| 81 | X(XAUTH, 41) \ | |
| 82 | X(CHARSET, 42) /* Character set */ \ | |
| 83 | X(RSP, 43) /* Remote serial port */ \ | |
| 84 | X(COM_PORT_OPTION, 44) /* Com port control */ \ | |
| 85 | X(SLE, 45) /* Suppress local echo */ \ | |
| 86 | X(STARTTLS, 46) /* Start TLS */ \ | |
| 87 | X(KERMIT, 47) /* Automatic Kermit file transfer */ \ | |
| 88 | X(SEND_URL, 48) \ | |
| 89 | X(FORWARD_X, 49) \ | |
| 90 | X(PRAGMA_LOGON, 138) \ | |
| 91 | X(SSPI_LOGON, 139) \ | |
| 92 | X(PRAGMA_HEARTBEAT, 140) \ | |
| 93 | X(EXOPL, 255) /* extended-options-list */ | |
| 94 | ||
| 95 | #define telnet_enum(x,y) TELOPT_##x = y, | |
| 96 | enum { TELOPTS(telnet_enum) dummy=0 }; | |
| 97 | #undef telnet_enum | |
| 93 | 98 | |
| 94 | 99 | #define TELQUAL_IS 0 /* option is... */ |
| 95 | 100 | #define TELQUAL_SEND 1 /* send option */ |
| ... | ...@@ -109,62 +114,13 @@ | |
| 109 | 114 | |
| 110 | 115 | static char *telopt(int opt) |
| 111 | 116 | { |
| 112 | #define i(x) if (opt == TELOPT_ ## x) return #x; | |
| 113 | i(BINARY); | |
| 114 | i(ECHO); | |
| 115 | i(RCP); | |
| 116 | i(SGA); | |
| 117 | i(NAMS); | |
| 118 | i(STATUS); | |
| 119 | i(TM); | |
| 120 | i(RCTE); | |
| 121 | i(NAOL); | |
| 122 | i(NAOP); | |
| 123 | i(NAOCRD); | |
| 124 | i(NAOHTS); | |
| 125 | i(NAOHTD); | |
| 126 | i(NAOFFD); | |
| 127 | i(NAOVTS); | |
| 128 | i(NAOVTD); | |
| 129 | i(NAOLFD); | |
| 130 | i(XASCII); | |
| 131 | i(LOGOUT); | |
| 132 | i(BM); | |
| 133 | i(DET); | |
| 134 | i(SUPDUP); | |
| 135 | i(SUPDUPOUTPUT); | |
| 136 | i(SNDLOC); | |
| 137 | i(TTYPE); | |
| 138 | i(EOR); | |
| 139 | i(TUID); | |
| 140 | i(OUTMRK); | |
| 141 | i(TTYLOC); | |
| 142 | i(X3PAD); | |
| 143 | i(NAWS); | |
| 144 | i(TSPEED); | |
| 145 | i(LFLOW); | |
| 146 | i(LINEMODE); | |
| 147 | i(XDISPLOC); | |
| 148 | i(OLD_ENVIRON); | |
| 149 | i(AUTHENTICATION); | |
| 150 | i(ENCRYPT); | |
| 151 | i(NEW_ENVIRON); | |
| 152 | i(TN3270E); | |
| 153 | i(XAUTH); | |
| 154 | i(CHARSET); | |
| 155 | i(RSP); | |
| 156 | i(COM_PORT_OPTION); | |
| 157 | i(SLE); | |
| 158 | i(STARTTLS); | |
| 159 | i(KERMIT); | |
| 160 | i(SEND_URL); | |
| 161 | i(FORWARD_X); | |
| 162 | i(PRAGMA_LOGON); | |
| 163 | i(SSPI_LOGON); | |
| 164 | i(PRAGMA_HEARTBEAT); | |
| 165 | i(EXOPL); | |
| 166 | #undef i | |
| 167 | return "<unknown>"; | |
| 117 | #define telnet_str(x,y) case TELOPT_##x: return #x; | |
| 118 | switch (opt) { | |
| 119 | TELOPTS(telnet_str) | |
| 120 | default: | |
| 121 | return "<unknown>"; | |
| 122 | } | |
| 123 | #undef telnet_str | |
| 168 | 124 | } |
| 169 | 125 | |
| 170 | 126 | static void telnet_size(void *handle, int width, int height); |