示例#1
0
void near CTIFFInfo::SwapData(TIFF_DATA* pData, SHORT nType)
{
	if (m_Info.byte_order != BYTE_ORDER_IBM)
	{
		switch (nType)
		{
			case TIFF_SHORT:
			{
				swap_word((LPWORD)&pData->Short);
				break;
			}
			case TIFF_LONG:
			{
				swap_long(&pData->Long);
				break;
			}
			case TIFF_RATIONAL:
			{
				swap_long(&pData->Rational.numerator);
				swap_long(&pData->Rational.denominator);
				break;
			}
			default:
			{
				break;
			}
		}
	}
}
示例#2
0
void CConfigNetwork::SaveNetCfgInfo()
{
	UpdateData();
	m_pNetCommon.bUseHSDownLoad = m_bHightLoadDown;
	m_pNetDHCP.vNetDHCPConfig[0].bEnable = m_bDHCP;
	m_pNetCommon.TCPPort = GetDlgItemInt(IDC_EDIT_TCPPORT);
	m_pNetCommon.HttpPort = GetDlgItemInt(IDC_EDIT_HTTPPORT);
	m_pNetCommon.TransferPlan = m_ctlTransferPolicy.GetCurSel();
	DWORD dwIP;
	m_ctlNetIP.GetAddress(dwIP);
	m_pNetCommon.HostIP.l = swap_long(dwIP);
	DWORD dwIPMask;
	m_ctlNetIPMask.GetAddress(dwIPMask);
	m_pNetCommon.Submask.l = swap_long(dwIPMask);
	DWORD dwGateway;
	m_ctlNetGateWay.GetAddress(dwGateway);
	m_pNetCommon.Gateway.l = swap_long(dwGateway);
	DWORD dwPrimary;
	m_ctlPrimaryDNS.GetAddress(dwPrimary);
	m_pNetDNS.PrimaryDNS.l = swap_long(dwPrimary);
	DWORD dwSecondary;
	m_ctlSecondaryDNS.GetAddress(dwSecondary);
	m_pNetDNS.SecondaryDNS.l = swap_long(dwSecondary);

	CString strMac;
	strMac = m_EditMac1 + ":" + m_EditMac2 + ":" + m_EditMac3 
		+ ":" + m_EditMac4 + ":" + m_EditMac5 + ":" + m_EditMac6;
	strcpy(m_pNetCommon.sMac,strMac.GetBuffer(0));
}
示例#3
0
void flip_ucac2_star( UCAC2_STAR *star)
{
   swap_long( &star->ra);
   swap_long( &star->dec);
   swap_short( &star->mag);
   swap_short( &star->epoch_ra);
   swap_short( &star->epoch_dec);
   swap_long( &star->pm_ra);
   swap_long( &star->pm_dec);
   swap_long( &star->twomass_id);
   swap_short( &star->j_mag);
   swap_short( &star->h_mag);
   swap_short( &star->ks_mag);
}
示例#4
0
void send_long(char *name, long integer) /* includefile */
{
  send_string(name);
  if (swapout) swap_long(&integer);
  fwrite(&integer,sizeof(long),1,output);
  /*fprintf(stderr,"%ld\n",integer);*/
}
 void swapEndianess() {
     swap_long(reinterpret_cast<unsigned char*>(&views));
     swap_long(reinterpret_cast<unsigned char*>(&vols_added));
     swap_long(reinterpret_cast<unsigned char*>(&start_field));
     swap_long(reinterpret_cast<unsigned char*>(&field_skip));
     swap_long(reinterpret_cast<unsigned char*>(&omax));
     swap_long(reinterpret_cast<unsigned char*>(&omin));
     swap_long(reinterpret_cast<unsigned char*>(&smax));
     swap_long(reinterpret_cast<unsigned char*>(&smin));
 }
