Esempio n. 1
0
/**
 * Handle a PDU
 * @pre m_pdu_size bytes in the buffer
 */
void IncomingStreamTransport::HandlePDU() {
    OLA_DEBUG << "Got PDU, data length is " << DataLength() << ", expected " <<
              m_pdu_size;

    if (DataLength() != m_pdu_size) {
        OLA_WARN << "PDU size doesn't match the available data";
        m_stream_valid = false;
        return;
    }

    HeaderSet header_set;
    header_set.SetTransportHeader(m_transport_header);

    unsigned int data_consumed = m_inflator->InflatePDUBlock(
                                     &header_set,
                                     m_buffer_start,
                                     m_pdu_size);
    OLA_DEBUG << "inflator consumed " << data_consumed << " bytes";

    if (m_pdu_size != data_consumed) {
        OLA_WARN << "PDU inflation size mismatch, " << m_pdu_size << " != "
                 << data_consumed;
        m_stream_valid = false;
        return;
    }

    m_consumed_block_size += data_consumed;

    if (m_consumed_block_size == m_block_size) {
        // all PDUs in this block have been processed
        EnterWaitingForPreamble();
    } else {
        EnterWaitingForPDU();
    }
}
Esempio n. 2
0
OpaqueVarbind::OpaqueVarbind(unsigned char* &pduPart)
              :Varbind(pduPart, SNMPOPAQUE, "Opaque"),
	       mData(NULL)
{
  mData = new unsigned char [DataLength()];
  memcpy(mData, pduPart, DataLength());
  pduPart += DataLength();
}
Esempio n. 3
0
void
StructuredCloneData::WriteIPCParams(IPC::Message* aMsg) const
{
  WriteParam(aMsg, DataLength());

  if (DataLength()) {
    // Structured clone data must be 64-bit aligned.
    aMsg->WriteBytes(Data(), DataLength(), sizeof(uint64_t));
  }
}
Esempio n. 4
0
bool
BKey::operator==(const BKey& other) const
{
	return Type() == other.Type()
		&& DataLength() == other.DataLength()
		&& Purpose() == other.Purpose()
		&& fOwner == other.fOwner
		&& fIdentifier == other.fIdentifier
		&& fSecondaryIdentifier == other.fSecondaryIdentifier
		&& memcmp(Data(), other.Data(), DataLength()) == 0;
}
Esempio n. 5
0
TBool HPingHeader::SetHeader(TUint aOffset)
//
// Set the header from an Icmp reply
// 
	{
	
	const TUint8* buffData; 
	
	// Check size
	if(DataLength() < (TInt)KIcmpHeaderSize)
		{
		return EFalse;
		}
	
	buffData = iData->Des().Ptr();

	if(!buffData)
		{
		return EFalse;
		}
	
	// Fill TInet6HeaderICMP_Echo from the buffer
	for(int k=0;k<(TInt)KIcmpHeaderSize;k++)
		{
		i[k] = *(buffData + k + aOffset);
		}

	return ETrue;
	}
Esempio n. 6
0
/**
 * Handle the Preamble data.
 * @pre 20 bytes in the buffer
 */
void IncomingStreamTransport::HandlePreamble() {
    OLA_DEBUG << "in handle preamble, data len is " << DataLength();

    if (memcmp(m_buffer_start, ACN_HEADER, ACN_HEADER_SIZE) != 0) {
        ola::FormatData(&std::cout, m_buffer_start, ACN_HEADER_SIZE);
        ola::FormatData(&std::cout, ACN_HEADER, ACN_HEADER_SIZE);
        OLA_WARN << "bad ACN header";
        m_stream_valid = false;
        return;
    }

    // read the PDU block length
    memcpy(reinterpret_cast<void*>(&m_block_size),
           m_buffer_start + ACN_HEADER_SIZE,
           sizeof(m_block_size));
    m_block_size = ola::network::NetworkToHost(m_block_size);
    OLA_DEBUG << "pdu block size is " << m_block_size;

    if (m_block_size) {
        m_consumed_block_size = 0;
        EnterWaitingForPDU();
    } else {
        EnterWaitingForPreamble();
    }
}
Esempio n. 7
0
OpaqueVarbind::OpaqueVarbind(int value)
              :Varbind(SNMPOPAQUE, "Opaque"),
	       mData(NULL)
{
  DataLength((unsigned short)((value / 255) + 1));
  mData = new unsigned char [sizeof(int)];
  *mData = value;
}
Esempio n. 8
0
DistillerStatus gjpg_passthrough(DistillerInput *din, DistillerOutput *dout)
{
  strcpy(dout->mimeType, din->mimeType);
  SetDataLength(dout,DataLength(din));
  SetData(dout, DataPtr(din));
  DataNeedsFree(dout,gm_False);
  return distOk;
}
Esempio n. 9
0
DistillerStatus
ComputeDistillationCost(Argument *args, int numArgs,
			DistillerInput *din,
                        DistillationCost *cost)
{
  cost->estimatedTime_ms = DataLength(din);
  return distOk;
}
Esempio n. 10
0
OpaqueVarbind::OpaqueVarbind(unsigned short value)
              :Varbind(SNMPOPAQUE, "Opaque"),
	       mData(NULL)
{
  DataLength((unsigned short)((value / 255) + 1));
  mData = new unsigned char [sizeof(unsigned short)];
  memcpy(mData, &value, sizeof(unsigned short));
}
Esempio n. 11
0
/**
 * Handle the PDU Flag data, this allows us to figure out how many bytes we
 * need to read the length.
 * @pre 1 byte in the buffer
 */
void IncomingStreamTransport::HandlePDUFlags() {
    OLA_DEBUG << "Reading PDU flags, data size is " << DataLength();
    m_pdu_length_size = (*m_buffer_start  & BaseInflator::LFLAG_MASK) ?
                        THREE_BYTES : TWO_BYTES;
    m_outstanding_data += static_cast<unsigned int>(m_pdu_length_size) - 1;
    OLA_DEBUG << "PDU length size is " << static_cast<int>(m_pdu_length_size) <<
              " bytes";
    m_state = WAITING_FOR_PDU_LENGTH;
}
Esempio n. 12
0
unsigned char* 
OpaqueVarbind::Data()
{
  unsigned int len = DataLength();
  unsigned int lenLen = (len / 129) + 1;
  unsigned char* data = new unsigned char [len + lenLen + 1];
  unsigned char* retVal = data;
  Build(data);
  return retVal;
}
Esempio n. 13
0
std::vector<BYTE> kjm::eventlog_record::Data() {

	std::vector<BYTE> data( DataLength() );

	for ( int i = 0; i < data.size(); i++) {
		data.at( i ) = *(((unsigned char *)getRaw()) + DataOffset() + i);
	}

	return data;
}
Esempio n. 14
0
void
OpaqueVarbind::Build(unsigned char*& pdu)
{
  unsigned int len = DataLength();
  unsigned int lenLen = (len / 129) + 1;
  pdu[0] = SNMPOPAQUE;
  unsigned char* lPdu = pdu;
  lPdu++;
  encodeLength(lPdu, (long)len);
  memcpy(&pdu[lenLen + 1], mData, len); // the tag too  
}
Esempio n. 15
0
TBool HPingHeader::VerifyNonEcho(TInt aId)
//
// Verify header which is not echo reply
// 
	{
	
	// Fill TInet6HeaderICMP_Echo from packet data
	TBool ret = SetHeader();

	// Look at IP version
	if(ret && iIPVersion == KAfInet)	// IP4
		{
		switch(Type())
			{
		case KIPv4PingTypeUnreachable:
		case KIPv4PingTypeSourceQuench:
		case KIPv4PingTypeRedirect:
		case KIPv4PingTypeTimeExceeded:
		case KIPv4PingTypeBadParameter:
			break;
		default:
			ret = EFalse;
			}
	
		if(ret && (DataLength() < (TInt)KIcmpHeaderSize))
			{
		    	ret = EFalse;
			}

		if(ret)
			{
			ret = SetHeader(KIcmpHeaderSize + KMinIpHeaderSize);
			if(ret && (Type() != KIPv4PingTypeEchoRequest || Identifier() != aId))
				{
				ret = EFalse;
				}
			}
		}
	else
		{				// IP6
		switch(Type())
			{
		case KIPv6PingTypeUnreachable:
		case KIPv6PingTypePacketTooBig:
		case KIPv6PingTypeTimeExeeded:
		case KIPv6PingTypeParamProblem:
			break;
		default:
			ret = EFalse;
			}
		}

	return ret;
	}
