static void call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass) { const char *srcfile = rb_sourcefile(); VALUE eventname = rb_str_new2(get_event_name(event)); VALUE filename = srcfile ? rb_str_new2(srcfile) : Qnil; VALUE argv[6]; int line = rb_sourceline(); rb_thread_t *th = GET_THREAD(); if (!klass) { rb_thread_method_id_and_class(th, &id, &klass); } if (klass) { if (RB_TYPE_P(klass, T_ICLASS)) { klass = RBASIC(klass)->klass; } else if (FL_TEST(klass, FL_SINGLETON)) { klass = rb_iv_get(klass, "__attached__"); } } argv[0] = eventname; argv[1] = filename; argv[2] = INT2FIX(line); argv[3] = id ? ID2SYM(id) : Qnil; argv[4] = (self && srcfile) ? rb_binding_new() : Qnil; argv[5] = klass ? klass : Qnil; rb_proc_call_with_block(proc, 6, argv, Qnil); }
static void debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE klass) { #ifdef PRINT_EVENTS char *file = (char*)rb_sourcefile(); int line = rb_sourceline(); fprintf(stderr, "%s:%d [%s] %s\n", file, line, get_event_name(event), rb_id2name(mid)); #endif }
/*Read in the data files ready for use*/ void read_files() { e_name = get_event_name("//Users//XeTK//Desktop//CassignmentTXT//name.txt"); e_nodes = get_event_nodes("//Users//XeTK//Desktop//CassignmentTXT//nodes.txt"); e_tracks = get_event_tracks("//Users//XeTK//Desktop//CassignmentTXT//tracks.txt"); e_courses = get_event_courses("//Users//XeTK//Desktop//CassignmentTXT//courses.txt"); e_entrants = get_event_entrants("//Users//XeTK//Desktop//CassignmentTXT//entrants.txt"); e_times = get_event_times("//Users//XeTK//Desktop//CassignmentTXT//cp_times_2.txt"); /*Index are competitors to make it easier to carry out operations on them later*/ c_competitors = noderized(e_times,e_entrants,e_courses,e_nodes); }
//-------------------------------------------------------------------------- char *debmod_t::debug_event_str(const debug_event_t *ev, char *buf, size_t bufsize) { char *ptr = buf; char *end = buf + bufsize; ptr += qsnprintf(ptr, end-ptr, "%s ea=%a", get_event_name(ev->eid), ev->ea); switch ( ev->eid ) { case PROCESS_START: // New process started case PROCESS_ATTACH: // Attached to running process case LIBRARY_LOAD: // New library loaded ptr += qsnprintf(ptr, end-ptr, " base=%a size=%a rebase=%a name=%s", ev->modinfo.base, ev->modinfo.size, ev->modinfo.rebase_to, ev->modinfo.name); break; case PROCESS_EXIT: // Process stopped case THREAD_EXIT: // Thread stopped ptr += qsnprintf(ptr, end-ptr, " exit_code=%d", ev->exit_code); break; case BREAKPOINT: // Breakpoint reached ptr += qsnprintf(ptr, end-ptr, " hea=%a kea=%a", ev->bpt.hea, ev->bpt.kea); break; case EXCEPTION: // Exception ptr += qsnprintf(ptr, end-ptr, " code=%x can_cont=%d ea=%a info=%s", ev->exc.code, ev->exc.can_cont, ev->exc.ea, ev->exc.info); break; case LIBRARY_UNLOAD: // Library unloaded case INFORMATION: // User-defined information APPCHAR(ptr, end, ' '); APPEND(ptr, end, ev->info); break; default: break; } qsnprintf(ptr, end-ptr, " pid=%d tid=%d handled=%d", ev->pid, ev->tid, ev->handled); return buf; }
/*! Returns the last complete cup for the specified event \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ list_elem_t get_last_complete_cup_for_event( event_data_t *event_data ) { char *last_cup; list_elem_t cup; if ( get_last_completed_cup( g_game.player[local_player()].name, get_event_name( event_data ), g_game.difficulty, &last_cup ) ) { cup = get_event_cup_by_name( event_data, last_cup ); if ( cup == NULL ) { print_warning( IMPORTANT_WARNING, "Couldn't find saved cup `%s'", last_cup ); } return cup; } else { return NULL; } }
static void continue_click_cb( button_t *button, void *userdata ) { cup_data_t *cup_data; player_data_t *plyr = get_player_data( local_player() ); check_assertion( userdata == NULL, "userdata is not null" ); cur_event = listbox_get_current_item( event_listbox ); event_data = (event_data_t*) get_list_elem_data( cur_event ); cur_cup = listbox_get_current_item( cup_listbox ); cup_data = (cup_data_t*) get_list_elem_data( cur_cup ); g_game.current_event = get_event_name( event_data ); g_game.current_cup = get_cup_name( cup_data ); plyr->lives = INIT_NUM_LIVES; set_game_mode( RACE_SELECT ); ui_set_dirty(); }
static void test_event(int fd) { struct input_event ev[64]; int rd, i; printf ("Testing events. Please, press CTRL-C to abort.\n"); while (1) { rd = read(fd, ev, sizeof(ev)); if (rd < (int) sizeof(struct input_event)) { perror("Error reading event"); return; } for (i = 0; i < rd / sizeof(struct input_event); i++) { printf("%ld.%06ld: event type %s(0x%02x)", ev[i].time.tv_sec, ev[i].time.tv_usec, get_event_name(events_type, ev[i].type), ev[i].type); switch (ev[i].type) { case EV_SYN: printf(".\n"); break; case EV_KEY: printf(" key_%s: %s(0x%04x)\n", (ev[i].value == 0) ? "up" : "down", get_event_name(key_events, ev[i].code), ev[i].type); break; case EV_REL: printf(": %s (0x%04x) value=%d\n", get_event_name(rel_events, ev[i].code), ev[i].type, ev[i].value); break; case EV_ABS: printf(": %s (0x%04x) value=%d\n", get_event_name(abs_events, ev[i].code), ev[i].type, ev[i].value); break; case EV_MSC: if (ev[i].code == MSC_SCAN) printf(": scancode = 0x%02x\n", ev[i].value); else printf(": code = %s(0x%02x), value = %d\n", get_event_name(msc_events, ev[i].code), ev[i].code, ev[i].value); break; case EV_REP: printf(": value = %d\n", ev[i].value); break; case EV_SW: case EV_LED: case EV_SND: case EV_FF: case EV_PWR: case EV_FF_STATUS: default: printf(": code = 0x%02x, value = %d\n", ev[i].code, ev[i].value); break; } } } }
static char* event_list_elem_to_string_func( list_elem_data_t elem ) { return get_event_name( (event_data_t*) elem ); }
int main( int argc, /* Argument count */ char **argv) /* Argument vector */ { sam_event_t event; event_handler_t ev_handler; if (dbupd_init(argc, argv) < 0) { return (EXIT_FAILURE); } connect: /* Keep trying to connect to database until shutdown or retry limit */ while (num_retry < RETRY_MAX && !is_shutdown && dbupd_connect() < 0) { num_retry++; sleep(RETRY_SLEEP); } /* Keep trying to process events until retry limit or shutdown */ while (num_retry < RETRY_MAX && !is_shutdown) { int status = sam_fsa_read_event(&fsa_inv, &event); if (status < 0) { /* Error reading event for fs_name */ SendCustMsg(HERE, 26003, fs_name); num_retry++; sleep(RETRY_SLEEP); goto connect; } else if (status == FSA_EOF) { /* Reached the end of events, goto sleep for a while */ sleep(EOF_SLEEP); } else if (IS_DB_INODE(event.ev_id.ino) && IS_DB_INODE(event.ev_pid.ino)) { /* Got next event, get event handler and process */ ev_handler = get_event_handler(event.ev_num); if (ev_handler == NULL) { /* Unrecognized event for fsname */ SendCustMsg(HERE, 26006, event.ev_num, fs_name); continue; } /* Handle event */ if (ev_handler(db_ctx, &event) < 0) { mysql_rollback(db_ctx->mysql); /* Event processing failed, running check */ SendCustMsg(HERE, 26007, get_event_name(event.ev_num), event.ev_id.ino, event.ev_id.gen, fs_name); if (check_consistency(db_ctx, &event, TRUE) < 0) { mysql_rollback(db_ctx->mysql); sam_fsa_rollback(&fsa_inv); /* Consistency check failed, retrying */ SendCustMsg(HERE, 26008); num_retry++; goto connect; } else { mysql_commit(db_ctx->mysql); } } else { mysql_commit(db_ctx->mysql); } num_retry = 0; } else { /* * Event's inode doesn't belong in database, * run consistency to be sure. */ (void) check_consistency(db_ctx, &event, TRUE); } } /* Close event log */ sam_fsa_close_inv(&fsa_inv); /* Close database */ sam_db_disconnect(db_ctx); sam_db_context_free(db_ctx); if (num_retry >= RETRY_MAX) { /* Retry max reached, exiting */ SendCustMsg(HERE, 26005, RETRY_MAX); } return (is_shutdown && num_retry < RETRY_MAX ? EXIT_SUCCESS : EXIT_FAILURE); }