示例#6
0
FileHeader *get_file_header( FILE *in )
/*
**  Creates a FileHeader structure and fills it with data beginning at the
**  current file location in 'in'.  Obviously, it's best if you've already
**  advanced to where a FileHeader is stored in the file.  If an error
**  occurs, NULL is returned.
*/
{
   FileHeader *fileHdr;

   if( fileHdr = (FileHeader *)malloc( FileHdrSize ) )
   {
      if( FileHdrSize == fread( (void *)fileHdr, sizeof( ubyte ),
         FileHdrSize, in ) || ask( "Read error on file header" ) )
      {
         CheckSum crc;

         crc = calc_crc( (ubyte *)fileHdr,
            FileHdrSize - sizeof( CheckSum ), INIT_CRC );
#ifdef SWAP
         /*  We MUST calculate the checksum BEFORE we swab the data!  */
         swap_long( (ulong *)&fileHdr->fType );
         swap_long( (ulong *)&fileHdr->fCreator );
         swap_word( (uword *)&fileHdr->FndrFlags );
         swap_long( &fileHdr->creationDate );
         swap_long( &fileHdr->modDate );
         swap_long( &fileHdr->rsrcLength );
         swap_long( &fileHdr->dataLength );
         swap_long( &fileHdr->compRLength );
         swap_long( &fileHdr->compDLength );
         swap_word( &fileHdr->rsrcCRC );
         swap_word( &fileHdr->dataCRC );
         swap_word( &fileHdr->hdrCRC );
#endif
         if( crc == fileHdr->hdrCRC || 
            ask( "Bad checksum on file header" ) )
         {
            ubyte len = (ubyte)*(fileHdr->fName);

            /*  Convert the Pascal-style name string to C-style  */
            memmove( fileHdr->fName, fileHdr->fName + 1, len );
            *(fileHdr->fName + len) = '\0';

            return( fileHdr );
         }
      }
      free( fileHdr );
   }
   else
      clean_exit( "Out of memory!" );

   return( NULL );
}
示例#7
0
SitHeader *get_sit_header( FILE *in )
/*
**  This function creates a SitHeader structure and initializes it with the
**  data stored at the beginning of the file 'in'.  If an error occurs, this
**  routine returns NULL.
*/
{
   SitHeader *sitHdr;

   fseek( in, InfoSize, SEEK_SET );
   if( sitHdr = (SitHeader *)malloc( SitHdrSize ) )
   {
      if( SitHdrSize == fread( (void *)sitHdr, sizeof( byte ),
         SitHdrSize, in ) || ask( "Read error on SIT header" ) )
      {
#ifdef SWAP
         swap_long( (ulong *)&sitHdr->signature );
         swap_word( &sitHdr->numFiles );
         swap_long( &sitHdr->arcLength );
         swap_long( (ulong *)&sitHdr->signature2 );
#endif
         /*
         **  Verify the signature and version of this file's SitHeader.
         **  If not version 1, we may not be able to decompress this
         **  archive.
         */
         if( sitHdr->signature == 0x53495421 &&
            sitHdr->signature2 == 0x724c6175 )
         {
            if( sitHdr->version <= SIT_VERSION ||
               ask( "This archive wasn't created with StuffIt version 1" ) )
                  return( sitHdr );
         }
         else
            clean_exit( "This file is not a StuffIt archive" );
      }
      free( sitHdr );
   }
   else
      clean_exit( "Out of memory!" );

   return( NULL );
}
示例#8
0
int aud_readinit (char *filename, int *sample_rate, 
		  int *sample_size, int *channels ) 
{
  /* Sets up a descriptor to read from a wave (RIFF). 
   * Returns file descriptor if successful*/
  int fd;
  WaveHeader wh;
		  
  if (0 > (fd = open (filename, O_RDONLY))){
    fprintf(stderr,"unable to open the audiofile\n");
    return -1;
  }

  read (fd, &wh, sizeof(wh));

  if (0 != bcmp(wh.main_chunk, RIFF, sizeof(wh.main_chunk)) || 
      0 != bcmp(wh.chunk_type, WAVEFMT, sizeof(wh.chunk_type)) ) {
    fprintf (stderr, "not a WAVE-file\n");
    errno = 3;// EFTYPE;
    return -1;
  }
  if (swap_short(wh.format) != PCM_CODE) {
    fprintf (stderr, "can't play non PCM WAVE-files\n");
    errno = 5;//EFTYPE;
    return -1;
  }
  if (swap_short(wh.chans) > 2) {
    fprintf (stderr, "can't play WAVE-files with %d tracks\n", wh.chans);
    return -1;
  }
	
  *sample_rate = (unsigned int) swap_long(wh.sample_fq);
  *sample_size = (unsigned int) swap_short(wh.bit_p_spl);
  *channels = (unsigned int) swap_short(wh.chans);	
	
  fprintf (stderr, "%s chan=%u, freq=%u bitrate=%u format=%hu\n", 
	   filename, *channels, *sample_rate, *sample_size, wh.format);
  return fd;
}
示例#9
0
/*
 * This is called from the server loop to (1) find the target object of a
 * message, (2) extract the `GIOP::RequestHeader.request_id' field of the
 * request, and (3) set the message stream pointer to point to the operation
 * key in the `GIOP::RequestHeader'.
 */
FLICK_TARGET find_implementation(CORBA_BOA ths,
				 void *_buf_start,
				 CORBA_Environment *ev)
{
	char message_byte_order;
	int object_key;
	
	/*****/
	
	object_key = ((int *)_buf_start)[1];
	
	/* Pluck the byte order out of the header. */
	message_byte_order = ((char *)_buf_start)[0];
	
	if (flick_is_little_endian != message_byte_order)
		object_key = swap_long(object_key);
	
	if (object_key < ths->count_servers)
		return CORBA_Object_duplicate(&ths->refs[object_key], ev);
	else
		flick_set_exception(ths, ev, ex_CORBA_NO_IMPLEMENT,
				    0, CORBA_COMPLETED_NO);
	return 0;
}
示例#10
0
 void swapEndianess() {
     swap_short(reinterpret_cast<unsigned char*>(&dim[0]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[1]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[2]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[3]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[4]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[5]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[6]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[7]));
     swap_short(reinterpret_cast<unsigned char*>(&unused8));
     swap_short(reinterpret_cast<unsigned char*>(&unused9));
     swap_short(reinterpret_cast<unsigned char*>(&unused10));
     swap_short(reinterpret_cast<unsigned char*>(&unused11));
     swap_short(reinterpret_cast<unsigned char*>(&unused12));
     swap_short(reinterpret_cast<unsigned char*>(&unused13));
     swap_short(reinterpret_cast<unsigned char*>(&unused14));
     swap_short(reinterpret_cast<unsigned char*>(&datatype));
     swap_short(reinterpret_cast<unsigned char*>(&bitpix));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[0]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[1]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[2]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[3]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[4]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[5]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[5]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[6]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[7]));
     swap_long(reinterpret_cast<unsigned char*>(&vox_offset));
     swap_long(reinterpret_cast<unsigned char*>(&funused1));
     swap_long(reinterpret_cast<unsigned char*>(&funused2));
     swap_long(reinterpret_cast<unsigned char*>(&cal_max));
     swap_long(reinterpret_cast<unsigned char*>(&cal_min));
     swap_long(reinterpret_cast<unsigned char*>(&compressed));
     swap_long(reinterpret_cast<unsigned char*>(&verified));
     swap_short(reinterpret_cast<unsigned char*>(&dim_un0));
     swap_long(reinterpret_cast<unsigned char*>(&glmax));
     swap_long(reinterpret_cast<unsigned char*>(&glmin));
 }
