Esempio n. 1
0
void DS::Stream::writeSafeString(const ST::string& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        ST::utf16_buffer buffer = value.to_utf16();
        uint16_t length = value.size() & 0x0FFF;
        ST::utf16_buffer work;
        char16_t* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char16_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char16_t));
        write<char16_t>(0);
    } else {
        ST::char_buffer buffer = (format == e_StringUTF8) ? value.to_utf8()
                               : value.to_latin_1(ST::substitute_invalid);
        uint16_t length = value.size() & 0x0FFF;
        ST::char_buffer work;
        char* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char));
    }
}
Esempio n. 2
0
void DS::Stream::writeString(const ST::string& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        ST::utf16_buffer buffer = value.to_utf16();
        writeBytes(buffer.data(), buffer.size() * sizeof(char16_t));
    } else {
        ST::char_buffer buffer = (format == e_StringUTF8) ? value.to_utf8()
                               : value.to_latin_1(ST::substitute_invalid);
        writeBytes(buffer.data(), buffer.size() * sizeof(char));
    }
}
Esempio n. 3
0
void cb_authServIpAddress(GateKeeper_Private& client)
{
    START_REPLY(e_GateKeeperToCli_AuthServIpAddressReply);

    // Trans ID
    client.m_buffer.write<uint32_t>(DS::CryptRecvValue<uint32_t>(client.m_sock, client.m_crypt));

    // Address
    ST::utf16_buffer address = DS::Settings::AuthServerAddress();
    client.m_buffer.write<uint16_t>(address.size());
    client.m_buffer.writeBytes(address.data(), address.size() * sizeof(char16_t));

    SEND_REPLY();
}