static void do_config_file(const char *filename) { struct stat st; int fd; void *map; fd = open(filename, O_RDONLY); if (fd < 0) { fprintf(stderr, "fixdep: error opening config file: "); perror(filename); exit(2); } if (fstat(fd, &st) < 0) { fprintf(stderr, "fixdep: error fstat'ing config file: "); perror(filename); exit(2); } if (st.st_size == 0) { close(fd); return; } map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if ((long) map == -1) { perror("fixdep: mmap"); close(fd); return; } parse_config_file(map, st.st_size); munmap(map, st.st_size); close(fd); }
/** OpenOCD runtime meat that can become single-thread in future. It parse * commandline, reads configuration, sets up the target and starts server loop. * Commandline arguments are passed into this function from openocd_main(). */ static int openocd_thread(int argc, char *argv[], struct command_context *cmd_ctx) { int ret; if (parse_cmdline_args(cmd_ctx, argc, argv) != ERROR_OK) return EXIT_FAILURE; if (server_preinit() != ERROR_OK) return EXIT_FAILURE; ret = parse_config_file(cmd_ctx); if (ret != ERROR_OK) return EXIT_FAILURE; ret = server_init(cmd_ctx); if (ERROR_OK != ret) return EXIT_FAILURE; ret = command_run_line(cmd_ctx, "init_targets"); if (ERROR_OK != ret) ret = EXIT_FAILURE; if (init_at_startup) { ret = command_run_line(cmd_ctx, "init"); if (ERROR_OK != ret) return EXIT_FAILURE; } server_loop(cmd_ctx); server_quit(); return ret; }
void config_load(void) { if (!g_extern.block_config_read) { config_set_defaults(); parse_config_file(); } }
int main(void) { parse_config_file(".config"); setup_pci(card_id); pci.sendVetoClear(); close_pci(); return 0; }
/* now the session stuff */ PAM_EXTERN int pam_sm_open_session (pam_handle_t *pamh, int flags UNUSED, int argc, const char **argv) { int retval; char *user_name; struct passwd *pwd; int ctrl; struct pam_limit_s pl; D(("called.")); memset(&pl, 0, sizeof(pl)); ctrl = _pam_parse(pamh, argc, argv, &pl); retval = pam_get_item( pamh, PAM_USER, (void*) &user_name ); if ( user_name == NULL || retval != PAM_SUCCESS ) { pam_syslog(pamh, LOG_CRIT, "open_session - error recovering username"); return PAM_SESSION_ERR; } pwd = getpwnam(user_name); if (!pwd) { if (ctrl & PAM_DEBUG_ARG) pam_syslog(pamh, LOG_WARNING, "open_session username '%s' does not exist", user_name); return PAM_SESSION_ERR; } retval = init_limits(&pl); if (retval != PAM_SUCCESS) { pam_syslog(pamh, LOG_WARNING, "cannot initialize"); return PAM_ABORT; } retval = parse_config_file(pamh, pwd->pw_name, ctrl, &pl); if (retval == PAM_IGNORE) { D(("the configuration file has an applicable '<domain> -' entry")); return PAM_SUCCESS; } if (retval != PAM_SUCCESS) { pam_syslog(pamh, LOG_WARNING, "error parsing the configuration file"); return retval; } if (ctrl & PAM_DO_SETREUID) { setreuid(pwd->pw_uid, -1); } retval = setup_limits(pamh, pwd->pw_name, pwd->pw_uid, ctrl, &pl); if (retval & LOGIN_ERR) pam_error(pamh, _("Too many logins for '%s'."), pwd->pw_name); if (retval != LIMITED_OK) { return PAM_PERM_DENIED; } return PAM_SUCCESS; }
int read_again() { /* tracking files list creation*/ char *old_list[ntf]; for(unsigned int i=0; i<ntf; i++){ old_list[i]=tracked_files[i].logfile; } for(unsigned int i=0; i<ntf; i++){ if(inotify_rm_watch(inotify_fds[i], inotify_wds[i]) == -1){ LOG_ERR(); return -1; } } for(unsigned int i=0; i<ntf; i++){ if(fclose(tracked_files[i].log_stream)){ fprintf(core_log, "Cannot close log file \"%s\"\n", tracked_files[i].logfile); fflush(core_log); return -1; } } free(inotify_fds); free(inotify_wds); free(fds); free(tracked_files); int ret; ret = parse_config_file((const char *)config_file); CHECK_RETVAL(ret); ret = init_inotify_actions(); CHECK_RETVAL(ret); init_pollfd_structures(); /*not good code*/ ret = create_log_streams(NOTRUNCATE); for(unsigned int i=0; i<ntf; i++){ if(!is_in_list(old_list, tracked_files[i].logfile)){ if(truncate((const char *)tracked_files[i].logfile, (off_t)0)){ LOG_ERR(); } } } CHECK_RETVAL(ret); print_starttime_in_new_logfiles(); return 0; }
int main(void) { unsigned long int total_number_of_quarter_events_to_read_per_fiber_channel = 0; parse_config_file(".config"); setup_pci(card_id); readout_all_pending_data(); close_pci(); return 0; }
/* * rpmemd_config_read -- read and merge cl params and config from file */ int rpmemd_config_read(struct rpmemd_config *config, int argc, char *argv[]) { const char *config_file = RPMEMD_DEFAULT_CONFIG_FILE; rpmemd_config_set_default(config); uint64_t cl_options = 0; parse_cl_args(argc, argv, config, &config_file, &cl_options); return parse_config_file(config_file, config, cl_options); }
void load_fileinfo(ChmFile *book) { GList *pairs, *list; gchar *path; path = g_strdup_printf("%s/%s", book->dir, CHMSEE_BOOKINFO_FILE); g_debug("bookinfo path = %s", path); pairs = parse_config_file("bookinfo", path); for (list = pairs; list; list = list->next) { Item *item; item = list->data; if (strstr(item->id, "hhc")) { book->hhc = g_strdup(item->value); continue; } if (strstr(item->id, "hhk")) { book->hhk = g_strdup(item->value); continue; } if (strstr(item->id, "home")) { book->home = g_strdup(item->value); continue; } if (strstr(item->id, "title")) { book->title = g_strdup(item->value); continue; } if (strstr(item->id, "encoding")) { book->encoding = g_strdup(item->value); continue; } if (strstr(item->id, "variable_font")) { book->variable_font = g_strdup(item->value); continue; } if (strstr(item->id, "fixed_font")) { book->fixed_font = g_strdup(item->value); continue; } } free_config_list(pairs); }
/* * module initialization function */ static int mod_init(void) { LM_DBG("initializing...\n"); init_db_url( db_url , 1 /*can be null*/); address_table.len = strlen(address_table.s); ip_col.len = strlen(ip_col.s); proto_col.len = strlen(proto_col.s); pattern_col.len = strlen(pattern_col.s); info_col.len = strlen(info_col.s); grp_col.len = strlen(grp_col.s); mask_col.len = strlen(mask_col.s); port_col.len = strlen(port_col.s); allow[0].filename = get_pathname(default_allow_file); allow[0].rules = parse_config_file(allow[0].filename); if (allow[0].rules) { LM_DBG("default allow file (%s) parsed\n", allow[0].filename); } else { LM_INFO("default allow file (%s) not found => empty rule set\n", allow[0].filename); } deny[0].filename = get_pathname(default_deny_file); deny[0].rules = parse_config_file(deny[0].filename); if (deny[0].rules) { LM_DBG("default deny file (%s) parsed\n", deny[0].filename); } else { LM_INFO("default deny file (%s) not found => empty rule set\n", deny[0].filename); } if (init_address() != 0) { LM_ERR("failed to initialize the allow_address function\n"); return -1; } rules_num = 1; return 0; }
void SlideshowController::show_next_slide() { Slide current_slide; parse_config_file(slideshow_data_model_-> config_file_path()); build_slide_queue(); // Check if image folder is empty if (slideshow_data_model_->slideshow_queue()->size() == 0) { slideshow_window_view_->display_no_images_error(); return; } current_slide = slideshow_data_model_-> slideshow_queue()->service(); if (current_slide.slide_type() == IMAGE) { disconnect(&main_slide_timer_, SIGNAL(timeout()), this, SLOT(show_next_slide())); slideshow_window_view_->display_image(current_slide.full_path()); connect(&main_slide_timer_, SIGNAL(timeout()), this, SLOT(show_next_slide())); if (!slideshow_data_model_->slideshow_queue()->marketing_queued()) { main_slide_timer_.start( slideshow_data_model_->main_timer_interval()); } else { main_slide_timer_.start( slideshow_data_model_->indiv_info_slide_interval()); } } else if (current_slide.slide_type() == VIDEO) { if (slideshow_data_model_->video_disabled()) { main_slide_timer_.start(200); return; } // For some reason, this does not stop the timer // Disconnecting and reconnecting is a workaround main_slide_timer_.stop(); marketing_slide_timer_.stop(); slideshow_window_view_->display_video(current_slide.full_path()); disconnect(&main_slide_timer_, SIGNAL(timeout()), this, SLOT(show_next_slide())); } qWarning() <<"[show]: " + current_slide.full_path(); }
int main(void) { unsigned long int total_number_of_quarter_events_to_read_per_fiber_channel = 0; parse_config_file(".config"); setup_pci(card_id); usleep(10000); send_soft_trigger_request_command_packet(); usleep(10000); close_pci(); return 0; }
/* * Read and populate the given config parsed data structure. * * Return 0 on success or else a negative value. */ ATTR_HIDDEN int config_file_read(const char *filename, struct configuration *config) { int ret; FILE *fp; assert(config); /* Clear out the structure */ memset(config, 0x0, sizeof(*config)); /* If a filename wasn't provided, use the default. */ if (!filename) { filename = DEFAULT_CONF_FILE; DBG("Config file not provided by TORSOCKS_CONF_FILE. Using default %s", filename); } fp = fopen(filename, "r"); if (!fp) { WARN("Config file not found: %s. Using default for Tor", filename); (void) set_tor_address(DEFAULT_TOR_ADDRESS, config); /* * We stringify the default value here so we can print the debug * statement in the function call to set port. */ (void) set_tor_port(XSTR(DEFAULT_TOR_PORT), config); ret = set_onion_info( DEFAULT_ONION_ADDR_RANGE "/" DEFAULT_ONION_ADDR_MASK, config); if (!ret) { /* ENOMEM is probably the only case here. */ goto error; } config->allow_inbound = 0; goto end; } ret = parse_config_file(fp, config); if (ret < 0) { goto error; } DBG("Config file %s opened and parsed.", filename); end: error: if (fp) { fclose(fp); } return ret; }
/*! \fn FaceDetectorPlugin::loadConfig(string sConfigFileName) * \param sConfigFileName is path to configuration to load parameters from */ void FaceDetectorPlugin::loadConfig(string sConfigFileName) { options_description config_file("Configuration file options."); variables_map vm; config_file.add_options() // Haar face detector options ((m_sConfigSectionName + string(".cascade")).c_str(), value<string>()->default_value(DEFAULT_HAAR_FACE_CASCADE_PATH)) ((m_sConfigSectionName + string(".scale")).c_str(), value<double>()->default_value(DEFAULT_HAAR_SCALE_FACTOR)) ((m_sConfigSectionName + string(".flag")).c_str(), value<int>()->default_value(DEFAULT_HAAR_FLAG)) ((m_sConfigSectionName + string(".min-nbrs")).c_str(), value<int>()->default_value(DEFAULT_HAAR_MIN_NEIGHBORS)) ((m_sConfigSectionName + string(".min-obj-width")).c_str(), value<double>()->default_value(DEFAULT_DETECTOR_MIN_OBJECT_SIZE_WIDTH)) ((m_sConfigSectionName + string(".min-obj-height")).c_str(), value<double>()->default_value(DEFAULT_DETECTOR_MIN_OBJECT_SIZE_HEIGHT)) ((m_sConfigSectionName + string(".min-alarm-score")).c_str(), value<double>()->default_value(DEFAULT_MIN_ALARM_SCORE)) ((m_sConfigSectionName + string(".max-alarm-score")).c_str(), value<double>()->default_value(DEFAULT_MAX_ALARM_SCORE)) ((m_sConfigSectionName + string(".image-scale-factor")).c_str(), value<double>()->default_value(DEFAULT_IMAGE_SCALE_FACTOR)) ((m_sConfigSectionName + string(".det-cause")).c_str(), value<string>()->default_value(DETECTED_CAUSE)) ((m_sConfigSectionName + string(".log-prefix")).c_str(), value<string>()->default_value(LOG_PREFIX)) ; ifstream ifs(sConfigFileName.c_str()); store(parse_config_file(ifs, config_file, true), vm); notify(vm); m_fScaleFactor = vm[(m_sConfigSectionName + string(".scale")).c_str()].as<double>(); m_nMinNeighbors = vm[(m_sConfigSectionName + string(".min-nbrs")).c_str()].as<int>(); m_nFlag = vm[(m_sConfigSectionName + string(".flag")).c_str()].as<int>(); m_fMinObjWidth = vm[(m_sConfigSectionName + string(".min-obj-width")).c_str()].as<double>(); m_fMinObjHeight = vm[(m_sConfigSectionName + string(".min-obj-height")).c_str()].as<double>(); m_fMinAlarmScore = vm[(m_sConfigSectionName + string(".min-alarm-score")).c_str()].as<double>(); m_fMaxAlarmScore = vm[(m_sConfigSectionName + string(".max-alarm-score")).c_str()].as<double>(); m_fImageScaleFactor = vm[(m_sConfigSectionName + string(".image-scale-factor")).c_str()].as<double>(); m_sDetectionCause = vm[(m_sConfigSectionName + string(".det-cause")).c_str()].as<string>(); m_sLogPrefix = vm[(m_sConfigSectionName + string(".log-prefix")).c_str()].as<string>(); // if (m_sHaarCascadePath != vm[(m_sConfigSectionName + string(".cascade")).c_str()].as<string>()) // { m_sHaarCascadePath = vm[(m_sConfigSectionName + string(".cascade")).c_str()].as<string>(); _loadHaarCascade(m_sHaarCascadePath); // } zmLoadConfig(); log(LOG_NOTICE, "Face Detector Plugin\'s Object is configured."); }
int main(void) { parse_config_file(".config"); setup_pci(card_id); should_soft_trigger = true; readout_all_pending_data(); set_some_DACs_to(0, 0xe); //set_all_DACs_to(0); //set_all_DACs_to_built_in_nominal_values(); close_pci(); return 0; }
basic_parsed_options<charT> parse_config_file(const char* filename, const options_description& desc, bool allow_unregistered) { // Parser return char strings std::basic_ifstream< charT > strm(filename); if (!strm) { pdalboost::throw_exception(reading_file(filename)); } return parse_config_file(strm, desc, allow_unregistered); }
int main(void) { // setup: parse_config_file(".config"); open_status_file_for_reading_and_writing(); read_status_file(); create_directory_if_necessary(location_of_raw_datafiles); generate_new_base_filename(); setup_pci(card_id); readout_all_pending_data(); setup_filenames_for_fiber(); if (init_camac("CAMAC_config.txt")) { cerr << "ERROR: could not connect to CAMAC crate" << endl; // exit(7); } // if (CAMAC_initialized) { // CAMAC_initialize_3377s(); open_CAMAC_file(); // } setup_to_catch_ctrl_c(close_all_files); open_logfile(); open_files_for_all_enabled_fiber_channels(); unsigned short int beginning_window = 0; unsigned short int ending_window = 63; set_start_and_end_windows(beginning_window, ending_window); usleep(50000); // testing: should_soft_trigger = true; // actual running: while (1) { wait_for_start_of_spill(); while (spill_is_active()) { readout_an_event(true); read_data_from_CAMAC_and_write_to_CAMAC_file(); // CAMAC_read_3377s(); printf("\n"); } // increment_spill_number(); // write_status_file(); // generate_new_base_filename(); // split_fiber_file_to_prepare_for_next_spill(); // split_CAMAC_file_to_prepare_for_next_spill(); // usleep(250000); // sync(); } // cleanup: close_all_files(); return 0; }
void LoadAConfigFile(std::string filename) { bool ALLOW_UNREGISTERED = true; po::options_description config_opts; config_opts.add(config_only_options).add(common_options); std::ifstream cfg_file(filename.c_str()); if (cfg_file) { store(parse_config_file(cfg_file, config_opts, ALLOW_UNREGISTERED), results); notify(results); } }
int main(int argc, char *argv[]) { FILE *file=fopen("test.config", "w"); fwrite(some_data, 1, strlen(some_data), file); fclose(file); parse_config_file("test.config", 0); printf("abc=%s\n", get_config_var("abc")); return 0; }
int main(void) { unsigned long int total_number_of_quarter_events_to_read_per_fiber_channel = 0; parse_config_file(".config"); setup_pci(card_id); should_soft_trigger = true; readout_all_pending_data(); setup_feedback_enables_and_goals(1); close_pci(); return 0; }
int main(void) { unsigned long int total_number_of_quarter_events_to_read_per_fiber_channel = 0; parse_config_file(".config"); setup_pci(card_id); should_soft_trigger = true; readout_all_pending_data(); //set_all_DACs_to(0); set_all_DACs_to_built_in_nominal_values(); //setup_filenames_for_fiber(); //open_files_for_output_and_read_N_events(total_number_of_quarter_events_to_read_per_fiber_channel); close_pci(); return 0; }
void config_load(void) { // Flush out per-core configs before loading a new config. if (*g_extern.core_specific_config_path && g_extern.config_save_on_exit && g_settings.core_specific_config) config_save_file(g_extern.core_specific_config_path); if (!g_extern.block_config_read) { config_set_defaults(); parse_config_file(); } // Per-core config handling. config_load_core_specific(); }
STATIC int load_config_file(char const *filename) { FILE *file; int rc; file = fopen(filename, "r"); if (file == NULL) { return (-2); } current_file_name = filename; rc = parse_config_file(file); fclose(file); return (rc); }
void SlideshowController::begin_slideshow() { set_all_settings_to_default(); ensure_folder_structure(); parse_config_file(slideshow_data_model_-> config_file_path()); if (slideshow_data_model_->fullscreen_disabled()) { slideshow_window_view_->show(); } else { // showFullscreen() seems to only work on linux and mac. For now, we // will emulate fullscreen with frameless maximized window so the app // doesn't break on windows. #ifdef Q_OS_WIN slideshow_window_view_->setWindowFlags(Qt::FramelessWindowHint); slideshow_window_view_->showMaximized(); #else slideshow_window_view_->showFullScreen(); #endif } if (slideshow_data_model_->begin_on_marketing()) { marketing_slide_timer_.stop(); queue_marketing_slide(); } // Delay display of first slide to account for external // desktop effects int init_delay = slideshow_data_model_->init_delay_millisecs(); QTimer::singleShot(init_delay, this, SLOT(show_next_slide())); if (!slideshow_data_model_->slideshow_queue()->marketing_queued()) { main_slide_timer_.start( slideshow_data_model_->main_timer_interval()); } else { main_slide_timer_.start( slideshow_data_model_->indiv_info_slide_interval()); } marketing_slide_timer_.start( slideshow_data_model_->marketing_timer_interval() + slideshow_data_model_->indiv_info_slide_interval()); }
int init_current_config(const char *config_path) { int flag; /* Lock to prevent other threads from accessing the configuration while * it is being updated. */ pthread_mutex_lock(&__mtx_config); /* Parse/Re-parse configuration file */ flag = parse_config_file(config_path, &__current_configuration); /* Initialize unit string with the defaults */ memset(__rpiwd_unitstring, 0, sizeof(char) * RPIWD_MAX_MEASUREMENTS); __rpiwd_unitstring[RPIWD_MEASURE_TEMPERATURE] = RPIWD_DEFAULT_TEMP_UNIT; __rpiwd_unitstring[RPIWD_MEASURE_HUMIDITY] = RPIWD_DEFAULT_HUMID_UNIT; pthread_mutex_unlock(&__mtx_config); return flag; }
ssize_t parse_config_file2(const char *pathname, char sep, int (*handler)(char *key, char *value, void *data), void *data) { ssize_t ret; size_t size; char *content; content = file_read_all_text(pathname, &size); if (content == NULL) { pr_red_info("file_read_all_text"); return -EFAULT; } ret = parse_config_file(content, size, sep, handler, data); free(content); return ret; }
int main(int argc, char** argv) { if(argc != 2) { fprintf(stderr, "ERROR: usage: <conf-file> \n"); exit(1); } register_for_signals(close_db); parse_config_file(&config, argv[1]); priv_key = load_private_key(config.private_key_fname); db = bdb_open_env(config.db_env_fname, g_db_env_flags, config.db_fname, g_db_flags | DB_CREATE); warm_db(db); // create global UNIX domain server sockets // to get replies from other threads child_finished_sock = openUnixServerSock(config.request_finished_sock,1000); fd_set readset; struct timeval t,now; while(1) { t.tv_sec = 1; t.tv_usec = 0; FD_ZERO(&readset); FD_SET(child_finished_sock, &readset); int result = select(child_finished_sock + 1, &readset, NULL, NULL, &t); if(result > 0) { gettimeofday(&now,NULL); if(FD_ISSET(child_finished_sock, &readset)) { handle_finished_client(now.tv_sec); } }else if(result < 0) { fprintf(stderr, "ERROR: select: %s\n", strerror(errno)); } } close(child_finished_sock); bdb_close_env(db); return 0; }
void udev_config_init(void) { const char* env; strcpy(udev_root, UDEV_ROOT); strcpy(udev_config_filename, UDEV_CONFIG_FILE); strcpy(udev_rules_dir, UDEV_RULES_DIR); udev_log_priority = LOG_ERR; udev_run = 1; /* disable RUN key execution */ env = getenv("UDEV_RUN"); if (env && !string_is_true(env)) { udev_run = 0; } env = getenv("UDEV_CONFIG_FILE"); if (env) { strlcpy(udev_config_filename, env, sizeof(udev_config_filename)); remove_trailing_chars(udev_config_filename, '/'); } parse_config_file(); env = getenv("UDEV_ROOT"); if (env) { strlcpy(udev_root, env, sizeof(udev_root)); remove_trailing_chars(udev_root, '/'); } env = getenv("UDEV_LOG"); if (env) { udev_log_priority = log_priority(env); } dbg("UDEV_CONFIG_FILE='%s'", udev_config_filename); dbg("udev_root='%s'", udev_root); dbg("udev_rules='%s'", udev_rules_dir); dbg("udev_log=%d", udev_log_priority); }
int main(int argc, char**argv) { int option; const char* conf_file = NULL; const char* output_dir = NULL; const char options[]="c:o:h"; while ((option = getopt(argc, argv, options)) != -1) { switch (option) { case 'c': conf_file = optarg; break; case 'o': output_dir = optarg; break; case 'h': _display_usage(); return true; break; default: break; } } if (output_dir == NULL ) { printf("No output option found\n"); _display_usage(); exit(1); } if ( conf_file == NULL ) { printf("No Configuration file is given\n"); _display_usage(); exit(1); } if ( parse_config_file(output_dir, conf_file, OUTPUT_ALL) == false ) { exit(1); } display_data_from_directory(output_dir, DISPLAY_ALL); exit(0); }
int main(void) { unsigned long int total_number_of_quarter_events_to_read_per_fiber_channel = 0; parse_config_file(".config"); setup_pci(card_id); should_soft_trigger = true; readout_all_pending_data(); setup_filenames_for_fiber(); // setup_to_catch_ctrl_c(close_all_files); // open_logfile(); // open_files_for_all_enabled_fiber_channels(); send_command_packet_to_all_enabled_channels(0xeeeee01a, 0x0000077b); // set trigger thresholds for all channels // close_all_fiber_files(); close_pci(); return 0; }