]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove crappy, unsafe (and now unneeded!) casts.
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 8 Sep 2008 20:59:16 +0000 (20:59 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 8 Sep 2008 20:59:16 +0000 (20:59 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10476 e03df62e-2008-0410-955e-edbf42e46eb7

include/socket.h
src/listensocket.cpp
src/modules/m_httpd.cpp
src/socket.cpp

index 961fbd98ece7d67d45425da7726ed8e80fbc4a97..e1050201ae20b13b4b36d48f4ee17c00fa317d53 100644 (file)
@@ -135,7 +135,7 @@ namespace irc
                 * or a negative value upon failure (negative values are invalid file
                 * descriptors)
                 */
-               CoreExport int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
+               CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM);
        }
 }
 
@@ -171,7 +171,7 @@ class CoreExport ListenSocketBase : public EventHandler
  public:
        /** Create a new listening socket
         */
-       ListenSocketBase(InspIRCd* Instance, int port, char* addr);
+       ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr);
        /** Handle an I/O event
         */
        void HandleEvent(EventType et, int errornum = 0);
@@ -219,7 +219,7 @@ class CoreExport ClientListenSocket : public ListenSocketBase
 {
        virtual void OnAcceptReady(const std::string &ipconnectedto, int fd, const std::string &incomingip);
  public:
-       ClientListenSocket(InspIRCd* Instance, int port, char* addr) : ListenSocketBase(Instance, port, addr) { }
+       ClientListenSocket(InspIRCd* Instance, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr) { }
 };
 
 #endif
index 3ecfbb432d54dcd2db18924e058b72fceb18433e..961156ae6f74e4b846397d6ab3ef9d4ea33446d2 100644 (file)
@@ -24,15 +24,15 @@ sockaddr* ListenSocketBase::sock_us = NULL;
 sockaddr* ListenSocketBase::client = NULL;
 sockaddr* ListenSocketBase::raddr = NULL;
 
-ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, char* addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
+ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
 {
-       this->SetFd(irc::sockets::OpenTCPSocket(addr));
+       this->SetFd(irc::sockets::OpenTCPSocket(addr.c_str()));
        if (this->GetFd() > -1)
        {
-               if (!Instance->BindSocket(this->fd,port,addr))
+               if (!Instance->BindSocket(this->fd,port,addr.c_str()))
                        this->fd = -1;
 #ifdef IPV6
-               if ((!*addr) || (strchr(addr,':')))
+               if ((!*addr.c_str()) || (strchr(addr.c_str(),':')))
                        this->family = AF_INET6;
                else
 #endif
index ec4aec43c04f61acd5a8c0545a7d4d17d5917303..9b59ea6bb5cbe66cbc42be09aa2d97a3e9eda5e8 100644 (file)
@@ -378,7 +378,7 @@ class HttpListener : public ListenSocketBase
 
        virtual void OnAcceptReady(const std::string &ipconnectedto, int nfd, const std::string &incomingip)
        {
-               new HttpServerSocket(ServerInstance, nfd, (char *)incomingip.c_str(), index); // XXX unsafe casts suck
+               new HttpServerSocket(ServerInstance, nfd, incomingip.c_str(), index);
        }
 };
 
index 01c07e2d093651b50ef3cdfe4befd1525ca9a711..d2090c3a2542a3c752a816d833589d09c9fa6f8b 100644 (file)
@@ -143,7 +143,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
 }
 
 // Open a TCP Socket
-int irc::sockets::OpenTCPSocket(char* addr, int socktype)
+int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
 {
        int sockfd;
        int on = 1;