diff options
Diffstat (limited to 'client/utils.cpp')
-rw-r--r-- | client/utils.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/client/utils.cpp b/client/utils.cpp index 29201743..c27aa361 100644 --- a/client/utils.cpp +++ b/client/utils.cpp @@ -37,3 +37,14 @@ void wstring_printf(std::wstring& str, const wchar_t* format, ...) va_end(ap); } +int str_to_port(const char *str) +{ + long port; + char *endptr; + port = strtol(str, &endptr, 0); + if (endptr != str + strlen(str) || port < 0 || port > 0xffff) { + return -1; + } + return port; +} + |