2017-01-19 22:07:52 +01:00
|
|
|
#ifndef __CHANNELS_H__
|
|
|
|
#define __CHANNELS_H__
|
|
|
|
|
|
|
|
#include "../../core/queue.h"
|
2018-10-04 01:22:50 +02:00
|
|
|
#include "../../core/client.h"
|
2017-01-19 22:07:52 +01:00
|
|
|
|
|
|
|
// head of the list
|
|
|
|
LIST_HEAD(channels, channel);
|
|
|
|
|
|
|
|
// element of the list
|
|
|
|
// channel : chan name + chan name length + a list of applications
|
|
|
|
struct channel {
|
|
|
|
char *chan;
|
|
|
|
size_t chanlen;
|
2018-10-04 22:51:31 +02:00
|
|
|
struct ipc_clients *subs;
|
2017-01-19 22:07:52 +01:00
|
|
|
LIST_ENTRY(channel) entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
// simple channel
|
|
|
|
int pubsubd_channel_new (struct channel *c, const char *name);
|
|
|
|
struct channel * pubsubd_channel_get (struct channels *chans, struct channel *c);
|
|
|
|
void pubsubd_channel_free (struct channel *c);
|
|
|
|
int pubsubd_channel_eq (const struct channel *c1, const struct channel *c2);
|
|
|
|
void pubsubd_channel_print (const struct channel *c);
|
|
|
|
|
|
|
|
// list of channels
|
|
|
|
void pubsubd_channels_init (struct channels *chans);
|
|
|
|
void pubsubd_channels_print (const struct channels *chans);
|
|
|
|
struct channel * pubsubd_channels_add (struct channels *chans, const char *chan);
|
|
|
|
void pubsubd_channels_del (struct channels *chans, struct channel *c);
|
|
|
|
void pubsubd_channels_del_all (struct channels *chans);
|
|
|
|
struct channel * pubsubd_channel_search (struct channels *chans, char *chan);
|
|
|
|
|
|
|
|
// add and remove subscribers
|
2018-10-04 00:30:47 +02:00
|
|
|
void pubsubd_channel_subscribe (const struct channel *c, struct ipc_client *p);
|
|
|
|
void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_client *p);
|
2017-01-19 22:07:52 +01:00
|
|
|
|
|
|
|
void pubsubd_channels_subscribe (struct channels *chans
|
2018-10-04 00:30:47 +02:00
|
|
|
, char *chname, struct ipc_client *p);
|
2017-01-19 22:07:52 +01:00
|
|
|
void pubsubd_channels_unsubscribe (struct channels *chans
|
2018-10-04 00:30:47 +02:00
|
|
|
, char *chname, struct ipc_client *p);
|
2017-01-19 22:07:52 +01:00
|
|
|
|
|
|
|
void pubsubd_channels_unsubscribe_everywhere (struct channels *chans
|
2018-10-04 00:30:47 +02:00
|
|
|
, struct ipc_client *p);
|
2017-01-19 22:07:52 +01:00
|
|
|
|
|
|
|
#endif
|