static void
clock_location_localtime (SystemTimezone *systz, char *tzone, struct tm *tm, time_t now)
{
	glong offset = get_offset (tzone, systz);
	time_t real_now = now + offset;

        clock_set_tz (tzone);

        localtime_r (&real_now, tm);

        clock_unset_tz (systz);
}
示例#2
0
void c64_magic_voice_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{
	if (!io2 && sphi2)
	{
		m_tpi->write(space, offset & 0x07, data);
	}

	int roml2 = !(!roml || (roml && !PB5 && A12 && A13 && !A14 && A15));
	int romh2 = !((!romh && !PB6) || (!PB5 && A12 && A13 && !A14 && !A15));

	m_exp->cd_w(space, get_offset(offset), data, sphi2, ba, roml2, romh2, io1, 1);
}
示例#3
0
static floperr_t internal_cqm_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
{
	UINT64 offset;
	floperr_t err;

	// take sector offset
	err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
	if (err)
		return err;
	memcpy(buffer,get_tag(floppy)->buf+offset,buflen);
	return FLOPPY_ERROR_SUCCESS;
}
示例#4
0
static floperr_t internal_sorc_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, bool sector_is_index, const void *buffer, size_t buflen, int ddam)
{
	uint64_t offset;
	floperr_t err;

	err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
	if (err)
		return err;

	floppy_image_write(floppy, buffer, offset, buflen);
	return FLOPPY_ERROR_SUCCESS;
}
示例#5
0
static floperr_t exi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
{
	floperr_t err;
	err = get_offset(floppy, head, track, sector, FALSE, NULL);
	if (err)
		return err;

	if (sector_length) {
		*sector_length = 256;
	}
	return FLOPPY_ERROR_SUCCESS;
}
示例#6
0
static floperr_t td0_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *sector_length)
{
	floperr_t err;
	err = get_offset(floppy, head, track, sector, false, nullptr);
	if (err)
		return err;

	if (sector_length) {
		*sector_length = get_tag(floppy)->sector_size;
	}
	return FLOPPY_ERROR_SUCCESS;
}
示例#7
0
/* Not much happens here.  Eventually use this function to try and
 * avoid saving/reloading the source pointers each vertex (if some of
 * them can fit in registers).
 */
static void get_src_ptr( struct x86_program *p,
			 struct x86_reg srcREG,
			 struct x86_reg vtxREG,
			 struct tnl_clipspace_attr *a )
{
   struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx);
   struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr));

   /* Load current a[j].inputptr
    */
   x86_mov(&p->func, srcREG, ptr_to_src);
}
示例#8
0
static floperr_t dsk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
{
	floperr_t err;
	err = get_offset(floppy, head, track, sector, FALSE, NULL);
	if (err)
		return err;

	if (sector_length) {
		*sector_length = get_tag(floppy)->sector_size;
	}
	return FLOPPY_ERROR_SUCCESS;
}
示例#9
0
static floperr_t internal_basicdsk_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
{
	UINT64 offset;
	floperr_t err;

	err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
	if (err)
		return err;

	floppy_image_write(floppy, buffer, offset, buflen);
	return FLOPPY_ERROR_SUCCESS;
}
示例#10
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));
    }
  }
}
示例#11
0
static void *get_virtual_base_pointer(void                  *ptr,
                                      a_base_class_spec_ptr bcsp)
