static void qio_channel_websock_write_close(QIOChannelWebsock *ioc,

                                            uint16_t code, const char *reason)

{

    struct iovec iov;

    buffer_reserve(&ioc->rawoutput, 2 + (reason ? strlen(reason) : 0));

    *(uint16_t *)(ioc->rawoutput.buffer + ioc->rawoutput.offset) =

        cpu_to_be16(code);

    ioc->rawoutput.offset += 2;

    if (reason) {

        buffer_append(&ioc->rawoutput, reason, strlen(reason));

    }

    iov.iov_base = ioc->rawoutput.buffer;

    iov.iov_len = ioc->rawoutput.offset;

    qio_channel_websock_encode(ioc, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,

                               &iov, 1, iov.iov_len);

    buffer_reset(&ioc->rawoutput);

    qio_channel_websock_write_wire(ioc, NULL);

    qio_channel_shutdown(ioc->master, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);

}

static void qio_channel_websock_write_close(QIOChannelWebsock *ioc,

                                            uint16_t code, const char *reason)

{

    struct iovec iov;

    buffer_reserve(&ioc->rawoutput, 2 + (reason ? strlen(reason) : 0));

    *(uint16_t *)(ioc->rawoutput.buffer + ioc->rawoutput.offset) =

        cpu_to_be16(code);

    ioc->rawoutput.offset += 2;

    if (reason) {

        buffer_append(&ioc->rawoutput, reason, strlen(reason));

    }

    iov.iov_base = ioc->rawoutput.buffer;

    iov.iov_len = ioc->rawoutput.offset;

    qio_channel_websock_encode(ioc, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,

                               &iov, 1, iov.iov_len);

    buffer_reset(&ioc->rawoutput);

    qio_channel_websock_write_wire(ioc, NULL);

    qio_channel_shutdown(ioc->master, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);

}

static void FUNC_0(QIOChannelWebsock *VAR_0,

                                            uint16_t VAR_1, const char *VAR_2)

{

    struct iovec VAR_3;

    buffer_reserve(&VAR_0->rawoutput, 2 + (VAR_2 ? strlen(VAR_2) : 0));

    *(uint16_t *)(VAR_0->rawoutput.buffer + VAR_0->rawoutput.offset) =

        cpu_to_be16(VAR_1);

    VAR_0->rawoutput.offset += 2;

    if (VAR_2) {

        buffer_append(&VAR_0->rawoutput, VAR_2, strlen(VAR_2));

    }

    VAR_3.iov_base = VAR_0->rawoutput.buffer;

    VAR_3.iov_len = VAR_0->rawoutput.offset;

    qio_channel_websock_encode(VAR_0, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,

                               &VAR_3, 1, VAR_3.iov_len);

    buffer_reset(&VAR_0->rawoutput);

    qio_channel_websock_write_wire(VAR_0, NULL);

    qio_channel_shutdown(VAR_0->master, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);

}

static void FUNC_0(QIOChannelWebsock *VAR_0,
uint16_t VAR_1, const char *VAR_2)
{ struct iovec VAR_3; buffer_reserve(&VAR_0->rawoutput, 2 + (VAR_2 ? strlen(VAR_2) : 0)); *(uint16_t *)(VAR_0->rawoutput.buffer + VAR_0->rawoutput.offset) =
cpu_to_be16(VAR_1); VAR_0->rawoutput.offset += 2; if (VAR_2) { buffer_append(&VAR_0->rawoutput, VAR_2, strlen(VAR_2)); } VAR_3.iov_base = VAR_0->rawoutput.buffer; VAR_3.iov_len = VAR_0->rawoutput.offset; qio_channel_websock_encode(VAR_0, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,
&VAR_3, 1, VAR_3.iov_len); buffer_reset(&VAR_0->rawoutput); qio_channel_websock_write_wire(VAR_0, NULL); qio_channel_shutdown(VAR_0->master, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); }