int GetPropertyReplyStore::decodeIdentity(DecodeBuffer &decodeBuffer, unsigned char *&buffer, unsigned int &size, int bigEndian, WriteBuffer *writeBuffer, ChannelCache *channelCache) const { ServerCache *serverCache = (ServerCache *) channelCache; #ifdef DEBUG *logofs << name() << ": Decoding full message identity.\n" << logofs_flush; #endif unsigned char format; decodeBuffer.decodeCachedValue(format, 8, serverCache -> getPropertyFormatCache); unsigned int length; decodeBuffer.decodeValue(length, 32, 9); unsigned int numBytes = length; if (format == 16) { numBytes <<= 1; } else if (format == 32) { numBytes <<= 2; } size = 32 + RoundUp4(numBytes); buffer = writeBuffer -> addMessage(size); *(buffer + 1) = format; PutULONG(length, buffer + 16, bigEndian); unsigned int value; decodeBuffer.decodeCachedValue(value, 29, serverCache -> getPropertyTypeCache, 9); PutULONG(value, buffer + 8, bigEndian); decodeBuffer.decodeValue(value, 32, 9); PutULONG(value, buffer + 12, bigEndian); #ifdef DEBUG *logofs << name() << ": Decoded full message identity.\n" << logofs_flush; #endif return 1; }
void SetUnpackColormapCompatStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message, ChannelCache *channelCache) const { SetUnpackColormapCompatMessage *setUnpackColormap = (SetUnpackColormapCompatMessage *) message; ClientCache *clientCache = (ClientCache *) channelCache; unsigned int value; decodeBuffer.decodeCachedValue(setUnpackColormap -> client, 8, clientCache -> resourceCache); #ifdef DEBUG *logofs << name() << ": Decoded value " << (unsigned int) setUnpackColormap -> client << " as client field.\n" << logofs_flush; #endif decodeBuffer.decodeBoolValue(value); if (value) { decodeBuffer.decodeValue(value, 32, 9); setUnpackColormap -> entries = value; #ifdef DEBUG *logofs << name() << ": Decoded value " << setUnpackColormap -> entries << " as entries field.\n" << logofs_flush; #endif } }
int SetUnpackColormapCompatStore::decodeIdentity(DecodeBuffer &decodeBuffer, unsigned char *&buffer, unsigned int &size, int bigEndian, WriteBuffer *writeBuffer, ChannelCache *channelCache) const { ClientCache *clientCache = (ClientCache *) channelCache; #ifdef DEBUG *logofs << name() << ": Decoding full message identity.\n" << logofs_flush; #endif unsigned int value; unsigned char cValue; // Client. decodeBuffer.decodeCachedValue(cValue, 8, clientCache -> resourceCache); // Entries. decodeBuffer.decodeValue(value, 32, 9); size = (value << 2) + 8; buffer = writeBuffer -> addMessage(size); *(buffer + 1) = cValue; PutULONG(value, buffer + 4, bigEndian); #ifdef DEBUG *logofs << name() << ": Decoded full message identity.\n" << logofs_flush; #endif return 1; }
int SetUnpackColormapStore::decodeIdentity(DecodeBuffer &decodeBuffer, unsigned char *&buffer, unsigned int &size, int bigEndian, WriteBuffer *writeBuffer, ChannelCache *channelCache) const { ClientCache *clientCache = (ClientCache *) channelCache; #ifdef DEBUG *logofs << name() << ": Decoding full message identity.\n" << logofs_flush; #endif unsigned int value; unsigned char cValue; // SrcLength. decodeBuffer.decodeValue(value, 32, 9); size = RoundUp4(value) + 16; buffer = writeBuffer -> addMessage(size); PutULONG(value, buffer + 8, bigEndian); // Client. decodeBuffer.decodeCachedValue(cValue, 8, clientCache -> resourceCache); *(buffer + 1) = cValue; // Method. decodeBuffer.decodeCachedValue(cValue, 8, clientCache -> methodCache); *(buffer + 4) = cValue; // DstLength. decodeBuffer.decodeValue(value, 32, 9); PutULONG(value, buffer + 12, bigEndian); #ifdef DEBUG *logofs << name() << ": Decoded full message identity.\n" << logofs_flush; #endif return 1; }
int StaticCompressor::decompressBuffer(unsigned char *plainBuffer, unsigned int plainSize, const unsigned char *&compressedBuffer, unsigned int &compressedSize, DecodeBuffer &decodeBuffer) { #ifdef DEBUG *logofs << "StaticCompressor: Called for buffer at " << (void *) plainBuffer << ".\n" << logofs_flush; #endif unsigned int value; decodeBuffer.decodeBoolValue(value); if (value == 0) { memcpy(plainBuffer, decodeBuffer.decodeMemory(plainSize), plainSize); return 0; } unsigned int checkSize = plainSize; decodeBuffer.decodeValue(value, 32, 14); compressedSize = value; decodeBuffer.decodeValue(value, 32, 14); checkSize = value; // // If caller needs the original compressed // data it must copy this to its own buffer // before using any further decode function. // compressedBuffer = decodeBuffer.decodeMemory(compressedSize); int result = ZDecompress(&decompressionStream_, plainBuffer, &checkSize, compressedBuffer, compressedSize); if (result != Z_OK) { #ifdef PANIC *logofs << "StaticCompressor: PANIC! Failure decompressing buffer. " << "Error is '" << zError(result) << "'.\n" << logofs_flush; #endif cerr << "Error" << ": Failure decompressing buffer. " << "Error is '" << zError(result) << "'.\n"; return -1; } else if (plainSize != checkSize) { #ifdef PANIC *logofs << "StaticCompressor: PANIC! Expected decompressed size was " << plainSize << " while it is " << checkSize << ".\n" << logofs_flush; #endif cerr << "Error" << ": Expected decompressed size was " << plainSize << " while it is " << checkSize << ".\n"; return -1; } return 1; }
void SendEventStore::updateIdentity(DecodeBuffer &decodeBuffer, const Message *message, ChannelCache *channelCache) const { SendEventMessage *sendEvent = (SendEventMessage *) message; ClientCache *clientCache = (ClientCache *) channelCache; unsigned int value; decodeBuffer.decodeBoolValue(value); sendEvent -> propagate = value; #ifdef DEBUG *logofs << name() << ": Decoded value " << (unsigned int) sendEvent -> propagate << " as propagate field.\n" << logofs_flush; #endif decodeBuffer.decodeBoolValue(value); if (value) { decodeBuffer.decodeBoolValue(value); } else { decodeBuffer.decodeXidValue(value, clientCache -> windowCache); } sendEvent -> window = value; #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> window << " as window field.\n" << logofs_flush; #endif decodeBuffer.decodeCachedValue(sendEvent -> mask, 32, clientCache -> sendEventMaskCache); #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> mask << " as mask field.\n" << logofs_flush; #endif decodeBuffer.decodeCachedValue(sendEvent -> code, 8, clientCache -> sendEventCodeCache); #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> code << " as code field.\n" << logofs_flush; #endif decodeBuffer.decodeCachedValue(sendEvent -> byte_data, 8, clientCache -> sendEventByteDataCache); #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> byte_data << " as byte_data field.\n" << logofs_flush; #endif decodeBuffer.decodeValue(value, 16, 4); clientCache -> sendEventLastSequence += value; clientCache -> sendEventLastSequence &= 0xffff; sendEvent -> sequence = clientCache -> sendEventLastSequence; #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> sequence << " as sequence field.\n" << logofs_flush; #endif decodeBuffer.decodeCachedValue(sendEvent -> int_data, 32, clientCache -> sendEventIntDataCache); #ifdef DEBUG *logofs << name() << ": Decoded value " << sendEvent -> int_data << " as int_data field.\n" << logofs_flush; #endif }