vector<vector<double>> adm_0o_terms(const string& filename, size_t a){ vector<vector<double>> adm = read_table(filename); vector<vector<double>> ret; for (size_t i = a * a; i < a * a + a; ++i){ ret.push_back(adm[i]); } return ret; }
void create() { string file; quests = read_table("/quest/dynamic_quest"); file = read_file("/quest/dynamic_location"); roomlines = explode(file,"\n"); init_dynamic_quest(1); }
static int pc98_read (PedDisk* disk) { PED_ASSERT (disk != NULL); PED_ASSERT (disk->dev != NULL); ped_disk_delete_all (disk); return read_table (disk); }
bool read_pmt(char *demux, uint16_t service_id, unsigned int timeout, unsigned char *out) { char cache_item[PATH_MAX]; unsigned char pat[MAX_TABLE_LEN]; uint16_t section_length; uint16_t offset; uint16_t map_pid = 0; bool found; bool rc; /* is it in the cache */ snprintf(cache_item, sizeof(cache_item), "pmt-%u", service_id); if(cache_load(cache_item, out)) return true; /* get the PAT */ if(!read_pat(demux, timeout, pat)) return false; section_length = 3 + (((pat[1] & 0x0f) << 8) + pat[2]); /* find the PMT for this service_id */ found = false; offset = 8; /* -4 for the CRC at the end */ while((offset < (section_length - 4)) && !found) { if((pat[offset] << 8) + pat[offset+1] == service_id) { map_pid = ((pat[offset+2] & 0x1f) << 8) + pat[offset+3]; found = true; } else { offset += 4; } } if(!found) fatal("Unable to find PMT PID for service_id %u", service_id); vverbose("PMT PID: %u", map_pid); /* get the PMT */ rc = read_table(demux, map_pid, TID_PMT, timeout, out, 0); /* cache it */ if(rc) cache_save(cache_item, out); else error("Unable to read PMT"); return rc; }
// read a variable and push in onto the stack. this returns 1 if a "normal" // variable was read, or 0 if an end-table or end-function marker was read (in which case // nothing is pushed onto the stack). static int read_variable( Transport *tpt, lua_State *L ) { struct exception e; uint8_t type = transport_read_uint8_t( tpt ); switch( type ) { case RPC_NIL: lua_pushnil( L ); break; case RPC_BOOLEAN: lua_pushboolean( L, transport_read_uint8_t( tpt ) ); break; case RPC_NUMBER: lua_pushnumber( L, transport_read_number( tpt ) ); break; case RPC_STRING: { uint32_t len = transport_read_uint32_t( tpt ); char *s = ( char * )alloca( len + 1 ); transport_read_string( tpt, s, len ); s[ len ] = 0; lua_pushlstring( L, s, len ); break; } case RPC_TABLE: read_table( tpt, L ); break; case RPC_TABLE_END: return 0; case RPC_FUNCTION: read_function( tpt, L ); break; case RPC_FUNCTION_END: return 0; case RPC_REMOTE: read_index( tpt, L ); break; default: e.errnum = type; e.type = fatal; Throw( e ); } return 1; }
// --------------------------------------------------------- // Is this hero normally allowed in taverns? // --------------------------------------------------------- bool hero_allowed_by_default( int portrait_id ) { read_table(); int biography_id = get_default_biography_id_from_portrait_id( portrait_id ); if ( biography_id >= 0 && biography_id < (int)g_default_heroes.size() ) return g_default_heroes[ biography_id ].allowed_by_default; else return false; }
void create() { #ifdef WEATHER day_phase = read_table("/adm/etc/nature/day_phase"); init_day_phase(); weather = read_table("/adm/etc/nature/weather"); init_weather(); #endif #ifdef SEND_MONEY send_money(); #endif clan(); init_mail(); auto_reboot(); war_start(); // do_full(); sp_boss(); sys_init(); call_out( "check_heart_beat", 10 ); }
static void event_nudge(void *drcontext, uint64 argument) { DISPLAY_FUNC(NAME" received nudge event; re-reading config file."); /* An external process has nudged us with dr_nudge_process() telling us * to re-read the configuration file. */ dr_mutex_lock(table_lock); free_table(); read_table(); dr_mutex_unlock(table_lock); }
int main( int argc, char *argv[]) { Arb_connection *conn = NULL; int rc; int i; char server[128]; char database[128]; /* schema */ char user[128]; char password[128]; char application[128]; char infile[256]; get_env_param( argc, argv, 0, server, database, user, password); strcpy( application, __FILE__); #if 0 printf( "server = '%s'\n" "database = '%s'\n" "user = '******'\n" "password = '******'\n" "application = '%s'\n", server, database, user, password, application); #endif init_DLAYER_THREAD(); rc = arb_database_login( server, database, user, password, application, ALLOW_BCP, &conn); if( rc == SUCCESS) puts( "Login successful."); else { puts( "Login failed."); exit(1); } drop_table( conn, TABLENAME); create_testcols_table( conn); create_procedure( conn); populate_table( conn); read_table( conn); arb_close(conn,1); exit_DLAYER_THREAD(); return 0; }
/* Read in all of the tables, create the decoding decision tree and return the tree root. */ static struct bittree * initialize_decoder_tree (void) { int i; const int num_of_tables = (sizeof (aarch64_opcode_tables) / sizeof (struct aarch64_opcode *)); for (i = 0; i < num_of_tables; ++i) read_table (aarch64_opcode_tables [i]); if (debug) print_opcode_nodes (); return divide_table (); }
bool G_SoldierMakeMgr::init() { auto tab_info = the_app->script()->read_table("the_soldier_make_info"); if (tab_info->is_nil()) { return false; } G_SoldierMakeInfo *info = nullptr; for (unsigned i = 1; ; ++i) { auto tab_item = tab_info->read_table(i); if (tab_item->is_nil()) { break; } int item_id = tab_item->read_integer("itemid", -1); if (item_id < 0) { if (!info) { continue; } } else { const G_ItemInfo *item_info = G_ItemMgr::instance()->get_info(item_id); if (!item_info) { log_error("unknown item id '%d'.", item_id); return false; } info = probe_info(item_id); if (info->_use_item) { log_error("dup item id '%d'.", item_id); return false; } info->_use_item = item_info; info->_use_count = tab_item->read_integer("itemnumber", 0); if (!info->_use_count) { log_error("bad use item count."); return false; } } int soldier_id = tab_item->read_integer("heroid", -1); if (soldier_id < 0) { continue; } const G_SoldierInfo *soldier_info = G_SoldierMgr::instance()->get_info(soldier_id); if (!soldier_info) { log_error("unknown soldier id '%d'.", soldier_id); return false; } info->_soldiers.push_back(soldier_info); } return true; }
vector<vector<double>> adm_log_odds_rc(const string& filename, const vector<double> &bg, double pseudocount, size_t a){ vector<vector<double>> adm = read_table(filename); vector<vector<double>> mat; for (size_t i = 0; i < a * a; ++i){ mat.push_back(adm[i]); } vector<vector<double>> zero_terms (1, vector<double>(a, 0)); for (size_t i = 0; i < a; ++i){ zero_terms[0][i] = adm[a * a + i][0]; } return tools::log_odds_rc(mat, zero_terms, bg, pseudocount, a); }
int main(int argc, char **argv) { if(argc < 2) { printf("Usage: %s [filename]\n", argv[0]); return EXIT_FAILURE; } srand(time(NULL)); char *filename = argv[1]; table *data = read_table(filename); run_simulation(data); return EXIT_SUCCESS; }
/* If force is true then ignore the timestamps */ void mount_update(gboolean force) { #ifdef DO_MOUNT_POINTS time_t time; time = read_time(THE_FSTAB); if (force || time != fstab_time) { fstab_time = time; read_table(); } #endif /* DO_MOUNT_POINTS */ }
int main(int argc, char ** argv) { if (argc != 4) fail ("too few arguments to makeucn"); read_ucnid (argv[1]); read_table (argv[2]); read_derived (argv[3]); write_copyright (); write_table (); return 0; }
/* * Reads headers from a buffer and returns an array of headers. * Returns NULL on file error * This routine tries to deal with too long lines and continuation lines. * @@@: XXX: FIXME: currently the headers are passed thru un-merged. * Is that okay, or should they be collapsed where possible? */ static apr_status_t recall_headers(cache_handle_t *h, request_rec *r) { disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj; /* This case should not happen... */ if (!dobj->hfd) { /* XXX log message */ return APR_NOTFOUND; } h->req_hdrs = apr_table_make(r->pool, 20); h->resp_hdrs = apr_table_make(r->pool, 20); /* Call routine to read the header lines/status line */ read_table(h, r, h->resp_hdrs, dobj->hfd); read_table(h, r, h->req_hdrs, dobj->hfd); apr_file_close(dobj->hfd); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "disk_cache: Recalled headers for URL %s", dobj->name); return APR_SUCCESS; }
int main(int argc, string argv[]) { real mass_scale; initparam(argv, defv); nmax = getiparam("nmax"); radius_tab = (double *) allocate(nmax * sizeof(double)); density_tab = (double *) allocate(nmax * sizeof(double)); mass_tab = (double *) allocate(nmax * sizeof(double)); read_table(getparam("in"), getbparam("smooth")); integ_mass(getbparam("smooth")); fit_params(); mass_scale = (strnull(getparam("mtot")) ? 1 : getdparam("mtot") / mtot); if (!strnull(getparam("out"))) write_gsp(getparam("out"), mass_scale); return (0); }
// --------------------------------------------------------- // Get the default hero for a given biography id // --------------------------------------------------------- t_default_hero get_default_hero( int biography_id ) { read_table(); assert( biography_id >= 0 && biography_id < (int)g_default_heroes.size() ); t_hero_biography const & hero = g_default_heroes[ biography_id ]; t_default_hero result; result.biography = hero.biography; result.biography_id = biography_id; result.hero_class = hero.hero_class; result.is_male = hero.is_male; result.name = hero.name; result.portrait_id = hero.portrait_id; return result; }
int main(object me, string arg) { int i,a; b=0; c=0; if (arg != "yesiknow") return notify_fail("╟ы╘─╢┴░я╓·гм┤╦├№┴ю╙╨╞╞╗╡╨╘бг\n"); seteuid(getuid()); files=read_table("change.txt"); write("\n"); for (i=0; i<sizeof(files); i++) analysis(files[i]); write(HIY+(b+c)+HIC"╕Ў╡╡░╕▒╗╖в╧╓гм"HIY+b+HIC"╕Ў╡╡░╕┤ж└э│╔╣жгм"HIY+c+HIC"╕Ў╡╡░╕┤ж└э╩з░▄бг\n"NOR); write("Ok.\n"); return 1; }
// --------------------------------------------------------- // object to record which portraits have been used // --------------------------------------------------------- t_default_hero_list::t_default_hero_list() { read_table(); int portrait_count = 0; t_hero_biography const* bio; int i; // find the minimum # of times a portrait has been used for ( i = 0; i < (int)g_default_heroes.size(); i++) { bio = &g_default_heroes[i]; if (bio->portrait_id > portrait_count) portrait_count = bio->portrait_id; } m_portrait_count.insert( m_portrait_count.end(), portrait_count + 1, 0 ); m_biography_count.insert( m_biography_count.end(), g_default_heroes.size(), 0 ); }
bool read_pat(char *demux, unsigned int timeout, unsigned char *out) { /* is it in the cache */ if(cache_load("pat", out)) return true; /* read it from the DVB card */ if(!read_table(demux, PID_PAT, TID_PAT, timeout, out, 0)) { error("Unable to read PAT"); return false; } /* cache it */ cache_save("pat", out); return true; }
int main (int argc, char *argv[]) { boolean debug = FALSE; program_name = argv[0]; if (argc == 2 && strcmp(argv[1], "-phase") == 0) { table_for_phase = TRUE; } read_table(); fill_option_info(); if (debug) dump_option_info(); /* create files from info */ write_option_names(); write_init_options(); write_get_option(); write_opt_action(); write_implicits(); return(error_status); }
int main(int argc, char *argv[]){ TABLE *table = create_table(); read_table(stdin, table); // print_table(table); PIECE_LIST *list = create_piece_list(table); QUEUE *queue = create_queue(); list_moves(table, queue, list); print_queue(queue); //printf("-----------------------------------------------------\n"); // print_table(table); delete_queue(&queue); delete_list(&list); //printf("-----------------------------------------------------\n"); // print_table(table); delete_table(&table); return 0; }
/* void displaypath(int source,int dest){ stack<int> shortpath; int temp = dest; while(temp != source){ shortpath.push(temp); temp = path[source][temp]; } shortpath.push(source); cout<<"short distance:"<<weight[source][dest]<<endl<<"path:"; while(!shortpath.empty()){ cout<<shortpath.top()<<" "; shortpath.pop(); } } */ bool G_Map::init_side() { auto tab_info = the_app->script()->read_table("the_side_info"); if (tab_info->is_nil()) { return false; } for (unsigned i = 1; ; ++i) { auto tab_item = tab_info->read_table(i); if (tab_item->is_nil()) { break; } unsigned id = tab_item->read_integer("id", 0); id--; if (id > G_SIDE_UNKNOWN) { log_error("unknown side '%d'.", id + 1); return false; } G_MapSide *side = _sides[id]; unsigned capital_id = tab_item->read_integer("capital", 0); unsigned revive_id = tab_item->read_integer("reborn", 0); if (id < G_SIDE_OTHER) { side->_capital = get_city(capital_id); if (!side->_capital) { log_error("unknown capital city '%d'.", capital_id); return false; } side->_revive = get_city(revive_id); if (!side->_revive) { log_error("unknown revive city '%d'.", revive_id); return false; } } side->_aborigine_defender_num = tab_item->read_integer("defarmy1", 0); side->_occupy_defender_num = tab_item->read_integer("defarmy2", 0); } return true; }
int main(int argc, char **argv) { int linenb; char *file; t_env e; if (argc == 4) { file = ft_strdup(argv[1]); linenb = read_linenb(file); /*ft_putstr("so, our file is containing "); ft_putnbr(linenb); ft_putendl(" lines, now we can create an int table which contain the z values for each cases.");*/ e.zval = (int **)malloc(sizeof(int *) * (linenb + 1)); e.nbcases = (int *)malloc(sizeof(int) * linenb); e.zval[linenb + 1] = NULL; e.zval = read_table(file, e.zval, &e.nbcases); e.res[0] = ft_atoi(argv[2]); e.res[1] = ft_atoi(argv[3]); /*ft_putendl("we calculate "); ft_putstr("e.res : "); ft_putnbr(((int)e.res[0])); ft_putchar('\n'); ft_putstr("e.nbcases : "); ft_putnbr(e.nbcases[0]); ft_putchar('\n');*/ e.taille = ((int)e.res[0] / 1.15) / (e.nbcases[0] * 0.95); e.x = e.res[0] / 10; e.y = e.res[1] / 10; //ft_putendl("terminated"); free(file); //ft_putendl("free done."); ft_win(e.res[0], e.res[1], &e); } else ft_putendl("You have to put in first argument the file name, in second argument the x value of the resolution you want and in third argument the y value of the resolution you want !"); return (0); }
void mount_init(void) { fstab_mounts = g_hash_table_new(g_str_hash, g_str_equal); user_mounts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); #ifdef DO_MOUNT_POINTS if(file_exists(THE_FSTAB)) { fstab_time = read_time(THE_FSTAB); } else { fstab_time = 0; #if defined(HAVE_MNTENT_H) || defined(HAVE_SYS_MNTENT_H) /* We need THE_FSTAB for these implementations, but * it is missing */ g_warning(_("File system table \"%s\" not found, cannot monitor system mounts"), THE_FSTAB); #endif } read_table(); #endif }
bool read_sdt(char *demux, unsigned int timeout, unsigned char *out, unsigned char sn) { char cache_item[PATH_MAX]; snprintf(cache_item, sizeof(cache_item), "sdt-%u", sn); /* is it in the cache */ if(cache_load(cache_item, out)) return true; /* read it from the DVB card */ if(!read_table(demux, PID_SDT, TID_SDT, timeout, out, sn)) { error("Unable to read SDT"); return false; } /* cache it */ cache_save(cache_item, out); return true; }
bool G_SoldierMgr::init() { auto tab_info = the_app->script()->read_table("the_soldier_info"); if (tab_info->is_nil()) { return false; } for (unsigned i = 1; ; ++i) { auto tab_item = tab_info->read_table(i); if (tab_item->is_nil()) { break; } int id = tab_item->read_integer("id", -1); if (id < 0) { continue; } int type2 = tab_item->read_integer("type2", 0); if (type2 != G_TYPE_HERO && type2 != G_TYPE_SOLDIER) { log_error("unknown soldier type '%d'.", type2); } G_SoldierInfo *info = probe_info(id); info->_is_hero = (type2 == G_TYPE_HERO); info->_quality = tab_item->read_integer("qua", 0); info->_star = tab_item->read_integer("star", 0); info->_hp = tab_item->read_integer("hp", 0); info->_attack = tab_item->read_integer("att", 0); info->_attack_speed = tab_item->read_integer("as", 0); info->_hp_param = tab_item->read_integer("hpup", 0); info->_attack_param = tab_item->read_integer("attup", 0); info->_people = tab_item->read_integer("peo", 0); if (!info->_is_hero && !info->_people) { log_error("bad soldier people."); return false; } } return true; }
DR_EXPORT void dr_init(client_id_t id) { dr_set_client_name("DynamoRIO Sample Client 'MF_moduledb'", "http://dynamorio.org/issues"); VDISPLAY_FUNC(NAME" initializing."); /* register the events we wish to handle */ dr_register_security_event(event_security_violation); dr_register_nudge_event(event_nudge, id); dr_register_exit_event(event_exit); /* read the client options */ table_def_file_name = dr_get_options(id); if (table_def_file_name == NULL || table_def_file_name[0] == '\0') { DISPLAY_FUNC(NAME" requires the table name as parameter\n"); dr_abort(); } /* initialize structures */ table_lock = dr_mutex_create(); read_table(); }
static int read_header(AVFormatContext *s) { PAFDemuxContext *p = s->priv_data; AVIOContext *pb = s->pb; AVStream *ast, *vst; int ret = 0; avio_skip(pb, 132); vst = avformat_new_stream(s, 0); if (!vst) return AVERROR(ENOMEM); vst->start_time = 0; vst->nb_frames = vst->duration = p->nb_frames = avio_rl32(pb); avio_skip(pb, 4); vst->codec->width = avio_rl32(pb); vst->codec->height = avio_rl32(pb); avio_skip(pb, 4); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = 0; vst->codec->codec_id = AV_CODEC_ID_PAF_VIDEO; avpriv_set_pts_info(vst, 64, 1, 10); ast = avformat_new_stream(s, 0); if (!ast) return AVERROR(ENOMEM); ast->start_time = 0; ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = 0; ast->codec->codec_id = AV_CODEC_ID_PAF_AUDIO; ast->codec->channels = 2; ast->codec->channel_layout = AV_CH_LAYOUT_STEREO; ast->codec->sample_rate = 22050; avpriv_set_pts_info(ast, 64, 1, 22050); p->buffer_size = avio_rl32(pb); p->preload_count = avio_rl32(pb); p->frame_blks = avio_rl32(pb); p->start_offset = avio_rl32(pb); p->max_video_blks = avio_rl32(pb); p->max_audio_blks = avio_rl32(pb); if (p->buffer_size < 175 || p->max_audio_blks < 2 || p->max_video_blks < 1 || p->frame_blks < 1 || p->nb_frames < 1 || p->preload_count < 1 || p->buffer_size > 2048 || p->max_video_blks > 2048 || p->max_audio_blks > 2048 || p->nb_frames > INT_MAX / sizeof(uint32_t) || p->frame_blks > INT_MAX / sizeof(uint32_t)) return AVERROR_INVALIDDATA; p->blocks_count_table = av_mallocz(p->nb_frames * sizeof(*p->blocks_count_table)); p->frames_offset_table = av_mallocz(p->nb_frames * sizeof(*p->frames_offset_table)); p->blocks_offset_table = av_mallocz(p->frame_blks * sizeof(*p->blocks_offset_table)); p->video_size = p->max_video_blks * p->buffer_size; p->video_frame = av_mallocz(p->video_size); p->audio_size = p->max_audio_blks * p->buffer_size; p->audio_frame = av_mallocz(p->audio_size); p->temp_audio_frame = av_mallocz(p->audio_size); if (!p->blocks_count_table || !p->frames_offset_table || !p->blocks_offset_table || !p->video_frame || !p->audio_frame || !p->temp_audio_frame) { ret = AVERROR(ENOMEM); goto fail; } avio_seek(pb, p->buffer_size, SEEK_SET); read_table(s, p->blocks_count_table, p->nb_frames); read_table(s, p->frames_offset_table, p->nb_frames); read_table(s, p->blocks_offset_table, p->frame_blks); p->got_audio = 0; p->current_frame = 0; p->current_frame_block = 0; avio_seek(pb, p->start_offset, SEEK_SET); return 0; fail: read_close(s); return ret; }