-static Socket s = NULL;
-
-static void raw_size(void);
-
-static int sb_opt, sb_len;
-static char *sb_buf = NULL;
-static int sb_size = 0;
-#define SB_DELTA 1024
-
-static void c_write (char *buf, int len) {
- from_backend(0, buf, len);
-}
-
-static int raw_receive (Socket skt, int urgent, char *data, int len) {
- if (urgent==3) {
- /* A socket error has occurred. */
- sk_close(s);
- s = NULL;
- connection_fatal(data);
- len = 0;
- return 0;
- } else if (!len) {
- /* Connection has closed. */
- sk_close(s);
- s = NULL;
- return 0;
+#define RAW_MAX_BACKLOG 4096
+
+typedef struct raw_backend_data {
+ const struct plug_function_table *fn;
+ /* the above field _must_ be first in the structure */
+
+ Socket s;
+ int bufsize;
+ void *frontend;
+} *Raw;
+
+static void raw_size(void *handle, int width, int height);
+
+static void c_write(Raw raw, char *buf, int len)
+{
+ int backlog = from_backend(raw->frontend, 0, buf, len);
+ sk_set_frozen(raw->s, backlog > RAW_MAX_BACKLOG);
+}
+
+static int raw_closing(Plug plug, char *error_msg, int error_code,
+ int calling_back)
+{
+ Raw raw = (Raw) plug;
+
+ if (raw->s) {
+ sk_close(raw->s);
+ raw->s = NULL;