Пример #1
0
//handles all user input
userInput(){
	//Clear input fields
	command = NULL;
	memset(&input,'\0',sizeof(input));
	memset(&first,'\0',sizeof(first));
	memset(&second,'\0',sizeof(second));
	memset(&third,'\0',sizeof(third));

	//Take input from user
	printf("nsh3_WesJos$ ");
	fgets(input,80,stdin);


	commentfilter(input);//removes the text after a comment but not inside a complex string from a command.

	//Split the input the user provides
	splitInput(input);



	//Make sure command or alias exists
	if ((nshFind(alias,first) == NULL) && (nshFind(native,first) == NULL))
	{
		printf("\tCommand not found.\n");
		userInput();
	}
	else
	{
		//Checks if alias or native command passed fail test
		if (nshFind(alias,first) == NULL)
			command = nshFind(native,first);
		else
		{
			command = nshFind(alias,first);
			handleAlias(command->value);
		}
		//Check command
		if ((strcmp(command->value,"set")==0) || (strcmp(first,"set") == 0))
			commandSet(&var,second,third);
		if ((strcmp(command->value,"alias")==0) || (strcmp(first,"alias") == 0))
			commandSet(&alias,second,third);
		if ((strcmp(command->value,"tes") == 0) || (strcmp(first,"tes") == 0))
			nshDelete(&var,second);
		if ((strcmp(command->value,"saila") == 0) || (strcmp(first,"saila") == 0))
			nshDelete(&alias,second);
		if ((strcmp(command->value,"exit") == 0) || (strcmp(first,"exit") == 0))
			cont = 0;
	}

}
Пример #2
0
void FileProcessor::readNextCommand() {
  if (file_ == NULL) { return; }
  if (file_->atEnd()) {
    stopSequence();
    return;
  }

  QString line = file_->readLine();

  QStringList tokens = line.split(QRegExp("[\\s,]"), QString::SkipEmptyParts);
  qDebug() << "Command: " << tokens;

  if (tokens.at(0) == "BASE" && tokens.length() == 2) {
    commandBase(tokens);
  } else if (tokens.at(0) == "VOLUME" && tokens.length() == 2) {
    commandVolume(tokens);
  } else if (tokens.at(0) == "SET" && tokens.length() == 2) {
    commandSet(tokens);
  } else if (tokens.at(0) == "HARMONICS" && tokens.length() == 2) {
    commandHarmonics(tokens);
  } else if (tokens.at(0) == "HOLD" && tokens.length() == 2) {
    commandHold(tokens);
  } else if (tokens.at(0) == "PAUSE" && tokens.length() == 1) {
    commandPause(tokens);
  } else if (tokens.at(0) == "END" && tokens.length() == 1) {
    commandEnd(tokens);
  } else if (tokens.at(0) == "EXIT" && tokens.length() == 1) {
    commandExit(tokens);
  } else if (tokens.at(0) == "FADE" && tokens.length() == 3) {
    commandFade(tokens);
  } else if (tokens.at(0) == "SLIDE" && tokens.length() == 3) {
    commandSlide(tokens);
  } else {
    qDebug() << "Invalid command: " << tokens;
    stopSequence();
  }
}