BC_Window* Render::new_gui() { this->jobs = 0; batch_cancelled = 0; format_error = 0; result = 0; completion->reset(); RenderWindow *window = 0; if(mode == Render::INTERACTIVE) { // Fix the asset for rendering if(!asset) asset = new Asset; load_defaults(asset); check_asset(mwindow->edl, *asset); // Get format from user window = new RenderWindow(mwindow, this, asset, mwindow->gui->get_abs_cursor_x(1), mwindow->gui->get_abs_cursor_y(1)); window->create_objects(); } else { ; } return window; }
BlurZoomMain::BlurZoomMain(PluginServer *server) : PluginVClient(server) { thread = 0; defaults = 0; load_defaults(); }
int eval_init() { load_defaults(); if(!init_pfv()) return 0; if(!init_pvv()) return 0; return 1; }
void NewThread::run() { int result = 0; load_defaults(); int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2; int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2; window_lock->lock("NewThread::run 1\n"); nwindow = new NewWindow(mwindow, this, x, y); nwindow->create_objects(); window_lock->unlock(); result = nwindow->run_window(); window_lock->lock("NewThread::run 2\n"); delete nwindow; nwindow = 0; window_lock->unlock(); new_project->new_edl->save_defaults(mwindow->defaults); mwindow->defaults->save(); if(result) { // Aborted delete new_project->new_edl; } else { new_project->create_new_project(); } }
BC_Window* BatchRenderThread::new_gui() { current_start = 0.0; current_end = 0.0; default_job = new BatchRenderJob(mwindow->preferences); if(!file_entries) { file_entries = new ArrayList<BC_ListBoxItem*>; FileSystem fs; char string[BCTEXTLEN]; // Load current directory fs.update(getcwd(string, BCTEXTLEN)); for(int i = 0; i < fs.total_files(); i++) { file_entries->append( new BC_ListBoxItem( fs.get_entry(i)->get_name())); } } char path[BCTEXTLEN]; path[0] = 0; load_jobs(path, mwindow->preferences); load_defaults(mwindow->defaults); this->gui = new BatchRenderGUI(mwindow, this, mwindow->session->batchrender_x, mwindow->session->batchrender_y, mwindow->session->batchrender_w, mwindow->session->batchrender_h); this->gui->create_objects(); return this->gui; }
int main(int argc, char** argv){ NDB_INIT(argv[0]); const char* _tabname; load_defaults("my",load_default_groups,&argc,&argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_show_tables.trace"; #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); _tabname = argv[0]; ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str); ndb_cluster_connection->set_name("ndb_show_tables"); if (ndb_cluster_connection->connect(12,5,1)) fatal("Unable to connect to management server."); if (ndb_cluster_connection->wait_until_ready(30,0) < 0) fatal("Cluster nodes not ready in 30 seconds."); ndb = new Ndb(ndb_cluster_connection, _dbname); if (ndb->init() != 0) fatal("init"); dic = ndb->getDictionary(); for (int i = 0; _loops == 0 || i < _loops; i++) { list(_tabname, (NdbDictionary::Object::Type)_type); } delete ndb; delete ndb_cluster_connection; return NDBT_ProgramExit(NDBT_OK); }
void fse_init_theme() { fs_log("THEME: Init\n"); fs_emu_theme_overlay* o = g_fs_emu_theme.overlays; o[FS_EMU_TOP_LEFT_OVERLAY].name = g_strdup("top_left_overlay"); o[FS_EMU_TOP_RIGHT_OVERLAY].name = g_strdup("top_right_overlay"); o[FS_EMU_TOP_RIGHT_OVERLAY].anchor = FS_EMU_ANCHOR_TOP_RIGHT; o[FS_EMU_BOTTOM_RIGHT_OVERLAY].name = g_strdup("bottom_right_overlay"); o[FS_EMU_BOTTOM_RIGHT_OVERLAY].anchor = FS_EMU_ANCHOR_BOTTOM_RIGHT; o[FS_EMU_BOTTOM_LEFT_OVERLAY].name = g_strdup("bottom_left_overlay"); o[FS_EMU_BOTTOM_LEFT_OVERLAY].anchor = FS_EMU_ANCHOR_BOTTOM_LEFT; o[FS_EMU_AUDIO_LED_OVERLAY].name = g_strdup("audio_led"); o[FS_EMU_FPS_LED_OVERLAY].name = g_strdup("fps_led"); o[FS_EMU_VSYNC_LED_OVERLAY].name = g_strdup("vsync_led"); o[FS_EMU_FPS_D0_OVERLAY].name = g_strdup("fps_d0"); o[FS_EMU_FPS_D1_OVERLAY].name = g_strdup("fps_d1"); const char *theme = fs_config_get_const_string("theme"); if (theme) { g_fs_emu_theme.name = g_strdup(theme); // first try to find the theme in the user's theme dir const char *themes_dir = fs_config_get_const_string("themes_dir"); if (themes_dir) { g_fs_emu_theme.path = g_build_filename(themes_dir, g_fs_emu_theme.name, NULL); if (!fs_path_exists(g_fs_emu_theme.path)) { free(g_fs_emu_theme.path); g_fs_emu_theme.path = NULL; } } // or by direct path lookup if (!g_fs_emu_theme.path) { if (fs_path_exists(theme)) { g_fs_emu_theme.path = g_strdup(theme); } } // then try to find a bundled / installed theme if (!g_fs_emu_theme.path) { g_fs_emu_theme.path = fs_get_program_data_file( g_fs_emu_theme.name); } if (g_fs_emu_theme.path) { fs_log("theme found at %s\n", g_fs_emu_theme.path); } else { fs_emu_warning(_("Theme not found: %s"), g_fs_emu_theme.name); free(g_fs_emu_theme.name); // resources will not be found, but path should not be NULL... g_fs_emu_theme.path = g_strdup(""); } } else { g_fs_emu_theme.name = g_strdup(""); g_fs_emu_theme.path = g_strdup(""); } load_defaults(); load_theme(); }
void ReverbMenu::create_objects(BC_Hash *defaults) { add_menu(filemenu = new BC_Menu(_("File"))); filemenu->add_item(load = new ReverbLoad(reverb, this)); filemenu->add_item(save = new ReverbSave(reverb, this)); //filemenu->add_item(set_default = new ReverbSetDefault); load_defaults(defaults); prev_load_thread = new ReverbLoadPrevThread(reverb, this); }
void loadDefaults(const std::string& filename) { LoadDefaultsDecoder load_defaults(filename); Entity::Anonymous e = Entity::AnonymousData::allocator.getDefaultObjectInstance(); std::vector<double> coords(3, 0.0); e->setPos(coords); e->setVelocity(coords); std::list<std::string> parents; e->setParents(parents); }
int Snes9xConfig::load_config_file (void) { struct stat file_info; char *pathname; xmlDoc *xml_doc = NULL; xmlNodePtr xml_root = NULL; load_defaults (); pathname = get_config_dir (); if (stat (pathname, &file_info)) { if (mkdir (pathname, 0755)) { fprintf (stderr, _("Couldn't create config directory: %s\n"), pathname); return -1; } } else { chmod (pathname, 0755); } free (pathname); pathname = get_config_file_name (); if (stat (pathname, &file_info)) { save_config_file (); } xml_doc = xmlReadFile (pathname, NULL, 0); if (!xml_doc) { fprintf (stderr, _("Couldn't open config file: %s\n"), pathname); return -2; } free (pathname); xml_root = xmlDocGetRootElement (xml_doc); parse_snes9x (xml_root); xmlFreeDoc (xml_doc); return 0; }
TimeStretch::TimeStretch(PluginServer *server) : PluginAClient(server) { PLUGIN_CONSTRUCTOR_MACRO load_defaults(); temp = 0; pitch = 0; resample = 0; stretch = 0; input = 0; input_allocated = 0; }
int add_function(int sd, char *funcName, ...) { struct function *f, *flist; struct finfo *function_info; struct anonflow *flow; static char defaults_loaded = 0; va_list vl; if (!defaults_loaded) { load_defaults(); defaults_loaded = 1; } if (sd >= num_of_sets) { printf("Wrong set number\n"); return -1; } flow = flowArray[sd]; if ((function_info = search_for_registered_function(funcName)) == NULL) { printf("Function %s is not a registered function\n", funcName); return -1; } f = (struct function *)malloc(sizeof(struct function)); f->next = NULL; va_start(vl, funcName); if (function_info->init != NULL && !function_info->init(vl, (void *)f, flow)) { printf("Function %s couldn't be initialized\n", funcName); return -1; } f->function_info = function_info; if (flow->function_list == NULL) { f->fid = 1; flow->function_list = f; } else { f->fid = 0; flist = flow->function_list; while (flist->next) { flist = flist->next; } f->fid = flist->fid + 1; flist->next = f; } return 1; }
void BatchRenderThread::start_rendering(char *config_path, char *batch_path) { BC_Hash *boot_defaults; Preferences *preferences; Render *render; BC_Signals *signals = new BC_Signals; // XXX the above stuff is leaked, //PRINT_TRACE // Initialize stuff which MWindow does. signals->initialize(); MWindow::init_defaults(boot_defaults, config_path); load_defaults(boot_defaults); preferences = new Preferences; preferences->load_defaults(boot_defaults); MWindow::init_plugins(0, preferences); char font_path[BCTEXTLEN]; strcpy(font_path, preferences->plugin_dir); strcat(font_path, "/fonts"); BC_Resources::init_fontconfig(font_path); BC_WindowBase::get_resources()->vframe_shm = 1; MWindow::init_fileserver(preferences); //PRINT_TRACE load_jobs(batch_path, preferences); save_jobs(batch_path); save_defaults(boot_defaults); //PRINT_TRACE // Test EDL files for existence if(test_edl_files()) return; //PRINT_TRACE // Predict all destination paths ArrayList<char*> paths; paths.set_array_delete(); calculate_dest_paths(&paths, preferences); //PRINT_TRACE int result = ConfirmSave::test_files(0, &paths); paths.remove_all_objects(); // Abort on any existing file because it's so hard to set this up. if(result) return; //PRINT_TRACE render = new Render(0); //PRINT_TRACE render->start_batches(&jobs, boot_defaults, preferences); //PRINT_TRACE }
int main(int argc, char** argv){ NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_select_count.trace"; #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); if (argc < 1) { usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } Ndb_cluster_connection con(opt_connect_str); con.set_name("ndb_select_count"); if(con.connect(12, 5, 1) != 0) { ndbout << "Unable to connect to management server." << endl; return NDBT_ProgramExit(NDBT_FAILED); } if (con.wait_until_ready(30,0) < 0) { ndbout << "Cluster nodes not ready in 30 seconds." << endl; return NDBT_ProgramExit(NDBT_FAILED); } Ndb MyNdb(&con, _dbname ); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); return NDBT_ProgramExit(NDBT_FAILED); } for(int i = 0; i<argc; i++){ // Check if table exists in db const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); if(pTab == NULL){ ndbout << " Table " << argv[i] << " does not exist!" << endl; continue; } int rows = 0; if (select_count(&MyNdb, pTab, _parallelism, &rows, (NdbOperation::LockMode)_lock) != 0){ return NDBT_ProgramExit(NDBT_FAILED); } ndbout << rows << " records in table " << argv[i] << endl; } return NDBT_ProgramExit(NDBT_OK); }
/* load plugin configuration */ void load_config (void) { HotkeyConfiguration *hotkey; int i,max; /* default volume level */ plugin_cfg.vol_increment = 4; plugin_cfg.vol_decrement = 4; hotkey = &(plugin_cfg.first); hotkey->next = NULL; hotkey->key = 0; hotkey->mask = 0; hotkey->event = 0; hotkey->type = TYPE_KEY; max = aud_get_int ("globalHotkey", "NumHotkeys"); if (max == 0) load_defaults(); else for (i=0; i<max; i++) { gchar *text = NULL; if (hotkey->key) { hotkey->next = (HotkeyConfiguration*) malloc(sizeof (HotkeyConfiguration)); hotkey = hotkey->next; hotkey->next = NULL; hotkey->key = 0; hotkey->mask = 0; hotkey->event = 0; hotkey->type = TYPE_KEY; } text = g_strdup_printf("Hotkey_%d_key", i); hotkey->key = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_mask", i); hotkey->mask = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_type", i); hotkey->type = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_event", i); hotkey->event = aud_get_int ("globalHotkey", text); g_free(text); } }
int main(int argc, char** argv){ NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_delete_all.trace"; #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); Ndb_cluster_connection con(opt_connect_str); con.set_name("ndb_delete_all"); if(con.connect(12, 5, 1) != 0) { ndbout << "Unable to connect to management server." << endl; return NDBT_ProgramExit(NDBT_FAILED); } if (con.wait_until_ready(30,0) < 0) { ndbout << "Cluster nodes not ready in 30 seconds." << endl; return NDBT_ProgramExit(NDBT_FAILED); } Ndb MyNdb(&con, _dbname ); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); return NDBT_ProgramExit(NDBT_FAILED); } // Check if table exists in db int res = NDBT_OK; for(int i = 0; i<argc; i++){ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); if(pTab == NULL){ ndbout << " Table " << argv[i] << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } ndbout << "Deleting all from " << argv[i]; if (! _transactional) ndbout << " (non-transactional)"; ndbout << " ..."; if(clear_table(&MyNdb, pTab, ! _transactional) == NDBT_FAILED){ res = NDBT_FAILED; ndbout << "FAILED" << endl; } } return NDBT_ProgramExit(res); }
int main(int argc, char** argv){ NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); int ho_error; if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); if (argc < 1) { usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } Ndb_cluster_connection con(opt_connect_str); con.set_name("ndb_drop_table"); if(con.connect(12, 5, 1) != 0) { ndbout << "Unable to connect to management server." << endl; return NDBT_ProgramExit(NDBT_FAILED); } if (con.wait_until_ready(30,3) < 0) { ndbout << "Cluster nodes not ready in 30 seconds." << endl; return NDBT_ProgramExit(NDBT_FAILED); } Ndb MyNdb(&con, _dbname ); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); return NDBT_ProgramExit(NDBT_FAILED); } int res = 0; for(int i = 0; i<argc; i++){ ndbout << "Dropping table " << argv[i] << "..."; int tmp; if((tmp = MyNdb.getDictionary()->dropTable(argv[i])) != 0){ ndbout << endl << MyNdb.getDictionary()->getNdbError() << endl; res = tmp; } else { ndbout << "OK" << endl; } } if(res != 0){ return NDBT_ProgramExit(NDBT_FAILED); } return NDBT_ProgramExit(NDBT_OK); }
int main (int argc, char *argv[]) { GtkWidget *dialog = NULL; gchar * filename = NULL; gchar * fname = NULL; GError *error = NULL; GtkBuilder *builder = NULL; GtkWidget *main_window = NULL; gtk_init (&argc, &argv); global_data = g_new0(gconstpointer, 1); fname = g_build_filename(GUI_DATA_DIR,"mtxloader.glade",NULL); filename = get_file(NULL,fname,NULL); if (!filename) { printf("ERROR! Could NOT locate %s\n",fname); g_free(fname); dialog = gtk_message_dialog_new_with_markup(NULL,GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"\n<b>MegaTunix/mtxloader</b> doesn't appear to be installed correctly!\n\nDid you forget to run <i>\"sudo make install\"</i> ??\n\n"); g_signal_connect(G_OBJECT(dialog),"response", G_CALLBACK(gtk_main_quit), dialog); g_signal_connect(G_OBJECT(dialog),"delete_event", G_CALLBACK(gtk_main_quit), dialog); g_signal_connect(G_OBJECT(dialog),"destroy_event", G_CALLBACK(gtk_main_quit), dialog); gtk_widget_show_all(dialog); gtk_main(); exit(-1); } else { builder = gtk_builder_new(); if(!gtk_builder_add_from_file(builder,filename,&error)) { g_warning ("Couldn't load builder file: %s", error->message); g_error_free(error); exit(-1); } } main_window = GTK_WIDGET(gtk_builder_get_object(builder, "main_window")); DATA_SET(global_data,"main_window",main_window); DATA_SET(global_data,"builder",builder); g_free(fname); g_free(filename); gtk_builder_connect_signals (builder,NULL); load_defaults(); gtk_widget_show_all (main_window); gtk_main (); return 0; }
BC_Window* NewThread::new_gui() { mwindow->edl->save_defaults(mwindow->defaults); new_project->create_new_edl(); load_defaults(); mwindow->gui->lock_window("NewThread::new_gui"); int x = mwindow->gui->get_abs_cursor_x(0) - WIDTH / 2; int y = mwindow->gui->get_abs_cursor_y(0) - HEIGHT / 2; nwindow = new NewWindow(mwindow, this, x, y); nwindow->create_objects(); mwindow->gui->unlock_window(); return nwindow; }
int main(int argc, char** argv){ NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_desc.trace"; #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); Ndb_cluster_connection con(opt_connect_str); con.set_name("ndb_desc"); if(con.connect(12, 5, 1) != 0) { ndbout << "Unable to connect to management server." << endl; return NDBT_ProgramExit(NDBT_FAILED); } if (con.wait_until_ready(30,0) < 0) { ndbout << "Cluster nodes not ready in 30 seconds." << endl; return NDBT_ProgramExit(NDBT_FAILED); } Ndb MyNdb(&con, _dbname); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); return NDBT_ProgramExit(NDBT_FAILED); } for(int i= 0; i<argc;i++) { if(desc_table(&MyNdb,argv[i])) ; else if(desc_tablespace(&MyNdb,argv[i])) ; else if(desc_logfilegroup(&MyNdb,argv[i])) ; else if(desc_datafile(con, &MyNdb, argv[i])) ; else if(desc_undofile(con, &MyNdb, argv[i])) ; else ndbout << "No such object: " << argv[i] << endl << endl; } return NDBT_ProgramExit(NDBT_OK); }
/* Parses single column description. Returns zero on successful parsing. */ static int parse(map_name_cb cn, const char str[], column_info_t *info, void *arg) { load_defaults(info); if((str = parse_align(str, info)) != NULL) { if((str = parse_width(str, info)) != NULL) { if((str = parse_name(cn, str, info, arg)) != NULL) { str = parse_cropping(str, info); } } } return str == NULL || *str != '\0'; }
int main(int argc, char *argv[]) { int pid = 0; int t = 0; int ret = -1; char **save_argv; load_defaults("my",load_default_groups,&argc,&argv); save_argv = argv; progname= argv[0]; if (handle_options(&argc, &argv, my_long_options, get_one_option)) exit(-1); if (!argv[0] || !argv[1] || (pid = atoi(argv[0])) <= 0 || (t= atoi(argv[1])) <= 0) ret = mysqlcc_main(argc, argv); free_defaults(save_argv); return ret; }
int main (int argc, char *argv[]) { int i; printf ("Original argument vector:\n"); for (i = 0; i < argc; i++) printf ("arg %d: %s\n", i, argv[i]); MY_INIT (argv[0]); load_defaults ("my", client_groups, &argc, &argv); printf ("Modified argument vector:\n"); for (i = 0; i < argc; i++) printf ("arg %d: %s\n", i, argv[i]); exit (0); }
static void load_gui_defaults (JpegSaveGui *pg) { GtkAdjustment *restart_markers; load_defaults (); #define SET_ACTIVE_BTTN(field) \ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pg->field), jsvals.field) SET_ACTIVE_BTTN (optimize); SET_ACTIVE_BTTN (progressive); SET_ACTIVE_BTTN (use_orig_quality); SET_ACTIVE_BTTN (preview); SET_ACTIVE_BTTN (save_exif); SET_ACTIVE_BTTN (save_thumbnail); SET_ACTIVE_BTTN (save_xmp); SET_ACTIVE_BTTN (save_iptc); #undef SET_ACTIVE_BTTN /*spin button stuff*/ g_signal_handler_block (pg->use_restart_markers, pg->handler_id_restart); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pg->use_restart_markers), jsvals.restart); restart_markers = GTK_ADJUSTMENT (pg->scale_data); gtk_adjustment_set_value (restart_markers, jsvals.restart); g_signal_handler_unblock (pg->use_restart_markers, pg->handler_id_restart); gtk_adjustment_set_value (GTK_ADJUSTMENT (pg->quality), jsvals.quality); gtk_adjustment_set_value (GTK_ADJUSTMENT (pg->smoothing), jsvals.smoothing); if (gimp_drawable_is_rgb (drawable_ID_global)) { gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->subsmp), jsvals.subsmp); } gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->dct), jsvals.dct); }
BC_Window* BatchRenderThread::new_gui() { current_start = 0.0; current_end = 0.0; default_job = new BatchRenderJob(mwindow->preferences); char path[BCTEXTLEN]; path[0] = 0; load_jobs(path, mwindow->preferences); load_defaults(mwindow->defaults); this->gui = new BatchRenderGUI(mwindow, this, mwindow->session->batchrender_x, mwindow->session->batchrender_y, mwindow->session->batchrender_w, mwindow->session->batchrender_h); this->gui->create_objects(); return this->gui; }
int main (int argc, char *argv[]) { int i; int opt_err; printf ("Original connection parameters:\n"); printf ("hostname: %s\n", opt_host_name ? opt_host_name : "(null)"); printf ("username: %s\n", opt_user_name ? opt_user_name : "(null)"); printf ("password: %s\n", opt_password ? opt_password : "******"); printf ("port number: %u\n", opt_port_num); printf ("socket filename: %s\n", opt_socket_name ? opt_socket_name : "(null)"); printf ("Original argument vector:\n"); for (i = 0; i < argc; i++) printf ("arg %d: %s\n", i, argv[i]); MY_INIT (argv[0]); load_defaults ("my", client_groups, &argc, &argv); printf ("Argument vector after calling load_defaults():\n"); for (i = 0; i < argc; i++) printf ("arg %d: %s\n", i, argv[i]); if ((opt_err = handle_options (&argc, &argv, my_opts, get_one_option))) exit (opt_err); printf ("Connection parameters after calling handle_options():\n"); printf ("hostname: %s\n", opt_host_name ? opt_host_name : "(null)"); printf ("username: %s\n", opt_user_name ? opt_user_name : "(null)"); printf ("password: %s\n", opt_password ? opt_password : "******"); printf ("port number: %u\n", opt_port_num); printf ("socket filename: %s\n", opt_socket_name ? opt_socket_name : "(null)"); printf ("Argument vector after calling handle_options():\n"); for (i = 0; i < argc; i++) printf ("arg %d: %s\n", i, argv[i]); exit (0); }
void BatchRenderThread::start_rendering(char *config_path, char *batch_path) { BC_Hash *boot_defaults; Preferences *preferences; Render *render; ArrayList<PluginServer*> *plugindb; // Initialize stuff which MWindow does. MWindow::init_defaults(boot_defaults, config_path); load_defaults(boot_defaults); preferences = new Preferences; preferences->load_defaults(boot_defaults); MWindow::init_plugins(preferences, plugindb, 0); load_jobs(batch_path, preferences); save_jobs(batch_path); save_defaults(boot_defaults); // Test EDL files for existence if(test_edl_files()) return; // Predict all destination paths ArrayList<char*> paths; calculate_dest_paths(&paths, preferences, plugindb); int result = ConfirmSave::test_files(0, &paths); paths.remove_all_objects(); // Abort on any existing file because it's so hard to set this up. if(result) return; render = new Render(0); render->start_batches(&jobs, boot_defaults, preferences, plugindb); }
int main(int argc, char** argv){ NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); const char* _hostName = NULL; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_waiter.trace"; #endif if (handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option)) return NDBT_ProgramExit(NDBT_WRONGARGS); _hostName = argv[0]; if (_hostName == 0) _hostName= opt_connect_str; enum ndb_mgm_node_status wait_status; if (_no_contact) { wait_status= NDB_MGM_NODE_STATUS_NO_CONTACT; } else if (_not_started) { wait_status= NDB_MGM_NODE_STATUS_NOT_STARTED; } else if (_single_user) { wait_status= NDB_MGM_NODE_STATUS_SINGLEUSER; } else { wait_status= NDB_MGM_NODE_STATUS_STARTED; } if (waitClusterStatus(_hostName, wait_status) != 0) return NDBT_ProgramExit(NDBT_FAILED); return NDBT_ProgramExit(NDBT_OK); }
/* * MAIN */ int main(int argc, char** argv) { NDB_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:O,/tmp/ndb_mgmd.trace"; #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) exit(ho_error); start: glob= new MgmGlobals; /** * OSE specific. Enable shared ownership of file system resources. * This is needed in order to use the cluster log since the events * from the cluster is written from the 'ndb_receive'(NDBAPI) thread/process. */ #if defined NDB_OSE || defined NDB_SOFTOSE efs_segment_share(); #endif global_mgmt_server_check = 1; if (opt_interactive || opt_non_interactive || g_print_full_config) { opt_daemon= 0; } if (opt_mycnf && opt_config_filename) { ndbout_c("Both --mycnf and -f is not supported"); return 0; } if (opt_mycnf == 0 && opt_config_filename == 0) { struct stat buf; if (stat("config.ini", &buf) != -1) opt_config_filename = "config.ini"; } glob->socketServer = new SocketServer(); MgmApiService * mapi = new MgmApiService(); glob->mgmObject = new MgmtSrvr(glob->socketServer, opt_config_filename, opt_connect_str); if (g_print_full_config) goto the_end; if (glob->mgmObject->init()) goto error_end; my_setwd(NdbConfig_get_path(0), MYF(0)); glob->localNodeId= glob->mgmObject->getOwnNodeId(); if (glob->localNodeId == 0) { goto error_end; } glob->port= glob->mgmObject->getPort(); if (glob->port == 0) goto error_end; glob->interface_name = 0; glob->use_specific_ip = false; if(!glob->use_specific_ip){ int count= 5; // no of retries for tryBind while(!glob->socketServer->tryBind(glob->port, glob->interface_name)){ if (--count > 0) { NdbSleep_MilliSleep(1000); continue; } ndbout_c("Unable to setup port: %s:%d!\n" "Please check if the port is already used,\n" "(perhaps a ndb_mgmd is already running),\n" "and if you are executing on the correct computer", (glob->interface_name ? glob->interface_name : "*"), glob->port); goto error_end; } free(glob->interface_name); glob->interface_name = 0; } if(!glob->socketServer->setup(mapi, &glob->port, glob->interface_name)) { ndbout_c("Unable to setup management port: %d!\n" "Please check if the port is already used,\n" "(perhaps a ndb_mgmd is already running),\n" "and if you are executing on the correct computer", glob->port); delete mapi; goto error_end; } if(!glob->mgmObject->check_start()){ ndbout_c("Unable to check start management server."); ndbout_c("Probably caused by illegal initial configuration file."); goto error_end; } if (opt_daemon) { // Become a daemon char *lockfile= NdbConfig_PidFileName(glob->localNodeId); char *logfile= NdbConfig_StdoutFileName(glob->localNodeId); NdbAutoPtr<char> tmp_aptr1(lockfile), tmp_aptr2(logfile); if (NdbDaemon_Make(lockfile, logfile, 0) == -1) { ndbout << "Cannot become daemon: " << NdbDaemon_ErrorText << endl; return 1; } } #ifndef NDB_WIN32 signal(SIGPIPE, SIG_IGN); #endif { BaseString error_string; if(!glob->mgmObject->start(error_string)){ ndbout_c("Unable to start management server."); ndbout_c("Probably caused by illegal initial configuration file."); ndbout_c(error_string.c_str()); goto error_end; } } //glob->mgmObject->saveConfig(); mapi->setMgm(glob->mgmObject); char msg[256]; BaseString::snprintf(msg, sizeof(msg), "NDB Cluster Management Server. %s", NDB_VERSION_STRING); ndbout_c(msg); g_eventLogger.info(msg); BaseString::snprintf(msg, 256, "Id: %d, Command port: %d", glob->localNodeId, glob->port); ndbout_c(msg); g_eventLogger.info(msg); g_StopServer = false; g_RestartServer= false; glob->socketServer->startServer(); #if ! defined NDB_OSE && ! defined NDB_SOFTOSE if(opt_interactive) { BaseString con_str; if(glob->interface_name) con_str.appfmt("host=%s:%d", glob->interface_name, glob->port); else con_str.appfmt("localhost:%d", glob->port); Ndb_mgmclient com(con_str.c_str(), 1); while(g_StopServer != true && read_and_execute(&com, "ndb_mgm> ", 1)); } else #endif { while(g_StopServer != true) NdbSleep_MilliSleep(500); } if(g_RestartServer) g_eventLogger.info("Restarting server..."); else g_eventLogger.info("Shutting down server..."); glob->socketServer->stopServer(); // We disconnect from the ConfigRetreiver mgmd when we delete glob below glob->socketServer->stopSessions(true); g_eventLogger.info("Shutdown complete"); the_end: delete glob; if(g_RestartServer) goto start; ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return 0; error_end: delete glob; ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return 1; }
int OGRMySQLDataSource::Open( const char * pszNewName, int bUpdate, int bTestOpen ) { CPLAssert( nLayers == 0 ); /* -------------------------------------------------------------------- */ /* Verify MySQL prefix. */ /* -------------------------------------------------------------------- */ if( !EQUALN(pszNewName,"MYSQL:",6) ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_AppDefined, "%s does not conform to MySQL naming convention," " MYSQL:dbname[, user=..][,password=..][,host=..][,port=..][tables=table;table;...]", pszNewName ); return FALSE; } /* -------------------------------------------------------------------- */ /* Use options process to get .my.cnf file contents. */ /* -------------------------------------------------------------------- */ int nPort = 0, i; char **papszTableNames=NULL; std::string oHost, oPassword, oUser, oDB; char *apszArgv[2] = { (char*) "org", NULL }; char **papszArgv = apszArgv; int nArgc = 1; const char *client_groups[] = {"client", "ogr", NULL }; my_init(); // I hope there is no problem with calling this multiple times! load_defaults( "my", client_groups, &nArgc, &papszArgv ); for( i = 0; i < nArgc; i++ ) { if( EQUALN(papszArgv[i],"--user="******"--host=",7) ) oHost = papszArgv[i] + 7; else if( EQUALN(papszArgv[i],"--password="******"--port=",7) ) nPort = atoi(papszArgv[i] + 7); } // cleanup free_defaults( papszArgv ); /* -------------------------------------------------------------------- */ /* Parse out connection information. */ /* -------------------------------------------------------------------- */ char **papszItems = CSLTokenizeString2( pszNewName+6, ",", CSLT_HONOURSTRINGS ); if( CSLCount(papszItems) < 1 ) { CSLDestroy( papszItems ); CPLError( CE_Failure, CPLE_AppDefined, "MYSQL: request missing databasename." ); return FALSE; } oDB = papszItems[0]; for( i = 1; papszItems[i] != NULL; i++ ) { if( EQUALN(papszItems[i],"user="******"password="******"host=",5) ) oHost = papszItems[i] + 5; else if( EQUALN(papszItems[i],"port=",5) ) nPort = atoi(papszItems[i] + 5); else if( EQUALN(papszItems[i],"tables=",7) ) { papszTableNames = CSLTokenizeStringComplex( papszItems[i] + 7, ";", FALSE, FALSE ); } else CPLError( CE_Warning, CPLE_AppDefined, "'%s' in MYSQL datasource definition not recognised and ignored.", papszItems[i] ); } CSLDestroy( papszItems ); /* -------------------------------------------------------------------- */ /* Try to establish connection. */ /* -------------------------------------------------------------------- */ hConn = mysql_init( NULL ); if( hConn == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); } /* -------------------------------------------------------------------- */ /* Set desired options on the connection: charset and timeout. */ /* -------------------------------------------------------------------- */ if( hConn ) { const char *pszTimeoutLength = CPLGetConfigOption( "MYSQL_TIMEOUT", "0" ); unsigned int timeout = atoi(pszTimeoutLength); mysql_options(hConn, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&timeout); mysql_options(hConn, MYSQL_SET_CHARSET_NAME, "utf8" ); } /* -------------------------------------------------------------------- */ /* Perform connection. */ /* -------------------------------------------------------------------- */ if( hConn && mysql_real_connect( hConn, oHost.length() ? oHost.c_str() : NULL, oUser.length() ? oUser.c_str() : NULL, oPassword.length() ? oPassword.c_str() : NULL, oDB.length() ? oDB.c_str() : NULL, nPort, NULL, CLIENT_INTERACTIVE ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "MySQL connect failed for: %s\n%s", pszNewName + 6, mysql_error( hConn ) ); mysql_close( hConn ); hConn = NULL; } if( hConn == NULL ) { CSLDestroy( papszTableNames ); return FALSE; } pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate; /* -------------------------------------------------------------------- */ /* Get a list of available tables. */ /* -------------------------------------------------------------------- */ if( papszTableNames == NULL ) { MYSQL_RES *hResultSet; MYSQL_ROW papszRow; if( mysql_query( hConn, "SHOW TABLES" ) ) { ReportError( "SHOW TABLES Failed" ); return FALSE; } hResultSet = mysql_store_result( hConn ); if( hResultSet == NULL ) { ReportError( "mysql_store_result() failed on SHOW TABLES result."); return FALSE; } while( (papszRow = mysql_fetch_row( hResultSet )) != NULL ) { if( papszRow[0] == NULL ) continue; if( EQUAL(papszRow[0],"spatial_ref_sys") || EQUAL(papszRow[0],"geometry_columns") ) continue; papszTableNames = CSLAddString(papszTableNames, papszRow[0] ); } mysql_free_result( hResultSet ); } /* -------------------------------------------------------------------- */ /* Get the schema of the available tables. */ /* -------------------------------------------------------------------- */ int iRecord; for( iRecord = 0; papszTableNames != NULL && papszTableNames[iRecord] != NULL; iRecord++ ) { // FIXME: This should be fixed to deal with tables // for which we can't open because the name is bad/ OpenTable( papszTableNames[iRecord], bUpdate, FALSE ); } CSLDestroy( papszTableNames ); return nLayers > 0 || bUpdate; }