mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +00:00
Use RAII for terminal settings
This commit is contained in:
parent
e997ad74ae
commit
4f4ad965d1
3 changed files with 12 additions and 2 deletions
3
nmap.cc
3
nmap.cc
|
|
@ -1899,8 +1899,7 @@ int nmap_main(int argc, char *argv[]) {
|
|||
else
|
||||
nbase_set_log(fatal, NULL);
|
||||
|
||||
|
||||
tty_init(); // Put the keyboard in raw mode
|
||||
TTYState ttystate; // Put the keyboard in raw mode
|
||||
|
||||
#ifdef WIN32
|
||||
// Must come after parse_options because of --unprivileged
|
||||
|
|
|
|||
|
|
@ -246,6 +246,10 @@ void tty_init()
|
|||
|
||||
#endif //!win32
|
||||
|
||||
TTYState::~TTYState() {
|
||||
tty_done();
|
||||
}
|
||||
|
||||
/* Catches all of the predefined
|
||||
keypresses and interpret them, and it will also tell you if you
|
||||
should print anything. A value of true being returned means a
|
||||
|
|
|
|||
|
|
@ -74,4 +74,11 @@ void tty_init();
|
|||
calling method should print a status message */
|
||||
bool keyWasPressed();
|
||||
|
||||
/* RAII object for TTY management */
|
||||
class TTYState {
|
||||
public:
|
||||
TTYState() { tty_init(); }
|
||||
~TTYState(); // calls tty_done()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue