static bool_t handleConsoleLineInternal(char *line, int lineLength) { int firstTokenLength = tokenLength(line); // print("processing [%s] with %d actions\r\n", line, consoleActionCount); if (firstTokenLength == lineLength) { // no-param actions are processed here for (int i = 0; i < consoleActionCount; i++) { TokenCallback *current = &consoleActions[i]; if (strEqual(line, current->token)) { // invoke callback function by reference (*current->callback)(); return TRUE; } } } else { char *ptr = line + firstTokenLength; ptr[0] = 0; // change space into line end ptr++; // start from next symbol for (int i = 0; i < consoleActionCount; i++) { TokenCallback *current = &consoleActions[i]; if (strEqual(line, current->token)) { handleActionWithParameter(current, ptr); return TRUE; } } } return FALSE; }
static bool handleConsoleLineInternal(const char *commandLine, int lineLength) { strncpy(handleBuffer, commandLine, sizeof(handleBuffer) - 1); handleBuffer[sizeof(handleBuffer) - 1] = 0; // we want this to be null-terminated for sure char *line = handleBuffer; int firstTokenLength = tokenLength(line); // print("processing [%s] with %d actions\r\n", line, consoleActionCount); if (firstTokenLength == lineLength) { // no-param actions are processed here for (int i = 0; i < consoleActionCount; i++) { TokenCallback *current = &consoleActions[i]; if (strEqual(line, current->token)) { if (current->parameterType == NO_PARAMETER) { (*current->callback)(); } else if (current->parameterType == NO_PARAMETER_P) { VoidPtr cb = (VoidPtr) current->callback; (*cb)(current->param); } return true; } } } else { char *ptr = line + firstTokenLength; ptr[0] = 0; // change space into line end ptr++; // start from next symbol for (int i = 0; i < consoleActionCount; i++) { TokenCallback *current = &consoleActions[i]; if (strEqual(line, current->token)) { handleActionWithParameter(current, ptr); return true; } } } return false; }