]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/unix.cpp
Move most platform-specific code into overlay directories
[libs/net.git] / source / net / unix.cpp
index 9d8cf2780af0da1d99eb177136944b30659730bb..fe00020988bf92c1b915b7e6a7ef399ad7e9c4af 100644 (file)
@@ -1,8 +1,3 @@
-#include <stdexcept>
-#ifndef _WIN32
-#include <sys/un.h>
-#endif
-#include "sockaddr_private.h"
 #include "unix.h"
 
 using namespace std;
@@ -13,60 +8,6 @@ namespace Net {
 UnixAddr::UnixAddr():
        abstract(false)
 {
-#ifdef _WIN32
-       throw logic_error("no unix sockets on windows");
-#endif
-}
-
-UnixAddr::UnixAddr(const SysAddr &sa):
-       abstract(false)
-{
-#ifdef _WIN32
-       (void)sa;
-       throw logic_error("no unix sockets on windows");
-#else
-       const sockaddr_un &sau = reinterpret_cast<const sockaddr_un &>(sa.addr);
-       if(static_cast<size_t>(sa.size)>sizeof(sa_family_t))
-       {
-               abstract = (sau.sun_path[0]==0);
-               path.assign(sau.sun_path+abstract, sa.size-sizeof(sa_family_t)-abstract);
-       }
-#endif
-}
-
-UnixAddr::UnixAddr(const string &p, bool a):
-       path(p),
-       abstract(a)
-{
-#ifdef _WIN32
-       throw logic_error("no unix sockets on windows");
-#else
-       if(sizeof(sa_family_t)+path.size()+1>sizeof(sockaddr_storage))
-               throw invalid_argument("UnixAddr");
-#endif
-}
-
-SockAddr::SysAddr UnixAddr::to_sys() const
-{
-       SysAddr sa;
-#ifndef _WIN32
-       sa.size = sizeof(sa_family_t);
-       if(!path.empty())
-               sa.size += path.size()+1;
-
-       sockaddr_un &sau = reinterpret_cast<sockaddr_un &>(sa.addr);
-       sau.sun_family = AF_UNIX;
-       if(!path.empty())
-       {
-               if(abstract)
-                       sau.sun_path[0] = 0;
-               std::copy(path.begin(), path.end(), sau.sun_path+abstract);
-               if(!abstract)
-                       sau.sun_path[path.size()] = 0;
-       }
-#endif
-
-       return sa;
 }
 
 string UnixAddr::str() const