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

38 lines
1.2 KiB
C
Raw Normal View History

2018-10-03 21:52:11 +02:00
#ifndef __IPC_MSG_H__
#define __IPC_MSG_H__
2016-12-21 01:26:47 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2016-12-23 13:06:31 +01:00
#define MSG_TYPE_CLOSE 0
2016-12-23 01:33:52 +01:00
#define MSG_TYPE_CON 1
2016-12-23 13:06:31 +01:00
#define MSG_TYPE_ERR 2
#define MSG_TYPE_ACK 3
#define MSG_TYPE_DATA 4
2016-12-21 01:26:47 +01:00
2018-10-03 22:02:37 +02:00
struct ipc_message {
2016-12-21 01:26:47 +01:00
char type;
2018-10-04 01:54:12 +02:00
unsigned short length;
char *payload;
2016-12-21 01:26:47 +01:00
};
// used to create msg structure from buffer
2018-10-03 22:02:37 +02:00
int ipc_message_format_read (struct ipc_message *m, const char *buf, size_t msize);
2016-12-21 01:26:47 +01:00
// used to create buffer from msg structure
2018-10-03 22:02:37 +02:00
int ipc_message_format_write (const struct ipc_message *m, char **buf, size_t *msize);
2016-12-21 01:26:47 +01:00
// read a structure msg from fd
2018-10-03 22:02:37 +02:00
int ipc_message_read (int fd, struct ipc_message *m);
2016-12-21 01:26:47 +01:00
// write a structure msg to fd
2018-10-03 22:02:37 +02:00
int ipc_message_write (int fd, const struct ipc_message *m);
2016-12-21 01:26:47 +01:00
2018-10-04 01:54:12 +02:00
int ipc_message_format_con (struct ipc_message *m, const char *payload, size_t length);
int ipc_message_format_data (struct ipc_message *m, const char *payload, size_t length);
int ipc_message_format_ack (struct ipc_message *m, const char *payload, size_t length);
2016-12-21 01:26:47 +01:00
2018-10-03 22:02:37 +02:00
int ipc_message_free (struct ipc_message *m);
void ipc_message_print (const struct ipc_message *m);
2016-12-21 01:26:47 +01:00
#endif