14 #define RAW_MAX_BACKLOG 4096
16 static Socket s = NULL;
17 static int raw_bufsize;
18 static void *frontend;
20 static void raw_size(void);
22 static void c_write(char *buf, int len)
24 int backlog = from_backend(frontend, 0, buf, len);
25 sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
28 static int raw_closing(Plug plug, char *error_msg, int error_code,
36 /* A socket error has occurred. */
38 connection_fatal("%s", error_msg);
39 } /* Otherwise, the remote side closed the connection normally. */
43 static int raw_receive(Plug plug, int urgent, char *data, int len)
49 static void raw_sent(Plug plug, int bufsize)
51 raw_bufsize = bufsize;
55 * Called to set up the raw connection.
57 * Returns an error message, or NULL on success.
59 * Also places the canonical host name into `realhost'. It must be
60 * freed by the caller.
62 static char *raw_init(void *frontend_handle, char *host, int port,
63 char **realhost, int nodelay)
65 static struct plug_function_table fn_table = {
69 }, *fn_table_ptr = &fn_table;
74 frontend = frontend_handle;
81 sprintf(buf, "Looking up host \"%.170s\"", host);
84 addr = sk_namelookup(host, realhost);
85 if ((err = sk_addr_error(addr)))
89 port = 23; /* default telnet port */
95 char buf[200], addrbuf[100];
96 sk_getaddr(addr, addrbuf, 100);
97 sprintf(buf, "Connecting to %.100s port %d", addrbuf, port);
100 s = new_connection(addr, *realhost, port, 0, 1, nodelay, &fn_table_ptr);
101 if ((err = sk_socket_error(s)))
110 * Called to send data down the raw connection.
112 static int raw_send(char *buf, int len)
117 raw_bufsize = sk_write(s, buf, len);
123 * Called to query the current socket sendability status.
125 static int raw_sendbuffer(void)
131 * Called to set the size of the window
133 static void raw_size(void)
140 * Send raw special codes.
142 static void raw_special(Telnet_Special code)
148 static Socket raw_socket(void)
153 static int raw_sendok(void)
158 static void raw_unthrottle(int backlog)
160 sk_set_frozen(s, backlog > RAW_MAX_BACKLOG);
163 static int raw_ldisc(int option)
165 if (option == LD_EDIT || option == LD_ECHO)
170 static int raw_exitcode(void)
172 /* Exit codes are a meaningless concept in the Raw protocol */
176 Backend raw_backend = {