int testLoadingTwoOrbs (int , ACE_TCHAR *argv[]) { ACE_ARGV new_argv; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Looking for conf file %s\n"), config_file_name ())); // Process the Service Configurator directives in this test's if (new_argv.add (argv) == -1 || new_argv.add (ACE_TEXT ("-f")) == -1 || new_argv.add (config_file_name ()) == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT("ARGV initialization failed\n"))); return -1; } if (ACE_Service_Config::instance() ->open (new_argv.argc (), new_argv.argv ()) == -1) { if (errno == ENOENT) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("No service config file found\n"))); else ACE_ERROR ((LM_ERROR, ACE_TEXT ("Service Config open failed: %m\n"))); return -1; } // Since the loaded services start their own threads, wait until all of them // are done to avoid pulling the rug under their feet. ACE_Thread_Manager::instance ()->wait (); return 0; }
Wt::Test::WTestEnvironment& env() { if (!_env) { writeConfigFile(); _env.reset(new Wt::Test::WTestEnvironment(temp_dir.string(), config_file_name().string())); } return *_env.get(); }
void writeConfigFile() { std::fstream config_file; config_file.open(config_file_name().string(), std::ios_base::out); config_file << "<server>\n" << " <application-settings location=\"*\">\n" << " <properties>\n"; for (auto property : properties) { config_file << "<property name=\"" << property.first << "\">" << property.second << "</property>\n"; } config_file << " </properties>\n" << " </application-settings>\n" << "</server>\n"; config_file.close(); }
void read_tokens_from_config_file(generator & gen) { std::string config_file_name("cppclassgen.cfg"); std::ifstream config_file(config_file_name); if(!config_file.is_open()) { print_error_and_exit("Error opening config file \"" + config_file_name + "\""); } std::string curr_line; while(std::getline(config_file, curr_line)) { std::stringstream curr_line_stream(curr_line); std::string curr_token, curr_replacement_value; curr_line_stream >> curr_token; curr_line_stream >> curr_replacement_value; // Ignore lines with < 2 entires (ex. final empty line) if(!curr_token.empty() && !curr_replacement_value.empty()) { gen.m_tokens.push_back(std::make_pair(curr_token, curr_replacement_value)); } } }
Fixture() : temp_dir(fs::unique_path()) { fs::create_directories(temp_dir); std::cout << config_file_name().string() << std::endl; setProperty("db", temp_dir.string() + "/db"); }
/* It's not static since it will be called from the GUI */ void save_config(void) { gchar *pref_file; gchar *cfgdata; gchar *tmpstr; gboolean res; GError *error = NULL; GKeyFile *gkey; gkey = g_key_file_new(); g_key_file_set_boolean(gkey, pref_group, "diagram_only", pref.diagram_only); g_key_file_set_boolean(gkey, pref_group, "group_unk", pref.group_unk); g_key_file_set_boolean(gkey, pref_group, "name_res", pref.name_res); g_key_file_set_double(gkey, pref_group, "node_timeout_time", pref.node_timeout_time); g_key_file_set_double(gkey, pref_group, "gui_node_timeout_time", pref.gui_node_timeout_time); g_key_file_set_double(gkey, pref_group, "proto_node_timeout_time", pref.proto_node_timeout_time); g_key_file_set_double(gkey, pref_group, "link_timeout_time", pref.link_timeout_time); g_key_file_set_double(gkey, pref_group, "gui_link_timeout_time", pref.gui_link_timeout_time); g_key_file_set_double(gkey, pref_group, "proto_link_timeout_time", pref.proto_link_timeout_time); g_key_file_set_double(gkey, pref_group, "proto_timeout_time", pref.proto_timeout_time); g_key_file_set_double(gkey, pref_group, "averaging_time", pref.averaging_time); g_key_file_set_double(gkey, pref_group, "node_radius_multiplier", pref.node_radius_multiplier); g_key_file_set_double(gkey, pref_group, "link_node_ratio", pref.link_node_ratio); g_key_file_set_integer(gkey, pref_group, "refresh_period", pref.refresh_period); g_key_file_set_integer(gkey, pref_group, "size_mode", pref.size_mode); g_key_file_set_integer(gkey, pref_group, "node_size_variable", pref.node_size_variable); g_key_file_set_integer(gkey, pref_group, "stack_level", pref.stack_level); g_key_file_set_string(gkey, pref_group, "filter", pref.filter); g_key_file_set_string(gkey, pref_group, "fontname", pref.fontname); g_key_file_set_string(gkey, pref_group, "text_color", pref.text_color); g_key_file_set_string(gkey, pref_group, "center_node", pref.center_node); tmpstr = g_strjoinv(" ", pref.colors); g_key_file_set_string(gkey, pref_group, "colors", tmpstr); g_free(tmpstr); g_key_file_set_string(gkey, "General", "version", VERSION); /* write config to file */ cfgdata = g_key_file_to_data(gkey, NULL, NULL); pref_file = config_file_name(); res = g_file_set_contents(pref_file, cfgdata, -1, &error); g_free(cfgdata); if (res) g_my_info (_("Preferences saved to %s"), pref_file); else { GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error saving preferences to '%s': %s"), pref_file, (error && error->message) ? error->message : ""); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } g_free(pref_file); } /* save_config */
/* loads configuration from .gnome/Etherape */ void load_config(void) { gchar *pref_file; gchar *tmpstr = NULL; gchar **colorarray; GKeyFile *gkey; /* first reset configurations to defaults */ set_default_config(&pref); gkey = g_key_file_new(); /* tries to read config from file (~/.config/etherape) */ pref_file = config_file_name(); if (!g_key_file_load_from_file(gkey, pref_file, G_KEY_FILE_NONE, NULL)) { /* file not found, try old location (~/.gnome2/Etherape) */ g_free(pref_file); pref_file = old_config_file_name(); if (!g_key_file_load_from_file(gkey, pref_file, G_KEY_FILE_NONE, NULL)) { g_free(pref_file); return; } } g_free(pref_file); read_string_config(&pref.filter, gkey, "filter"); read_string_config(&pref.fontname, gkey, "fontname"); read_string_config(&pref.text_color, gkey, "text_color"); read_string_config(&pref.center_node, gkey, "center_node"); read_boolean_config(&pref.diagram_only, gkey, "diagram_only"); read_boolean_config(&pref.group_unk, gkey, "group_unk"); read_boolean_config(&pref.stationary, gkey, "stationary"); read_boolean_config(&pref.name_res, gkey, "name_res"); read_int_config((gint *)&pref.refresh_period, gkey, "refresh_period"); read_int_config((gint *)&pref.size_mode, gkey, "size_mode"); read_int_config((gint *)&pref.node_size_variable, gkey, "node_size_variable"); read_int_config((gint *)&pref.stack_level, gkey, "stack_level"); read_double_config(&pref.node_timeout_time, gkey, "node_timeout_time"); read_double_config(&pref.gui_node_timeout_time, gkey, "gui_node_timeout_time"); read_double_config(&pref.proto_node_timeout_time, gkey, "proto_node_timeout_time"); read_double_config(&pref.link_timeout_time, gkey, "link_timeout_time"); read_double_config(&pref.gui_link_timeout_time, gkey, "gui_link_timeout_time"); read_double_config(&pref.proto_link_timeout_time, gkey, "proto_link_timeout_time"); read_double_config(&pref.proto_timeout_time, gkey, "proto_timeout_time"); read_double_config(&pref.averaging_time, gkey, "averaging_time"); read_double_config(&pref.node_radius_multiplier, gkey, "node_radius_multiplier"); read_double_config(&pref.link_node_ratio, gkey, "link_node_ratio"); read_string_config(&tmpstr, gkey, "colors"); if (tmpstr) { colorarray = g_strsplit(tmpstr, " ", 0); if (colorarray) { g_strfreev(pref.colors); pref.colors = protohash_compact(colorarray); protohash_read_prefvect(pref.colors); } g_free(tmpstr); } /* if needed, read the config version version = g_key_file_get_string(gkey, "General", "version"); ... do processing here ... g_free(version); */ g_key_file_free(gkey); } /* load_config */