int main(int argc,char* argv[]) { int rc; /** caribou_init() must first be called before any other CARIBOU function calls */ caribou_init(0); print_summary(); /** Initialize a mutex object */ caribou_mutex_init(&test.mutex_a,0); /** Initialize a queue of the specified depth */ caribou_queue_init(&test.queue_a,QUEUE_DEPTH,&test.queue_msgs); /** Allocate and start up the enqueue and dequeue threads... */ caribou_thread_create("test1_thread",test1_thread,NULL,NULL,test.stack_thread1,THREAD_STACK_SIZE,THREAD_PRIORITY); caribou_thread_create("test2_thread",test2_thread,NULL,NULL,test.stack_thread2,THREAD_STACK_SIZE,THREAD_PRIORITY); caribou_thread_create("board_thread",board_thread,NULL,NULL,test.board_stack,THREAD_STACK_SIZE,THREAD_PRIORITY); /** * House keep chores are managed from the main thread, and must be called via caribou_exec() * Never to return */ caribou_exec(); }
int main(int argc, char* argv[]) { if (argc > 1) { fprintf(stderr, "%s: usage: summarize\n", argv[0]); exit(1); } /* FILE* f = fopen(argv[1], "w"); if (f == NULL) { perror(argv[1]); exit(1); } */ FILE* f = stdout; fprintf(f, "\n==================================================\n"); fprintf(f, "[SUMMARY] Test Summary\n"); fprintf(f, "==================================================\n\n"); size_t len; char* ln; long total = 0; long pass = 0; long fail = 0; long total_total = 0; long total_pass = 0; long total_fail = 0; for(;;) { ln = fgetln(stdin, &len); //if (ln) fprintf(stdout, "%.*s", (int)len, ln); if (ln == NULL || has_prefix(ln, "[TEST]")) { if (total) { print_summary(f, total, pass, fail); } total_total += total; total_pass += pass; total_fail += fail; total = 0; pass = 0; fail = 0; if (ln) { fprintf(f, "%.*s", (int)len, ln); } else { fprintf(f, "[TOTAL]\n"); print_summary(f, total_total, total_pass, total_fail); break; } } else if (has_prefix(ln, "[PASS]")) { ++total; ++pass; } else if (has_prefix(ln, "[FAIL]")) { ++total; ++fail; } } return (total_fail ? EXIT_FAILURE : EXIT_SUCCESS); }
static int tester_summarize(void) { unsigned int not_run = 0, passed = 0, failed = 0; gdouble execution_time; GList *list; printf("\n"); print_text(COLOR_HIGHLIGHT, ""); print_text(COLOR_HIGHLIGHT, "Test Summary"); print_text(COLOR_HIGHLIGHT, "------------"); for (list = g_list_first(test_list); list; list = g_list_next(list)) { struct test_case *test = list->data; gdouble exec_time; exec_time = test->end_time - test->start_time; switch (test->result) { case TEST_RESULT_NOT_RUN: print_summary(test->name, COLOR_YELLOW, "Not Run", ""); not_run++; break; case TEST_RESULT_PASSED: print_summary(test->name, COLOR_GREEN, "Passed", "%8.3f seconds", exec_time); passed++; break; case TEST_RESULT_FAILED: print_summary(test->name, COLOR_RED, "Failed", "%8.3f seconds", exec_time); failed++; break; case TEST_RESULT_TIMED_OUT: print_summary(test->name, COLOR_RED, "Timed out", "%8.3f seconds", exec_time); failed++; break; } } printf("\nTotal: %d, " COLOR_GREEN "Passed: %d (%.1f%%)" COLOR_OFF ", " COLOR_RED "Failed: %d" COLOR_OFF ", " COLOR_YELLOW "Not Run: %d" COLOR_OFF "\n", not_run + passed + failed, passed, (not_run + passed + failed) ? (float) passed * 100 / (not_run + passed + failed) : 0, failed, not_run); execution_time = g_timer_elapsed(test_timer, NULL); printf("Overall execution time: %.3g seconds\n", execution_time); return failed; }
static void cb_complete_run (CutRunContext *run_context, gboolean success, CutConsoleUI *console) { CutVerboseLevel verbose_level; notify(console, run_context, success); verbose_level = console->verbose_level; if (verbose_level < CUT_VERBOSE_LEVEL_NORMAL) return; if (verbose_level == CUT_VERBOSE_LEVEL_NORMAL) g_print("\n"); print_results(console, run_context); g_print("\n"); g_print("Finished in %f seconds (total: %f seconds)", cut_run_context_get_elapsed(run_context), cut_run_context_get_total_elapsed(run_context)); g_print("\n\n"); print_summary(console, run_context); }
int main (int argc, char **argv) { int rc; int fd; const char *path; struct libevdev *dev; struct measurements measurements = {0}; if (argc < 2) return usage(); path = argv[1]; if (path[0] == '-') return usage(); fd = open(path, O_RDONLY|O_NONBLOCK); if (fd < 0) { fprintf(stderr, "Error opening the device: %s\n", strerror(errno)); return 1; } rc = libevdev_new_from_fd(fd, &dev); if (rc != 0) { fprintf(stderr, "Error fetching the device info: %s\n", strerror(-rc)); return 1; } if (libevdev_grab(dev, LIBEVDEV_GRAB) != 0) { fprintf(stderr, "Error: cannot grab the device, something else is grabbing it.\n"); fprintf(stderr, "Use 'fuser -v %s' to find processes with an open fd\n", path); return 1; } libevdev_grab(dev, LIBEVDEV_UNGRAB); printf("Mouse %s on %s\n", libevdev_get_name(dev), path); printf("Move the device 250mm/10in or more along the x-axis.\n"); printf("Pause 3 seconds before movement to reset, Ctrl+C to exit.\n"); setbuf(stdout, NULL); rc = mainloop(dev, &measurements); printf("\n"); print_summary(&measurements); printf("\n"); printf("Entry for hwdb match (replace XXX with the resolution in DPI):\n" "mouse:%s:v%04xp%04x:name:%s:\n" " MOUSE_DPI=XXX@%d\n", bustype(libevdev_get_id_bustype(dev)), libevdev_get_id_vendor(dev), libevdev_get_id_product(dev), libevdev_get_name(dev), (int)measurements.max_frequency); libevdev_free(dev); close(fd); return rc; }
int main(int argc, const char *argv[]) { fit_summary *summary; int i; /* Check arguments */ if (argc < 2) { printf("Usage: %s FIT-FILE\n", argv[0]); return EXIT_SUCCESS; } for (i = 1; i < argc; i++) { iprintf("Activity: %s\n", argv[i]); print_increase_indent(); summary = summarize(argv[i]); if (summary) { print_summary(summary); // print_record_table(summary); destroy_summary(summary); } print_decrease_indent(); } return EXIT_SUCCESS; }
int main() { int i,j,k; int error = 0; printf("Start stencil\n"); for (i=0;i<N;i++) { for (k=0;k<M;k++) A[i*M+k] = i+k+1; W[i] = i+2; } for (j = 0; j<2; j++) { stencil(A, h_R, W); } for (i=0;i<N;i++) { for (k=0;k<M;k++) { if (RESULT_STENCIL[i*M+k] != h_R[i*M+k]) { error = error + 1; printf("Error occurred at i=%d k=%d; Computed result R=%d does not match expected Result=%d\n",i,k,h_R[i*M+k],RESULT_STENCIL[i*M+k]); } } } print_summary(error); return 0; }
int main() { coral::rpc::RpcObject srcObject; coral::rpc::RpcObject dstObject; srcObject.resource = "calculator"; srcObject.action = "add"; srcObject.instanceId = 2; srcObject.rpcId = 21754; srcObject.error.exceptionId = NoException; std::string data; data = srcObject.serialize(); std::cout << "data.size() = " << data.size() << std::endl; ASSERT_EQUAL(bool, true, dstObject.deserialize(data)); ASSERT_EQUAL(std::string, "calculator", dstObject.resource); ASSERT_EQUAL(std::string, "add", dstObject.action); ASSERT_EQUAL(i32, 2, dstObject.instanceId); ASSERT_EQUAL(i32, 21754, dstObject.rpcId); ASSERT_EQUAL(RpcException, NoException, dstObject.error.exceptionId); print_summary(); return 0; }
int main(int argc, char **argv) { char *queryp; int bool_balance; sanitize_input(&argc, argv); if (argv[1][0] == 's') { print_summary(argv[2]); exit(0); } mysql_start(); bool_balance = check_balance(&argc, argv); queryp = forge_query(&argc, argv); mysql_insert(queryp); if (bool_balance) calculate_balance(&argc, argv); mysql_stop(); return 0; }
static void call_destructor(void *arg) { struct call *call = arg; if (call->state != STATE_IDLE) print_summary(call); call_stream_stop(call); list_unlink(&call->le); tmr_cancel(&call->tmr_dtmf); mem_deref(call->sess); mem_deref(call->local_uri); mem_deref(call->local_name); mem_deref(call->peer_uri); mem_deref(call->peer_name); mem_deref(call->audio); #ifdef USE_VIDEO mem_deref(call->video); mem_deref(call->bfcp); #endif mem_deref(call->sdp); mem_deref(call->mnats); mem_deref(call->mencs); mem_deref(call->sub); mem_deref(call->not); mem_deref(call->acc); }
static void annotate_sym(struct hist_entry *he) { struct map *map = he->map; struct dso *dso = map->dso; struct symbol *sym = he->sym; const char *filename = dso->long_name, *d_filename; u64 len; char command[PATH_MAX*2]; FILE *file; if (!filename) return; if (verbose) fprintf(stderr, "%s: filename=%s, sym=%s, start=%Lx, end=%Lx\n", __func__, filename, sym->name, map->unmap_ip(map, sym->start), map->unmap_ip(map, sym->end)); if (full_paths) d_filename = filename; else d_filename = basename(filename); len = sym->end - sym->start; if (print_line) { get_source_line(he, len, filename); print_summary(filename); } printf("\n\n------------------------------------------------\n"); printf(" Percent | Source code & Disassembly of %s\n", d_filename); printf("------------------------------------------------\n"); if (verbose >= 2) printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->long_name, sym, sym->name); sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s", map->unmap_ip(map, sym->start), map->unmap_ip(map, sym->end), filename, filename); if (verbose >= 3) printf("doing: %s\n", command); file = popen(command, "r"); if (!file) return; while (!feof(file)) { if (parse_line(file, he, len) < 0) break; } pclose(file); if (print_line) free_source_line(he, len); }
int main(int argc, char** argv) { lang_t lang; article_t article; status_t status; int opt; literal_t file_name = NULL; float ratio = 0.0; while(-1 != (opt = getopt(argc, argv, "i:r:h"))) { switch(opt) { case 'i': file_name = optarg; break; case 'r': ratio = atof(optarg)/100; break; case 'h': usage(argv[0]); return(0); default: usage(argv[0]); return(1); } } if(NULL == file_name) { fprintf(stderr, "No input file specified\n"); usage(argv[0]); return(1); } if(0.0 == ratio) { fprintf(stderr, "Ratio cannot be 0.0\n"); usage(argv[0]); return(1); } status = init_globals() || lang_init(&lang) || parse_lang_xml(DICTIONARY_DIR"/en.xml", &lang) || article_init(&article) || parse_article(file_name, &lang, &article) || grade_article(&article, &lang, ratio); print_summary(&article); article_destroy(&article); lang_destroy(&lang); return(SMRZR_OK == status ? 0 : 1); }
static void print_progress(uperf_shm_t *shm, newstats_t prev) { if (ENABLED_STATS(options)) { newstats_t pns; update_aggr_stat(shm); (void) memcpy(&pns, AGG_STAT(shm), sizeof (pns)); pns.start_time = prev.end_time; pns.size -= prev.size; pns.end_time = GETHRTIME(); pns.count -= prev.count; (void) strlcpy(pns.name, prev.name, sizeof (pns.name)); print_summary(&pns, 1); } }
int print_total(unsigned long files, unsigned long dirs, unsigned long bytes) { int rv; if(optB) return 0; rv = flush_nl(); if(rv == E_None) { printf("\tTotal of %s\n", path); if((rv = incline()) == E_None) return print_summary(files, dirs, bytes); } return rv; }
int main(int argc, char ** argv) { if ( argc != 2 ) { fprintf(stderr, "Usage: pricelist FILENAME\n"); return EXIT_FAILURE; } const int dbfd = x_open(argv[1], O_RDWR | O_CREAT, 0644); bool should_quit = false; while ( !should_quit ) { print_summary(dbfd, argv[1]); int choice = get_menu_choice(); struct record record; switch ( choice ) { case MENU_LIST: list_records(dbfd); break; case MENU_ADD: get_new_record(&record); write_record(dbfd, &record, -1); break; case MENU_DELETE: printf("Enter record number to delete: "); fflush(stdout); delete_record(dbfd, get_integer()); break; case MENU_QUIT: printf("Goodbye!\n"); should_quit = true; break; default: printf("Invalid menu choice. Try again.\n\n"); break; } } x_close(dbfd); return 0; }
static gboolean output_plain (MuMsg *msg, MuMsgIter *iter, MuConfig *opts, GError **err) { /* we reuse the color (whatever that may be) * for message-priority for threads, too */ ansi_color_maybe (MU_MSG_FIELD_ID_PRIO, !opts->nocolor); if (opts->threads) thread_indent (iter); output_plain_fields (msg, opts->fields, !opts->nocolor, opts->threads); if (opts->summary_len > 0) print_summary (msg, opts); return TRUE; }
int print_total (unsigned long files, unsigned long bytes) { int rv; if(optB) return 0; rv = flush_nl(); if(rv == E_None) { printf("Total files listed:\n"); if((rv = incline()) == E_None) return print_summary(files, bytes); } return rv; }
/** * int event_loop() * * page all selected algorithms with input ref * * @param page_ref {int} page to ref * * @return 0 */ int event_loop() { counter = 0; while(counter < max_page_calls) { page(get_ref()); ++counter; } size_t i = 0; for (i = 0; i < num_algos; i++) { if(algos[i].selected==1) { print_summary(algos[i]); } } return 0; }
void CompilerTest::run_tests(JVM_SINGLE_ARG_TRAPS) { UsingFastOops fast_oops; ObjArray::Fast classes; ObjArray::Fast methods; InstanceClass::Fast klass; Method::Fast m; Os::suspend_profiler(); { classes = load_and_sort_classes(JVM_SINGLE_ARG_CHECK); } Os::resume_profiler(); int num_classes = classes().length(); for (int i=0; i<num_classes; i++) { klass = classes().obj_at(i); Os::suspend_profiler(); { methods = sort_methods(&klass JVM_CHECK); } Os::resume_profiler(); if (Verbose) { tty->print("Compiling class: "); klass().print_name_on(tty); tty->cr(); } int num_methods = methods().length(); for (int j=0; j<num_methods; j++) { m = methods().obj_at(j); if (m.not_null() && !m().is_impossible_to_compile() && !m().is_abstract()) { test_compile(&m JVM_CHECK); } } } Os::suspend_profiler(); { print_summary(); } Os::resume_profiler(); }
int main(int argc, char * argv[]) { char line[256]; int count = 5; FILE * input = stdin; if(argc > 1 && !strcmp(argv[1], "-n")) { if(argc > 2) { count = atoi(argv[2]); if(count < 2) { fprintf(stderr, "%s: argument to -n must be at least 2\n", argv[0]); return 1; } } else { fprintf(stderr, "%s: option -n requires an argument\n", argv[0]); return 1; } argc -= 2; argv += 2; } if(argc > 1) { input = fopen(argv[1], "r"); if(!input) { perror(argv[1]); return 1; } } while(fgets(line, sizeof(line), input)) process_line(line); if(input != stdin) fclose(input); return (print_summary(count) < 0) ? 1 : 0; }
void print_beam(ll_params_t *beam) { static int header_count = 0; static int summary_count = 0; /* * print out as requested */ if (Glob->params.print_header) { if (header_count == 0) print_header(beam); header_count++; if (header_count == Glob->params.header_interval) header_count = 0; } /* if (Glob->params.header_print) */ if (Glob->params.print_summary) { if (summary_count == 0) print_summary(beam); summary_count++; if (summary_count == Glob->params.summary_interval) summary_count = 0; } /* if (Glob->params.summary_print) */ }
void mt_compress_all(void){ int i; pthread_t *thread_ids; int *index; NewMemory((void **)&thread_ids,mt_nthreads*sizeof(pthread_t)); NewMemory((void **)&index,mt_nthreads*sizeof(int)); NewMemory((void **)&threadinfo,mt_nthreads*sizeof(threaddata)); for(i=0;i<mt_nthreads;i++){ index[i]=i; pthread_create(&thread_ids[i],NULL,compress_all,&index[i]); threadinfo[i].stat=-1; } for(i=0;i<mt_nthreads;i++){ pthread_join(thread_ids[i],NULL); } print_summary(); FREEMEMORY(thread_ids); FREEMEMORY(index); FREEMEMORY(threadinfo); }
int main() { // Configure ISRs int_init(); int_add(29, (void *) int_time_cmp, 0); int_enable(); EER = 0xF0000000; // enable all timer events; IER = 0xF0000000; // enable all timer interrupts /* Setup Timer A */ TOCRA = 0x80; TPRA = 0x3F; // set prescaler, enable interrupts and start timer. while (timer_triggered < 5) { printf("Loop Counter: %d\n", timer_triggered); sleep(); } set_gpio_pin_value(0, 0); int_disable(); print_summary(0); return 0; }
int cmd_commit(int argc, const char **argv, const char *prefix) { static struct wt_status s; static struct option builtin_commit_options[] = { OPT__QUIET(&quiet, N_("suppress summary after successful commit")), OPT__VERBOSE(&verbose, N_("show diff in commit message template")), OPT_GROUP(N_("Commit message options")), OPT_FILENAME('F', "file", &logfile, N_("read message from file")), OPT_STRING(0, "author", &force_author, N_("author"), N_("override author for commit")), OPT_STRING(0, "date", &force_date, N_("date"), N_("override date for commit")), OPT_CALLBACK('m', "message", &message, N_("message"), N_("commit message"), opt_parse_m), OPT_STRING('c', "reedit-message", &edit_message, N_("commit"), N_("reuse and edit message from specified commit")), OPT_STRING('C', "reuse-message", &use_message, N_("commit"), N_("reuse message from specified commit")), OPT_STRING(0, "fixup", &fixup_message, N_("commit"), N_("use autosquash formatted message to fixup specified commit")), OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")), OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")), OPT_BOOL('s', "signoff", &signoff, N_("add Signed-off-by:")), OPT_FILENAME('t', "template", &template_file, N_("use specified template file")), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")), OPT_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")), OPT_BOOL(0, "status", &include_status, N_("include status in commit message template")), { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key id"), N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, /* end commit message options */ OPT_GROUP(N_("Commit contents options")), OPT_BOOL('a', "all", &all, N_("commit all changed files")), OPT_BOOL('i', "include", &also, N_("add specified files to index for commit")), OPT_BOOL(0, "interactive", &interactive, N_("interactively add files")), OPT_BOOL('p', "patch", &patch_interactive, N_("interactively add changes")), OPT_BOOL('o', "only", &only, N_("commit only specified files")), OPT_BOOL('n', "no-verify", &no_verify, N_("bypass pre-commit hook")), OPT_BOOL(0, "dry-run", &dry_run, N_("show what would be committed")), OPT_SET_INT(0, "short", &status_format, N_("show status concisely"), STATUS_FORMAT_SHORT), OPT_BOOL(0, "branch", &s.show_branch, N_("show branch information")), OPT_SET_INT(0, "porcelain", &status_format, N_("machine-readable output"), STATUS_FORMAT_PORCELAIN), OPT_SET_INT(0, "long", &status_format, N_("show status in long format (default)"), STATUS_FORMAT_LONG), OPT_BOOL('z', "null", &s.null_termination, N_("terminate entries with NUL")), OPT_BOOL(0, "amend", &amend, N_("amend previous commit")), OPT_BOOL(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")), { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, /* end commit contents options */ OPT_HIDDEN_BOOL(0, "allow-empty", &allow_empty, N_("ok to record an empty change")), OPT_HIDDEN_BOOL(0, "allow-empty-message", &allow_empty_message, N_("ok to record a change with an empty message")), OPT_END() }; struct strbuf sb = STRBUF_INIT; struct strbuf author_ident = STRBUF_INIT; const char *index_file, *reflog_msg; char *nl; unsigned char sha1[20]; struct ref_lock *ref_lock; struct commit_list *parents = NULL, **pptr = &parents; struct stat statbuf; struct commit *current_head = NULL; struct commit_extra_header *extra = NULL; if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_commit_usage, builtin_commit_options); status_init_config(&s, git_commit_config); status_format = STATUS_FORMAT_NONE; /* Ignore status.short */ s.colopts = 0; if (get_sha1("HEAD", sha1)) current_head = NULL; else { current_head = lookup_commit_or_die(sha1, "HEAD"); if (parse_commit(current_head)) die(_("could not parse HEAD commit")); } argc = parse_and_validate_options(argc, argv, builtin_commit_options, builtin_commit_usage, prefix, current_head, &s); if (dry_run) return dry_run_commit(argc, argv, prefix, current_head, &s); index_file = prepare_index(argc, argv, prefix, current_head, 0); /* Set up everything for writing the commit object. This includes running hooks, writing the trees, and interacting with the user. */ if (!prepare_to_commit(index_file, prefix, current_head, &s, &author_ident)) { rollback_index_files(); return 1; } /* Determine parents */ reflog_msg = getenv("GIT_REFLOG_ACTION"); if (!current_head) { if (!reflog_msg) reflog_msg = "commit (initial)"; } else if (amend) { struct commit_list *c; if (!reflog_msg) reflog_msg = "commit (amend)"; for (c = current_head->parents; c; c = c->next) pptr = &commit_list_insert(c->item, pptr)->next; } else if (whence == FROM_MERGE) { struct strbuf m = STRBUF_INIT; FILE *fp; int allow_fast_forward = 1; if (!reflog_msg) reflog_msg = "commit (merge)"; pptr = &commit_list_insert(current_head, pptr)->next; fp = fopen(git_path("MERGE_HEAD"), "r"); if (fp == NULL) die_errno(_("could not open '%s' for reading"), git_path("MERGE_HEAD")); while (strbuf_getline(&m, fp, '\n') != EOF) { struct commit *parent; parent = get_merge_parent(m.buf); if (!parent) die(_("Corrupt MERGE_HEAD file (%s)"), m.buf); pptr = &commit_list_insert(parent, pptr)->next; } fclose(fp); strbuf_release(&m); if (!stat(git_path("MERGE_MODE"), &statbuf)) { if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0) die_errno(_("could not read MERGE_MODE")); if (!strcmp(sb.buf, "no-ff")) allow_fast_forward = 0; } if (allow_fast_forward) parents = reduce_heads(parents); } else { if (!reflog_msg) reflog_msg = (whence == FROM_CHERRY_PICK) ? "commit (cherry-pick)" : "commit"; pptr = &commit_list_insert(current_head, pptr)->next; } /* Finally, get the commit message */ strbuf_reset(&sb); if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { int saved_errno = errno; rollback_index_files(); die(_("could not read commit message: %s"), strerror(saved_errno)); } /* Truncate the message just before the diff, if any. */ if (verbose) wt_status_truncate_message_at_cut_line(&sb); if (cleanup_mode != CLEANUP_NONE) stripspace(&sb, cleanup_mode == CLEANUP_ALL); if (template_untouched(&sb) && !allow_empty_message) { rollback_index_files(); fprintf(stderr, _("Aborting commit; you did not edit the message.\n")); exit(1); } if (message_is_empty(&sb) && !allow_empty_message) { rollback_index_files(); fprintf(stderr, _("Aborting commit due to empty commit message.\n")); exit(1); } if (amend) { const char *exclude_gpgsig[2] = { "gpgsig", NULL }; extra = read_commit_extra_headers(current_head, exclude_gpgsig); } else { struct commit_extra_header **tail = &extra; append_merge_tag_headers(parents, &tail); } if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1, author_ident.buf, sign_commit, extra)) { rollback_index_files(); die(_("failed to write commit object")); } strbuf_release(&author_ident); free_commit_extra_headers(extra); ref_lock = lock_any_ref_for_update("HEAD", !current_head ? NULL : current_head->object.sha1, 0, NULL); nl = strchr(sb.buf, '\n'); if (nl) strbuf_setlen(&sb, nl + 1 - sb.buf); else strbuf_addch(&sb, '\n'); strbuf_insert(&sb, 0, reflog_msg, strlen(reflog_msg)); strbuf_insert(&sb, strlen(reflog_msg), ": ", 2); if (!ref_lock) { rollback_index_files(); die(_("cannot lock HEAD ref")); } if (write_ref_sha1(ref_lock, sha1, sb.buf) < 0) { rollback_index_files(); die(_("cannot update HEAD ref")); } unlink(git_path("CHERRY_PICK_HEAD")); unlink(git_path("REVERT_HEAD")); unlink(git_path("MERGE_HEAD")); unlink(git_path("MERGE_MSG")); unlink(git_path("MERGE_MODE")); unlink(git_path("SQUASH_MSG")); if (commit_index_files()) die (_("Repository has been updated, but unable to write\n" "new_index file. Check that disk is not full or quota is\n" "not exceeded, and then \"git reset HEAD\" to recover.")); rerere(0); run_hook(get_index_file(), "post-commit", NULL); if (amend && !no_post_rewrite) { struct notes_rewrite_cfg *cfg; cfg = init_copy_notes_for_rewrite("amend"); if (cfg) { /* we are amending, so current_head is not NULL */ copy_note_for_rewrite(cfg, current_head->object.sha1, sha1); finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'"); } run_rewrite_hook(current_head->object.sha1, sha1); } if (!quiet) print_summary(prefix, sha1, !current_head); return 0; }
static void do_lockdebug(char *name) { struct summary summary; struct rinfo info; FILE *file; char path[PATH_MAX]; char line[LOCK_LINE_MAX]; int old = 0; snprintf(path, PATH_MAX, "/sys/kernel/debug/dlm/%s_all", name); file = fopen(path, "r"); if (!file) { snprintf(path, PATH_MAX, "/sys/kernel/debug/dlm/%s", name); file = fopen(path, "r"); if (!file) { fprintf(stderr, "can't open %s: %s\n", path, strerror(errno)); return; } old = 1; } memset(&summary, 0, sizeof(struct summary)); memset(&info, 0, sizeof(struct rinfo)); while (fgets(line, LOCK_LINE_MAX, file)) { if (old) goto raw; if (!strncmp(line, "version", 7)) continue; if (!strncmp(line, "rsb", 3)) { count_rinfo(&summary, &info); clear_rinfo(&info); printf("\n"); print_rsb(line, &info); continue; } if (!strncmp(line, "lvb", 3)) { print_lvb(line); info.lvb = 1; continue; } if (!strncmp(line, "lkb", 3)) { print_lkb(line, &info); continue; } raw: printf("%s", line); } count_rinfo(&summary, &info); clear_rinfo(&info); printf("\n"); fclose(file); do_toss(name, &summary); do_waiters(name, &summary); if (summarize) { printf("\n"); print_summary(&summary); } }
int main(int argc, char** argv) { #if defined(__APPLE__) glfwInit(); glfwEnable(GLFW_AUTO_POLL_EVENTS); /* No explicit call to glfwPollEvents() */ glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_FALSE); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #if defined(NDEBUG) glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_FALSE); #else glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); #endif GLboolean Result = glfwOpenWindow(512, 512, 0, 0, 0, 0, 16, 0, GLFW_WINDOW); assert(Result == GL_TRUE); glewExperimental = GL_TRUE; glewInit(); /* if(::LoadFunctions() == LS_LOAD_FAILED) { exit(1); } glTexImage3D = (PFNGLTEXIMAGE3DPROC)glfwGetProcAddress("glTexImage3D"); */ glfwSetWindowTitle("triangles"); // glfwSetMousePosCallback(cursor_position_callback); // glfwSetWindowCloseCallback(close_callback); // glfwSetKeyCallback(glfw_key); // glfwSetKeyCallback(special); // glfwSetCharCallback(keyboard); // glfwSetWindowSizeCallback(reshape); GLint MajorVersionContext = 0; GLint MinorVersionContext = 0; glGetIntegerv(GL_MAJOR_VERSION, &MajorVersionContext); glGetIntegerv(GL_MINOR_VERSION, &MinorVersionContext); printf("OpenGL version = %d.%d\n", MajorVersionContext, MinorVersionContext); init(); print_summary(); while(true) { if(terminating) break; display(); } glfwTerminate(); exit(EXIT_SUCCESS); return 0; #else glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(512, 512); glutInitContextVersion(4,3); glutInitContextFlags (GLUT_CORE_PROFILE | GLUT_DEBUG); glutInitContextProfile(GLUT_FORWARD_COMPATIBLE); glutCreateWindow(argv[0]); if (glewInit()) { std::cerr << "Unable to initialize GLEW ... exiting" << std::endl; exit(EXIT_FAILURE); } init(); glutDisplayFunc(display); glutMainLoop(); #endif }
int main(int argc, char ** argv) { int c; int option_index = 0; int ret=0; global_context_t * global_context; global_context = (global_context_t*)malloc(sizeof(global_context_t)); init_global_context(global_context); global_context->config.entry_program_name = CORE_PROGRAM_SUBINDEL; optind = 1; opterr = 1; optopt = 63; while ((c = getopt_long (argc, argv, "pi:g:o:I:d:?v", long_options, &option_index)) != -1) { switch(c) { case 'i': strncpy(global_context->config.first_read_file, optarg, MAX_FILE_NAME_LENGTH-1); break; case 'p': global_context -> input_reads.is_paired_end_reads=1; break; case 'g': strncpy(global_context->config.index_prefix, optarg, MAX_FILE_NAME_LENGTH-1); break; case 'o': strncpy(global_context->config.output_prefix, optarg, MAX_FILE_NAME_LENGTH-1); break; case 'd': global_context->config.expected_pair_distance = atoi(optarg); break; case 'v': core_version_number("subindel"); return 0; break; case 'I': global_context->config.max_indel_length = atoi(optarg); if(global_context->config.max_indel_length>=16) { global_context->config.reassembly_subread_length = 16; global_context->config.reassembly_window_multiplex = 3; global_context->config.reassembly_start_read_number = 3; global_context->config.reassembly_tolerable_voting = 0; global_context->config.reassembly_window_alleles = 3; global_context->config.reassembly_key_length = 28; } break; default: case 'h': print_usage_subindel(); return -1; break; } } if(argc<3) { print_usage_subindel(); return -1; } ret = print_configuration_forindel(global_context); warning_file_type(global_context->config.first_read_file,global_context->config.is_BAM_input?FILE_TYPE_BAM:FILE_TYPE_SAM); ret = ret || load_global_context_forindel(global_context); ret = ret || load_indexes_forindel(global_context); ret = ret || transfer_SAM_to_assembly(global_context); ret = ret || init_indel_tables(global_context); ret = ret || finalise_long_insertions_by_hashtable(global_context); ret = ret || write_indel_final_results(global_context); ret = ret || destroy_indel_module(global_context); ret = ret || print_summary(global_context); free(global_context); return ret; }
int main(int argc, char **argv) { int rc = 0; auparse_state_t *au = NULL; setlocale(LC_ALL, ""); if (parse_args(argc, argv)) goto error; if (help_flag) { usage(stdout); goto exit; } /* Initialize event list*/ events = list_new((list_free_data_fn*) event_free); if (events == NULL) goto unexpected_error; /* Initialize auparse */ au = init_auparse(); if (au == NULL) goto error; if (create_search_criteria(au)) goto error; while (ausearch_next_event(au) > 0) { int err = 0; switch(auparse_get_type(au)) { case AUDIT_VIRT_MACHINE_ID: err = process_machine_id_event(au); break; case AUDIT_VIRT_CONTROL: err = process_control_event(au); break; case AUDIT_VIRT_RESOURCE: err = process_resource_event(au); break; case AUDIT_AVC: err = process_avc(au); break; case AUDIT_FIRST_ANOM_MSG ... AUDIT_LAST_ANOM_MSG: case AUDIT_FIRST_KERN_ANOM_MSG ... AUDIT_LAST_KERN_ANOM_MSG: err = process_anom(au); break; case AUDIT_SYSTEM_SHUTDOWN: err = process_shutdown(au); break; } if (err) { goto unexpected_error; } auparse_next_event(au); } /* Show results */ if (summary_flag) { print_summary(); } else { print_events(); } /* success */ goto exit; unexpected_error: fprintf(stderr, "Unexpected error\n"); error: rc = 1; exit: if (au) auparse_destroy(au); list_free(events); if (debug) fprintf(stdout, "Exit code: %d\n", rc); return rc; }
int main(int argc,char **argv) { pcap_t *pcap; char pcapErr[PCAP_ERRBUF_SIZE], line[80] ; char* title; int datalink; char timeDuration[MAX_BUF_SIZE]; char file_name[MAX_BUF_SIZE]; if (argc != 2) { printf("Usage: ./wiretap file.pcap\n"); printf(" ./wiretap file.pcap > output.txt\n"); exit(1); } strcpy(file_name, argv[1]); pcap = pcap_open_offline(file_name, pcapErr); if (pcap == NULL) { fprintf(stderr, "pcap_open_offline failed: %s\n", pcapErr); exit(EXIT_FAILURE); } datalink = pcap_datalink(pcap); if(datalink != Ethernet) { printf("not Ethernet!\n"); exit(EXIT_FAILURE); } pcap_loop(pcap,-1,my_callback,NULL); getTimeDiff(timeDuration); print_summary(timebuffer, start_time, timeDuration); printf("=== Link layer ===\n\n"); print("Source ethernet addresses", eth_src_addr, packets); free_nodes(eth_src_addr); print("Destination ethernet addresses", eth_dest_addr, packets); free_nodes(eth_dest_addr); printf("=== Network Layer ===\n\n"); print("Network layer protocols", net_layer, packets); free_nodes(net_layer); print("Source IP addresses", IP_src_addr, ip_packets); free_nodes(IP_src_addr); print("Destination IP addresses", IP_dest_addr, ip_packets); free_nodes(IP_dest_addr); print("TTLs",TTL_list, ip_packets); free_nodes(TTL_list); print_arp(arp_participants); free_arp_nodes(arp_participants); printf("=== Transport Layer ===\n\n"); print("Transport Layer protocols", transLayer, ip_packets); free_nodes(transLayer); printf("=== Transport Layer: TCP ===\n\n"); print("Source TCP ports", TCP_src_ports, TCP_packets); free_nodes(TCP_src_ports); print("Destination TCP ports", TCP_dest_ports, TCP_packets); free_nodes(TCP_dest_ports); print("TCP flags", TCP_flags, TCP_packets); free_nodes(TCP_flags); print("TCP options", TCP_options, TCP_packets); free_nodes(TCP_options); printf("=== Transport Layer: UDP ===\n\n"); print("Source UDP ports", UDP_src_ports, UDP_packets); free_nodes(UDP_src_ports); print("Destination UDP ports", UDP_dest_ports, UDP_packets); free_nodes(UDP_dest_ports); printf("=== Transport Layer: ICMP ===\n\n"); print("Source IPs for ICMP", ICMP_src_IP, ICMP_packets); free_nodes(ICMP_src_IP); print("Destination IPs for ICMP", ICMP_dest_IP, ICMP_packets); free_nodes(ICMP_dest_IP); print("ICMP types", ICMP_TYPE, ICMP_packets); free_nodes(ICMP_TYPE); print("ICMP codes", ICMP_CODE, ICMP_packets); free_nodes(ICMP_CODE); print("ICMP responses", ICMP_RESPONSE, ICMP_packets); free_nodes(ICMP_RESPONSE); pcap_close(pcap); }
int main(int ac, char **av) { struct sigaction sa; struct trussinfo *trussinfo; char *fname; char **command; pid_t pid; int c; fname = NULL; /* Initialize the trussinfo struct */ trussinfo = (struct trussinfo *)calloc(1, sizeof(struct trussinfo)); if (trussinfo == NULL) errx(1, "calloc() failed"); pid = 0; trussinfo->outfile = stderr; trussinfo->strsize = 32; trussinfo->curthread = NULL; LIST_INIT(&trussinfo->proclist); init_syscalls(); while ((c = getopt(ac, av, "p:o:facedDs:SH")) != -1) { switch (c) { case 'p': /* specified pid */ pid = atoi(optarg); /* make sure i don't trace me */ if (pid == getpid()) { errx(2, "attempt to grab self."); } break; case 'f': /* Follow fork()'s */ trussinfo->flags |= FOLLOWFORKS; break; case 'a': /* Print execve() argument strings. */ trussinfo->flags |= EXECVEARGS; break; case 'c': /* Count number of system calls and time. */ trussinfo->flags |= (COUNTONLY | NOSIGS); break; case 'e': /* Print execve() environment strings. */ trussinfo->flags |= EXECVEENVS; break; case 'd': /* Absolute timestamps */ trussinfo->flags |= ABSOLUTETIMESTAMPS; break; case 'D': /* Relative timestamps */ trussinfo->flags |= RELATIVETIMESTAMPS; break; case 'o': /* Specified output file */ fname = optarg; break; case 's': /* Specified string size */ trussinfo->strsize = atoi(optarg); break; case 'S': /* Don't trace signals */ trussinfo->flags |= NOSIGS; break; case 'H': trussinfo->flags |= DISPLAYTIDS; break; default: usage(); } } ac -= optind; av += optind; if ((pid == 0 && ac == 0) || (pid != 0 && ac != 0)) usage(); if (fname != NULL) { /* Use output file */ /* * Set close-on-exec ('e'), so that the output file is not * shared with the traced process. */ if ((trussinfo->outfile = fopen(fname, "we")) == NULL) err(1, "cannot open %s", fname); } /* * If truss starts the process itself, it will ignore some signals -- * they should be passed off to the process, which may or may not * exit. If, however, we are examining an already-running process, * then we restore the event mask on these same signals. */ if (pid == 0) { /* Start a command ourselves */ command = av; setup_and_wait(trussinfo, command); signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); signal(SIGQUIT, SIG_IGN); } else { sa.sa_handler = restore_proc; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); start_tracing(trussinfo, pid); } /* * At this point, if we started the process, it is stopped waiting to * be woken up, either in exit() or in execve(). */ if (LIST_FIRST(&trussinfo->proclist)->abi == NULL) { /* * If we are not able to handle this ABI, detach from the * process and exit. If we just created a new process to * run a command, kill the new process rather than letting * it run untraced. */ if (pid == 0) kill(LIST_FIRST(&trussinfo->proclist)->pid, SIGKILL); ptrace(PT_DETACH, LIST_FIRST(&trussinfo->proclist)->pid, NULL, 0); return (1); } ptrace(PT_SYSCALL, LIST_FIRST(&trussinfo->proclist)->pid, (caddr_t)1, 0); /* * At this point, it's a simple loop, waiting for the process to * stop, finding out why, printing out why, and then continuing it. * All of the grunt work is done in the support routines. */ clock_gettime(CLOCK_REALTIME, &trussinfo->start_time); eventloop(trussinfo); if (trussinfo->flags & COUNTONLY) print_summary(trussinfo); fflush(trussinfo->outfile); return (0); }