Skip to content

Commit

Permalink
Added nssm_exe().
Browse files Browse the repository at this point in the history
New function to retrieve argv[0].
  • Loading branch information
Iain Patterson committed Jul 15, 2016
1 parent 6adc886 commit caaaa12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nssm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extern imports_t imports;

static TCHAR unquoted_imagepath[PATH_LENGTH];
static TCHAR imagepath[PATH_LENGTH];
static TCHAR imageargv0[PATH_LENGTH];

/* Are two strings case-insensitively equivalent? */
int str_equiv(const TCHAR *a, const TCHAR *b) {
Expand Down Expand Up @@ -104,6 +105,10 @@ const TCHAR *nssm_imagepath() {
return imagepath;
}

const TCHAR *nssm_exe() {
return imageargv0;
}

int _tmain(int argc, TCHAR **argv) {
check_console();

Expand All @@ -123,6 +128,8 @@ int _tmain(int argc, TCHAR **argv) {
if (get_imports()) exit(111);

/* Remember our path for later. */
_sntprintf_s(imageargv0, _countof(imageargv0), _TRUNCATE, _T("%s"), argv[0]);
PathQuoteSpaces(imageargv0);
GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath));
GetModuleFileName(0, imagepath, _countof(imagepath));
PathQuoteSpaces(imagepath);
Expand Down
1 change: 1 addition & 0 deletions nssm.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ int num_cpus();
int usage(int);
const TCHAR *nssm_unquoted_imagepath();
const TCHAR *nssm_imagepath();
const TCHAR *nssm_exe();

#define NSSM _T("NSSM")
#ifdef _WIN64
Expand Down

0 comments on commit caaaa12

Please sign in to comment.