Beispiel #1
0
static void processCommand(char* command) {
	int argc;
	char** argv = tokenize(command, &argc);

	if(strcmp(argv[0], "sendfile") == 0) {
		if(argc >= 2) {
			// enter file mode
			EnterCriticalSection();
			if(dataRecvBuffer == commandRecvBuffer) {
				dataRecvBuffer = (uint8_t*) parseNumber(argv[1]);
			}
			LeaveCriticalSection();
			free(argv);
			return;
		}
	}

	if(strcmp(argv[0], "getfile") == 0) {
		if(argc >= 3) {
			// enter file mode
			EnterCriticalSection();
			if(sendFileBytesLeft == 0) {
				sendFilePtr = (uint8_t*) parseNumber(argv[1]);
				sendFileBytesLeft = parseNumber(argv[2]);
			}
			LeaveCriticalSection();
			free(argv);
			return;
		}
	}

	OPIBCommand* curCommand = CommandList;

	int success = FALSE;
	while(curCommand->name != NULL) {
		if(strcmp(argv[0], curCommand->name) == 0) {
			curCommand->routine(argc, argv);
			success = TRUE;
			break;
		}
		curCommand++;
	}

	if(!success) {
		bufferPrintf("unknown command: %s\r\n", command);
	}

	free(argv);
}
Beispiel #2
0
int command_run(int argc, char **argv)
{
	OIBCommandIterator cmdIt = NULL;
	OPIBCommand *cmd;

	if(*argv[0] == 0)
		return 0; // Hack to prevent empty lines erroring out.

	while((cmd = command_get_next(&cmdIt)))
	{
		if(strcmp(argv[0], cmd->name) == 0) {
			cmd->routine(argc, argv);
			return 0;
		}
	}

	return -1;
}
Beispiel #3
0
int scriptCommand(char* command){
    int argc;
	char** argv = tokenize(command, &argc);

	OPIBCommand* curCommand = CommandList;

	int success = FALSE;
	while(curCommand->name != NULL) {
		if(strcmp(argv[0], curCommand->name) == 0) {
			curCommand->routine(argc, argv);
			success = TRUE;
			break;
		}
		curCommand++;
	}

	if(!success) {
		bufferPrintf("unknown command: %s\r\n", command);
	}

	free(argv);
	return success;
}
Beispiel #4
0
uint32_t scriptCommand(char* command){
    int argc;
	char** argv = tokenize(command, &argc);

	OPIBCommand* curCommand = CommandList;

	int success = FALSE;
	while(curCommand->name != NULL) {
		if(strcmp(argv[0], curCommand->name) == 0) {
			curCommand->routine(argc, argv);
			success = TRUE;
			break;
		}
		curCommand++;
	}

	if(!success) {
		bufferPrintf("unknown command: %s\r\n", command);
	}

	free(argv);
	//bufferPrintf("going back to scriptCommand()\r\n"); /*at this point, the command has been executed */
	return success;
}