mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Add set_program_name and get_program_name functions to cache argv[0].
This commit is contained in:
13
main.cc
13
main.cc
@@ -127,6 +127,17 @@ static BOOL OpenLibs(void) {
|
||||
/* global options */
|
||||
extern NmapOps o; /* option structure */
|
||||
|
||||
/* A mechanism to save argv[0] for code that requires that. */
|
||||
static const char *program_name = NULL;
|
||||
|
||||
static void set_program_name(const char *name) {
|
||||
program_name = name;
|
||||
}
|
||||
|
||||
const char *get_program_name(void) {
|
||||
return program_name;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/* The "real" main is nmap_main(). This function hijacks control at the
|
||||
beginning to do the following:
|
||||
@@ -141,6 +152,8 @@ int main(int argc, char *argv[]) {
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
set_program_name(argv[0]);
|
||||
|
||||
#ifdef __amigaos__
|
||||
if(!OpenLibs()) {
|
||||
error("Couldn't open TCP/IP Stack Library(s)!");
|
||||
|
||||
2
nmap.cc
2
nmap.cc
@@ -138,6 +138,8 @@ extern char *optarg;
|
||||
extern int optind;
|
||||
extern NmapOps o; /* option structure */
|
||||
|
||||
/* argv[0] storage from main.cc. */
|
||||
extern const char *get_program_name(void);
|
||||
static bool target_needs_new_hostgroup(std::vector<Target *> &targets,
|
||||
const Target *target);
|
||||
static void display_nmap_version();
|
||||
|
||||
Reference in New Issue
Block a user