Moved remoting layer to new library.
[shibboleth/sp.git] / shibsp / UnixListener.cpp
similarity index 63%
rename from shib-target/UnixListener.cpp
rename to shibsp/UnixListener.cpp
index b837585..dd45509 100644 (file)
  * Unix Domain-based SocketListener implementation\r
  */\r
 \r
-#include "RPCListener.h"\r
+#include "internal.h"\r
+#include "SocketListener.h"\r
+\r
+#include <xercesc/util/XMLUniDefs.hpp>\r
+#include <xmltooling/unicode.h>\r
 \r
 #ifdef HAVE_UNISTD_H\r
 # include <sys/socket.h>\r
 #include <stdlib.h>\r
 #include <errno.h>\r
 \r
+using namespace shibsp;\r
+using namespace xmltooling;\r
+using namespace xercesc;\r
 using namespace std;\r
-using namespace saml;\r
-using namespace shibboleth;\r
-using namespace shibtarget;\r
-using namespace log4cpp;\r
 \r
-static const XMLCh address[] = { chLatin_a, chLatin_d, chLatin_d, chLatin_r, chLatin_e, chLatin_s, chLatin_s, chNull };\r
 \r
-class UnixListener : virtual public SocketListener\r
-{\r
-public:\r
-    UnixListener(const DOMElement* e);\r
-    ~UnixListener() {if (m_bound) unlink(m_address.c_str());}\r
-\r
-    bool create(ShibSocket& s) const;\r
-    bool bind(ShibSocket& s, bool force=false) const;\r
-    bool connect(ShibSocket& s) const;\r
-    bool close(ShibSocket& s) const;\r
-    bool accept(ShibSocket& listener, ShibSocket& s) const;\r
-\r
-    int send(ShibSocket& s, const char* buf, int len) const {\r
-        return ::send(s, buf, len, 0);\r
-    }\r
-    \r
-    int recv(ShibSocket& s, char* buf, int buflen) const {\r
-        return ::recv(s, buf, buflen, 0);\r
+namespace shibsp {\r
+    static const XMLCh address[] = UNICODE_LITERAL_7(a,d,d,r,e,s,s);\r
+\r
+    class UnixListener : virtual public SocketListener\r
+    {\r
+    public:\r
+        UnixListener(const DOMElement* e);\r
+        ~UnixListener() {if (m_bound) unlink(m_address.c_str());}\r
+\r
+        bool create(ShibSocket& s) const;\r
+        bool bind(ShibSocket& s, bool force=false) const;\r
+        bool connect(ShibSocket& s) const;\r
+        bool close(ShibSocket& s) const;\r
+        bool accept(ShibSocket& listener, ShibSocket& s) const;\r
+\r
+        int send(ShibSocket& s, const char* buf, int len) const {\r
+            return ::send(s, buf, len, 0);\r
+        }\r
+        \r
+        int recv(ShibSocket& s, char* buf, int buflen) const {\r
+            return ::recv(s, buf, buflen, 0);\r
+        }\r
+        \r
+    private:\r
+        string m_address;\r
+        mutable bool m_bound;\r
+    };\r
+\r
+    ListenerService* SHIBSP_DLLLOCAL UnixListenerServiceFactory(const DOMElement* const & e)\r
+    {\r
+        return new UnixListener(e);\r
     }\r
-    \r
-private:\r
-    string m_address;\r
-    mutable bool m_bound;\r
 };\r
 \r
-IPlugIn* UnixListenerFactory(const DOMElement* e)\r
-{\r
-    return new UnixListener(e);\r
-}\r
-\r
-UnixListener::UnixListener(const DOMElement* e) : RPCListener(e), m_address("/var/run/shar-socket"), m_bound(false)\r
+UnixListener::UnixListener(const DOMElement* e) : SocketListener(e), m_address("/var/run/shar-socket"), m_bound(false)\r
 {\r
     // We're stateless, but we need to load the configuration.\r
     const XMLCh* tag=e->getAttributeNS(NULL,address);\r
@@ -149,11 +155,3 @@ bool UnixListener::accept(ShibSocket& listener, ShibSocket& s) const
         return log_error();\r
     return true;\r
 }\r
-\r
-CLIENT* UnixListener::getClientHandle(ShibSocket& s, u_long program, u_long version) const\r
-{\r
-    struct sockaddr_in sin;\r
-    memset (&sin, 0, sizeof (sin));\r
-    sin.sin_port = 1;\r
-    return clnttcp_create(&sin, program, version, &s, 0, 0);\r
-}\r