コード例 #1
0
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
  }
}
コード例 #2
0
ファイル: StaticCompressor.cpp プロジェクト: narenas/nx-libs
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;
}
コード例 #3
0
ファイル: SendEvent.cpp プロジェクト: kleopatra999/finx
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
}