1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-10 09:49:05 +00:00

Reduce use of utils.h for error functions

This commit is contained in:
dmiller
2017-04-20 22:39:08 +00:00
parent 0ff217dc53
commit e813de759a
18 changed files with 33 additions and 23 deletions

View File

@@ -140,7 +140,6 @@
#include <dnet.h> #include <dnet.h>
#include "nbase.h" #include "nbase.h"
#include "NmapOps.h" #include "NmapOps.h"
#include "utils.h"
#include "nmap.h" #include "nmap.h"
#include "nmap_error.h" #include "nmap_error.h"

View File

@@ -135,6 +135,7 @@
#include "nmap.h" #include "nmap.h"
#include "NmapOps.h" #include "NmapOps.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#ifdef MTRACE #ifdef MTRACE
#include "mcheck.h" #include "mcheck.h"

View File

@@ -143,6 +143,14 @@ extern NmapOps o;
#endif /* WIN32 */ #endif /* WIN32 */
#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
void fatal(const char *fmt, ...) { void fatal(const char *fmt, ...) {
time_t timep; time_t timep;
struct timeval tv; struct timeval tv;

View File

@@ -170,6 +170,10 @@ NORETURN void pfatal(const char *err, ...)
void gh_perror(const char *err, ...) void gh_perror(const char *err, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
#ifndef HAVE_STRERROR
char *strerror(int errnum);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -138,6 +138,7 @@
#include "tcpip.h" #include "tcpip.h"
#include "Target.h" #include "Target.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "FPEngine.h" #include "FPEngine.h"
#include "FingerPrintResults.h" #include "FingerPrintResults.h"
#include <dnet.h> #include <dnet.h>

View File

@@ -129,8 +129,6 @@
* * * *
***************************************************************************/ ***************************************************************************/
/* $Id: osscan.h 3636 2006-07-04 23:04:56Z fyodor $ */
#ifndef OSSCAN2_H #ifndef OSSCAN2_H
#define OSSCAN2_H #define OSSCAN2_H

View File

@@ -146,6 +146,7 @@
#include "FingerPrintResults.h" #include "FingerPrintResults.h"
#include "tcpip.h" #include "tcpip.h"
#include "Target.h" #include "Target.h"
#include "nmap_error.h"
#include "utils.h" #include "utils.h"
#include "xml.h" #include "xml.h"
#include "nbase.h" #include "nbase.h"

View File

@@ -171,7 +171,7 @@
#include "scan_lists.h" #include "scan_lists.h"
#ifndef NOLUA #ifndef NOLUA
#include "nse_main.h" class ScriptResults;
#endif #endif
#include <nsock.h> #include <nsock.h>
class PortList; class PortList;

View File

@@ -143,6 +143,7 @@
#include "nbase.h" #include "nbase.h"
#include "payload.h" #include "payload.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
extern NmapOps o; extern NmapOps o;

View File

@@ -147,6 +147,7 @@
#include "Target.h" #include "Target.h"
#include "targets.h" #include "targets.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "struct_ip.h" #include "struct_ip.h"

View File

@@ -133,7 +133,10 @@
#ifndef SCAN_ENGINE_CONNECT_H #ifndef SCAN_ENGINE_CONNECT_H
#define SCAN_ENGINE_CONNECT_H #define SCAN_ENGINE_CONNECT_H
#include "scan_engine.h" #include <nbase.h>
class UltraProbe;
class UltraScanInfo;
class HostScanStats;
UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss, UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss,
u16 destport, u8 tryno, u8 pingseq); u16 destport, u8 tryno, u8 pingseq);

View File

@@ -133,7 +133,10 @@
#ifndef SCAN_ENGINE_RAW_H #ifndef SCAN_ENGINE_RAW_H
#define SCAN_ENGINE_RAW_H #define SCAN_ENGINE_RAW_H
#include "scan_engine.h" #include <nbase.h>
class UltraProbe;
class UltraScanInfo;
class HostScanStats;
#include <vector> #include <vector>
class Target; class Target;

View File

@@ -138,6 +138,7 @@
#include "nsock.h" #include "nsock.h"
#include "Target.h" #include "Target.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "protocols.h" #include "protocols.h"
#include "scan_lists.h" #include "scan_lists.h"

View File

@@ -142,6 +142,7 @@
#include "scan_engine.h" #include "scan_engine.h"
#include "nmap_dns.h" #include "nmap_dns.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "xml.h" #include "xml.h"
extern NmapOps o; extern NmapOps o;

View File

@@ -139,6 +139,7 @@
#include "NmapOps.h" #include "NmapOps.h"
#include "Target.h" #include "Target.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "libnetutil/netutil.h" #include "libnetutil/netutil.h"
#include "struct_ip.h" #include "struct_ip.h"

View File

@@ -135,6 +135,7 @@
#include "timing.h" #include "timing.h"
#include "NmapOps.h" #include "NmapOps.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "xml.h" #include "xml.h"
#include <math.h> #include <math.h>

View File

@@ -131,6 +131,7 @@
#include "nmap.h" #include "nmap.h"
#include "utils.h" #include "utils.h"
#include "nmap_error.h"
#include "NmapOps.h" #include "NmapOps.h"
#include <fcntl.h> #include <fcntl.h>
@@ -191,14 +192,6 @@ void nmap_hexdump(unsigned char *cp, unsigned int length) {
} }
#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, removes the terminating newline from string IF one /* Like the perl equivalent, removes the terminating newline from string IF one
exists. It then returns the POSSIBLY MODIFIED string. */ exists. It then returns the POSSIBLY MODIFIED string. */
char *chomp(char *string) { char *chomp(char *string) {

11
utils.h
View File

@@ -137,8 +137,7 @@
#endif #endif
#include "nbase.h" #include "nbase.h"
#include <assert.h>
#include "nmap_error.h"
/* Arithmatic difference modulo 2^32 */ /* Arithmatic difference modulo 2^32 */
#ifndef MOD_DIFF #ifndef MOD_DIFF
@@ -161,9 +160,7 @@
/* Return num if it is between min and max. Otherwise return min or max /* Return num if it is between min and max. Otherwise return min or max
(whichever is closest to num). */ (whichever is closest to num). */
template<class T> T box(T bmin, T bmax, T bnum) { template<class T> T box(T bmin, T bmax, T bnum) {
if (bmin > bmax) assert(bmin <= bmax);
fatal("box(%d, %d, %d) called (min,max,num)", (int) bmin, (int) bmax, (int) bnum);
// assert(bmin <= bmax);
if (bnum >= bmax) if (bnum >= bmax)
return bmax; return bmax;
if (bnum <= bmin) if (bnum <= bmin)
@@ -190,10 +187,6 @@ void bintohexstr(char *buf, int buflen, char *src, int srclen);
u8 *parse_hex_string(char *str, size_t *outlen); u8 *parse_hex_string(char *str, size_t *outlen);
#ifndef HAVE_STRERROR
char *strerror(int errnum);
#endif
int cpe_get_part(const char *cpe); int cpe_get_part(const char *cpe);
char *mmapfile(char *fname, int *length, int openflags); char *mmapfile(char *fname, int *length, int openflags);