void x11_send(Socket s, char *data, int len)
int x11_send(Socket s, char *data, int len)
void x11_send(Socket s, char *data, int len){    struct X11Private *pr = (struct X11Private *) sk_get_private_ptr(s);    if (s == NULL)	return;    /*     * Read the first packet.     */    while (len > 0 && pr->data_read < 12)	pr->firstpkt[pr->data_read++] = (unsigned char) (len--, *data++);    if (pr->data_read < 12)	return;    /*     * If we have not allocated the auth_protocol and auth_data     * strings, do so now.     */    if (!pr->auth_protocol) {	pr->auth_plen = GET_16BIT(pr->firstpkt[0], pr->firstpkt + 6);	pr->auth_dlen = GET_16BIT(pr->firstpkt[0], pr->firstpkt + 8);	pr->auth_psize = (pr->auth_plen + 3) & ~3;	pr->auth_dsize = (pr->auth_dlen + 3) & ~3;	/* Leave room for a terminating zero, to make our lives easier. */	pr->auth_protocol = (char *) smalloc(pr->auth_psize + 1);	pr->auth_data = (char *) smalloc(pr->auth_dsize);    }    /*     * Read the auth_protocol and auth_data strings.     */    while (len > 0 && pr->data_read < 12 + pr->auth_psize)	pr->auth_protocol[pr->data_read++ - 12] = (len--, *data++);    while (len > 0 && pr->data_read < 12 + pr->auth_psize + pr->auth_dsize)	pr->auth_data[pr->data_read++ - 12 -		      pr->auth_psize] = (unsigned char) (len--, *data++);    if (pr->data_read < 12 + pr->auth_psize + pr->auth_dsize)	return;    /*     * If we haven't verified the authentication, do so now.     */    if (!pr->verified) {	int ret;	pr->auth_protocol[pr->auth_plen] = '\0';	/* ASCIZ */	ret = x11_verify(pr->auth_protocol, pr->auth_data, pr->auth_dlen);	/*	 * If authentication failed, construct and send an error	 * packet, then terminate the connection.	 */	if (!ret) {	    char message[] = "Authentication failed at PuTTY X11 proxy";	    unsigned char reply[8 + sizeof(message) + 4];	    int msglen = sizeof(message) - 1;	/* skip zero byte */	    int msgsize = (msglen + 3) & ~3;	    reply[0] = 0;	       /* failure */	    reply[1] = msglen;	       /* length of reason string */	    memcpy(reply + 2, pr->firstpkt + 2, 4);	/* major/minor proto vsn */	    PUT_16BIT(pr->firstpkt[0], reply + 6, msglen >> 2);	/* data len */	    memset(reply + 8, 0, msgsize);	    memcpy(reply + 8, message, msglen);	    sshfwd_write(pr->c, reply, 8 + msgsize);	    sshfwd_close(pr->c);	    x11_close(s);	    return;	}	/*	 * Now we know we're going to accept the connection. Strip	 * the auth data. (TODO: if we ever work out how, we should	 * replace some real auth data in here.)	 */	PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 6, 0);	/* auth proto */	PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 8, 0);	/* auth data */	sk_write(s, pr->firstpkt, 12);	pr->verified = 1;    }    /*     * After initialisation, just copy data simply.     */    sk_write(s, data, len);}