From: Iain Patterson Date: Wed, 1 Jan 2014 12:39:20 +0000 (+0000) Subject: Added str_number(). X-Git-Tag: v2.22~93 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=da3d37ae16f1af9735699ae444128b1224a7103f;p=nssm.git Added str_number(). Wrapper function around _tcstoul(). --- diff --git a/nssm.cpp b/nssm.cpp index 02ad21f..781a228 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -12,6 +12,17 @@ int str_equiv(const TCHAR *a, const TCHAR *b) { return 1; } +/* Convert a string to a number. */ +int str_number(const TCHAR *string, unsigned long *number) { + if (! string) return 1; + + TCHAR *bogus; + *number = _tcstoul(string, &bogus, 0); + if (*bogus) return 2; + + return 0; +} + /* Remove basename of a path. */ void strip_basename(TCHAR *buffer) { size_t len = _tcslen(buffer); diff --git a/nssm.h b/nssm.h index 636524d..cf6133e 100644 --- a/nssm.h +++ b/nssm.h @@ -18,6 +18,7 @@ int str_equiv(const TCHAR *, const TCHAR *); void strip_basename(TCHAR *); +int str_number(const TCHAR *, unsigned long *); int usage(int); #define NSSM _T("nssm")