from_backend(0, buf, len);
}
-static int raw_receive (Socket s, int urgent, char *data, int len) {
- if (!len) {
- /* Connection has closed. */
- sk_close(s);
- s = NULL;
- return 0;
- }
+static int raw_closing (Plug plug, char *error_msg, int error_code, int calling_back) {
+ sk_close(s);
+ s = NULL;
+ if (error_msg) {
+ /* A socket error has occurred. */
+ connection_fatal (error_msg);
+ } /* Otherwise, the remote side closed the connection normally. */
+ return 0;
+}
+
+static int raw_receive (Plug plug, int urgent, char *data, int len) {
c_write(data, len);
return 1;
}
* Also places the canonical host name into `realhost'.
*/
static char *raw_init (char *host, int port, char **realhost) {
+ static struct plug_function_table fn_table = {
+ raw_closing,
+ raw_receive
+ }, *fn_table_ptr = &fn_table;
+
SockAddr addr;
char *err;
/*
* Open socket.
*/
- s = sk_new(addr, port, raw_receive);
+ s = sk_new(addr, port, 0, 1, &fn_table_ptr);
if ( (err = sk_socket_error(s)) )
return err;
sk_addr_free(addr);
- /*
- * We have no pre-session phase.
- */
- begin_session();
-
return NULL;
}
static int raw_sendok(void) { return 1; }
+static int raw_ldisc(int option) {
+ if (option == LD_EDIT || option == LD_ECHO)
+ return 1;
+ return 0;
+}
+
Backend raw_backend = {
raw_init,
raw_send,
raw_special,
raw_socket,
raw_sendok,
+ raw_ldisc,
1
};