Beispiel #1
0
/* internalCommandHandler
 * handles internal commands when given and passes it accordingly.
 * will return false if not an internal command
 */
static bool internalCommandHandler( struct commandType* command )
{
	// exit command
	if (strcmp((*command).args[0], "exit" ) == 0) {
		exitCommand(command);
		return true;
	}

	// history command
	if (strcmp((*command).args[0], "history" ) == 0) {
		historyCommand(command);
		return true;
	}

	// not an internal command
	return false;
}
Beispiel #2
0
void getInput(){
	/*char input[1000];*/
	
	
	while(1){
		printf(pointer);
		if(fgets(input, MAX, stdin) == NULL){
			exit(0);
		}
		int t = strncmp(input, "!", 1);
		int k = strncmp(input, "!-", 2);
		if( t != 0){
		saveHistory();
		saveHistoryFile();
		}
		if(t == 0){/*
			if(input[3] == '\0' || input[2] == '\0' || input[4] == '\0'){
				if((isdigit(input[1]) && input[2] == '\0') || (isdigit(input[1]) && isdigit(input[2])	)){
			printf("hehEHE111");
			historyCommand();
				}
			}*/



			if(input[3] == '\0'){
				
				if(isdigit(input[1])){
					
					historyCommand();
				}
				else{
					printf("%s : event not found here 1",input);
				}
			}

			else if(input[4] == '\0' && k !=0){
				if(isdigit(input[1]) && isdigit(input[2])){
					
					historyCommand();
				}
				else{
					printf("%s : event not found here 2",input);
				}
			}


			else if(k==0){
				if(input[4]=='\0' && isdigit(input[2])){
					historyCommand();
				}
				else if((input[5]=='\0') && isdigit(input[2]) && isdigit(input[3])){
					historyCommand();
				}
				else{
				printf("%s : event not found here 3",input);
			}

			}
			
			

			else{
				printf("%s : event not found",input);
			}
		}




		
		else tokenise();
	
		}
}