Beispiel #1
0
void delete_box_in_list_by_type( const char type[], boxlist_param_t *boxlist)
{
  box_param_t *box;

  box = search_box( type, boxlist);
  delete_box_in_list( &box, boxlist);
}
Beispiel #2
0
t_bunny_response	bunny_box_move(const t_bunny_position	*rel,
				       void			*data)
{
  const t_bunny_position *mpos = bunny_get_mouse_position();
  t_bunny_box_system	*box = (t_bunny_box_system*)data;
  t_bunny_gui_box	*x = &box->screen;
  t_bunny_response	ret;

  (void)rel;
  if ((ret = search_box(data, x, *mpos)) < GO_ON)
    return (ret);
  if (ret == NOTHING_HAPPENED)
    {
      if (box->hovered && box->hovered->mouse_out)
	box->hovered->mouse_out(box, box->hovered);
      box->hovered = NULL;
      if (box->head.subcontext.move)
	if ((ret = box->head.subcontext.move(mpos, data)) < GO_ON)
	  return (ret);
      if (box->subhead)
	if ((ret = box->subhead->subcontext.move(mpos, data)) < GO_ON)
	  return (ret);
    }
  return (ret);
}
Beispiel #3
0
static t_bunny_response	search_box(void				*data,
				   t_bunny_gui_box		*box,
				   t_bunny_position		pos)
{
  t_bunny_gui_box	*fnd;

  if (box->inactive)
    return (NOTHING_HAPPENED);

  if (pos.x < box->position.x ||
      pos.y < box->position.y ||
      pos.x > box->position.x + box->size.x ||
      pos.y > box->position.y + box->size.y)
    return (NOTHING_HAPPENED);
  pos.x -= box->position.x;
  pos.y -= box->position.y;

  if ((fnd = bunny_fetch_box(box, &pos)) == NULL)
    {
      if (box->mouse_move)
	return (box->mouse_move(pos, (t_bunny_box_system*)data, box));
      return (NOTHING_HAPPENED);
    }
  return (search_box(data, fnd, pos));
}
Beispiel #4
0
index_param_t * parse_jp2file( int fd)
{
  index_param_t *jp2idx;
  box_param_t *cidx;
  metadatalist_param_t *metadatalist;
  boxlist_param_t *toplev_boxlist;
  Byte8_t filesize;

  if( !(filesize = (Byte8_t)get_filesize( fd)))
    return NULL;

  if( !(toplev_boxlist = get_boxstructure( fd, 0, filesize))){
    fprintf( FCGI_stderr, "Error: Not correctl JP2 format\n");
    return NULL;
  }

  if( !check_JP2boxidx( toplev_boxlist)){
    fprintf( FCGI_stderr, "Index format not supported\n");
    delete_boxlist( &toplev_boxlist);
    return NULL;
  }

  if( !(cidx = search_box( "cidx", toplev_boxlist))){
    fprintf( FCGI_stderr, "Box cidx not found\n");
    delete_boxlist( &toplev_boxlist);
    return NULL;
  }

  jp2idx = (index_param_t *)opj_malloc( sizeof(index_param_t));

  if( !set_cidxdata( cidx, jp2idx)){
    fprintf( FCGI_stderr, "Error: Not correctl format in cidx box\n");
    opj_free(jp2idx);
    delete_boxlist( &toplev_boxlist);
    return NULL;
  }
  delete_boxlist( &toplev_boxlist);

  metadatalist = const_metadatalist( fd);
  jp2idx->metadatalist = metadatalist;

#ifndef SERVER
    fprintf( logstream, "local log: code index created\n");
#endif

  return jp2idx;
}
Beispiel #5
0
ihdrbox_param_t * gene_ihdrbox( metadatalist_param_t *metadatalist, Byte_t *jpipstream)
{
  ihdrbox_param_t *ihdrbox;
  metadata_param_t *meta;
  box_param_t *jp2h, *ihdr;
  int bpc_val;
  
  jp2h = NULL;
  meta = metadatalist->first;
  while( meta){
    if( meta->boxlist){
      jp2h = search_box( "jp2h", meta->boxlist);
      if( jp2h)
	break;
    }
    meta = meta->next;
  }
  if( !jp2h){
    fprintf( stderr, "jp2h box not found\n");
    return NULL;
  }
  
  ihdr = gene_boxbyTypeinStream( jpipstream, get_DBoxoff( jp2h), get_DBoxlen( jp2h), "ihdr");

  if( !ihdr){
    fprintf( stderr, "ihdr box not found\n");
    return NULL;
  }
  
  ihdrbox = (ihdrbox_param_t *)malloc( sizeof(ihdrbox_param_t));
  
  ihdrbox->height = big4( jpipstream+get_DBoxoff(ihdr));
  ihdrbox->width  = big4( jpipstream+get_DBoxoff(ihdr)+4);
  ihdrbox->nc     = big2( jpipstream+get_DBoxoff(ihdr)+8);
  bpc_val = *(jpipstream+get_DBoxoff(ihdr)+10)+1;
  assert( bpc_val >= 0 && bpc_val <= 255 );
  ihdrbox->bpc    = (Byte_t)bpc_val;

  free( ihdr);

  return ihdrbox;
}
Beispiel #6
0
OPJ_BOOL check_JP2boxidx( boxlist_param_t *toplev_boxlist)
{
  box_param_t *iptr, *fidx, *prxy;
  box_param_t *cidx, *jp2c;
  Byte8_t off;
  Byte8_t len;
  int pos;
  Byte8_t ooff;
  boxheader_param_t *obh;
  Byte_t ni;
  Byte8_t ioff;
  boxheader_param_t *ibh;

  iptr = search_box( "iptr", toplev_boxlist);
  fidx = search_box( "fidx", toplev_boxlist);
  cidx = search_box( "cidx", toplev_boxlist);
  jp2c = search_box( "jp2c", toplev_boxlist);
  prxy = gene_childboxbyType( fidx, 0, "prxy");

  off = fetch_DBox8bytebigendian( iptr, 0);
  if( off != (Byte8_t)fidx->offset)
    fprintf( FCGI_stderr, "Reference File Index box offset in Index Finder box not correct\n");

  len = fetch_DBox8bytebigendian( iptr, 8);
  if( len != fidx->length)
    fprintf( FCGI_stderr, "Reference File Index box length in Index Finder box not correct\n");

  pos = 0;
  ooff = fetch_DBox8bytebigendian( prxy, pos);
  if( ooff != (Byte8_t)jp2c->offset)
    fprintf( FCGI_stderr, "Reference jp2c offset in prxy box not correct\n");
  pos += 8;

  obh = gene_childboxheader( prxy, pos);
  if( obh->length != jp2c->length || strncmp( obh->type, "jp2c",4)!=0)
    fprintf( FCGI_stderr, "Reference jp2c header in prxy box not correct\n");
  pos += obh->headlen;
  opj_free(obh);

  ni = fetch_DBox1byte( prxy, pos);
  if( ni != 1){
    fprintf( FCGI_stderr, "Multiple indexes not supported\n");
    return OPJ_FALSE;
  }
  pos += 1;

  ioff = fetch_DBox8bytebigendian( prxy, pos);
  if( ioff != (Byte8_t)cidx->offset)
    fprintf( FCGI_stderr, "Reference cidx offset in prxy box not correct\n");
  pos += 8;

  ibh = gene_childboxheader( prxy, pos);
  if( ibh->length != cidx->length || strncmp( ibh->type, "cidx",4)!=0)
    fprintf( FCGI_stderr, "Reference cidx header in prxy box not correct\n");
  pos += ibh->headlen;
  opj_free(ibh);

  opj_free(prxy);

  return OPJ_TRUE;
}