static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string ) { FAIL_IF_ERROR( x264_cli_csp_is_invalid( info->csp ), "invalid csp %d\n", info->csp ); crop_hnd_t *h = calloc( 1, sizeof(crop_hnd_t) ); if( !h ) return -1; h->csp = x264_cli_get_csp( info->csp ); static const char * const optlist[] = { "left", "top", "right", "bottom", NULL }; char **opts = x264_split_options( opt_string, optlist ); if( !opts ) return -1; int err = handle_opts( h, info, opts, optlist ); free( opts ); if( err ) return -1; h->dims[2] = info->width - h->dims[0] - h->dims[2]; h->dims[3] = info->height - h->dims[1] - h->dims[3]; FAIL_IF_ERROR( h->dims[2] <= 0 || h->dims[3] <= 0, "invalid output resolution %dx%d\n", h->dims[2], h->dims[3] ); if( info->width != h->dims[2] || info->height != h->dims[3] ) x264_cli_log( NAME, X264_LOG_INFO, "cropping to %dx%d\n", h->dims[2], h->dims[3] ); else { /* do nothing as the user supplied 0s for all the values */ free( h ); return 0; } /* done initializing, overwrite values */ info->width = h->dims[2]; info->height = h->dims[3]; h->prev_filter = *filter; h->prev_hnd = *handle; *handle = h; *filter = crop_filter; return 0; }
int do_op(t_stack *a, t_stack *b, char *s) { t_opcode op; if ((op = get_op(s)) == NONE) return (FAILURE); op == SA ? swap(a) : (0); op == SB ? swap(b) : (0); op == SS ? swap_a_b(a, b) : (0); op == RA ? rotate(a) : (0); op == RB ? rotate(b) : (0); op == RR ? rotate_a_b(a, b, 0) : (0); op == RRA ? rotate_r(a) : (0); op == RRB ? rotate_r(b) : (0); op == RRR ? rotate_a_b(a, b, 1) : 0; if (op == PA && !empty(b)) push(a, pop(b)); if (op == PB && !empty(a)) push(b, pop(a)); handle_opts(a, b, s); return (SUCCESS); }
int main(int argc, char *argv[]) { /* process arguments */ handle_opts(argc, argv); /* open files */ vlog("[plppp] opening files\n"); FILE_INPUT = fopen(S_FILE_INPUT,"r"); if (FILE_INPUT == NULL) { err("[plppp] cannot open input file: %s\n", S_FILE_INPUT); } FILE_OUTPUT = fopen(S_FILE_OUTPUT,"w"); if (FILE_OUTPUT == NULL) { err("[plppp] cannot open output file: %s\n", S_FILE_OUTPUT); } yyset_in(FILE_INPUT); /* create our first define */ defines = install_define(defines,"WIRA","brengsek"); log("[plppp] starting preprocessor\n"); yyparse(); /* print the defines */ if (S_DEFINE_OUTPUT != NULL) { vlog("[plppp] printing defines\n"); FILE_DEFINE = fopen(S_DEFINE_OUTPUT, "w"); print_defines(FILE_DEFINE, defines); } fprintf(FILE_OUTPUT, "%s", program); vlog("[plppp] closing files\n"); fclose(FILE_INPUT); fclose(FILE_OUTPUT); log("[plppp] done\n"); return 0; }
static void parse_username_password(struct vsf_session* p_sess) { while (1) { vsf_cmdio_get_cmd_and_arg(p_sess, &p_sess->ftp_cmd_str, &p_sess->ftp_arg_str, 1); if (tunable_ftp_enable) { if (str_equal_text(&p_sess->ftp_cmd_str, "USER")) { handle_user_command(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "PASS")) { handle_pass_command(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT")) { vsf_cmdio_write_exit(p_sess, FTP_GOODBYE, "Goodbye."); } else if (str_equal_text(&p_sess->ftp_cmd_str, "FEAT")) { handle_feat(p_sess); } else if (str_equal_text(&p_sess->ftp_cmd_str, "OPTS")) { handle_opts(p_sess); } else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "AUTH") && !p_sess->control_use_ssl) { handle_auth(p_sess); } else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "PBSZ")) { handle_pbsz(p_sess); } else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "PROT")) { handle_prot(p_sess); } else if (str_isempty(&p_sess->ftp_cmd_str) && str_isempty(&p_sess->ftp_arg_str)) { /* Deliberately ignore to avoid NAT device bugs, as per ProFTPd. */ } else { vsf_cmdio_write(p_sess, FTP_LOGINERR, "Please login with USER and PASS."); } } else if (tunable_http_enable) { if (str_equal_text(&p_sess->ftp_cmd_str, "GET")) { handle_get(p_sess); } else { vsf_cmdio_write(p_sess, FTP_LOGINERR, "Bad HTTP verb."); } vsf_sysutil_exit(0); } } }
int main (int argc, char* argv[]) { Command_line_opts opts; Search_settings sett; Search_range s_range; Aux_arrays aux_arr; double *F; // F-statistic array int i; #define QUOTE(x) #x #define STR(macro) QUOTE(macro) #define CVSTR STR(CODEVER) printf("Code version : " CVSTR "\n"); // Command line options handle_opts(&sett, &opts, argc, argv); // Output data handling struct stat buffer; if (stat(opts.prefix, &buffer) == -1) { if (errno == ENOENT) { // Output directory apparently does not exist, try to create one if(mkdir(opts.prefix, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { perror (opts.prefix); return 1; } } else { // can't access output directory perror (opts.prefix); return 1; } } // Grid data read_grid(&sett, &opts); // Search settings search_settings(&sett); // Detector network settings detectors_settings(&sett, &opts); // Array initialization and reading the ephemerids init_arrays(&sett, &opts, &aux_arr, &F); // Narrowing-down the band (excluding the edges // according to the opts.narrowdown parameter) if(opts.narrowdown < 0.5*M_PI) narrow_down_band(&sett, &opts); // Reading known lines data from external files if(opts.veto_flag) { for(i=0; i<sett.nifo; i++) { printf("Reading known lines data for %s from %s\n", ifo[i].name, opts.dtaprefix); read_lines(&sett, &opts, &ifo[i]); } // Vetoing known lines in band lines_in_band(&sett, &opts); } // If excluded parts of band, list them // and check if the band isn't fully vetoed if(sett.numlines_band) { int k; printf("list of excluded frequencies in band (in radians):\n"); for(k=0; k<sett.numlines_band; k++) printf("%f %f\n", sett.lines[k][0], sett.lines[k][1]); check_if_band_is_fully_vetoed(&sett); } // Amplitude modulation functions for each detector for(i=0; i<sett.nifo; i++) rogcvir(&ifo[i]); // Grid search range if(strlen(opts.addsig)) { // If addsig switch used, add signal from file, // search around this position (+- gsize) add_signal(&sett, &opts, &aux_arr, &s_range); } else // Set search range from range file set_search_range(&sett, &opts, &s_range); // FFT plans FFTW_plans fftw_plans; FFTW_arrays fftw_arr; plan_fftw(&sett, &opts, &fftw_plans, &fftw_arr, &aux_arr); if (strlen(opts.getrange)) exit(EXIT_SUCCESS); // Checkpointing int Fnum=0; // candidate signal number read_checkpoints(&opts, &s_range, &Fnum); // main search job search(&sett, &opts, &s_range, &fftw_plans, &fftw_arr, &aux_arr, &Fnum, F); // state file zeroed at the end of the run FILE *state; if(opts.checkp_flag) { state = fopen (opts.qname, "w"); fclose (state); } // Cleanup & memory free cleanup(&sett, &opts, &s_range, &fftw_plans, &fftw_arr, &aux_arr, F); return 0; }
int main(int argc, char *argv[]) { /* process arguments */ handle_opts(argc, argv); /* open files */ vlog("[plpcc] opening files\n"); FILE_INPUT = fopen(S_FILE_INPUT,"r"); if (FILE_INPUT == NULL) { err("[plpcc] cannot open input file: %s\n", S_FILE_INPUT); } FILE_OUTPUT = fopen(S_FILE_OUTPUT,"w"); if (FILE_OUTPUT == NULL) { err("[plpcc] cannot open output file: %s\n", S_FILE_OUTPUT); } yyset_in(FILE_INPUT); if (S_SYMBOL_OUTPUT != NULL) { SYMBOL_OUTPUT = fopen(S_SYMBOL_OUTPUT, "w"); if (SYMBOL_OUTPUT == NULL) { err("[plpcc] cannot open symbol table output file: %s\n", S_SYMBOL_OUTPUT); } } if (S_PARSE_OUTPUT != NULL) { PARSE_OUTPUT = fopen(S_PARSE_OUTPUT, "w"); if (PARSE_OUTPUT == NULL) { err("[plpcc] cannot open parse tree output file: %s\n", S_PARSE_OUTPUT); } } if (S_GRAPH_OUTPUT != NULL) { GRAPH_OUTPUT = fopen(S_GRAPH_OUTPUT, "w"); if (GRAPH_OUTPUT == NULL) { err("[plpcc] cannot open parse tree graph output file: %s\n", S_GRAPH_OUTPUT); } } /* grab the lines from the source for error handling and annotation */ build_lines(S_FILE_INPUT); /* create an empty symbol table */ sym = new_symbol_table(NULL); log("[plpcc] starting frontend\n"); yyparse(); /* print the parse tree */ if (PARSE_OUTPUT != NULL) { vlog("[plpcc] printing parse tree\n"); print_tree(parse_tree_head, PARSE_OUTPUT, 0); } /* print the parse tree graph formatted for Graphviz*/ if (GRAPH_OUTPUT != NULL) { vlog("[plpcc] printing parse tree graph\n"); print_tree_graph(parse_tree_head, GRAPH_OUTPUT, S_FILE_INPUT); /* close output file*/ fclose(GRAPH_OUTPUT); /* Run Graphviz command to generate PNG of parse tree */ S_GRAPH_COMMAND = malloc(sizeof(char) * (strlen(S_FILE_OUTPUT) * 2 + 22)); sprintf(S_GRAPH_COMMAND, "dot -Tpng %s.dot > %s.png", S_FILE_OUTPUT, S_FILE_OUTPUT); system(S_GRAPH_COMMAND); } /* print the symbol table */ if (SYMBOL_OUTPUT != NULL) { vlog("[plpcc] printing symbol table\n"); print_symbols(sym, SYMBOL_OUTPUT, 0); vlog("[plpcc] printing activation records\n"); print_frames(sym, SYMBOL_OUTPUT); } /* call the backend to compile the parse tree, starting from the head */ if (NO_COMPILE == 0) { handle(parse_tree_head); fprintf(FILE_OUTPUT, "%s", program); } vlog("[plpcc] closing files\n"); fclose(FILE_INPUT); fclose(FILE_OUTPUT); log("[plpcc] done\n"); return 0; }
int main(int argc, char **argv) { struct sigaction action; char *pps_filename; char *lat_filename; uint64_t expected_packets; socklen_t len = 4; int enabled = 1; int val = 0; unsigned char *buffers = (unsigned char *)malloc(BUFFER_SIZE * NUM_BUFFERS); pps = (unsigned int *)malloc(sizeof(unsigned int) * MAX_SECONDS); memset(pps, 0, sizeof(unsigned int) * MAX_SECONDS); if (!handle_opts(argc, argv, &expected_packets, &pps_filename, &lat_filename)) { printf("%s", USAGE); return 0; } if (pps_filename) { pps_output = fopen(pps_filename, "a+"); if (!pps_output) ERROR("Failed to open/create file: %s, %s", pps_filename, strerror(errno)); } else { pps_output = stdout; } if (lat_filename) { lat_output = fopen(lat_filename, "a+"); if (!lat_output) ERROR("Failed to open/create file: %s, %s", lat_filename, strerror(errno)); } else { lat_output = stdout; } if (hdr_init(LOWEST_LAT_US, HIGHEST_LAT_US, 4, &hist) != 0) { ERROR("Failed to init histogram"); return -1; } sock_raw = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock_raw < 0) ERROR("Socket error: %s", strerror(errno)); if (setsockopt(sock_raw, SOL_SOCKET, SO_TIMESTAMPNS, &enabled, sizeof(enabled)) < 0 || getsockopt(sock_raw, SOL_SOCKET, SO_TIMESTAMPNS, &val, &len) < 0 || val == 0) { ERROR("Failed to configure rx timestamps: %s", strerror(errno)); } memset(&action, 0, sizeof(struct sigaction)); action.sa_handler = on_signal; sigaction(SIGINT, &action, NULL); if (expected_packets == 0) expected_packets = ~UINT64_C(0); while (received_packets < expected_packets) { int npkts = rcv_packet(sock_raw, buffers, hist); if (npkts == 0) continue; if (start == -1) start = time(NULL); uint64_t second = time(NULL) - start; pps[second] += npkts; received_packets += npkts; } report(); return 0; }
int main(int argc, char** argv) { struct timespec timestamp; struct timespec start_timestamp; struct timespec end_timestamp; struct hdr_interval_recorder recorder; struct hdr_log_writer log_writer; struct config_t config; pthread_t recording_thread; FILE* output = stdout; memset(&config, 0, sizeof(struct config_t)); if (!handle_opts(argc, argv, &config)) { printf("%s", USAGE); return 0; } if (config.filename) { output = fopen(config.filename, "a+"); if (!output) { fprintf( stderr, "Failed to open/create file: %s, %s", config.filename, strerror(errno)); return -1; } } if (0 != hdr_interval_recorder_init(&recorder)) { fprintf(stderr, "%s\n", "Failed to init phaser"); return -1; } if (0 != hdr_init( 1, INT64_C(24) * 60 * 60 * 1000000, 3, (struct hdr_histogram**) &recorder.active)) { fprintf(stderr, "%s\n", "Failed to init hdr_histogram"); return -1; } if (0 != hdr_init( 1, INT64_C(24) * 60 * 60 * 1000000, 3, (struct hdr_histogram**) &recorder.inactive)) { fprintf(stderr, "%s\n", "Failed to init hdr_histogram"); return -1; } if (pthread_create(&recording_thread, NULL, record_hiccups, &recorder)) { fprintf(stderr, "%s\n", "Failed to create thread"); return -1; } hdr_gettime(&start_timestamp); hdr_log_writer_init(&log_writer); hdr_log_write_header(&log_writer, output, "foobar", ×tamp); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" while (true) { sleep(config.interval); hdr_reset(recorder.inactive); struct hdr_histogram* h = hdr_interval_recorder_sample(&recorder); hdr_gettime(&end_timestamp); timestamp = start_timestamp; hdr_gettime(&start_timestamp); hdr_log_write(&log_writer, output, ×tamp, &end_timestamp, h); fflush(output); } #pragma clang diagnostic pop pthread_exit(NULL); }
// Main programm int main (int argc, char *argv[]) { Search_settings sett; Command_line_opts opts; Search_range s_range; Aux_arrays aux_arr; double *F; // F-statistic array int i, j, r, c, a, b, g; int d, o, m, k; int bins = 2, ROW, dim = 4; // neighbourhood of point will be divide into defined number of bins double pc[4]; // % define neighbourhood around each parameter for initial grid double pc2[4]; // % define neighbourhood around each parameter for direct maximum search (MADS & Simplex) double tol = 1e-10; // double delta = 1e-5; // initial step in MADS function // double *results; // Vector with results from Fstatnet function // double *maximum; // True maximum of Fstat // double results_max[11]; double s1, s2, s3, s4; double sgnlo[4]; double **arr; // arr[ROW][COL], arrg[ROW][COL]; double nSource[3]; double sinalt, cosalt, sindelt, cosdelt; double F_min; char path[512]; double x, y; ROW = pow((bins+1),4); #ifdef YEPPP yepLibrary_Init(); Yep64f *results_max = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *results_first = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *results = (Yep64f*)malloc(sizeof(Yep64f)*11); Yep64f *maximum = (Yep64f*)malloc(sizeof(Yep64f)*11); // Yep64f *sgnlo = (Yep64f*)malloc(sizeof(Yep64f)*4); // Yep64f *nSource = (Yep64f*)malloc(sizeof(Yep64f)*3); Yep64f *mean = (Yep64f*)malloc(sizeof(Yep64f)*4); enum YepStatus status; #endif pc[0] = 0.015; pc[1] = 0.015; pc[2] = 0.015; pc[3] = 0.015; for (i = 0; i < 4; i++){ pc2[i] = 2*pc[i]/bins; } // Time tests double tdiff; clock_t tstart, tend; // Command line options handle_opts(&sett, &opts, argc, argv); // Output data handling /* struct stat buffer; if (stat(opts.prefix, &buffer) == -1) { if (errno == ENOENT) { // Output directory apparently does not exist, try to create one if(mkdir(opts.prefix, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { perror (opts.prefix); return 1; } } else { // can't access output directory perror (opts.prefix); return 1; } } */ sprintf(path, "%s/candidates.coi", opts.dtaprefix); //Glue function if(strlen(opts.glue)) { glue(&opts); sprintf(opts.dtaprefix, "./data_total"); sprintf(opts.dtaprefix, "%s/followup_total_data", opts.prefix); opts.ident = 000; } FILE *coi; int z; if ((coi = fopen(path, "r")) != NULL) { // while(!feof(coi)) { /* if(!fread(&w, sizeof(unsigned short int), 1, coi)) { break; } fread(&mean, sizeof(float), 5, coi); fread(&fra, sizeof(unsigned short int), w, coi); fread(&ops, sizeof(int), w, coi); if((fread(&mean, sizeof(float), 4, coi)) == 4){ */ while(fscanf(coi, "%le %le %le %le", &mean[0], &mean[1], &mean[2], &mean[3]) == 4){ //Time test // tstart = clock(); arr = matrix(ROW, 4); //Function neighbourhood - generating grid around point arr = neigh(mean, pc, bins); // Output data handling /* struct stat buffer; if (stat(opts.prefix, &buffer) == -1) { if (errno == ENOENT) { // Output directory apparently does not exist, try to create one if(mkdir(opts.prefix, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { perror (opts.prefix); return 1; } } else { // can't access output directory perror (opts.prefix); return 1; } } */ // Grid data if(strlen(opts.addsig)) { read_grid(&sett, &opts); } // Search settings search_settings(&sett); // Detector network settings detectors_settings(&sett, &opts); // Array initialization init_arrays(&sett, &opts, &aux_arr, &F); // Amplitude modulation functions for each detector for(i=0; i<sett.nifo; i++) rogcvir(&ifo[i]); // Adding signal from file if(strlen(opts.addsig)) { add_signal(&sett, &opts, &aux_arr, &s_range); } // Setting number of using threads (not required) omp_set_num_threads(1); results_max[5] = 0.; // ifo zostaje shared // ifo....shft i ifo....xdatm{a,b] prerobić na lokalne tablice w fstatnet // w regionie parallel wprowadzić tablice private aa i bb ; alokować i przekazywać je jako argumenty do fstatnet i amoeba // Main loop - over all parameters + parallelisation #pragma omp parallel default(shared) private(d, i, sgnlo, sinalt, cosalt, sindelt, cosdelt, nSource, results, maximum) { double **sigaa, **sigbb; // aa[nifo][N] sigaa = matrix(sett.nifo, sett.N); sigbb = matrix(sett.nifo, sett.N); #pragma omp for for (d = 0; d < ROW; ++d){ for (i = 0; i < 4; i++){ sgnlo[i] = arr[d][i]; // sgnlo[i] = mean[i]; } sinalt = sin(sgnlo[3]); cosalt = cos(sgnlo[3]); sindelt = sin(sgnlo[2]); cosdelt = cos(sgnlo[2]); nSource[0] = cosalt*cosdelt; nSource[1] = sinalt*cosdelt; nSource[2] = sindelt; for (i = 0; i < sett.nifo; ++i){ modvir(sinalt, cosalt, sindelt, cosdelt, sett.N, &ifo[i], &aux_arr, sigaa[i], sigbb[i]); } // F-statistic in given point results = Fstatnet(&sett, sgnlo, nSource, sigaa, sigbb); //printf("Fstatnet: %le %le %le %le %le %le\n", results[6], results[7], results[8], results[9], results[5], results[4]); #pragma omp critical if(results[5] < results_max[5]){ for (i = 0; i < 11; i++){ results_max[i] = results[i]; } } // Maximum search using simplex algorithm if(opts.simplex_flag){ // puts("Simplex"); maximum = amoeba(&sett, &aux_arr, sgnlo, nSource, results, dim, tol, pc2, sigaa, sigbb); printf("Amoeba: %le %le %le %le %le %le\n", maximum[6], maximum[7], maximum[8], maximum[9], maximum[5], maximum[4]); // Maximum value in points searching #pragma omp critical if(maximum[5] < results_max[5]){ for (i = 0; i < 11; i++){ results_max[i] = maximum[i]; } } } //simplex } // d - main outside loop free_matrix(sigaa, sett.nifo, sett.N); free_matrix(sigbb, sett.nifo, sett.N); } //pragma for(g = 0; g < 11; g++) results_first[g] = results_max[g]; // Maximum search using MADS algorithm if(opts.mads_flag) { // puts("MADS"); maximum = MADS(&sett, &aux_arr, results_max, mean, tol, pc2, bins); } //Time test // tend = clock(); // tdiff = (tend - tstart)/(double)CLOCKS_PER_SEC; printf("%le %le %le %le %le %le\n", results_max[6], results_max[7], results_max[8], results_max[9], results_max[5], results_max[4]); } // while fread coi // } } //if coi else { perror (path); return 1; } // Output information /* puts("**********************************************************************"); printf("*** Maximum value of F-statistic for grid is : (-)%.8le ***\n", -results_first[5]); printf("Sgnlo: %.8le %.8le %.8le %.8le\n", results_first[6], results_first[7], results_first[8], results_first[9]); printf("Amplitudes: %.8le %.8le %.8le %.8le\n", results_first[0], results_first[1], results_first[2], results_first[3]); printf("Signal-to-noise ratio: %.8le\n", results_first[4]); printf("Signal-to-noise ratio from estimated amplitudes (for h0 = 1): %.8le\n", results_first[10]); puts("**********************************************************************"); if((opts.mads_flag)||(opts.simplex_flag)){ printf("*** True maximum is : (-)%.8le ***\n", -maximum[5]); printf("Sgnlo for true maximum: %.8le %.8le %.8le %.8le\n", maximum[6], maximum[7], maximum[8], maximum[9]); printf("Amplitudes for true maximum: %.8le %.8le %.8le %.8le\n", maximum[0], maximum[1], maximum[2], maximum[3]); printf("Signal-to-noise ratio for true maximum: %.8le\n", maximum[4]); printf("Signal-to-noise ratio from estimated amplitudes (for h0 = 1) for true maximum: %.8le\n", maximum[10]); puts("**********************************************************************"); }*/ // Cleanup & memory free free(results_max); free(results_first); free(results); free(maximum); free(mean); free_matrix(arr, ROW, 4); cleanup_followup(&sett, &opts, &s_range, &aux_arr, F); return 0; }