X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=3c7545ab6283db5b21b0497d310587866368809b;hb=53371f115d94fbbc7e5cb60853b9e4a5d356d4b0;hp=792b62be89fad8986d19f13ef1ac3af1b11a0095;hpb=9cf66b86846f97f0bd2efdfe2b8bd36ea0b00499;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 792b62b..3c7545a 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -13,16 +13,20 @@ int str_equiv(const TCHAR *a, const TCHAR *b) { } /* Convert a string to a number. */ -int str_number(const TCHAR *string, unsigned long *number) { +int str_number(const TCHAR *string, unsigned long *number, TCHAR **bogus) { if (! string) return 1; - TCHAR *bogus; - *number = _tcstoul(string, &bogus, 0); - if (*bogus) return 2; + *number = _tcstoul(string, bogus, 0); + if (**bogus) return 2; return 0; } +int str_number(const TCHAR *string, unsigned long *number) { + TCHAR *bogus; + return str_number(string, number, &bogus); +} + /* Remove basename of a path. */ void strip_basename(TCHAR *buffer) { size_t len = _tcslen(buffer); @@ -35,8 +39,8 @@ void strip_basename(TCHAR *buffer) { /* How to use me correctly */ int usage(int ret) { - if (GetConsoleWindow()) print_message(stderr, NSSM_MESSAGE_USAGE, NSSM_VERSION, NSSM_DATE); - else popup_message(0, MB_OK, NSSM_MESSAGE_USAGE, NSSM_VERSION, NSSM_DATE); + if (GetConsoleWindow()) print_message(stderr, NSSM_MESSAGE_USAGE, NSSM_VERSION, NSSM_CONFIGURATION, NSSM_DATE); + else popup_message(0, MB_OK, NSSM_MESSAGE_USAGE, NSSM_VERSION, NSSM_CONFIGURATION, NSSM_DATE); return(ret); } @@ -71,6 +75,13 @@ static void check_console() { FreeConsole(); } +int num_cpus() { + DWORD_PTR i, affinity, system_affinity; + if (! GetProcessAffinityMask(GetCurrentProcess(), &affinity, &system_affinity)) return 64; + for (i = 0; system_affinity & (1LL << i); i++); + return (int) i; +} + int _tmain(int argc, TCHAR **argv) { check_console();