/*
Return a pointer to the virtual base class of the derived object ptr as
specified by bcsp.
*/
{
  a_vtbl_entry_ptr vtbl, vbase_offset;

  vtbl = *((a_vtbl_entry_ptr *)ptr);
  vbase_offset = (a_vtbl_entry_ptr)(((char *)vtbl) + get_offset(bcsp));
  return (void *)(((char *)ptr) + *vbase_offset);
}  /* get_virtual_base_pointer */
示例#12
0
int draw_pixl(PFBDEV const pfbdev,int x,int y,unsigned int color)
{
	char *offset;	

	if (is_fbdev(pfbdev))
		return -1;
	offset = (char *)get_offset(pfbdev,x,y);
	*offset = (color & COLOR);
	*(offset + 1) = ((color >> 8) & COLOR);
	*(offset + 2) = ((color >> 16) & COLOR);

	return 0;
}
示例#13
0
void trans_op(Operand op){
	switch(op->kind){
		case CONSTANT:
			fprintf(f2, "\tli $t0, %d\n", op->u.value);
			break;
		case ARRA:
			fprintf(f2, "\tmove $t1, $fp\n");
			fprintf(f2, "\taddi $t1, $t1, -%d\n", get_offset(op->u.array_var_no, 1));
			fprintf(f2, "\tmove $t0, $t1\n");
			break;
		case ADDRESS:
			fprintf(f2, "\tlw $t1, -%d($fp)\n", get_offset(op->u.addr_temp_no, 0));
			fprintf(f2, "lw $t0, 0($t1)\n");
			break;
		case VARIABLE:
			fprintf(f2, "\tlw $t0, -%d($fp)\n", get_offset(op->u.var_no, 1));
			break;
		case TEMP:
			fprintf(f2, "\tlw $t0, -%d($fp)\n", get_offset(op->u.temp_no, 0));
			break;
	}
}
示例#14
0
/* Adds another pointer to a struct represented by an offset table */
int add_to_table_otable(struct offset_table *src, struct offset_table *dest){
    struct offset_member temp;

    temp.offset = get_offset(DYN_S_VOIDP, dest);
    temp.size = dstru_sizeof(DYN_S_VOIDP, NULL);
    temp.scalar_type = STYPE_NONE;
    temp.flags = SPTR_OFFSET_TBL;
    temp.subtable = src;

    dest->structure_size += temp.size;
    table_add_entry(dest, temp);

    return 0;
}
示例#15
0
/* Adds a pointer to a scalar */
int add_to_table_sptr(struct offset_table *dest, struct ffi_instruction *ins){
    struct offset_member temp;

    temp.offset = get_offset(DYN_S_VOIDP, dest);
    temp.size = dstru_sizeof(DYN_S_VOIDP, NULL);
    temp.scalar_type = (enum type) ins->type;
    temp.flags = PTR_MEMBER;
    temp.subtable = NULL;

    dest->structure_size += temp.size;
    table_add_entry(dest, temp);

    return 0;
}
示例#16
0
/* delete = 1 Do delete dbdata
   delete = 0 Do not delete dbdta */
unsigned int file_commit_block(unsigned char *dbdata, INOBNO inobno, 
									off_t offset)
{
    unsigned char *stiger;
    compr *compressed;
    INUSE *inuse;
	OFFHASH *offhash;
    unsigned int ret = 0;
#ifndef SHA3
    word64 res[3];
#endif

    FUNC;
#ifdef SHA3
    stiger=sha_binhash(dbdata, BLKSIZE);
#else
    binhash(dbdata, BLKSIZE, res);
    stiger=(unsigned char *)&res;
#endif
#ifdef LZO
    compressed = lzo_compress((unsigned char *) dbdata, BLKSIZE);
#else
    compressed = clz_compress((unsigned char *) dbdata, BLKSIZE);
#endif
    ret = compressed->size;
    inuse = file_get_inuse(stiger);
    if (NULL == inuse) {
        loghash("commit_block : write hash with file_qdta", stiger);
        inuse = s_malloc(sizeof(INUSE));
        inuse->inuse = 0;
        inuse->offset = get_offset(compressed->size);
        inuse->size = compressed->size;
        file_qdta(&inobno, stiger, compressed->data, compressed->size,
                  inuse->offset);
    } else
        loghash("commit_block : only updated inuse for hash ", stiger);
    inuse->inuse++;
    file_update_inuse(stiger, inuse);
    comprfree(compressed);
	offhash = s_malloc(sizeof(OFFHASH));
	offhash->offset = offset;
	memcpy(offhash->stiger, stiger, config->hashlen);
    write_dbb_to_cache(&inobno, offhash);
#ifdef SHA3
    free(stiger);
#endif
    free(inuse);
    return (ret);
}
示例#17
0
void	bltin_completion(t_prompt *prompt, char **env)
{
  int	count;
  int	ret;

  if ((prompt->offset =
       get_offset(prompt->line, prompt->count_char, &ret)) == -1)
    return ;
  if (ret == 0
      && (count = count_commands(prompt, env)))
    print_commands(prompt, env, count);
  else
    print_files(prompt);

}
示例#18
0
文件: region.cpp 项目: Ben0mega/c10t
  time_t region::read_modification_time(unsigned int x, unsigned int z) const
  {
    if (!header) {
      throw bad_region(path, "header has not been loaded");
    }

    int o = get_offset(x, z) + RECORD_SIZE;

    uint8_t buf[HEADER_RECORD_SIZE];

    ::memcpy(reinterpret_cast<char*>(buf), &header[o], HEADER_RECORD_SIZE);

    uint32_t mtime = ((buf[0] << 24) || (buf[1] << 16) || (buf[2] << 8)) || buf[3];
    return mtime;
  }
