/* * pool_hdr_preliminary_check -- (internal) check pool header checksum and pool * parameters */ static int pool_hdr_preliminary_check(PMEMpoolcheck *ppc, location *loc) { LOG(3, NULL); CHECK_INFO(ppc, "%schecking pool header", loc->prefix); if (util_is_zeroed((void *)&loc->hdr, sizeof(loc->hdr))) { if (CHECK_IS_NOT(ppc, REPAIR)) { check_end(ppc->data); ppc->result = CHECK_RESULT_NOT_CONSISTENT; return CHECK_ERR(ppc, "%sempty pool hdr", loc->prefix); } } else if (loc->hdr_valid) { enum pool_type type = pool_hdr_get_type(&loc->hdr); if (type == POOL_TYPE_UNKNOWN) { if (CHECK_IS_NOT(ppc, REPAIR)) { check_end(ppc->data); ppc->result = CHECK_RESULT_NOT_CONSISTENT; return CHECK_ERR(ppc, "%sinvalid signature", loc->prefix); } CHECK_INFO(ppc, "%sinvalid signature", loc->prefix); } else { /* valid check sum */ CHECK_INFO(ppc, "%spool header correct", loc->prefix); loc->step = CHECK_STEP_COMPLETE; return 0; } } else if (CHECK_IS_NOT(ppc, REPAIR)) { check_end(ppc->data); ppc->result = CHECK_RESULT_NOT_CONSISTENT; return CHECK_ERR(ppc, "%sincorrect pool header", loc->prefix); } else { CHECK_INFO(ppc, "%sincorrect pool header", loc->prefix); } ASSERT(CHECK_IS(ppc, REPAIR)); if (ppc->pool->params.type == POOL_TYPE_UNKNOWN) { ppc->pool->params.type = pool_hdr_possible_type(ppc); if (ppc->pool->params.type == POOL_TYPE_UNKNOWN) { ppc->result = CHECK_RESULT_CANNOT_REPAIR; return CHECK_ERR(ppc, "cannot determine pool type"); } } if (!pool_supported(ppc->pool->params.type)) { ppc->result = CHECK_RESULT_CANNOT_REPAIR; return CHECK_ERR(ppc, "the repair of %s pools is not supported", pool_get_pool_type_str(ppc->pool->params.type)); } return 0; }
bool loop_check(long read_size) { if (loop_) { if (check_end(read_size)) { set_loop_start(); } } else { if (check_end(read_size)) { end_ = true; return true; } } return false; }
int epur_fct(char *str, t_epur *e) { while (str[e->i] == ' ' && str[e->i] != '\0') e->i++; while (str[e->i] != '\0') { while ((str[e->i] == ' ' && str[e->i + 1] == ' ') || (str[e->i] == '\t' && str[e->i + 1] == '\t')) e->i++; if ((e->tmp = epur_single(str, e)) != NULL) { e->tmp[e->k] = str[e->i]; e->k++; e->i++; } else return (-1); e->tmp[e->k] = '\0'; } e->tmp = check_end(str, e); if (check_start(e->tmp) == -1 || epur_end(str) == -1) return (-1); else return (1); }
char kongjumpright(char **map, char c, t_pict *pict) { int x, y; char sauv = c; x = 0; y = 0; while (map[x][y] != 'i' && map[x][y] != 'j') { if (map[x][y] == '\n') { y = 0; x++; } y++; } if (map[x - 1][y] != 'w' || map[x -1][y] == 'k') sauv = kongjumpright_2(x, y, c, map, pict); if (sauv == 'o' && (check_end(map) == 1)) donkey_win(pict->win); fall(map, pict); if (sauv == 'n' || sauv == 'm' || sauv == 'k') { if (c != 's') sauv = '.'; } return (sauv); }
void draw(t_env *e) { t_vect2i p; t_vect2i s; s = set_vect2i((COLS - 1) / 4, (LINES - 1) / 4 - 1); draw_ui(ft_itoa(e->score), s); p.y = -1; check_end(e->score, e->map); while (++p.y <= (s.y * 4) + 1) { p.x = -1; while (++p.x <= (s.x * 4)) { if (p.x < (s.x * 4) && (p.y % (s.y) == 0 || p.y == (s.y * 4))) { while (p.x < (s.x * 4)) mvprintw(p.y + 3, p.x, ((p.x++) % (s.x) == 0) ? "+" : "-"); mvprintw(p.y + 3, p.x, "+"); } else if (p.y < (s.y * 4) && (p.x % (s.x) == 0 || p.x == (s.x * 4))) mvprintw(p.y + 3, p.x, "|"); } } draw_numbers(e->map, s); }
blargg_err_t Vgm_Emu::run_clocks( blip_time_t& time_io, int msec ) { check_end(); time_io = core.run_psg( msec ); check_warning(); return (blargg_err_t)blargg_ok; }
static int exec_key(t_env *env, int key) { int ret_move; int ret_end; if (key == 27) return (1); else if (key == KEY_UP || key == KEY_LEFT || key == KEY_RIGHT || key == KEY_DOWN) { ret_move = move_plate(env, key); if (ret_move != -1) { env->score += ret_move; pop_new(env->plate, env->size); } ret_end = check_end(env); if (ret_end == -1) return (1); } else if (key == 'u' && env->undo-- > 0) dup_plate(env->plate, env->last_plate, env->size); else if (key == KEY_F(1)) save_plate(env); else if (env->ascii.ascii_on && key >= '1' && key <= MAX_ASCII + '0') load_ascii(env, key - '0'); return (0); }
inline int Vgm_Emu::play_frame( blip_time_t blip_time, int sample_count, sample_t buf [] ) { check_end(); int result = core.play_frame( blip_time, sample_count, buf ); check_warning(); return result; }
/* * sds_check -- (internal) check shutdown_state */ static int sds_check(PMEMpoolcheck *ppc, location *loc) { LOG(3, NULL); CHECK_INFO(ppc, "%s" SDS_CHECK_STR, loc->prefix); /* shutdown state is valid */ if (!sds_check_replica(loc)) { CHECK_INFO(ppc, "%s" SDS_OK_STR, loc->prefix); loc->step = CHECK_STEP_COMPLETE; return 0; } /* shutdown state is NOT valid and can NOT be repaired */ if (CHECK_IS_NOT(ppc, REPAIR)) { check_end(ppc->data); ppc->result = CHECK_RESULT_NOT_CONSISTENT; return CHECK_ERR(ppc, "%s%s", loc->prefix, SDS_FAIL_MSG(&loc->hdr)); } /* shutdown state is NOT valid but can be repaired */ CHECK_ASK(ppc, Q_RESET_SDS, "%s%s", loc->prefix, SDS_REPAIR_MSG(&loc->hdr)); return check_questions_sequence_validate(ppc); }
/*! \brief Choose an action * \author Josh Bolduc * \date Created ???????? * \date Updated * * Choose a fighter action. */ static void do_action (int dude) { int index; for (index = 0; index < 2; index++) if (fighter[dude].imb[index] > 0) cast_imbued_spell (dude, fighter[dude].imb[index], 1, TGT_CASTER); if (fighter[dude].sts[S_MALISON] > 0) { if ((rand () % 100) < fighter[dude].sts[S_MALISON] * 5) cact[dude] = 0; } if (fighter[dude].sts[S_CHARM] > 0) { fighter[dude].sts[S_CHARM]--; if (dude < PSIZE) auto_herochooseact (dude); else enemy_charmaction (dude); } if (cact[dude] != 0) { revert_cframes (dude, 0); if (dude < PSIZE) { if (fighter[dude].sts[S_CHARM] == 0) hero_choose_action (dude); } else enemy_chooseaction (dude); } cact[dude] = 0; if (check_end () == 1) combatend = 1; }
void ram(void) { while(1) { if (!screen_intro()){ setTextColor(0xff,0x00); return; } game.rokets = 3; game.level = 1; game.score = 0; init_game(); screen_level(); while (game.rokets>=0) { ////checkISP(); lcdFill(0x00); check_end(); move_ufo(); move_shot(); move_shots(); move_player(); move_enemy(); draw_score(); draw_ufo(); draw_bunker(); draw_player(); draw_enemy(); draw_shots(); // draw_status(); lcdDisplay(); delayms(12); } if (!screen_gameover()) setTextColor(0xff,0x00); return; } }
static int move(t_server *server) { double diff; diff = (double)SPEED * (double)TIMEOUT; diff /= (double)1000000; server->players->x += diff; server->players->next->x += diff; move_vertical(server, server->players); move_vertical(server, server->players->next); check_coin(server, server->players, server->players->x, server->players->y); check_coin(server, server->players, server->players->x + 0.99, server->players->y); check_coin(server, server->players, server->players->x, server->players->y + 0.99); check_coin(server, server->players, server->players->x + 0.99, server->players->y + 0.99); check_coin(server, server->players->next, server->players->next->x, server->players->next->y); check_coin(server, server->players->next, server->players->next->x + 0.99, server->players->next->y); check_coin(server, server->players->next, server->players->next->x, server->players->next->y + 0.99); check_coin(server, server->players->next, server->players->next->x + 0.99, server->players->next->y + 0.99); return (check_end(server)); }
static inline void apply(std::string const& wkt, MultiGeometry& geometry) { traits::clear<MultiGeometry>::apply(geometry); tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); tokenizer::iterator it; if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it)) { handle_open_parenthesis(it, tokens.end(), wkt); // Parse sub-geometries while(it != tokens.end() && *it != ")") { traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1); Parser < typename boost::range_value<MultiGeometry>::type >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); if (it != tokens.end() && *it == ",") { // Skip "," after multi-element is parsed ++it; } } handle_close_parenthesis(it, tokens.end(), wkt); } check_end(it, tokens.end(), wkt); }
inline void increment() { if (this->base() != m_end) { (this->base_reference())++; check_end(); } }
int main(int argv, char** argc) { check_init(); check_start("clib -- libdatrie -- trie"); test_trie_tree_states(); test_datrie_states(); test_datrie(); check_end(); check_close(); return 0; }
// warning! geometry must be empty! static inline void apply(std::string const& wkt, Geometry& geometry) { typedef boost::tokenizer<boost::char_separator<char> > tokenizer; tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); tokenizer::iterator it = tokens.begin(); tokenizer::iterator end = tokens.end(); Parser<Geometry>::apply(it, end, wkt, geometry); check_end(it, end, wkt); }
form * sendanswer_1_svc(form *argp, struct svc_req *rqstp) { static form result; if(current_user == manager) //se processo corrente e o coordenador recebendo respostas { printf("Coordenador recebeu respostas de %s\n", argp->attr.address); if(find_by_address(argp->attr) >= 0) { printf("1\n"); int index = find_by_address(argp->attr); printf("2\n"); int formsize = sizeof(form); printf("3\n"); memcpy(&answer[index], argp, formsize); printf("4\n"); count_answer[index] = 1; printf("5\n"); check_end(); printf("6\n"); } } else //se processo corrente recebe resposta do cliente, a envia para o coordenador { questions_answered++; printf("Cliente enviando respostas ao coordenador\n"); memcpy(&answer[current_user],argp,sizeof(form)); CLIENT *clnt; form *result_4; form sendanswer_1_arg; memcpy(&sendanswer_1_arg, &answer[current_user], sizeof(form)); char *host = list[manager].ip; printf("host: %s usuario numero: %d\n",host,manager); clnt = clnt_create (host, PROGJOGO, VERJOGO, "udp"); if (clnt == NULL) { reset = 1; } strcpy(sendanswer_1_arg.attr.address, list[current_user].ip); result_4 = sendanswer_1(&sendanswer_1_arg, clnt); if (result_4 == (form *) NULL) { reset = 1; } //manda pro grandao //falta tratamento caso o coordenador esteja morto } return &result; }
void aff_promt(t_prog_base *base) { aff_message(base, 1); if ((base->nb_deleted[base->line - 1] += base->matches) == base->matches_per_lines[base->line - 1]) base->is_empty[base->line - 1] = 1; print_screen(base); check_end(base, 1); if (base->is_ended == 1) return ; my_putstr("\nIA's turn...\n", 1); my_ia(base); aff_message(base, 2); if ((base->nb_deleted[base->line - 1] += base->matches) == base->matches_per_lines[base->line - 1]) base->is_empty[base->line - 1] = 1; print_screen(base); check_end(base, 2); if (base->is_ended == 1) return ; my_putstr("\nYour turn:", 1); }
infoperson * nicetomeetyou_1_svc(infoperson *argp, struct svc_req *rqstp) { static infoperson result; if(argp->attr.booleanVar != 1) { printf("Verificando se hosts estao vivos\n"); CLIENT *clnt; infoperson *result_5; infoperson nicetomeetyou_1_arg; char *host; int i; nicetomeetyou_1_arg.attr.booleanVar = 1; for(i=0;i<10;i++) { if(current_user != i) { host = list[i].ip; clnt = clnt_create (host, PROGJOGO, VERJOGO, "udp"); if (clnt == NULL) { printf("Host %s nao esta respondendo\n",host); list[i].keepAlive = 0; check_end(); } result_5 = nicetomeetyou_1(&nicetomeetyou_1_arg, clnt); if (result_5 == (infoperson *) NULL) { printf("Host %s nao esta respondendo\n",host); list[i].keepAlive = 0; check_end(); } } } } return &result; }
void my_ls3(int ac, char **av, int i, int *tab) { int r; ac = ac + i - 1; my_ls31(ac, av, i); while (i < ac) { r = my_ls32(av, i, tab); if (check_end(ac, (i + 1), av) == 1 && r == 0) my_printf("\n"); i++; } }
int check_map(char *str, t_infos *infos, t_list **rooms) { if (check_ants(str, infos) == 1) return (1); else if (check_start(str, infos) == 1 && infos->ok != 2) return (1); else if (check_end(str, infos) == 1 && infos->ok != 2) return (1); else if(check_pos(str, rooms, infos) == 1) return (1); else if(check_tubes(str, infos, rooms) == 1) return (1); return (0); }
int check_room(t_lem_env *env, char *s) { if (is_link(s) && env->fonction[env->r.state + 1](env, s)) return (ft_add_state(env)); if (ft_strcmp("##start", s) == 0 && check_start(env, s)) return (1); if (ft_strcmp("##end", s) == 0 && check_end(env, s)) return (1); if (is_room(s) && add_room(env, s)) { env->r.nbline += add_file(env, s); return (1); } return (ft_error(env, 1)); }
int step_two(int *remove_line, int *tab, int tab_size, char *buff) { int nbr; nbr = my_getnbr(buff); if (check_s2(buff, nbr, tab[*remove_line]) == 1) return (1); tab[*remove_line] = tab[*remove_line] - nbr; if (check_end(get_total_matches(tab, tab_size), 0) == -1) return (-1); show_tab(tab, tab_size); if (ia(tab, tab_size, 0) == -1) return (-1); *remove_line = -1; my_putstr("On which line would you want to remove matches ? "); return (0); }
static inline void apply(std::string const& wkt, MultiGeometry& geometry) { traits::clear<MultiGeometry>::apply(geometry); tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); tokenizer::iterator it; if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it)) { handle_open_parenthesis(it, tokens.end(), wkt); // If first point definition starts with "(" then parse points as (x y) // otherwise as "x y" bool using_brackets = (it != tokens.end() && *it == "("); while(it != tokens.end() && *it != ")") { traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1); if (using_brackets) { point_parser < typename boost::range_value<MultiGeometry>::type >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); } else { noparenthesis_point_parser < typename boost::range_value<MultiGeometry>::type >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); } if (it != tokens.end() && *it == ",") { // Skip "," after point is parsed ++it; } } handle_close_parenthesis(it, tokens.end(), wkt); } check_end(it, tokens.end(), wkt); }
void ia_vs_ia(t_prog_base *base) { int i; while (42) { my_putstr("IA's turn...\n", 1); my_ia(base); aff_message(base, 2); if ((base->nb_deleted[base->line - 1] += base->matches) == base->matches_per_lines[base->line - 1]) base->is_empty[base->line - 1] = 1; print_screen(base); check_end(base, 3); if (base->is_ended == 1) return ; i = 0; while (i++ < 100000000); } }
time_t parse_time(char *time_str, int use_american_date_formats) { struct tm tm; char **date_formats; memset(&tm, 0, sizeof (tm)); tm.tm_isdst = -1; for (date_formats = (use_american_date_formats ? american_date_formats : european_date_formats); *date_formats; date_formats++) { if (check_end((const char *)strptime(time_str, *date_formats, &tm))) return mktime_from_utc(&tm); } return -1; }
time_t http_atotm(const char *time_string) { /* NOTE: Solaris strptime man page claims that %n and %t match white space, but that's not universally available. Instead, we simply use ` ' to mean "skip all WS", which works under all strptime implementations I've tested. */ static const char *time_formats[] = { "%a, %d %b %Y %T", /* rfc1123: Thu, 29 Jan 1998 22:12:57 */ "%A, %d-%b-%y %T", /* rfc850: Thursday, 29-Jan-98 22:12:57 */ "%a %b %d %T %Y", /* asctime: Thu Jan 29 22:12:57 1998 */ "%a, %d-%b-%Y %T" /* cookies: Thu, 29-Jan-1998 22:12:57 (used in Set-Cookie, defined in the Netscape cookie specification.) */ }; int i; for (i = 0; i < countof(time_formats); i++) { struct tm t; /* Some versions of strptime use the existing contents of struct tm to recalculate the date according to format. Zero it out to prevent garbage from the stack influencing strptime. */ memset(&t,0,sizeof(t)); /* Solaris strptime fails to recognize English month names in non-English locales, which we work around by not setting the LC_TIME category. Another way would be to temporarily set locale to C before invoking strptime, but that's slow and messy. GNU strptime does not have this problem because it recognizes English month names along with the local ones. */ if (check_end(strptime(time_string, time_formats[i], &t))) return timegm(&t); } /* All formats have failed. */ return -1; }
void ft_epur_str(char *s) { int i; i = 0; if (s[0] == '\0') return (ft_putchar('\n')); if (s) while (s[i]) { while (ft_isspace(s[i]) != 0) i++; while (s[i] > 32 && s[i] < 127) { ft_putchar(s[i]); i++; } if (check_end(s, i) == 1) return (ft_putchar('\n')); else ft_putchar(' '); } }
int main(int ac, char **av) { t_env e; struct timeval t; get_opt(ac, av, &e.opt); init_game(&e); init_connection(&e); while (1) { t.tv_sec = 0; t.tv_usec = 0; FD_ZERO(&e.fd_read); FD_ZERO(&e.fd_write); e.max = 0; fd_iter_all(&e, fd_watch); e.res = select(e.max + 1, &e.fd_read, &e.fd_write, NULL, &t); try_int(e.res, -1, "select"); fd_iter_all(&e, fd_check); bot_iter_all_connected_queued_egg(&e, timer); check_end(&e); } return (EXIT_SUCCESS); }
void game_start(char *board) { int i; char killer; while (check_end(board) == 1) { i = 0; while (board[i] != '\0') { if (board[i] == '1' || board[i] == '2') { if (board[i] == '1') killer = '2'; else killer = '1'; is_dead(board, i, killer); } ++i; } display_board(board); move_player(board); } }