adding switch functions

poll
Karchnu 2020-07-08 16:49:09 +02:00
parent 58ec731530
commit 50107123ea
1 changed files with 24 additions and 3 deletions

View File

@ -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