Exemplo n.º 1
0
void GCode::pushCommand()
{
    bufferWriteIndex = (bufferWriteIndex+1) % GCODE_BUFFER_SIZE;
    bufferLength++;
#ifndef ECHO_ON_EXECUTE
    echoCommand();
#endif
}
Exemplo n.º 2
0
/** \brief Removes the last returned command from cache. */
void GCode::popCurrentCommand()
{
    if(!bufferLength) return; // Should not happen, but safety first
#ifdef ECHO_ON_EXECUTE
    echoCommand();
#endif
    if(++bufferReadIndex == GCODE_BUFFER_SIZE) bufferReadIndex = 0;
    bufferLength--;
}
Exemplo n.º 3
0
void EchoIpcServer::completeCode(const CompleteCodeCommand &command)
{
    echoCommand(QVariant::fromValue(command));
}
Exemplo n.º 4
0
void EchoIpcServer::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command)
{
    echoCommand(QVariant::fromValue(command));
}
Exemplo n.º 5
0
void EchoIpcServer::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command)
{
    echoCommand(QVariant::fromValue(command));
}
Exemplo n.º 6
0
/**
 * Start the Mish and runs it in a loop until CTRL + D is pressed and the
 * shell will exit. Collect the commands from the shells input and parses
 * them into a list of commands. The list is iterated through and the
 * commands are started with pipes and file redirections set between them.
 */
int main(void) {

	char input[MAXLINELEN];
	char *internCommand;
	command comLine[MAXCOMMANDS];
	command tempCom;
	int commandCount = 0;
	int i;
	int status;
	int fdRead[2];
	int fdWrite[2];

	if (signal(SIGINT, sig_handler) == SIG_ERR)
		fprintf(stderr, "\ncan't catch SIGINT\n");

	do {
		i = 0;
		stopped =false;

		fprintf(stderr, "\e[1;34m\nmish%% \e[0m");
		fflush(stderr);
		if (fgets(input, MAXLINELEN, stdin) == NULL) {
			running = 0;
		}
		commandCount = parse(input, comLine);

		if (commandCount > 0 && running == 1) {

			internCommand = intCommands(comLine);

			if (internCommand != NULL) {
				tempCom = comLine[i];

				if (strcmp(internCommand, "cd") == 0) {
					cdCommand(&tempCom);
				} else if (strcmp(internCommand, "echo") == 0) {
					echoCommand(&tempCom);
				}

			} else {
				pipe(fdWrite);

				if(commandCount > 1 && !stopped) {

					// 	first fork in a chain of 2 or more pipe to stdout
					//	from process
					makeFork(comLine[i], fdWrite, NULL);
					wait(&status);

					fdRead[0] = fdWrite[0];
					fdRead[1] = fdWrite[1];

					// Pipe stdin and stdout between processes
					for(i = 1 ; i < commandCount -1 ; i++) {

						if (!stopped) {
							pipe(fdWrite);

							makeFork(comLine[i], fdWrite, fdRead);
							close(fdRead[0]);
							close(fdRead[1]);
							wait(&status);

							fdRead[0] = fdWrite[0];
							fdRead[1] = fdWrite[1];
						}
					}

					// Fork and pipe to stdin of the last process
					if (!stopped) {
						makeFork(comLine[i], NULL, fdRead);
						close(fdRead[0]);
						close(fdRead[1]);
						wait(&status);
					}

				} else {
					// Run single command
					makeFork(comLine[i], NULL, NULL);
					wait(&status);
				}
			}
		}

	} while(running == 1);

	return 0;
}