]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix building on Windows.
authorPeter Powell <petpow@saberuk.com>
Tue, 24 Jul 2018 10:01:50 +0000 (11:01 +0100)
committerPeter Powell <petpow@saberuk.com>
Tue, 24 Jul 2018 10:05:51 +0000 (11:05 +0100)
src/modules/m_spanningtree/main.cpp
src/socket.cpp
win/inspircd_win32wrapper.h

index 8bc3bfd9cb573b14170e163f6b75267fcede2263..21251983cd27b7b9a1f0ae50c65525f8759542c5 100644 (file)
@@ -203,12 +203,14 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                return;
        }
 
+#ifndef _WIN32
        if (x->IPAddr.find('/') != std::string::npos)
        {
                struct stat sb;
                if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode))
                        ipvalid = false;
        }
+#endif
        if (x->IPAddr.find(':') != std::string::npos)
        {
                in6_addr n;
index 1d110323567a589ca39d3a55c89a2c1884363540..5827b8b7743fb7c17c43123bba3cdc86bdd28f74 100644 (file)
@@ -93,6 +93,7 @@ int InspIRCd::BindPorts(FailedPortList& failed_ports)
                        continue;
                }
 
+#ifndef _WIN32
                // Are we creating a UNIX listener?
                const std::string path = tag->getString("path");
                if (!path.empty())
@@ -109,13 +110,14 @@ int InspIRCd::BindPorts(FailedPortList& failed_ports)
                        // Create the bindspec manually (aptosa doesn't work with AF_UNIX yet).
                        memset(&bindspec, 0, sizeof(bindspec));
                        bindspec.un.sun_family = AF_UNIX;
-                       stpncpy(bindspec.un.sun_path, path.c_str(), sizeof(bindspec.un.sun_path) - 1);
+                       memcpy(&bindspec.un.sun_path, path.c_str(), sizeof(bindspec.un.sun_path));
 
                        if (!BindPort(tag, bindspec, old_ports))
                                failed_ports.push_back(std::make_pair(bindspec, errno));
                        else
                                bound++;
                }
+#endif
        }
 
        std::vector<ListenSocket*>::iterator n = ports.begin();
index 8b418928d28be458e1441502ba9920e41a0e1ca9..a6ca0da6e7754b81c9110559f16bfde95e95b595 100644 (file)
@@ -198,3 +198,11 @@ inline ssize_t writev(int fd, const WindowsIOVec* iov, int count)
                return sent;
        return -1;
 }
+
+// This wrapper is just so we don't need to do #ifdef _WIN32 everywhere in the socket code. It is
+// not actually used and does not need to be the same size as sockaddr_un on UNIX systems.
+struct sockaddr_un
+{
+       ADDRESS_FAMILY sun_family;
+       char sun_path[6];
+};