X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=3c7545ab6283db5b21b0497d310587866368809b;hb=53371f115d94fbbc7e5cb60853b9e4a5d356d4b0;hp=32f1142036aea814d011e269de2f7efd5361a9c6;hpb=3f77c8a2c04c269f7e293a0cec517cb9cb8c5d49;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 32f1142..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); @@ -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();