From bc3b9484e6479ff1a591b966a5e79b3c109dc559 Mon Sep 17 00:00:00 2001 From: kris Date: Tue, 15 Jul 2008 20:06:05 +0000 Subject: [PATCH] Move tval2msecs() to Nbase for reuse --- utils.cc | 22 ---------------------- utils.h | 8 -------- 2 files changed, 30 deletions(-) diff --git a/utils.cc b/utils.cc index 93ce6a33d..1f47c3df1 100644 --- a/utils.cc +++ b/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) { diff --git a/utils.h b/utils.h index ab81783b1..da83ce656 100644 --- a/utils.h +++ b/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