Archived
3
0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
libipc-old/core/communication.h

58 lines
1.9 KiB
C
Raw Normal View History

2018-10-03 21:52:11 +02:00
#ifndef __IPC_COMMUNICATION_H__
#define __IPC_COMMUNICATION_H__
2016-05-26 18:27:59 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h> // error numbers
2018-10-09 13:20:26 +02:00
#include "message.h"
2018-10-04 01:22:50 +02:00
#include "client.h"
2018-10-28 17:09:35 +01:00
#include "event.h"
2016-05-26 18:27:59 +02:00
#define COMMUNICATION_VERSION 1
2018-10-08 15:18:56 +02:00
#define IPC_WITH_UNIX_SOCKETS
#ifdef IPC_WITH_UNIX_SOCKETS
#include "usocket.h"
#endif
// SERVICE
2016-12-17 18:00:04 +01:00
// srv->version and srv->index must be already set
// init unix socket + fill srv->spath
int ipc_server_init (char **env
2018-10-04 00:30:47 +02:00
, struct ipc_service *srv, const char *sname);
int ipc_server_close (struct ipc_service *srv);
2018-10-04 01:54:12 +02:00
int ipc_server_close_client (struct ipc_client *p);
2018-10-04 00:30:47 +02:00
int ipc_server_accept (struct ipc_service *srv, struct ipc_client *p);
2016-05-26 18:27:59 +02:00
2018-10-08 19:56:11 +02:00
// 1 on a recipient socket close
2018-10-04 00:30:47 +02:00
int ipc_server_read (const struct ipc_client *, struct ipc_message *m);
int ipc_server_write (const struct ipc_client *, const struct ipc_message *m);
2016-06-04 20:33:44 +02:00
int ipc_server_select (struct ipc_clients * clients, struct ipc_service *srv
, struct ipc_clients *active_clients, int *new_connection);
2016-12-20 23:36:00 +01:00
2018-10-28 19:28:19 +01:00
int ipc_service_poll_event (struct ipc_clients *clients, struct ipc_service *srv
2018-10-28 17:09:35 +01:00
, struct ipc_event *event);
2016-06-05 03:19:36 +02:00
// APPLICATION
2016-05-26 18:27:59 +02:00
2016-12-17 18:00:04 +01:00
// Initialize connection with unix socket
// send the connection string to $TMP/<service>
2016-12-17 18:00:04 +01:00
// fill srv->spath && srv->service_fd
int ipc_application_connection (char **env
2018-10-08 16:15:35 +02:00
, struct ipc_service *, const char *);
2018-10-04 00:30:47 +02:00
int ipc_application_close (struct ipc_service *);
2016-10-28 13:58:04 +02:00
2018-10-08 19:56:11 +02:00
// 1 on a recipient socket close
2018-10-04 00:30:47 +02:00
int ipc_application_read (struct ipc_service *srv, struct ipc_message *m);
int ipc_application_write (struct ipc_service *, const struct ipc_message *m);
2016-10-14 17:47:08 +02:00
2018-10-10 23:08:58 +02:00
int ipc_application_select (struct ipc_services *services, struct ipc_services *active_services);
2016-12-20 23:36:00 +01:00
2018-10-28 19:28:19 +01:00
int ipc_application_poll_event (struct ipc_services *services, struct ipc_event *event);
int ipc_application_peek_event (struct ipc_services *services, struct ipc_event *event);
2016-05-26 18:27:59 +02:00
#endif