int adhocTerm(void) { if (adhoc_initialized > 0) { char message[256]; sprintf(message, TEXT(DISCONNECTING_FROM_x), Server ? TEXT(CLIENT) : TEXT(SERVER)); adhoc_init_progress(5, message); sceNetAdhocctlDisconnect(); update_progress(); sceNetAdhocPdpDelete(pdpId, 0); update_progress(); sceNetAdhocctlTerm(); update_progress(); sceNetAdhocTerm(); update_progress(); sceNetTerm(); update_progress(); show_progress(TEXT(DISCONNECTED)); adhoc_initialized = 0; } return 0; }
/*----------------------------------------------------------------------*/ static char * qm_summary() { dcx_summary_t ans; static char buf[1024]; DB(_("qm_summary")); if( dcx_get_summary(&ans) == NG ) { return "Error!!"; } #if 0 /* delete 1999.10.1 for gphoto-0.3.9 */ update_progress(0); update_progress(100); #endif sprintf(buf, "This camera is a Konica QM100/200 \n" "It has taken %ld pictures and currently contains %ld picture(s)\n" "The time according to the Camera is %d:%d:%d %d/%d/%d", ans.total_pict, ans.picture_count, (int)ans.hour, (int)ans.minute, (int)ans.second, (int)ans.day, (int)ans.month, (int)ans.year); return buf; }
/* * downloads data from camera and send * a checksum every 512 bytes. */ int mdc800_rs232_download (char* buffer, int size) { int checksum,readen=0,i; char DSC_checksum; int numtries=0; gpio_set_timeout (mdc800_io_device_handle, MDC800_DEFAULT_TIMEOUT ); while (readen < size) { if (size) update_progress (100 * readen / size); if (!mdc800_rs232_receive (&buffer[readen],512)) return readen; checksum=0; for (i=0; i<512; i++) checksum=(checksum+(unsigned char) buffer [readen+i])%256; if (gpio_write (mdc800_io_device_handle,(char*) &checksum,1) != GPIO_OK) return readen; if (!mdc800_rs232_receive (&DSC_checksum,1)) return readen; if ((char) checksum != DSC_checksum) { numtries++; printCError ("(mdc800_rs232_download) checksum: software %i, DSC %i , reload block! (%i) \n",checksum,(unsigned char)DSC_checksum,numtries); if (numtries > 10) { printCError ("(mdc800_rs232_download) to many retries, giving up.."); return 0; } } else { readen+=512; numtries=0; } } { int i,j; unsigned char* b=(unsigned char*) buffer; for (i=0; i<4; i++) { printCError ("%i: ",i); for (j=0; j<8; j++) printCError (" %i", b[i*8+j]); printCError ("\n"); } } if (size) update_progress (100 * readen/size); return readen; }
void StreamSorter<Message>::streaming_merge(list<cursor_t>& cursors, emitter_t& emitter, size_t expected_messages) { create_progress("merge " + to_string(cursors.size()) + " files", expected_messages == 0 ? 1 : expected_messages); // Count the messages we actually see size_t observed_messages = 0; // Put all the files in a priority queue based on which has a message that comes first. // We work with pointers to cursors because we don't want to be copying the actual cursors around the heap. // We also *reverse* the order, because priority queues put the "greatest" element first auto cursor_order = [&](cursor_t*& a, cursor_t*& b) { if (b->has_next()) { if(!a->has_next()) { // Cursors that aren't empty come first return true; } return less_than(*(*b), *(*a)); } return false; }; priority_queue<cursor_t*, vector<cursor_t*>, decltype(cursor_order)> cursor_queue(cursor_order); for (auto& cursor : cursors) { // Put the cursor pointers in the queue cursor_queue.push(&cursor); } while(!cursor_queue.empty() && cursor_queue.top()->has_next()) { // Until we have run out of data in all the temp files // Pop off the winning cursor cursor_t* winner = cursor_queue.top(); cursor_queue.pop(); // Grab and emit its message, and advance it emitter.write(std::move(winner->take())); // Put it back in the heap if it is not depleted if (winner->has_next()) { cursor_queue.push(winner); } // TODO: Maybe keep it off the heap for the next loop somehow if it still wins observed_messages++; if (expected_messages != 0) { update_progress(observed_messages); } } // We finished the files, so say we're done. // TODO: Should we warn/fail if we expected the wrong number of messages? update_progress(expected_messages == 0 ? 1 : expected_messages); destroy_progress(); }
// Reverse a section of the file in-place static inline void reverse(tubtf_row_64 *rows, uint64_t start, uint64_t end, bool progress) { uint64_t i = start, j = end; uint64_t mid = (end - start + 1) / 2; uint64_t interval = mid / 100; while (i < j) { if (progress && (i % interval) == 0) update_progress(i, mid); swaprecs(rows, i, j); i++; j--; } if (progress) update_progress(mid, mid); }
bool GncSqlBackend::write_accounts() { update_progress(); auto is_ok = write_account_tree (gnc_book_get_root_account (m_book)); if (is_ok) { update_progress(); is_ok = write_account_tree (gnc_book_get_template_root(m_book)); } return is_ok; }
static void adhocDisconnect(void) { char message[256]; sprintf(message, TEXT(DISCONNECTING_FROM_x), TEXT(LOBBY)); adhoc_init_progress(8, message); sceNetAdhocMatchingStop(matchingId); update_progress(); sceNetAdhocMatchingDelete(matchingId); update_progress(); sceNetAdhocMatchingTerm(); update_progress(); sceNetAdhocctlDisconnect(); update_progress(); sceNetAdhocPdpDelete(pdpId, 0); update_progress(); sceNetAdhocctlTerm(); update_progress(); sceNetAdhocTerm(); update_progress(); sceNetTerm(); update_progress(); show_progress(TEXT(DISCONNECTED)); adhoc_initialized = 0; }
static int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void *payload) { int percent = 0; if (total != 0) percent = 100 * current / total; return update_progress(percent); }
// the checkout_progress_cb doesn't allow canceling of the operation static void progress_cb(const char *path, size_t completed_steps, size_t total_steps, void *payload) { int percent = 0; if (total_steps) percent = 100 * completed_steps / total_steps; (void)update_progress(percent); }
void BaseTest::run( int start_from ) { int test_case_idx, count = get_test_case_count(); int64 t_start = cvGetTickCount(); double freq = cv::getTickFrequency(); bool ff = can_do_fast_forward(); int progress = 0, code; int64 t1 = t_start; for( test_case_idx = ff && start_from >= 0 ? start_from : 0; count < 0 || test_case_idx < count; test_case_idx++ ) { ts->update_context( this, test_case_idx, ff ); progress = update_progress( progress, test_case_idx, count, (double)(t1 - t_start)/(freq*1000) ); code = prepare_test_case( test_case_idx ); if( code < 0 || ts->get_err_code() < 0 ) return; if( code == 0 ) continue; run_func(); if( ts->get_err_code() < 0 ) return; if( validate_test_results( test_case_idx ) < 0 || ts->get_err_code() < 0 ) return; } }
void Convert::convert_start(void) { update_progress(0.0); if(!libvlc_loaded) { if(convert_init() == 0) libvlc_loaded = true; else { status(tr("Internal error !")); return; } } ui.convert_button->setEnabled(false); ui.input_choose->setEnabled(false); ui.output_choose->setEnabled(false); status(tr("in progress")); thread = new ConvertThread( ui.input_file->text().toUtf8().data(), ui.output_file->text().toUtf8().data()); connect(thread, SIGNAL(finished()), this, SLOT(finished())); connect(thread, SIGNAL(progress_changed(float)), this, SLOT(update_progress(float))); thread->start(); }
bool GncSqlBackend::write_account_tree(Account* root) { GList* descendants; GList* node; bool is_ok = true; g_return_val_if_fail (root != nullptr, false); auto obe = m_backend_registry.get_object_backend(GNC_ID_ACCOUNT); is_ok = obe->commit (this, QOF_INSTANCE (root)); if (is_ok) { descendants = gnc_account_get_descendants (root); for (node = descendants; node != NULL && is_ok; node = g_list_next (node)) { is_ok = obe->commit(this, QOF_INSTANCE (GNC_ACCOUNT (node->data))); if (!is_ok) break; } g_list_free (descendants); } update_progress(); return is_ok; }
/* save file */ void save_file(const int fd, const char *filename, const int total) { int w_bytes, chk; FILE *fp = NULL; static char buf[1500]; assert(filename != NULL && total >= 0); fp = fopen(filename, "a+"); if (NULL == fp) { printf("open file error!\r\n"); return; } w_bytes = 0; while (w_bytes != total) { chk = recv(fd, buf, sizeof(buf), 0); fwrite(buf, chk, 1, fp); w_bytes += chk; fflush(fp); /* update progress bar */ update_progress(&bar, chk); display_image(&bar); } putchar('\n'); fflush(fp); fclose(fp); printf("%s: save!", filename); }
void overwrite(int stage) { u_int32_t i, j; off_t count = 0; unsigned char *buffptr = buffer; lseek(file, 0, SEEK_SET); while (count < file_size - buffsize) { if (stage == W_RANDOM) { randomize_buffer(buffer, buffsize); } else if (stage == W_TRIPLE) { buffptr = align_buffer(buffer, count); } i = write(file, buffptr, buffsize); if (options & OPT_VERIFY) { /* verify the write */ lseek(file, count, SEEK_SET); j = read(file, verify_buffer, buffsize); if (!(i == j && !memcmp(verify_buffer, buffptr, buffsize))) { verification_failure(count); } } if (options & OPT_V) { update_progress(i); } count += i; } if (stage == W_RANDOM) { randomize_buffer(buffer, file_size - count); } else if (stage == W_TRIPLE) { buffptr = align_buffer(buffer, count); } i = write(file, buffptr, file_size - count); if (options & OPT_VERIFY) { /* verify the write */ lseek(file, count, SEEK_SET); j = read(file, verify_buffer, file_size - count); if (!(i == j && !memcmp(verify_buffer, buffptr, file_size - count))) { verification_failure(count); } } if (options & OPT_V) { update_progress(i); } flush(file); lseek(file, 0, SEEK_SET); }
int main(int argc, char **argv) { struct stat st; if(argc < 2) { fprintf(stderr, "usage: %s <tubtf.log>\n", argv[0]); return 1; } if (stat(argv[1], &st) != 0) { perror("stat"); return 1; } int fd = open(argv[1], O_RDWR|O_LARGEFILE); uint8_t *mapped = (uint8_t *)mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (mapped == MAP_FAILED) { perror("mmap"); return 1; } // Skip header tubtf_row_64 *rows = (tubtf_row_64 *)(mapped + 20); uint64_t num_records = (st.st_size - 20) / sizeof(tubtf_row_64); printf("Reversing %d records in place... \n", num_records); reverse(rows, 0, num_records - 1, true); printf("\n"); printf("Reversing each group.... \n"); uint64_t i = 0, j = 0; uint64_t interval = num_records / 100; tubtf_row_64 row = {}; do { if ((j % interval) == 0) update_progress(j, num_records); if (rows[j].type == TUBTFE_LLVM_FN) { reverse(rows, i, j, false); i = j+1; } j++; } while (j < num_records); update_progress(num_records, num_records); munmap(rows, st.st_size); close(fd); return 0; }
// this randomly assumes that 80% of the time is spent on the objects and 20% on the deltas // if the user cancels the dialog this is passed back to libgit2 static int transfer_progress_cb(const git_transfer_progress *stats, void *payload) { int percent = 0; if (stats->total_objects) percent = 80 * stats->received_objects / stats->total_objects; if (stats->total_deltas) percent += 20 * stats->indexed_deltas / stats->total_deltas; return update_progress(percent); }
void GncSqlBackend::create_tables() noexcept { for(auto entry : m_backend_registry) { update_progress(); std::get<1>(entry)->create_tables(this); } }
int main(){ progress_bar_t *mybar = setup_progress('=', '[', ']',70, true); printf("\n"); for (int i=0;i<=100;i=i+1){ update_progress(((double)i)/100, mybar); usleep(200*MILLISEC); } }
void Convert::finished(void) { ui.input_file->setText(NULL); ui.output_file->setText(NULL); ui.input_choose->setEnabled(true); ui.output_choose->setEnabled(true); update_progress(1.0); status(tr("finished!")); }
bool GncSqlBackend::write_transactions() { auto obe = m_backend_registry.get_object_backend(GNC_ID_TRANS); write_objects_t data{this, TRUE, obe.get()}; (void)xaccAccountTreeForEachTransaction ( gnc_book_get_root_account (m_book), write_tx, &data); update_progress(); return data.is_ok; }
// }}} // {{{ int main(int argc, char **argv) int main(int argc, char **argv) { ffqueued_init(); while(1) { read_queue(); update_progress(); check_exits(); sleep(10); } }
/** * gpgmegtk_recipient_selection: * @recp_names: A list of email addresses * * Select a list of recipients from a given list of email addresses. * This may pop up a window to present the user a choice, it will also * check that the recipients key are all valid. * * Return value: NULL on error or a list of list of recipients. **/ gpgme_key_t * gpgmegtk_recipient_selection (GSList *recp_names, SelectionResult *result, gpgme_protocol_t proto) { struct select_keys_s sk; gpgme_key_t key = NULL; memset (&sk, 0, sizeof sk); open_dialog (&sk); do { sk.pattern = recp_names? recp_names->data:NULL; sk.proto = proto; gtk_cmclist_clear (sk.clist); key = fill_clist (&sk, sk.pattern, proto); update_progress (&sk, 0, sk.pattern ? sk.pattern : "NULL"); if (!key) { gtk_widget_show_all (sk.window); gtk_main (); } else { gtk_widget_hide (sk.window); sk.kset = g_realloc(sk.kset, sizeof(gpgme_key_t) * (sk.num_keys + 1)); gpgme_key_ref(key); sk.kset[sk.num_keys] = key; sk.num_keys++; sk.okay = 1; sk.result = KEY_SELECTION_OK; gpgme_release (sk.select_ctx); sk.select_ctx = NULL; debug_print("used %s\n", key->uids->email); } key = NULL; if (recp_names) recp_names = recp_names->next; } while (sk.okay && recp_names); close_dialog (&sk); if (!sk.okay) { g_free(sk.kset); sk.kset = NULL; } else { sk.kset = g_realloc(sk.kset, sizeof(gpgme_key_t) * (sk.num_keys + 1)); sk.kset[sk.num_keys] = NULL; } if (result) *result = sk.result; return sk.kset; }
void CV_BinaryDescriptorDetectorTest::compareKeylineSets( const std::vector<KeyLine>& validKeylines, const std::vector<KeyLine>& calcKeylines ) { const float maxCountRatioDif = 0.01f; // Compare counts of validation and calculated keylines. float countRatio = (float) validKeylines.size() / (float) calcKeylines.size(); if( countRatio < 1 - maxCountRatioDif || countRatio > 1.f + maxCountRatioDif ) { ts->printf( cvtest::TS::LOG, "Bad keylines count ratio (validCount = %d, calcCount = %d).\n", validKeylines.size(), calcKeylines.size() ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); return; } int progress = 0; int progressCount = (int) ( validKeylines.size() * calcKeylines.size() ); int badLineCount = 0; int commonLineCount = max( (int) validKeylines.size(), (int) calcKeylines.size() ); for ( size_t v = 0; v < validKeylines.size(); v++ ) { int nearestIdx = -1; float minDist = std::numeric_limits<float>::max(); for ( size_t c = 0; c < calcKeylines.size(); c++ ) { progress = update_progress( progress, (int) ( v * calcKeylines.size() + c ), progressCount, 0 ); float curDist = (float)cv::norm(calcKeylines[c].pt - validKeylines[v].pt); if( curDist < minDist ) { minDist = curDist; nearestIdx = (int) c; } } assert( minDist >= 0 ); if( !isSimilarKeylines( validKeylines[v], calcKeylines[nearestIdx] ) ) badLineCount++; } ts->printf( cvtest::TS::LOG, "badLineCount = %d; validLineCount = %d; calcLineCount = %d\n", badLineCount, validKeylines.size(), calcKeylines.size() ); if( badLineCount > 0.9 * commonLineCount ) { ts->printf( cvtest::TS::LOG, " - Bad accuracy!\n" ); ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); return; } ts->printf( cvtest::TS::LOG, " - OK\n" ); }
bool GncSqlBackend::write_template_transactions() { auto obe = m_backend_registry.get_object_backend(GNC_ID_TRANS); write_objects_t data{this, true, obe.get()}; auto ra = gnc_book_get_template_root (m_book); if (gnc_account_n_descendants (ra) > 0) { (void)xaccAccountTreeForEachTransaction (ra, write_tx, &data); update_progress(); } return data.is_ok; }
int belle_sip_body_handler_send_chunk(belle_sip_body_handler_t *obj, belle_sip_message_t *msg, uint8_t *buf, size_t *size){ int ret; if (obj->expected_size!=0){ *size=MIN(*size,obj->expected_size-obj->transfered_size); } ret=BELLE_SIP_OBJECT_VPTR(obj,belle_sip_body_handler_t)->chunk_send(obj,msg,obj->transfered_size,buf,size); obj->transfered_size+=*size; update_progress(obj,msg); if (obj->expected_size!=0){ if (obj->transfered_size==obj->expected_size) return BELLE_SIP_STOP; if (ret==BELLE_SIP_STOP && obj->transfered_size<obj->expected_size){ belle_sip_error("body handler [%p] transfered only [%i] bytes while [%i] were expected",obj, (int)obj->transfered_size,(int)obj->expected_size); } } return ret; }
// Sends the requested files to the Hooli file transfer server // @param hftpd a pointer to the server information // @param client a pointer to the client information // @return -1 if there was an error, 1 otherwise int hooli_file_sync(server_info *hftpd, client_info *client) { int sockfd; // The socket for communication with the server int seq = 0; // The sequence number int count = 0; file_info *file; host server; // Server address sockfd = create_udp_client_socket(hftpd->server, hftpd->port, &server); csv_record *p = client->response_list; // Loop through all the requested files while (p != NULL) { count++; file = create_file(); initialize_file(file, client, p); send_initialize(sockfd, &server, &seq, file, client, hftpd, p, count); // Keep sending data messages until a file is transferred while (!file->file_transferred) { manage_file_buffer(file); send_data(sockfd, &server, &seq, file); update_progress(file); } //end while final_progress_update(file); free_file_info(file); p = p->next; } //end while send_termination(sockfd, &server, &seq, p, client); // Close the socket close(sockfd); return 1; } //end hooli_file_sync
static void other_btn_cb (GtkWidget *widget, gpointer data) { struct select_keys_s *sk = data; char *uid; cm_return_if_fail (sk); uid = input_dialog ( _("Add key"), _("Enter another user or key ID:"), NULL ); if (!uid) return; if (fill_clist (sk, uid, sk->proto) != NULL) { gpgme_release(sk->select_ctx); sk->select_ctx = NULL; } update_progress (sk, 0, sk->pattern); g_free (uid); }
bool GncSqlBackend::write_schedXactions() { GList* schedXactions; SchedXaction* tmpSX; bool is_ok = true; schedXactions = gnc_book_get_schedxactions (m_book)->sx_list; auto obe = m_backend_registry.get_object_backend(GNC_ID_SCHEDXACTION); for (; schedXactions != NULL && is_ok; schedXactions = schedXactions->next) { tmpSX = static_cast<decltype (tmpSX)> (schedXactions->data); is_ok = obe->commit (this, QOF_INSTANCE (tmpSX)); } update_progress(); return is_ok; }
static void nautilus_progress_info_widget_constructed (GObject *obj) { NautilusProgressInfoWidget *self = NAUTILUS_PROGRESS_INFO_WIDGET (obj); G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->constructed (obj); g_signal_connect_swapped (self->priv->info, "changed", G_CALLBACK (update_data), self); g_signal_connect_swapped (self->priv->info, "progress-changed", G_CALLBACK (update_progress), self); g_signal_connect_swapped (self->priv->info, "finished", G_CALLBACK (info_finished), self); g_signal_connect_swapped (self->priv->info, "cancelled", G_CALLBACK (info_cancelled), self); update_data (self); update_progress (self); }
/* handle the files in the given directory * calls walk_dir in case a directory is found and recursively * looking through in the subdirectories */ static int handle_file(char *fname) { struct stat stbuf; md5_t chksum = { 0 }; if (stat(fname, &stbuf) == -1) { perror(strerror(errno)); goto error; } if (S_ISDIR(stbuf.st_mode)) { check_error(walk_dir(fname, handle_file)); } else { check_error(md5_get(fname, chksum)); hasharray_add(chksum, fname); update_progress(); } return R_OK; error: return R_ERR; }