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

63 lines
1.7 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
2016-12-21 01:26:47 +01:00
#include "msg.h"
2018-10-04 01:22:50 +02:00
#include "client.h"
2016-05-26 18:27:59 +02:00
#define COMMUNICATION_VERSION 1
2016-12-17 18:00:04 +01:00
#define ER_MEM_ALLOC 100
#define ER_PARAMS 101
2018-10-03 21:24:20 +02:00
#define TMPDIR "/run/ipc/"
2016-12-17 18:00:04 +01:00
#define PATH_MAX BUFSIZ
2016-06-12 12:38:43 +02:00
2016-12-23 01:33:52 +01:00
#define CONNECTION 0
2016-12-20 23:36:00 +01:00
#define APPLICATION 1
2016-12-23 01:33:52 +01:00
#define CON_APP 2
2016-12-20 23:36:00 +01:00
2018-10-04 00:30:47 +02:00
struct ipc_service {
unsigned int version;
unsigned int index;
2016-06-05 20:48:13 +02:00
char spath[PATH_MAX];
2016-10-28 13:58:04 +02:00
int service_fd;
};
// 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-03 21:24:20 +02:00
int ipc_server_init (int argc, char **argv, 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-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 01:22:50 +02:00
int ipc_server_select (struct ipc_client_array *, struct ipc_service *, struct ipc_client_array *);
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
// send the connection string to $TMP/<service>
2016-12-17 18:00:04 +01:00
// fill srv->spath && srv->service_fd
2018-10-03 21:24:20 +02:00
int ipc_application_connection (int argc, char **argv, char **env
2018-10-04 00:30:47 +02:00
, struct ipc_service *, const char *, const char *, size_t);
int ipc_application_close (struct ipc_service *);
2016-10-28 13:58:04 +02:00
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