int main(int argc, char *argv[]) { int i, count, readfile; void config(int rt, int rmax, int ic); double ewens_form(int *r, int r_tot, double *mpt); double F(int *r), multiplicity; double theta_est(int k_obs, int n); void print_config(int *r); long start_time, finish_time, net_time; void fill_factors(); start_time = time(NULL); if (argc == 1) { printf("Specify the configuration on the command line\n"); exit(0); } k = argc - 1; for (i=1; i<=k; i++) { r_obs[i] = atoi(argv[i]); r_tot += r_obs[i]; } F_obs = F(r_obs); printf("\nn = %d, k = %d, theta = %g, F = %g\n", r_tot, k, theta_est(k, r_tot), F_obs); if (r_tot >= RLIM) { printf("n = %d is too large..\n", r_tot); exit(0); } if (k >= KLIMIT) { printf("k = %d is too large.\n", k); exit(0); } for (i=1; i<k; i++) if (r_obs[i] < r_obs[i+1]) { print_config(r_obs); printf(" is not a valid configuration.\n"); exit(0); } r_top = r_tot - 1; Fsig = Esig = 0; fill_factors(); obs_value = ewens_form(r_obs, r_obs[1], &multiplicity); config(r_tot, r_tot-k+1, 1); print_config(r_obs); printf(": P_E = %g, ", sig_sum / tot_sum); printf("P_H = %g\n", F_sig_sum / tot_sum); finish_time = time(NULL); net_time = time(NULL) - start_time; if (net_time < 60) printf("Program took %ld seconds\n", net_time); else printf("Program took %4.2f minutes\n", net_time / 60.0); } /* end, main */
static void print_info(struct cfg *cfg) { const char *c; int i; c = strrchr(cfg->controlfile, '/'); if (c != NULL) c = c + 1; else c = cfg->controlfile; if (cfg->verbose) { printf("%s: %s with %d ports and %d VLAN groups\n", c, cfg->info.es_name, cfg->info.es_nports, cfg->info.es_nvlangroups); printf("%s: ", c); printb("VLAN capabilities", cfg->info.es_vlan_caps, ETHERSWITCH_VLAN_CAPS_BITS); printf("\n"); } print_config(cfg); for (i=0; i<cfg->info.es_nports; i++) { print_port(cfg, i); } for (i=0; i<cfg->info.es_nvlangroups; i++) { print_vlangroup(cfg, i); } }
/** * eo_prep * ``````` * Validate and prepare the command line arguments for execution. * * @argc : number of arguments * @argv : vector of arguments * Return: nothing. */ void eo_prep(int argc, char *argv[]) { struct routine_t *r; static int tree[30]; int i; if (isarg(1, "stat")) print_config(); else if (isarg(1, "init")) eo_init(); else if (isarg(1, "kleene")) { if ((kleene(argv[2], argv[3]))) printf("match\n"); else printf("no match\n"); } else { /* If there is only one argument, assume the CWD. */ /*r = (argc==2) ? parse(scwd(), argv[1]) */ /*: parse(argv[1], argv[2]);*/ if (argc == 2) build_tree(tree, argv[1]); else build_tree(tree, argv[2]); for (i=0; tree[i] != END; i++) { printf("%s (%d)\n", op_name[tree[i]], tree[i]); } return; eo_process(r); } return; }
int main(int argc, char *argv[]) { int rc; getopts(argc, argv); if(getlognumber()) { fprintf(stderr, "Cannot determine actual log number\n"); exit(4); } if(run_as_daemon) { if((rc = daemonize(outputfile)) != 0) { fprintf(stderr, "Error starting daemon process : %s\n", strerror(rc)); exit(5); } } else { if(redirect(outputfile)) { exit(6); } } if(workdir) { if(chdir(workdir)) { perror("Error changing directory: "); exit(7); } } if(verbose) { print_config(); } if(cmd != NULL) { sighandling(); if(start_cmd() != 0) exit(9); } return process(); }
int main(void){ //Set constants // double d = 4.065; //(Au-Au spacing in Angstroms) int i,j = 0; //pick shape const char *input = "cube"; //allocate memory (for lattice) //The lattice is 3d, each side indexes from 0 to nl-1 nn_vec ***lat; lat = (nn_vec ***)calloc((size_t)nl, sizeof(nn_vec**)); for(i = 0; i < nl; i++){ lat[i] = (nn_vec **) calloc((size_t)nl, sizeof(nn_vec*)); for(j = 0; j < nl; j++){ lat[i][j] = (nn_vec*) calloc((size_t)nl, sizeof(nn_vec)); } } //Create shape on the lattice shape(input, lat); //Print out lattice as xyz file print_config(lat); }
int main(void) { //Set constants // double d = 4.065; //(Au-Au spacing in Angstroms) int i,j = 0; //pick shape const char *input = "cube"; //allocate memory (for lattice) //The lattice is 3d, each side indexes from -1 to 2*nl-1 //Except for the spherocylinder configuration, where one side is 4 times the length of the other nn_vec ***lat; lat = (nn_vec ***)calloc((size_t)2*nl, sizeof(nn_vec**)); for(i = 0; i < 2*nl; i++) { lat[i] = (nn_vec **) calloc((size_t)2*nl, sizeof(nn_vec*)); for(j = 0; j < 2*nl; j++) { lat[i][j] = (nn_vec*) calloc((size_t)2*nl, sizeof(nn_vec)); } } //Create shape on the lattice shape(input, lat); //Print out lattice as xyz file print_config(lat); }
int main(int argc, char **argv) { // Paso 1.- Parsear Argumentos parseArgs(argc, argv); // Paso 2.- Validar Argumentos if(MAX_PACKS < 1 || strlen(IP_DEST)==0) { printf("Error en el ingreso de parametros\n"); print_usage(); exit(1); } if(mostrarInfo) print_config(); // Paso 3.- Llenar Buffer con datos para mandar int i; for(i = 0; i < BUF_SIZE; i++) buf[i] = 'p'+i; // Paso 4.- Crear Socket int socket_fd; char ports[10]; sprintf(ports, "%d", DESTINATION_PORT); socket_fd = udp_connect(IP_DEST, ports); if(socket_fd < 0) { fprintf(stderr, "connection refused\n"); exit(1); } //Medir Inicio gettimeofday(&dateInicio, NULL); // Paso 4.1.- Escribir en el socket for(i = 0; i < MAX_PACKS; i++){ if(intensiveMode){ write(socket_fd, buf, BUF_SIZE); }else{ if(write(socket_fd, buf, BUF_SIZE) != BUF_SIZE) { gettimeofday(&dateFin, NULL); segundos = (dateFin.tv_sec+dateFin.tv_usec/1000000.)-(dateInicio.tv_sec*1.0+dateInicio.tv_usec/1000000.); //fprintf(stderr, "Falla el write al servidor, envio %d paquetes\n", i); //fprintf(stderr, "total time = %g\n", segundos); break; } } } //Medir Fin gettimeofday(&dateFin, NULL); segundos=(dateFin.tv_sec*1.0+dateFin.tv_usec/1000000.)-(dateInicio.tv_sec*1.0+dateInicio.tv_usec/1000000.); if(mostrarInfo){ printf("Tiempo Total = %g\n", segundos); printf("QPS = %g\n", MAX_PACKS*1.0/segundos); }else{ printf("%g \n", segundos); } exit(0); return 0; }
TEST_PYLIBUSB_API print_device(struct usb_device* dev) { int i; printf("usb_device at %p\n",dev); print_device_descriptor( &(dev->descriptor) ); for (i=0;i<(dev->descriptor.bNumConfigurations);i++) { print_config(&(dev->config[i])); } }
void show_config() { int i; for(i = 0; config_table[i].name; i++) { print_config(&config_table[i]); } }
int main(int argc, const char ** argv) { print_copyright(); //* GraphChi initialization will read the command line arguments and the configuration file. */ graphchi_init(argc, argv); /* Metrics object for keeping track of performance counters and other information. Currently required. */ metrics m("rbm-inmemory-factors"); /* Basic arguments for RBM algorithm */ rbm_bins = get_option_int("rbm_bins", rbm_bins); rbm_alpha = get_option_float("rbm_alpha", rbm_alpha); rbm_beta = get_option_float("rbm_beta", rbm_beta); rbm_mult_step_dec = get_option_float("rbm_mult_step_dec", rbm_mult_step_dec); rbm_scaling = get_option_float("rbm_scaling", rbm_scaling); parse_command_line_args(); parse_implicit_command_line(); mytimer.start(); /* Preprocess data if needed, or discover preprocess files */ int nshards = convert_matrixmarket<float>(training); rbm_init(); if (validation != "") { int vshards = convert_matrixmarket<EdgeDataType>(validation, 0, 0, 3, VALIDATION); init_validation_rmse_engine<VertexDataType, EdgeDataType>(pvalidation_engine, vshards, &rbm_predict); } /* load initial state from disk (optional) */ if (load_factors_from_file) { load_matrix_market_matrix(training + "_U.mm", 0, 3*D); load_matrix_market_matrix(training + "_V.mm", M, rbm_bins*(D+1)); } print_config(); /* Run */ RBMVerticesInMemProgram program; graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); set_engine_flags(engine); pengine = &engine; engine.run(program, niters); /* Output latent factor matrices in matrix-market format */ output_rbm_result(training); test_predictions(&rbm_predict); /* Report execution metrics */ if (!quiet) metrics_report(m); return 0; }
int main(int argc, const char ** argv) { print_copyright(); //* GraphChi initialization will read the command line arguments and the configuration file. */ graphchi_init(argc, argv); /* Metrics object for keeping track of performance counters and other information. Currently required. */ /* Basic arguments for application. NOTE: File will be automatically 'sharded'. */ beta = get_option_float("beta", 1); debug = get_option_int("debug", 0); parse_command_line_args(); parse_implicit_command_line(); D = 0; //no feature vector is needed binary_relevance_threshold = 0; //treat all edge values as binary /* Preprocess data if needed, or discover preprocess files */ int nshards = convert_matrixmarket<EdgeDataType>(training, 0, 0, 3, TRAINING, false); init_feature_vectors<std::vector<vertex_data> >(M+N, latent_factors_inmem, !load_factors_from_file); //read initial vector from file std::cout << "Load CTR vector from file" << training << ":vec" << std::endl; load_matrix_market_vector(training + ":vec", Y_POS, false, false); mu_ij = zeros(M+N); sigma_ij = ones(M+N); if (validation != ""){ //read validation data (optional) vshards = convert_matrixmarket<EdgeDataType>(validation, 0, 0, 3, VALIDATION, false); validation_targets = load_matrix_market_vector(validation + ":vec", false, false); Me = validation_targets.size(); } print_config(); /* Run */ AdPredictorVerticesInMemProgram program; metrics m("adpredictor"); graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); set_engine_flags(engine); pengine = &engine; engine.run(program, niters); /* Output latent factor matrices in matrix-market format */ output_adpredictor_result(training); /* Report execution metrics */ if (!quiet) metrics_report(m); return 0; }
int main(int argc, char **argv) { if (argc > 1) if (emp_config(argv[1]) < 0) exit(1); print_config(stdout); exit(0); }
int main(int argc, const char ** argv) { //* GraphChi initialization will read the command line arguments and the configuration file. */ graphchi_init(argc, argv); /* Metrics object for keeping track of performance counters and other information. Currently required. */ metrics m("climf-inmemory-factors"); /* Basic arguments for application. NOTE: File will be automatically 'sharded'. */ sgd_lambda = get_option_float("sgd_lambda", 1e-3); sgd_gamma = get_option_float("sgd_gamma", 1e-4); sgd_step_dec = get_option_float("sgd_step_dec", 1.0); binary_relevance_thresh = get_option_float("binary_relevance_thresh", 0); halt_on_mrr_decrease = get_option_int("halt_on_mrr_decrease", 0); num_ratings = get_option_int("num_ratings", 10000); //number of top predictions over which we compute actual MRR verbose = get_option_int("verbose", 0); debug = get_option_int("debug", 0); parse_command_line_args(); parse_implicit_command_line(); /* Preprocess data if needed, or discover preprocess files */ bool allow_square = false; int nshards = convert_matrixmarket<EdgeDataType>(training, 0, 0, 3, TRAINING, allow_square); init_feature_vectors<std::vector<vertex_data> >(M+N, latent_factors_inmem, !load_factors_from_file, 0.01); if (validation != ""){ int vshards = convert_matrixmarket<EdgeDataType>(validation, 0, 0, 3, VALIDATION); init_mrr_engine<VertexDataType, EdgeDataType>(pvalidation_engine, vshards); } if (load_factors_from_file) { load_matrix_market_matrix(training + "_U.mm", 0, D); load_matrix_market_matrix(training + "_V.mm", M, D); } print_config(); /* Run */ SGDVerticesInMemProgram program; graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); set_engine_flags(engine); pengine = &engine; engine.run(program, niters); /* Output latent factor matrices in matrix-market format */ output_sgd_result(training); test_predictions(&climf_predict); /* Report execution metrics */ if (!quiet) metrics_report(m); return 0; }
/* * Record the use of a CONFIG_* word. */ static void use_config(const char *m, int slen) { unsigned int hash = strhash(m, slen); if (is_defined_config(m, slen, hash)) return; define_config(m, slen, hash); print_config(m, slen); }
void bluez_detect(void) { inquiry_info *ii = NULL; int max_rsp, num_rsp; int dev_id, sock, len, flags; int i; char addr[19] = { 0 }; char name[248] = { 0 }; dev_id = hci_get_route(NULL); sock = hci_open_dev(dev_id); if (dev_id < 0 || sock < 0) { perror("opening socket"); exit(1); } len = 8; max_rsp = 255; flags = IREQ_CACHE_FLUSH; ii = (inquiry_info *) malloc(max_rsp * sizeof(inquiry_info)); num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags); if (num_rsp < 0) perror("hci_inquiry"); for (i = 0; i < num_rsp; i++) { ba2str(&(ii + i)->bdaddr, addr); memset(name, 0, sizeof(name)); if (hci_read_remote_name(sock, &(ii + i)->bdaddr, sizeof(name), name, 0) < 0) strcpy(name, "[unknown]"); if (debug) printf("; %s %s\n", addr, name); if (find_list(addr, at_prefixes)) { print_config(addr, name, "blueat"); } if (find_list(addr, nokia_prefixes)) { print_config(addr, name, "bluephonet"); } } free(ii); close(sock); }
void test_trailing_whitespace(void **state) { struct pam_hbac_config *conf; (void) state; /* unused */ conf = read_test_config(TEST_CONF_DIR"/src/tests/configs/twsp.conf"); print_config(conf); check_example_result(conf); ph_cleanup_config(conf); }
void test_whitespace_around_equal_sign(void **state) { struct pam_hbac_config *conf; (void) state; /* unused */ conf = read_test_config(TEST_CONF_DIR"/src/tests/configs/eqwsp.conf"); print_config(conf); check_example_result(conf); ph_cleanup_config(conf); }
/* ------------- the tests themselves ------------- */ void test_good_config(void **state) { struct pam_hbac_config *conf; (void) state; /* unused */ conf = read_test_config(TEST_CONF_DIR"/src/tests/configs/good1.conf"); print_config(conf); check_example_result(conf); ph_cleanup_config(conf); }
/*----------------------------------------------------------------------------*/ void app_config_update() { // save new values (unverified!) _app_config_save_internal(); // debug output print_config(); // reconfigure sensors configure_sensors(); }
void Config::update_best() { for (N_INDEX i = 0; i < N; i++) { for (N_INDEX j = 0; j < N; j++) best_heights[i][j] = heights[i][j]; } best_card = card; #if ROOKS_PRINT printf("----- BEST ! ----- %zu\n", card); print_config(); #endif }
int main(int argc, const char ** argv) { print_copyright(); //* GraphChi initialization will read the command line arguments and the configuration file. */ graphchi_init(argc, argv); /* Metrics object for keeping track of performance counters and other information. Currently required. */ metrics m("sgd-inmemory-factors"); /* Basic arguments for application. NOTE: File will be automatically 'sharded'. */ sgd_lambda = get_option_float("sgd_lambda", 1e-3); sgd_gamma = get_option_float("sgd_gamma", 1e-3); sgd_step_dec = get_option_float("sgd_step_dec", 0.9); parse_command_line_args(); parse_implicit_command_line(); /* Preprocess data if needed, or discover preprocess files */ int nshards = convert_matrixmarket<EdgeDataType>(training, NULL, 0, 0, 3, TRAINING, false); init_feature_vectors<std::vector<vertex_data> >(M+N, latent_factors_inmem, !load_factors_from_file); if (validation != ""){ int vshards = convert_matrixmarket<EdgeDataType>(validation, NULL, 0, 0, 3, VALIDATION, false); init_validation_rmse_engine<VertexDataType, EdgeDataType>(pvalidation_engine, vshards, &sgd_predict); } /* load initial state from disk (optional) */ if (load_factors_from_file){ load_matrix_market_matrix(training + "_U.mm", 0, D); load_matrix_market_matrix(training + "_V.mm", M, D); } print_config(); /* Run */ SGDVerticesInMemProgram program; graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); set_engine_flags(engine); pengine = &engine; engine.run(program, niters); /* Output latent factor matrices in matrix-market format */ output_sgd_result(training); test_predictions(&sgd_predict); /* Report execution metrics */ if (!quiet) metrics_report(m); return 0; }
static void do_extra_deps(void) { if (insert_extra_deps) { char buf[80]; while(fgets(buf, sizeof(buf), stdin)) { int len = strlen(buf); if (len < 2 || buf[len-1] != '\n') { fprintf(stderr, "fixdep: bad data on stdin\n"); exit(1); } print_config(buf, len-1); } } }
/* * dump_table_config -- * Dump the config for a table. */ static int dump_table_config(WT_SESSION *session, WT_CURSOR *cursor, const char *uri) { WT_CURSOR *srch; WT_DECL_RET; int tret; const char *key, *name, *value; /* Get the table name. */ if ((name = strchr(uri, ':')) == NULL) { fprintf(stderr, "%s: %s: corrupted uri\n", progname, uri); return (1); } ++name; /* * Dump out the config information: first, dump the uri entry itself * (requires a lookup). */ cursor->set_key(cursor, uri); if ((ret = cursor->search(cursor)) != 0) return (util_cerr(cursor, "search", ret)); if ((ret = cursor->get_key(cursor, &key)) != 0) return (util_cerr(cursor, "get_key", ret)); if ((ret = cursor->get_value(cursor, &value)) != 0) return (util_cerr(cursor, "get_value", ret)); if (print_config(session, key, value, NULL) != 0) return (1); /* * The underlying table configuration function needs a second cursor: * open one before calling it, it makes error handling hugely simpler. */ if ((ret = session->open_cursor(session, NULL, cursor, NULL, &srch)) != 0) return (util_cerr(cursor, "open_cursor", ret)); if ((ret = dump_table_config_type( session, cursor, srch, name, "colgroup:")) == 0) ret = dump_table_config_type( session, cursor, srch, name, "index:"); if ((tret = srch->close(srch)) != 0) { tret = util_cerr(cursor, "close", tret); if (ret == 0) ret = tret; } return (ret); }
int main() { struct Config *config; config = init_config("../sniproxy.conf"); if (config == NULL) { fprintf(stderr, "Failed to parse config\n"); return 1; } print_config(stdout, config); free_config(config); return 0; }
void log_preamble(Config_t *cfg) { time_t t = get_starttime(); log_printf(0, "\n"); log_printf(0, "*****************************************************************\n"); log_printf(0, "Starting ibp_server on %s", ctime(&t)); log_printf(0, "*****************************************************************\n"); log_printf(0, "\n"); log_printf(0, "*********************Printing configuration file **********************\n\n"); print_config(log_fd(), cfg); log_printf(0, "*****************************************************************\n\n"); }
static void run(Options *options) { int socket = open_udp_socket(options->listen_port); if (options->verbose) fprintf(stderr, "Opened socket on port %d\n", options->listen_port); if (signal(SIGQUIT, handle_sigquit) == SIG_IGN) signal(SIGQUIT, SIG_IGN); reload_config = 1; while (1) { int sleep_time; if (reload_config) { if (options->config != NULL) destroy_config(options->config); options->config = load_config(options->config_filename); if (!options->config) { fprintf(stderr, "Warning: Config file cannot be read: %s\n", options->config_filename); options->config = create_config(); } initialise_config(options->config); if (options->verbose) { fprintf(stderr, "Loaded config from %s\n", options->config_filename); print_config(options->config, stderr); } reload_config = 0; } //TODO how long until the next request goes out? sleep_time = 1; input_timeout(socket, sleep_time); check_for_responses(options, socket); check_requests(options, socket); } close(socket); }
int main(int argc, char** argv) { int i, cnt; int* old_config; int* curr_config; int* aux; int n_n_n; int n_n; g = strtol(argv[1], (char **)NULL, 10); CHECK((read_config(argv[2], &n, cube, MAX_N) == 0), err, "Unable to read initial config"); n_n_n = n * n * n; n_n = n * n; old_config = cube; curr_config = tmp_cube; for (cnt = 0; cnt < g; ++ cnt) { int tmp_alive = 0; //#pragma omp parallel for private(i) schedule(runtime) reduction(+:tmp_alive) for (i = 0; i < n_n_n; ++ i) { int x, y, z; x = i / n_n; y = (i % n_n) / n; z = (i % n_n) % n; if (is_alive(x, y, z, old_config, n)) { curr_config[i] = 1; ++ tmp_alive; } else { curr_config[i] = 0; } } alive[cnt] = tmp_alive; aux = old_config; old_config = curr_config; curr_config = aux; } exit(print_config(argv[3], n , g, old_config, alive)); err: exit(1); }
int main(int argc, const char ** argv) { print_copyright(); //* GraphChi initialization will read the command line arguments and the configuration file. */ graphchi_init(argc, argv); /* Metrics object for keeping track of performance counters and other information. Currently required. */ metrics m("sgd-inmemory-factors"); algorithm = get_option_string("algorithm", "global_mean"); if (algorithm == "global_mean") algo = GLOBAL_MEAN; else if (algorithm == "user_mean") algo = USER_MEAN; else if (algorithm == "item_mean") algo = ITEM_MEAN; else logstream(LOG_FATAL)<<"Unsupported algorithm name. Should be --algorithm=XX where XX is one of [global_mean,user_mean,item_mean] for example --algorithm=global_mean" << std::endl; parse_command_line_args(); mytimer.start(); /* Preprocess data if needed, or discover preprocess files */ int nshards = convert_matrixmarket<float>(training, NULL, 0, 0, 3, TRAINING, false); init_feature_vectors<std::vector<vertex_data> >(M+N, latent_factors_inmem, false); rmse_vec = zeros(number_of_omp_threads()); print_config(); /* Run */ BaselineVerticesInMemProgram program; graphchi_engine<VertexDataType, EdgeDataType> engine(training, nshards, false, m); set_engine_flags(engine); pengine = &engine; engine.run(program, 1); if (algo == USER_MEAN || algo == ITEM_MEAN) output_baseline_result(training); test_predictions(&baseline_predict); /* Report execution metrics */ if (!quiet) metrics_report(m); return 0; }
int main(int argc, char * argv[]) { int res = 0; char * config_path = NULL; double start, end; // Valgrind says might want to allocate the struct with calloc and check for NULL ptr. This requires rewriting all the struct assignment. ". => ->" Config conf; //The Config struct is found in utils.h res = parse_args(argc, argv, &config_path); //parse_args is found in utils.cpp if (res != 0) { fprintf(stderr, "[ERROR] Parsing arguments.\n"); return -1; } if (config_path == NULL){ fprintf(stderr, "[ERROR] Invalid config file value.\n"); return -1; } res = load_config(conf, config_path); //load_config is found in utils.cpp if (res != 0) { fprintf(stderr, "[ERROR] loading configuration file.\n"); return -1; } print_config(conf); //print_config is found in utils.cpp for (size_t i = 0; i < conf.all_sboxes.size(); i++) { res = parse_sbox_file(conf.all_sboxes[i].c_str(), &conf.sbox); //parse_sbox_file is found in utils.cpp if (res != 0){ fprintf(stderr, "[ERROR]: Loading lookup table %s.\n", conf.all_sboxes[i].c_str()); continue; } printf("[INFO] Lookup table specified at %s\n\n", conf.all_sboxes[i].c_str()); start = omp_get_wtime(); res = run(conf); //run i defined above end = omp_get_wtime(); printf("[INFO] Total attack of file %s done in %lf seconds.\n\n", conf.all_sboxes[i].c_str(), end - start); fflush(stdout); if (res != 0) return res; free(conf.sbox); } return 0; }
int read_config() { struct option_array *opt; sstr *buf; if (!fp) { if (config.config_file == NULL) fp = fopen(CONFIG_FILE, "r"); else fp = fopen(config.config_file, "r"); if (fp == NULL) return (-1); line_no=0; } buf = sstr_init(0); while (sstr_fgets(buf, fp) != NULL) { line_no++; switch (parse_line(buf)) { case -1: sstr_free(buf); if (sublevel == 0) fclose(fp); return (-1); case 0: break; case 1: /* end subsection */ sstr_free(buf); return (0); } }; sstr_free(buf); fclose(fp); fp = NULL; opt = opts; while (opt->name != NULL && !opt->essential) opt++; if (opt->name != NULL) { fprintf(stderr, "Essential option \"%s\" not specified.\n", opt->name); return (-1); } process_opts(); #ifdef DEBUG if(!config.inetd) print_config(); #endif return (0); }