Esempio n. 16
0
void
StructuredCloneData::Read(JSContext* aCx,
                          JS::MutableHandle<JS::Value> aValue,
                          ErrorResult &aRv)
{
  MOZ_ASSERT(Data());

  nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
  MOZ_ASSERT(global);

  ReadFromBuffer(global, aCx, Data(), DataLength(), aValue, aRv);
}
Esempio n. 17
0
/**
 * Read data until we reach the number of bytes we required or there is no more
 * data to be read
 */
void IncomingStreamTransport::ReadRequiredData() {
    if (m_outstanding_data == 0)
        return;

    if (m_outstanding_data > FreeSpace())
        IncreaseBufferSize(DataLength() + m_outstanding_data);

    unsigned int data_read;
    int ok = m_descriptor->Receive(m_data_end,
                                   m_outstanding_data,
                                   data_read);

    if (ok != 0)
        OLA_WARN << "tcp rx failed";
    OLA_DEBUG << "read " << data_read;
    m_data_end += data_read;
    m_outstanding_data -= data_read;
}
Esempio n. 18
0
const char*
OpaqueVarbind::Printable()
{
  if (mPrintable == NULL)
  {
    unsigned short len = DataLength();
    mPrintable = new char [len + 1];
    for (unsigned short i = 0; i < len; i++)
    {
      if (isprint(mData[i]))
	mPrintable[i] = mData[i];
      else
	mPrintable[i] = ' ';
    }
    mPrintable[len] = '\0';
  }
  return mPrintable;
}
Esempio n. 19
0
/**
 * Grow the rx buffer to the new size.
 */