示例#19
0
//address
static void *add_free_block(void *bp) {
//dbg_printf("addfree%p\n",bp);
    void* block;
    if (free_list==base) {
        set_succ(bp,0);
        set_pred(bp,0);
        free_list=bp;
        return bp;
    }
//int i=0;
    block=free_list;
    size_t block_off;
    while(block!=base) {
//printf("freehead%p",block);
        block_off=get_offset(block);
        if (get_offset(bp)<block_off) {
            set_succ(bp,block_off);
            set_pred(bp,get_pred_offset(block));
            void *pred=pred_blkp(block);
            set_pred(block,get_offset(bp));
            if (block==free_list)
                free_list=bp;
            else {
                set_succ(pred,get_offset(bp));
            }//printf("add%p %p %p %p\n",bp,pred_blkp(bp),succ_blkp(bp),block);
            return bp;
        }
        block=succ_blkp(block);
        //	i++;
    }
    set_succ(bp,0);
    set_pred(bp,block_off);
    set_succ(get_addr(block_off),get_offset(bp));
    return bp;

}
示例#20
0
SgAsmCoffSymbolTable*
SgAsmCoffSymbolTable::parse()
{
    /* Set the section size according to the number of entries indicated in the header. */
    SgAsmPEFileHeader *fhdr = dynamic_cast<SgAsmPEFileHeader*>(get_header());
    ROSE_ASSERT(fhdr!=NULL);
    set_offset(fhdr->get_e_coff_symtab());
    set_size(fhdr->get_e_coff_nsyms()*SgAsmCoffSymbol::COFFSymbol_disk_size);

    SgAsmGenericSection::parse();

    /* The string table immediately follows the symbols. The first four bytes of the string table are the size of the
     * string table in little endian. */
    rose_addr_t strtab_offset = get_offset() + fhdr->get_e_coff_nsyms() * SgAsmCoffSymbol::COFFSymbol_disk_size;
    p_strtab = new SgAsmGenericSection(fhdr->get_file(), fhdr);
    p_strtab->set_offset(strtab_offset);
    p_strtab->set_size(sizeof(uint32_t));
    p_strtab->set_synthesized(true);
    p_strtab->set_name(new SgAsmBasicString("COFF Symbol Strtab"));
    p_strtab->set_purpose(SP_HEADER);
    p_strtab->parse();

    uint32_t word;
    p_strtab->read_content(0, &word, sizeof word);
    rose_addr_t strtab_size = ByteOrder::le_to_host(word);
    if (strtab_size < sizeof(uint32_t))
        throw FormatError("COFF symbol table string table size is less than four bytes");
    p_strtab->extend(strtab_size - sizeof(uint32_t));

    /* Parse symbols until we've parsed the required number or we run off the end of the section. */
    for (size_t i = 0; i < fhdr->get_e_coff_nsyms(); i++) {
        try {
            SgAsmCoffSymbol *symbol = new SgAsmCoffSymbol(fhdr, this, p_strtab, i);
            i += symbol->get_st_num_aux_entries();
            p_symbols->get_symbols().push_back(symbol);
        } catch (const ShortRead &e) {
            fprintf(stderr, "SgAsmCoffSymbolTable::parse: warning: read past end of section \"%s\" [%d]\n"
                    "    symbol #%zu at file offset 0x%08"PRIx64"\n"
                    "    skipping %zu symbols (including this one)\n",
                    get_name()->get_string(true).c_str(), get_id(),
                    i, e.offset,
                    fhdr->get_e_coff_nsyms()-i);
            break;
        }
    }

    return this;
}
示例#21
0
/* %k */
static int print_key (FILE * stream,
		      const struct printf_info *info,
		      const void *const *args)
{
    const struct key * key;
    char * buffer;
    int len;

    key = *((const struct key **)(args[0]));
    len = asprintf (&buffer, "%u %u 0x%Lx %s",  
		    key_dir_id(key),
                    key_objectid(key),
                    get_offset (key),
                    key_of_what (key));
    FPRINTF;
}
示例#22
0
void text_display::timerEvent(QTimerEvent *event)
{
	if(event->timerId() == cursor_timer_id){
		cursor_state = !cursor_state;
		QPoint screen = nibble_to_screen(get_cursor_nibble());
		update(screen.x(), screen.y(), cursor_width, editor_font::get_height());
	}else if(event->timerId() == scroll_timer_id){
		selection selection_area = get_selection();
		set_offset(get_offset() + columns * scroll_direction * scroll_speed);
		if(selection_area.is_dragging()){
			selection_area.move_end(columns * 2 * scroll_direction);
			set_selection(selection_area);
		}
		editor->update_window();
	}
}
示例#23
0
文件: sampler.cpp 项目: nerdstrike/vg
map<pos_t, char> Sampler::next_pos_chars(pos_t pos) {
    map<pos_t, char> nexts;
    
    // See if the node is cached (did we just visit it?)
    pair<Node, bool> cached = node_cache.retrieve(id(pos));
    
    if(!cached.second) {
        // If it's not in the cache, put it in
        cached.first = xgidx->node(id(pos));
        node_cache.put(id(pos), cached.first);
    }
    
    Node& node = cached.first;
    // if we are still in the node, return the next position and character
    if (offset(pos) < node.sequence().size()-1) {
        ++get_offset(pos);
        nexts[pos] = pos_char(pos);
    } else {
        // look at the next positions we could reach
        if (!is_rev(pos)) {
            // we are on the forward strand, the next things from this node come off the end
            for (auto& edge : xgidx->edges_on_end(id(pos))) {
                if (edge.from() == id(pos)) {
                    pos_t p = make_pos_t(edge.to(), edge.to_end(), 0);
                    nexts[p] = pos_char(p);
                } else if (edge.from_start() && edge.to_end() && edge.to() == id(pos)) {
                    // doubly inverted, should be normalized to forward but we handle here for safety
                    pos_t p = make_pos_t(edge.from(), false, 0);
                    nexts[p] = pos_char(p);
                }
            }
        } else {
            // we are on the reverse strand, the next things from this node come off the start
            for (auto& edge : xgidx->edges_on_start(id(pos))) {
                if (edge.to() == id(pos)) {
                    pos_t p = make_pos_t(edge.from(), !edge.from_start(), 0);
                    nexts[p] = pos_char(p);
                } else if (edge.from_start() && edge.to_end() && edge.from() == id(pos)) {
                    // doubly inverted, should be normalized to forward but we handle here for safety
                    pos_t p = make_pos_t(edge.to(), true, 0);
                    nexts[p] = pos_char(p);
                }
            }
        }
    }
    return nexts;
}
示例#24
0
文件: arm.c 项目: halfbro/radare
int rasm_arm(ut64 offset, const char *str, unsigned char *data)
{
    char op[128];
    char *arg;

    strncpy(op, str, 120);
    arg = strchr(op, ' ');
    if (arg) {
        arg[0] = '\0';
        arg = arg + 1;
    }

    if (!strcmp(op, "trap")) {
        memcpy(data, "\xe7\xff\xde\xf", 4);
        return 4;
    } else if (!strcmp(op, "int")) {
        unsigned int sc = get_offset(arg);
        unsigned char *ptr = (uchar *)&sc;
        data[0] = 0x5f; // 0xff ??
        data[1] = ptr[2];
        data[2] = ptr[1];
        data[3] = ptr[0];
        return 4;
    } else if (!strcmp(op, "hang")) {
        memcpy(data, "\xea\xfe\xff\xff", 4);
        return 4;
    } else if (!strcmp(op, "jmp")) {
        off_t dst = get_math(arg);
        unsigned long addr = (dst-8)/4;
        unsigned char *ptr = (uchar *)&addr;

        data[0] = 0xea;
        data[1] = ptr[2];
        data[2] = ptr[1];
        data[3] = ptr[0];
        return 4;
    } else if (!strcmp(op, "jz")) {
    } else if (!strcmp(op, "nop")) {
        // little endian
        memcpy(data, "\x00\x00\xa0\xe1", 4);
    } else
        return -1;

    return 4;
}
示例#25
0
/* Parser */
SgAsmPESectionTable*
SgAsmPESectionTable::parse()
{
    SgAsmGenericSection::parse();

    SgAsmPEFileHeader *fhdr = dynamic_cast<SgAsmPEFileHeader*>(get_header());
    ROSE_ASSERT(fhdr!=NULL);

    /* Parse section table and construct section objects, but do not parse the sections yet. */
    SgAsmGenericSectionPtrList pending;
    const size_t entsize = sizeof(SgAsmPESectionTableEntry::PESectionTableEntry_disk);
    for (size_t i=0; i<fhdr->get_e_nsections(); i++) {
        SgAsmPESectionTableEntry::PESectionTableEntry_disk disk;
        if (entsize!=read_content_local(i * entsize, &disk, entsize, false))
            fprintf(stderr, "SgAsmPESectionTable::parse: warning: section table entry %" PRIuPTR " at file offset 0x%08"PRIx64
                    " extends beyond end of defined section table.\n",
                    i, get_offset()+i*entsize);
        SgAsmPESectionTableEntry *entry = new SgAsmPESectionTableEntry(&disk);

        SgAsmPESection *section = NULL;
        if (entry->get_name() == ".idata") {
            section = new SgAsmPEImportSection(fhdr);
        } else {
            section = new SgAsmPESection(fhdr);
        }
        section->init_from_section_table(entry, i+1);
        pending.push_back(section);
    }

    /* Build the memory mapping like the real loader would do. This is the same code used by
     * SgAsmExecutableFileFormat::parseBinaryFormat() except we're doing it here early because we need it in the rest of the
     * PE parser. */
    ROSE_ASSERT(NULL==fhdr->get_loader_map());
    BinaryLoader *loader = BinaryLoader::lookup(fhdr); /*no need to clone; we're not changing any settings*/
    ROSE_ASSERT(loader!=NULL);
    MemoryMap *loader_map = new MemoryMap;
    loader->remap(loader_map, fhdr);
    fhdr->set_loader_map(loader_map);

    /* Parse each section after the loader map is created */
    for (size_t i=0; i<pending.size(); i++)
        pending[i]->parse();

    return this;
}
/* Fill in the response with the current hash status */
static void fill_response(struct ec_response_vboot_hash *r,
			  int request_offset)
{
	if (in_progress)
		r->status = EC_VBOOT_HASH_STATUS_BUSY;
	else if (get_offset(request_offset) == data_offset && hash &&
		 !want_abort) {
		r->status = EC_VBOOT_HASH_STATUS_DONE;
		r->hash_type = EC_VBOOT_HASH_TYPE_SHA256;
		r->digest_size = SHA256_DIGEST_SIZE;
		r->reserved0 = 0;
		r->offset = data_offset;
		r->size = data_size;
		ASSERT(SHA256_DIGEST_SIZE < sizeof(r->hash_digest));
		memcpy(r->hash_digest, hash, SHA256_DIGEST_SIZE);
	} else
		r->status = EC_VBOOT_HASH_STATUS_NONE;
}
static void
insert_location (GtkTreeStore *store, GWeatherTimezone *zone, const char *loc_name, GtkTreeIter *parent)
{
    GtkTreeIter iter;
    char *name, *offset;

    offset = get_offset (zone);
    name = g_strdup_printf ("%s <small>(%s)</small>",
                            loc_name ? loc_name : gweather_timezone_get_name (zone),
                            offset);
    gtk_tree_store_append (store, &iter, parent);
    gtk_tree_store_set (store, &iter,
                        GWEATHER_TIMEZONE_MENU_NAME, name,
                        GWEATHER_TIMEZONE_MENU_ZONE, zone,
                        -1);
    g_free (name);
    g_free (offset);
}
示例#28
0
static int read_block_raw(struct hlfs_ctrl *ctrl,uint32_t storage_address,char* block_buf)
{
	//HLOG_DEBUG("enter func %s", __func__);
    uint32_t block_size = ctrl->sb.block_size;
    struct back_storage * storage =NULL;
    uint32_t offset = get_offset(storage_address);
    uint32_t segno = get_segno(storage_address);
    if(segno >= ctrl->start_segno){
             storage = ctrl->storage;
    }else{
             if(NULL == (storage = get_parent_storage(ctrl->family,segno))){
		  return -1;
	      }
    }
    int ret = read_block(storage,storage_address,block_size,block_buf);
    //HLOG_DEBUG("leave func %s", __func__);
    return ret;
}
示例#29
0
string ArchivoRegVars::get(t_num_ref n){
    t_reg_var_size reg_size;
    int bytes_para_campo_longitud=sizeof(t_reg_var_size);

    t_offset offset=get_offset(n);
    fseek(f_d_handler, offset, SEEK_SET);
    fread(&reg_size, 1, bytes_para_campo_longitud, f_d_handler);
    char* buffer= (char*) malloc(reg_size+1);
    fread(buffer, 1, reg_size, f_d_handler);
    *(buffer+reg_size)='\0';

    if(ferror(f_d_handler)!=0){
        salir("",ERROR_DE_LECTURA_DATOS);
    }
    string data=buffer;
    free(buffer);
return data;
}
示例#30
0
bl particle::iterate( vector& _vector, const map2d::layer* _layer, f32 _f32_gravity, bl _bl_fixed,
f32 _f32_rate )
{
	translation translation_iteration;

	if( collides( translation_iteration, _layer, _bl_fixed, _f32_rate ) )
	{
		_vector = translation_iteration.vector_collision;

		if( translation_iteration.get_collision_distance() - ENG2D_PRECISION > 0.f )
			position() = get_moved( direction, translation_iteration.get_collision_distance() - ENG2D_PRECISION );

		f32 d = direction;
		f32 c = translation_iteration.line_collision.get_normal_direction();
		f32 b = c - d;

		direction = c + b - math<f32>::radians_05();

		vector vector_offset = get_offset(true);

		const map2d::tile* tile_map = &_layer->get( _vector );

		vector_offset.x *= ( 1.f - roughness ) * ( 1.f - tile_map->get_friction()    );
		vector_offset.y *=         hardness    * ( 1.f - tile_map->get_restitution() );

		set_offset( vector_offset, true );

		return true;
	}
	else
	{
		position() = get_moved( direction, get_distance( _bl_fixed, _f32_rate ) );

		if( _bl_fixed )
		{
			shift_offset_y( _f32_gravity * _layer->get_gravity(),                             true, _f32_rate );
		}
		else
		{
			shift_offset_y( _f32_gravity * _layer->get_gravity() * ( sys::delta() * 1000.0 ), true, _f32_rate );
		}

		return false;
} }