Support configuration changes from the shell.
syntax: property => lists the current value of the property property=value => Sets property to value examples: ems=true cycles=5000 core=full Added "wc" as alias for writeconf and "wl" for writelang(Requested by DosFreak) Added support for home/end on the shell(parapente) Config supports the setting of configuration as well: config -set "section property=value" This one should be used for properties that exist in more than one section. Samplerate for example. Changed the main shellinput loop. So it checks for a property if the entered command isn't an internal command or an executable. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2190
This commit is contained in:
parent
50f9e11282
commit
2a0f3a1f3d
5 changed files with 138 additions and 49 deletions
|
@ -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 <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue