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

38 lines
1023 B
C
Raw Normal View History

2016-12-21 01:26:47 +01:00
#ifndef __MSG_H__
#define __MSG_H__
#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
struct msg {
char type;
2016-12-22 21:48:35 +01:00
unsigned short valsize;
2016-12-21 01:26:47 +01:00
char *val;
};
// used to create msg structure from buffer
int msg_format_read (struct msg *m, const char *buf, size_t msize);
// used to create buffer from msg structure
int msg_format_write (const struct msg *m, char **buf, size_t *msize);
2016-12-21 01:26:47 +01:00
// read a structure msg from fd
int msg_read (int fd, struct msg *m);
// write a structure msg to fd
int msg_write (int fd, const struct msg *m);
int msg_format_con (struct msg *m, const char *val, size_t valsize);
int msg_format_data (struct msg *m, const char *val, size_t valsize);
int msg_format_ack (struct msg *m, const char *val, size_t valsize);
int msg_free (struct msg *m);
void print_msg (const struct msg *m);
2016-12-21 01:26:47 +01:00
#endif