Beispiel #1
0
void GrowableIOBuffer::SetCapacity(int capacity) {
  assert(capacity >= 0);
  // realloc will crash if it fails.
  real_data_.reset(static_cast<char*>(realloc(real_data_.release(), capacity)));
  capacity_ = capacity;
  if (offset_ > capacity)
    set_offset(capacity);
  else
    set_offset(offset_);  // The pointer may have changed.
}
Beispiel #2
0
void
TileMap::editor_update()
{
  if (get_walker()) {
    if (get_path() && get_path()->is_valid()) {
      m_movement = get_walker()->get_pos() - get_offset();
      set_offset(get_walker()->get_pos());
    } else {
      set_offset(Vector(0, 0));
    }
  }
}
Beispiel #3
0
//--------------------------------------------------------------------------
static void load_imports(linput_t *li, dl_header &dl)
{
  if ( !dl.import_list_count ) return;
  qlseek(li, first_text_subspace_fpos+dl.import_list_loc);
  ea_t ea = data_start + dl.dlt_loc;
  int n   = dl.dlt_count;
  char buf[MAXSTR];
  for ( int i=0; i < dl.import_list_count; i++ )
  {
    import_entry ie;
    lread(li, &ie, sizeof(ie));
    ie.swap();
    if ( n == 0 ) ea = data_start + dl.plt_loc;
    n--;
    buf[0] = '.';
    get_text_name(ie.name, &buf[1], sizeof(buf)-1);
    do_name_anyway(ea, buf);
    doDwrd(ea, 4);
    set_offset(ea, 0, 0);
    if ( n > 0 )
    {
      ea += 4;
    }
    else
    {
      ea_t ea2 = get_long(ea);
      do_name_anyway(ea2, &buf[1]);
      add_func(ea2, BADADDR);
      set_func_cmt(get_func(ea2), "THUNK", false);
      doDwrd(ea+4, 4);
      ea += 8;
    }
  }
}
Beispiel #4
0
void DexInstruction::verify_encoding() const {
  auto test = m_count ? new DexInstruction(opcode()) : new DexInstruction(opcode(), 0);
  if (dests_size()) {
    test->set_dest(dest());
  }
  for (unsigned i = 0; i < srcs_size(); i++) {
    test->set_src(i, src(i));
  }
  if (has_range_base()) test->set_range_base(range_base());
  if (has_range_size()) test->set_range_size(range_size());
  if (has_arg_word_count()) test->set_arg_word_count(arg_word_count());
  if (has_literal()) test->set_literal(literal());
  if (has_offset()) test->set_offset(offset());

  assert_log(m_opcode == test->m_opcode, "%x %x\n", m_opcode, test->m_opcode);
  for (unsigned i = 0; i < m_count; i++) {
    assert_log(m_arg[i] == test->m_arg[i],
               "(%x %x) (%x %x)",
               m_opcode,
               m_arg[i],
               test->m_opcode,
               test->m_arg[i]);
  }

  delete test;
}
Beispiel #5
0
static int update_off_mtime(const char *file, int fd)
{
#ifdef PGSQL
    PGconn *conn;
    time_t now = -1;
    off_t  off = -1;
    char *ret = NULL;

    if ((conn = logpg_conn()) == NULL)
        return -1;

    time(&now);
    if ((ret = set_last_mtime(conn, file, &now)) == NULL) {
        fprintf(stderr, "set_last_mtime failed.\n");
        return -1;
    }
    free(ret);

    off = lseek(fd, 0, SEEK_CUR);
    if ((ret = set_offset(conn, file, off)) == NULL) {
        fprintf(stderr, "set_offset failed.\n");
        return -1;
    }
    free(ret);

#endif
    return 0;
}
Beispiel #6
0
//----------------------------------------------------------------------
//
//      define location as word (2 byte), convert it to an offset, rename it
//      and comment it with the file offset
//
static void name_vector( ushort address, const char *name )
{
    do_unknown( address, true );
    do_data_ex( address, wordflag(), 2, BADNODE );
    set_offset( address, 0, 0 );
    set_name( address, name );
}
Beispiel #7
0
/** Update this segment table entry with newer information from the section */
void
SgAsmElfSegmentTableEntry::update_from_section(SgAsmElfSection *section)
{
    set_offset(section->get_offset());
    set_filesz(section->get_size());
    set_vaddr(section->get_mapped_preferred_va());
    set_memsz(section->get_mapped_size());
    set_align(section->is_mapped() ? section->get_mapped_alignment() : section->get_file_alignment());

    if (section->get_mapped_rperm()) {
        set_flags((SegmentFlags)(p_flags | PF_RPERM));
    } else {
        set_flags((SegmentFlags)(p_flags & ~PF_RPERM));
    }
    if (section->get_mapped_wperm()) {
        set_flags((SegmentFlags)(p_flags | PF_WPERM));
    } else {
        set_flags((SegmentFlags)(p_flags & ~PF_WPERM));
    }
    if (section->get_mapped_xperm()) {
        set_flags((SegmentFlags)(p_flags | PF_XPERM));
    } else {
        set_flags((SegmentFlags)(p_flags & ~PF_XPERM));
    }

    if (isSgAsmElfNoteSection(section)) {
        set_type(PT_NOTE);
    }
}
Beispiel #8
0
//----------------------------------------------------------------------
int idaapi emu(void)
{
  uint32 Feature = cmd.get_canon_feature();

  flow = ((Feature & CF_STOP) == 0);

  if ( Feature & CF_USE1 ) process_operand(cmd.Op1, true);
  if ( Feature & CF_USE2 ) process_operand(cmd.Op2, true);
  if ( Feature & CF_USE3 ) process_operand(cmd.Op3, true);
  if ( Feature & CF_CHG1 ) process_operand(cmd.Op1, false);
  if ( Feature & CF_CHG2 ) process_operand(cmd.Op2, false);
  if ( Feature & CF_CHG3 ) process_operand(cmd.Op3, false);

//
//      Determine if the next instruction should be executed
//
  if ( segtype(cmd.ea) == SEG_XTRN ) flow = 0;
  if ( flow ) ua_add_cref(0,cmd.ea+cmd.size,fl_F);

//
//      convert "lda imm, reg" to "lda mem, reg"
//

  if ( cmd.itype == I960_lda
    && cmd.Op1.type == o_imm
    && !isDefArg(uFlag, 0)
    && isEnabled(cmd.Op1.value) ) set_offset(cmd.ea, 0, 0);

  return 1;
}
Beispiel #9
0
/* main: parse args, loop over FILES, count and print results */
int main(int argc, char *args[])
{
	int i = 1;
	int fd;
	struct ht ht = {0, 0, 0, 0, 0};

	i += parse_opts(argc, args, &ht);
	ht.side = END;
	/* if no options specified, fallback to default */
	set_default(&ht);

	while (args[i]) {
		fd = open(args[i], O_RDONLY);
		if (fd < 0) {
			fprintf(stderr, "File %s not found.\r\n", args[i]);
			i++;
			continue;
		}
		struct wc wc = {0, 0, 0};
		word_count(fd, &wc);

		close(fd);
		fd = open(args[i], O_RDONLY);

		set_offset(&ht, &wc);

		ouroboros(fd, &ht);

		close(fd);
		i++;
	}

	exit(0);
}
Beispiel #10
0
loff_t i2c_flash_lseek(struct file *file, loff_t offset, int whence) {
	
	char *asBuf = kmalloc(2, GFP_KERNEL);
	int address;
	int res;

	set_offset(offset);

	//Addres Low
	address = (currPage & 0x00ff);
	memcpy((char *)asBuf + 1, &address, 1);

	//Address high
	address = (currPage & 0xff00) >> 8;
	memcpy((char *)asBuf, &address, 1);

	

	res = i2c_master_send(client, asBuf, 2);

	if (res < 0) {
		printk("\nWriting the address failed!\n");
		return -1;
	}

	if (asBuf) kfree(asBuf);

	return res;
}
Beispiel #11
0
Samples::Samples(Samples *src)
{
	reset();
	share(src->get_shmid());
	set_allocated(src->get_allocated());
	set_offset(src->get_offset());
}
Beispiel #12
0
//----------------------------------------------------------------------
static void fixup(uint32 ea, uint32 delta, int extdef)
{
  fixup_data_t fd;
  fd.type = FIXUP_OFF32;
  if ( extdef ) fd.type |= FIXUP_EXTDEF;
  segment_t *s = getseg(delta);
  fd.displacement = get_long(ea);
  if ( s == NULL ) {
    fd.sel = 0;
    fd.off = delta;
  } else {
    fd.sel = (ushort)s->sel;
    fd.off = delta - get_segm_base(s);
  }
  set_fixup(ea, &fd);
  uint32 target = get_long(ea) + delta;
  put_long(ea, target);
  set_offset(ea, 0, 0);
  cmd.ea = ea; ua_add_dref(0, target, dr_O); cmd.ea = BADADDR;
  if ( target != toc_ea
    && !has_name(get_flags_novalue(ea))
    && has_name(get_flags_novalue(target)) )
  {
    char buf[MAXSTR];
    if ( get_true_name(BADADDR, target, &buf[3], sizeof(buf)-3) != NULL )
    {
      buf[0] = 'T';
      buf[1] = 'C';
      buf[2] = '_';
      do_name_anyway(ea, buf);
      make_name_auto(ea);
    }
  }
//  toc.charset(ea,XMC_TC+1,1);
}
Beispiel #13
0
void GraphNode::_input_event(const InputEvent& p_ev) {

	if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {

		Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
		if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
			emit_signal("close_request");
			return;
		}

		drag_from=get_offset();
		drag_accum=Vector2();
		dragging=true;
		emit_signal("raise_request");

	}

	if (p_ev.type==InputEvent::MOUSE_BUTTON && !p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {

		dragging=false;
		emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
	}

	if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {

		drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
		set_offset(drag_from+drag_accum);
	}

}
Beispiel #14
0
void gui_surface::resize(const float2& buffer_size_) {
	uint2 buffer_size_abs_ = ((flags & SURFACE_FLAGS::ABSOLUTE_SIZE) == SURFACE_FLAGS::ABSOLUTE_SIZE ?
							  buffer_size_.rounded() :
							  buffer_size_ * float2(oclraster::get_width(), oclraster::get_height()));
	if(buffer.get_attachment_count() != 0 &&
	   buffer_size_abs.x == buffer_size_abs_.x && buffer_size_abs.y == buffer_size_abs_.y) {
		// same size, nothing to do here
		return;
	}
	buffer_size = buffer_size_;
	buffer_size_abs = buffer_size_abs_;
	
	delete_buffer();
	
	const bool has_depth = ((flags & SURFACE_FLAGS::NO_DEPTH) != SURFACE_FLAGS::NO_DEPTH);
	buffer = framebuffer::create_with_images(buffer_size_abs.x, buffer_size_abs.y,
											 { { IMAGE_TYPE::UINT_8, IMAGE_CHANNEL::RGBA } },
											 {
												 has_depth ? IMAGE_TYPE::FLOAT_32 : IMAGE_TYPE::NONE,
												 has_depth ? IMAGE_CHANNEL::R : IMAGE_CHANNEL::NONE
											 });
	
	// set blit vbo rectangle data
	set_offset(offset);
	
	//
	redraw();
}
Beispiel #15
0
int pkg_dispack(void *net_struct,char *buf,T_PkgType *pkg_type,char delimit)
{
	char *cp;
	register char *cp1;
	char dml[2];
	T_PkgType *typ;

	*dml=delimit;
	dml[1]=0;
	cp=buf;
	if(!cp||!*cp) return 0;
	if(pkg_type->offset<0) set_offset(pkg_type);
	for(typ=pkg_type;typ->type>-1;typ++){
		if(typ->bindtype&NOSELECT) continue;
		if(typ->type==CH_STRUCT) {
			cp+=pkg_dispack((char *)net_struct+typ->offset,cp,(T_PkgType *)typ->format,delimit);
			continue;
		}
		cp1=cp;
		cp=stptok(cp,0,0,dml);
		if(*cp==delimit) *cp++=0;
		put_str_one(net_struct,cp1,typ,delimit);
		if(!*cp) break;
	}
	return (cp-buf);
}
Beispiel #16
0
int VMDTracker::start(const SensorConfig *config) {
  set_scale(config->getscale());
  set_offset(config->getoffset());
  set_right_rot(config->getright_rot());
  set_left_rot(config->getleft_rot());
  return do_start(config);
}
Beispiel #17
0
//----------------------------------------------------------------------
static void process_vector(uint32 ea, const char *name)
{
  set_offset(ea,0,0);
  set_offset(ea+4,0,0);
  uint32 mintoc = get_long(ea+4);
  if ( segtype(mintoc) == SEG_DATA && mintoc < toc_ea )
  {
    toc_ea = mintoc;
    ph.notify(processor_t::idp_notify(ph.loader+1), toc_ea);
  }
  set_name(ea, name);
  char buf[MAXSTR];
  qsnprintf(buf, sizeof(buf), ".%s", name);
  uint32 code = get_long(ea);
  add_entry(code, code, buf, 1);
  make_name_auto(code);
}
Beispiel #18
0
ulong bit_reader::read(std::size_t length)
{
	if(debugging)
		std::cout << "Reading " << length << " bit(s)" << std::endl;
	ulong output = nil::read_little_endian(data.c_str(), offset, length);
	std::size_t new_offset = offset + length;
	set_offset(new_offset);
	return output;
}
Beispiel #19
0
void bsacfa::operator= (const bsacfa& other)
{
  if (this != &other) {
	  set_filename(other.get_filename());
	  set_header(other.get_header());
	  set_offset(other.get_offset());
	  set_size(other.get_size());
  }
}
Beispiel #20
0
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
bool t_actor_sequence_24::set_frames( t_bitmap_group_24 const & bitmap_group )
{
	if ( !t_image_sequence_24::set_frames( bitmap_group ) )
		return false;

	set_offset( t_screen_point( -361, -347 ) );

	return true;
}
Beispiel #21
0
/* expand @coord as to accommodate for insertion of @no new entries starting
   from @pos, with total bodies size @size. */
static int expand_item(const coord_t * coord /* coord of item */ ,
		       int pos /* unit position */ , int no	/* number of new
								 * units*/ ,
		       int size /* total size of new units' data */ ,
		       unsigned int data_size	/* free space already reserved
						 * in the item for insertion */ )
{
	int entries;
	cde_unit_header *header;
	char *dent;
	int i;

	assert("nikita-1310", coord != NULL);
	assert("nikita-1311", pos >= 0);
	assert("nikita-1312", no > 0);
	assert("nikita-1313", data_size >= no * sizeof(directory_entry_format));
	assert("nikita-1343",
	       item_length_by_coord(coord) >=
	       (int)(size + data_size + no * sizeof *header));

	entries = units(coord);

	if (pos == entries)
		dent = address(coord, size);
	else
		dent = (char *)entry_at(coord, pos);
	/* place where new header will be in */
	header = header_at(coord, pos);
	/* free space for new entry headers */
	memmove(header + no, header,
		(unsigned)(address(coord, size) - (char *)header));
	/* if adding to the end initialise first new header */
	if (pos == entries) {
		set_offset(coord, pos, (unsigned)size);
	}

	/* adjust entry pointer and size */
	dent = dent + no * sizeof *header;
	size += no * sizeof *header;
	/* free space for new entries */
	memmove(dent + data_size, dent,
		(unsigned)(address(coord, size) - dent));

	/* increase counter */
	entries += no;
	put_unaligned(cpu_to_le16((__u16) entries), &formatted_at(coord)->num_of_entries);

	/* [ 0 ... pos ] entries were shifted by no * ( sizeof *header )
	   bytes.  */
	for (i = 0; i <= pos; ++i)
		adj_offset(coord, i, no * sizeof *header);
	/* [ pos + no ... +\infty ) entries were shifted by ( no *
	   sizeof *header + data_size ) bytes */
	for (i = pos + no; i < entries; ++i)
		adj_offset(coord, i, no * sizeof *header + data_size);
	return 0;
}
Beispiel #22
0
void
TileMap::finish_construction()
{
  if (get_path()) {
    Vector v = get_path()->get_base();
    set_offset(v);
  }

  m_add_path = get_walker() && get_path() && get_path()->is_valid();
}
Beispiel #23
0
char *getitem_idx(char *buf,void *data,T_PkgType *pkg_type,const char *key,const char *colidx,int colnum)
{
	int k;

	if(pkg_type->offset<0) set_offset(pkg_type);
	k=index_col(colidx,colnum,key,pkg_type);
	if(k<0) return 0;
	k=get_one_str(buf,data,pkg_type+k,0);
	return buf+k;
}
Beispiel #24
0
int putitem_idx(void *buf,char *cp,T_PkgType *pkg_type,const char *key,const char *colidx,int colnum)
{
	int k;

	if(pkg_type->offset<0) set_offset(pkg_type);
	k=index_col(colidx,colnum,key,pkg_type);
	if(k<0) return 0;
	k=put_str_one(buf,cp,pkg_type+k,0);
	return k;
}
Beispiel #25
0
T_PkgType *patt_dup(T_PkgType *tp)
{
    int n=set_offset(tp);
    T_PkgType *new_tp;

    new_tp=(T_PkgType *)malloc(sizeof(T_PkgType) * (n+1));
    if(!new_tp) return NULL;
    patt_copy(new_tp,tp,0);
    return new_tp;
}
Beispiel #26
0
void
TileMap::update(float dt_sec)
{
  // handle tilemap fading
  if (m_current_alpha != m_alpha) {
    m_remaining_fade_time = std::max(0.0f, m_remaining_fade_time - dt_sec);
    if (m_remaining_fade_time == 0.0f) {
      m_current_alpha = m_alpha;
    } else {
      float_channel(m_alpha, m_current_alpha, m_remaining_fade_time, dt_sec);
    }
    update_effective_solid ();
  }

  // handle tint fading
  if (m_current_tint.red != m_tint.red || m_current_tint.green != m_tint.green ||
      m_current_tint.blue != m_tint.blue || m_current_tint.alpha != m_tint.alpha) {

    m_remaining_tint_fade_time = std::max(0.0f, m_remaining_tint_fade_time - dt_sec);
    if (m_remaining_tint_fade_time == 0.0f) {
      m_current_tint = m_tint;
    } else {
      float_channel(m_tint.red  , m_current_tint.red  , m_remaining_tint_fade_time, dt_sec);
      float_channel(m_tint.green, m_current_tint.green, m_remaining_tint_fade_time, dt_sec);
      float_channel(m_tint.blue , m_current_tint.blue , m_remaining_tint_fade_time, dt_sec);
      float_channel(m_tint.alpha, m_current_tint.alpha, m_remaining_tint_fade_time, dt_sec);
    }
  }

  m_movement = Vector(0,0);
  // if we have a path to follow, follow it
  if (get_walker()) {
    get_walker()->update(dt_sec);
    Vector v = get_walker()->get_pos();
    if (get_path() && get_path()->is_valid()) {
      m_movement = v - get_offset();
      set_offset(v);
    } else {
      set_offset(Vector(0, 0));
    }
  }
}
void hi_ncurses_fpager_search(hi_ncurses_fpager *pager, char *search)
{
  off_t offset;
  gboolean found;
  
  found = hi_search_compile_and_exec(pager->file, search, pager->offset, &offset, &pager->curses->error);
  if (found == TRUE)
  {
    set_offset(pager, offset);
  }
}
Beispiel #28
0
streammarker::streammarker(streambuf *sb)
{
    _sbuf = sb;
    if (!(sb->xflags() & _S_IS_BACKUPBUF)) {
	set_streampos(sb->seekoff(0, ios::cur, ios::in));
	_next = 0;
    }
    else {
	if (sb->put_mode())
	    sb->switch_to_get_mode();
	if (((backupbuf*)sb)->in_backup())
	    set_offset(sb->_gptr - sb->_egptr);
	else
	    set_offset(sb->_gptr - sb->_eback);

	// Should perhaps sort the chain?
	_next = ((backupbuf*)sb)->_markers;
	((backupbuf*)sb)->_markers = this;
    }
}
Beispiel #29
0
//----------------------------------------------------------------------
static void TouchArg( op_t &x, int isload )
{
  switch( x.type )
  {
    case o_imm:
      doImmd(cmd.ea);
      if ( isOff(uFlag, x.n) )
        ua_add_off_drefs2(x, dr_O, OOF_SIGNED);
      break;
    case o_indexed:                                 // addr[value]
      doImmd(cmd.ea);
      if ( x.value == 0 && !isDefArg(uFlag, x.n) )
        set_offset(cmd.ea, x.n, toEA(cmd.cs, 0));
      if ( isOff(uFlag, x.n) )                      // xref to addr
      {
        uval_t saved = x.value;
        x.value = x.addr;
        ua_add_off_drefs2(x, saved ? dr_O : isload ? dr_R : dr_W, OOF_SIGNED|OOF_ADDR);
        x.value = saved;
      }
      if ( x.value != 0 )                           // xref to value
      {                                             // no references to ZERO_REG
        ea_t ea = toEA(cmd.cs, x.value);
        ua_add_dref(x.offb, ea, isload ? dr_R : dr_W );
        ua_dodata2(x.offb, ea, x.dtyp);
      }
      break;
    case o_indirect:
    case o_indirect_inc:
    case o_mem:
      {
        ea_t dea = toEA( cmd.cs, x.addr );
        ua_dodata2(x.offb, dea, x.dtyp);
        if( !isload )
          doVar(dea);
        ua_add_dref( x.offb, dea, isload ? dr_R : dr_W );
        if ( !isload && (x.addr == 0x14 || x.addr == 0x15) )
        {
          sel_t wsrval = BADSEL;
          if ( cmd.Op2.type == o_imm ) wsrval = sel_t(cmd.Op2.value);
          splitSRarea1(cmd.ea, x.addr == 0x14 ? WSR : WSR1, wsrval, SR_auto);
        }
      }
      break;

    case o_near:
      ea_t ea = toEA( cmd.cs, x.addr );
      int iscall = InstrIsSet( cmd.itype, CF_CALL );
      ua_add_cref( x.offb, ea, iscall ? fl_CN : fl_JN );
      if ( flow && iscall )
        flow = func_does_return(ea);
  }
}
            std::string read() final {
                std::string buffer(osmium::io::Decompressor::input_buffer_size, '\0');
                int nread = ::gzread(m_gzfile, const_cast<char*>(buffer.data()), static_cast_with_assert<unsigned int>(buffer.size()));
                if (nread < 0) {
                    detail::throw_gzip_error(m_gzfile, "read failed");
                }
                buffer.resize(static_cast<std::string::size_type>(nread));
#if ZLIB_VERNUM >= 0x1240
                set_offset(size_t(::gzoffset(m_gzfile)));
#endif
                return buffer;
            }