diff --git a/main.cc b/main.cc index 1340fde77..1e5f2410a 100644 --- a/main.cc +++ b/main.cc @@ -117,20 +117,21 @@ struct Library *SocketBase = NULL, *MiamiBase = NULL, *MiamiBPFBase = NULL, *MiamiPCapBase = NULL; static const char ver[] = "$VER:" NMAP_NAME " v"NMAP_VERSION " [Amiga.sf]"; -BOOL OpenLibs(void) { - if(!( MiamiBase = OpenLibrary(MIAMINAME,21))) return FALSE; - if(!( SocketBase = OpenLibrary("bsdsocket.library", 4))) return FALSE; - if(!( MiamiBPFBase = OpenLibrary(MIAMIBPFNAME,3))) return FALSE; - if(!(MiamiPCapBase = OpenLibrary(MIAMIPCAPNAME,5))) return FALSE; -return TRUE; -} - -void CloseLibs(void) { +static void CloseLibs(void) { if ( MiamiPCapBase ) CloseLibrary( MiamiPCapBase ); if ( MiamiBPFBase ) CloseLibrary( MiamiBPFBase ); if ( SocketBase ) CloseLibrary( SocketBase ); if ( MiamiBase ) CloseLibrary( MiamiBase ); } + +static BOOL OpenLibs(void) { + if(!( MiamiBase = OpenLibrary(MIAMINAME,21))) return FALSE; + if(!( SocketBase = OpenLibrary("bsdsocket.library", 4))) return FALSE; + if(!( MiamiBPFBase = OpenLibrary(MIAMIBPFNAME,3))) return FALSE; + if(!(MiamiPCapBase = OpenLibrary(MIAMIPCAPNAME,5))) return FALSE; + atexit(CloseLibs); + return TRUE; +} #endif /* global options */ @@ -401,9 +402,6 @@ int main(int argc, char *argv[], char *envp[]) { } arg_parse_free(myargv); } -#ifdef __amigaos__ - CloseLibs(); -#endif return 0; } diff --git a/nmap.cc b/nmap.cc index b38cb3e47..ce2d4adeb 100644 --- a/nmap.cc +++ b/nmap.cc @@ -119,10 +119,6 @@ extern char *optarg; extern int optind; extern NmapOps o; /* option structure */ -#ifdef __amigaos__ -extern void CloseLibs(void); -#endif - /* parse the --scanflags argument. It can be a number >=0 or a string consisting of TCP flag names like "URGPSHFIN". Returns -1 if the argument is invalid. */ static int parse_scanflags(char *arg) { int flagval = 0; diff --git a/nmap_amigaos.h b/nmap_amigaos.h index 2653e86bd..bfb527825 100644 --- a/nmap_amigaos.h +++ b/nmap_amigaos.h @@ -147,7 +147,4 @@ struct addrinfo { struct addrinfo *ai_next; /* next structure in linked list */ }; - -#define exit(x); {CloseLibs();exit(x);} - #endif /* _NMAP_AMIGAOS_H_ */ diff --git a/nmap_error.cc b/nmap_error.cc index 9183d3d14..b3cc552e0 100644 --- a/nmap_error.cc +++ b/nmap_error.cc @@ -108,10 +108,6 @@ extern NmapOps o; #include #endif /* WIN32 */ -#ifdef __amigaos__ -extern void CloseLibs(void); -#endif - void fatal(const char *fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/scan_engine.cc b/scan_engine.cc index 5a5f67eb1..8f2f007c2 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -576,10 +576,6 @@ private: }; -#ifdef __amigaos__ -extern void CloseLibs(void); -#endif - bool ultrascan_port_pspec_update(UltraScanInfo *USI, HostScanStats *hss, const probespec *pspec, int newstate); diff --git a/tcpip.cc b/tcpip.cc index 3a5c2d7a2..87c4465e8 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -133,10 +133,6 @@ extern NmapOps o; -#ifdef __amigaos__ -extern void CloseLibs(void); -#endif - #ifdef WIN32 #include "pcap-int.h"