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/pubsub/lib/message.h

42 lines
1.3 KiB
C
Raw Normal View History

2018-10-09 16:38:27 +02:00
#ifndef __PUBSUB_MSG_H__
#define __PUBSUB_MSG_H__
2018-10-30 11:13:30 +01:00
#include "../../core/ipc.h"
#define PUBSUB_SUBSCRIBER_ACTION_STR_PUB "pub"
#define PUBSUB_SUBSCRIBER_ACTION_STR_SUB "sub"
enum subscriber_action {PUBSUB_PUB, PUBSUB_SUB};
#define PUBSUB_TYPE_MESSAGE 1
#define PUBSUB_TYPE_ERROR 2
#define PUBSUB_TYPE_DEBUG 4
#define PUBSUB_TYPE_INFO 5
enum pubsub_message_types {
PUBSUB_MSG_TYPE_SUB
, PUBSUB_MSG_TYPE_UNSUB
, PUBSUB_MSG_TYPE_PUB
};
2018-10-09 16:38:27 +02:00
struct pubsub_msg {
2018-10-30 13:18:53 +01:00
enum pubsub_message_types type; // message type : alert, notification, …
2018-10-09 16:38:27 +02:00
char *chan;
size_t chanlen;
char *data;
size_t datalen;
};
2018-10-30 11:13:30 +01:00
void pubsub_message_from_message (struct pubsub_msg *msg, struct ipc_message *m);
void pubsub_message_to_message (const struct pubsub_msg *msg, struct ipc_message *m);
void pubsub_message_set_chan (struct pubsub_msg *pm, char *chan, size_t len);
void pubsub_message_set_data (struct pubsub_msg *pm, char *data, size_t len);
void pubsub_message_empty (struct pubsub_msg *msg);
2018-10-09 16:38:27 +02:00
void pubsub_message_print (const struct pubsub_msg *msg);
2018-10-30 11:13:30 +01:00
int pubsub_message_send (struct ipc_service *srv, const struct pubsub_msg * m);
2018-10-09 16:38:27 +02:00
#endif