int main(int argc, char** argv) { guint8 * key, * msg, * plain; gsize key_len, msg_len; key = g_malloc0(KEY_SIZE); msg = g_malloc0(MSG_SIZE); plain = g_malloc0(MSG_SIZE); if ((key_len = get_input(key, KEY_SIZE, "Enter QQ key: ")) == -1) { return EXIT_FAILURE; } if ((msg_len = get_input(msg, MSG_SIZE, "Enter QQ msg: ")) == -1) { return EXIT_FAILURE; } qq_decrypt(plain, msg, msg_len, key); g_printf("Encrypted msg: "); print_results(msg, msg_len); g_printf("Key: "); print_results(key, key_len); g_printf("Decrypted msg: "); print_results(plain, msg_len); g_free(key); g_free(msg); g_free(plain); return EXIT_SUCCESS; }
int main() { int m, i, n; double x[MAX_m], w[MAX_m], c[MAX_n+1], eps; m = 90; for (i=0; i<m; i++) { x[i] = 3.1415926535897932 * (double)(i+1) / 180.0; w[i] = 1.0; } eps = 0.001; n = OPA(f1, m, x, w, c, &eps); print_results(n, c, eps); m = 200; for (i=0; i<m; i++) { x[i] = 0.01*(double)i; w[i] = 1.0; } eps = 0.001; n = OPA(f2, m, x, w, c, &eps); print_results(n, c, eps); return 0; }
int main(int argc, char* argv[]) { bool test_kinematics = false; for(int i=1; i<argc; ++i) { if(std::string(argv[i])=="-k") test_kinematics = true; } std::vector<dart::simulation::WorldPtr> worlds = getWorlds(); if(test_kinematics) { std::cout << "Testing Kinematics" << std::endl; std::vector<double> acceleration_results; std::vector<double> velocity_results; std::vector<double> position_results; for(size_t i=0; i<10; ++i) { std::cout << "\nTrial #" << i+1 << std::endl; runKinematicsTest(acceleration_results, worlds, true, true, true); runKinematicsTest(velocity_results, worlds, true, true, false); runKinematicsTest(position_results, worlds, true, false, false); } std::cout << "\n\n --- Final Kinematics Results --- \n\n"; std::cout << "Position, Velocity, Acceleration\n"; print_results(acceleration_results); std::cout << "\nPosition, Velocity\n"; print_results(velocity_results); std::cout << "\nPosition\n"; print_results(position_results); return 0; } std::cout << "Testing Dynamics" << std::endl; std::vector<double> dynamics_results; for(size_t i=0; i<10; ++i) { std::cout << "\nTrial #" << i+1 << std::endl; runDynamicsTest(dynamics_results, worlds); } std::cout << "\n\n --- Final Dynamics Results --- \n\n"; print_results(dynamics_results); }
int main (int argc, char *argv[]) { int i, nthreads, tid, section; float a[N], b[N], c[N]; void print_results(float array[N], int tid, int section); /* Some initializations */ for (i=0; i<N; i++) a[i] = b[i] = i * 1.0; #pragma omp parallel private(c,i,tid,section) { tid = omp_get_thread_num(); if (tid == 0) { nthreads = omp_get_num_threads(); printf("Number of threads = %d\n", nthreads); } /*** Use barriers for clean output ***/ #pragma omp barrier printf("Thread %d starting...\n",tid); #pragma omp barrier #pragma omp sections nowait { #pragma omp section { section = 1; for (i=0; i<N; i++) c[i] = a[i] * b[i]; print_results(c, tid, section); } #pragma omp section { section = 2; for (i=0; i<N; i++) c[i] = a[i] + b[i]; print_results(c, tid, section); } } /* end of sections */ /*** Use barrier for clean output ***/ #pragma omp barrier printf("Thread %d exiting...\n",tid); } /* end of parallel section */ }
long int memcpy_with_stride(int fd, int stride, int filesize) { struct timeval start, end; int counter, ops, bytes; char *mapped; char *buffer = malloc(sizeof(char)*filesize); mapped = mmap(0, filesize, PROT_READ, MAP_SHARED, fd, 0); bytes = 0; ops = 0; gettimeofday(&start, NULL); for(counter = 0; counter + stride < filesize; counter += stride) { ops++; bytes += stride; memcpy(buffer+counter, mapped, stride); } if(counter < filesize) { ops++; bytes += filesize - counter; memcpy(buffer + counter, mapped, filesize - counter); } gettimeofday(&end, NULL); print_results(get_log_10(stride), ops, bytes, get_time_diff(start, end)); free(buffer); return get_time_diff(start, end); }
void media_identifier::identify_file(const char *name) { std::vector<file_info> info; digest_file(info, name); match_hashes(info); print_results(info); }
void media_identifier::identify(const char *filename) { std::vector<file_info> info; collect_files(info, filename); match_hashes(info); print_results(info); }
int main(int argc, char** argv) { /* error_num takes the value of any error_descriptors returned from the * file handling functions */ int error_num = INITIAL_ERROR_NUM_VALUE; FILE * fp; /* the competitor at the root, and the information for the competition*/ competitor * root; competition competition; /* pass fp by reference in order to modify its values * within the get_file_name_and_open function * call check_error to check if an error occurred, and if so react * appropriately */ error_num = get_file_name_and_open(&fp); if(check_error(error_num)) return EXIT_FAILURE; /* pass a pointer to the root pointer, the file pointer and a pointer * to the competition, to read all the data for each competitor and the * competition itself, from the file. Adding each competitor to the * binary tree as we go. * as before, call check_error to detect error occurrence */ error_num = read_file(&competition, &root, fp); if(check_error(error_num)) return EXIT_FAILURE; fclose(fp); /* calls the in_order_traverse function and passes the corresponding * pointer to printing function: print_results_inner for each node*/ print_results(competition, root); return (EXIT_SUCCESS); }
int main (int argc, char *argv[]) { /* Default values */ gchar *output_result_file ="shot.txt"; gchar *str_pipeline = NULL; /* Get input arguments */ if (get_input_arguments (argc, argv, &option, &output_result_file, &str_pipeline) == FALSE) { return -1; } {/* Play the pipeline */ g_assert( run_pipeline(argc,argv,str_pipeline) == 0); } {/* print the results */ print_results (option, output_result_file); } { /* Cleaning global variables */ g_hash_table_destroy (timestamps); } return 0; }
int main(int argc, char **argv){ to_visit = create_stack(); visited = create_empty_list(); char *path = NULL; if(argc > 2){ usage(); exit(-1); } //start search at specified directory if(argc == 2){ path = *(argv+1); } //start search at current working directory (default behavior) else{ path = "."; } push_key(to_visit, path); char *cur; while(!is_stack_empty(to_visit)){ cur = (char *)(pop(to_visit)->data); if(process(cur) == -1){ break; } } print_results(); return 0; }
static void run(struct options options, size_t *offset, size_t *size_max, double *single_red_cum, double *intra_red_cum, double *inter_red_cum, size_t index, char print) { if(options.latex) { struct context inter; memset(&inter, 0, sizeof(inter)); struct context intra; memset(&intra, 0, sizeof(intra)); struct context single; memset(&single, 0, sizeof(single)); file_bounds_set(options, offset, size_max, options.files[index]); //fprintf(stderr, "Size: %zu\n", *size_max); analyze(options.files[index], print, MODE_SINGLE, options.fsubst, options.chain, options.cleanup, *offset, *size_max, options.offset, &single); analyze(options.files[index], print, MODE_DEFAULT, options.fsubst, options.chain, options.cleanup, *offset, *size_max, options.offset, &intra); analyze(options.files[index], print, MODE_CHILDREN, options.fsubst, options.chain, options.cleanup, *offset, *size_max, options.offset, &inter); print_results_latex(options.files[index], &single, &intra, &inter); *single_red_cum += 1 - (single.stmts_opt / (double)single.stmts); *intra_red_cum += 1 - (intra.stmts_opt / (double)intra.stmts); *inter_red_cum += 1 - (inter.stmts_opt / (double)inter.stmts); } else { struct context context; memset(&context, 0, sizeof(context)); file_bounds_set(options, offset, size_max, options.files[index]); analyze(options.files[index], print, options.mode, options.fsubst, options.chain, options.cleanup, *offset, *size_max, options.offset, &context); print_results(&context); } }
int main(int argc, char **argv) { char infile[MAX_FILENAME]; struct tailq queue; struct tailq_node *node; if (argc == 1) { file_add(&queue, "index.html"); } else if (argc == 2) { strncpy(infile, argv[1], MAX_FILENAME-1); extract_files(&queue, infile); } else { printf("usage: ./cr [in file]\n"); exit(-1); } node = queue.head; for (int i = 0; node; i++) { if (!populate_ref(&queue, node)) tailq_remove(&queue, node); node = node->next; } print_results(&queue); getchar(); printf("Bye!\n"); return 0; }
int main_(int argc, char *argv[]) { int cache_params[CACHE_COUNT * 3]; parse_args(argc, argv, cache_params); struct cache caches[CACHE_COUNT]; int j = 0; for (int i = 0; i < CACHE_COUNT; ++i) { int level = i + 1; int c = cache_params[j++]; int b = cache_params[j++]; int s = cache_params[j++]; cache_init(&caches[i], &caches[i+1], level, c, b, s); } caches[CACHE_COUNT - 1].next = NULL; void *addr; char rw; while (!feof(stdin)) { fscanf(stdin, "%c %p\n", &rw, &addr); cache_access(caches, rw2access_type(rw), addr); } print_results(caches); for (int i = 0; i < CACHE_COUNT; ++i) { cache_destroy(&caches[i]); } return 0; }
int main(void) { //deklaracja zmiennych, tablice sa globalne char pesel[12], name[30]; int date[3], error, sex; error = 0; sex = 0; // wczytanie danych printf("Podaj swoje imie: \n"); scanf("%s", name); printf("Czesc %s, wpisz swoj PESEL. \n", name); scanf("%s", pesel); error = make_pesel(pesel); //kazda funkcja zwraca albo 0 albo 1 if(error == 0) { error = check(pesel); if(error == 0) { error = make_and_check_date(pesel, date); if(error == 0) { error = check_sex(pesel, name, &sex); if(error == 0) print_results(date, pesel, name, &sex); else printf("Twoja plec nie zgadza sie z imieniem!"); } else printf("Bledna data urodzenia"); } else printf("Blad liczby kontrolnej!"); } else printf("Bledny numer PESEL!"); return 0; //no }
long int fread_with_stride(FILE *fd, int stride, int filesize) { struct timeval start, end; int counter, ops, bytes; char *buffer = malloc(sizeof(char)*filesize); bytes = 0; ops = 0; gettimeofday(&start, NULL); for(counter = 0; counter + stride < filesize; counter += stride) { ops++; bytes += stride; fread(buffer + counter, 1, stride, fd); } if(counter < filesize) { ops++; bytes += filesize - counter; fread(buffer + counter, 1, filesize - counter, fd); } gettimeofday(&end, NULL); print_results(stride, ops, bytes, get_time_diff(start, end)); free(buffer); return get_time_diff(start, end); }
double algorithm_3(int *arr, int size, int print_option, FILE *file) { int max, beg, end; clock_t T1, T2; double time; T1 = clock();//start timer /*************************************************** ALGORITHM 3 CODE GOES HERE *****************************************************/ max = alg3(arr, size, 0); T2 = clock();//end timer time = (double)(T2 - T1) / CLOCKS_PER_SEC;//get total time beg = (int)(max_index - &arr[0]); end = beg + max_size - 1; print_results(arr, size, print_option, file, max, beg, end); return time; }
double algorithm_4(int *arr, int size, int print_option, FILE *file) { int max, beg, end; clock_t T1, T2; double time; T1 = clock();//start timer /*************************************************** ALGORITHM 4 CODE GOES HERE *****************************************************/ max = alg4(arr, &size); T2 = clock();//end timer time = (double)(T2 - T1) / CLOCKS_PER_SEC;//get total time beg = *low; end = *high; print_results(arr, size, print_option, file, max, beg, end); return time; }
void media_identifier::identify_data(const char *name, const uint8_t *data, std::size_t length) { std::vector<file_info> info; digest_data(info, name, data, length); match_hashes(info); print_results(info); }
void algorithm(int *arr, int size, int value, int version, FILE *file) { clock_t T1, T2; double time; int *outputArr; outputArr = createArr(size); initArr(outputArr, size); T1 = clock();//start timer //Call the appropriate algorithm on the array switch (version) { case 1 : outputArr = algorithm_1(arr, outputArr, size, value); break; case 2 : outputArr = algorithm_2(arr, outputArr, size, value); break; case 3 : outputArr = algorithm_3(arr, outputArr, size, value); break; } T2 = clock();//end timer time = (double)(T2 - T1) / CLOCKS_PER_SEC;//get total time value = sumArray(outputArr, size); print_results(outputArr, size, value, file); fprintf(file, "Time to execute: %fs\n", time); free(outputArr); }
double algorithm_2(int *arr, int size, int print_option, FILE *file) { int i, j, s, temp, max, beg, end; clock_t T1, T2; double time; max = -32767; beg = 0; end = size - 1; T1 = clock();//start timer //beginning point incrementer for (i = 0; i < size; i++) { s = 0; //end point incrementer for (j = i; j < size; j++) { temp = arr[j];//for debugging s += arr[j]; if (s > max) { max = s; end = j; beg = i; } } } T2 = clock();//end timer time = (double)(T2 - T1) / CLOCKS_PER_SEC;//get total time print_results(arr, size, print_option, file, max, beg, end); return time; }
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) { get_args(argc,argv); process_data(); print_results(); return 0; }
static void reduction_handler(void *msg) { int i=0; int idx = CpvAccess(nextidx); EmptyMsg emsg; sizes[idx].time = CmiWallTimer() - CpvAccess(starttime); CmiFree(msg); CpvAccess(numiter) = 0; idx++; if(sizes[idx].size == (-1)) { print_results("Consecutive CmiSyncBroadcastAllAndFree"); CpvAccess(nextidx) = 0; CpvAccess(numiter) = 0; while(sizes[i].size != (-1)) { sizes[i].time = 0; i++; } CmiSetHandler(&emsg, CpvAccess(sync_reply)); CpvAccess(lasttime) = CmiWallTimer(); CmiSyncSend(CpvAccess(currentPe), sizeof(EmptyMsg), &emsg); return; } else { CpvAccess(nextidx) = idx; msg = CmiAlloc(CmiMsgHeaderSizeBytes+sizes[idx].size); CmiSetHandler(msg, CpvAccess(bcast_handler)); CpvAccess(starttime) = CmiWallTimer(); CmiSyncBroadcastAllAndFree(CmiMsgHeaderSizeBytes+sizes[idx].size, msg); } }
//grab a DCHP address static int init_DHCP(){ int status; _survivebootp = 1;// Set to 1 (default) or 0 to never use fallbacks _bootptimeout = 6;// Short timeout for testing printf("Starting network (max wait %d seconds)...\n", _bootptimeout); status = sock_init(); switch (status) { case 1: printf("! Could not initialize packet driver.\n"); return 0; case 2: printf("! Could not configure using DHCP.\n"); break; // continue with fallbacks case 3: printf("! Could not configure using DHCP; fallbacks disallowed.\n"); return 0; default: break; } if (_dhcphost != ~0UL) printf(" Lease obtained\n"); else { printf("! Lease not obtained. DHCP server may be down.\n"); printf("! Using fallback parameters...\n"); return 0; } print_results(); set_nist_time(); //and now set the time... return 1; }
int main(int argc, char **argv) { printf("**** aldl-analyzer: CSV Log Analyzer %s ****\n",ANL_VERSION); printf(RFCOPYRIGHT); printf("\n\n"); /* load config */ anl_load_conf(ANL_CONFIGFILE); prep_anl(); /* load files ... */ if(argc < 2) error("No logs to analyze!\nTry dragging and dropping your log files onto analyzer.exe..."); int x; char *log; for(x=1;x<argc;x++) { printf("Loading file %s\n",argv[x]); log = rf_loadfile(argv[x]); if(log == NULL) { printf("Couldn't load file, skipping.\n"); } else { anl_reset_columns(log); parse_file(log); free(log); } } post_calc(); /* post-calculations (averaging mostly) */ print_results(); wait_for_input_then_exit(); return 1; }
int main(int argc, char const *argv[]) { if(DO_PRINT) printf("RANDOM ALLOCATION USAGE TEST\n\n"); if(DO_PRINT) printf("STARTING...\n"); struct parameters p; p.description = malloc(500); sprintf(p.description,""); p.deallocate_after_fail = true; p.dealloc_falldown = 0.8; p.max_allocs = 120; struct parameters p1, p2, p3; p1 = p2 = p3 = p; /*add_to_description("SMALL CHUNKS", &p1); run_all_benchmarks(32, p1);*/ add_to_description("MEDIUM CHUNKS", &p2); run_all_benchmarks(128, p2); add_to_description("BIG CHUNKS", &p3); run_all_benchmarks(512, p3); print_results(); return 0; }
int main (int argc, char *argv[]) { FILE *file_var; char file_name[MAX]; /* string array for file name */ int counts[26] /* counts[0]..counts[25] for individual letters. */ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /*initialize array with 0's */ int non_letters = 0; /* counter for non-letters */ int control_chars = 0; /* counter for control characters (e.g., eol) */ printf ("This program counts letter frequencies in a file\n"); /* determine file name from command line, if present, or ask user */ if (argc > 1) strcpy (file_name, argv[1]);/* copy command-line string to file_name */ else { printf ("Enter file name: "); scanf ("%s", file_name);} /* work with file and file data */ file_var = fopen (file_name, "r"); process_file (&file_var, counts, &non_letters, &control_chars); fclose (file_var); /* finish up file */ /* report frequencies */ print_results (file_name, counts, non_letters, control_chars); }
/* Function to load the main menu for the program. */ int menu(event_ptr event) { int option; do { printf("\nPress enter to continue.\n"); getchar(); /* Consumes \n. */ getchar(); /* Pauses program until enter is entered. */ printf("\n===================================== MAIN MENU ====================================="); printf("\n| |"); printf("\n| 1: Query competitor for current location/status. |"); printf("\n| 2: Display how many competitors have not started yet. |"); printf("\n| 3: Display how many competitors are out on the courses. |"); printf("\n| 4: Display how many competitors have completed their course successfully. |"); printf("\n| 5: Manually supply time at which a competitor had reached a time checkpoint. |"); printf("\n| 6: Read in a file of times at which competitors have reached time checkpoints. |"); printf("\n| 7: Display the result times for the successfully completed. |"); printf("\n| 8: Display the competitors who have been excluded. |"); printf("\n| 9: Exit program. |"); printf("\n| |"); printf("\n====================================================================================="); printf("\n\nPlease select from one of the options above (number): "); scanf("%d", &option); switch (option) { case 1: query_location(event); break; case 2: print_not_started(event); break; case 3: print_out_on_course(event); break; case 4: print_finished(event); break; case 5: update_competitor(event); break; case 6: read_times_file(event); break; case 7: print_results(event); break; case 8: print_excluded(event); break; case 9: break; default: printf("\nPlease enter in a valid option."); } } while (option != 9); return SUCCESS; }
int test_counting_remove_reopen(const char *bloom_file, const char *words_file) { FILE *fp; char word[256]; counting_bloom_t *bloom; int i, key_removed; struct stats results = { 0 }; printf("\n* test counting remove & reopen\n"); if ((fp = fopen(bloom_file, "r"))) { fclose(fp); remove(bloom_file); } if (!(bloom = new_counting_bloom(CAPACITY, ERROR_RATE, bloom_file))) { fprintf(stderr, "ERROR: Could not create bloom filter\n"); return TEST_FAIL; } if (!(fp = fopen(words_file, "r"))) { fprintf(stderr, "ERROR: Could not open words file\n"); return TEST_FAIL; } for (i = 0; fgets(word, sizeof(word), fp) && (i < CAPACITY); i++) { chomp_line(word); counting_bloom_add(bloom, word, strlen(word)); } fseek(fp, 0, SEEK_SET); for (i = 0; fgets(word, sizeof(word), fp) && (i < CAPACITY); i++) { if (i % 5 == 0) { chomp_line(word); counting_bloom_remove(bloom, word, strlen(word)); } } free_counting_bloom(bloom); bloom = new_counting_bloom_from_file(CAPACITY, ERROR_RATE, bloom_file); fseek(fp, 0, SEEK_SET); for (i = 0; (fgets(word, sizeof(word), fp)) && (i < CAPACITY); i++) { chomp_line(word); key_removed = (i % 5 == 0); bloom_score(counting_bloom_check(bloom, word, strlen(word)), !key_removed, &results, word); } fclose(fp); printf("Elements added: %6d" "\n" "Elements removed: %6d" "\n" "Total size: %d KiB" "\n\n", i, i / 5, (int) bloom->num_bytes / 1024); free_counting_bloom(bloom); return print_results(&results); }
void run() const { // Cold run kernel(); // Hot run results_type results = kernel(); print_results(results); }