static int disk_info(playa_info_t *info, disk68_t *d) { char tmp[256]; music68_t *mus = 0; /* SDDEBUG("disk info [%p]\n", d); */ if (!d) { return update_info(info, app.cur_disk, app.cur_mus, tmp); } /* SDDEBUG("disk info...\n"); */ if (mus = app.cur_mus, !mus) { mus = d->mus + d->default_six; } update_info(info, d, mus, tmp); playa_info_bits(info,1); playa_info_stereo(info,1); playa_info_frq(info, (int)app.mix.real_frq); playa_info_bps(info,0); playa_info_bytes(info,0); playa_info_album(info,d->name); playa_info_year(info,0); playa_info_genre(info,"chip-tune"); playa_info_comments(info,0); return 0; }
void transcode_stream::close() { std::istream::rdbuf(nullptr); if (process) { update_info_timer.stop(); if (process->joinable()) { // Flush pipe to prevent deadlock while stopping player. std::thread flush([this] { while (*process) process->get(); }); process->send_term(); process->join(); flush.join(); } update_info(); process = nullptr; last_info = nullptr; info_offset = unsigned(-1); } }
blargg_err_t Zip_Extractor::seek_arc_v( fex_pos_t pos ) { assert( 0 <= pos && (size_t) pos <= catalog.size() - end_entry_size ); catalog_pos = pos; return update_info( false ); }
int SSG_Planet::update(float dt) { double time = dt / 1000.f; this->finishPhysicsCycle(dt); assert(!std::isnan(x().get_d())); assert(!std::isnan(y().get_d())); //printf("Velocity is %f|%f\n", this->getVelocity().getVector().x.get_d(), this->getVelocity().getVector().y.get_d()); mpf_class ex1 = this->x().get_d() + this->getVelocity().getVector().x.get_d() * time; mpf_class ex2 = this->y().get_d() + this->getVelocity().getVector().y.get_d() * time; float test1 = float(ex1.get_d()); float test2 = float(ex2.get_d()); //We can lose precision, so if the precision is too small, just ignore everything if (!(std::isnan(test1) || std::isinf(test1)) && !(std::isnan(test2) || std::isinf(test2))) { this->setPosition(ex1, ex2); assert(!std::isnan(x().get_d())); assert(!std::isnan(y().get_d())); } //std::cout << "Vel (" << this->getVelocity().getVector().x << "|" << this->getVelocity().getVector().y << ")" << std::endl; //std::cout << "Loc (" << this->x() << "|" << this->y() << ")" << std::endl; update_info(dt); return 0; }
// Update the main window to show snoozing, smart alarm monitoring, or Get Out Of Bed alarm monitoring void show_status(time_t alarm_time, status_enum status) { s_onoff_mode = MODE_ACTIVE; stop_autoclose_timer(); switch (status) { case S_Snoozing: set_onoff_text("SNOOZING"); break; case S_SmartMonitoring: set_onoff_text("SMART ALARM\nACTIVE"); break; case S_GooBMonitoring: set_onoff_text("GET OUT OF BED\nMONITORING"); break; case S_GooBSnooze: set_onoff_text("SNOOZING\nGET OUT OF BED\nMONITORING"); break; } struct tm *t = localtime(&alarm_time); char time_str[8]; gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str)); char info[40]; snprintf(info, sizeof(info), "%s: %s\n2 clicks to stop", (status == S_Snoozing ? "Until" : "Alarm"), time_str); update_info(info); action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); cl = new dhcp_client; connect(cl, SIGNAL(update_info()), this, SLOT(update_gui())); }
int main(int argc, char** argv) { ToxGroup *g; if(argc != 1 && argc != 3) { printf("Usage: %s [ip port]\n", argv[0]); return 1; } curses_init(); if(argc == 3) { uint32_t ip; uint16_t port; inet_pton(AF_INET, argv[1], &ip); port = strtol(argv[2], NULL, 0); g = toxgroup_new_bootstrap(ip, port); } else { g = toxgroup_new(); } update_info(g); g->peer_callback = peer_callback; g->message_callback = message_callback; int z = 0; while(1) { toxgroup_do(g); do_input(g); if(info_change) { update_info(g); info_change = 0; } usleep(500); z++; if(z == 2000) { if(send_audio) {toxgroup_sendaudio(g);} z = 0; } } return 0; }
void select_scanned_file_dlg::on_file_selected(wxListEvent &) { auto selected = m_lc_files->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (-1 == selected) return; m_selected_playlist_idx = m_lc_files->GetItemData(selected); update_info(); }
static int decode_packet(struct dec_audio *da) { struct ad_mpg123_context *con = da->priv; int ret; mp_audio_set_null_data(&da->decoded); struct demux_packet *pkt; if (demux_read_packet_async(da->header, &pkt) == 0) return AD_WAIT; if (!pkt) return AD_EOF; /* Next bytes from that presentation time. */ if (pkt->pts != MP_NOPTS_VALUE) { da->pts = pkt->pts; da->pts_offset = 0; } /* Have to use mpg123_feed() to avoid decoding here. */ ret = mpg123_feed(con->handle, pkt->buffer, pkt->len); talloc_free(pkt); if (ret != MPG123_OK) goto mpg123_fail; unsigned char *audio = NULL; size_t bytes = 0; ret = mpg123_decode_frame(con->handle, NULL, &audio, &bytes); if (ret == MPG123_NEED_MORE) return 0; if (ret != MPG123_OK && ret != MPG123_DONE && ret != MPG123_NEW_FORMAT) goto mpg123_fail; ret = set_format(da); if (ret != MPG123_OK) goto mpg123_fail; if (con->sample_size < 1) { MP_ERR(da, "no sample size\n"); return AD_ERR; } int got_samples = bytes / con->sample_size; da->decoded.planes[0] = audio; da->decoded.samples = got_samples; update_info(da); return 0; mpg123_fail: MP_ERR(da, "mpg123 decoding error: %s\n", mpg123_strerror(con->handle)); return AD_ERR; }
static void inbox_received_callback (DictionaryIterator* iterator, void* context) { APP_LOG(APP_LOG_LEVEL_INFO, "Message received."); t_sound_level = (int32_t) dict_find (iterator, KEY_SOUND_LVL)->value->int32; t_mute_status = (int32_t) dict_find (iterator, KEY_MUTE_STATUS)->value->int32; t_power_status = (int32_t) dict_find (iterator, KEY_POWER_STATUS)->value->int32; strcpy(t_current_source, (char*) dict_find (iterator, KEY_CURRENT_SOURCE)->value->cstring); update_info (); }
bool TmsiAmplifier::_refreshInfo(int type) { int counter = 0; while (counter++ < 20) { send_request(type); if (br < 0 || tms_chk_msg(msg, br) != 0) fprintf(stderr, "Error while receiving message (%d)", br); else if (update_info(type)) return true; } fprintf(stderr, "Could not receive proper %s!!\n",get_type_name(type)); return false; }
static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxlen) { struct ad_mpg123_context *con = da->priv; void *buf = buffer->planes[0]; int ret; if (con->new_format) { ret = set_format(da); if (ret == MPG123_OK) { return 0; // let caller handle format change } else if (ret == MPG123_NEED_MORE) { con->need_data = true; } else { goto mpg123_fail; } } if (con->need_data) { if (feed_new_packet(da) < 0) return -1; } if (!mp_audio_config_equals(&da->decoded, buffer)) return 0; size_t got_now = 0; ret = mpg123_replace_buffer(con->handle, buf, maxlen * con->sample_size); if (ret != MPG123_OK) goto mpg123_fail; ret = mpg123_decode_frame(con->handle, NULL, NULL, &got_now); int got_samples = got_now / con->sample_size; buffer->samples += got_samples; da->pts_offset += got_samples; if (ret == MPG123_NEW_FORMAT) { con->new_format = true; } else if (ret == MPG123_NEED_MORE) { con->need_data = true; } else if (ret != MPG123_OK && ret != MPG123_DONE) { goto mpg123_fail; } update_info(da); return 0; mpg123_fail: MP_ERR(da, "mpg123 decoding error: %s\n", mpg123_strerror(con->handle)); return -1; }
void show_alarm_ui(bool on) { if (on) { s_onoff_mode = MODE_ACTIVE; set_onoff_text("WAKEY! WAKEY!"); update_info("Click to snooze\n2 clicks to stop "); action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze); } else { update_onoff(s_alarms_on); action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_standby); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_settings); } }
void show_snooze(time_t snooze_time) { s_onoff_mode = MODE_ACTIVE; set_onoff_text("SNOOZING"); struct tm *t = localtime(&snooze_time); char time_str[8]; gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str)); char info[40]; snprintf(info, sizeof(info), "Until: %s\n2 clicks to stop", time_str); update_info(info); action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze); }
void terrain_label::update_info(const t_string& text, const int creator, const t_string& tooltip, const std::string& team_name, const SDL_Color color, const bool visible_in_fog, const bool visible_in_shroud, const bool immutable, const std::string& category) { visible_in_fog_ = visible_in_fog; visible_in_shroud_ = visible_in_shroud; immutable_ = immutable; category_ = category; update_info(text, creator, tooltip, team_name, color); }
void show_monitoring(time_t alarm_time) { s_onoff_mode = MODE_ACTIVE; set_onoff_text("SMART ALARM ACTIVE"); struct tm *t = localtime(&alarm_time); char time_str[8]; gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str)); char info[40]; snprintf(info, sizeof(info), "Alarm: %s\n2 clicks to stop", time_str); update_info(info); action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze); }
static void do_events(s_game *game, s_perso **persos, s_sound *sounds) { SDL_Event event; int t1 = 0; while (1) { handle_time(game, &t1, 1, persos); update_grid(game, persos); update_board(game, persos, sounds); update_info(game, persos); update_items(game, persos); SDL_PollEvent(&event); input_actions(game, event, persos, sounds); SDL_BlitSurface(game->help_s, NULL, game->screen, &game->help_r); SDL_Flip(game->screen); game->trigger = 0; } }
void TmsiAmplifier::start_sampling() { if (fd < 0) return; fei.mode &= 0x10; fei.currentsampleratesetting = sample_rate_div&0xFFFF; br = 0; keep_alive=1; int counter = 0; int type; signal(SIGINT,handler); signal(SIGTERM,handler); tms_write_frontendinfo(fd, &fei); receive(); while (counter < sampling_rate && (!update_info(TMSACKNOWLEDGE))) { counter++; if (counter%(sampling_rate/4)==0 || read_errors==MAX_ERRORS/2) { fprintf(stderr,"Sending start request again....\n"); tms_write_frontendinfo(fd,&fei); } receive(); type = tms_get_type(msg, br); //if (type == TMSCHANNELDATA || type == TMSVLDELTADATA) break; } if (ack.errorcode != 0) { tms_prt_ack(stderr, &ack); tms_prt_frontendinfo(stderr, &fei, 0, 1); } while (type != TMSCHANNELDATA && type != TMSVLDELTADATA) { receive(); type = tms_get_type(msg, br); } sampling=true; free_channel_data(channel_data); channel_data = alloc_channel_data(type == TMSVLDELTADATA); }
static void redraw_all(void) { ENTER("redraw_all()"); int must_update = 0; if(zone_to_refresh!=-1) { gmt_h = -1; /* force redraw time bar */ update_info(zone_to_refresh); must_update |= redraw_world(zone_to_refresh); must_update |= update_time(zone_to_refresh); current_zone = zone_to_refresh; zone_to_refresh = -1; } else { must_update |= update_time(current_zone); } if(must_update) { update(); } LEAVE; }
blargg_err_t Zip_Extractor::next_v() { return update_info( true ); }
void UpdateElement::updt() { emit update_info(); }
static void tcpip_handler(void) { static uint8_t *appdata=NULL; short int code=0; int j=0; uint8_t isme=0; //printf("size of %d %d %d \n ",sizeof(int),sizeof(short int), sizeof(char)); if(uip_newdata()) { appdata = (uint8_t *) uip_appdata; MAPPER_GET_PACKETDATA(code,appdata); switch(code) { case 1: add_node(appdata); break; case 2: //adding neighbor info and ranks j=update_info(appdata); //printf("updating node info by unicast \n"); if(j==2) { printf("Duplicate packet returning\n"); return; } if(etimer_expired(&nw_settle_timer) && attack_processing==0) //if nw settle timer expires then only chk for attack { //currently no victims MAPPER_GET_PACKETDATA(node_to_v,appdata); process_start(&validatepc_process, NULL); } break; case 5: rssi_received(appdata); break; case 3://victim packet code+dest+collouge printf("victim packet received\n"); if(last_target==0 && monitor==0) { //monitor==0 ){ printf("I am Vtm or mntring for sus\n"); MAPPER_GET_PACKETDATA(isme,appdata); MAPPER_GET_PACKETDATA(monitor_target,appdata); if(isme!=myip.u8[15] ) { printf("not 4 me\n"); if(rssi_stored==3) return; suspect_monitor(isme,monitor_target); return; } process_start(&monitor_process, NULL); } else { printf("re received victim\n"); } break; } } if(monitor && (monitor_target==UIP_IP_BUF->srcipaddr.u8[15])) { printf("RSSI %d\n",packetbuf_attr(PACKETBUF_ATTR_RSSI) - 45); mrssi[rssi_stored]=packetbuf_attr(PACKETBUF_ATTR_RSSI) - 45; rssi_stored++; } //uip_udp_packet_sendto(server_conn, "p", sizeof("p"), &UIP_IP_BUF->srcipaddr, UIP_HTONS(12345)); //uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); //uip_udp_packet_send(server_conn, "Reply", sizeof("Reply")); //uip_create_unspecified(&server_conn->ripaddr); }
select_scanned_file_dlg::select_scanned_file_dlg(wxWindow *parent, std::vector<playlist_file_cptr> const &playlists, wxString const &orig_file_name) : wxDialog(parent, wxID_ANY, Z("Select file to add"), wxDefaultPosition, wxSize{1000, 650}) , m_playlists{playlists} , m_selected_playlist_idx{0} { // controls left column auto st_scanned_files = new wxStaticText(this, wxID_ANY, Z("Scanned files")); auto sl_left = new wxStaticLine(this); m_lc_files = new wxListCtrl( this, ID_LC_PLAYLIST_FILE, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); // controls right column auto st_details = new wxStaticText(this, wxID_ANY, Z("Details")); auto sl_right = new wxStaticLine(this); auto st_duration = new wxStaticText(this, wxID_ANY, Z("Duration:")); m_st_duration = new wxStaticText(this, wxID_ANY, wxEmptyString); auto st_size = new wxStaticText(this, wxID_ANY, Z("Size:")); m_st_size = new wxStaticText(this, wxID_ANY, wxEmptyString); auto st_chapters = new wxStaticText(this, wxID_ANY, Z("Number of chapters:")); m_st_chapters = new wxStaticText(this, wxID_ANY, wxEmptyString); auto st_tracks = new wxStaticText(this, wxID_ANY, Z("Tracks:")); m_lc_tracks = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); auto st_playlist_items = new wxStaticText(this, wxID_ANY, Z("Playlist items:")); m_lc_items = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); // button controls auto b_add = new wxButton(this, wxID_OK, Z("&Add")); auto b_cancel = new wxButton(this, wxID_CANCEL, Z("&Cancel")); b_add->SetDefault(); // list controls wxListItem item; item.SetText(Z("File name")); m_lc_files->InsertColumn(0, item); item.SetText(Z("Duration")); m_lc_files->InsertColumn(1, item); item.SetText(Z("Size")); m_lc_files->InsertColumn(2, item); item.SetText(Z("Type")); m_lc_tracks->InsertColumn(0, item); item.SetText(Z("Codec")); m_lc_tracks->InsertColumn(1, item); item.SetText(Z("Language")); m_lc_tracks->InsertColumn(2, item); item.SetText(Z("File name")); m_lc_items->InsertColumn(0, item); item.SetText(Z("Directory")); m_lc_items->InsertColumn(1, item); // fill "files" with data m_lc_files->Hide(); long idx = 0; for (auto &playlist : m_playlists) { auto id = m_lc_files->InsertItem(idx, wxFileName{playlist->file_name}.GetFullName()); m_lc_files->SetItem(id, 1, wxU(format_timecode(playlist->duration, 0))); m_lc_files->SetItem(id, 2, wxU(format_file_size(playlist->size))); m_lc_files->SetItemData(id, idx); if (orig_file_name == playlist->file_name) { m_lc_files->SetItemState(id, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); m_selected_playlist_idx = idx; } ++idx; } m_lc_files->SetColumnWidth(0, wxLIST_AUTOSIZE); m_lc_files->SetColumnWidth(1, wxLIST_AUTOSIZE); m_lc_files->SetColumnWidth(2, wxLIST_AUTOSIZE); m_lc_files->Show(); // layout auto siz_left_column = new wxBoxSizer(wxVERTICAL); siz_left_column->Add(st_scanned_files, 0, wxALL, 5); siz_left_column->Add(sl_left, 0, wxALL | wxEXPAND, 5); siz_left_column->Add(m_lc_files, 1, wxALL | wxEXPAND, 5); auto siz_info = new wxGridSizer(3, 2, 0, 0); siz_info->Add(st_duration, 0, wxALL, 5); siz_info->Add(m_st_duration, 0, wxALL, 5); siz_info->Add(st_size, 0, wxALL, 5); siz_info->Add(m_st_size, 0, wxALL, 5); siz_info->Add(st_chapters, 0, wxALL, 5); siz_info->Add(m_st_chapters, 0, wxALL, 5); auto siz_right_column = new wxBoxSizer(wxVERTICAL); siz_right_column->Add(st_details, 0, wxALL, 5); siz_right_column->Add(sl_right, 0, wxEXPAND | wxALL, 5); siz_right_column->Add(siz_info, 0, wxEXPAND, 5); siz_right_column->Add(st_tracks, 0, wxALL, 5); siz_right_column->Add(m_lc_tracks, 1, wxALL | wxEXPAND, 5); siz_right_column->Add(st_playlist_items, 0, wxALL, 5); siz_right_column->Add(m_lc_items, 1, wxALL | wxEXPAND, 5); auto siz_columns = new wxBoxSizer(wxHORIZONTAL); siz_columns->Add(siz_left_column, 1, wxEXPAND, 5); siz_columns->Add(siz_right_column, 1, wxEXPAND, 5); auto siz_buttons = new wxBoxSizer(wxHORIZONTAL); siz_buttons->AddStretchSpacer(); siz_buttons->Add(b_add, 0, wxALL, 5); siz_buttons->AddStretchSpacer(); siz_buttons->Add(b_cancel, 0, wxALL, 5); siz_buttons->AddStretchSpacer(); auto siz_all = new wxBoxSizer(wxVERTICAL); siz_all->Add(siz_columns, 1, wxEXPAND, 5); siz_all->Add(siz_buttons, 0, wxEXPAND, 5); SetSizer(siz_all); Layout(); Centre(wxBOTH); update_info(); }
/* * routine: * do_rename * * purpose: * to propagate a rename * * parameters: * file pointer for the new name * src/dst indication for which side gets changed * * returns: * error mask */ errmask_t do_rename(struct file *fp, side_t srcdst) { int rc; struct file *pp = fp->f_previous; struct base *bp = fp->f_base; errmask_t errs = 0; char *errstr = "???"; char *newname; char *oldname; struct stat statb; /* see if this is a forbidden propagation */ if (srcdst == opt_oneway) { fp->f_problem = gettext(PROB_prohibited); /* if we can't resolve the TO, the FROM is also unresolved */ pp->f_problem = gettext(PROB_prohibited); pp->f_flags |= F_CONFLICT; bp->b_unresolved++; return (ERR_UNRESOLVED); } newname = (srcdst == OPT_SRC) ? srcname : dstname; oldname = full_name(pp, srcdst, OPT_BASE); if (!opt_quiet) fprintf(stdout, "%s %s %s\n", (fp->f_info[0].f_type == S_IFDIR) ? "mvdir" : "mv", noblanks(oldname), noblanks(newname)); #ifdef DBG_ERRORS /* should we simulate a rename failure */ if (errno = dbg_chk_error(oldname, 'm')) rc = -1; else #endif rc = opt_notouch ? 0 : rename(oldname, newname); if (opt_debug & DBG_RECON) fprintf(stderr, "RECO: do_rename %s %s -> %d(%d)\n", oldname, newname, rc, errno); /* if we succeed, update the baseline */ if (rc == 0) if (!opt_notouch) { errstr = gettext(PROB_restat); #ifdef DBG_ERRORS /* should we simulate a restat failure */ if (errno = dbg_chk_error(newname, 'S')) rc = -1; else #endif rc = lstat(newname, &statb); if (rc == 0) { note_info(fp, &statb, srcdst); link_update(fp, srcdst); update_info(fp, srcdst); } } else { /* * BOGOSITY ALERT * in order for link tests to work in notouch * mode we have to dummy up some updated status */ fp->f_info[srcdst].f_ino = pp->f_info[srcdst].f_ino; fp->f_info[srcdst].f_nlink = pp->f_info[srcdst].f_nlink; fp->f_info[srcdst].f_type = pp->f_info[srcdst].f_type; fp->f_info[srcdst].f_size = pp->f_info[srcdst].f_size; fp->f_info[srcdst].f_mode = pp->f_info[srcdst].f_mode; fp->f_info[srcdst].f_uid = pp->f_info[srcdst].f_uid; fp->f_info[srcdst].f_gid = pp->f_info[srcdst].f_gid; update_info(fp, srcdst); } else errstr = gettext(PROB_rename2); if (rc == 0) { pp->f_flags |= F_REMOVE; if (srcdst == OPT_SRC) { bp->b_src_copies++; bp->b_src_deletes++; } else { bp->b_dst_copies++; bp->b_dst_deletes++; } errs |= ERR_RESOLVABLE; } else { fprintf(stderr, gettext(ERR_cannot), errstr, oldname); bp->b_unresolved++; fp->f_flags |= F_CONFLICT; pp->f_flags |= F_CONFLICT; fp->f_problem = errstr; pp->f_problem = gettext(PROB_rename); errs |= ERR_PERM | ERR_UNRESOLVED; } return (errs); }
/* * routine: * do_copy * * purpose: * to propagate a creation or change * * parameters: * file pointer * src/dst indication for who gets the copy * * returns: * error mask * * note: * after any successful operation we update the stat/info * structure for the updated file. This is somewhat redundant * because we will restat at the end of the routine, but these * anticipatory updates help to ensure that the link finding * code will still behave properly in notouch mode (when restats * cannot be done). */ errmask_t do_copy(struct file *fp, side_t srcdst) { char *src, *dst; char cmdbuf[ MAX_PATH + MAX_NAME ]; int mode, maj, min, type; uid_t uid; gid_t gid; int rc; long mtime; int do_chmod = 0; int do_chown = 0; int do_chgrp = 0; int do_unlink = 0; int do_acls = 0; int do_create = 0; char *errstr = "???"; errmask_t errs = 0; struct base *bp; struct file *lp; struct fileinfo *sp, *dp; struct utimbuf newtimes; struct stat statb; bp = fp->f_base; /* see if this is a forbidden propagation */ if (srcdst == opt_oneway) { fp->f_problem = gettext(PROB_prohibited); fp->f_flags |= F_CONFLICT; bp->b_unresolved++; return (ERR_UNRESOLVED); } /* figure out who is the source and who is the destination */ if (srcdst == OPT_SRC) { sp = &fp->f_info[ OPT_DST ]; dp = &fp->f_info[ OPT_SRC ]; src = dstname; dst = srcname; } else { sp = &fp->f_info[ OPT_SRC ]; dp = &fp->f_info[ OPT_DST ]; src = srcname; dst = dstname; } /* note information about the file to be created */ type = sp->f_type; /* type of the new file */ uid = sp->f_uid; /* owner of the new file */ gid = sp->f_gid; /* group of the new file */ mode = sp->f_mode; /* modes for the new file */ mtime = sp->f_modtime; /* modtime (if preserving) */ maj = sp->f_rd_maj; /* major (if it is a device) */ min = sp->f_rd_min; /* minor (if it is a device) */ /* * creating a file does not guarantee it will get the desired * modes, uid and gid. If the file already exists, it will * retain its old ownership and protection. If my UID/GID * are not the desired ones, the new file will also require * manual correction. If the file has the wrong type, we will * need to delete it and recreate it. If the file is not writable, * it is easier to delete it than to chmod it to permit overwrite */ if ((dp->f_type == S_IFREG && sp->f_type == S_IFREG) && (dp->f_mode & 0200)) { /* if the file already exists */ if (dp->f_uid != uid) do_chown = 1; if (dp->f_gid != gid) do_chgrp = 1; if (dp->f_mode != mode) do_chmod = 1; } else { /* if we will be creating a new file */ do_create = 1; if (dp->f_type) do_unlink = 1; if (uid != my_uid) do_chown = 1; if (gid != my_gid) do_chgrp = 1; } /* * if the source has acls, we will surely have to set them for dest */ if (sp->f_numacls) do_acls = 1; /* * for any case other than replacing a normal file with a normal * file, we need to delete the existing file before creating * the new one. */ if (do_unlink) { if (dp->f_type == S_IFDIR) { if (!opt_quiet) fprintf(stdout, "rmdir %s\n", noblanks(dst)); errstr = gettext(PROB_rmdir); #ifdef DBG_ERRORS /* should we simulate a rmdir failure */ if (errno = dbg_chk_error(dst, 'D')) rc = -1; else #endif rc = opt_notouch ? 0 : rmdir(dst); } else { if (!opt_quiet) fprintf(stdout, "rm %s\n", noblanks(dst)); errstr = gettext(PROB_unlink); #ifdef DBG_ERRORS /* should we simulate a unlink failure */ if (errno = dbg_chk_error(dst, 'u')) rc = -1; else #endif rc = opt_notouch ? 0 : unlink(dst); } if (rc != 0) goto cant; /* note that this file no longer exists */ dp->f_type = 0; dp->f_mode = 0; } if (opt_debug & DBG_RECON) { fprintf(stderr, "RECO: do_copy %s %s (", src, dst); if (do_unlink) fprintf(stderr, "unlink "); if (do_chmod) fprintf(stderr, "chmod "); if (do_acls) fprintf(stderr, "acls "); if (do_chown) fprintf(stderr, "chown "); if (do_chgrp) fprintf(stderr, "chgrp "); fprintf(stderr, ")\n"); } /* * how we go about copying a file depends on what type of file * it is that we are supposed to copy */ switch (type) { case S_IFDIR: if (!opt_quiet) { fprintf(stdout, "mkdir %s;", noblanks(dst)); fprintf(stdout, " chmod %o %s;\n", mode, noblanks(dst)); } errstr = gettext(PROB_mkdir); #ifdef DBG_ERRORS /* should we simulate a mkdir failure */ if (errno = dbg_chk_error(dst, 'd')) rc = -1; else #endif rc = opt_notouch ? 0 : mkdir(dst, mode); /* update stat with what we have just created */ if (rc == 0) { dp->f_type = S_IFDIR; dp->f_uid = my_uid; dp->f_gid = my_gid; dp->f_mode = mode; } break; case S_IFLNK: errstr = gettext(PROB_readlink); #ifdef DBG_ERRORS /* should we simulate a symlink read failure */ if (errno = dbg_chk_error(dst, 'r')) rc = -1; else #endif rc = readlink(src, cmdbuf, sizeof (cmdbuf)); if (rc > 0) { cmdbuf[rc] = 0; if (!opt_quiet) { fprintf(stdout, "ln -s %s", noblanks(cmdbuf)); fprintf(stdout, " %s;\n", noblanks(dst)); } errstr = gettext(PROB_symlink); #ifdef DBG_ERRORS /* should we simulate a symlink failure */ if (errno = dbg_chk_error(dst, 'l')) rc = -1; else #endif rc = opt_notouch ? 0 : symlink(cmdbuf, dst); if (rc == 0) dp->f_type = S_IFLNK; } break; case S_IFBLK: case S_IFCHR: if (!opt_quiet) fprintf(stdout, "mknod %s %s %d %d\n", noblanks(dst), (type == S_IFBLK) ? "b" : "c", maj, min); errstr = gettext(PROB_mknod); #ifdef DBG_ERRORS /* should we simulate a mknod failure */ if (errno = dbg_chk_error(dst, 'd')) rc = -1; else #endif rc = opt_notouch ? 0 : mknod(dst, mode|type, makedev(maj, min)); /* update stat with what we have just created */ if (rc == 0) { dp->f_type = type; dp->f_uid = my_uid; dp->f_gid = my_gid; dp->f_mode = 0666; if (dp->f_mode != mode) do_chmod = 1; } break; case S_IFREG: /* * The first thing to do is ascertain whether or not * the alleged new copy might in fact be a new link. * We trust find_link to weigh all the various factors, * so if he says make a link, we'll do it. */ lp = find_link(fp, srcdst); if (lp) { /* figure out name of existing file */ src = full_name(lp, srcdst, OPT_BASE); /* * if file already exists, it must be deleted */ if (dp->f_type) { if (!opt_quiet) fprintf(stdout, "rm %s\n", noblanks(dst)); errstr = gettext(PROB_unlink); #ifdef DBG_ERRORS /* should we simulate a unlink failure */ if (errno = dbg_chk_error(dst, 'u')) rc = -1; else #endif rc = opt_notouch ? 0 : unlink(dst); /* * if we couldn't do the unlink, we must * mark the linkee in conflict as well * so his reference count remains the same * in the baseline and he continues to show * up on the change list. */ if (rc != 0) { lp->f_flags |= F_CONFLICT; lp->f_problem = gettext(PROB_link); goto cant; } } if (!opt_quiet) { fprintf(stdout, "ln %s", noblanks(src)); fprintf(stdout, " %s\n", noblanks(dst)); } errstr = gettext(PROB_link); #ifdef DBG_ERRORS /* should we simulate a link failure */ if (errno = dbg_chk_error(dst, 'l')) rc = -1; else #endif rc = opt_notouch ? 0 : link(src, dst); /* * if this is a link, there is no reason to worry * about ownership and modes, they are automatic */ do_chown = 0; do_chgrp = 0; do_chmod = 0; do_acls = 0; if (rc == 0) { dp->f_type = type; dp->f_uid = uid; dp->f_gid = gid; dp->f_mode = mode; break; } else { /* * if we failed to make a link, we want to * mark the linkee in conflict too, so that * his reference count remains the same in * the baseline, and he shows up on the change * list again next time. */ lp->f_flags |= F_CONFLICT; lp->f_problem = errstr; break; } /* * in some situation we haven't figured out yet * we might want to fall through and try a copy * if the link failed. */ } /* we are going to resolve this by making a copy */ if (!opt_quiet) { fprintf(stdout, "cp %s", noblanks(src)); fprintf(stdout, " %s\n", noblanks(dst)); } rc = opt_notouch ? 0 : copy(src, dst, mode); if (rc != 0) { errs |= rc; if (copy_err_str) errstr = copy_err_str; else errstr = gettext(PROB_copy); /* * The new copy (if it exists at all) is a botch. * If this was a new create or a remove and copy * we should get rid of the botched copy so that * it doesn't show up as two versions next time. */ if (do_create) unlink(dst); } else if (dp->f_mode == 0) { dp->f_type = S_IFREG; dp->f_uid = my_uid; dp->f_gid = my_gid; dp->f_mode = mode; /* FIX: inode number is still wrong */ } /* for normal files we have an option to preserve mod time */ if (rc == 0 && opt_notouch == 0 && opt_mtime) { newtimes.actime = mtime; newtimes.modtime = mtime; /* ignore the error return on this one */ (void) utime(dst, &newtimes); } break; default: errstr = gettext(PROB_deal); rc = -1; } /* * if any of the file's attributes need attention, I should let * do_like take care of them, since it knows all rules for who * can and cannot make what types of changes. */ if (rc == 0 && (do_chmod || do_chown || do_chgrp || do_acls)) { rc = do_like(fp, srcdst, FALSE); errstr = fp->f_problem; errs |= rc; } /* * finish off by re-stating the destination and using that to * update the baseline. If we were completely successful in * our chowns/chmods, stating the destination will confirm it. * If we were unable to make all the necessary changes, stating * the destination will make the source appear to have changed, * so that the differences will continue to reappear as new * changes (inconsistancies). */ if (rc == 0) if (!opt_notouch) { errstr = gettext(PROB_restat); #ifdef DBG_ERRORS /* should we simulate a restat failure */ if (errno = dbg_chk_error(dst, 'R')) rc = -1; else #endif rc = lstat(dst, &statb); if (rc == 0) { note_info(fp, &statb, srcdst); link_update(fp, srcdst); if (do_acls) (void) get_acls(dst, dp); update_info(fp, srcdst); } } else { /* * BOGOSITY ALERT * we are in notouch mode and haven't really * done anything, but if we want link detection * to work and be properly reflected in the * what-I-would-do output for a case where * multiple links are created to a new file, * we have to make the new file appear to * have been created. Since we didn't create * the new file we can't stat it, but if * no file exists, we can't make a link to * it, so we will pretend we created a file. */ if (dp->f_ino == 0 || dp->f_nlink == 0) { dp->f_ino = sp->f_ino; dp->f_nlink = 1; } } cant: if (rc != 0) { fprintf(stderr, gettext(ERR_cannot), errstr, dst); bp->b_unresolved++; fp->f_flags |= F_CONFLICT; fp->f_problem = errstr; if (errs == 0) errs = ERR_PERM; errs |= ERR_UNRESOLVED; } else { /* update the statistics */ if (srcdst == OPT_SRC) bp->b_src_copies++; else bp->b_dst_copies++; errs |= ERR_RESOLVABLE; } return (errs); }
void MainWindow::setdie() { srand(time(NULL)); disconnect(sell_button,SIGNAL(clicked()),this,SLOT(sell())); disconnect(buy_button,SIGNAL(clicked()),this,SLOT(purchase())); int y=(rand()%6+1); dice_display[0]->setText(QString::number(y)); int z=(rand()%6+1); dice_display[1]->setText(QString::number(z)); int x=y+z; // x=4;//------------------------------------------------------------------------------------------------------------------- int i=1; std::cout<<"chance is:-"<<chance<<"\n"; chance=chance%number_of_players; show_frames(); update_current_player(); if(chance==0) { prev=index1; while(i<=x) { index1=(index1+1)%32; player[0]->b->setParent(window); player[0]->b->setGeometry(button[index1]->x(),button[index1]->y(),player_width,player_height); player[0]->b->show(); i++; dice->setEnabled(false); delay(); dice->setEnabled(true); } set_current_card(); if(x!=12) { chance=1; } next=index1; if(abs(prev-next)>19) { player[0]->rounds++; player[0]->balance+=1500; } std::cout<<"Index1 is:-"<<index1<<"\n"; update_info(0,index1,x); score_board_update(); after_roll(); //player1_score->setText(QString::number(player[0]->balance)); //setting the value of score-------------- } else if(chance==1) { prev=index2; while(i<=x) { index2=(index2+1)%32; player[1]->b->setParent(window); player[1]->b->setGeometry(button[index2]->x(),button[index2]->y(),player_width,player_height); player[1]->b->show(); i++; dice->setEnabled(false); delay(); dice->setEnabled(true); } set_current_card(); if(x!=12) { chance=2; } next=index2; if(abs(prev-next)>19) { player[1]->rounds++; player[1]->balance+=1500; } update_info(1,index2,x); score_board_update(); after_roll(); //player2_score->setText(QString::number(player[1]->balance)); //setting the value std::cout<<"Index2 is:-"<<index2<<"\n"; } else if(chance==2) { prev=index3; while(i<=x) { index3=(index3+1)%32; player[2]->b->setParent(window); player[2]->b->setGeometry(button[index3]->x(),button[index3]->y(),player_width,player_height); player[2]->b->show(); i++; dice->setEnabled(false); delay(); dice->setEnabled(true); } set_current_card(); if(x!=12) { chance=3; } std::cout<<"Index3 is:-"<<index3<<"\n"; next=index3; if(abs(prev-next)>19) { player[2]->rounds++; player[2]->balance+=1500; } update_info(2,index3,x); score_board_update(); after_roll(); //player3_score->setText(QString::number(player[2]->balance)); } else if(chance==3) { prev=index4; while(i<=x) { index4=(index4+1)%32; player[3]->b->setParent(window); player[3]->b->setGeometry(button[index4]->x(),button[index4]->y(),player_width,player_height); player[3]->b->show(); i++; dice->setEnabled(false); delay(); dice->setEnabled(true); } set_current_card(); if(x!=12) { chance=0; } std::cout<<"Index4 is:-"<<index4<<"\n"; next=index4; if(abs(prev-next)>19) { player[3]->rounds++; player[3]->balance+=1500; } update_info(3,index4,x); score_board_update(); after_roll(); //player4_score->setText(QString::number(player[3]->balance)); } }
int main(void) { uint8_t i; #ifdef DEBUG uart_init(); uart_puts ("\r\nreset\r\ninit port 1\r\n"); #endif // /* uart_puts ("a123\n"); uart_puts ("b456\n"); uart_puts ("c789\n"); uart_puts ("d20\n"); */ init_keypad_4x4s (P_PORTC); init_count_switch(); init_timer (); lcd_setup (0, P_PA2, P_PA4, P_PA6, P_PA0, P_PA1, P_PA3, P_PA5, P_PA7); //lcd_setup (uint8_t chip, uint8_t strobe, uint8_t clock, uint8_t io) lcd_setup_info (0, HD44780, 20, 2); lcd_init (0, LCD_DISP_ON); // relays // sh_cp:11 (geel) st_cp:12(paars) ds:14(wit) //void hc595_setup (uint8_t chip, uint8_t clk, uint8_t cs, uint8_t data) DDRD|=P_BIT7 | P_BIT6 | P_BIT5 | P_BIT4; #ifdef DEBUG test_relais(); #endif c=0; prevc=0; num=0; turns_done=0; turns_prog=0; total_turns_done=0; for (i=0; i<80; i++) layer[i]=0; stop_motor(); set_wind_dir_none(); lcd_clrscr(0); lcd_puts (0,"* Winding controller 20140114"); lcd_gotoxy(0,39,0); lcd_puts (0,"*"); lcd_gotoxy(0,0,3); lcd_puts (0,"*"); lcd_gotoxy(0,39,3); lcd_puts (0,"*"); lcd_gotoxy(0,2,2); lcd_printf(0,"Free RAM:%d b",freeRam()); sleep(1); lcd_clrscr(0); update_info (); update_command(); update_num (); update_speed (); update_turns(); for (;;) { c=keypad_w_getch(); if (c!=prevc) { /*a=PINC; uart_printf ("%x %x %d\r\n",a,c,num); */ prevc=c; if ((action==FILL) || (action==WIND_LEFT) || (action==WIND_RIGHT)) { switch (c) { case 0x0c: stop_winding(); action=INACTIVE; //dubbel maar extra voor readability break; } } // if !INACTIVE if (action==HELP) { switch (c) { case 0x0f: if (helppage<MAX_HELPPAGES) helppage++; show_help(); break; case 0x0e: if (helppage>0) helppage--; show_help(); break; case 0x0c: action=INACTIVE; lcd_clrscr(0); break; } } // if HELP if (action==CORR) { switch (c) { //corrmode is wat we de *vorige* keer gedaan hebben char buf[10]; case 0x0c: turns_done=turns_before_corr; total_turns_done=total_turns_done_before_corr; action=INACTIVE; break; case 0x0e: turns_done=turns_before_corr; total_turns_done=total_turns_done_before_corr; if (corrmode==SUB) { turns_done+=corr; total_turns_done+=corr; corrmode=ADD; break; } if (corrmode==ADD) { if (turns_done>=corr) { turns_done-=corr; total_turns_done-=corr; } corrmode=SUB; } break; case 0x0f: turns_done=0; total_turns_done=0; turns_before_corr=0; total_turns_done_before_corr=0; action=INACTIVE; break; case 0xff: case 0xfd: case 0xfe: break; default: num=0; action=INACTIVE; itoa(corr,buf,10); if (corrmode==SUB) strcat(layer,"+"); if (corrmode==ADD) strcat(layer,"+"); strcat (layer,buf); update_layer(); break; } update_command(); update_turns(); } if (action==INACTIVE) { switch (c) { case 0x0a: wind_left(); turns_prog=num; num=0; break; case 0x0b: wind_right (); turns_prog=num; num=0; break; case 0x0d: fill (); turns_prog=num; num=0; break; case 0x0c: num=0; stop_motor(); break; case 0x0e: corr=num; turns_before_corr=turns_done; if (turns_done>=corr) turns_done-=corr; action=CORR; corrmode=SUB; break; case 0x0f: helppage=0; show_help(); action=HELP; break; case 0xff: case 0xfd: case 0xfe: break; default: if (num<1000) { num=num*10 + c; update_num(); update_speed(); } } if (action!=HELP) { update_command(); update_turns(); update_num(); update_speed(); } } // if INACTIVE } // if c==prevc } // mainloop return 0; }
/* * CPX user interaction */ BOOLEAN cdecl cpx_call( GRECT *rect ) { OBJECT *tree = (OBJECT *)rs_trindex[MACCEL]; int button; int quit = 0; int saveptime; WORD msg[8]; MA_INFO *src; int ox, oy; MRETS mk; if( !ma_installed ) { form_alert( 1, alertbox ); return FALSE; } ma_work = ma_cancel = *ma_info; ObX( ROOT ) = rect->g_x; ObY( ROOT ) = rect->g_y; set_accelbox( tree, ma_info->linear ); set_screenbox( tree, ma_info->udset ); ma_work.timeout /= 3600; ma_cancel.timeout /= 3600; xcpb->Sl_x( tree, SCRNBACK, SCRNTHUM, ma_work.timeout, SCRN_MIN, SCRN_MAX, NULLFUNC ); TedText(SCRNTHUM)[0] = '0' + ma_work.timeout; if( ma_info->watch ) Select(PHONE); else Deselect(PHONE); if( ma_info->stacy ) { ObFlags(STACSCRN) = ObFlags(STACLITE) = TOUCHEXIT; if( ma_info->stacmask & SH_SCREEN ) Select( STACSCRN ); if( ma_info->stacmask & SH_LIGHT ) Select( STACLITE ); } else { ObFlags(STACSCRN) = ObFlags(STACLITE) = NONE; ObState(STACSCRN) = ObState(STACLITE) = DISABLED; /* deselects */ } Supexec( (long(*)())get_ptime ); saveptime = ma_work.savepark = parktime; if( saveptime == 0 ) saveptime = 1; set_parkbox( tree ); if( parktime >= 0 ) { xcpb->Sl_x( tree, PARKBACK, PARKTHUM, parktime, PARK_MIN, PARK_MAX, NULLFUNC ); itoa2( ma_work.savepark, TedText(PARKTHUM) ); } Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); do { dodelay = FALSE; sl_time = SL_MAX_DELAY; button = xcpb->Xform_do( tree, 0, msg ); if( button == -1 ) if( msg[0] == AC_CLOSE ) button = CANCEL; else if( msg[0] == WM_CLOSED ) button = OK; else button &= 0x7fff; switch( button ) { case OK: src = &ma_work; update_info( tree, src ); quit = OK; break; case CANCEL: src = &ma_cancel; quit = CANCEL; break; case SAVE: if( xcpb->XGen_Alert( SAVE_DEFAULTS ) ) { src = &ma_work; update_info( tree, src ); src->timeout *= 3600; if( xcpb->CPX_Save( src, sizeof(MA_INFO) ) ) { set_info( ma_info, src ); src->timeout /= 3600; ma_cancel = ma_work; } else { src->timeout /= 3600; } } deselect( tree, SAVE ); break; case OFF: ma_work.linear = ma_info->linear = -1; break; case SLOW: ma_work.linear = ma_info->linear = 1; break; case FAST: ma_work.linear = ma_info->linear = 0; break; case PARK: if( IsSelected(PARK) ) /* deselecting */ { saveptime = ma_work.savepark; ma_work.savepark = 0; } else { ma_work.savepark = saveptime; xcpb->Sl_x( tree, PARKBACK, PARKTHUM, parktime, PARK_MIN, PARK_MAX, update_parkbox ); } set_parkbox( tree ); Objc_draw( tree, PARKBOX, MAX_DEPTH, NULL ); break; case PARKUP: dodelay = TRUE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, PARKUP, 1, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case PARKDN: dodelay = TRUE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, PARKDN, -1, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case PARKTHUM: xcpb->Sl_dragx( tree, PARKBACK, PARKTHUM, PARK_MIN, PARK_MAX, &ma_work.savepark, update_parkbox ); break; case PARKBACK: dodelay = TRUE; Graf_mkstate( &mk ); objc_offset( tree, PARKTHUM, &ox, &oy ); if( mk.x < ox ) oy = -PARK_PAGE; else oy = PARK_PAGE; xcpb->Sl_arrow( tree, PARKBACK, PARKTHUM, -1, oy, PARK_MIN, PARK_MAX, &ma_work.savepark, HORIZONTAL, update_parkbox ); break; case SCRN: ma_work.udset ^= 1; set_screenbox( tree, ma_work.udset ); Objc_draw( tree, SCRNBOX, MAX_DEPTH, NULL ); break; case SCRNUP: dodelay = TRUE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, SCRNUP, 1, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; case SCRNDN: dodelay = TRUE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, SCRNDN, -1, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; case SCRNTHUM: xcpb->Sl_dragx( tree, SCRNBACK, SCRNTHUM, SCRN_MIN, SCRN_MAX, &ma_work.timeout, update_screenbox ); break; case SCRNBACK: dodelay = TRUE; Graf_mkstate( &mk ); objc_offset( tree, SCRNTHUM, &ox, &oy ); if( mk.x < ox ) oy = -SCRN_PAGE; else oy = SCRN_PAGE; xcpb->Sl_arrow( tree, SCRNBACK, SCRNTHUM, -1, oy, SCRN_MIN, SCRN_MAX, &ma_work.timeout, HORIZONTAL, update_screenbox ); break; } } while (!quit); Deselect(quit); src->timeout *= 3600; set_info( ma_info, src ); return FALSE; }
void gnc_split_register_load (SplitRegister *reg, GList * slist, Account *default_account) { SRInfo *info; Transaction *pending_trans; CursorBuffer *cursor_buffer; GHashTable *trans_table = NULL; CellBlock *cursor_header; CellBlock *lead_cursor; CellBlock *split_cursor; Transaction *blank_trans; Transaction *find_trans; Transaction *trans; CursorClass find_class; Split *find_trans_split; Split *blank_split; Split *find_split; Split *split; Table *table; GList *node; gboolean start_primary_color = TRUE; gboolean found_pending = FALSE; gboolean need_divider_upper = FALSE; gboolean found_divider_upper = FALSE; gboolean found_divider = FALSE; gboolean has_last_num = FALSE; gboolean multi_line; gboolean dynamic; gboolean we_own_slist = FALSE; gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book()); VirtualCellLocation vcell_loc; VirtualLocation save_loc; int new_trans_split_row = -1; int new_trans_row = -1; int new_split_row = -1; time64 present, autoreadonly_time = 0; g_return_if_fail(reg); table = reg->table; g_return_if_fail(table); info = gnc_split_register_get_info (reg); g_return_if_fail(info); ENTER("reg=%p, slist=%p, default_account=%p", reg, slist, default_account); blank_split = xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ()); pending_trans = xaccTransLookup (&info->pending_trans_guid, gnc_get_current_book ()); /* make sure we have a blank split */ if (blank_split == NULL) { /* Wouldn't it be a bug to open the new transaction if there was * already a pending transaction? */ g_assert(pending_trans == NULL); blank_split = create_blank_split (default_account, info); } blank_trans = xaccSplitGetParent (blank_split); DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p", blank_split, blank_trans, pending_trans); info->default_account = *xaccAccountGetGUID (default_account); // gnc_table_leave_update (table, table->current_cursor_loc); multi_line = (reg->style == REG_STYLE_JOURNAL); dynamic = (reg->style == REG_STYLE_AUTO_LEDGER); lead_cursor = gnc_split_register_get_passive_cursor (reg); split_cursor = gnc_table_layout_get_cursor (table->layout, CURSOR_SPLIT); /* figure out where we are going to. */ if (info->traverse_to_new) { find_trans = blank_trans; find_split = NULL; find_trans_split = blank_split; find_class = CURSOR_CLASS_SPLIT; } else { find_trans = info->cursor_hint_trans; find_split = info->cursor_hint_split; find_trans_split = info->cursor_hint_trans_split; find_class = info->cursor_hint_cursor_class; } save_loc = table->current_cursor_loc; /* If the current cursor has changed we save the values for later * possible restoration. */ if (gnc_table_current_cursor_changed (table, TRUE) && (find_split == gnc_split_register_get_current_split (reg))) { cursor_buffer = gnc_cursor_buffer_new (); gnc_table_save_current_cursor (table, cursor_buffer); } else cursor_buffer = NULL; /* disable move callback -- we don't want the cascade of * callbacks while we are fiddling with loading the register */ gnc_table_control_allow_move (table->control, FALSE); /* invalidate the cursor */ { VirtualLocation virt_loc; gnc_virtual_location_init(&virt_loc); gnc_table_move_cursor_gui (table, virt_loc); } /* make sure that the header is loaded */ vcell_loc.virt_row = 0; vcell_loc.virt_col = 0; cursor_header = gnc_table_layout_get_cursor (table->layout, CURSOR_HEADER); gnc_table_set_vcell (table, cursor_header, NULL, TRUE, TRUE, vcell_loc); vcell_loc.virt_row++; /* get the current time and reset the dividing row */ present = gnc_time64_get_today_end (); if (use_autoreadonly) { GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book()); // "d" is NULL if use_autoreadonly is FALSE autoreadonly_time = d ? timespecToTime64(gdate_to_timespec(*d)) : 0; g_date_free(d); } if (info->first_pass) { if (default_account) { const char *last_num = xaccAccountGetLastNum (default_account); if (last_num) { NumCell *cell; cell = (NumCell *) gnc_table_layout_get_cell(table->layout, NUM_CELL); gnc_num_cell_set_last_num (cell, last_num); has_last_num = TRUE; } } /* load up account names into the transfer combobox menus */ gnc_split_register_load_xfer_cells (reg, default_account); gnc_split_register_load_recn_cells (reg); gnc_split_register_load_type_cells (reg); } if (info->separator_changed) change_account_separator (info, table, reg); table->model->dividing_row_upper = -1; table->model->dividing_row = -1; // Ensure that the transaction and splits being edited are in the split // list we're about to load. if (pending_trans != NULL) { for (node = xaccTransGetSplitList(pending_trans); node; node = node->next) { Split *pending_split = (Split*)node->data; if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue; if (g_list_find(slist, pending_split) != NULL) continue; if (g_list_find_custom(slist, pending_trans, _find_split_with_parent_txn) != NULL) continue; if (!we_own_slist) { // lazy-copy slist = g_list_copy(slist); we_own_slist = TRUE; } slist = g_list_append(slist, pending_split); } } if (multi_line) trans_table = g_hash_table_new (g_direct_hash, g_direct_equal); /* populate the table */ for (node = slist; node; node = node->next) { split = node->data; trans = xaccSplitGetParent (split); if (!xaccTransStillHasSplit(trans, split)) continue; if (pending_trans == trans) found_pending = TRUE; /* If the transaction has only one split, and it's not our * pending_trans, then it's another register's blank split and * we don't want to see it. */ else if (xaccTransCountSplits (trans) == 1 && xaccSplitGetAccount (split) == NULL) continue; /* Do not load splits from the blank transaction. */ if (trans == blank_trans) continue; if (multi_line) { /* Skip this split if its transaction has already been loaded. */ if (g_hash_table_lookup (trans_table, trans)) continue; g_hash_table_insert (trans_table, trans, trans); } if (info->show_present_divider && use_autoreadonly && !found_divider_upper) { if (xaccTransGetDate (trans) >= autoreadonly_time) { table->model->dividing_row_upper = vcell_loc.virt_row; found_divider_upper = TRUE; } else { need_divider_upper = TRUE; } } if (info->show_present_divider && !found_divider && (xaccTransGetDate (trans) > present)) { table->model->dividing_row = vcell_loc.virt_row; found_divider = TRUE; } /* If this is the first load of the register, * fill up the quickfill cells. */ if (info->first_pass) add_quickfill_completions(reg->table->layout, trans, split, has_last_num); if (trans == find_trans) new_trans_row = vcell_loc.virt_row; if (split == find_trans_split) new_trans_split_row = vcell_loc.virt_row; gnc_split_register_add_transaction (reg, trans, split, lead_cursor, split_cursor, multi_line, start_primary_color, TRUE, find_trans, find_split, find_class, &new_split_row, &vcell_loc); if (!multi_line) start_primary_color = !start_primary_color; } if (multi_line) g_hash_table_destroy (trans_table); /* add the blank split at the end. */ if (pending_trans == blank_trans) found_pending = TRUE; /* No upper divider yet? Store it now */ if (info->show_present_divider && use_autoreadonly && !found_divider_upper && need_divider_upper) { table->model->dividing_row_upper = vcell_loc.virt_row; found_divider_upper = TRUE; } if (blank_trans == find_trans) new_trans_row = vcell_loc.virt_row; if (blank_split == find_trans_split) new_trans_split_row = vcell_loc.virt_row; /* If we didn't find the pending transaction, it was removed * from the account. */ if (!found_pending) { info->pending_trans_guid = *guid_null (); if (xaccTransIsOpen (pending_trans)) xaccTransCommitEdit (pending_trans); else if (pending_trans) g_assert_not_reached(); pending_trans = NULL; } /* go to blank on first pass */ if (info->first_pass) { new_split_row = -1; new_trans_split_row = -1; new_trans_row = -1; save_loc.vcell_loc = vcell_loc; save_loc.phys_row_offset = 0; save_loc.phys_col_offset = 0; } gnc_split_register_add_transaction (reg, blank_trans, blank_split, lead_cursor, split_cursor, multi_line, start_primary_color, info->blank_split_edited, find_trans, find_split, find_class, &new_split_row, &vcell_loc); /* resize the table to the sizes we just counted above */ /* num_virt_cols is always one. */ gnc_table_set_size (table, vcell_loc.virt_row, 1); /* restore the cursor to its rightful position */ { VirtualLocation trans_split_loc; if (new_split_row > 0) save_loc.vcell_loc.virt_row = new_split_row; else if (new_trans_split_row > 0) save_loc.vcell_loc.virt_row = new_trans_split_row; else if (new_trans_row > 0) save_loc.vcell_loc.virt_row = new_trans_row; trans_split_loc = save_loc; gnc_split_register_get_trans_split (reg, save_loc.vcell_loc, &trans_split_loc.vcell_loc); if (dynamic || multi_line || info->trans_expanded) { gnc_table_set_virt_cell_cursor( table, trans_split_loc.vcell_loc, gnc_split_register_get_active_cursor (reg)); gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc, TRUE, multi_line); info->trans_expanded = (reg->style == REG_STYLE_LEDGER); } else { save_loc = trans_split_loc; info->trans_expanded = FALSE; } if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE)) { gnc_table_move_cursor_gui (table, save_loc); new_split_row = save_loc.vcell_loc.virt_row; if (find_split == gnc_split_register_get_current_split (reg)) gnc_table_restore_current_cursor (table, cursor_buffer); } } gnc_cursor_buffer_destroy (cursor_buffer); cursor_buffer = NULL; update_info (info, reg); gnc_split_register_set_cell_fractions( reg, gnc_split_register_get_current_split (reg)); gnc_table_refresh_gui (table, TRUE); gnc_split_register_show_trans (reg, table->current_cursor_loc.vcell_loc); /* enable callback for cursor user-driven moves */ gnc_table_control_allow_move (table->control, TRUE); if (we_own_slist) g_list_free(slist); LEAVE(" "); }
int main (int argc, char **argv) { fl_init_locale_support("evolume", PREFIX"/share/locale"); Fl_Config globalConfig("EDE Team", "evolume"); globalConfig.get("Sound mixer", "Device", device, "/dev/mixer", sizeof(device)); main_window = new Fl_Window(720, 205, _("Volume control")); Fl_Menu_Bar *vc_menubar = new Fl_Menu_Bar(0, 0, 724, 25); vc_menubar->begin(); Fl_Item_Group file(_("&File")); Fl_Item* pref_item = new Fl_Item(_("Preferences")); pref_item->shortcut(FL_CTRL+'p'); pref_item->callback(PreferencesDialog); Fl_Item* quit_item = new Fl_Item(_("Quit")); quit_item->shortcut(FL_CTRL+'q'); quit_item->callback(quit_cb); file.end(); Fl_Item_Group help(_("&Help")); Fl_Item* about_item = new Fl_Item(_("About")); about_item->shortcut(FL_CTRL+'a'); about_item->callback((Fl_Callback*)cb_About); help.end(); vc_menubar->end(); new Fl_Divider(0, 24, 724, 3); volume_slider = new Fl_Slider(20, 50, 20, 80, "VOL"); default_look(volume_slider); volume_balance = new Fl_Slider(10, 135, 40, 15, "Balance"); default_look_b(volume_balance); volume_mute = new Fl_Check_Button(5, 165, 20, 20, "Mute"); volume_mute->align(FL_ALIGN_BOTTOM); volume_rec = new Fl_Check_Button(35, 165, 20, 20, "Rec"); volume_rec->align(FL_ALIGN_BOTTOM); cd_slider = new Fl_Slider(80, 50, 20, 80, "CD"); default_look(cd_slider); cd_balance = new Fl_Slider(70, 135, 40, 15, "Balance"); default_look_b(cd_balance); cd_mute = new Fl_Check_Button(65, 165, 20, 20, "Mute"); cd_mute->align(FL_ALIGN_BOTTOM); cd_rec = new Fl_Check_Button(95, 165, 20, 20, "Rec"); cd_rec->align(FL_ALIGN_BOTTOM); pcm_slider = new Fl_Slider(140, 50, 20, 80, "PCM"); default_look(pcm_slider); pcm_balance = new Fl_Slider(130, 135, 40, 15, "Balance"); default_look_b(pcm_balance); pcm_mute = new Fl_Check_Button(125, 165, 20, 20, "Mute"); pcm_mute->align(FL_ALIGN_BOTTOM); pcm_rec = new Fl_Check_Button(155, 165, 20, 20, "Rec"); pcm_rec->align(FL_ALIGN_BOTTOM); synth_slider = new Fl_Slider(200, 50, 20, 80, "SYNTH"); default_look(synth_slider); synth_balance = new Fl_Slider(190, 135, 40, 15, "Balance"); default_look_b(synth_balance); synth_mute = new Fl_Check_Button(185, 165, 20, 20, "Mute"); synth_mute->align(FL_ALIGN_BOTTOM); synth_rec = new Fl_Check_Button(215, 165, 20, 20, "Rec"); synth_rec->align(FL_ALIGN_BOTTOM); line_slider = new Fl_Slider(260, 50, 20, 80, "LINE"); default_look(line_slider); line_balance = new Fl_Slider(250, 135, 40, 15, "Balance"); default_look_b(line_balance); line_mute = new Fl_Check_Button(245, 165, 20, 20, "Mute"); line_mute->align(FL_ALIGN_BOTTOM); line_rec = new Fl_Check_Button(275, 165, 20, 20, "Rec"); line_rec->align(FL_ALIGN_BOTTOM); bass_slider = new Fl_Slider(320, 50, 20, 80, "BASS"); default_look(bass_slider); bass_balance = new Fl_Slider(310, 135, 40, 15, "Balance"); default_look_b(bass_balance); bass_mute = new Fl_Check_Button(305, 165, 20, 20, "Mute"); bass_mute->align(FL_ALIGN_BOTTOM); bass_rec = new Fl_Check_Button(335, 165, 20, 20, "Rec"); bass_rec->align(FL_ALIGN_BOTTOM); treble_slider = new Fl_Slider(380, 50, 20, 80, "TREBLE"); default_look(treble_slider); treble_balance = new Fl_Slider(370, 135, 40, 15, "Balance"); default_look_b(treble_balance); treble_mute = new Fl_Check_Button(365, 165, 20, 20, "Mute"); treble_mute->align(FL_ALIGN_BOTTOM); treble_rec = new Fl_Check_Button(395, 165, 20, 20, "Rec"); treble_rec->align(FL_ALIGN_BOTTOM); mic_slider = new Fl_Slider(440, 50, 20, 80, "MIC"); default_look(mic_slider); mic_balance = new Fl_Slider(430, 135, 40, 15, "Balance"); default_look_b(mic_balance); mic_mute = new Fl_Check_Button(425, 165, 20, 20, "Mute"); mic_mute->align(FL_ALIGN_BOTTOM); mic_rec = new Fl_Check_Button(455, 165, 20, 20, "Rec"); mic_rec->align(FL_ALIGN_BOTTOM); speaker_slider = new Fl_Slider(500, 50, 20, 80, "SPK"); default_look(speaker_slider); speaker_balance = new Fl_Slider(490, 135, 40, 15, "Balance"); default_look_b(speaker_balance); speaker_mute = new Fl_Check_Button(485, 165, 20, 20, "Mute"); speaker_mute->align(FL_ALIGN_BOTTOM); speaker_rec = new Fl_Check_Button(515, 165, 20, 20, "Rec"); speaker_rec->align(FL_ALIGN_BOTTOM); imix_slider = new Fl_Slider(560, 50, 20, 80, "IMIX"); default_look(imix_slider); imix_balance = new Fl_Slider(550, 135, 40, 15, "Balance"); default_look_b(imix_balance); imix_mute = new Fl_Check_Button(545, 165, 20, 20, "Mute"); imix_mute->align(FL_ALIGN_BOTTOM); imix_rec = new Fl_Check_Button(575, 165, 20, 20, "Rec"); imix_rec->align(FL_ALIGN_BOTTOM); igain_slider = new Fl_Slider(620, 50, 20, 80, "IGAIN"); default_look(igain_slider); igain_balance = new Fl_Slider(610, 135, 40, 15, "Balance"); default_look_b(igain_balance); igain_mute = new Fl_Check_Button(605, 165, 20, 20, "Mute"); igain_mute->align(FL_ALIGN_BOTTOM); igain_rec = new Fl_Check_Button(635, 165, 20, 20, "Rec"); igain_rec->align(FL_ALIGN_BOTTOM); ogain_slider = new Fl_Slider(680, 50, 20, 80, "OGAIN"); default_look(ogain_slider); ogain_balance = new Fl_Slider(670, 135, 40, 15, "Balance"); default_look_b(ogain_balance); ogain_mute = new Fl_Check_Button(665, 165, 20, 20, "Mute"); ogain_mute->align(FL_ALIGN_BOTTOM); ogain_rec = new Fl_Check_Button(695, 165, 20, 20, "Rec"); ogain_rec->align(FL_ALIGN_BOTTOM); mixer_device = open(device, O_RDWR); if (mixer_device == -1) { fl_alert(_("Opening mixer device %s failed. Setup correct device in configuration dialog."), device); volume_slider->deactivate(); cd_slider->deactivate(); pcm_slider->deactivate(); synth_slider->deactivate(); line_slider->deactivate(); bass_slider->deactivate(); treble_slider->deactivate(); mic_slider->deactivate(); speaker_slider->deactivate(); imix_slider->deactivate(); igain_slider->deactivate(); ogain_slider->deactivate(); } update_info(); volume_slider->callback( cb_volume, 1 ); volume_balance->callback( cb_volume, 2 ); volume_mute->callback( cb_volume, 3 ); volume_rec->callback( cb_volume, 4 ); get_device_info(mixer_device, volume_slider, volume_balance, volume_rec, SOUND_MIXER_VOLUME); cd_slider->callback( cb_cd, 1 ); cd_balance->callback( cb_cd, 2 ); cd_mute->callback( cb_cd, 3 ); cd_rec->callback( cb_cd, 4 ); get_device_info(mixer_device, cd_slider, cd_balance, cd_rec, SOUND_MIXER_CD); pcm_slider->callback( cb_pcm, 1 ); pcm_balance->callback( cb_pcm, 2 ); pcm_mute->callback( cb_pcm, 3 ); pcm_rec->callback( cb_pcm, 4 ); get_device_info(mixer_device, pcm_slider, pcm_balance, pcm_rec, SOUND_MIXER_PCM); synth_slider->callback( cb_synth, 1 ); synth_balance->callback( cb_synth, 2 ); synth_mute->callback( cb_synth, 3 ); synth_rec->callback( cb_synth, 4 ); get_device_info(mixer_device, synth_slider, synth_balance, synth_rec, SOUND_MIXER_SYNTH); line_slider->callback( cb_line, 1 ); line_balance->callback( cb_line, 2 ); line_mute->callback( cb_line, 3 ); line_rec->callback( cb_line, 4 ); get_device_info(mixer_device, line_slider, line_balance, line_rec, SOUND_MIXER_LINE); bass_slider->callback( cb_bass, 1 ); bass_balance->callback( cb_bass, 2 ); bass_mute->callback( cb_bass, 3 ); bass_rec->callback( cb_bass, 4 ); get_device_info(mixer_device, bass_slider, bass_balance, bass_rec, SOUND_MIXER_BASS); treble_slider->callback( cb_treble, 1 ); treble_balance->callback( cb_treble, 2 ); treble_mute->callback( cb_treble, 3 ); treble_rec->callback( cb_treble, 4 ); get_device_info(mixer_device, treble_slider, treble_balance, treble_rec, SOUND_MIXER_TREBLE); mic_slider->callback( cb_mic, 1 ); mic_balance->callback( cb_mic, 2 ); mic_mute->callback( cb_mic, 3 ); mic_rec->callback( cb_mic, 4 ); get_device_info(mixer_device, mic_slider, mic_balance, mic_rec, SOUND_MIXER_MIC); speaker_slider->callback( cb_speaker, 1 ); speaker_balance->callback( cb_speaker, 2 ); speaker_mute->callback( cb_speaker, 3 ); speaker_rec->callback( cb_speaker, 4 ); get_device_info(mixer_device, speaker_slider, speaker_balance, speaker_rec, SOUND_MIXER_SPEAKER); imix_slider->callback( cb_imix, 1 ); imix_balance->callback( cb_imix, 2 ); imix_mute->callback( cb_imix, 3 ); imix_rec->callback( cb_imix, 4 ); get_device_info(mixer_device, imix_slider, imix_balance, imix_rec, SOUND_MIXER_IMIX); igain_slider->callback( cb_igain, 1 ); igain_balance->callback( cb_igain, 2 ); igain_mute->callback( cb_igain, 3 ); igain_rec->callback( cb_igain, 4 ); get_device_info(mixer_device, igain_slider, igain_balance, igain_rec, SOUND_MIXER_IGAIN); ogain_slider->callback( cb_ogain, 1 ); ogain_balance->callback( cb_ogain, 2 ); ogain_mute->callback( cb_ogain, 3 ); ogain_rec->callback( cb_ogain, 4 ); get_device_info(mixer_device, ogain_slider, ogain_balance, ogain_rec, SOUND_MIXER_OGAIN); main_window->end(); main_window->show(argc, argv); return Fl::run(); }