mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-07-06 04:51:40 -07:00
Added support for interuptable windows sleep
This commit is contained in:
parent
554d66c768
commit
00e6cc3a6c
2 changed files with 27 additions and 5 deletions
20
hydra-time.c
20
hydra-time.c
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "hydra.h"
|
#include "hydra.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <time.h>
|
||||||
int sleepn(time_t seconds)
|
int sleepn(time_t seconds)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
@ -10,10 +9,23 @@ int sleepn(time_t seconds)
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
return nanosleep(&ts, NULL);
|
return nanosleep(&ts, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usleepn(long int milisec) {
|
int usleepn(long int milisec) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
ts.tv_sec = milisec / 1000;
|
ts.tv_sec = milisec / 1000;
|
||||||
ts.tv_nsec = (milisec % 1000) * 1000000L;
|
ts.tv_nsec = (milisec % 1000) * 1000000L;
|
||||||
return nanosleep(&ts, NULL);
|
return nanosleep(&ts, NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
int sleepn(unsigned int seconds)
|
||||||
|
{
|
||||||
|
return SleepEx(milisec*1000,TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int usleepn(unsigned int milisec)
|
||||||
|
{
|
||||||
|
return SleepEx(milisec,TRUE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
12
hydra.h
12
hydra.h
|
@ -132,9 +132,19 @@
|
||||||
#define INET_ADDRSTRLEN 16
|
#define INET_ADDRSTRLEN 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int sleepn(time_t seconds);
|
#ifndef _WIN32
|
||||||
|
|
||||||
|
int sleepn(time_t seconds);
|
||||||
int usleepn(long int useconds);
|
int usleepn(long int useconds);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
int sleepn(unsigned int seconds);
|
||||||
|
int usleepn(unsigned int useconds);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _HYDRA_H
|
#define _HYDRA_H
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue