Nmap Development mailing list archives
[PATCH] Move strerror() from nmap to nbase
From: Kris Katterjohn <katterjohn () gmail com>
Date: Thu, 04 Jan 2007 19:40:18 -0600
The attached patch takes the strerror() from utils.cc and moves it to nbase/nbase_misc.c. strerror() is also used in nsock and nmapfe, so if strerror() isn't there, in my mind, it should be put in nbase because they're both linked with it. I don't exactly have a great way to really test it because strerror() is on most systems (including all the ones I have access to), but it should work. The configure script in nbase checks for strerror(), so I don't think that's a problem. It's a diff against 4.21ALPHA1 Thanks, Kris Katterjohn P.S. Fyodor, did you get my reply about /nmap-exp on SVN? I know it's only been 4 or 5 days since we talked but I've been moving around lately and using different computers, on different networks, in different states even, so it's a distinct possibility it got lost somewhere. Or maybe you're just being "slow" again :)
--- x/nbase/nbase.h 2006-12-10 17:46:24.000000000 -0600 +++ y/nbase/nbase.h 2007-01-04 19:22:14.000000000 -0600 @@ -338,6 +338,10 @@ extern "C" { or EINTR. */ int socket_errno(); +#ifndef HAVE_STRERROR +char *strerror(int errnum); +#endif + /* The usleep() function is important as well */ #ifndef HAVE_USLEEP #if defined( HAVE_NANOSLEEP) || defined(WIN32) --- x/nbase/nbase_misc.c 2006-12-10 17:46:24.000000000 -0600 +++ y/nbase/nbase_misc.c 2007-01-04 19:21:37.000000000 -0600 @@ -130,6 +130,14 @@ int socket_errno() { #endif } +#ifndef HAVE_STRERROR +char *strerror(int errnum) { + static char buf[1024]; + sprintf(buf, "your system is too old for strerror of errno %d\n", errnum); + return buf; +} +#endif + /* This function is an easier version of inet_ntop because you don't need to pass a dest buffer. Instead, it returns a static buffer that you can use until the function is called again (by the same or another --- x/utils.cc 2006-11-19 21:49:09.000000000 -0600 +++ y/utils.cc 2007-01-04 19:21:18.000000000 -0600 @@ -187,14 +187,6 @@ void lamont_hdump(char *cp, unsigned int printf("\n"); } -#ifndef HAVE_STRERROR -char *strerror(int errnum) { - static char buf[1024]; - sprintf(buf, "your system is too old for strerror of errno %d\n", errnum); - return buf; -} -#endif - /* Like the perl equivalent -- It removes the terminating newline from string IF one exists. It then returns the POSSIBLY MODIFIED string */ char *chomp(char *string) { --- x/utils.h 2006-09-15 21:25:30.000000000 -0500 +++ y/utils.h 2007-01-04 19:22:01.000000000 -0600 @@ -247,10 +247,6 @@ void bintohexstr(char *buf, int buflen, char* print_ip_options(u8* ipopt, int ipoptlen); -#ifndef HAVE_STRERROR -char *strerror(int errnum); -#endif - /* Convert a comma-separated list of ASCII u16-sized numbers into the given 'dest' array, which is of total size (meaning sizeof() as opposed to numelements) of destsize. If min_elem and max_elem are
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [PATCH] Move strerror() from nmap to nbase Kris Katterjohn (Jan 04)