Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 1 | /* |
Sean Middleditch | 9de1598 | 2009-03-14 03:35:49 -0400 | [diff] [blame] | 2 | * Sean Middleditch |
| 3 | * sean@sourcemud.org |
| 4 | * |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 5 | * The author or authors of this code dedicate any and all copyright interest |
| 6 | * in this code to the public domain. We make this dedication for the benefit |
| 7 | * of the public at large and to the detriment of our heirs and successors. We |
| 8 | * intend this dedication to be an overt act of relinquishment in perpetuity of |
| 9 | * all present and future rights to this code under copyright law. |
| 10 | */ |
| 11 | |
Sean Middleditch | 6aef073 | 2009-03-12 23:27:35 -0400 | [diff] [blame] | 12 | #if !defined(LIBTELNET_INCLUDE) |
Sean Middleditch | aac2c12 | 2009-03-14 18:31:26 -0400 | [diff] [blame] | 13 | #define LIBTELNET_INCLUDE 1 |
Sean Middleditch | 6aef073 | 2009-03-12 23:27:35 -0400 | [diff] [blame] | 14 | |
Sean Middleditch | e22b477 | 2009-03-22 16:44:40 -0400 | [diff] [blame] | 15 | /* printf type checking feature in GCC and some other compilers */ |
| 16 | #if __GNUC__ |
| 17 | # define TELNET_GNU_PRINTF(f,a) __attribute__((format(printf, f, a))) |
| 18 | # define TELNET_GNU_SENTINEL __attribute__((sentinel)) |
| 19 | #else |
| 20 | # define TELNET_GNU_PRINTF(f,a) |
| 21 | # define TELNET_GNU_SENTINEL |
| 22 | #endif |
| 23 | |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 24 | /* forward declarations */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 25 | typedef struct telnet_t telnet_t; |
| 26 | typedef struct telnet_event_t telnet_event_t; |
Sean Middleditch | 34bb099 | 2009-03-21 00:20:44 -0400 | [diff] [blame] | 27 | typedef struct telnet_telopt_t telnet_telopt_t; |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 28 | |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 29 | /* telnet special values */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 30 | #define TELNET_IAC 255 |
| 31 | #define TELNET_DONT 254 |
| 32 | #define TELNET_DO 253 |
| 33 | #define TELNET_WONT 252 |
| 34 | #define TELNET_WILL 251 |
| 35 | #define TELNET_SB 250 |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 36 | #define TELNET_GA 249 |
| 37 | #define TELNET_EL 248 |
| 38 | #define TELNET_EC 247 |
| 39 | #define TELNET_AYT 246 |
| 40 | #define TELNET_AO 245 |
| 41 | #define TELNET_IP 244 |
| 42 | #define TELNET_BREAK 243 |
| 43 | #define TELNET_DM 242 |
| 44 | #define TELNET_NOP 241 |
| 45 | #define TELNET_SE 240 |
| 46 | #define TELNET_EOR 239 |
| 47 | #define TELNET_ABORT 238 |
| 48 | #define TELNET_SUSP 237 |
| 49 | #define TELNET_EOF 236 |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 50 | |
| 51 | /* telnet options */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 52 | #define TELNET_TELOPT_BINARY 0 |
| 53 | #define TELNET_TELOPT_ECHO 1 |
| 54 | #define TELNET_TELOPT_RCP 2 |
| 55 | #define TELNET_TELOPT_SGA 3 |
| 56 | #define TELNET_TELOPT_NAMS 4 |
| 57 | #define TELNET_TELOPT_STATUS 5 |
| 58 | #define TELNET_TELOPT_TM 6 |
| 59 | #define TELNET_TELOPT_RCTE 7 |
| 60 | #define TELNET_TELOPT_NAOL 8 |
| 61 | #define TELNET_TELOPT_NAOP 9 |
| 62 | #define TELNET_TELOPT_NAOCRD 10 |
| 63 | #define TELNET_TELOPT_NAOHTS 11 |
| 64 | #define TELNET_TELOPT_NAOHTD 12 |
| 65 | #define TELNET_TELOPT_NAOFFD 13 |
| 66 | #define TELNET_TELOPT_NAOVTS 14 |
| 67 | #define TELNET_TELOPT_NAOVTD 15 |
| 68 | #define TELNET_TELOPT_NAOLFD 16 |
| 69 | #define TELNET_TELOPT_XASCII 17 |
| 70 | #define TELNET_TELOPT_LOGOUT 18 |
| 71 | #define TELNET_TELOPT_BM 19 |
| 72 | #define TELNET_TELOPT_DET 20 |
| 73 | #define TELNET_TELOPT_SUPDUP 21 |
| 74 | #define TELNET_TELOPT_SUPDUPOUTPUT 22 |
| 75 | #define TELNET_TELOPT_SNDLOC 23 |
| 76 | #define TELNET_TELOPT_TTYPE 24 |
| 77 | #define TELNET_TELOPT_EOR 25 |
| 78 | #define TELNET_TELOPT_TUID 26 |
| 79 | #define TELNET_TELOPT_OUTMRK 27 |
| 80 | #define TELNET_TELOPT_TTYLOC 28 |
| 81 | #define TELNET_TELOPT_3270REGIME 29 |
| 82 | #define TELNET_TELOPT_X3PAD 30 |
| 83 | #define TELNET_TELOPT_NAWS 31 |
| 84 | #define TELNET_TELOPT_TSPEED 32 |
| 85 | #define TELNET_TELOPT_LFLOW 33 |
| 86 | #define TELNET_TELOPT_LINEMODE 34 |
| 87 | #define TELNET_TELOPT_XDISPLOC 35 |
| 88 | #define TELNET_TELOPT_ENVIRON 36 |
| 89 | #define TELNET_TELOPT_AUTHENTICATION 37 |
| 90 | #define TELNET_TELOPT_ENCRYPT 38 |
| 91 | #define TELNET_TELOPT_NEW_ENVIRON 39 |
Sean Middleditch | e2122b2 | 2009-03-20 23:55:09 -0400 | [diff] [blame] | 92 | #define TELNET_TELOPT_MSSP 70 |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 93 | #define TELNET_TELOPT_COMPRESS2 86 |
| 94 | #define TELNET_TELOPT_ZMP 93 |
| 95 | #define TELNET_TELOPT_EXOPL 255 |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 96 | |
Sean Middleditch | e2122b2 | 2009-03-20 23:55:09 -0400 | [diff] [blame] | 97 | #define TELNET_TELOPT_MCCP2 86 |
| 98 | |
Sean Middleditch | 2d5c499 | 2009-03-22 22:21:42 -0400 | [diff] [blame^] | 99 | /* special codes for the subnegotiation commands for certain telopts */ |
| 100 | #define TELNET_TTYPE_IS 0 |
| 101 | #define TELNET_TTYPE_SEND 1 |
| 102 | |
| 103 | #define TELNET_ENVIRON_IS 0 |
| 104 | #define TELNET_ENVIRON_SEND 1 |
| 105 | #define TELNET_ENVIRON_INFO 2 |
| 106 | #define TELNET_ENVIRON_VAR 0 |
| 107 | #define TELNET_ENVIRON_VALUE 1 |
| 108 | #define TELNET_ENVIRON_ESC 2 |
| 109 | #define TELNET_ENVIRON_USERVAR 3 |
| 110 | |
| 111 | #define TELNET_MSSP_VAR 1 |
| 112 | #define TELNET_MSSP_VAL 2 |
| 113 | |
Sean Middleditch | 08bb05f | 2009-03-15 23:29:46 -0400 | [diff] [blame] | 114 | /* libtelnet feature flags */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 115 | #define TELNET_FLAG_PROXY (1<<0) |
Sean Middleditch | 61f8eb6 | 2009-03-14 04:57:27 -0400 | [diff] [blame] | 116 | |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 117 | #define TELNET_PFLAG_DEFLATE (1<<7) |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 118 | |
| 119 | /* telnet states */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 120 | enum telnet_state_t { |
| 121 | TELNET_STATE_DATA = 0, |
| 122 | TELNET_STATE_IAC, |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 123 | TELNET_STATE_WILL, |
| 124 | TELNET_STATE_WONT, |
Sean Middleditch | 447d3ad | 2009-03-20 23:22:37 -0400 | [diff] [blame] | 125 | TELNET_STATE_DO, |
| 126 | TELNET_STATE_DONT, |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 127 | TELNET_STATE_SB, |
| 128 | TELNET_STATE_SB_DATA, |
| 129 | TELNET_STATE_SB_DATA_IAC |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 130 | }; |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 131 | typedef enum telnet_state_t telnet_state_t; |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 132 | |
| 133 | /* error codes */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 134 | enum telnet_error_t { |
| 135 | TELNET_EOK = 0, |
| 136 | TELNET_EBADVAL, /* invalid parameter, or API misuse */ |
| 137 | TELNET_ENOMEM, /* memory allocation failure */ |
| 138 | TELNET_EOVERFLOW, /* data exceeds buffer size */ |
| 139 | TELNET_EPROTOCOL, /* invalid sequence of special bytes */ |
| 140 | TELNET_ECOMPRESS /* error handling compressed streams */ |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 141 | }; |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 142 | typedef enum telnet_error_t telnet_error_t; |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 143 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 144 | /* event codes */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 145 | enum telnet_event_type_t { |
| 146 | TELNET_EV_DATA = 0, |
| 147 | TELNET_EV_SEND, |
| 148 | TELNET_EV_IAC, |
| 149 | TELNET_EV_WILL, |
| 150 | TELNET_EV_WONT, |
| 151 | TELNET_EV_DO, |
| 152 | TELNET_EV_DONT, |
| 153 | TELNET_EV_SUBNEGOTIATION, |
| 154 | TELNET_EV_COMPRESS, |
| 155 | TELNET_EV_WARNING, |
| 156 | TELNET_EV_ERROR |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 157 | }; |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 158 | typedef enum telnet_event_type_t telnet_event_type_t; |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 159 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 160 | /* event information */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 161 | struct telnet_event_t { |
Sean Middleditch | e5327da | 2009-03-21 00:54:50 -0400 | [diff] [blame] | 162 | /* ZMP argument list */ |
| 163 | const char **argv; |
| 164 | size_t argc; |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 165 | /* data buffer: for DATA, SEND, SUBNEGOTIATION, and ERROR events */ |
Sean Middleditch | 8daf774 | 2009-03-19 02:05:24 -0400 | [diff] [blame] | 166 | const char *buffer; |
Sean Middleditch | 340a51b | 2009-03-19 02:08:46 -0400 | [diff] [blame] | 167 | size_t size; |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 168 | /* type of event */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 169 | enum telnet_event_type_t type; |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 170 | /* IAC command */ |
| 171 | unsigned char command; |
| 172 | /* telopt info: for negotiation events SUBNEGOTIATION */ |
| 173 | unsigned char telopt; |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 174 | }; |
| 175 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 176 | /* event handler declaration */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 177 | typedef void (*telnet_event_handler_t)(telnet_t *telnet, |
| 178 | telnet_event_t *event, void *user_data); |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 179 | |
Sean Middleditch | 34bb099 | 2009-03-21 00:20:44 -0400 | [diff] [blame] | 180 | /* telopt support table element; use telopt of -1 for end marker */ |
| 181 | struct telnet_telopt_t { |
Sean Middleditch | bfc641e | 2009-03-22 16:26:06 -0400 | [diff] [blame] | 182 | short telopt; /* one of the TELOPT codes or -1 */ |
| 183 | unsigned char us; /* TELNET_WILL or TELNET_WONT */ |
| 184 | unsigned char him; /* TELNET_DO or TELNET_DONT */ |
Sean Middleditch | 34bb099 | 2009-03-21 00:20:44 -0400 | [diff] [blame] | 185 | }; |
| 186 | |
Sean Middleditch | 4d9444d | 2009-03-13 22:48:05 -0400 | [diff] [blame] | 187 | /* state tracker */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 188 | struct telnet_t { |
Sean Middleditch | 9f79cc5 | 2009-03-15 13:39:24 -0400 | [diff] [blame] | 189 | /* user data */ |
| 190 | void *ud; |
Sean Middleditch | 34bb099 | 2009-03-21 00:20:44 -0400 | [diff] [blame] | 191 | /* telopt support table */ |
| 192 | const telnet_telopt_t *telopts; |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 193 | /* event handler */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 194 | telnet_event_handler_t eh; |
Sean Middleditch | 9de1598 | 2009-03-14 03:35:49 -0400 | [diff] [blame] | 195 | #ifdef HAVE_ZLIB |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 196 | /* zlib (mccp2) compression */ |
Sean Middleditch | fbe93e3 | 2009-03-15 23:39:31 -0400 | [diff] [blame] | 197 | z_stream *z; |
Sean Middleditch | 9de1598 | 2009-03-14 03:35:49 -0400 | [diff] [blame] | 198 | #endif |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 199 | /* RFC1143 option negotiation states */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 200 | struct telnet_rfc1143_t *q; |
Sean Middleditch | 4d9444d | 2009-03-13 22:48:05 -0400 | [diff] [blame] | 201 | /* sub-request buffer */ |
Sean Middleditch | 8daf774 | 2009-03-19 02:05:24 -0400 | [diff] [blame] | 202 | char *buffer; |
Sean Middleditch | 4d9444d | 2009-03-13 22:48:05 -0400 | [diff] [blame] | 203 | /* current size of the buffer */ |
Sean Middleditch | 340a51b | 2009-03-19 02:08:46 -0400 | [diff] [blame] | 204 | size_t buffer_size; |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 205 | /* current buffer write position (also length of buffer data) */ |
Sean Middleditch | 340a51b | 2009-03-19 02:08:46 -0400 | [diff] [blame] | 206 | size_t buffer_pos; |
Sean Middleditch | 4d9444d | 2009-03-13 22:48:05 -0400 | [diff] [blame] | 207 | /* current state */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 208 | enum telnet_state_t state; |
Sean Middleditch | 08bb05f | 2009-03-15 23:29:46 -0400 | [diff] [blame] | 209 | /* option flags */ |
| 210 | unsigned char flags; |
Sean Middleditch | da0e695 | 2009-03-15 13:28:09 -0400 | [diff] [blame] | 211 | /* current subnegotiation telopt */ |
| 212 | unsigned char sb_telopt; |
Sean Middleditch | 5b5bc92 | 2009-03-15 23:02:10 -0400 | [diff] [blame] | 213 | /* length of RFC1143 queue */ |
| 214 | unsigned char q_size; |
Sean Middleditch | 4d9444d | 2009-03-13 22:48:05 -0400 | [diff] [blame] | 215 | }; |
| 216 | |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 217 | /* initialize a telnet state tracker */ |
Sean Middleditch | 34bb099 | 2009-03-21 00:20:44 -0400 | [diff] [blame] | 218 | extern void telnet_init(telnet_t *telnet, const telnet_telopt_t *telopts, |
| 219 | telnet_event_handler_t eh, unsigned char flags, void *user_data); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 220 | |
| 221 | /* free up any memory allocated by a state tracker */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 222 | extern void telnet_free(telnet_t *telnet); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 223 | |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 224 | /* push a byte buffer into the state tracker */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 225 | extern void telnet_recv(telnet_t *telnet, const char *buffer, |
Sean Middleditch | 340a51b | 2009-03-19 02:08:46 -0400 | [diff] [blame] | 226 | size_t size); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 227 | |
| 228 | /* send an iac command */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 229 | extern void telnet_iac(telnet_t *telnet, unsigned char cmd); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 230 | |
Sean Middleditch | 2b4bfc4 | 2009-03-16 01:25:52 -0400 | [diff] [blame] | 231 | /* send negotiation, with RFC1143 checking. |
| 232 | * will not actually send unless necessary, but will update internal |
| 233 | * negotiation queue. |
| 234 | */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 235 | extern void telnet_negotiate(telnet_t *telnet, unsigned char cmd, |
Sean Middleditch | 812358d | 2009-03-15 23:24:03 -0400 | [diff] [blame] | 236 | unsigned char opt); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 237 | |
| 238 | /* send non-command data (escapes IAC bytes) */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 239 | extern void telnet_send(telnet_t *telnet, |
Sean Middleditch | 340a51b | 2009-03-19 02:08:46 -0400 | [diff] [blame] | 240 | const char *buffer, size_t size); |
Sean Middleditch | 2914485 | 2009-03-12 23:14:47 -0400 | [diff] [blame] | 241 | |
Sean Middleditch | 90e79da | 2009-03-19 15:17:13 -0400 | [diff] [blame] | 242 | /* send IAC SB followed by the telopt code */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 243 | extern void telnet_begin_sb(telnet_t *telnet, |
Sean Middleditch | 90e79da | 2009-03-19 15:17:13 -0400 | [diff] [blame] | 244 | unsigned char telopt); |
| 245 | |
| 246 | /* send IAC SE */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 247 | #define telnet_finish_sb(telnet) telnet_iac((telnet), TELNET_SE) |
Sean Middleditch | 90e79da | 2009-03-19 15:17:13 -0400 | [diff] [blame] | 248 | |
| 249 | /* shortcut for sending a complete subnegotiation buffer. |
| 250 | * equivalent to: |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 251 | * telnet_begin_sb(telnet, telopt); |
| 252 | * telnet_send(telnet, buffer, size); |
| 253 | * telnet_finish_sb(telnet); |
Sean Middleditch | 2b4bfc4 | 2009-03-16 01:25:52 -0400 | [diff] [blame] | 254 | */ |
Sean Middleditch | 4f0c37f | 2009-03-20 23:08:55 -0400 | [diff] [blame] | 255 | extern void telnet_subnegotiation(telnet_t *telnet, unsigned char telopt, |
Sean Middleditch | 90e79da | 2009-03-19 15:17:13 -0400 | [diff] [blame] | 256 | const char *buffer, size_t size); |
Sean Middleditch | 6aef073 | 2009-03-12 23:27:35 -0400 | [diff] [blame] | 257 | |
Sean Middleditch | 124a1c2 | 2009-03-15 13:20:03 -0400 | [diff] [blame] | 258 | /* begin sending compressed data (server only) */ |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 259 | extern void telnet_begin_compress2(telnet_t *telnet); |
Sean Middleditch | 124a1c2 | 2009-03-15 13:20:03 -0400 | [diff] [blame] | 260 | |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 261 | /* send formatted data with \r and \n translated, and IAC escaped */ |
Sean Middleditch | e22b477 | 2009-03-22 16:44:40 -0400 | [diff] [blame] | 262 | extern int telnet_printf(telnet_t *telnet, const char *fmt, ...) |
| 263 | TELNET_GNU_PRINTF(2, 3); |
Sean Middleditch | 4a15604 | 2009-03-16 17:10:58 -0400 | [diff] [blame] | 264 | |
Sean Middleditch | f65f27d | 2009-03-19 02:32:04 -0400 | [diff] [blame] | 265 | /* send formatted data with just IAC escaped */ |
Sean Middleditch | e22b477 | 2009-03-22 16:44:40 -0400 | [diff] [blame] | 266 | extern int telnet_printf2(telnet_t *telnet, const char *fmt, ...) |
| 267 | TELNET_GNU_PRINTF(2, 3); |
| 268 | |
| 269 | /* send ZMP commands */ |
| 270 | extern void telnet_send_zmp(telnet_t *telnet, size_t argc, const char **argv); |
| 271 | extern void telnet_send_zmpv(telnet_t *telnet, ...) TELNET_GNU_SENTINEL; |
Sean Middleditch | d58f49f | 2009-03-16 12:49:35 -0400 | [diff] [blame] | 272 | |
Sean Middleditch | 6aef073 | 2009-03-12 23:27:35 -0400 | [diff] [blame] | 273 | #endif /* !defined(LIBTELNET_INCLUDE) */ |