static void parse_cmdline_and_init_file (int argc, TCHAR **argv) { _tcscpy (optionsfile, _T("")); #ifdef OPTIONS_IN_HOME { TCHAR *home = getenv ("HOME"); if (home != NULL && strlen (home) < 240) { _tcscpy (optionsfile, home); _tcscat (optionsfile, _T("/")); } } #endif parse_cmdline_2 (argc, argv); _tcscat (optionsfile, restart_config); if (! target_cfgfile_load (&currprefs, optionsfile, 0, default_config)) { write_log (_T("failed to load config '%s'\n"), optionsfile); #ifdef OPTIONS_IN_HOME /* sam: if not found in $HOME then look in current directory */ _tcscpy (optionsfile, restart_config); target_cfgfile_load (&currprefs, optionsfile, 0, default_config); #endif } fixup_prefs (&currprefs); parse_cmdline (argc, argv); // fixup_prefs (&currprefs); //fixup after cmdline }
void action(const gcn::ActionEvent& actionEvent) { int selected_item; selected_item = lstConfigs->getSelected(); if(!txtName->getText().compare(ConfigFilesList[selected_item]->Name)) { //----------------------------------------------- // Selected same config again -> load and start it //----------------------------------------------- if(ConfigFilesList[selected_item]->BuildInID != BUILDINID_NONE) { load_buildin_config(ConfigFilesList[selected_item]->BuildInID); strcpy(changed_prefs.description, ConfigFilesList[selected_item]->Description); } else { target_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, 0, 0); } strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_PATH); DisableResume(); RefreshAllPanels(); if(emulating) uae_reset(1, 1); else uae_reset(0, 1); gui_running = false; } else { txtName->setText(ConfigFilesList[selected_item]->Name); txtDesc->setText(ConfigFilesList[selected_item]->Description); } }
static void parse_cmdline_and_init_file (int argc, TCHAR **argv) { _tcscpy (optionsfile, ""); #ifdef OPTIONS_IN_HOME { TCHAR *home = getenv ("HOME"); if (home != NULL && strlen (home) < 240) { _tcscpy (optionsfile, home); _tcscat (optionsfile, "/"); } } #endif parse_cmdline_2 (argc, argv); _tcscat (optionsfile, restart_config); if (! target_cfgfile_load (&currprefs, optionsfile, 0, default_config)) { write_log ("failed to load config '%s'\n", optionsfile); #ifdef OPTIONS_IN_HOME /* sam: if not found in $HOME then look in current directory */ char *saved_path = strdup (optionsfile); strcpy (optionsfile, OPTIONSFILENAME); if (!target_cfgfile_load (&currprefs, optionsfile, 0) ) { /* If not in current dir either, change path back to home * directory - so that a GUI can save a new config file there */ strcpy (optionsfile, saved_path); } free (saved_path); #endif } fixup_prefs (&currprefs); parse_cmdline (argc, argv); fixup_prefs (&currprefs); //fixup after cmdline }
bool LoadConfigByName(const char *name) { ConfigFileInfo* config = SearchConfigInList(name); if(config != NULL) { txtName->setText(config->Name); txtDesc->setText(config->Description); target_cfgfile_load(&changed_prefs, config->FullPath, 0, 0); strncpy(last_active_config, config->Name, MAX_PATH); DisableResume(); RefreshAllPanels(); } return false; }
void action(const gcn::ActionEvent& actionEvent) { int i; if (actionEvent.getSource() == cmdLoad) { //----------------------------------------------- // Load selected configuration //----------------------------------------------- i = lstConfigs->getSelected(); if(ConfigFilesList[i]->BuildInID != BUILDINID_NONE) { load_buildin_config(ConfigFilesList[i]->BuildInID); strcpy(changed_prefs.description, ConfigFilesList[i]->Description); } else { target_cfgfile_load(&changed_prefs, ConfigFilesList[i]->FullPath, 0, 0); } strncpy(last_active_config, ConfigFilesList[i]->Name, MAX_PATH); DisableResume(); RefreshAllPanels(); } else if(actionEvent.getSource() == cmdSave) { //----------------------------------------------- // Save current configuration //----------------------------------------------- char filename[MAX_DPATH]; if(!txtName->getText().empty()) { fetch_configurationpath(filename, MAX_DPATH); strncat(filename, txtName->getText().c_str(), MAX_DPATH); strncat(filename, ".uae", MAX_DPATH); strncpy(changed_prefs.description, txtDesc->getText().c_str(), 256); if(cfgfile_save(&changed_prefs, filename, 0)) RefreshPanelConfig(); } } else if(actionEvent.getSource() == cmdLoadFrom) { } else if(actionEvent.getSource() == cmdSaveAs) { } else if(actionEvent.getSource() == cmdDelete) { //----------------------------------------------- // Delete selected config //----------------------------------------------- char msg[256]; i = lstConfigs->getSelected(); if(i >= 0 && ConfigFilesList[i]->BuildInID == BUILDINID_NONE && strcmp(ConfigFilesList[i]->Name, OPTIONSFILENAME)) { snprintf(msg, 256, "Do you want to delete '%s' ?", ConfigFilesList[i]->Name); if(ShowMessage("Delete Configuration", msg, "", "Yes", "No")) { remove(ConfigFilesList[i]->FullPath); if(!strcmp(last_active_config, ConfigFilesList[i]->Name)) { txtName->setText(""); txtDesc->setText(""); last_active_config[0] = '\0'; } ConfigFilesList.erase(ConfigFilesList.begin() + i); RefreshPanelConfig(); } cmdDelete->requestFocus(); } } }
static void parse_cmdline (int argc, TCHAR **argv) { int i; for (i = 1; i < argc; i++) { if (!_tcsncmp (argv[i], _T("-diskswapper="), 13)) { TCHAR *txt = parsetextpath (argv[i] + 13); parse_diskswapper (txt); xfree (txt); } else if (_tcsncmp (argv[i], _T("-cfgparam="), 10) == 0) { ; } else if (_tcscmp (argv[i], _T("-cfgparam")) == 0) { if (i + 1 < argc) i++; } else if (_tcsncmp (argv[i], _T("-config="), 8) == 0) { TCHAR *txt = parsetextpath (argv[i] + 8); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, -1, 0); xfree (txt); } else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) { #ifdef SAVESTATE TCHAR *txt = parsetextpath (argv[i] + 11); savestate_state = STATE_DORESTORE; _tcscpy (savestate_fname, txt); xfree (txt); #else write_log (_T("Option -statefile ignored:\n")); write_log (_T("-> puae has been configured with --disable-save-state\n")); #endif // SAVESTATE } else if (_tcscmp (argv[i], _T("-f")) == 0) { /* Check for new-style "-f xxx" argument, where xxx is config-file */ if (i + 1 == argc) { write_log (_T("Missing argument for '-f' option.\n")); } else { TCHAR *txt = parsetextpath (argv[++i]); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, -1, 0); xfree (txt); } } else if (_tcscmp (argv[i], _T("-s")) == 0) { if (i + 1 == argc) write_log (_T("Missing argument for '-s' option.\n")); else cfgfile_parse_line (&currprefs, argv[++i], 0); } else if (_tcscmp (argv[i], _T("-h")) == 0 || _tcscmp (argv[i], _T("-help")) == 0) { usage (); exit (0); } else if (_tcsncmp (argv[i], _T("-cdimage="), 9) == 0) { TCHAR *txt = parsetextpath (argv[i] + 9); TCHAR *txt2 = xmalloc(TCHAR, _tcslen(txt) + 2); _tcscpy(txt2, txt); if (_tcsrchr(txt2, ',') != NULL) _tcscat(txt2, _T(",")); cfgfile_parse_option (&currprefs, _T("cdimage0"), txt2, 0); xfree(txt2); xfree (txt); } else { if (argv[i][0] == '-' && argv[i][1] != '\0') { const TCHAR *arg = argv[i] + 2; int extra_arg = *arg == '\0'; if (extra_arg) arg = i + 1 < argc ? argv[i + 1] : 0; if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg) i++; } } } }
static void parse_cmdline (int argc, TCHAR **argv) { int i; static bool started; bool firstconfig = true; bool loaded = false; // only parse command line when starting for the first time if (started) return; started = true; for (i = 1; i < argc; i++) { if (!_tcsncmp (argv[i], _T("-diskswapper="), 13)) { TCHAR *txt = parsetextpath (argv[i] + 13); parse_diskswapper (txt); xfree (txt); } else if (_tcsncmp (argv[i], _T("-cfgparam="), 10) == 0) { ; } else if (_tcscmp (argv[i], _T("-cfgparam")) == 0) { if (i + 1 < argc) i++; } else if (_tcsncmp (argv[i], _T("-config="), 8) == 0) { TCHAR *txt = parsetextpath (argv[i] + 8); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0); xfree (txt); firstconfig = false; loaded = true; } else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) { TCHAR *txt = parsetextpath (argv[i] + 11); savestate_state = STATE_DORESTORE; _tcscpy (savestate_fname, txt); xfree (txt); loaded = true; } else if (_tcscmp (argv[i], _T("-f")) == 0) { /* Check for new-style "-f xxx" argument, where xxx is config-file */ if (i + 1 == argc) { write_log (_T("Missing argument for '-f' option.\n")); } else { TCHAR *txt = parsetextpath (argv[++i]); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0); xfree (txt); firstconfig = false; } loaded = true; } else if (_tcscmp (argv[i], _T("-s")) == 0) { if (i + 1 == argc) write_log (_T("Missing argument for '-s' option.\n")); else cfgfile_parse_line (&currprefs, argv[++i], 0); } else if (_tcscmp (argv[i], _T("-h")) == 0 || _tcscmp (argv[i], _T("-help")) == 0) { usage (); exit (0); } else if (_tcsncmp (argv[i], _T("-cdimage="), 9) == 0) { TCHAR *txt = parsetextpath (argv[i] + 9); TCHAR *txt2 = xmalloc(TCHAR, _tcslen(txt) + 2); _tcscpy(txt2, txt); if (_tcsrchr(txt2, ',') != NULL) _tcscat(txt2, _T(",")); cfgfile_parse_option (&currprefs, _T("cdimage0"), txt2, 0); xfree(txt2); xfree(txt); loaded = true; } else if (argv[i][0] == '-' && argv[i][1] != '\0') { const TCHAR *arg = argv[i] + 2; int extra_arg = *arg == '\0'; if (extra_arg) arg = i + 1 < argc ? argv[i + 1] : 0; if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg) i++; } else if (i == argc - 1) { // if last config entry is an orphan and nothing else was loaded: // check if it is config file or statefile if (!loaded) { TCHAR *txt = parsetextpath(argv[i]); struct zfile *z = zfile_fopen(txt, _T("rb"), ZFD_NORMAL); if (z) { int type = zfile_gettype(z); zfile_fclose(z); if (type == ZFILE_CONFIGURATION) { currprefs.mountitems = 0; target_cfgfile_load(&currprefs, txt, CONFIG_TYPE_ALL, 0); } else if (type == ZFILE_STATEFILE) { savestate_state = STATE_DORESTORE; _tcscpy(savestate_fname, txt); } } xfree(txt); } } } }
static void parse_cmdline (int argc, TCHAR **argv) { int i; bool firstconfig = true; for (i = 1; i < argc; i++) { if (!_tcsncmp (argv[i], _T("-diskswapper="), 13)) { TCHAR *txt = parsetextpath (argv[i] + 13); parse_diskswapper (txt); xfree (txt); } else if (_tcsncmp (argv[i], _T("-cfgparam="), 10) == 0) { ; } else if (_tcscmp (argv[i], _T("-cfgparam")) == 0) { if (i + 1 < argc) i++; } else if (_tcsncmp (argv[i], _T("-config="), 8) == 0) { TCHAR *txt = parsetextpath (argv[i] + 8); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0); xfree (txt); firstconfig = false; } else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) { TCHAR *txt = parsetextpath (argv[i] + 11); savestate_state = STATE_DORESTORE; _tcscpy (savestate_fname, txt); xfree (txt); } else if (_tcscmp (argv[i], _T("-f")) == 0) { /* Check for new-style "-f xxx" argument, where xxx is config-file */ if (i + 1 == argc) { write_log (_T("Missing argument for '-f' option.\n")); } else { TCHAR *txt = parsetextpath (argv[++i]); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0); xfree (txt); firstconfig = false; } } else if (_tcscmp (argv[i], _T("-s")) == 0) { if (i + 1 == argc) write_log (_T("Missing argument for '-s' option.\n")); else cfgfile_parse_line (&currprefs, argv[++i], 0); } else if (_tcscmp (argv[i], _T("-h")) == 0 || _tcscmp (argv[i], _T("-help")) == 0) { usage (); exit (0); } else if (_tcsncmp (argv[i], _T("-cdimage="), 9) == 0) { TCHAR *txt = parsetextpath (argv[i] + 9); TCHAR *txt2 = xmalloc(TCHAR, _tcslen(txt) + 2); _tcscpy(txt2, txt); if (_tcsrchr(txt2, ',') != NULL) _tcscat(txt2, _T(",")); cfgfile_parse_option (&currprefs, _T("cdimage0"), txt2, 0); xfree(txt2); xfree (txt); } else { if (argv[i][0] == '-' && argv[i][1] != '\0') { const TCHAR *arg = argv[i] + 2; int extra_arg = *arg == '\0'; if (extra_arg) arg = i + 1 < argc ? argv[i + 1] : 0; if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg) i++; } } } }