AAIO Advanced I/O Library v0.3.0 Reference


Functions

int getch (void)
int getche (void)
int kbhit (void)
int aaio_hard_reset (void)
int aaio_reset (void)
int aaio_grant_tty_lock (void)
int aaio_flush (void)

Detailed Description

AAIO Advanced I/O

Many people moving from Windows programming to UNIX program have problems with the missing non-blocking getch() and getche() functions provided by conio.h. This library provides the functionality of getch(), getche() and kbhit(). It does not require an initialization (like curses) and does not abuse the terminal (i.e. whenever the mode of the terminal is changed its state is stored so it can be restored). For increased efficiency there exists funcionality to allow abuse of the terminal as well as functions to restore or reset the terminal when the application exits.

Author:
Daniel Aarno
Version:
0.3.0

Function Documentation

int aaio_flush void   ) 
 

Flush any remaining characters from the stdandard input

int aaio_grant_tty_lock void   ) 
 

Allow the aaio functions (getch, getche and kbhit) to "abuse" the terminal (i.e. change the terminal settings without resetting them. This gives a boost to performance that can be usefull in some cases. Most often, however, it is not necessary or recomended to grant the tty lock to aaio.

If the lock has been granted aaio_reset must be called before program exit to reset the terminal to its original state.

Returns:
-1 on error, 0 on success.
Note:
The aaio library does not really get a lock on the tty, others may change the tty settings, however this will corrupt the aaio library and can cause undefined results.
See also:
aaio_reset

int aaio_hard_reset void   ) 
 

Perform a hard reset of the terminal to cause it to go back to its original state.

Returns:
-1 on error, 0 on success.
See also:
reset(1)

aaio_reset

int aaio_reset void   ) 
 

Reset the terminal to the state it was in when aaio_grant_tty_lock was called.

Returns:
-1 on error, 0 on success.
See also:
aaio_hard_reset

aaio_grant_tty_lock

int getch void   ) 
 

Get a character from stdin. Block until a character is available but does not wait for a new line. Characters are not echoed on to screen.

Returns:
The first character available cast to an int or -1 on error.
See also:
getche

int getche void   ) 
 

Get a character from stdin. Block until a character is available but does not wait for a new line. Characters are echoed on to screen.

Returns:
The first character available cast to an int or -1 on error.
See also:
getch

int kbhit void   ) 
 

Get the number of characters available on stdin.

Returns:
The number of characters that can be read from stdin without blocking, -1 on error.
See also:
getch

getche