Esempio n. 1
0
//Function to input and initiate initial selection of action
void Information::compSciOrLinkChoice()
{
    char number;
    cin >> number;
    cout << endl;

    switch (number) {
        case'1':{
            instructions();
            choices(number);
            break;}
        case '2':{
            instructions();
            choices(number); //scientis
            break;}
        case '3':{
            linkChoice();
            break;}
        case '4':{
            //serv.disconnect();
            displayClosing();
            exit(0);
            break;}
        default:{
            cout << "This is invalid choice!! " << endl;
            compSciOrLink();
            break;}
    }
}
Esempio n. 2
0
/**
	Procedure: commandHandler

	Purpose: Handles User Commands & Command Execution

	Parameters: None  

	Return value: None

	Calls: displayWelcome, keyboardInput, cmpP2S, handler_help, handler_version, handler_set_date, handler_get_date, handler_display_mpx, 
		handler_display_history, handler_terminate_mpx, change_prompt, handler_help_function, handler_create_pcb, handler_delete_pcb, 
		handler_block, handler_unblock, handler_suspend, handler_resume, handler_set_priority, handler_show_pcb, handler_show, displayClosing, 
		commandCleanup, sys_exit

	Globals: comDone, userCommand

	Errors: None
**/
void commandHandler(){
	int userCommandSize;
	displayWelcome();							//2.1 Display the Welcome Message

	while(comDone !=1){							//2.2 Begin While Loop for User Commands
		userCommand = NULL;
		printf("\nPlease enter the command to be executed(case sensitive).\n");
		userCommand = keyboardInput(0);      	//2.2.1 Request User Input & Accept Command from User
		printf("\n");
		//Decision Statement
		if(cmpP2S(userCommand, "help") == 1 || cmpP2S(userCommand, "/?") == 1){
			handler_help();
		} 
		else if(cmpP2S(userCommand, "version") == 1){
			handler_version();
		} 
		else if(cmpP2S(userCommand, "set_date") == 1){
			handler_set_date();
			//fix = 1;
		} 
		else if(cmpP2S(userCommand, "get_date") == 1){
			handler_get_date();
		} 
		else if(cmpP2S(userCommand, "display_mpx") == 1){
			handler_display_mpx();
		} 
		//else if(cmpP2S(userCommand, "display_history") == 1){
		//	handler_display_history();
		//}
		else if(cmpP2S(userCommand, "terminate_mpx") == 1||cmpP2S(userCommand, "exit") == 1||cmpP2S(userCommand, "quit") == 1){
			handler_terminate_mpx();
		} 
		else if(cmpP2S(userCommand, "change_prompt") == 1){
			change_prompt();
			//fix = 1;
		} 
		else if(cmpP2S(userCommand, "help_version")==1){
			handler_help_function("version");
		}
		else if(cmpP2S(userCommand, "help_set_date")==1){
			handler_help_function("set_date");
		}
		else if(cmpP2S(userCommand, "help_get_date")==1){
			handler_help_function("get_date");
		}
		else if(cmpP2S(userCommand, "help_display_mpx")==1){
			handler_help_function("display_mpx");
		}
		else if(cmpP2S(userCommand, "help_terminate_mpx")==1){
			handler_help_function("terminate_mpx");
		}
		else if(cmpP2S(userCommand, "help_change_prompt")==1){
			handler_help_function("change_prompt");
		}
		else if(cmpP2S(userCommand, "help_create_pcb")==1){
			handler_help_function("create_pcb");
		}
		else if(cmpP2S(userCommand, "create_pcb")==1){
			handler_create_pcb();
		}
		else if(cmpP2S(userCommand, "help_delete_pcb")==1){
			handler_help_function("delete_pcb");
		}
		else if(cmpP2S(userCommand, "delete_pcb")==1){
			handler_delete_pcb();
		}
		else if(cmpP2S(userCommand, "help_block")==1){
			handler_help_function("block");
		}
		else if(cmpP2S(userCommand, "block")==1){
			handler_block();
		}
		else if(cmpP2S(userCommand, "help_unblock")==1){
			handler_help_function("unblock");
		}
		else if(cmpP2S(userCommand, "unblock")==1){
			handler_unblock();
		}
		else if(cmpP2S(userCommand, "help_suspend")==1){
			handler_help_function("suspend");
		}
		else if(cmpP2S(userCommand, "suspend")==1){
			handler_suspend();
		}
		else if(cmpP2S(userCommand, "help_resume")==1){
			handler_help_function("resume");
		}
		else if(cmpP2S(userCommand, "resume")==1){
			handler_resume();
		}
		else if(cmpP2S(userCommand, "help_set_priority")==1){
			handler_help_function("set_priority");
		}
		else if(cmpP2S(userCommand, "set_priority")==1){
			handler_set_priority();
		}
		else if(cmpP2S(userCommand, "help_show_pcb")==1){
			handler_help_function("show_pcb");
		}
		else if(cmpP2S(userCommand, "show_pcb")==1){
			handler_show_pcb();
		}
		else if(cmpP2S(userCommand, "help_show_all")==1){
			handler_help_function("show_all");
		}
		else if(cmpP2S(userCommand, "show_all")==1){
			handler_show(0);
		}
		else if(cmpP2S(userCommand, "help_show_ready")==1){
			handler_help_function("show_ready");
		}
		else if(cmpP2S(userCommand, "show_ready")==1){
			handler_show(4);
			handler_show(6);
		}
		else if(cmpP2S(userCommand, "help_show_blocked")==1){
			handler_help_function("show_blocked");
		}
		else if(cmpP2S(userCommand, "show_blocked")==1){
			handler_show(5);
			handler_show(7);
		}
		else {
			printf("Invalid Command.\n");
		}//end if - Decision
		
		
	}//end while
	displayClosing();						//2.2.4 Display closing message
	commandCleanup();						//2.2.5 Cleanup Allocated Memory
	keyboardInput(0);
	
	sys_exit();								//2.2.6 Return to host system
}