static void handle_font_family(QWebSettings::FontFamily font, void *_object, void *_param) { if (READ_PROPERTY) GB.ReturnNewZeroString(TO_UTF8(get_settings(_object)->fontFamily(font))); else get_settings(_object)->setFontFamily(font, QSTRING_PROP()); }
END_METHOD static void handle_font_size(QWebSettings::FontSize size, void *_object, void *_param) { if (READ_PROPERTY) GB.ReturnInteger(get_settings(_object)->fontSize(size)); else get_settings(_object)->setFontSize(size, VPROP(GB_INTEGER)); }
void resize_and_rescale(double scale) { int docwidth,docheight; double docscale; int sp_inner; double ltrimpct=0.0,rtrimpct=0.0; //ewl_object_maximum_h_set(EWL_OBJECT(pdfwidget),99999); //ewl_object_minimum_h_set(EWL_OBJECT(pdfwidget),0); sp_inner=CURRENT_W(scrollpane)-INSET_HORIZONTAL(scrollpane)-PADDING_HORIZONTAL(scrollpane); //if(EWL_SCROLLPANE(scrollpane)->vflag) // sp_inner-=CURRENT_W(EWL_OBJECT(EWL_SCROLLPANE(scrollpane)->vscrollbar)); //ewl_pdf_size_get(EWL_PDF(pdfwidget),&docwidth,&docheight); epdf_page_size_get (EWL_PDF(pdfwidget)->pdf_page,&docwidth,&docheight); if(fitmode==0) docscale=((double)sp_inner)/((double)docwidth)*scale; else if(fitmode==1) { ltrimpct=((double)get_settings()->ltrimpad)/((double)docwidth); rtrimpct=((double)get_settings()->rtrimpad)/((double)docwidth); docscale=((double)sp_inner)/((1.0-leftmarge+ltrimpct-rightmarge+rtrimpct)*((double)docwidth))*scale; } ewl_pdf_scale_set(EWL_PDF(pdfwidget),docscale,docscale); //ewl_object_custom_w_set(EWL_OBJECT(pdfwidget),floor(((double)sp_inner)*scale)); //ewl_object_custom_w_set(EWL_OBJECT(pdfwidget),floor(((double)sp_inner)*scale)); //ewl_object_custom_h_set(EWL_OBJECT(pdfwidget),floor(((double)docheight)/((double)docwidth)*((double)sp_inner)*scale)); ewl_object_custom_w_set(EWL_OBJECT(pdfwidget),floor(((double)docwidth)*docscale)); ewl_object_custom_h_set(EWL_OBJECT(pdfwidget),floor(((double)docheight)*docscale)); //ewl_object_position_request(EWL_OBJECT(pdfwidget),0,0); ewl_widget_configure(pdfwidget); //ewl_object_custom_w_set(EWL_OBJECT(trimpane),floor(((double)docwidth)*docscale)); //ewl_object_custom_h_set(EWL_OBJECT(trimpane),floor(((double)docheight)*docscale)); ewl_object_custom_w_set(EWL_OBJECT(trimpane),floor(((double)sp_inner)*scale)); ewl_object_custom_h_set(EWL_OBJECT(trimpane),floor(((double)docheight)*docscale)); ewl_object_position_request(EWL_OBJECT(trimpane),0,0); //ewl_object_place(EWL_OBJECT(pdfwidget),0,0,floor(((double)docwidth)*docscale),floor(((double)docheight)*docscale)); ewl_widget_configure(trimpane); ewl_widget_configure(scrollpane); if(fitmode==0) ewl_scrollpane_hscrollbar_value_set(EWL_SCROLLPANE(trimpane),0.0); else if(fitmode==1) ewl_scrollpane_hscrollbar_value_set(EWL_SCROLLPANE(trimpane),(leftmarge-ltrimpct)/(leftmarge-ltrimpct+rightmarge-rtrimpct)); }
void contrtemp_init(void) { struct pid_k_set *k_set; struct settings *settings; fixpt_t temp_setpoint; settings = get_settings(); k_set = &settings->temp_k[TEMPBOOST_NORMAL]; pid_init(&contrtemp.pid, #if CONF_DEBUG PSTR("pid-t"), #endif k_set, float_to_fixpt(CONTRTEMP_NEGLIM_I), float_to_fixpt(CONTRTEMP_POSLIM_I), float_to_fixpt(CONTRTEMP_NEGLIM), float_to_fixpt(CONTRTEMP_POSLIM)); temp_setpoint = presets_get_active_value(); pid_set_setpoint(&contrtemp.pid, temp_setpoint); /* Enable the controller. */ do_set_enabled(true); do_set_emerg(false); }
DisplayWindow *DisplayWindowCreator::new_disp_win_if_nec( Display &d ) { if ( not d.window ) { d.window = new DisplayWindow( &d.painter, get_settings() ); d.window->show(); } return d.window; }
static int start_ebs(bool is_start_paused) { int i; int ret; get_settings(); if (is_pmu_enabled()) { pmu_paused = is_start_paused; ret = register_hotcpu_notifier(&cpu_notifier_for_pmu); if (ret != 0) return ret; ret = allocate_pmu(); if (ret != 0) return ret; ret = register_pmu_isr(px_css_isr); if (ret != 0) return ret; for (i=0; i<COUNTER_A9_MAX_ID; i++) reg_value[i] = 0; on_each_cpu(start_pmu, &is_start_paused, 1); } return 0; }
double get_vertical_pan_inc() { double hs=(double)CURRENT_H(scrollpane); double ht=(double)CURRENT_H(trimpane); if(ht<=hs) return 0.0; return ((double)get_settings()->vpan)*hs/(100.0*(ht-hs)); }
double get_horizontal_pan_inc() { double ws=(double)CURRENT_W(scrollpane); double wt=(double)CURRENT_W(trimpane); if(wt<=ws) return 0.0; return ((double)get_settings()->hpan)*ws/(100.0*(wt-ws)); }
void meastemp_adjust_set(fixpt_t adjustment) { #if CONF_ADJ measure_adjust_set(MEAS_CHAN_TEMP, adjustment); get_settings()->temp_adj = adjustment; store_settings(); menu_request_display_update(); #endif }
/* PAM hook for ACCOUNT management: * other account required pam_globus.so */ int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) { settings_t *settings = get_settings(pamh, "auth", NULL); int result = PAM_SUCCESS; msg(settings->ctx, LOG_INFO, "%s@%s: acct mgmt for %s@%s", settings->ctx->svc, settings->ctx->uts.nodename, settings->ctx->user, settings->ctx->rhost); return result; }
void contrtemp_set_idle_setpoint(fixpt_t w) { struct settings *settings; if (CONF_IDLE) { settings = get_settings(); settings->temp_idle_setpoint = w; contrtemp_update_setpoint(); store_settings(); } }
static gboolean game_handle_io (GGZMod * mod) { int op = -1; fd = ggzmod_get_server_fd (mod); // Read the fd if (ggz_read_int (fd, &op) < 0) { ggz_error_msg ("Couldn't read the game fd"); return FALSE; } switch (op) { case GN_MSG_SEAT: get_seat (); break; case GN_MSG_PLAYERS: get_players (); break; case GN_MSG_START: gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE); new_game (); break; case GN_MSG_SYNC: get_sync (); break; case GN_MSG_MOVE: get_move (); break; case GN_MSG_SETTINGS: get_settings (); break; case GN_MSG_BONI: get_boni (); break; case GN_MSG_NOBONI: get_noboni (); break; default: ggz_error_msg ("Incorrect opcode %d \n", op); break; } return TRUE; }
static int start_ebs(bool is_start_paused) { int ret; get_settings(); if (is_pmu_enabled()) { if ((ret = start_pmu(is_start_paused)) != 0) return ret; } return 0; }
void contrtemp_update_setpoint(void) { struct settings *settings; fixpt_t temp_setpoint; fixpt_t temp_idle_setpoint; temp_setpoint = presets_get_active_value(); settings = get_settings(); temp_idle_setpoint = settings->temp_idle_setpoint; if (contrtemp_is_idle() && (temp_idle_setpoint < temp_setpoint)) pid_set_setpoint(&contrtemp.pid, temp_idle_setpoint); else pid_set_setpoint(&contrtemp.pid, temp_setpoint); }
static void contrtemp_set_boost_mode(enum contrtemp_boostmode new_boost_mode) { struct pid_k_set *k_set; struct settings *settings; settings = get_settings(); k_set = &settings->temp_k[new_boost_mode]; pid_set_factors(&contrtemp.pid, k_set); #if CONF_BOOST contrtemp.boost_mode = new_boost_mode; debug_print_int16(DEBUG_PFX1("tb"), (int16_t)new_boost_mode); #endif menu_request_display_update(); }
void DisplayWindowCreator::set_val( int num_display_window, int id_val, int val ) { if ( not displays.contains( num_display_window ) ) displays[ num_display_window ].painter.load_settings( get_settings() ); switch ( id_val ){ case ID_SHRINK: displays[ num_display_window ].painter.shrink = val / 65535.0; break; case ID_ANTIALIASING: displays[ num_display_window ].painter.anti_aliasing = val; break; case ID_BORDERS: displays[ num_display_window ].painter.borders = val; break; case ID_FIT: displays[ num_display_window ].painter.zoom_should_be_updated = true; } }
/** * @brief Sets the desired LED behaviour * * Led thread handle two functionalities: * - the led state, * - diagnostic button. * The led state service is driving from Proximetry agent. The led can be set to one of three state ON,OFF,BLINKING. * The diagnostic button service allows to determine the end node connection state without console inspection. * The diagnostic button distinguish three states: * - end node disconnected from BR - led blinking with 5Hz frequency for 5s, * - end node connected with BR only - led blinking with 2Hz frequency for 5s , * - end node agent connected to Cloud Serve - led is On for 5s. */ PROCESS_THREAD(led_process, ev, data) { UNUSED(data); UNUSED(ev); PROCESS_BEGIN(); timer_set(&led_timer, LED_TOGGLE_INTERVAL); while(1) { diagnostic_button_service(); if (diagnostic_button_service_is_active()) { diagnostic_button_led_service(); } else { if (!timer_expired(&led_timer)) goto end; timer_restart(&led_timer); switch (get_settings()->led0_state) { case LED_OFF: set_led_state(LED_OFF); break; case LED_ON: set_led_state(LED_ON); break; case LED_BLINK: led_toggle(); break; default: ; } } end: PROCESS_PAUSE(); } PROCESS_END(); }
void window_load_main(Window *window){ Layer *window_layer = window_get_root_layer(window); main_settings = get_settings(); theme = inverter_layer_create(GRect(0, 0, 144, 168)); first_word_t = text_layer_init(GRect(0, 0, 144, 168), GTextAlignmentLeft, 1); second_word_t = text_layer_init(GRect(0, 30, 144, 168), GTextAlignmentLeft, 2); third_word_t = text_layer_init(GRect(0, 63, 144, 168), GTextAlignmentLeft, 1); fourth_word_t = text_layer_init(GRect(0, 91, 144, 168), GTextAlignmentLeft, 1); slot_t = text_layer_init(GRect(0, 130, 144, 168), GTextAlignmentLeft, 3); seconds_t = text_layer_init(GRect(115, 0, 20, 20), GTextAlignmentRight, 4); battery_bar_layer = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(battery_bar_layer, battery_bar_proc); layer_add_child(window_layer, text_layer_get_layer(first_word_t)); layer_add_child(window_layer, text_layer_get_layer(second_word_t)); layer_add_child(window_layer, text_layer_get_layer(third_word_t)); layer_add_child(window_layer, text_layer_get_layer(fourth_word_t)); layer_add_child(window_layer, text_layer_get_layer(slot_t)); layer_add_child(window_layer, text_layer_get_layer(seconds_t)); layer_add_child(window_layer, battery_bar_layer); layer_add_child(window_layer, inverter_layer_get_layer(theme)); notify_bar_create(window); tick_timer_service_subscribe(SECOND_UNIT, tick_handler); battery_state_service_subscribe(battery_handler); bluetooth_connection_service_subscribe(bluetooth_handler); BatteryChargeState state = battery_state_service_peek(); battery_handler(state); struct tm *t; time_t temp; temp = time(NULL); t = localtime(&temp); tick_handler(t, 0); refresh_settings(); }
/* Calculate the relative and absolute pan increments for the given * window and document sizes. Return them in *relative and *absolute. */ static void pan_inc(double doc, double win, double *relative, double *absolute) { if(doc <= win) { // no need to scroll *relative = *absolute = 0.0; } /* Now panning comes into the picture. * We have this setting, the "minimum pan overlap" (%). * Let us prepare the absolute (minimum) overlap amount, in pixels. */ double overlap_fraction = (double)get_settings()->pan_overlap / 100.0; double overlap_amount = win * overlap_fraction; /* The question is: how many pannings do we need per page, * given the doc and win sizes and the overlap amount? */ double pan_steps = ceil((doc - overlap_amount) / (win - overlap_amount)); assert(pan_steps > 1.0); /* To move to next step (we can do that pan_steps - 1 times), * advance a (pan_steps - 1)th part of what is outside the window. */ *relative = 1.0 / (pan_steps - 1); *absolute = *relative * (doc - win); }
int main(int argc, char **argv) { CJOB *settings = get_settings(argc, argv); if(DEBUG_LEVEL >= 1) print_commet_job(settings); int i = 0, j = 0; int n = settings->num_sets; char *sfafname = settings->sets[0]->filenames[0]; char *sbvfname = get_bvfname_from_one_fafname(settings, sfafname); READSET *set_b = settings->sets[1]; BITVEC *uniq = reads_not_in_set(settings, sfafname, sbvfname, set_b); for(i = 2; i < settings->num_sets; i++) { set_b = settings->sets[i]; BITVEC *uniq2 = reads_not_in_set(settings, sfafname, sbvfname, set_b); bv_iand(uniq, uniq2); } bv_save_to_file(uniq, "uniq.bv"); for(i = 0; i < uniq->num_bits / CHAR_BIT; i++) { printf("%i", bv_get(uniq, i)); if(i % 100 == 0) puts(""); } puts(""); extract_reads(sfafname, "uniq.bv", "uniq.fasta"); cjob_destroy(settings); return 0; }
static BOOL CALLBACK dialog_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam ) { static char edit_buf[256] = { 0 }; switch( message ) { case WM_INITDIALOG : InitCommonControls(); get_settings(); /* threads */ sprintf( edit_buf, "%d", reader_opt.threads ); SetDlgItemText( hwnd, IDC_EDIT_THREADS, (LPCTSTR)edit_buf ); SendMessage( GetDlgItem( hwnd, IDC_SPIN_THREADS ), UDM_SETBUDDY, (WPARAM)GetDlgItem( hwnd, IDC_EDIT_THREADS ), 0 ); /* av_sync */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_AV_SYNC ), BM_SETCHECK, (WPARAM) reader_opt.av_sync ? BST_CHECKED : BST_UNCHECKED, 0 ); /* no_create_index */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_CREATE_INDEX_FILE ), BM_SETCHECK, (WPARAM) reader_opt.no_create_index ? BST_UNCHECKED : BST_CHECKED, 0 ); /* force stream index */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_FORCE_VIDEO ), BM_SETCHECK, (WPARAM) reader_opt.force_video ? BST_CHECKED : BST_UNCHECKED, 0 ); sprintf( edit_buf, "%d", reader_opt.force_video_index ); SetDlgItemText( hwnd, IDC_EDIT_FORCE_VIDEO_INDEX, (LPCTSTR)edit_buf ); SendMessage( GetDlgItem( hwnd, IDC_CHECK_FORCE_AUDIO ), BM_SETCHECK, (WPARAM) reader_opt.force_audio ? BST_CHECKED : BST_UNCHECKED, 0 ); sprintf( edit_buf, "%d", reader_opt.force_audio_index ); SetDlgItemText( hwnd, IDC_EDIT_FORCE_AUDIO_INDEX, (LPCTSTR)edit_buf ); /* forward_seek_threshold */ sprintf( edit_buf, "%d", video_opt->forward_seek_threshold ); SetDlgItemText( hwnd, IDC_EDIT_FORWARD_THRESHOLD, (LPCTSTR)edit_buf ); SendMessage( GetDlgItem( hwnd, IDC_SPIN_FORWARD_THRESHOLD ), UDM_SETBUDDY, (WPARAM)GetDlgItem( hwnd, IDC_EDIT_FORWARD_THRESHOLD ), 0 ); /* seek mode */ HWND hcombo = GetDlgItem( hwnd, IDC_COMBOBOX_SEEK_MODE ); for( int i = 0; i < 3; i++ ) SendMessage( hcombo, CB_ADDSTRING, 0, (LPARAM)seek_mode_list[i] ); SendMessage( hcombo, CB_SETCURSEL, video_opt->seek_mode, 0 ); /* scaler */ hcombo = GetDlgItem( hwnd, IDC_COMBOBOX_SCALER ); for( int i = 0; i < 11; i++ ) SendMessage( hcombo, CB_ADDSTRING, 0, (LPARAM)scaler_list[i] ); SendMessage( hcombo, CB_SETCURSEL, video_opt->scaler, 0 ); /* apply_repeat_flag */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_APPLY_REPEAT_FLAG ), BM_SETCHECK, (WPARAM) video_opt->apply_repeat_flag ? BST_CHECKED : BST_UNCHECKED, 0 ); /* field_dominance */ hcombo = GetDlgItem( hwnd, IDC_COMBOBOX_FIELD_DOMINANCE ); for( int i = 0; i < 3; i++ ) SendMessage( hcombo, CB_ADDSTRING, 0, (LPARAM)field_dominance_list[i] ); SendMessage( hcombo, CB_SETCURSEL, video_opt->field_dominance, 0 ); /* LW48 output */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_LW48_OUTPUT ), BM_SETCHECK, (WPARAM) video_opt->colorspace == 0 ? BST_UNCHECKED : BST_CHECKED, 0 ); /* AVS bit-depth */ hcombo = GetDlgItem( hwnd, IDC_COMBOBOX_AVS_BITDEPTH ); for( int i = 0; i < 4; i++ ) { SendMessage( hcombo, CB_ADDSTRING, 0, (LPARAM)avs_bit_depth_list[i] ); if( video_opt->avs.bit_depth == atoi( avs_bit_depth_list[i] ) ) SendMessage( hcombo, CB_SETCURSEL, i, 0 ); } /* audio_delay */ sprintf( edit_buf, "%d", audio_delay ); SetDlgItemText( hwnd, IDC_EDIT_AUDIO_DELAY, (LPCTSTR)edit_buf ); /* channel_layout */ if( audio_opt->channel_layout ) { char *buf = edit_buf; for( int i = 0; i < 64; i++ ) { uint64_t audio_channel = audio_opt->channel_layout & (1ULL << i); if( audio_channel ) { const char *channel_name = av_get_channel_name( audio_channel ); if( channel_name ) { int name_length = strlen( channel_name ); memcpy( buf, channel_name, name_length ); buf += name_length; *(buf++) = '+'; } } } if( buf > edit_buf ) *(buf - 1) = '\0'; /* Set NULL terminator. */ else memcpy( edit_buf, "Unspecified", 12 ); } else memcpy( edit_buf, "Unspecified", 12 ); SetDlgItemText( hwnd, IDC_EDIT_CHANNEL_LAYOUT, (LPCTSTR)edit_buf ); /* sample_rate */ if( audio_opt->sample_rate > 0 ) sprintf( edit_buf, "%d", audio_opt->sample_rate ); else { audio_opt->sample_rate = 0; memcpy( edit_buf, "0 (Auto)", 12 ); } SetDlgItemText( hwnd, IDC_EDIT_SAMPLE_RATE, (LPCTSTR)edit_buf ); /* mix_level */ send_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_CENTER, IDC_TEXT_MIX_LEVEL_CENTER, 0, 500, audio_opt->mix_level[MIX_LEVEL_INDEX_CENTER ], edit_buf ); send_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_SURROUND, IDC_TEXT_MIX_LEVEL_SURROUND, 0, 500, audio_opt->mix_level[MIX_LEVEL_INDEX_SURROUND], edit_buf ); send_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_LFE, IDC_TEXT_MIX_LEVEL_LFE, 0, 500, audio_opt->mix_level[MIX_LEVEL_INDEX_LFE ], edit_buf ); /* readers */ SendMessage( GetDlgItem( hwnd, IDC_CHECK_LIBAVSMASH_INPUT ), BM_SETCHECK, (WPARAM) reader_disabled[0] ? BST_UNCHECKED : BST_CHECKED, 0 ); SendMessage( GetDlgItem( hwnd, IDC_CHECK_AVS_INPUT ), BM_SETCHECK, (WPARAM) reader_disabled[1] ? BST_UNCHECKED : BST_CHECKED, 0 ); SendMessage( GetDlgItem( hwnd, IDC_CHECK_VPY_INPUT ), BM_SETCHECK, (WPARAM) reader_disabled[2] ? BST_UNCHECKED : BST_CHECKED, 0 ); SendMessage( GetDlgItem( hwnd, IDC_CHECK_LIBAV_INPUT ), BM_SETCHECK, (WPARAM) reader_disabled[3] ? BST_UNCHECKED : BST_CHECKED, 0 ); /* dummy reader */ sprintf( edit_buf, "%d", video_opt->dummy.width ); SetDlgItemText( hwnd, IDC_EDIT_DUMMY_WIDTH, (LPCTSTR)edit_buf ); sprintf( edit_buf, "%d", video_opt->dummy.height ); SetDlgItemText( hwnd, IDC_EDIT_DUMMY_HEIGHT, (LPCTSTR)edit_buf ); sprintf( edit_buf, "%d", video_opt->dummy.framerate_num ); SetDlgItemText( hwnd, IDC_EDIT_DUMMY_FRAMERATE_NUM, (LPCTSTR)edit_buf ); sprintf( edit_buf, "%d", video_opt->dummy.framerate_den ); SetDlgItemText( hwnd, IDC_EDIT_DUMMY_FRAMERATE_DEN, (LPCTSTR)edit_buf ); hcombo = GetDlgItem( hwnd, IDC_COMBOBOX_DUMMY_COLORSPACE ); for( int i = 0; i < 3; i++ ) SendMessage( hcombo, CB_ADDSTRING, 0, (LPARAM)dummy_colorspace_list[i] ); SendMessage( hcombo, CB_SETCURSEL, video_opt->dummy.colorspace, 0 ); /* Library informations */ if( plugin_information[0] == 0 ) get_plugin_information(); SetDlgItemText( hwnd, IDC_TEXT_LIBRARY_INFO, (LPCTSTR)plugin_information ); HFONT hfont = (HFONT)GetStockObject( DEFAULT_GUI_FONT ); LOGFONT lf = { 0 }; GetObject( hfont, sizeof(lf), &lf ); lf.lfWidth *= 0.90; lf.lfHeight *= 0.90; lf.lfQuality = ANTIALIASED_QUALITY; SendMessage( GetDlgItem( hwnd, IDC_TEXT_LIBRARY_INFO ), WM_SETFONT, (WPARAM)CreateFontIndirect( &lf ), 1 ); return TRUE; case WM_NOTIFY : if( wparam == IDC_SPIN_THREADS ) { LPNMUPDOWN lpnmud = (LPNMUPDOWN)lparam; if( lpnmud->hdr.code == UDN_DELTAPOS ) { GetDlgItemText( hwnd, IDC_EDIT_THREADS, (LPTSTR)edit_buf, sizeof(edit_buf) ); reader_opt.threads = atoi( edit_buf ); if( lpnmud->iDelta ) reader_opt.threads += lpnmud->iDelta > 0 ? -1 : 1; if( reader_opt.threads < 0 ) reader_opt.threads = 0; sprintf( edit_buf, "%d", reader_opt.threads ); SetDlgItemText( hwnd, IDC_EDIT_THREADS, (LPCTSTR)edit_buf ); } } else if( wparam == IDC_SPIN_FORWARD_THRESHOLD ) { LPNMUPDOWN lpnmud = (LPNMUPDOWN)lparam; if( lpnmud->hdr.code == UDN_DELTAPOS ) { GetDlgItemText( hwnd, IDC_EDIT_FORWARD_THRESHOLD, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->forward_seek_threshold = atoi( edit_buf ); if( lpnmud->iDelta ) video_opt->forward_seek_threshold += lpnmud->iDelta > 0 ? -1 : 1; video_opt->forward_seek_threshold = CLIP_VALUE( video_opt->forward_seek_threshold, 1, 999 ); sprintf( edit_buf, "%d", video_opt->forward_seek_threshold ); SetDlgItemText( hwnd, IDC_EDIT_FORWARD_THRESHOLD, (LPCTSTR)edit_buf ); } } return TRUE; case WM_HSCROLL : if( GetDlgItem( hwnd, IDC_SLIDER_MIX_LEVEL_CENTER ) == (HWND)lparam ) get_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_CENTER, IDC_TEXT_MIX_LEVEL_CENTER, &audio_opt->mix_level[MIX_LEVEL_INDEX_CENTER ], edit_buf ); else if( GetDlgItem( hwnd, IDC_SLIDER_MIX_LEVEL_SURROUND ) == (HWND)lparam ) get_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_SURROUND, IDC_TEXT_MIX_LEVEL_SURROUND, &audio_opt->mix_level[MIX_LEVEL_INDEX_SURROUND], edit_buf ); else if( GetDlgItem( hwnd, IDC_SLIDER_MIX_LEVEL_LFE ) == (HWND)lparam ) get_mix_level( hwnd, IDC_SLIDER_MIX_LEVEL_LFE, IDC_TEXT_MIX_LEVEL_LFE, &audio_opt->mix_level[MIX_LEVEL_INDEX_LFE ], edit_buf ); return FALSE; case WM_COMMAND : switch( wparam ) { case IDCANCEL : EndDialog( hwnd, IDCANCEL ); return TRUE; case IDOK : { if( !settings_path ) settings_path = (char *)settings_path_list[0]; FILE *ini = fopen( settings_path, "w" ); if( !ini ) { MESSAGE_BOX_DESKTOP( MB_ICONERROR | MB_OK, "Failed to update configuration file" ); return FALSE; } /* threads */ GetDlgItemText( hwnd, IDC_EDIT_THREADS, (LPTSTR)edit_buf, sizeof(edit_buf) ); reader_opt.threads = MAX( atoi( edit_buf ), 0 ); if( reader_opt.threads > 0 ) fprintf( ini, "threads=%d\n", reader_opt.threads ); else fprintf( ini, "threads=0 (auto)\n" ); /* av_sync */ reader_opt.av_sync = (BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_AV_SYNC ), BM_GETCHECK, 0, 0 )); fprintf( ini, "av_sync=%d\n", reader_opt.av_sync ); /* no_create_index */ reader_opt.no_create_index = !(BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_CREATE_INDEX_FILE ), BM_GETCHECK, 0, 0 )); fprintf( ini, "no_create_index=%d\n", reader_opt.no_create_index ); /* force stream index */ reader_opt.force_video = (BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_FORCE_VIDEO ), BM_GETCHECK, 0, 0 )); GetDlgItemText( hwnd, IDC_EDIT_FORCE_VIDEO_INDEX, (LPTSTR)edit_buf, sizeof(edit_buf) ); reader_opt.force_video_index = MAX( atoi( edit_buf ), -1 ); fprintf( ini, "force_video_index=%d:%d\n", reader_opt.force_video, reader_opt.force_video_index ); reader_opt.force_audio = (BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_FORCE_AUDIO ), BM_GETCHECK, 0, 0 )); GetDlgItemText( hwnd, IDC_EDIT_FORCE_AUDIO_INDEX, (LPTSTR)edit_buf, sizeof(edit_buf) ); reader_opt.force_audio_index = MAX( atoi( edit_buf ), -1 ); fprintf( ini, "force_audio_index=%d:%d\n", reader_opt.force_audio, reader_opt.force_audio_index ); /* seek_mode */ video_opt->seek_mode = SendMessage( GetDlgItem( hwnd, IDC_COMBOBOX_SEEK_MODE ), CB_GETCURSEL, 0, 0 ); fprintf( ini, "seek_mode=%d\n", video_opt->seek_mode ); /* forward_seek_threshold */ GetDlgItemText( hwnd, IDC_EDIT_FORWARD_THRESHOLD, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->forward_seek_threshold = CLIP_VALUE( atoi( edit_buf ), 1, 999 ); fprintf( ini, "forward_threshold=%d\n", video_opt->forward_seek_threshold ); /* scaler */ video_opt->scaler = SendMessage( GetDlgItem( hwnd, IDC_COMBOBOX_SCALER ), CB_GETCURSEL, 0, 0 ); fprintf( ini, "scaler=%d\n", video_opt->scaler ); /* apply_repeat_flag */ video_opt->apply_repeat_flag = (BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_APPLY_REPEAT_FLAG ), BM_GETCHECK, 0, 0 )); fprintf( ini, "apply_repeat_flag=%d\n", video_opt->apply_repeat_flag ); /* field_dominance */ video_opt->field_dominance = SendMessage( GetDlgItem( hwnd, IDC_COMBOBOX_FIELD_DOMINANCE ), CB_GETCURSEL, 0, 0 ); fprintf( ini, "field_dominance=%d\n", video_opt->field_dominance ); /* LW48 output */ video_opt->colorspace = (BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_LW48_OUTPUT ), BM_GETCHECK, 0, 0 )) ? OUTPUT_LW48 : 0; fprintf( ini, "colorspace=%d\n", video_opt->colorspace ); /* AVS bit-depth */ video_opt->avs.bit_depth = SendMessage( GetDlgItem( hwnd, IDC_COMBOBOX_AVS_BITDEPTH ), CB_GETCURSEL, 0, 0 ); video_opt->avs.bit_depth = atoi( avs_bit_depth_list[ video_opt->avs.bit_depth ] ); fprintf( ini, "avs_bit_depth=%d\n", video_opt->avs.bit_depth ); /* audio_delay */ GetDlgItemText( hwnd, IDC_EDIT_AUDIO_DELAY, (LPTSTR)edit_buf, sizeof(edit_buf) ); audio_delay = atoi( edit_buf ); fprintf( ini, "audio_delay=%d\n", audio_delay ); /* channel_layout */ GetDlgItemText( hwnd, IDC_EDIT_CHANNEL_LAYOUT, (LPTSTR)edit_buf, sizeof(edit_buf) ); audio_opt->channel_layout = av_get_channel_layout( edit_buf ); fprintf( ini, "channel_layout=0x%"PRIx64"\n", audio_opt->channel_layout ); /* sample_rate */ GetDlgItemText( hwnd, IDC_EDIT_SAMPLE_RATE, (LPTSTR)edit_buf, sizeof(edit_buf) ); audio_opt->sample_rate = atoi( edit_buf ); fprintf( ini, "sample_rate=%d\n", audio_opt->sample_rate ); /* mix_level */ fprintf( ini, "mix_level=%d:%d:%d\n", audio_opt->mix_level[MIX_LEVEL_INDEX_CENTER ], audio_opt->mix_level[MIX_LEVEL_INDEX_SURROUND], audio_opt->mix_level[MIX_LEVEL_INDEX_LFE ] ); /* readers */ reader_disabled[0] = !(BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_LIBAVSMASH_INPUT ), BM_GETCHECK, 0, 0 )); reader_disabled[1] = !(BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_AVS_INPUT ), BM_GETCHECK, 0, 0 )); reader_disabled[2] = !(BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_VPY_INPUT ), BM_GETCHECK, 0, 0 )); reader_disabled[3] = !(BST_CHECKED == SendMessage( GetDlgItem( hwnd, IDC_CHECK_LIBAV_INPUT ), BM_GETCHECK, 0, 0 )); fprintf( ini, "libavsmash_disabled=%d\n", reader_disabled[0] ); fprintf( ini, "avs_disabled=%d\n", reader_disabled[1] ); fprintf( ini, "vpy_disabled=%d\n", reader_disabled[2] ); fprintf( ini, "libav_disabled=%d\n", reader_disabled[3] ); /* dummy reader */ GetDlgItemText( hwnd, IDC_EDIT_DUMMY_WIDTH, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->dummy.width = MAX( atoi( edit_buf ), 32 ); GetDlgItemText( hwnd, IDC_EDIT_DUMMY_HEIGHT, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->dummy.height = MAX( atoi( edit_buf ), 32 ); GetDlgItemText( hwnd, IDC_EDIT_DUMMY_FRAMERATE_NUM, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->dummy.framerate_num = MAX( atoi( edit_buf ), 1 ); GetDlgItemText( hwnd, IDC_EDIT_DUMMY_FRAMERATE_DEN, (LPTSTR)edit_buf, sizeof(edit_buf) ); video_opt->dummy.framerate_den = MAX( atoi( edit_buf ), 1 ); video_opt->dummy.colorspace = SendMessage( GetDlgItem( hwnd, IDC_COMBOBOX_DUMMY_COLORSPACE ), CB_GETCURSEL, 0, 0 ); fprintf( ini, "dummy_resolution=%dx%d\n", video_opt->dummy.width, video_opt->dummy.height ); fprintf( ini, "dummy_framerate=%d/%d\n", video_opt->dummy.framerate_num, video_opt->dummy.framerate_den ); fprintf( ini, "dummy_colorspace=%d\n", video_opt->dummy.colorspace ); fclose( ini ); EndDialog( hwnd, IDOK ); MESSAGE_BOX_DESKTOP( MB_OK, "Please reopen the input file for updating settings!" ); return TRUE; } default : return FALSE; } case WM_CLOSE : EndDialog( hwnd, IDOK ); return TRUE; default : return FALSE; } }
////////////////////////////////// // Main entry function of the GPU cache model ////////////////////////////////// int main(int argc, char** argv) { srand(time(0)); std::cout << SPLIT_STRING << std::endl; message(""); // Flush messages as soon as possible std::cout.setf(std::ios_base::unitbuf); // Read the hardware settings from file Settings hardware = get_settings(); // Print cache statistics message("Cache configuration:"); std::cout << "### \t Cache size: ~" << hardware.cache_bytes/1024 << "KB" << std::endl; std::cout << "### \t Line size: " << hardware.line_size << " bytes" << std::endl; std::cout << "### \t Layout: " << hardware.cache_ways << " ways, " << hardware.cache_sets << " sets" << std::endl; message(""); // Parse the input argument and make sure that there is only one if (argc != 3) { message("Error: provide one argument only (a folder containing input trace files)"); message(""); std::cout << SPLIT_STRING << std::endl; exit(1); } std::string benchname = argv[1]; std::string suitename = argv[2]; // Loop over all found traces in the folder (one trace per kernel) for (unsigned kernel_id = 0; kernel_id < 20; kernel_id++) { std::vector<Thread> threads(MAX_THREADS); for (unsigned t=0; t<MAX_THREADS; t++) { threads[t] = Thread(); } // Set the kernelname and include a counter std::string kernelname; if (kernel_id < 10) { kernelname = benchname+"_0"+std::to_string(kernel_id); } else { kernelname = benchname+"_" +std::to_string(kernel_id); } // Load a memory access trace from a file Dim3 blockdim = read_file(threads, kernelname, benchname, suitename); unsigned blocksize = blockdim.x*blockdim.y*blockdim.z; // There was not a single trace that could be found - exit with an error if (blocksize == 0 && kernel_id == 0) { std::cout << "### Error: could not read file 'output/" << benchname << "/" << kernelname << ".trc'" << std::endl; message(""); std::cout << SPLIT_STRING << std::endl; exit(1); } // The final tracefile is already processed, exit the loop if (blocksize == 0) { break; } // Assign threads to warps, threadblocks and GPU cores message(""); std::cout << "### Assigning threads to warps/blocks/cores..."; unsigned num_blocks = ceil(threads.size()/(float)(blocksize)); unsigned num_warps_per_block = ceil(blocksize/(float)(hardware.warp_size)); std::vector<std::vector<unsigned>> warps(num_warps_per_block*num_blocks); std::vector<std::vector<unsigned>> blocks(num_blocks); std::vector<std::vector<unsigned>> cores(hardware.num_cores); schedule_threads(threads, warps, blocks, cores, hardware, blocksize); std::cout << "done" << std::endl; // Model only a single core, modelling multiple cores requires a loop over 'cid' unsigned cid = 0; // Compute the number of active blocks on this core unsigned hardware_max_active_blocks = std::min(hardware.max_active_threads/blocksize, hardware.max_active_blocks); unsigned active_blocks = std::min((unsigned)cores[cid].size(), hardware_max_active_blocks); // Start the computation of the reuse distance profile message(""); std::cout << "### [core " << cid << "]:" << std::endl; std::cout << "### Running " << active_blocks << " block(s) at a time" << std::endl; std::cout << "### Calculating the reuse distances"; // Create a Gaussian distribution to model memory latencies std::random_device random; std::mt19937 gen(random()); // Compute the reuse distance for 4 different cases std::vector<map_type<unsigned,unsigned>> distances(NUM_CASES); for (unsigned runs = 0; runs < NUM_CASES; runs++) { std::cout << "..."; unsigned sets, ways; unsigned ml, ms, nml; unsigned mshr; // CASE 0 | Normal - full model sets = hardware.cache_sets; ways = hardware.cache_ways; ml = hardware.mem_latency; ms = hardware.mem_latency_stddev; nml = NON_MEM_LATENCY; mshr = hardware.num_mshr; // CASE 1 | Only 1 set: don't model associativity if (runs == 1) { sets = 1; ways = hardware.cache_ways*hardware.cache_sets; } // CASE 2 | Memory latency to 0: don't model latencies if (runs == 2) { ml = 0; ms = 0; nml = 0; } // CASE 3 | MSHR count to infinite: don't model MSHRs if (runs == 3) { mshr = INF; } // Calculate the reuse distance profile std::normal_distribution<> distribution(0,ms); reuse_distance(cores[cid], blocks, warps, threads, distances[runs], active_blocks, hardware, sets, ways, ml, nml, mshr, gen, distribution); } std::cout << "done" << std::endl; // Process the reuse distance profile to obtain the cache hit/miss rate message(""); output_miss_rate(distances, kernelname, benchname,suitename, hardware); // Display the cache hit/miss rate from the output of the verifier (if available) message(""); verify_miss_rate(kernelname, benchname); message(""); } // End of the program std::cout << SPLIT_STRING << std::endl; return 0; }
void DisplayWindowCreator::set_min_max( int num_display_window, double mi, double ma ) { if ( not displays.contains( num_display_window ) ) displays[ num_display_window ].painter.load_settings( get_settings() ); displays[ num_display_window ].painter.set_min_max( mi, ma ); }
void DisplayWindowCreator::add_paint_function( int num_display_window, void *make_tex_function, void *paint_function, void *bounding_box_function, void *data ) { if ( not displays.contains( num_display_window ) ) displays[ num_display_window ].painter.load_settings( get_settings() ); displays[ num_display_window ].painter.add_paint_function( make_tex_function, paint_function, bounding_box_function, data ); }
int main(int argc, char **argv) { int ret = EXIT_FAILURE; struct prog_settings settings = { .letter_file = "grammar/letters.in", .token_file = "grammar/tokens.in", .keyword_file = "grammar/keywords.in", .grammar_file = "grammar/grammar.in", .input_file = "test.file", .k = 1, }; if (get_settings(argc, argv, &settings)) return EXIT_FAILURE; if (sh_lexer_init(&lexer)) return EXIT_FAILURE; if (test_init_lexer(&lexer, &settings)) goto exit_cleanup_lexer; #if DO_LEX /* the code below tests functionality of the lexer alone */ test_print_tokens(&lexer, DO_LEX_DETAILED); #endif if (sh_parser_init(&parser)) goto exit_cleanup_lexer; #if DO_PARSE sh_parser_ambiguity_resolution(&parser, SH_PARSER_ACCEPT_SHIFT); if (test_init_parser(&parser, &lexer, &settings, SH_PARSER_LRK)) goto exit_cleanup_parser; /* give parser callbacks */ sh_parser_set_action_routine(&parser, "@init", init); sh_parser_set_action_routine(&parser, "@print_result", print_result); sh_parser_set_action_routine(&parser, "@push_variable_in_stack_possibly_new", push_variable_in_stack_possibly_new); sh_parser_set_action_routine(&parser, "@store_in_variable", store_in_variable); sh_parser_set_action_routine(&parser, "@push_op_in_stack", push_op_in_stack); sh_parser_set_action_routine(&parser, "@compute", compute); sh_parser_set_action_routine(&parser, "@push_variable_in_stack", push_variable_in_stack); sh_parser_set_action_routine(&parser, "@push_number_in_stack", push_number_in_stack); sh_parser_set_action_routine(&parser, "@negate", negate); sh_parser_set_action_routine(&parser, "@possibly_ignore_if", possibly_ignore_if); sh_parser_set_action_routine(&parser, "@possibly_ignore_else", possibly_ignore_else); sh_parser_set_action_routine(&parser, "@if_part_over", if_part_over); sh_parser_set_action_routine(&parser, "@else_part_over", else_part_over); sh_parser_set_action_routine(&parser, "@if_finished", if_finished); if (semantics_init(&parser)) { fprintf(stderr, "error: out of memory\n"); goto exit_cleanup_parser; } /* do the actual parsing */ if (test_open_file(&lexer, &settings) == 0) test_parse_file(&parser); semantics_free(&parser); #endif ret = 0; exit_cleanup_parser: sh_parser_free(&parser); exit_cleanup_lexer: sh_lexer_free(&lexer); return ret; }
void disconnection_alert_event(void * p_event_data, uint16_t event_size) { if (get_settings(CONFIG_DISCONNECT_ALERT)) vibration_vibrate(DISCONNECTION_ALERT, 0x0600, false); }
/* PAM hook for AUTH * other auth required pam_globus.so */ int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { settings_t *settings = get_settings(pamh, "auth", NULL); int result = PAM_AUTH_ERR; /* Default to failure in case of bugs */ int rc; bool already = false; const char *user, *pass; msg(settings->ctx, LOG_INFO, "%s@%s: authenticate %s@%s", settings->ctx->svc, settings->ctx->uts.nodename, settings->ctx->user, settings->ctx->rhost); rc = pam_get_user(pamh, &user, "Globus Username: "******"%s@%s: cannot obtain username", settings->ctx->svc, settings->ctx->uts.nodename); return rc; } rc = pam_set_item(pamh, PAM_USER, user); if (rc != PAM_SUCCESS) { msg(settings->ctx, LOG_ERR, "%s@%s: cannot set username", settings->ctx->svc, settings->ctx->uts.nodename); return PAM_AUTHINFO_UNAVAIL; } //msg(settings->ctx, LOG_INFO, "checkpoint 1"); /* If options request using inherited authentication tokens: */ if (settings->use_first || settings->try_first) { /* Get current authentication token, if present. */ pam_get_item(pamh, PAM_AUTHTOK, (const void **)&pass); //msg(settings->ctx, LOG_INFO, "checkpoint 2"); /* If authtok exists, try to authenticate with the old authtok. */ if (pass) { rc = globus_authenticate(NEXUSBASE, user, pass); //msg(settings->ctx, LOG_INFO, "auth: %d", rc); if (rc == PAM_SUCCESS) return PAM_SUCCESS; } //msg(settings->ctx, LOG_INFO, "checkpoint 3"); /* If we required inherited authtoks, fail now. */ if (settings->use_first) return rc; already = true; /* already prompted user */ } //msg(settings->ctx, LOG_INFO, "checkpoint 4"); /* Prompt for a token and try it. */ { struct pam_message pmsg, *pmsgp; struct pam_response *resp; const struct pam_conv *conv; pmsg.msg_style = PAM_PROMPT_ECHO_OFF; pmsg.msg = already ? "Globus Password: "******"Password: "******"checkpoint 5"); rc = pam_get_item(pamh, PAM_CONV, (const void **)&conv); if (rc != PAM_SUCCESS) { free_settings(settings); return rc; } //msg(settings->ctx, LOG_INFO, "checkpoint 6"); conv->conv(1, (const struct pam_message **)&pmsgp, &resp, conv->appdata_ptr); if (resp == NULL) { free_settings(settings); return PAM_CONV_ERR; } //msg(settings->ctx, LOG_INFO, "checkpoint 7"); if ((flags & PAM_DISALLOW_NULL_AUTHTOK) && resp[0].resp == NULL) { free(resp); free_settings(settings); return PAM_AUTHTOK_ERR; } //msg(settings->ctx, LOG_INFO, "checkpoint 8"); rc = globus_authenticate(NEXUSBASE, user, resp[0].resp); //msg(settings->ctx, LOG_INFO, "auth: %d", rc); if (rc == PAM_SUCCESS) { rc = pam_set_item(pamh, PAM_AUTHTOK, resp[0].resp); result = rc; } //msg(settings->ctx, LOG_INFO, "checkpoint 9"); resp[0].resp = NULL; free(resp); } //msg(settings->ctx, LOG_INFO, "checkpoint 10"); free_settings(settings); return result; }
INPUT_HANDLE func_open( LPSTR file ) { lsmash_handler_t *hp = (lsmash_handler_t *)lw_malloc_zero( sizeof(lsmash_handler_t) ); if( !hp ) return NULL; hp->video_reader = READER_NONE; hp->audio_reader = READER_NONE; get_settings(); if( reader_opt.threads <= 0 ) reader_opt.threads = get_auto_threads(); extern lsmash_reader_t libavsmash_reader; extern lsmash_reader_t avs_reader; extern lsmash_reader_t vpy_reader; extern lsmash_reader_t libav_reader; extern lsmash_reader_t dummy_reader; static lsmash_reader_t *lsmash_reader_table[] = { &libavsmash_reader, &avs_reader, &vpy_reader, &libav_reader, &dummy_reader, NULL }; for( int i = 0; lsmash_reader_table[i]; i++ ) { if( reader_disabled[lsmash_reader_table[i]->type - 1] ) continue; int video_none = 1; int audio_none = 1; lsmash_reader_t reader = *lsmash_reader_table[i]; void *private_stuff = reader.open_file( file, &reader_opt ); if( private_stuff ) { if( !hp->video_private ) { hp->video_private = private_stuff; if( reader.get_video_track && reader.get_video_track( hp ) == 0 ) { hp->video_reader = reader.type; hp->read_video = reader.read_video; hp->is_keyframe = reader.is_keyframe; hp->video_cleanup = reader.video_cleanup; hp->close_video_file = reader.close_file; video_none = 0; } else hp->video_private = NULL; } if( !hp->audio_private ) { hp->audio_private = private_stuff; if( reader.get_audio_track && reader.get_audio_track( hp ) == 0 ) { hp->audio_reader = reader.type; hp->read_audio = reader.read_audio; hp->delay_audio = reader.delay_audio; hp->audio_cleanup = reader.audio_cleanup; hp->close_audio_file = reader.close_file; audio_none = 0; } else hp->audio_private = NULL; } } if( video_none && audio_none ) { if( reader.close_file ) reader.close_file( private_stuff ); } else { if( reader.destroy_disposable ) reader.destroy_disposable( private_stuff ); if( !video_none && reader.prepare_video_decoding && reader.prepare_video_decoding( hp, video_opt ) ) { if( hp->video_cleanup ) { hp->video_cleanup( hp ); hp->video_cleanup = NULL; } hp->video_private = NULL; hp->video_reader = READER_NONE; video_none = 1; } if( !audio_none && reader.prepare_audio_decoding && reader.prepare_audio_decoding( hp, audio_opt ) ) { if( hp->audio_cleanup ) { hp->audio_cleanup( hp ); hp->audio_cleanup = NULL; } hp->audio_private = NULL; hp->audio_reader = READER_NONE; audio_none = 1; } if( video_none && audio_none && reader.close_file ) reader.close_file( private_stuff ); } /* Found both video and audio reader. */ if( hp->video_reader != READER_NONE && hp->audio_reader != READER_NONE ) break; } if( hp->video_reader == hp->audio_reader ) { hp->global_private = hp->video_private; hp->close_file = hp->close_video_file; hp->close_video_file = NULL; hp->close_audio_file = NULL; } if( hp->video_reader == READER_NONE && hp->audio_reader == READER_NONE ) { DEBUG_MESSAGE_BOX_DESKTOP( MB_OK, "No readable video and/or audio stream" ); func_close( hp ); return NULL; } return hp; }
void kermit_send(int fd_out, int fd_in, char *file_list[], int list_size) { unsigned char buffer[0x64], response[0x64]; unsigned char len, seq; int i, file, response_length; char *ptr; tabel = tabelcrc(CRCCCITT); seq = 0; init_alarm(); me.maxl = 79; me.time = 3; me.npad = 0; me.padc = 0x00; me.eol = '\r'; me.qctl = '#'; me.qbin = '&'; me.chkt = '1'; me.rept = '~'; len = 9 + 4; set_settings(buffer, me); set_hf_send_packet(fd_out, fd_in, buffer, len, &seq, 'S', response, &response_length); get_settings(response, &you); for(i = 0; i < list_size; i++) { file = open(file_list[i], O_RDONLY); if(file == -1) { fprintf(stderr, "sender: the file %s could not be opened\n", file_list[i]); continue; } ptr = strrchr(file_list[i], '/'); if(ptr == NULL) { len = strlen(file_list[i]); memcpy(buffer + 4, file_list[i], len); } else { len = strlen(ptr + 1); memcpy(buffer + 4, ptr + 1, len); } len += 4; set_hf_send_packet(fd_out, fd_in, buffer, len, &seq, 'F', response, &response_length); fprintf(stderr, "sender: sending file %s\n", file_list[i]); send_file_data(fd_out, fd_in, file, &seq); len = 4; set_hf_send_packet(fd_out, fd_in, buffer, len, &seq, 'Z', response, &response_length); close(file); } len = 4; set_hf_send_packet(fd_out, fd_in, buffer, len, &seq, 'B', response, &response_length); free(tabel); }
int main(int argc, char **argv) { int ret = EXIT_FAILURE; struct prog_settings settings = { .letter_file = "grammar/letters.in", .token_file = "grammar/tokens.in", .keyword_file = "grammar/keywords.in", .grammar_file = "grammar/grammar.in", .input_file = "test.file", .k = 1, }; if (get_settings(argc, argv, &settings)) return EXIT_FAILURE; if (sh_lexer_init(&lexer)) return EXIT_FAILURE; if (test_init_lexer(&lexer, &settings)) goto exit_cleanup_lexer; /* redo read file to make sure proper cleanup is done */ if (sh_lexer_file(&lexer, settings.input_file) == SH_LEXER_NO_FILE) { fprintf(stderr, "error: could not open file\n"); goto exit_cleanup_lexer; } #if DO_LEX /* the code below tests functionality of the lexer alone */ test_print_tokens(&lexer, DO_LEX_DETAILED); #endif if (sh_parser_init(&parser)) goto exit_cleanup_lexer; #ifdef DO_PARSE if (test_init_parser(&parser, &lexer, &settings, SH_PARSER_LLK)) goto exit_cleanup_parser; /* give parser callbacks */ sh_parser_set_action_routine(&parser, "@init", init); sh_parser_set_action_routine(&parser, "@print_result", print_result); sh_parser_set_action_routine(&parser, "@push_op_in_stack", push_op_in_stack); sh_parser_set_action_routine(&parser, "@compute", compute); sh_parser_set_action_routine(&parser, "@push_number_in_stack", push_number_in_stack); sh_parser_set_action_routine(&parser, "@negate", negate); if (semantics_init(&parser)) { fprintf(stderr, "error: out of memory\n"); goto exit_cleanup_parser; } /* do the actual parsing */ if (test_open_file(&lexer, &settings) == 0) test_parse_file(&parser); /* continue the parse from stdin, to make sure it switches over and everything is ok */ if (sh_lexer_interactive(&lexer, NULL, "stdin", NULL) != SH_LEXER_SUCCESS) fprintf(stderr, "error: failed to initialize lexer in interactive mode\n"); else test_parse_file(&parser); semantics_free(&parser); #endif ret = 0; exit_cleanup_parser: sh_parser_free(&parser); exit_cleanup_lexer: sh_lexer_free(&lexer); return ret; }