bool BaseDialog::Show(bool show) { if (show) readConfigSettings(); else writeConfigSettings(); return wxDialog::Show(show); }
/* Main, processes command line options and calls above functions as required. */ int FDKrnConfigMain(int argc,char **argv) { char *kfilename = KERNEL; int kfile; int updates = 0; /* flag used to indicate if we need to update kernel */ int argstart,i; char *cptr; char *argptr; printf("FreeDOS Kernel Configuration %s\n", VERSION); /* 1st go through and just process arguments (help/filename/etc) */ for (i = 2; i < argc; i++) { argptr = argv[i]; /* is it an argument or an option specifier */ if (argptr[0] == '-' || argptr[0] == '/') { switch(argptr[1]) { case 'H': case 'h': case '?': showUsage(); exit(0); default: printf("Invalid argument found <%s>.\nUse %s /help for usage.\n", argptr, PROGRAM); exit(1); } } } argstart = 2; argptr = argv[argstart]; #if 0 /* No arguments is acceptable, just displays current settings using default kernel file */ if (argptr == 0) { showUsage(); exit(1); } #endif /* the first argument may be the kernel name */ if ( (argstart < argc) && (strchr(argptr, '=') == NULL) ) { kfilename = argptr; argstart++; } kfile = open(kfilename, O_RDWR | O_BINARY); if (kfile < 0) printf("Error: unable to open kernel file <%s>\n", kfilename),exit(1); /* now that we know the filename (default or given) get config info */ readConfigSettings(kfile, kfilename, &cfg); for (i = argstart; i < argc; i++) { argptr = argv[i]; if ((cptr = strchr(argptr,'=')) == NULL) goto illegal_arg; /* split argptr into 2 pieces and make cptr point to 2nd one */ *cptr = '\0'; cptr++; /* allow 3 valid characters */ if (memicmp(argptr, "DLASORT",3) == 0) { setByteOption(&(cfg.DLASortByDriveNo), cptr, 1, &updates, "DLASORT"); } else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT",3) == 0) { setByteOption(&(cfg.InitDiskShowDriveAssignment), cptr, 1, &updates, "SHOWDRIVEASSIGNMENT"); } else if (memicmp(argptr, "SKIPCONFIGSECONDS",3) == 0) { setSByteOption(&(cfg.SkipConfigSeconds), cptr, -128, 127, &updates, "SKIPCONFIGSECONDS"); } else if (memicmp(argptr, "FORCELBA",3) == 0) { setByteOption(&(cfg.ForceLBA), cptr, 1, &updates, "FORCELBA"); } else if (memicmp(argptr, "GLOBALENABLELBASUPPORT",3) == 0) { setByteOption(&(cfg.GlobalEnableLBAsupport), cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); } else { illegal_arg: printf("Unknown option found <%s>.\nUse %s /help for usage.\n", argptr, PROGRAM); exit(1); } } /* write out new config values if modified */ if (updates) { /* update it */ if (writeConfigSettings(kfile, &cfg)) { printf("Error: Unable to write configuration changes to kernel!\n"); printf(" <%s>\n", kfilename); close(kfile); exit(1); } /* display new settings */ printf("\nUpdated Kernel settings.\n"); } else printf("\nCurrent Kernel settings.\n"); /* display current settings */ displayConfigSettings(&cfg); /* and done */ close(kfile); return 0; }