diff --git a/src/ipc/lowlevel.cr b/src/ipc/lowlevel.cr index 40fe824..119ef30 100644 --- a/src/ipc/lowlevel.cr +++ b/src/ipc/lowlevel.cr @@ -4,9 +4,10 @@ lib LibIPC INFTIM = -1 enum ConnectionType - IPC - External - Server + IPC # IO op. are handled by libipc. + External # IO op. are handled by the libipc user app. + Server # Should listen and accept new IPC users. + Switched # IO op. are handled by callbacks. end struct Connection @@ -88,6 +89,7 @@ lib LibIPC # Context is allocated, ipcd is requested and the connection/initialisation is performed. fun ipc_server_init(ctx : Ctx*, sname : LibC::Char*) : IPCError fun ipc_connection(Ctx*, LibC::Char*) : IPCError + fun ipc_connection_switched(Ctx*, LibC::Char*) : IPCError # Closing connections. fun ipc_close(ctx : Ctx*, index : LibC::UInt64T) : IPCError @@ -102,6 +104,7 @@ lib LibIPC fun ipc_add(Ctx*, Connection*, Pollfd*) : IPCError fun ipc_del(Ctx*, LibC::UInt) : IPCError fun ipc_add_fd(Ctx*, LibC::Int) : IPCError + fun ipc_add_fd_switched(Ctx*, LibC::Int) : IPCError fun ipc_del_fd(Ctx*, LibC::Int) : IPCError # Sending a message (will wait the fd to become available for IO operations). @@ -115,6 +118,24 @@ lib LibIPC fun ipc_receive_fd (sock : LibC::Int, fd : LibC::Int*) : IPCError fun ipc_provide_fd (sock : LibC::Int, fd : LibC::Int ) : IPCError + # To change the type of a fd. + fun ipc_ctx_fd_type(Ctx*, LibC::Int, LibIPC::ConnectionType) : IPCError + + enum IPCCB + NoError # + Closing # + Error # + ParsingError # + end + + # Changing the callbacks for switched fd. + # ipc_switching_callbacks: ctx, fd + # , enum ipccb cb_in (fd, *ipc_message) + # , enum ipccb cb_out (fd, *ipc_message) + fun ipc_switching_callbacks(Ctx*, LibC::Int, + cb_in : (LibC::Int, Pointer(LibIPC::Message)) -> LibIPC::IPCCB, + cb_out : (LibC::Int, Pointer(LibIPC::Message)) -> LibIPC::IPCCB) : IPCError + fun ipc_switching_add (switch : Switchings*, fd1 : LibC::Int, fd2 : LibC::Int) # Void fun ipc_switching_del (switch : Switchings*, fd : LibC::Int ) : LibC::Int fun ipc_switching_get (switch : Switchings*, fd : LibC::Int ) : LibC::Int