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/usocket.h

54 lines
1.1 KiB
C
Raw Normal View History

2018-10-03 21:52:11 +02:00
#ifndef __IPC_USOCKET_H__
#define __IPC_USOCKET_H__
2016-12-17 18:00:04 +01:00
#include <time.h>
#include <sys/socket.h>
#include <sys/un.h>
#define LISTEN_BACKLOG 128
2018-10-08 15:18:56 +02:00
#define TMPDIR "/run/ipc/"
#define PATH_MAX 4096
struct ipc_service {
unsigned int version;
unsigned int index;
char spath[PATH_MAX];
int service_fd;
};
/**
* for all functions: 0 ok, < 0 not ok
*/
// input: len = max buf size
// output: *sent = nb received bytes
int usock_send (const int fd, const char *buf, ssize_t len, ssize_t *sent);
// -1 on msize == NULL or buf == NULL
// -1 on unsupported errors from read(2)
// exit on most errors from read(2)
//
// allocation of *len bytes on *buf == NULL
//
// output: *len = nb sent bytes
int usock_recv (int fd, char **buf, ssize_t *len);
// -1 on close(2) < 0
2016-12-17 18:00:04 +01:00
int usock_close (int fd);
// same as connect(2)
2018-10-08 15:18:56 +02:00
// -1 on fd == NULL
int usock_connect (int *fd, const char *path);
int usock_init (int *fd, const char *path);
int usock_accept (int fd, int *pfd);
// same as unlink(2)
int usock_remove (const char *path);
2016-12-17 18:00:04 +01:00
2018-10-08 16:15:35 +02:00
static inline int ipc_service_empty (struct ipc_service *srv) { srv = srv; return 0 ;};
2016-12-17 18:00:04 +01:00
#endif