void IncomingStreamTransport::IncreaseBufferSize(unsigned int new_size) {
    if (new_size <= BufferSize())
        return;

    new_size = std::max(new_size, INITIAL_SIZE);

    unsigned int data_length = DataLength();
    if (!m_buffer_start)
        data_length = 0;

    // allocate new buffer and copy the data over
    uint8_t *buffer = new uint8_t[new_size];
    if (m_buffer_start) {
        if (data_length > 0)
            // this moves the data to the start of the buffer if it wasn't already
            memcpy(buffer, m_buffer_start, data_length);
        delete[] m_buffer_start;
    }

    m_buffer_start = buffer;
    m_buffer_end = buffer + new_size;
    m_data_end = buffer + data_length;
}
Esempio n. 20
0
void                   
OpaqueVarbind::Value(char* value, unsigned int length)
{
  DataLength(length);
  memcpy(mData, value, length);
}
Esempio n. 21
0
int
main(int argc, char *argv[])
{
  DistillerStatus st;
  UINT32 len;
  int i;
  char nextfile[MAX_FILENAME];
  char logFile[MAX_FILENAME];
  char *timeStr;
  TestRun runs[MAX_TESTRUNS];
  FILE *f;
  time_t t;
  
  int numRuns;
  int repeatCount;
  DistillerInput in;
  DistillerOutput out;
  C_DistillerType distType;


  sprintf(distType.string, "test " INPUT_MIME_TYPE);
  if (argc < 3) {
    usage();
    exit(1);
  }
  
  if (!(numRuns = readInputFile(argv[1],runs))) {
    fprintf(stderr, "Error reading input file %s.\n", argv[1]);
    exit(1);
  }
  repeatCount = atoi(argv[2]);
  if (repeatCount <=0) {
    fprintf(stderr, "Invaild count value.\n");
    exit(1);
  }

  if ((st = DistillerInit(distType, 0, NULL)) != distOk) {
    fprintf(stderr, "DistillerInit failed: error %d\n", (int)st);
    exit(1);
  }

  sprintf(logFile,"harness.log");

  t = time(NULL);
  timeStr = ctime(&t);

  printf("%s\n",logFile);
  if ((f = fopen(logFile, "a")) == NULL) {
    fprintf(stderr, "Can't open log file %s\n", logFile);
    return 0;
  }

  SetMimeType(&in, INPUT_MIME_TYPE);
  
  for (i=0;i<numRuns;i++) {
    int fd;
    int count;
    int ii;

    fprintf(stdout,"Test run for case %s:\n",runs[i].inputFileName);
    fprintf(f,"Test run for case %s:\n",runs[i].inputFileName);
    printArguments(f,*(runs[i].argList));

    fd = open(runs[i].inputFileName, O_RDONLY);


    if (fd == -1) {
      fprintf(stderr, "Can't read %s, skipping\n", runs[i].inputFileName);
      fprintf(f, "Can't read %s, skipping\n", runs[i].inputFileName);
      continue;
    }
    for (len = 0;
         (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0;
         len += count)
      ;

          
    fprintf(stderr, "Read %lu bytes from %s\n", len, runs[i].inputFileName);
    fprintf(f, "Read %lu bytes from %s\n", len, runs[i].inputFileName);
    SetData(&in, (void *)buf);
    SetDataLength(&in, len);
    SetMetadata(&in, NULL);
    SetMetadataLength(&in, 0);


    for (ii= 0; ii<repeatCount; ii++) {

      fprintf(stderr,"Calling distiller main\n");
      fprintf(f,"Calling distiller main\n");
     /* Distiller status */
      st = DistillerMain(runs[i].argList->arg,runs[i].argList->nargs,&in,&out); 
      if (st != distOk) {
        fprintf(stderr, "DistillerMain failed: error %d\n", (int)st);
        fprintf(f, "DistillerMain failed: error %d\n", (int)st);
      }
      close(fd);
      strcpy(nextfile,runs[i].inputFileName);
      strcat(nextfile, ".OUT");
      fd = open(nextfile, O_CREAT | O_WRONLY | O_TRUNC, 0666);
      if (fd == -1) {
        fprintf(stderr, "Can't write %s, using stdout\n", nextfile);
        fprintf(f, "Can't write %s, using stdout\n", nextfile);
        fd = fileno(stdout);
      }
      len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out)));
      if (fd != fileno(stdout))
        close(fd);
      fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile);
      fprintf(f, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile);
      if (out.data.freeMe == gm_True) 
        DistillerFree(DataPtr(&out));
      if (out.metadata.freeMe == gm_True)
        DistillerFree(MetadataPtr(&out));
    }
  }
  fclose(f);
  return(1);
}
Esempio n. 22
0
int
main(int argc, char *argv[])
{
  DistillerStatus st;
  UINT32 len;
  Argument args[12];
  int nargs = 0;
  int i;
  char *k;
  FILE *f;
  char nextfile[255];
  DistillerInput in;
  DistillerOutput out;
  C_DistillerType distType;

  sprintf(distType.string, "test " INPUT_MIME_TYPE);
  
  if ((argc < 2) || (argc >= 2  &&  strncmp(argv[1], "-h", 2) == 0)) {
    usage();
    exit(1);
  }

  if ((f = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Can't open input file %s\n", argv[1]);
    exit(1);
  }


  for (i=2; i<argc-1; i += 2, nargs++) {
    SET_ARG_ID(args[nargs], strtoul(&argv[i][1], (char**)NULL, 0));
    switch (argv[i][0]) {
    case 'i':
      SET_ARG_INT(args[nargs], strtol(argv[i+1], (char**)NULL, 0));
      fprintf(stderr, "Arg id %lu is %ld\n", ARG_ID(args[nargs]),
              ARG_INT(args[nargs]));
      break;
    case 'f':
      SET_ARG_DOUBLE(args[nargs], strtod(argv[i+1], (char**)NULL));
      fprintf(stderr, "Arg id %lu is %f\n", ARG_ID(args[nargs]),
              (float)ARG_DOUBLE(args[nargs]));
      break;
    case 's':
    default:
      SET_ARG_STRING(args[nargs], argv[i+1]);
      fprintf(stderr, "Arg id %lu is \"%s\"\n", ARG_ID(args[nargs]),
              ARG_STRING(args[nargs]));
    }
  }

  if ((st = DistillerInit(distType, 0, NULL)) != distOk) {
    fprintf(stderr, "DistillerInit failed: error %d\n", (int)st);
    exit(1);
  }

  SetMimeType(&in, INPUT_MIME_TYPE);
  while (fgets(nextfile, 254, f) != NULL) {
    char nextfile2[255];
    int fd;
    int count;
    int ii;
      
    nextfile[strlen(nextfile)-1] = 0;
    fd = open(nextfile, O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "Can't read %s, skipping\n", nextfile);
      continue;
    }
    for (len = 0;
         (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0;
         len += count)
      ;
          
    fprintf(stderr, "Read %lu bytes from %s\n", len, nextfile);
    SetData(&in, (void *)buf);
    SetDataLength(&in, len);
    SetMetadata(&in, NULL);
    SetMetadataLength(&in, 0);

    for (ii= 0; ii<REPEAT_COUNT; ii++) {

      fprintf(stderr,"Calling distiller main\n");
      st = DistillerMain(args,nargs,&in,&out);
      if (st != distOk) {
        fprintf(stderr, "DistillerMain failed: error %d\n", (int)st);
      }
      close(fd);
      strcpy(nextfile2, argv[argc-1]);
      if (nextfile2[strlen(nextfile2)-1] != '/')
        strcat(nextfile2,"/");
      k = strrchr(nextfile, '/');
      if (k)
        strcat(nextfile2, k+1);
      else
        strcat(nextfile2, nextfile);
      strcat(nextfile2, ".OUT");
      fd = open(nextfile2, O_CREAT | O_WRONLY | O_TRUNC, 0666);
      if (fd == -1) {
        fprintf(stderr, "Can't write %s, using stdout\n", nextfile2);
        fd = fileno(stdout);
      }
      len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out)));
      if (fd != fileno(stdout))
        close(fd);
      fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile2);
      if (out.data.freeMe == gm_True) 
        DistillerFree(DataPtr(&out));
      if (out.metadata.freeMe == gm_True)
        DistillerFree(MetadataPtr(&out));
    }
  }
  return(1);
}
Esempio n. 23
0
DistillerStatus
DistillerMain(Argument *args, int nargs,
	      DistillerInput *din,
	      DistillerOutput *dout)
{
  JSAMPROW handoff = NULL;
  JDIMENSION handoff_height, handoff_width, num_scanlines;
  int        max_x=-1, max_y=-1, min_x=-1, min_y=-1, qual=55, i;
  int        expert=0, resize=0, quality=3, nodistill=0, ismap=0;
  double     scale = 0.5;
  cjpeg_source_ptr src_mgr;
  void       *phase1_data;
  INT32       phase1_length;
  int        fin_denom, fin_qual;
  DistillerStatus result = distBadInput;

  SetData(dout, NULL);
  bailout_now = 0;

  if ( (setjmp(jumpbuffer) != 0) ) {
    /*
     *  fatal error occurred, so return immediately.
     */
    MonitorClientSend(monID, "Distiller Errors", 
		      "Resetting distiller...\n", "Log");
    DistillerExit();
    DistillerInit(dType, 0, NULL);

    if (DataPtr(dout) != NULL)
      DataNeedsFree(dout,gm_True);
    else
      DataNeedsFree(dout,gm_False);
    return distFatalError;
  }

  /*
   *  parse distillation arguments.  set default values for some
   *  things, then override them if args are specified.  Default will
   *  be to scale each axis by 0.5, turn quality down to 55%.
   */

  for (i=0; i<nargs; i++) {
    INT32 argval = ARG_INT(args[i]);

    switch(ARG_ID(args[i])) {
    case GJPG_MAX_X:
      max_x = (int) argval;
      break;
    case GJPG_MAX_Y:
      max_y = (int) argval;
      break;
    case GJPG_MIN_X:
      min_x = (int) argval;
      break;
    case GJPG_MIN_Y:
      min_y = (int) argval;
      break;
    case GJPG_SCALE:
      scale = (double) ARG_DOUBLE(args[i]);
      break;
    case GJPG_QUAL:
      qual = (int) argval;
      break;
    case FRONT_RESIZE:
      resize = (int) argval;
      break;
    case FRONT_NO_DISTILL:
      nodistill = (int) argval;
      break;
    case FRONT_QUALITY:
      if (argval >= 1 && argval <= 5)
        quality = (int) argval;
      break;
    case FRONT_EXPERT:
      expert = (int) argval;
      break;
    case FRONT_ISMAP:
      ismap = (int) argval;
      break;
    default:
      break;
    }
  }

  if (nodistill) {
    return gjpg_passthrough(din, dout);
  }

  /* First pass through, we're just going to convert the GIF to JPEG */
  phase1_data = NULL;
  phase1_length = 0;
  dstinfo.in_color_space = JCS_RGB;
  jpeg_set_defaults(&dstinfo);
  src_mgr = jinit_read_gif(&dstinfo, (JOCTET *) DataPtr(din),
			   (INT32) DataLength(din));
  (*src_mgr->start_input)(&dstinfo, src_mgr);
  jpeg_default_colorspace(&dstinfo);
  jpeg_mem_dest(&dstinfo, (void **) &phase1_data, (UINT32 *) &phase1_length);
  jpeg_start_compress(&dstinfo, TRUE);

  while (dstinfo.next_scanline < dstinfo.image_height) {
    num_scanlines = (*src_mgr->get_pixel_rows)(&dstinfo, src_mgr);
    jpeg_write_scanlines(&dstinfo, src_mgr->buffer, num_scanlines);
  }

  (*src_mgr->finish_input)(&dstinfo, src_mgr);
  jpeg_finish_compress(&dstinfo);

  /* early bailout because of animated or transparent gif? */
  if (bailout_now
      &&  DataLength(din) <= bailout_thresh[quality]) {
    result = distBadInput;
    goto JPGMUNGE_RETURN;
  }
    

  /* Now we're into the second pass.  Let's do our JPEG->JPEG
   * distillation. We need to compute the denominator and the quality
   * knob setting. */

  if (expert) {
    /* Do expert-like things here.  Need to work out still. */
    fin_qual = qual;
    fin_denom = compute_scale_denom(max_x, max_y, min_x, min_y,
				    srcinfo.image_width,
				    srcinfo.image_height, scale);
  } else {
    /* We're in beginner mode.  Life is easier. */
    if (ismap) {
      fin_qual = ismap_qual[quality-1];
      fin_denom = ismap_denom[quality-1];
    } else if (resize) {
      fin_qual = noscale_qual[quality-1];
      fin_denom = noscale_denom[quality-1];
    } else {
      fin_qual = norm_qual[quality-1];
      fin_denom = norm_denom[quality-1];
    }
  }

  /* Prep the input decompressor */
  jpeg_mem_src(&srcinfo, phase1_data, phase1_length);
  jpeg_read_header(&srcinfo, TRUE);

  srcinfo.scale_num = 1;
  srcinfo.scale_denom = fin_denom;
  srcinfo.dither_mode = JDITHER_ORDERED;  
  srcinfo.dct_method = JDCT_FASTEST;      
  jpeg_start_decompress(&srcinfo);

  /* Prep the output compressor */
  SetDataLength(dout,0);
  SetData(dout, NULL);
  sprintf(dout->mimeType, "image/jpeg");
  jpeg_mem_dest(&dstinfo, (void **) &(DataPtr(dout)),
                (UINT32 *) &(DataLength(dout)));
  dstinfo.image_width = srcinfo.output_width;
  dstinfo.image_height = srcinfo.output_height;
  dstinfo.input_components = srcinfo.output_components;
  dstinfo.in_color_space = srcinfo.out_color_space;
  jpeg_set_defaults(&dstinfo);
  jpeg_set_quality(&dstinfo, fin_qual, TRUE);
  jpeg_start_compress(&dstinfo, TRUE);

  handoff_height = (JDIMENSION) 1;
  handoff_width = 
    srcinfo.output_width*sizeof(JSAMPLE)*srcinfo.output_components;
  handoff = (JSAMPROW) malloc(handoff_width);

  /* We're going to need some buffer space to hand off data
     from the decompressor to the compressor. */
  while (srcinfo.output_scanline < srcinfo.output_height) {
    num_scanlines = jpeg_read_scanlines(&srcinfo, &handoff, handoff_height);
    jpeg_write_scanlines(&dstinfo, &handoff, num_scanlines);
  }

  jpeg_finish_decompress(&srcinfo);
  jpeg_finish_compress(&dstinfo);

  result = distOk;

JPGMUNGE_RETURN:
  if (handoff)
    free(handoff);
  DataNeedsFree(dout,gm_True);
  if (phase1_data)
    free(phase1_data);
  if (DataLength(dout) > DataLength(din)) {
    SetDataLength(dout, DataLength(din));
    memcpy(DataPtr(dout), DataPtr(din), DataLength(din));
    sprintf(dout->mimeType, "image/gif");
  }
  DEBUG("finished processing\n");
  return result;
}
Esempio n. 24
0
void                   
OpaqueVarbind::Value(char value)
{
  DataLength(1);
  *mData = value;
}
Esempio n. 25
0
void                   
OpaqueVarbind::Value(long value)  
{
  DataLength((unsigned short)(value / 255) + 1);
}
Esempio n. 26
0
void                   
OpaqueVarbind::Value(short value)
{
  DataLength((unsigned short)((value / 255) + 1));
}