Exemplo n.º 1
0
void DOS_Shell::Run(void) {
	char input_line[CMD_MAXLINE] = {0};
	std::string line;
	if (cmd->FindStringRemainBegin("/C",line)) {
		strcpy(input_line,line.c_str());
		char* sep = strpbrk(input_line,"\r\n"); //GTA installer
		if (sep) *sep = 0;
		DOS_Shell temp;
		temp.echo = echo;
		temp.ParseLine(input_line);		//for *.exe *.com  |*.bat creates the bf needed by runinternal;
		temp.RunInternal();				// exits when no bf is found.
		return;
	}
	/* Start a normal shell and check for a first command init */
	WriteOut(MSG_Get("SHELL_STARTUP_BEGIN"),VERSION);
#if C_DEBUG
	WriteOut(MSG_Get("SHELL_STARTUP_DEBUG"));
#endif
	if (machine == MCH_CGA) WriteOut(MSG_Get("SHELL_STARTUP_CGA"));
	if (machine == MCH_HERC) WriteOut(MSG_Get("SHELL_STARTUP_HERC"));
	WriteOut(MSG_Get("SHELL_STARTUP_END"));

	if (cmd->FindString("/INIT",line,true)) {
		strcpy(input_line,line.c_str());
		line.erase();
		ParseLine(input_line);
	}
	do {
		if (bf){
			if(bf->ReadLine(input_line)) {
				if (echo) {
					if (input_line[0]!='@') {
						ShowPrompt();
						WriteOut_NoParsing(input_line);
						WriteOut_NoParsing("\n");
					};
				};
				ParseLine(input_line);
				if (echo) WriteOut("\n");
			}
		} else {
			//locnet, exit shell loop without exception
			if (loadf->abort == 2) {
				loadf->abort = 3;
				exit = true;
				break;
			}
			if (echo) ShowPrompt();
			InputCommand(input_line);
			ParseLine(input_line);
			if (echo && !bf) WriteOut_NoParsing("\n");
		}
	} while (!exit);
}
Exemplo n.º 2
0
void DOS_Shell::Run(void) {
	char input_line[CMD_MAXLINE] = {0};
	std::string line;
	if (cmd->FindStringRemain("/C",line)) {
		strcpy(input_line,line.c_str());
		char* sep = strpbrk(input_line,"\r\n"); //GTA installer
		if (sep) *sep = 0;
		DOS_Shell temp;
		temp.echo = echo;
		temp.ParseLine(input_line);		//for *.exe *.com  |*.bat creates the bf needed by runinternal;
		temp.RunInternal();				// exits when no bf is found.
		return;
	}
	/* Start a normal shell and check for a first command init */
	WriteOut(MSG_Get("SHELL_STARTUP_BEGIN"),VERSION);
#if C_DEBUG
	WriteOut(MSG_Get("SHELL_STARTUP_DEBUG"));
#endif
	if (machine == MCH_CGA) WriteOut(MSG_Get("SHELL_STARTUP_CGA"));
	if (machine == MCH_HERC) WriteOut(MSG_Get("SHELL_STARTUP_HERC"));
	WriteOut(MSG_Get("SHELL_STARTUP_END"));

#ifdef IPHONEOS                        
    if (automount_path[0]) {
        char *p = (char*)automount_path;
        char *endp = p;
        char disk = 'c';
        LOG_MSG("DOS_Shell::Run Auto Mount");
        
        while (endp) {
            for (p = endp; *endp && *endp != ';'; endp++)
                ;
            if (*endp == ';') {
                *endp = 0; 
                endp++;
            } else {
                endp=0;
            }
            if (strlen(p) <= 0) break;
            sprintf(input_line, "mount %c \"%s\"",disk, p);
            ParseLine(input_line);
            disk++;
        }
        if (disk > 'c') {
            sprintf(input_line, "c:");
            ParseLine(input_line);
        }
    }
#endif       
    
	if (cmd->FindString("/INIT",line,true)) {
		strcpy(input_line,line.c_str());
		line.erase();
		ParseLine(input_line);
	}
	do {
		if (bf){
			if(bf->ReadLine(input_line)) {
				if (echo) {
					if (input_line[0]!='@') {
						ShowPrompt();
						WriteOut_NoParsing(input_line);
						WriteOut_NoParsing("\n");
					};
				};
				ParseLine(input_line);
				if (echo) WriteOut("\n");
			}
#ifdef IPHONEOS                        
        } else if (automount_path[0]) {
            automount_path[0] = 0;
            if (echo && !bf) WriteOut_NoParsing("\n");
            sprintf(input_line, "cls");
            ParseLine(input_line);
#endif                    
		} else {
			if (echo) ShowPrompt();
#ifdef IPHONEOS
            dospad_command_line_ready=1;
#endif
			InputCommand(input_line);
#ifdef IPHONEOS
            dospad_add_history(input_line);
            dospad_command_line_ready=0;
            if (dospad_should_launch_game)
            {
                // Make sure we can access the new installed files
                Bit8u drive = DOS_GetDefaultDrive();
                if (Drives[drive]) {
                    Drives[drive]->EmptyCache();
                }                
                FILE *fp=fopen(dospad_launch_config, "r");
                if (fp != NULL)
                {
                    char buf[256];
                    int sectionLength = strlen(dospad_launch_section);
                    while (fgets(buf, 256, fp))
                    {
                        if (strncmp(buf, dospad_launch_section, sectionLength) == 0)
                        {
                            while (fgets(buf, 256, fp))
                            {
                                if (buf[0] == '[') break;
                                if (buf[0] == '#') continue;
                                ParseLine(buf);
                            }
                        }
                    }
                    fclose(fp);
                }
                dospad_should_launch_game = 0;
                sprintf(input_line,"cls");
                dospad_launch_done();
            }
#endif
			ParseLine(input_line);
			if (echo && !bf) WriteOut_NoParsing("\n");
		}
	} while (!exit);
}
Exemplo n.º 3
0
void DOS_Shell::Run(void) {
	char input_line[CMD_MAXLINE] = {0};
	std::string line;
	if (cmd->FindStringRemain("/C",line)) {
		strcpy(input_line,line.c_str());
		char* sep = strpbrk(input_line,"\r\n"); //GTA installer
		if (sep) *sep = 0;
		DOS_Shell temp;
		temp.echo = echo;
		temp.ParseLine(input_line);		//for *.exe *.com  |*.bat creates the bf needed by runinternal;
		temp.RunInternal();				// exits when no bf is found.
		return;
	}
	/* Start a normal shell and check for a first command init */
    //--Modified 2012-08-19 by Alun Bestor to allow selective overriding of the startup messages.
    if (boxer_shouldDisplayStartupMessages())
    {
        WriteOut(MSG_Get("SHELL_STARTUP_BEGIN"),VERSION);
    #if C_DEBUG
        WriteOut(MSG_Get("SHELL_STARTUP_DEBUG"));
    #endif
        if (machine == MCH_CGA) WriteOut(MSG_Get("SHELL_STARTUP_CGA"));
        if (machine == MCH_HERC) WriteOut(MSG_Get("SHELL_STARTUP_HERC"));
        WriteOut(MSG_Get("SHELL_STARTUP_END"));
    }
    //--End of modifications
    
	if (cmd->FindString("/INIT",line,true)) {
		//--Added 2009-12-13 by Alun Bestor to let Boxer monitor the autoexec process
		boxer_autoexecDidStart();
		
		strcpy(input_line,line.c_str());
		line.erase();
		ParseLine(input_line);
		
		boxer_autoexecDidFinish();
		//--End of modifications
	}
	do {
        //--Added 2012-08-19 by Alun Bestor to let Boxer insert its own commands into batch processing.
        if (boxer_hasPendingCommands())
        {
            boxer_executeNextPendingCommand();
        }
		else if (bf){
        //--End of modifications
            if(bf->ReadLine(input_line)) {
				if (echo) {
					if (input_line[0]!='@') {
						ShowPrompt();
						WriteOut_NoParsing(input_line);
						WriteOut_NoParsing("\n");
					};
				};
				ParseLine(input_line);
				if (echo) WriteOut("\n");
			}
		} else {
            //--Added 2009-11-29 by Alun Bestor as a hook for detecting when control has returned to the DOS prompt. 
            boxer_didReturnToShell();
            //--End of modifications
            
			if (echo) ShowPrompt();
			InputCommand(input_line);
            
            //--Added 2012-08-19 by Alun Bestor to let Boxer interrupt the command input with its own commands.
            if (boxer_shellShouldContinue() && !boxer_hasPendingCommands())
            {
                //--End of modifications
                ParseLine(input_line);
                if (echo && !bf) WriteOut_NoParsing("\n");
            }
		}
	} while (boxer_shellShouldContinue() && !exit);
}