static tfm_char_data_t* find_char_data( tex_font_metrics_t *tfm, char c ) { int i; if ( tfm->char_data[(int)c] != NULL ) { return tfm->char_data[(int)c]; } else if ( isupper(c) && tfm->char_data[ tolower(c) ] != NULL ) { return tfm->char_data[ tolower(c) ]; } else if ( islower(c) && tfm->char_data[ toupper(c) ] != NULL ) { return tfm->char_data[ toupper(c) ]; } else if ( tfm->char_data[ ' ' ] != NULL ) { print_warning( IMPORTANT_WARNING, "Font does not have a representation of " "character `%c'; using space as placeholder", c ); return tfm->char_data[ ' ' ]; } else { for (i=0; i<MAX_TEX_FONT_CHARS; i++) { if ( tfm->char_data[i] != NULL ) { print_warning( IMPORTANT_WARNING, "Font does not have a representation of " "character `%c'; using `%c' as placeholder", c, i ); return tfm->char_data[i]; } } check_assertion( 0, "font contains no characters" ); } /* Shouldn't get here */ return NULL; }
/*! Truncates a player's saved data file \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ static void truncate_and_init_save_file( char *player_name ) { char save_file[BUFF_LEN]; FILE* save_stream; if ( get_save_game_file_name( save_file, player_name, sizeof(save_file) ) == 0 ) { save_stream = fopen( save_file, "w" ); if ( save_stream == NULL ) { print_warning( IMPORTANT_WARNING, "Couldn't open `%s' for writing: %s", save_file, strerror( errno ) ); } else { check_assertion( strlen( SAVE_MAGIC_V1 ) == 4, "Magic number has wrong size" ); fwrite( SAVE_MAGIC_V1, 4, 1, save_stream ); if ( fclose( save_stream ) != 0 ) { print_warning( IMPORTANT_WARNING, "Couldn't close `%s': %s", save_file, strerror( errno ) ); } } } else { print_warning( IMPORTANT_WARNING, "Couldn't get save game file for player `%s'", player_name ); } }
void cb_save (GtkWidget *p_widget, gpointer user_data) { if (docs.actif) { if (!docs.actif->sauve) { /* Le fichier n'a pas encore ete enregistre */ if (!docs.actif->path) { GtkWidget *dialog; dialog = gtk_file_chooser_dialog_new ("Sauvegarder le fichier", NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { docs.actif->path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); } gtk_widget_destroy (dialog); } /* Soit le fichier a deja ete enregistre, soit l'utilisateur vient de nous fournir son nouvel emplacement, on peut donc l'enregistrer */ if (docs.actif->path) { FILE *fichier; fichier = fopen (docs.actif->path, "w"); if (fichier) { gchar *contents; gchar *locale; GtkTextIter start; GtkTextIter end; GtkTextBuffer *text_buffer; text_buffer = gtk_text_view_get_buffer (docs.actif->text_view); gtk_text_buffer_get_bounds (text_buffer, &start, &end); contents = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE); locale = g_locale_from_utf8 (contents, -1, NULL, NULL, NULL); g_free (contents), contents = NULL; fprintf (fichier, "%s", locale); g_free (locale), locale = NULL; fclose (fichier), fichier = NULL; docs.actif->sauve = TRUE; } else print_warning ("Impossible de sauvegarder le fichier %s", docs.actif->path); } } } else print_warning ("Aucun document ouvert"); /* Parametres inutilises */ (void)p_widget; (void)user_data; }
uint8_t get_data_request(FastSerial* ps) { char c, d; ps->println("You've got data! "); ps->println(""); ps->println(" Select:"); ps->println(" (p) Print data to this terminal as text"); ps->println(" (e) Erase memory"); ps->println(" (o) Overwrite data. May lead to corrupt data sets if new"); ps->println(" data set is shorter than the one it is overwriting!"); ps->println(" (l) Leave data alone. No new data will be recorded."); ps->println(""); c = get_char_timeout(ps); if (c != 0) { switch (c) { case 'p': return ANS_PRINT_TO_TERMINAL; break; case 'e': print_warning(ps); ps->println("YOU ARE ABOUT TO ERASE ALL MEMORY. CONFIRM (y/n): "); d = get_char(ps); if ( (d == 'y') || (d == 'Y') ) { ps->println("Erasing memory...this may take a few minutes..."); return ANS_ERASE_MEMORY; } break; case 'o': print_warning(ps); ps->println("YOU ARE ABOUT TO OVERWRITE MEMORY. CONFIRM (y/n): "); d = get_char(ps); if ( (d == 'y') || (d == 'Y') ) { ps->println("Overwriting file header..."); return ANS_OVERWRITE; } break; case 'l': return ANS_LEAVE_ALONE; break; default: ps->println("Don't know that letter."); } } return ANS_NO_RESPONSE; }
void delete_ext_html(char *ext, char *gisbase, char **html) { int pos1, pos2, pos3; int start, end; char item[MAXSTR]; int found; int i; pos1 = find_pos("<b>Drivers sections:</b>", html, 0); /* first go to section on "Drivers" */ if (pos1 < 0) { /* we have a new version of the HTML docs that does not have a "Drivers" section anymore */ /* let's check for the special GEM comment */ pos1 = find_pos ("<!-- GEM Extensions StartHTML. Do not delete or change this comment! -->", html, 0); if (pos1 < 0) { /* sorry, I can't handle these HTML docs */ print_warning ("Unknown format of index.html. Unable to de-register HTML man pages.\n"); return; } } pos2 = find_pos("<hr>", html, pos1); /* the horizontal ruler marks the end of the HTML text */ if (find_pos("<h3>Installed extensions:</h3>", html, pos1) == -1) { /* Extensions section does not exist: bail out! */ print_warning("no extensions section found in index.html.\n"); return; } start = find_pos("<h3>Installed extensions:</h3>", html, pos1); end = find_pos("</ul>", html, start); /* check if the entry exists and if so delete */ found = 0; sprintf(item, "\">%s", ext); pos3 = find_pos(item, html, start); if (pos3 == -1) { /* does not exist: */ print_warning("extension '%s' not listed in index.html.\n", ext); return; } /* delete item, if it was found in the extensions section */ if (pos3 < end) { delete_str(pos3, html); } end--; /* end of extensions section is no one up! */ /* if no more entries left in the extensions list: delete the entire section */ pos3 = find_pos("<ul>", html, start); if ((pos3 != -1) && (end > pos3) && (end - pos3 < 2)) { for (i = 0; i < 4; i++) { delete_str(pos3 - 1, html); } } }
// Loop for communication with last sensor void last_loop() { print_info("Last loop"); while(1) { if(mode == RECONF) { sleep(1); continue; } print_info("Waiting for data from last..."); unsigned char buf[MAX_DATA]; unsigned last_addr_len = sizeof(last_addr); int len = recvfrom(sock_last, buf, MAX_DATA, 0, (struct sockaddr*)&last_addr, &last_addr_len); if(len < 0) { mode = DOUBLE_LIST; resolving_error = 1; print_warning("Didn't receive data message from last sensor"); print_success("Mode changed to double-list"); if(send_error_msg(FIRST) < 0 || receive_ack_and_finit(FIRST) < 0) { close_first = 1; } if(send_error_msg(LAST) < 0 || receive_ack_and_finit(LAST) < 0) { resolving_error = 0; return; } resolving_error = 0; } else { union msg received_msg; int msg_type = unpack_msg(buf, &received_msg); switch(msg_type) { case INIT_MSG: take_init_msg(received_msg.init); break; case DATA_MSG: take_data_msg(received_msg.data); break; default: print_warning("Received unknown bytes"); } cleanup_msg(&received_msg); } usleep(SERVER_TIMEOUT*1000); if(mode == DOUBLE_LIST) { print_info("Sending data to last sensor..."); send_data_msg(LAST); } } }
static atf_error_t run_tc(const atf_tp_t *tp, struct params *p, int *exitcode) { atf_error_t err; err = atf_no_error(); if (!atf_tp_has_tc(tp, p->m_tcname)) { err = usage_error("Unknown test case `%s'", p->m_tcname); goto out; } if (!atf_env_has("__RUNNING_INSIDE_ATF_RUN") || strcmp(atf_env_get( "__RUNNING_INSIDE_ATF_RUN"), "internal-yes-value") != 0) { print_warning("Running test cases outside of kyua(1) is unsupported"); print_warning("No isolation nor timeout control is being applied; you " "may get unexpected failures; see atf-test-case(4)"); } switch (p->m_tcpart) { case BODY: err = atf_tp_run(tp, p->m_tcname, atf_fs_path_cstring(&p->m_resfile)); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; case CLEANUP: err = atf_tp_cleanup(tp, p->m_tcname); if (atf_is_error(err)) { /* TODO: Handle error */ *exitcode = EXIT_FAILURE; atf_error_free(err); } else { *exitcode = EXIT_SUCCESS; } break; default: UNREACHABLE; } INV(!atf_is_error(err)); out: return err; }
/* Parse the debug parameter, fill in the debug_setting array */ void init_debug() { char *debug_str, *tmp_str; char *p; int i; bool_t new_setting; for ( i=0; i<NUM_DEBUG_MODES; i++ ) { debug_setting[i] = False; } debug_str = getparam_debug(); tmp_str = debug_str; while ( (p = strtok( tmp_str, " " )) != NULL ) { tmp_str = NULL; new_setting = True; if ( *p == '-' ) { p++; new_setting = False; if ( *p == '\0' ) { print_warning( CONFIGURATION_WARNING, "solitary `-' in debug parameter -- ignored." ); continue; } } if ( *p == '\0' ) { continue; } if ( string_cmp_no_case( p, "all" ) == 0 ) { for (i=0; i<NUM_DEBUG_MODES; i++) { debug_setting[i] = new_setting; } } else { for ( i=0; i<NUM_DEBUG_MODES; i++ ) { if ( string_cmp_no_case( p, debug_desc[i] ) == 0 ) { debug_setting[i] = new_setting; break; } } if ( i == NUM_DEBUG_MODES ) { print_warning( CONFIGURATION_WARNING, "unrecognized debug mode `%s'", p ); } } } }
/* shared memory control */ void sys_shmctl() { Trapframe *tf = task_curr->registers(); int shmid = (int)get_param2(tf); int cmd = (int)get_param3(tf); struct shmid_ds* buf = (struct shmid_ds*)get_param4(tf); print_warning(">> sys_shmctl\n"); print_warning(">> shmid: %d\n", shmid); print_warning(">> cmd: %d\n", cmd); print_warning(">> buf: %08x\n", buf); return set_return(tf, -1); }
int mainloop(struct watchdog *wd) { int rc, last_warning; bool should_warn; last_warning = -1; while (!exit_signaled) { rc = update_temp_sensor(wd); if (rc) { /* Try one more time before giving up */ sleep(1); rc = update_temp_sensor(wd); if (rc) { perror("ERROR: Failed to update temperature" " sensor value\n"); return rc; } } /* Limit log spamming */ should_warn = (last_warning < 0 || last_warning >= MAINLOOP_WARN_INTERVAL) ? true : false; if (wd->min_temp > wd->curr_temp) { if (should_warn) { print_warning(wd, "below"); last_warning = 0; } else { last_warning += MAINLOOP_ITERATION_INTERVAL; } disable_chip(); } else if (wd->curr_temp > wd->max_temp) { if (should_warn) { print_warning(wd, "above"); last_warning = 0; } else { last_warning += MAINLOOP_ITERATION_INTERVAL; } disable_chip(); } else { last_warning = -1; } sleep(MAINLOOP_ITERATION_INTERVAL); } return 0; }
bool value_profiler::test_rule(ad_rule ip_rule) { if(ip_rule.get_type() == RULE_TYPE_KERNEL) { print_warning("NOT Supported"); exit(-1); } else { if(profiler_state == ENABLED) { if(ip_rule.get_type() == VALUE_EXACT) { if(apply_rule_exact(ip_rule ) ) return RULE_SUCCESS; else return RULE_FAILURE; } if(ip_rule.get_type() == VALUE_LESS_THAN) { if(apply_rule_less_than(ip_rule )) return RULE_SUCCESS; else return RULE_FAILURE; } if(ip_rule.get_type() == VALUE_MORE_THAN) { if(apply_rule_more_than(ip_rule )) return RULE_SUCCESS; else return RULE_FAILURE; } if(ip_rule.get_type() == UNDEFINED_RULE_TYPE) { print_logging("rule not defined yet, Cannot test"); exit(-1); } } else { print_warning("Value profiler not enabled"); } } print_logging("Should not get here"); exit(-1); // Added this so the compiler doesnt moan return RULE_FAILURE; }
void pbc_assert_match2(element_ptr a, element_ptr b, const char *func) { print_warning(); if (a->field != b->field) { out("PBC assert failed: %s(): field mismatch\n", func); abort(); } }
int gen_args ( char * dirname , int sw ) { FILE * fp ; char fname[NAMELEN] ; char * fn = "_args.inc" ; char * p ; int linelen ; char outstr[64*4096] ; if ( dirname == NULL ) return(1) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s%s%s",dirname, (sw==ACTUAL||sw==ACTUAL_NEW)?"actual":"dummy",(sw==ACTUAL_NEW||sw==DUMMY_NEW)?"_new":"",fn) ; } else { sprintf(fname,"%s%s%s", (sw==ACTUAL||sw==ACTUAL_NEW)?"actual":"dummy",(sw==ACTUAL_NEW||sw==DUMMY_NEW)?"_new":"",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; linelen = 0 ; strcpy(outstr,",") ; gen_args1 ( fp , outstr, (sw==ACTUAL||sw==ACTUAL_NEW)?"grid%":"", &Domain , &linelen , sw , 0 ) ; /* remove trailing comma */ if ((p=rindex(outstr,','))!=NULL) *p = '\0' ; fputs(outstr,fp);fputs(" &\n",fp) ; close_the_file( fp ) ; return(0) ; }
void exit_tmp( void ) { int eax; int error; char tmp[2048]; DIR *dir; if ( TMPDIR[0] == 0 ) TMPCLEAN = 1; else if ( TMPCLEAN == 0 ) { chdir( CWD ); sprintf( tmp, "rm -rf %s/*", TMPDIR ); if ( VERBOSE ) fwrite( "Removing temporary extension files...", 1, 37, stdout ); error = system( tmp ); sprintf( tmp, "rmdir %s", TMPDIR ); error = system( tmp ); dir = opendir( TMPDIR ); if ( dir ) print_warning( "could not remove temporary directory %s.\nPlease remove manually.\n", TMPDIR[0] ); if ( VERBOSE ) print_done( ); TMPCLEAN = 1; } return; }
/** * Rule to check if the data on the device is more than the target value */ inline bool value_profiler::apply_rule_more_than(ad_rule ip) { if(profiler_state == DISABLED) { print_warning("Profiler Disabled"); return RULE_FAILURE; } else { float * target_ptr; cl_int status; printf("OPENCL BUFFER USED HAP CODE %p\n",ip.get_target_buff()); target_ptr = (float *)clEnqueueMapBuffer(access_queue,ip.get_target_buff(), CL_TRUE, CL_MAP_READ, 0,ip.get_target_mem_size(),0, NULL,NULL,&status); ad_errChk(status,"error mapping buffer in value profiler"); status = clFinish(access_queue); ad_errChk(status,"error mapping buffer in value profiler"); //printf("Value seen from memory %f and Target is %f \n", target_ptr[0],ip.get_target_value()); //for(int i =0 ; i< 64;i++) // printf("Value seen from memory mapping is %f \t Mapping %d \n",target_ptr[i],ip.get_target_mem_size()); //getchar(); if(float(target_ptr[0]) > ip.get_target_value()) return RULE_SUCCESS; else return RULE_FAILURE; } }
static void open_file (const gchar *file_name, GtkTextView *text_view) { g_return_if_fail (file_name && text_view); { gchar *contents = NULL; if (g_file_get_contents (file_name, &contents, NULL, NULL)) { /* Copie de contents dans le GtkTextView */ gchar *utf8; GtkTextIter iter; GtkTextBuffer *text_buffer; cb_new (NULL, text_view); docs.actif->path = g_strdup (file_name); gtk_widget_set_sensitive (GTK_WIDGET (docs.actif->text_view), TRUE); text_buffer = gtk_text_view_get_buffer (text_view); gtk_text_buffer_get_iter_at_line (text_buffer, &iter, 0); utf8 = g_locale_to_utf8 (contents, -1, NULL, NULL, NULL); g_free (contents), contents = NULL; gtk_text_buffer_insert (text_buffer, &iter, utf8, -1); g_free (utf8), utf8 = NULL; /* obliges de remetre save a TRUE car insertion du contenu du fichier dans le GtkTextView a appele cb_modfie */ docs.actif->sauve = TRUE; } else print_warning ("Impossible d'ouvrir le fichier %s\n", file_name); } }
static void map_sequence( const char * orig, sequence_t * mapped, p_query query ) { char * unknown_symbols = xmalloc( mapped->len ); size_t unknown_count = 0; size_t added_symbol_count = 0; char m; for( int i = 0; i < mapped->len; ++i ) { if( (m = query->map[(int )orig[i]]) >= 0 ) { mapped->seq[added_symbol_count++] = m; } else { if( orig[i] != '\n' && orig[i] != ' ' && orig[i] != '\t' ) { unknown_symbols[unknown_count++] = orig[i]; } } } if( unknown_count > 0 ) { unknown_symbols[unknown_count] = 0; print_warning( "%ld unknown symbols found and removed: '%s'", unknown_count, unknown_symbols ); } free( unknown_symbols ); mapped->len = added_symbol_count; mapped->seq[mapped->len] = 0; mapped->seq = xrealloc( mapped->seq, mapped->len + 1 ); }
int scalar_derefs ( char * dirname ) { FILE * fp ; char fname[NAMELEN] ; char * fn = "scalar_derefs.inc" ; char * p ; int linelen ; char outstr[64*4096] ; if ( dirname == NULL ) return(1) ; if ( strlen(dirname) > 0 ) { sprintf(fname,"%s/%s",dirname,fn) ; } else { sprintf(fname,"%s",fn) ; } if ((fp = fopen( fname , "w" )) == NULL ) return(1) ; print_warning(fp,fname) ; fprintf(fp,"! BEGIN SCALAR DEREFS\n") ; linelen = 0 ; if ( sw_limit_args ) { fprintf(fp,"#undef CPY\n") ; fprintf(fp,"#undef CPYC\n") ; fprintf(fp,"#ifdef COPY_OUT\n") ; scalar_derefs1 ( fp , &Domain, DIR_COPY_OUT ) ; fprintf(fp,"#else\n") ; scalar_derefs1 ( fp , &Domain, DIR_COPY_IN ) ; fprintf(fp,"#endif\n") ; } fprintf(fp,"! END SCALAR DEREFS\n") ; close_the_file( fp ) ; return(0) ; }
void draw_ui_snow( void ) { GLuint texture_id; char *binding; pp::Vec2d *pt, *tex_min, *tex_max; double size; double xres, yres; int i; xres = getparam_x_resolution(); yres = getparam_y_resolution(); UIMgr.setupDisplay(); binding = "ui_snow_particle"; if (!get_texture_binding( "ui_snow_particle", &texture_id ) ) { print_warning( IMPORTANT_WARNING, "Couldn't get texture for binding %s", binding ); texture_id = 0; } glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glBindTexture( GL_TEXTURE_2D, texture_id ); glColor4f( particleColor[0], particleColor[1], particleColor[2], particleColor[3] ); glPushMatrix(); { for ( i=0; i<num_particles; i++) { pt = &particles[i].pt; size = particles[i].size; tex_min = &particles[i].tex_min; tex_max = &particles[i].tex_max; glPushMatrix(); { glTranslatef( pt->x*xres, pt->y*yres, 0 ); glBegin( GL_QUADS ); { glTexCoord2f( tex_min->x, tex_min->y ); glVertex2f( 0, 0 ); glTexCoord2f( tex_max->x, tex_min->y ); glVertex2f( size, 0 ); glTexCoord2f( tex_max->x, tex_max->y ); glVertex2f( size, size ); glTexCoord2f( tex_min->x, tex_max->y ); glVertex2f( 0, size ); } glEnd(); } glPopMatrix(); } } glPopMatrix(); }
bool readFile(const string & filename, char *buffer, int buffer_length){ int file_length, readed_elements; FILE *fp; if((file_length = getLengthFile(filename)) != -1) { if((fp = fopen(filename.c_str(),"rb")) != NULL) { if(abs(file_length) < abs(buffer_length)) { memset(buffer,0,buffer_length); readed_elements = fread(buffer, 1, file_length, fp); } else { print_error("Cannot read, file (%s) exceds of max lenght bufffer > %i",filename.c_str(),buffer_length); return false; } if(readed_elements != file_length) { print_warning("number elements doesn't match with length file (%s)",filename.c_str()); return false; } fclose(fp); return true; } else print_error("I can't open 1 \"%s\"",filename.c_str()); } else print_error("I can't open 2 \"%s\"",filename.c_str()); return false; }
double f_simplex_kalman(const gsl_vector *x, void *params) { struct s_kalman *p = (struct s_kalman *) params; double log_like; transfer_estimated(p->p_best, x, p->p_data); if(plom_check_IC_assign_theta_remainder(p->p_best->mean, p->p_data)){ #if FLAG_WARNING print_warning("IC constraint has not been respected: pop_IC>pop_size at t=0 minimal likelihood value has been assigned"); #endif log_like = p->smallest_log_like; } else { back_transform_theta2par(p->p_par, p->p_best->mean, p->p_data->p_it_all, p->p_data); linearize_and_repeat(p->p_X, p->p_par, p->p_data, p->p_data->p_it_par_sv); prop2Xpop_size(p->p_X, p->p_data, p->calc[0]); theta_driftIC2Xdrift(p->p_X, p->p_best->mean, p->p_data); //reset dt p->p_X->dt = p->p_X->dt0; log_like = run_kalman(p->p_X, p->p_best, p->p_par, p->p_kalman_update, p->p_data, p->calc, f_prediction_ode, 0, NULL, NULL, NULL, 0); } // "-": simplex minimizes hence the "-" return - log_like; }
/* * child process'in bitmesini bekle ve child process idsini dondur. * child process yoksa -1 dondur. */ SYSCALL_DEFINE1(wait, int*, state) { // FIXME: bunu yapan fonksiyon var ... if ( task_curr->pgdir.verify_user_addr(state, 4, PTE_U) < 0 ) { print_warning(">> wait not verified: 0x%08x - 0x%08x\n", state, state+1); do_exit(111); } state = (int*)uaddr2kaddr((uint32_t)state); pushcli(); if (task_curr->childs.size() == 0) { popif(); return set_return(tf, -1); } /* cagriyi yapan taski runnable_list'den cikar */ remove_from_runnable_list(task_curr); task_curr->state = Task::State_interruptible; task_curr->waiting_child = 1; popif(); schedule(); task_curr->waiting_child = 0; Task *t = task_curr->wait_notify_next; ASSERT(t); task_curr->wait_notify_next = t->wait_notify_next; /* return ve state degiskenlerini ata */ *state = t->exit_code; return set_return(task_curr->registers(), t->id); }
int new_item( char *item, char *menu, char **tcl_lines, int line_no ) { int eax; char *token; int num_tokens; char entry[2048]; char command[2048]; char tmp[2048]; chop( item ); token = strtok( item, ";" ); if ( token == 0 ) { print_warning( "invalid token in 'entries-gisman'.\n" ); } else { strcpy( entry, token ); num_tokens = 0; for ( ; token == 0; num_tokens++ ) { token = strtok( 0, ";" ); if ( token ) strcpy( command, token ); // num_tokens++; } } return line_no; }
/*! Call when a race has just been won \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ void update_for_won_race( void ) { race_data_t *race_data; check_assertion( g_game.practicing == False, "Tried to update for won race in practice mode" ); race_data = (race_data_t*)get_list_elem_data( cur_elem ); if ( last_completed_race == NULL || compare_race_positions( cup_data, last_completed_race, cur_elem ) > 0 ) { last_completed_race = cur_elem; if ( cur_elem == get_list_tail( race_list ) ) { cup_complete = True; if ( !set_last_completed_cup( plyr->name, g_game.current_event, g_game.difficulty, g_game.current_cup ) ) { print_warning( IMPORTANT_WARNING, "Couldn't save cup completion" ); } else { print_debug( DEBUG_GAME_LOGIC, "Cup %s completed", g_game.current_cup ); } } } }
inline bool value_profiler::apply_rule_exact(ad_rule ip) { if(profiler_state == DISABLED) { print_warning("Profiler Disabled"); return RULE_FAILURE; } else { float * target_ptr; cl_int status; target_ptr = (float *)clEnqueueMapBuffer(access_queue ,ip.get_target_buff(), CL_TRUE, CL_MAP_READ, 0,ip.get_target_mem_size(),0, NULL,NULL,&status); //! Verify if this is needd clFinish(access_queue); ad_errChk(status,"error mapping buffer in value profiler"); if(float(target_ptr[0]) == ip.get_target_value()) return RULE_SUCCESS; else return RULE_FAILURE; } }
void pbc_assert(int expr, char *msg, const char *func) { print_warning(); if (!expr) { out("PBC assert failed: %s(): %s\n", func, msg); abort(); } }
static int open_ports(t_srv_data *srv_data, uint16_t ports[], size_t ports_nb) { size_t i; int success_nb; i = 0; success_nb = 0; while (i < ports_nb) { print_info("Initializing socket on port: %d... ", ports[i]); if (srv_create_socket(srv_data->sockets, ports[i], srv_data->slots_nb, SERVER)) { --srv_data->ports_nb; print_warning("%d port(s) remaining\n", ports_nb - (i + 1)); } else ++success_nb; ++i; } if (success_nb) print_info("%d / %d socket(s) %s operationnal.\n", success_nb, ports_nb, ((success_nb == 1) ? ("is") : ("are"))); else return (print_error("No socket has been created, \ given ports might be unavailable\n")); return (EXIT_SUCCESS); }
/*! Draws the text for the loading screen \author jfpatry */ void draw_loading_text( void ) { int w = getparam_x_resolution(); int h = getparam_y_resolution(); int x_org, y_org; const char *string; int string_w, asc, desc; font_t *font; x_org = w/2.0; y_org = h/2.0; if ( !get_font_binding( "loading", &font ) ) { print_warning( IMPORTANT_WARNING, "Couldn't get font for binding loading" ); } else { string = Localize("Loading, Please Wait...",""); get_font_metrics( font, string, &string_w, &asc, &desc ); glPushMatrix(); { glTranslatef( w/2.0 - string_w/2.0, h/2.0 - desc-30, 0 ); bind_font_texture( font ); draw_string( font, string ); } glPopMatrix(); } }
/*! Updates the race results based on the results of the race just completed Should be called before last_race_completed is updated. \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ static void update_race_results( void ) { char *event; char *cup; bool_t update_score = False; char *race_name; scalar_t time; int herring; int score; if ( g_game.practicing ) { open_course_data_t *data; data = (open_course_data_t*)get_list_elem_data( cur_elem ); race_name = data->name; } else { race_data_t *data; data = (race_data_t*)get_list_elem_data( cur_elem ); race_name = data->name; } event = g_game.current_event; cup = g_game.current_cup; if ( !get_saved_race_results( plyr->name, event, cup, race_name, g_game.difficulty, &time, &herring, &score ) ) { update_score = True; } else if ( !g_game.practicing && !cup_complete ) { /* Scores are always overwritten if cup isn't complete */ update_score = True; } else if ( plyr->score > score ) { update_score = True; } else { update_score = False; } if ( update_score ) { bool_t result; result = set_saved_race_results( plyr->name, event, cup, race_name, g_game.difficulty, g_game.time, plyr->herring, plyr->score ); if ( !result ) { print_warning( IMPORTANT_WARNING, "Couldn't save race results" ); } } }
/*! Draws the listbox \return None \author jfpatry \date Created: 2000-09-18 \date Modified: 2000-09-18 */ void listbox_draw( listbox_t *listbox ) { font_t *font; check_assertion( listbox != NULL, "listbox is NULL" ); glDisable( GL_TEXTURE_2D ); if(listbox->background_colour.a != 0.0) { glColor4dv( (scalar_t*)&listbox->border_colour ); glRectf( listbox->pos.x, listbox->pos.y, listbox->pos.x + listbox->w - listbox->arrow_width, listbox->pos.y + listbox->h ); glColor4dv( (scalar_t*)&listbox->background_colour ); glRectf( listbox->pos.x + listbox->border_width, listbox->pos.y + listbox->border_width, listbox->pos.x + listbox->w - listbox->border_width - listbox->arrow_width, listbox->pos.y + listbox->h - listbox->border_width ); } glEnable( GL_TEXTURE_2D ); if ( !get_font_binding( listbox->font_binding, &font ) ) { print_warning( IMPORTANT_WARNING, "Couldn't get font object for binding %s", listbox->font_binding ); } else { int w, asc, desc; char *string; string = listbox->label_gen_func( get_list_elem_data( listbox->cur_item ) ); get_font_metrics( font, string, &w, &asc, &desc ); bind_font_texture( font ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glPushMatrix(); { glTranslatef( listbox->pos.x + listbox->border_width + listbox->text_pad, listbox->pos.y + listbox->h/2.0 - asc/2.0 + desc/2.0, 0 ); draw_string( font, string ); } glPopMatrix(); } button_draw( listbox->up_button ); button_draw( listbox->down_button ); }