extern "C" void SystemNative_GetControlCharacters( int32_t* controlCharacterNames, uint8_t* controlCharacterValues, int32_t controlCharacterLength) { assert(controlCharacterNames != nullptr); assert(controlCharacterValues != nullptr); assert(controlCharacterLength >= 0); memset(controlCharacterValues, 0, sizeof(uint8_t) * UnsignedCast(controlCharacterLength)); #if HAVE_TCGETATTR struct termios newtermios = {}; if (tcgetattr(STDIN_FILENO, &newtermios) >= 0) { for (int i = 0; i < controlCharacterLength; i++) { int name = TranslatePalControlCharacterName(controlCharacterNames[i]); if (name >= 0) { controlCharacterValues[i] = newtermios.c_cc[name]; } } } #endif }
void SystemNative_GetControlCharacters( int32_t* controlCharacterNames, uint8_t* controlCharacterValues, int32_t controlCharacterLength, uint8_t* posixDisableValue) { assert(controlCharacterNames != NULL); assert(controlCharacterValues != NULL); assert(controlCharacterLength >= 0); assert(posixDisableValue != NULL); #ifdef _POSIX_VDISABLE *posixDisableValue = _POSIX_VDISABLE; #else *posixDisableValue = 0; #endif memset(controlCharacterValues, *posixDisableValue, sizeof(uint8_t) * Int32ToSizeT(controlCharacterLength)); if (controlCharacterLength > 0) { struct termios newTermios; memset(&newTermios, 0, sizeof(struct termios)); if (tcgetattr(STDIN_FILENO, &newTermios) >= 0) { for (int i = 0; i < controlCharacterLength; i++) { int name = TranslatePalControlCharacterName(controlCharacterNames[i]); if (name >= 0) { controlCharacterValues[i] = newTermios.c_cc[name]; } } } } }