2f879ff43aa188a3dc6e3b378320a1038f3d7798
[tpg/acess2.git] / Usermode / Libraries / libaxwin4.so_src / ipc_acessipcpipe.cpp
1 /*
2  * AxWin4 Interface Library
3  * - By John Hodge (thePowersGang)
4  *
5  * ipc_acessipcpipe.c
6  * - Acess2 /Devices/ipcpipe/ IPC Channel
7  */
8 #include "include/CIPCChannel_AcessIPCPipe.hpp"
9 #include <system_error>
10 #include <cerrno>
11
12 namespace AxWin {
13
14 CIPCChannel_AcessIPCPipe::CIPCChannel_AcessIPCPipe(const char *Path)
15 {
16         m_fd = _SysOpen(Path, OPENFLAG_READ|OPENFLAG_WRITE);
17         if( m_fd == -1 ) {
18                 throw ::std::system_error(errno, ::std::system_category());
19         }
20 }
21
22 CIPCChannel_AcessIPCPipe::~CIPCChannel_AcessIPCPipe()
23 {
24 }
25
26 int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& fds)
27 {
28         FD_SET(m_fd, &fds);
29         return m_fd+1;
30 }
31
32 bool CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& fds)
33 {
34         if( FD_ISSET(m_fd, &fds) )
35         {
36         }
37         return true;
38 }
39
40 void CIPCChannel_AcessIPCPipe::Send(CSerialiser& message)
41 {
42         const ::std::vector<uint8_t>& serialised = message.Compact();
43         if(serialised.size() > 0x1000 ) {
44                 throw ::std::length_error("CIPCChannel_AcessIPCPipe::Send");
45         }
46         _SysDebug("Send %i bytes", serialised.size());
47         _SysWrite(m_fd, serialised.data(), serialised.size());
48 }
49
50
51 };      // namespace AxWin
52

UCC git Repository :: git.ucc.asn.au