1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 11:29:01 +00:00
This commit is contained in:
david
2009-02-24 00:23:54 +00:00
parent a173fe6ce1
commit 486ff13e3a
6 changed files with 59 additions and 0 deletions

View File

@@ -116,6 +116,7 @@
#include <stdlib.h>
#include "nmap_tty.h"
#include "utils.h"
#include "NmapOps.h"
extern NmapOps o;
@@ -240,6 +241,8 @@ void tty_init()
print a status message */
bool keyWasPressed()
{
/* Where we keep the automatic stats printing schedule. */
static struct timeval stats_time = { 0 };
int c;
if (o.noninteractive)
@@ -282,5 +285,30 @@ bool keyWasPressed()
return true;
}
}
/* Check if we need to print a status update according to the --stats-every
option. */
if (o.stats_interval != 0.0) {
struct timeval now;
gettimeofday(&now, NULL);
if (stats_time.tv_sec == 0) {
/* Initialize the scheduled stats time. */
stats_time = *o.getStartTime();
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
}
if (TIMEVAL_AFTER(now, stats_time)) {
/* Advance to the next print time. */
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
/* If it's still in the past, catch it up to the present. */
if (TIMEVAL_AFTER(now, stats_time))
stats_time = now;
printStatusMessage();
/* Instruct the caller to print status too. */
return true;
}
}
return false;
}