示例#11
0
void fileHandler::swapHdr()
{
	swap_long(mHdr.hk.sizeof_hdr);
	swap_long(mHdr.hk.extents);
	swap_short(mHdr.hk.session_error);
	swap_short(mHdr.dime.dim[0]);
	swap_short(mHdr.dime.dim[1]);
	swap_short(mHdr.dime.dim[2]);
	swap_short(mHdr.dime.dim[3]);
	swap_short(mHdr.dime.dim[4]);
	swap_short(mHdr.dime.dim[5]);
	swap_short(mHdr.dime.dim[6]);
	swap_short(mHdr.dime.dim[7]);
	swap_short((short)mHdr.dime.funused1);
	swap_short(mHdr.dime.datatype);
	swap_short(mHdr.dime.bitpix);
	swap_long((int)mHdr.dime.pixdim[0]);
	swap_long((int)mHdr.dime.pixdim[1]);
	swap_long((int)mHdr.dime.pixdim[2]);
	swap_long((int)mHdr.dime.pixdim[3]);
	swap_long((int)mHdr.dime.pixdim[4]);
	swap_long((int)mHdr.dime.pixdim[5]);
	swap_long((int)mHdr.dime.pixdim[6]);
	swap_long((int)mHdr.dime.pixdim[7]);
	swap_long((int)mHdr.dime.vox_offset);
	swap_long((int)mHdr.dime.funused1);
	swap_long((int)mHdr.dime.funused2);
	swap_long((int)mHdr.dime.cal_max);
	swap_long((int)mHdr.dime.cal_min);
	swap_long((int)mHdr.dime.compressed);
	swap_long((int)mHdr.dime.verified);
	swap_short(mHdr.dime.dim_un0);
	swap_long(mHdr.dime.glmax);
	swap_long(mHdr.dime.glmin);
}
示例#12
0
void toc_extract( WINDOW * win )
{
  static const char * ext[] = { "avr", "raw", "raw", "wav" };
  char pathname[ 256 ];
  char prog_info[ 64 ];
  char buf[ 128 ];
  struct avr_header * avrh;
  struct wave_header * wavh;
  struct audio_entry entry;
  struct audio_stream * as;
  struct _toc_data * data;
  struct device_info * info;
  OBJECT * ck;
  int format, i, max, track_no;
  int fd, swap;
  long offset, length, position, end, progress, total_length;
  long max_buf_blocks, nblocks;
  void * buffer;

  if( !fileselect( preferences.toc_dest, "", "TXT_EXTDEST" ) )
    return;
  strrchr( preferences.toc_dest, '\\' )[1] = '\0';

  data = DataSearch( win, TW_MAGIC );
  max = data->n_tracks;
  format = fmt_popup.selected;
  total_length = 0;
  buffer = alloc_comm_buffer( BUFSIZE );
  if( !buffer )
    return;
  for( i = 0; i < max; i++ )
  {
    ck = data->tree + 1 + TF_CK + i * data->n_obj;
    if( ! (ck->ob_state & SELECTED) )
      continue;
    offset = toc_address( data->f[i].beg_time );
    length = toc_address( data->f[i].end_time ) + 1 - offset;
    if( length > 0 )
      total_length += length;
  }
  max_buf_blocks = BUFSIZE / 2352;

  progress = 0;
  progress_init( get_string( "TXT_EXTMSG" ), total_length );
  progress_activate_cancel( 1 );
  progress_init_timer();

  log_begin();
  log_printf( "*** Begin of a track extraction session\n\n" );
  as = NULL;
  for( i = 0; i < max; i++ )
  {
    ck = data->tree + 1 + TF_CK + i * data->n_obj;
    if( ! (ck->ob_state & SELECTED) )
      continue;
    offset = toc_address( data->f[i].beg_time );
    length = toc_address( data->f[i].end_time ) + 1 - offset;
    if( length <= 0 )
      continue;
    track_no = i + 1;
    position = get_track_offset( &data->toc, track_no, &end );
    if( toc_popup.selected == 0 )
      gen_daoimg_entry( &entry, toc_info.toc_file, track_no,
                        offset - position, end - offset - length );
    else
    {
      info = (struct device_info*)toc_popup.item[toc_popup.selected].info;
      gen_cd_entry( &entry, info, track_no, offset - position, end - offset - length );
    }
    if( as )
      as = audio_reopen( as, &entry );
    else
      as = audio_open( &entry );
    if( as == NULL )
      continue;

    sprintf( prog_info, get_string( "TXT_EXTTRK" ), track_no );
    progress_setinfo( prog_info );

    sprintf( pathname, "%strack%02d.%s", preferences.toc_dest, track_no, ext[ format ] );
    fd = open( pathname, O_WRONLY|O_CREAT|O_TRUNC );
    if( fd == -1 )
    {
      audio_close( as );
      alert_msg( "AL_FILERR", 1, pathname );
      goto error;
    }
    switch( format )
    {
    case 0:        /* AVR */
      avrh = (struct avr_header *) buf;
      avrh->avr_id = '2BIT';
      memset( avrh->name, 0, 8 );
      avrh->num_voices = 0xFFFF;
      avrh->num_bits = 16;
      avrh->signe = 0xffff;
      avrh->loop = 0;
      avrh->midi = 0xffff;
      avrh->freq_type.frequence = 0xff00ac44L;
      avrh->length = length * (2352 / 2);
      avrh->beg_loop = 0;
      avrh->end_loop = avrh->length;
      memset( avrh->reserved, 0, 26 + 64 );
      write( fd, avrh, sizeof( *avrh ) );
      swap = as->little_endian;
      break;
    case 1:        /* RAW big-endian */
      swap = as->little_endian;
      break;
    case 2:        /* RAW little-endian */
      swap = !as->little_endian;
      break;
    case 3:        /* WAVE */
      wavh = (struct wave_header *) buf;
      wavh->riff_id = 'RIFF';
      wavh->riff_len = swap_long( length * 2352 + 36 );
      wavh->wave_id = 'WAVE';
      wavh->fmt_id = 'fmt ';
      wavh->fmt_size = 0x10000000L;
      wavh->fmt_compression_code = 0x0100;
      wavh->fmt_channels = 0x0200;
      wavh->fmt_freq = 0x44ac0000L;
      wavh->fmt_bytes_sec = 0x10b10200L;
      wavh->fmt_block_align = 0x0400;
      wavh->fmt_num_bits = 0x1000;
      wavh->data_id = 'data';
      wavh->data_size = swap_long( length * 2352 );
      write( fd, wavh, sizeof( *wavh ) );
      swap = !as->little_endian;
      break;
    }
    while( length > 0 )
    {
      if( yield() )
      {
        audio_close( as );
        alert_msg( "AL_EXTINT", 1 );
        goto error;
      }
      nblocks = MIN( length, max_buf_blocks );
      if( audio_read( as, buffer, nblocks ) == 0 )
      {
        audio_close( as );
        goto error;
      }
      if( swap )
        swap_endian( buffer, nblocks * 2352 );
      if( write( fd, buffer, nblocks * 2352 ) == -1 )
      {
        close( fd );
        audio_close( as );
        alert_msg( "AL_FWRTERR", 1, pathname );
        goto error;
      }
      length -= nblocks;
      progress += nblocks;
      progress_setcount( progress );
    }
    close( fd );
  }
  audio_close( as );
error:
  log_printf( "*** End of the track extraction session\n\n" );
  log_end();
  progress_exit();
  free_comm_buffer( buffer );

}
示例#13
0
ERRORCODE near CTIFFInfo::GetData(TIFF_TAG_TAG nTag, LONG lNumber, TIFF_DATA* pData)
{
	ERRORCODE error;			// General use.

	TIFF_ENTRY_PTR pEntry;
	SHORT nTypeSize;
	LPBYTE data_ptr;
	BOOL fNeedsSwapping;
	ST_DEV_POSITION offset;

/* Zero the data union. A Rational is the largest element, so zero it. */

	pData->Rational.numerator = pData->Rational.denominator = 0L;

	if (!m_Info.valid)
	{
		return ERRORCODE_NotInitialized;
	}

	if ((pEntry = FindEntry(nTag)) == NULL)
	{
		return ERRORCODE_BadParameter;
	}

	data_ptr = NULL;				/* No data pointed to, yet. */

	if (pEntry->entry.type >= MAX_TIFF_TAG_TYPE)
	{
	/* Bad type. */
		return ERRORCODE_IllegalType;
	}

	nTypeSize = nTypeSizes[pEntry->entry.type];

/* See if the entry was read. */

	if (pEntry->entry_valid)
	{
	/* The entry was read! */

		if (lNumber >= pEntry->entry.length)
		{
		/* Invalid item number. */
			return ERRORCODE_BadParameter;
		}

		if (nTypeSize*pEntry->entry.length > sizeof(LONG))
		{
		/* If the default has been set for a Rational, use it. */

			if ((pEntry->entry.type == TIFF_RATIONAL) &&
				(pEntry->entry.length == 1) &&
				(pEntry->default_valid))
			{
				memcpy(pData, &pEntry->default_value, nTypeSize);
				return ERRORCODE_None;
			}

		/* The value_offset is a file offset. */

			offset = pEntry->entry.value_offset;

			if (m_Info.byte_order != BYTE_ORDER_IBM)
			{
				swap_long(&offset);
			}

			if ((error = m_pDevice->seek(offset + (LONG)(lNumber*nTypeSize), ST_DEV_SEEK_SET)) == ERRORCODE_None)
			{
				if ((error = m_pDevice->read(pData, nTypeSize)) != ERRORCODE_None)
				{
					return error;
				}

			/* Swap the data if necessary. */

				SwapData(pData, pEntry->entry.type);

			/*
			// Special case for Rational values.
			// If this is a single value on disk, we can set it as the default.
			// This will prevent the value from being read multiple times.
			// (i.e. We cache it.)
			*/

				if ((pEntry->entry.type == TIFF_RATIONAL)
					&& (pEntry->entry.length == 1))
				{
				/* Set as the default value. */

					memcpy(&pEntry->default_value, pData, nTypeSize);

					pEntry->default_valid = TRUE;
				}
				return ERRORCODE_None;
			}
			else
			{
			/* Multiple items do not have defaults. Just return the error. */
				return error;
			}
		}
		else
		{
			/* The value_offset is a value. */
			/* Copy the 'number'th element out of the field. */

			data_ptr = ((LPBYTE)&pEntry->entry.value_offset) + lNumber*nTypeSize;
		}
	}

/* If we fell through without setting the pointer, use the default. */

	if (data_ptr == NULL)
	{
		if (pEntry->default_valid)
		{
		/* The entry has a default! Send it back. */
			data_ptr = (LPBYTE)&pEntry->default_value;
			fNeedsSwapping = FALSE;
		}
		else
		{
		/* No default either! */
			return ERRORCODE_BadParameter;
		}
	}
	else
	{
		fNeedsSwapping = TRUE;
	}
	memcpy(pData, data_ptr, nTypeSize);

	if (fNeedsSwapping)
	{
		SwapData(pData, pEntry->entry.type);
	}
	return ERRORCODE_None;
}
示例#14
0
/*
 * This is called from the server loop to (1) find the target object of a
 * message, (2) extract the `GIOP::RequestHeader.request_id' field of the
 * request, and (3) set the message stream pointer to point to the operation
 * key in the `GIOP::RequestHeader'.
 */
FLICK_TARGET find_implementation(CORBA_BOA ths,
				 FLICK_BUFFER *input_buffer,
				 /* OUT */ unsigned int *request_id,
				 CORBA_Environment *ev)
{
	char *cursor;
	
	char message_byte_order;
	char *object_key;
	
	unsigned int service_context_seq_len;
	unsigned int object_key_len;
	unsigned int service_context_len;
	unsigned int i;
	
	/*****/
	
	/* Pluck the byte order out of the GIOP MessageHeader structure. */
	message_byte_order = ((char *) input_buffer->buf_start)[6];
	
	if ((((char *) input_buffer->buf_start) + 4 + 2 + 1 + 1 + 4 + 4)
	    > ((char *) input_buffer->buf_end))
		goto error;
	/* Skip past the `GIOP::MessageHeader' structure. */
	cursor = ((char *) input_buffer->buf_start)
		 + 4 /* GIOP::MessageHeader.magic */
		 + 2 /* GIOP::MessageHeader.GIOP_version */
		 + 1 /* GIOP::MessageHeader.byte_order */
		 + 1 /* GIOP::MessageHeader.message_type */
		 + 4 /* GIOP::MessageHeader.message_size */
		 ;
	
	/* Parse the `GIOP::RequestHeader.service_context' list. */
	service_context_seq_len = *(unsigned int *) cursor;
	if (flick_is_little_endian != message_byte_order)
		service_context_seq_len = swap_long(service_context_seq_len);
	cursor += 4;
	
	for (i = 0; i < service_context_seq_len; ++i) {
		/* Skip the `IOP::ServiceContext.context_id'. */
		cursor += 4;
		
		if( (void *)(cursor + 4) > input_buffer->buf_end )
			goto error;
		/* Skip the `IOP::ServiceContext.context_data' sequence. */
		service_context_len = *(unsigned int *) cursor;
		if (flick_is_little_endian != message_byte_order)
			service_context_len = swap_long(service_context_len);
		cursor += 4;
		/*
		 * Note: It is always right to 4-byte align here, because the
		 * last service context will be followed by the unsigned int
		 * `GIOP::RequestHeader.request_id'.
		 */
		cursor += (service_context_len + 3) & ~3;
	}
	
	if( (void *)(cursor + 4 + 4 + 4) > input_buffer->buf_end )
		goto error;
	/* Save the `GIOP::RequestHeader.request_id'. */
	*request_id = *(unsigned int *) cursor;
	if (flick_is_little_endian != message_byte_order)
		*request_id = swap_long(*request_id);
	cursor += 4;
	
	/* Skip over the `GIOP::RequestHeader.response_expected'. */
	cursor += 4;
	
	/* Get the `GIOP::RequestHeader.object_key'. */
	object_key_len = *(unsigned int *) cursor;
	if (flick_is_little_endian != message_byte_order)
		object_key_len = swap_long(object_key_len);
	cursor += 4;
	
	object_key = cursor;
	cursor += (object_key_len + 3) & ~3;
	
	if( (void *)cursor > input_buffer->buf_end )
		goto error;
	/*
	 * Now `cursor' is pointing to the `GIOP::RequestHeader.operation', and
	 * we can initailize the message stream pointer for the server dispatch
	 * function.
	 */
	input_buffer->buf_current = cursor;
	
	/*
	 * Locate the referenced object and return an appropriate reference.
	 *
	 * XXX --- We do a linear search through the list of objects, and
	 * return a duplicate reference (XXX --- Why duplicate?) to the located
	 * object.  This is painfully inefficient, but hey, it's runtime,
	 * right? :-\
	 */
	for (i = 0; i < (unsigned) ths->count_servers; ++i) {
		if ((ths->refs[i].key._length == object_key_len)
		    && (memcmp(object_key,
			       ths->refs[i].key._buffer,
			       object_key_len)
			== 0)
			)
			/* We've found the object reference. */
			return CORBA_Object_duplicate(&ths->refs[i], ev);
	}
	
	flick_set_exception(ths, ev, ex_CORBA_NO_IMPLEMENT,
			    0, CORBA_COMPLETED_NO);
	return 0;
  error:
	flick_set_exception(ths, ev, ex_CORBA_COMM_FAILURE,
			    0, CORBA_COMPLETED_NO);
	return 0;
}
示例#15
0
 void swapEndianess() {
     swap_long(reinterpret_cast<unsigned char*>(&sizeof_hdr));
     swap_long(reinterpret_cast<unsigned char*>(&extents));
     swap_short(reinterpret_cast<unsigned char*>(&session_error));
 }
示例#16
0
 void swapEndianess() {
     swap_long(reinterpret_cast<unsigned char*>(&sizeof_hdr));
     swap_long(reinterpret_cast<unsigned char*>(&extents));
     swap_short(reinterpret_cast<unsigned char*>(&session_error));
     swap_short(reinterpret_cast<unsigned char*>(&dim[0]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[1]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[2]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[3]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[4]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[5]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[6]));
     swap_short(reinterpret_cast<unsigned char*>(&dim[7]));
     swap_long(reinterpret_cast<unsigned char*>(&intent_p1));
     swap_long(reinterpret_cast<unsigned char*>(&intent_p2));
     swap_long(reinterpret_cast<unsigned char*>(&intent_p3));
     swap_short(reinterpret_cast<unsigned char*>(&intent_code));
     swap_short(reinterpret_cast<unsigned char*>(&datatype));
     swap_short(reinterpret_cast<unsigned char*>(&bitpix));
     swap_short(reinterpret_cast<unsigned char*>(&slice_start));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[0]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[1]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[2]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[3]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[4]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[5]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[6]));
     swap_long(reinterpret_cast<unsigned char*>(&pixdim[7]));
     swap_long(reinterpret_cast<unsigned char*>(&vox_offset));
     swap_long(reinterpret_cast<unsigned char*>(&scl_slope));
     swap_long(reinterpret_cast<unsigned char*>(&scl_inter));
     swap_short(reinterpret_cast<unsigned char*>(&slice_end));
     swap_long(reinterpret_cast<unsigned char*>(&cal_max));
     swap_long(reinterpret_cast<unsigned char*>(&cal_min));
     swap_long(reinterpret_cast<unsigned char*>(&slice_duration));
     swap_long(reinterpret_cast<unsigned char*>(&toffset));
     swap_long(reinterpret_cast<unsigned char*>(&glmax));
     swap_long(reinterpret_cast<unsigned char*>(&glmin));
     swap_short(reinterpret_cast<unsigned char*>(&qform_code));
     swap_short(reinterpret_cast<unsigned char*>(&sform_code));
     swap_long(reinterpret_cast<unsigned char*>(&quatern_b));
     swap_long(reinterpret_cast<unsigned char*>(&quatern_c));
     swap_long(reinterpret_cast<unsigned char*>(&quatern_d));
     swap_long(reinterpret_cast<unsigned char*>(&qoffset_x));
     swap_long(reinterpret_cast<unsigned char*>(&qoffset_y));
     swap_long(reinterpret_cast<unsigned char*>(&qoffset_z));

     swap_long(reinterpret_cast<unsigned char*>(&srow_x[0]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_x[1]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_x[2]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_x[3]));

     swap_long(reinterpret_cast<unsigned char*>(&srow_y[0]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_y[1]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_y[2]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_y[3]));

     swap_long(reinterpret_cast<unsigned char*>(&srow_z[0]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_z[1]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_z[2]));
     swap_long(reinterpret_cast<unsigned char*>(&srow_z[3]));
 }
示例#17
0
ERRORCODE near CTIFFInfo::ReadTags(void)
{
	ERRORCODE error;

	TIFF_HEADER header;
	TIFF_IFD ifd;
	TIFF_FILE_ENTRY entry;
	TIFF_ENTRY_PTR pEntry;
	WORD wEntryCount;
	LONG lIfdAddress, lEntryOffset;

/* If we have already read the tags, don't read them again. */

	if (m_Info.valid)
	{
		return ERRORCODE_None;
	}

/* Initialize data to defaults */

	SetDefaults();

	m_Info.unused_offset = 0L;

#if 0
	if (type == GRAPHIC_TYPE_EPS)
	{
		if ((error = m_pDevice->seek(0x14, ST_DEV_SEEK_SET)) != ERRORCODE_None
				|| (error = m_pDevice->read(&m_Info.offset, sizeof(m_Info.offset))) != ERRORCODE_None)
		{
			return error;
		}
	}
#endif

/*
// Seek to the start and read in the header.
*/
	if ((error = m_pDevice->seek(0, ST_DEV_SEEK_SET)) != ERRORCODE_None
		|| (error = m_pDevice->read(&header, sizeof(TIFF_HEADER))) != ERRORCODE_None)
	{
		return error;
	}

/* Save the byte order for later. */

	if ((m_Info.byte_order = header.byte_order) != BYTE_ORDER_IBM)
	{
		swap_word(&header.version);
	}

/* Make sure header is reasonable */

	if (header.version != TIFF_VERSION)
	{
		return ERRORCODE_IllegalType;
	}

/* Start at the first IFD in the TIFF file. */

	lIfdAddress = header.ifd0_address;

/* Step through and read in all the IFD's */

	while (lIfdAddress != 0L)
	{
		if (header.byte_order != BYTE_ORDER_IBM)
		{
			swap_long(&lIfdAddress);
		}

	/* Move to the beginning of the IFD. */
	/* Read in top of IFD (entry count) */

		if ((error = m_pDevice->seek(lIfdAddress, ST_DEV_SEEK_SET)) != ERRORCODE_None
			 || (error = m_pDevice->read(&ifd, sizeof(TIFF_IFD))) != ERRORCODE_None)
		{
			return error;
		}

		if (header.byte_order != BYTE_ORDER_IBM)
		{
			swap_word(&(ifd.entry_count));
		}

	/* Read in the entries. */

		for (wEntryCount = ifd.entry_count; wEntryCount != 0; wEntryCount--)
		{	
			m_pDevice->tell(&lEntryOffset);

		/* Read in entry */

			if ((error = m_pDevice->read(&entry, sizeof(TIFF_FILE_ENTRY))) != ERRORCODE_None)
			{
				return error;
			}

		/* Correct the byte order if it is wrong. */

			if (m_Info.byte_order != BYTE_ORDER_IBM)
			{
				swap_word((LPWORD)&(entry.tag));
				swap_word((LPWORD)&(entry.type));
				swap_long(&(entry.length));
			}

		/* What kind of field have we got? */

			if ((pEntry = FindEntry(entry.tag)) != NULL_TIFF_ENTRY)
			{
			/* Copy the data. THIS IS A STRUCTURE COPY. */

				pEntry->entry = entry;

			/* Say this entry was read. */

				pEntry->entry_valid = TRUE;
				pEntry->entry_offset = lEntryOffset;
				if (pEntry->entry.length == 0)
				{
				/* This is a fix for some bad TIFF files. */
					pEntry->entry.length = 1;
				}
			}
		}

	/* Read the next IFD offset. */

#ifdef MULTIPLE_IFDS
		if (read(file, &lIfdAddress, sizeof(lIfdAddress)) != sizeof(lIfdAddress))
		{
			lIfdAddress = 0L;			/* Just terminate. */
		}
#else
		lIfdAddress = 0L;				/* Always quit after the first IFD */
#endif
	}

	m_Info.valid = TRUE;
	return ERRORCODE_None;
}
示例#18
0
int extract_ucac2_stars( FILE *ofile, const double ra, const double dec,
                  const double width, const double height, const char *path,
                  const int is_supplement)
{
   const double dec1 = dec - height / 2., dec2 = dec + height / 2.;
   const double ra1 = ra - width / 2., ra2 = ra + width / 2.;
   const double zone_height = (is_supplement ? 5. : .5);
   int zone = (int)( (dec1  + 90.) / zone_height) + 1;
   int end_zone = (int)( (dec2 + 90.) / zone_height) + 1;
   int ra_start = (int)( ra1 / 1.5);
   int rval = 0;
   FILE *index_file;
   const char *idx_filename = (is_supplement ? "bsindex.da" : "u2index.da");

                     /* Look for the index file in the local directory... */
   index_file = fopen( idx_filename, read_only_permits);
                     /* ...and if it's not there,  look for it in the same */
                     /* directory as the data: */
   if( !index_file)
      {
      char filename[100];

      strcpy( filename, path);
      if( filename[strlen( filename) - 1] != path_separator[0])
         strcat( filename, path_separator);
      strcat( filename, idx_filename);
      index_file = fopen( filename, read_only_permits);
      }

   if( zone < 0)
      zone = 0;
   if( ra_start < 0)
      ra_start = 0;
   while( rval >= 0 && zone <= end_zone)
      {
      FILE *ifile = get_ucac2_zone_file( zone, is_supplement, path);

      if( ifile)
         {
         int keep_going = 1;
         UCAC2_STAR star;
         const long ra2_in_mas = (long)( ra2 * 3600. * 1000.);
         long offset0, offset;

         if( !index_file)
            offset0 = offset = 0L;
         else
            {           /* 'u2index.da' gives the _ending_ offset for each */
                        /* zone.  So we have to do some odd things to find  */
                        /* the _beginning_ offset for each zone.            */
            if( zone == 1)
               offset0 = 0;
            else
               {
               fseek( index_file, ((zone - 1L) * 240L - 1L) * sizeof( long),
                       SEEK_SET);
               fread( &offset0, 1, sizeof( long), index_file);
               }
            if( !ra_start)
               offset = offset0;
            else
               {
               fseek( index_file, ((zone - 1L) * 240L + ra_start - 1L) * sizeof( long),
                       SEEK_SET);
               fread( &offset, 1, sizeof( long), index_file);
               }

#ifdef WRONG_ENDIAN
            swap_long( &offset0);
            swap_long( &offset);
#endif
            }
         fseek( ifile, (offset - offset0) * sizeof( UCAC2_STAR), SEEK_SET);

         while( fread( &star, 1, sizeof( UCAC2_STAR), ifile) && keep_going)
            {
#ifdef WRONG_ENDIAN
            flip_ucac2_star( &star);
#endif
            if( star.ra > ra2_in_mas)
               keep_going = 0;
            else if( star.ra > (long)( ra1 * 3600. * 1000.) &&
                     star.dec > (long)( dec1 * 3600. * 1000.) &&
                     star.dec < (long)( dec2 * 3600. * 1000.))
               {
               char buff[200];

               write_ucac2_star( offset + 1L + (is_supplement ? BSS_OFFSET : 0),
                                       buff, &star);
               fwrite( buff, 1, strlen( buff), ofile);
               rval++;
               }
            offset++;
            }
         fclose( ifile);
         }
      zone++;
      }
   if( index_file)
      fclose( index_file);

            /* We need some special handling for cases where the area
               to be extracted crosses RA=0 or RA=24: */
   if( rval >= 0 && ra > 0. && ra < 360.)
      {
      if( ra1 < 0.)      /* left side crosses over RA=0h */
         rval += extract_ucac2_stars( ofile, ra+360., dec, width, height,
                                                      path, is_supplement);
      if( ra2 > 360.)    /* right side crosses over RA=24h */
         rval += extract_ucac2_stars( ofile, ra-360., dec, width, height,
                                                      path, is_supplement);
      }
   return( rval);
}
示例#19
0
ERRORCODE near CTIFFInfo::ReadInfo(LPINT pWidth, LPINT pHeight, \
								LPINT pXResolution, LPINT pYResolution)
{
	TIFF_DATA Data;
	TIFF_ENTRY* pEntry;
	ERRORCODE error;

	if (m_Info.valid)
	{
		return ERRORCODE_None;
	}

/* Read all tags. */

	if ((error = ReadTags()) != ERRORCODE_None)
	{
		return error;
	}

/* Read the image resolutions. */

/*
// A particular TIFF writer only writes one resolution. So we check both
// in the correct order.
*/

	if (GetData(TIFF_XResolution, 0L, &Data) == ERRORCODE_None
			|| GetData(TIFF_YResolution, 0L, &Data) == ERRORCODE_None)
	{
		if (Data.Rational.denominator == 0)
		{
			Data.Rational.denominator = 1;
		}
		*pXResolution = (int)((Data.Rational.numerator) /
				(Data.Rational.denominator));
	}

	if (GetData(TIFF_YResolution, 0L, &Data) == ERRORCODE_None
			|| GetData(TIFF_XResolution, 0L, &Data) == ERRORCODE_None)
	{
		if (Data.Rational.denominator == 0)
		{
			Data.Rational.denominator = 1;
		}
		*pYResolution = (int)((Data.Rational.numerator) /
				(Data.Rational.denominator));
	}

/* Read the width. */

	if (GetData(TIFF_ImageWidth, 0L, &Data) != ERRORCODE_None)
	{
	/* No width! */
		return ERRORCODE_IllegalType;
	}
	*pWidth = m_Info.width = Data.Short;

/* Read the length. */

	if (GetData(TIFF_ImageLength, 0L, &Data) != ERRORCODE_None)
	{
	/* No height! */
		return ERRORCODE_IllegalType;
	}
	*pHeight = m_Info.height = Data.Short;

/* Read the number of bits per sample. */

	GetData(TIFF_BitsPerSample, 0L, &Data);

	m_Info.bits_per_sample = Data.Short;

/*
// Read the number of samples per pixel.
*/

	GetData(TIFF_SamplesPerPixel, 0L, &Data);

	m_Info.samples_per_pixel = Data.Short;
	m_Info.byte_width=((m_Info.width*m_Info.bits_per_sample+7)/8)*Data.Short;

/* Read the photometric interpretation. */

	if (GetData(TIFF_PhotometricInterp, 0L, &Data) == ERRORCODE_None)
	{
		m_Info.photometric = Data.Short;
	}
	else
	{
	/* No interpretation! */
		m_Info.photometric = 0;
	}

/*
// Read the number of rows per strip.
// No error check is done because this value has a default, and if it got
// this far, the tags have been read.
*/

	GetData(TIFF_RowsPerStrip, 0L, &Data);

	m_Info.rows_per_strip = Data.Short;
	if ((Data.Short == -1) || (Data.Short > m_Info.height))
	{
		m_Info.rows_per_strip = m_Info.height;
	}

/*
// Read the planar configuration.
// No error check is done because this value has a default, and if it got
// this far, the tags have been read.
*/

	GetData(TIFF_PlanarConfiguration, 0L, &Data);

	m_Info.planar_configuration = Data.Short;

	if (m_Info.samples_per_pixel != 1 && m_Info.planar_configuration == 2)
	{
	/* Bad configuration! */
		return ERRORCODE_IllegalType;
	}

/*
// Read the compression value.
// No error check is done because this value has a default, and if it got
// this far, the tags have been read.
*/

	GetData(TIFF_Compression, 0L, &Data);
	m_Info.compression = Data.Short;

/*
// Read the strip offsets value.
// We don't use get_tiff_data here because we want the value in
// the tag field regardless of whether it is actual data or a pointer
// to disk data. get_tiff_data would actually read the disk data if we
// used it.
*/

	pEntry = FindEntry(TIFF_StripOffsets);

	if (!pEntry->entry_valid)
	{
	/* No default for strip offsets! */
		return ERRORCODE_IllegalType;
	}

	m_Info.strip_offsets = pEntry->entry.value_offset;

	if (m_Info.byte_order != BYTE_ORDER_IBM)
	{
		swap_long(&m_Info.strip_offsets);
	}

	if (pEntry->entry.length == 1 && pEntry->entry.type == TIFF_SHORT)
	{
	/* Make sure we only read the short value. */
		m_Info.strip_offsets &= 0x0FFFFL;
	}

/*
// Read the gray response curve data or color map data if it exists.
*/

	m_Info.palette_offset = -1L;

	if (m_Info.bits_per_sample > 1)
	{
	/* Gray scale! */

		if ((pEntry = FindEntry(TIFF_GrayResponseCurve))->entry_valid)
		{
			LONG curve_length;

		/* We have a curve. */

			m_Info.palette_offset = pEntry->entry.value_offset;
			curve_length = pEntry->entry.length;
			if (m_Info.byte_order != BYTE_ORDER_IBM)
			{
				swap_long(&curve_length);
				swap_long(&m_Info.palette_offset);
			}

			m_Info.gray_response_length = (SHORT)curve_length;
			GetData(TIFF_GrayResponseUnit, 0L, &Data);
			m_Info.gray_response_unit = Data.Short;

		/* Don't invert data. */

			m_pEntries[Tindex_PhotometricInterp].entry.value_offset =
							m_Info.photometric = 1;
		}
		else if ((pEntry = FindEntry(TIFF_ColorMap))->entry_valid)
		{
			m_Info.gray_response_unit = -1;		/* Flag as ColorMap */

		/* We have a color map. Store the offset. */

			m_Info.palette_offset = pEntry->entry.value_offset;

		/* Fix the offset if necessary. */

			if (m_Info.byte_order != BYTE_ORDER_IBM)
			{
				swap_long(&m_Info.palette_offset);
			}
		}
	}

	GetData(TIFF_Predictor, 0L, &Data);
	m_Info.predictor = Data.Short;

	return ERRORCODE_None;
}
void truncated_radix_sort(unsigned long int *morton_codes,
			  unsigned long int *sorted_morton_codes,
			  unsigned int *permutation_vector,
			  unsigned int *index,
			  unsigned int *level_record,
			  int N,
			  int population_threshold,
			  int sft, int lv){

  int BinSizes[MAXBINS] = {0};
  int BinCursor[MAXBINS] = {0};
  unsigned int *tmp_ptr;
  unsigned long int *tmp_code;


  if(N<=0){

    return;
  }
  else if(N<=population_threshold || sft < 0) { // Base case. The node is a leaf

    level_record[0] = lv; // record the level of the node
    memcpy(permutation_vector, index, N*sizeof(unsigned int)); // Copy the pernutation vector
    memcpy(sorted_morton_codes, morton_codes, N*sizeof(unsigned long int)); // Copy the Morton codes

    return;
  }
  else{

    int i, j;
    level_record[0] = lv;
    // Find which child each point belongs to
    for(j=0; j<N; j++){
      unsigned int ii = (morton_codes[j]>>sft) & 0x07;
      BinSizes[ii]++;
    }

    // scan prefix (must change this code)
    int offset = 0;
    for(i=0; i<MAXBINS; i++){
      int ss = BinSizes[i];
      BinCursor[i] = offset;
      offset += ss;
      BinSizes[i] = offset;
    }

    for(j=0; j<N; j++){
      unsigned int ii = (morton_codes[j]>>sft) & 0x07;
      permutation_vector[BinCursor[ii]] = index[j];
      sorted_morton_codes[BinCursor[ii]] = morton_codes[j];
      BinCursor[ii]++;
    }

    //swap the index pointers
    swap(&index, &permutation_vector);

    //swap the code pointers
    swap_long(&morton_codes, &sorted_morton_codes);

    /* Call the function recursively to split the lower levels */
#ifdef CILK
  cilk_for(i=0; i<MAXBINS; i++) {
#else
  for(i=0; i<MAXBINS; i++) {
#endif
      int offset = (i>0) ? BinSizes[i-1] : 0;
      int size = BinSizes[i] - offset;

      truncated_radix_sort(&morton_codes[offset],
			   &sorted_morton_codes[offset],
			   &permutation_vector[offset],
			   &index[offset], &level_record[offset],
			   size,
			   population_threshold,
			   sft-3, lv+1);
    }
  }
}
示例#21
0
ERRORCODE near CTIFFImageDriver::seek_tiff_line(VOID)
{
	ST_DEV_POSITION strip_offset;
	ERRORCODE error;

//	od("Seek to strip %d\r\n", seek_strip);

/* Get the strip offset so we know the beginning of the strip. */

	strip_offset = m_pInfo->m_Info.strip_offsets;

/*
// If this is a multiple strip TIFF, this offset is actually an offset to an
// array of offsets (one for each strip). We need to seek into this array and
// extract the real offset for the strip.
*/

	if (rows_per_strip != m_pInfo->m_Info.height)
	{
	/*
	// We need to read the next strip to seek to.
	// Strip offsets and data are usually in two separate places in the file.
	// We also don't want to buffer the strip data since we only want to read
	// a DWORD's worth. So we disable buffering while we "go underneath" the
	// buffering to pull out the next strip offset. This should improve data
	// reading throughput.
	*/

		strip_offset += seek_strip << 2;				/* (*4) */

//		od("Unbuffered read strip %ld (offset: %ld)...", seek_strip, strip_offset);
		if ((error = file.unbuffered_read(strip_offset /*+ m_pInfo->offset*/, &strip_offset, sizeof(strip_offset))) != ERRORCODE_None)
		{
			return error;
		}
//		od("Got strip offset %ld\r\n", strip_offset);

	/* If this is not IBM order, swap the offset now. */

		if (m_pInfo->m_Info.byte_order != BYTE_ORDER_IBM)
		{
			swap_long(&strip_offset);
		}
	}

/*
// After the seek, we will be at the first row.
*/

	row_in_strip = 0;

/*
// If we are starting part way down and not compressing,
// move down as part of the seek.
*/

	if (compression == TIFF_COMP_NONE && seek_row != 0)
	{
		strip_offset += (LONG)byte_width*(LONG)seek_row;
	/* We are already there! */
		row_in_strip = seek_row;
	}

/*
// Seek to where we want.
*/

	file.seek(strip_offset, ST_DEV_SEEK_SET);

	current_line = (SHORT)seek_strip * rows_per_strip + row_in_strip;

//	printf("S");
	return ERRORCODE_None;
}