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>
|
2016-05-27 17:00:02 +02:00
|
|
|
#include <errno.h> // error numbers
|
2018-10-09 13:20:26 +02:00
|
|
|
#include "message.h"
|
2016-05-27 17:00:02 +02:00
|
|
|
|
2018-10-04 01:22:50 +02:00
|
|
|
#include "client.h"
|
2016-12-19 18:16:38 +01:00
|
|
|
|
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
|
2016-12-15 00:28:42 +01:00
|
|
|
// SERVICE
|
|
|
|
|
2016-12-17 18:00:04 +01:00
|
|
|
// srv->version and srv->index must be already set
|
|
|
|
// init unix socket + fill srv->spath
|
2018-10-09 13:16:40 +02:00
|
|
|
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
|
|
|
|
2018-10-04 22:51:31 +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
|
|
|
|
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
|
2016-06-10 01:21:04 +02:00
|
|
|
// send the connection string to $TMP/<service>
|
2016-12-17 18:00:04 +01:00
|
|
|
// fill srv->spath && srv->service_fd
|
2018-10-09 13:16:40 +02:00
|
|
|
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
|
|
|
|
2016-12-20 23:36:00 +01:00
|
|
|
|
|
|
|
|
2016-05-26 18:27:59 +02:00
|
|
|
#endif
|