|
@@ -33,44 +33,24 @@ static vt100_decode_t cmds[] = {
|
|
{"[6~", tinyrl_vt100_PGDOWN},
|
|
{"[6~", tinyrl_vt100_PGDOWN},
|
|
};
|
|
};
|
|
|
|
|
|
-/*--------------------------------------------------------- */
|
|
|
|
-static void _tinyrl_vt100_setInputNonBlocking(const tinyrl_vt100_t * this)
|
|
|
|
-{
|
|
|
|
-#if defined(STDIN_FILENO)
|
|
|
|
- int flags = (fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
|
|
|
|
- fcntl(STDIN_FILENO, F_SETFL, flags);
|
|
|
|
-#endif /* STDIN_FILENO */
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/*--------------------------------------------------------- */
|
|
|
|
-static void _tinyrl_vt100_setInputBlocking(const tinyrl_vt100_t * this)
|
|
|
|
-{
|
|
|
|
-#if defined(STDIN_FILENO)
|
|
|
|
- int flags = (fcntl(STDIN_FILENO, F_GETFL, 0) & ~O_NONBLOCK);
|
|
|
|
- fcntl(STDIN_FILENO, F_SETFL, flags);
|
|
|
|
-#endif /* STDIN_FILENO */
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*--------------------------------------------------------- */
|
|
/*--------------------------------------------------------- */
|
|
tinyrl_vt100_escape_t tinyrl_vt100_escape_decode(const tinyrl_vt100_t * this)
|
|
tinyrl_vt100_escape_t tinyrl_vt100_escape_decode(const tinyrl_vt100_t * this)
|
|
{
|
|
{
|
|
tinyrl_vt100_escape_t result = tinyrl_vt100_UNKNOWN;
|
|
tinyrl_vt100_escape_t result = tinyrl_vt100_UNKNOWN;
|
|
char sequence[10], *p = sequence;
|
|
char sequence[10], *p = sequence;
|
|
int c;
|
|
int c;
|
|
- unsigned i;
|
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
|
if (!this->istream)
|
|
if (!this->istream)
|
|
return tinyrl_vt100_UNKNOWN;
|
|
return tinyrl_vt100_UNKNOWN;
|
|
|
|
|
|
- /* before the while loop, set the input as non-blocking */
|
|
|
|
- _tinyrl_vt100_setInputNonBlocking(this);
|
|
|
|
-
|
|
|
|
/* dump the control sequence into our sequence buffer
|
|
/* dump the control sequence into our sequence buffer
|
|
* ANSI standard control sequences will end
|
|
* ANSI standard control sequences will end
|
|
* with a character between 64 - 126
|
|
* with a character between 64 - 126
|
|
*/
|
|
*/
|
|
while (1) {
|
|
while (1) {
|
|
- c = fgetc(this->istream);
|
|
|
|
|
|
+ c = tinyrl_vt100_getchar(this);
|
|
|
|
+ if (c < 0) { /* Some error or timeout */
|
|
|
|
|
|
/* ignore no-character condition */
|
|
/* ignore no-character condition */
|
|
if (-1 != c) {
|
|
if (-1 != c) {
|
|
@@ -88,9 +68,6 @@ tinyrl_vt100_escape_t tinyrl_vt100_escape_decode(const tinyrl_vt100_t * this)
|
|
/* terminate the string */
|
|
/* terminate the string */
|
|
*p = '\0';
|
|
*p = '\0';
|
|
|
|
|
|
- /* restore the blocking status */
|
|
|
|
- _tinyrl_vt100_setInputBlocking(this);
|
|
|
|
-
|
|
|
|
if (tinyrl_vt100_UNKNOWN != result) {
|
|
if (tinyrl_vt100_UNKNOWN != result) {
|
|
p = sequence;
|
|
p = sequence;
|
|
result = tinyrl_vt100_UNKNOWN;
|
|
result = tinyrl_vt100_UNKNOWN;
|