]> git.stg.codes - stg.git/blobdiff - stglibs/common.lib/common.cpp
Виправлена помилка компіляції бібліотеки common.lib на платформі Win32
[stg.git] / stglibs / common.lib / common.cpp
index a5899dd2c2fdaaea9311b2ef3b1a81a648ab7ca9..7124670401bf5a6ed922145e29268b38488d5eb8 100644 (file)
@@ -23,8 +23,8 @@
  */
 
  /*
- $Revision: 1.41 $
- $Date: 2010/11/03 10:26:30 $
+ $Revision: 1.42 $
+ $Date: 2010/11/08 10:11:19 $
  $Author: faust $
  */
 
 #include <sys/socket.h>
 #endif*/
 
+#ifdef FREE_BSD
+#include <sys/types.h>
+#endif
+
+#ifdef WIN32
+#include <winsock2.h>
+#else
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
+
 #include <iconv.h>
 
 #include <cstdlib>
@@ -728,6 +737,26 @@ int str2x(const std::string & str, unsigned & x)
 {
 x = strtoul(str.c_str(), NULL, 10);
 
+if (errno == ERANGE)
+    return -1;
+
+return 0;
+}
+//---------------------------------------------------------------------------
+int str2x(const std::string & str, long & x)
+{
+x = strtol(str.c_str(), NULL, 10);
+
+if (errno == ERANGE)
+    return -1;
+
+return 0;
+}
+//---------------------------------------------------------------------------
+int str2x(const std::string & str, unsigned long & x)
+{
+x = strtoul(str.c_str(), NULL, 10);
+
 if (errno == ERANGE)
     return -1;
 
@@ -759,6 +788,11 @@ const std::string & x2str(unsigned x, std::string & s)
 return unsigned2str(x, s);
 }
 //---------------------------------------------------------------------------
+const std::string & x2str(unsigned long x, std::string & s)
+{
+return unsigned2str(x, s);
+}
+//---------------------------------------------------------------------------
 const std::string & x2str(unsigned long long x, std::string & s)
 {
 return unsigned2str(x, s);