mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
header file cleanup
see http://seclists.org/nmap-dev/2013/q4/168 Move some includes out of nmap.h: nmap.h gets included lots of places, and unconditionally included math.h, ctype.h, errno.h, stdio.h, sys/stat.h, fcntl.h, sys/types.h, and stdarg.h. This commit moves those includes into the .cc files where they are necessary and out of nmap.h Remove redundant include global_structures.h, included from nmap.h Removed redundant code included from nmap.h Removing #include nbase.h when nmap.h is included (redundant) Remove duplicate #include lines Add ifndef guards to a few .h files
This commit is contained in:
@@ -132,6 +132,7 @@
|
||||
#include "osscan.h"
|
||||
#include "libnetutil/npacket.h"
|
||||
#include "linear.h"
|
||||
#include <math.h>
|
||||
extern NmapOps o;
|
||||
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@
|
||||
class FingerPrintResults;
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "FPEngine.h"
|
||||
|
||||
/* Maximum number of results allowed in one of these things ... */
|
||||
|
||||
@@ -124,7 +124,6 @@
|
||||
|
||||
/* $Id$ */
|
||||
#include "nmap.h"
|
||||
#include "nbase.h"
|
||||
#include "NmapOps.h"
|
||||
#include "services.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -124,8 +124,10 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef NMAPOPS_H
|
||||
#define NMAPOPS_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "output.h"
|
||||
#include <nsock.h>
|
||||
#include <string>
|
||||
@@ -424,4 +426,4 @@ class NmapOps {
|
||||
u8 spoof_mac[6];
|
||||
bool spoof_mac_set;
|
||||
};
|
||||
|
||||
#endif /* NMAPOPS_H */
|
||||
|
||||
@@ -132,8 +132,6 @@
|
||||
#define IDLE_SCAN_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include <nbase.h>
|
||||
|
||||
class Target;
|
||||
|
||||
|
||||
6
nmap.cc
6
nmap.cc
@@ -129,12 +129,10 @@
|
||||
#include "osscan2.h"
|
||||
#include "scan_engine.h"
|
||||
#include "idle_scan.h"
|
||||
#include "timing.h"
|
||||
#include "NmapOps.h"
|
||||
#include "MACLookup.h"
|
||||
#include "traceroute.h"
|
||||
#include "nmap_tty.h"
|
||||
#include "nmap_dns.h"
|
||||
#include "services.h"
|
||||
#include "protocols.h"
|
||||
#include "targets.h"
|
||||
@@ -145,6 +143,10 @@
|
||||
#include "utils.h"
|
||||
#include "xml.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef NOLUA
|
||||
#include "nse_main.h"
|
||||
#endif
|
||||
|
||||
12
nmap.h
12
nmap.h
@@ -173,9 +173,6 @@ void *realloc();
|
||||
#include <bstring.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef WIN32 /* from nmapNT -- seems to work */
|
||||
#include <sys/wait.h>
|
||||
#endif /* !WIN32 */
|
||||
@@ -184,8 +181,6 @@ void *realloc();
|
||||
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_RPC_TYPES_H
|
||||
#include <rpc/types.h>
|
||||
#endif
|
||||
@@ -194,14 +189,10 @@ void *realloc();
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
@@ -217,8 +208,6 @@ void *realloc();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
@@ -236,7 +225,6 @@ void *realloc();
|
||||
/* Keep assert() defined for security reasons */
|
||||
#undef NDEBUG
|
||||
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
|
||||
@@ -194,7 +194,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
@@ -120,6 +120,8 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NMAP_DNS_H
|
||||
#define NMAP_DNS_H
|
||||
class Target;
|
||||
|
||||
#include "nbase.h"
|
||||
@@ -131,3 +133,4 @@ void nmap_mass_rdns(Target ** targets, int num_targets);
|
||||
const char *lookup_cached_host(u32 ip);
|
||||
|
||||
std::list<std::string> get_dns_servers();
|
||||
#endif /* NMAP_DNS_H */
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
#include "output.h"
|
||||
#include "NmapOps.h"
|
||||
#include "xml.h"
|
||||
#include <errno.h>
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
|
||||
@@ -121,10 +121,6 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WIN32
|
||||
#include "nmap_config.h"
|
||||
#endif
|
||||
|
||||
#include "nmap.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NMAP_TTY_H
|
||||
#define NMAP_TTY_H
|
||||
|
||||
/*
|
||||
* Initializes the terminal for unbuffered non-blocking input. Also
|
||||
* registers tty_done() via atexit(). You need to call this before
|
||||
@@ -133,4 +136,4 @@ void tty_init();
|
||||
being returned means a nonstandard key has been pressed and the
|
||||
calling method should print a status message */
|
||||
bool keyWasPressed();
|
||||
|
||||
#endif /* NMAP_TTY_H */
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "nmap.h"
|
||||
#include "nbase.h"
|
||||
#include "nmap_error.h"
|
||||
#include "portlist.h"
|
||||
#include "nsock.h"
|
||||
@@ -8,6 +7,7 @@
|
||||
#include "Target.h"
|
||||
#include "nmap_tty.h"
|
||||
#include "xml.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "nse_main.h"
|
||||
#include "nse_utility.h"
|
||||
|
||||
@@ -14,7 +14,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
|
||||
class ScriptResult
|
||||
{
|
||||
|
||||
@@ -122,6 +122,9 @@
|
||||
***************************************************************************/
|
||||
|
||||
/* $Id:$ */
|
||||
#ifndef NSE_SSL_CERT_H
|
||||
#define NSE_SSL_CERT_H
|
||||
|
||||
int l_get_ssl_certificate(lua_State *L);
|
||||
void nse_nsock_init_ssl_cert(lua_State *L);
|
||||
#endif /* NSE_SSL_CERT_H */
|
||||
|
||||
@@ -64,9 +64,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
1
osscan.h
1
osscan.h
@@ -128,7 +128,6 @@
|
||||
#define OSSCAN_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "FingerPrintResults.h"
|
||||
#include "Target.h"
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
#include "struct_ip.h"
|
||||
|
||||
#include <list>
|
||||
#include <math.h>
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
|
||||
@@ -129,8 +129,6 @@
|
||||
#define OSSCAN2_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "nbase.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "Target.h"
|
||||
|
||||
@@ -139,12 +139,10 @@
|
||||
#include "Target.h"
|
||||
#include "utils.h"
|
||||
#include "xml.h"
|
||||
#include "nbase.h"
|
||||
#include "libnetutil/netutil.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
|
||||
1
output.h
1
output.h
@@ -165,7 +165,6 @@
|
||||
|
||||
#include "portlist.h"
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include <nsock.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -134,7 +134,6 @@
|
||||
#include <map>
|
||||
|
||||
#include "NmapOps.h"
|
||||
#include "nbase.h"
|
||||
#include "payload.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
@@ -132,8 +132,6 @@
|
||||
#endif
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "nbase.h"
|
||||
|
||||
#define PROTOCOL_TABLE_SIZE 256
|
||||
|
||||
|
||||
@@ -129,7 +129,6 @@
|
||||
#define SCAN_ENGINE_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include <vector>
|
||||
|
||||
struct probespec_tcpdata {
|
||||
|
||||
@@ -129,7 +129,6 @@
|
||||
#define SERVICE_SCAN_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "portlist.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -128,15 +128,7 @@
|
||||
#ifndef SERVICES_H
|
||||
#define SERVICES_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include "mswin32\winclude.h"
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
|
||||
#include "nbase.h"
|
||||
|
||||
#define SERVICE_TABLE_SIZE 1024
|
||||
|
||||
|
||||
22
targets.h
22
targets.h
@@ -127,29 +127,7 @@
|
||||
#ifndef TARGETS_H
|
||||
#define TARGETS_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "nmap_config.h"
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#include "nmap_winconfig.h"
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
/* This contains pretty much everything we need ... */
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
||||
#endif
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
#include "TargetGroup.h"
|
||||
|
||||
class TargetGroup {
|
||||
|
||||
80
tcpip.h
80
tcpip.h
@@ -129,78 +129,7 @@
|
||||
#ifndef TCPIP_H
|
||||
#define TCPIP_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "nmap_config.h"
|
||||
#endif
|
||||
|
||||
#include "nbase.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "mswin32\winclude.h"
|
||||
#else
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
void *malloc();
|
||||
void *realloc();
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#if !STDC_HEADERS && HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#endif
|
||||
#if HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BSTRING_H
|
||||
#include <bstring.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RPC_TYPES_H
|
||||
#include <rpc/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#include "nmap.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -215,17 +144,14 @@ extern "C" {
|
||||
#if HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h> /* SIOCGIFCONF for Solaris */
|
||||
#endif
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <dnet.h>
|
||||
|
||||
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
/* from Target.h */
|
||||
class Target;
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN 16
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
#include "NmapOps.h"
|
||||
#include "utils.h"
|
||||
#include "xml.h"
|
||||
#include <math.h>
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
|
||||
1
timing.h
1
timing.h
@@ -130,7 +130,6 @@
|
||||
#define NMAP_TIMING_H
|
||||
|
||||
#include "nmap.h"
|
||||
#include "global_structures.h"
|
||||
|
||||
/* Call this function on a newly allocated struct timeout_info to
|
||||
initialize the values appropriately */
|
||||
|
||||
@@ -123,6 +123,8 @@
|
||||
|
||||
/* $Id: nmap.h 6676 2008-01-12 22:39:34Z fyodor $ */
|
||||
|
||||
#ifndef NMAP_TRACEROUTE_H
|
||||
#define NMAP_TRACEROUTE_H
|
||||
#include "Target.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -130,3 +132,4 @@
|
||||
int traceroute(std::vector<Target *> &Targets);
|
||||
|
||||
void traceroute_hop_cache_clear();
|
||||
#endif /* NMAP_TRACEROUTE_H */
|
||||
|
||||
1
utils.cc
1
utils.cc
@@ -126,6 +126,7 @@
|
||||
#include "nmap.h"
|
||||
#include "utils.h"
|
||||
#include "NmapOps.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
|
||||
28
utils.h
28
utils.h
@@ -133,38 +133,12 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include "nmap.h"
|
||||
#ifdef WIN32
|
||||
#include "mswin32\winclude.h"
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/mman.h>
|
||||
#include "nmap_config.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "nbase.h"
|
||||
|
||||
#include "nmap_error.h"
|
||||
#include "global_structures.h"
|
||||
|
||||
/* Arithmatic difference modulo 2^32 */
|
||||
#ifndef MOD_DIFF
|
||||
|
||||
Reference in New Issue
Block a user