static int qio_channel_websock_handshake_send_response(QIOChannelWebsock *ioc,

                                                       const char *key,

                                                       Error **errp)

{

    char combined_key[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                      QIO_CHANNEL_WEBSOCK_GUID_LEN + 1];

    char *accept = NULL, *response = NULL;

    size_t responselen;



    g_strlcpy(combined_key, key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1);

    g_strlcat(combined_key, QIO_CHANNEL_WEBSOCK_GUID,

              QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

              QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);



    /* hash and encode it */

    if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,

                            combined_key,

                            QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                            QIO_CHANNEL_WEBSOCK_GUID_LEN,

                            &accept,

                            errp) < 0) {

        return -1;

    }



    response = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, accept);

    responselen = strlen(response);

    buffer_reserve(&ioc->encoutput, responselen);

    buffer_append(&ioc->encoutput, response, responselen);



    g_free(accept);

    g_free(response);



    return 0;

}

static int qio_channel_websock_handshake_send_response(QIOChannelWebsock *ioc,

                                                       const char *key,

                                                       Error **errp)

{

    char combined_key[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                      QIO_CHANNEL_WEBSOCK_GUID_LEN + 1];

    char *accept = NULL, *response = NULL;

    size_t responselen;



    g_strlcpy(combined_key, key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1);

    g_strlcat(combined_key, QIO_CHANNEL_WEBSOCK_GUID,

              QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

              QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);



    

    if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,

                            combined_key,

                            QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                            QIO_CHANNEL_WEBSOCK_GUID_LEN,

                            &accept,

                            errp) < 0) {

        return -1;

    }



    response = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, accept);

    responselen = strlen(response);

    buffer_reserve(&ioc->encoutput, responselen);

    buffer_append(&ioc->encoutput, response, responselen);



    g_free(accept);

    g_free(response);



    return 0;

}

static int qio_channel_websock_handshake_send_response(QIOChannelWebsock *ioc,                                                        const char *key,                                                        Error **errp)     char *accept = NULL, *response = NULL;     size_t responselen;         return -1;     response = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, accept);     responselen = strlen(response);     buffer_reserve(&ioc->encoutput, responselen);     buffer_append(&ioc->encoutput, response, responselen);     g_free(response);     return 0;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;         return -1;
static int FUNC_0(QIOChannelWebsock *VAR_0,

                                                       const char *VAR_1,

                                                       Error **VAR_2)

{

    char VAR_3[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                      QIO_CHANNEL_WEBSOCK_GUID_LEN + 1];

    char *VAR_4 = NULL, *VAR_5 = NULL;

    size_t responselen;



    g_strlcpy(VAR_3, VAR_1, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1);

    g_strlcat(VAR_3, QIO_CHANNEL_WEBSOCK_GUID,

              QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

              QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);



    

    if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,

                            VAR_3,

                            QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +

                            QIO_CHANNEL_WEBSOCK_GUID_LEN,

                            &VAR_4,

                            VAR_2) < 0) {

        return -1;

    }



    VAR_5 = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, VAR_4);

    responselen = strlen(VAR_5);

    buffer_reserve(&VAR_0->encoutput, responselen);

    buffer_append(&VAR_0->encoutput, VAR_5, responselen);



    g_free(VAR_4);

    g_free(VAR_5);



    return 0;

}

static int FUNC_0(QIOChannelWebsock *VAR_0,
const char *VAR_1,
Error **VAR_2)
{ char VAR_3[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1]; char *VAR_4 = NULL, *VAR_5 = NULL; size_t responselen; g_strlcpy(VAR_3, VAR_1, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1); g_strlcat(VAR_3, QIO_CHANNEL_WEBSOCK_GUID,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1); if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,
VAR_3,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN,
&VAR_4,
VAR_2) < 0) { return -1; } VAR_5 = g_strdup_printf(QIO_CHANNEL_WEBSOCK_HANDSHAKE_RESPONSE, VAR_4); responselen = strlen(VAR_5); buffer_reserve(&VAR_0->encoutput, responselen); buffer_append(&VAR_0->encoutput, VAR_5, responselen); g_free(VAR_4); g_free(VAR_5); return 0; }