mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Move tval2msecs() to Nbase for reuse
This commit is contained in:
parent
c123984aa5
commit
bc3b9484e6
2 changed files with 0 additions and 30 deletions
22
utils.cc
22
utils.cc
|
|
@ -449,28 +449,6 @@ void arg_parse_free(char **argv) {
|
|||
free(argv);
|
||||
}
|
||||
|
||||
/* Converts an Nmap time specification string into milliseconds. If
|
||||
the string is a plain non-negative number, it is considered to
|
||||
already be in milliseconds and is returned. If it is a number
|
||||
followed by 's' (for seconds), 'm' (minutes), or 'h' (hours), the
|
||||
number is converted to milliseconds and returned. If Nmap cannot
|
||||
parse the string, it is returned instead. */
|
||||
long tval2msecs(char *tspec) {
|
||||
long l;
|
||||
char *endptr = NULL;
|
||||
l = strtol(tspec, &endptr, 10);
|
||||
if (l < 0 || !endptr) return -1;
|
||||
if (*endptr == '\0') return l;
|
||||
if (*endptr == 's' || *endptr == 'S') return l * 1000;
|
||||
if ((*endptr == 'm' || *endptr == 'M')) {
|
||||
if (*(endptr + 1) == 's' || *(endptr + 1) == 'S')
|
||||
return l;
|
||||
return l * 60000;
|
||||
}
|
||||
if (*endptr == 'h' || *endptr == 'H') return l * 3600000;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// A simple function to form a character from 2 hex digits in ASCII form
|
||||
static unsigned char hex2char(unsigned char a, unsigned char b)
|
||||
{
|
||||
|
|
|
|||
8
utils.h
8
utils.h
|
|
@ -223,14 +223,6 @@ unsigned int gcd_n_uint(int nvals, unsigned int *val);
|
|||
int arg_parse(const char *command, char ***argv);
|
||||
void arg_parse_free(char **argv);
|
||||
|
||||
/* Converts an Nmap time specification string into milliseconds. If
|
||||
the string is a plain non-negative number, it is considered to
|
||||
already be in milliseconds and is returned. If it is a number
|
||||
followed by 's' (for seconds), 'm' (minutes), or 'h' (hours), the
|
||||
number is converted to milliseconds and returned. If Nmap cannot
|
||||
parse the string, it is returned instead. */
|
||||
long tval2msecs(char *tspec);
|
||||
|
||||
/* Convert a string in the format of a roughly C-style string literal
|
||||
(e.g. can have \r, \n, \xHH escapes, etc.) into a binary string.
|
||||
This is done in-place, and the new (shorter or the same) length is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue