1
0
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:
david
2011-03-26 06:48:19 +00:00
parent 02669cbfd8
commit 45814927a9
2 changed files with 15 additions and 0 deletions

13
main.cc
View File

@@ -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)!");

View File

@@ -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();