]> www.average.org Git - psmb.git/blob - include/psmb.h
wip send/recv
[psmb.git] / include / psmb.h
1 #ifndef _PSMB_H
2
3 #include <stdlib.h>
4 #include <stdbool.h>
5 #include <netinet/in.h>
6
7 typedef struct _psmb_ctx psmb_ctx_t;
8 typedef struct _psmb_result { int code; } psmb_result_t;
9
10 psmb_ctx_t *psmb_new(void);
11 psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size),
12         void (*free)(void *ptr),
13         void *(*realloc)(void *ptr, size_t size));
14 psmb_result_t psmb_set_logf(psmb_ctx_t *ctx,
15         void (*logf)(void *log_priv, int priority, const char *format, ...),
16         void *log_priv);
17 psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu);
18 psmb_result_t psmb_set_port(psmb_ctx_t *ctx, unsigned short pmtu);
19 psmb_result_t psmb_set_mgrp(psmb_ctx_t *ctx, struct in6_addr prefix,
20         unsigned char prefixlen);
21 psmb_result_t psmb_open(psmb_ctx_t *ctx);
22 void psmb_destroy(psmb_ctx_t *ctx);
23 int psmb_getfd(psmb_ctx_t *ctx);
24 bool psmb_success(psmb_result_t result);
25 bool psmb_message_waiting(psmb_result_t result);
26 bool psmb_need_write_wait(psmb_result_t result);
27 psmb_result_t psmb_ev_rd(psmb_ctx_t *ctx);
28 psmb_result_t psmb_ev_wr(psmb_ctx_t *ctx);
29 psmb_result_t psmb_ev_ex(psmb_ctx_t *ctx);
30 psmb_result_t psmb_subscribe(psmb_ctx_t *ctx, char *channel);
31 psmb_result_t psmb_unsubscribe(psmb_ctx_t *ctx, char *channel);
32 psmb_result_t psmb_publish(psmb_ctx_t *ctx, char *channel,
33         void *data, size_t size);
34 psmb_result_t psmb_get_message(psmb_ctx_t *ctx, char **channel,
35         void **data, size_t *size);
36 psmb_result_t psmb_acknowledge(psmb_ctx_t *ctx);
37
38 #endif