diff --git a/include/shell.h b/include/shell.h index 04ca98cc..4d3eaaef 100644 --- a/include/shell.h +++ b/include/shell.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.h,v 1.11 2005-03-25 09:46:53 qbix79 Exp $ */ +/* $Id: shell.h,v 1.12 2005-04-21 21:17:45 qbix79 Exp $ */ #ifndef DOSBOX_SHELL_H #define DOSBOX_SHELL_H @@ -71,7 +71,9 @@ public: void InputCommand(char * line); void ShowPrompt(); void DoCommand(char * cmd); - void Execute(char * name,char * args); + bool Execute(char * name,char * args); + /* Checks if it matches a hardware-property */ + bool CheckConfig(char* cmd,char*line); /* Some internal used functions */ char * Which(char * name); /* Some supported commands */ diff --git a/src/dosbox.cpp b/src/dosbox.cpp index d2f95883..6722a5c5 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dosbox.cpp,v 1.83 2005-02-10 10:20:47 qbix79 Exp $ */ +/* $Id: dosbox.cpp,v 1.84 2005-04-21 21:17:45 qbix79 Exp $ */ #include #include @@ -208,17 +208,17 @@ void DOSBOX_Init(void) { LOG_StartUp(); #endif - secprop->AddInitFunction(&IO_Init); - secprop->AddInitFunction(&PAGING_Init); - secprop->AddInitFunction(&MEM_Init); - secprop->AddInitFunction(&HARDWARE_Init); + secprop->AddInitFunction(&IO_Init);//done + secprop->AddInitFunction(&PAGING_Init);//done + secprop->AddInitFunction(&MEM_Init);//done + secprop->AddInitFunction(&HARDWARE_Init);//done secprop->Add_int("memsize",16); secprop->AddInitFunction(&CALLBACK_Init); - secprop->AddInitFunction(&PIC_Init); + secprop->AddInitFunction(&PIC_Init);//done secprop->AddInitFunction(&PROGRAMS_Init); - secprop->AddInitFunction(&TIMER_Init); - secprop->AddInitFunction(&CMOS_Init); - secprop->AddInitFunction(&SERIAL_Init); + secprop->AddInitFunction(&TIMER_Init);//done + secprop->AddInitFunction(&CMOS_Init);//done + secprop->AddInitFunction(&SERIAL_Init); //done MSG_Add("DOSBOX_CONFIGFILE_HELP", "language -- Select another language file.\n" @@ -238,7 +238,7 @@ void DOSBOX_Init(void) { " Supported are none,normal2x,advmame2x,advmame3x,advinterp2x,interp2x,tv2x.\n" ); - secprop=control->AddSection_prop("cpu",&CPU_Init); + secprop=control->AddSection_prop("cpu",&CPU_Init,true);//done secprop->Add_string("core","normal"); secprop->Add_int("cycles",3000); secprop->Add_int("cycleup",500); @@ -257,10 +257,10 @@ void DOSBOX_Init(void) { #if C_FPU secprop->AddInitFunction(&FPU_Init); #endif - secprop->AddInitFunction(&DMA_Init); + secprop->AddInitFunction(&DMA_Init);//done secprop->AddInitFunction(&VGA_Init); secprop->AddInitFunction(&KEYBOARD_Init); - secprop->AddInitFunction(&JOYSTICK_Init); + secprop->AddInitFunction(&JOYSTICK_Init);//done secprop=control->AddSection_prop("mixer",&MIXER_Init); secprop->Add_bool("nosound",false); @@ -277,8 +277,8 @@ void DOSBOX_Init(void) { "prebuffer -- How many milliseconds of data to keep on top of the blocksize.\n" ); - secprop=control->AddSection_prop("midi",&MIDI_Init); - secprop->AddInitFunction(&MPU401_Init); + secprop=control->AddSection_prop("midi",&MIDI_Init,true);//done + secprop->AddInitFunction(&MPU401_Init,true);//done secprop->Add_bool("mpu401",true); secprop->Add_bool("intelligent",true); secprop->Add_string("device","default"); @@ -296,7 +296,7 @@ void DOSBOX_Init(void) { #if C_DEBUG secprop=control->AddSection_prop("debug",&DEBUG_Init); #endif - secprop=control->AddSection_prop("sblaster",&SBLASTER_Init); + secprop=control->AddSection_prop("sblaster",&SBLASTER_Init,true);//done secprop->Add_string("type","sb16"); secprop->Add_hex("base",0x220); secprop->Add_int("irq",7); @@ -315,7 +315,7 @@ void DOSBOX_Init(void) { "oplrate -- Sample rate of OPL music emulation.\n" ); - secprop=control->AddSection_prop("gus",&GUS_Init); + secprop=control->AddSection_prop("gus",&GUS_Init,true); //done secprop->Add_bool("gus",true); secprop->Add_int("rate",22050); secprop->Add_hex("base",0x240); @@ -336,12 +336,12 @@ void DOSBOX_Init(void) { " with Timidity should work fine.\n" ); - secprop=control->AddSection_prop("speaker",&PCSPEAKER_Init); + secprop=control->AddSection_prop("speaker",&PCSPEAKER_Init,true);//done secprop->Add_bool("pcspeaker",true); secprop->Add_int("pcrate",22050); - secprop->AddInitFunction(&TANDYSOUND_Init); + secprop->AddInitFunction(&TANDYSOUND_Init,true);//done secprop->Add_int("tandyrate",22050); - secprop->AddInitFunction(&DISNEY_Init); + secprop->AddInitFunction(&DISNEY_Init,true);//done secprop->Add_bool("disney",true); MSG_Add("SPEAKER_CONFIGFILE_HELP", @@ -351,16 +351,16 @@ void DOSBOX_Init(void) { " Tandysound emulation is present if machine is set to tandy.\n" "disney -- Enable Disney Sound Source emulation.\n" ); - secprop=control->AddSection_prop("bios",&BIOS_Init); + secprop=control->AddSection_prop("bios",&BIOS_Init,false);//done secprop->AddInitFunction(&INT10_Init); secprop->AddInitFunction(&MOUSE_Init); //Must be after int10 as it uses CurMode /* All the DOS Related stuff, which will eventually start up in the shell */ //TODO Maybe combine most of the dos stuff in one section like ems,xms - secprop=control->AddSection_prop("dos",&DOS_Init); - secprop->AddInitFunction(&XMS_Init); + secprop=control->AddSection_prop("dos",&DOS_Init,false);//done + secprop->AddInitFunction(&XMS_Init,true);//done secprop->Add_bool("xms",true); - secprop->AddInitFunction(&EMS_Init); + secprop->AddInitFunction(&EMS_Init,true);//done secprop->Add_bool("ems",true); MSG_Add("DOS_CONFIGFILE_HELP", "xms -- Enable XMS support.\n" @@ -369,7 +369,7 @@ void DOSBOX_Init(void) { // Mscdex secprop->AddInitFunction(&MSCDEX_Init); #if C_MODEM - secprop=control->AddSection_prop("modem",&MODEM_Init); + secprop=control->AddSection_prop("modem",&MODEM_Init,true);//done secprop->Add_bool("modem",false); secprop->Add_hex("comport",2); secprop->Add_int("listenport",23); @@ -412,4 +412,3 @@ void DOSBOX_Init(void) { ); control->SetStartUp(&SHELL_Init); } - diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index c9cdb151..eb975c73 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: programs.cpp,v 1.18 2005-02-10 10:21:11 qbix79 Exp $ */ +/* $Id: programs.cpp,v 1.19 2005-04-21 21:17:45 qbix79 Exp $ */ #include #include @@ -197,7 +197,8 @@ void MSG_Write(const char *); void CONFIG::Run(void) { FILE * f; - if (cmd->FindString("-writeconf",temp_line,true)) { + if (cmd->FindString("-writeconf",temp_line,true) + || cmd->FindString("-wc",temp_line,true)) { f=fopen(temp_line.c_str(),"wb+"); if (!f) { WriteOut(MSG_Get("PROGRAM_CONFIG_FILE_ERROR"),temp_line.c_str()); @@ -207,7 +208,8 @@ void CONFIG::Run(void) { control->PrintConfig(temp_line.c_str()); return; } - if (cmd->FindString("-writelang",temp_line,true)) { + if (cmd->FindString("-writelang",temp_line,true) + ||cmd->FindString("-wl",temp_line,true)) { f=fopen(temp_line.c_str(),"wb+"); if (!f) { WriteOut(MSG_Get("PROGRAM_CONFIG_FILE_ERROR"),temp_line.c_str()); @@ -217,7 +219,68 @@ void CONFIG::Run(void) { MSG_Write(temp_line.c_str()); return; } - WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE")); + + /* Code for the configuration changes * + * Official format: config -set "section property=value" * + * Accepted: without quotes and/or without -set and/or without section * + * and/or the "=" replaced by a " " */ + + if (cmd->FindString("-set",temp_line,true)) { //get all arguments + std::string temp2 = ""; + cmd->GetStringRemain(temp2);//So -set n1 n2=n3 can be used without quotes + if(temp2!="") temp_line = temp_line + " " + temp2; + } else if(!cmd->GetStringRemain(temp_line)) {//no set + WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE")); //and no arguments specified + return; + }; + //Wanted input: n1 n2=n3 + char copy[1024]; + strcpy(copy,temp_line.c_str()); + //seperate section from property + const char* temp = strchr(copy,' '); + if((temp && *temp) || (temp=strchr(copy,'=')) ) copy[temp++ - copy]= 0; + else { + WriteOut(MSG_Get("PROGRAM_CONFIG_USAGE")); + return; + } + //if n1 n2 n3 then replace last space with = + const char* sign = strchr(temp,'='); + if(!sign) { + sign = strchr(temp,' '); + if(sign) { + copy[sign - copy] = '='; + } else { + //2 items specified (no space nor = between n2 and n3 + //assume that they posted: property value + //Try to determine the section. + Section* sec=control->GetSectionFromProperty(copy); + if(!sec){ + if(control->GetSectionFromProperty(temp)) return; //Weird situation:ignore + WriteOut(MSG_Get("PROGRAM_CONFIG_PROPERTY_ERROR"),copy); + return; + } //Hack to allow config ems true + char buffer[1024];strcpy(buffer,copy);strcat(buffer,"=");strcat(buffer,temp); + sign = strchr(buffer,' '); + if(sign) buffer[sign - buffer] = '='; + strcpy(copy,sec->GetName()); + temp = buffer; + } + } + + /* Input processed. Now the real job starts + * copy contains the likely "sectionname" + * temp contains "property=value" + * the section is destroyed and a new input line is given to + * the configuration parser. Then the section is restarted. + */ + char* inputline = const_cast(temp); + Section* sec = 0; + sec = control->GetSection(copy); + if(!sec) { WriteOut(MSG_Get("PROGRAM_CONFIG_SECTION_ERROR"),copy);return;} + sec->ExecuteDestroy(false); + sec->HandleInputline(inputline); + sec->ExecuteInit(false); + return; } @@ -234,4 +297,6 @@ void PROGRAMS_Init(Section* sec) { MSG_Add("PROGRAM_CONFIG_FILE_ERROR","Can't open file %s\n"); MSG_Add("PROGRAM_CONFIG_USAGE","Config tool:\nUse -writeconf filename to write the current config.\nUse -writelang filename to write the current language strings.\n"); + MSG_Add("PROGRAM_CONFIG_SECTION_ERROR","Section %s doesn't exist.\n"); + MSG_Add("PROGRAM_CONFIG_PROPERTY_ERROR","Property %s doesn't have a section.\n"); } diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index a4370183..897eacd5 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_cmds.cpp,v 1.53 2005-03-25 09:02:44 qbix79 Exp $ */ +/* $Id: shell_cmds.cpp,v 1.54 2005-04-21 21:17:46 qbix79 Exp $ */ #include #include @@ -60,6 +60,20 @@ static SHELL_Cmd cmd_list[]={ { "PATH", 1, &DOS_Shell::CMD_PATH, "SHELL_CMD_PATH_HELP"}, {0,0,0,0} }; +bool DOS_Shell::CheckConfig(char* cmd,char*line) { + Section* test = control->GetSectionFromProperty(cmd); + if(!test) return false; + if(line && !line[0]) { + char* val = test->GetPropValue(cmd); + if(val) WriteOut("%s\n",val); + return true; + } + char newcom[1024]; newcom[0] = 0; strcpy(newcom,"z:\\config "); + strcat(newcom,test->GetName()); strcat(newcom," "); + strcat(newcom,cmd);strcat(newcom,line); + DoCommand(newcom); + return true; +} void DOS_Shell::DoCommand(char * line) { /* First split the line into command and arguments */ @@ -96,7 +110,9 @@ void DOS_Shell::DoCommand(char * line) { cmd_index++; } /* This isn't an internal command execute it */ - Execute(cmd,line); + if(Execute(cmd,line)) return; + if(CheckConfig(cmd,line)) return; + WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),cmd); } diff --git a/src/shell/shell_misc.cpp b/src/shell/shell_misc.cpp index e2cf2a47..e87385e5 100644 --- a/src/shell/shell_misc.cpp +++ b/src/shell/shell_misc.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_misc.cpp,v 1.37 2005-04-01 10:15:26 qbix79 Exp $ */ +/* $Id: shell_misc.cpp,v 1.38 2005-04-21 21:17:46 qbix79 Exp $ */ #include #include @@ -99,6 +99,19 @@ void DOS_Shell::InputCommand(char * line) { } break; + case 0x47: /* HOME */ + while (str_index) { + outc(8); + str_index--; + } + break; + + case 0x4F: /* END */ + while (str_index < str_len) { + outc(line[str_index++]); + } + break; + case 0x48: /* UP */ if (l_history.empty() || it_history == l_history.end()) break; @@ -112,7 +125,6 @@ void DOS_Shell::InputCommand(char * line) { size = CMD_MAXLINE - str_index - 2; DOS_WriteFile(STDOUT, (Bit8u *)line, &len); it_history ++; - break; case 0x50: /* DOWN */ @@ -315,7 +327,9 @@ void DOS_Shell::InputCommand(char * line) { if (l_completion.size()) l_completion.clear(); } -void DOS_Shell::Execute(char * name,char * args) { +bool DOS_Shell::Execute(char * name,char * args) { +/* return true => don't check for hardware changes in do_command + * return false => check for hardware changes in do_command */ char * fullname; char line[CMD_MAXLINE]; if(strlen(args)!= 0){ @@ -337,15 +351,12 @@ void DOS_Shell::Execute(char * name,char * args) { if (!DOS_SetDrive(toupper(name[0])-'A')) { WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); } - return; + return true; } /* Check for a full name */ fullname=Which(name); - if (!fullname) { - WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),name); - return; - } - + if (!fullname) return false; + char* extension =strrchr(fullname,'.'); /*always disallow files without extension from being executed. */ @@ -376,8 +387,7 @@ void DOS_Shell::Execute(char * name,char * args) { else { - WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),fullname); - return; + return false; } } @@ -396,11 +406,7 @@ void DOS_Shell::Execute(char * name,char * args) { { /* only .bat .exe .com extensions maybe be executed by the shell */ if(strcasecmp(extension, ".com") !=0) { - if(strcasecmp(extension, ".exe") !=0) - { - WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),fullname); - return; - } + if(strcasecmp(extension, ".exe") !=0) return false; } /* Run the .exe or .com file from the shell */ /* Allocate some stack space for tables in physical memory */ @@ -453,6 +459,7 @@ void DOS_Shell::Execute(char * name,char * args) { SegSet16(cs,oldcs); #endif } + return true; //Executable started }