From 2b86c851562f86f69acbf4b773107077680d5068 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 7 Apr 2017 23:59:03 +0200 Subject: Push weechat plugin --- weechat/net.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 weechat/net.h (limited to 'weechat/net.h') diff --git a/weechat/net.h b/weechat/net.h new file mode 100644 index 0000000..59f5f45 --- /dev/null +++ b/weechat/net.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include "global.h" + + +enum net_response_type{ + NET_OK, + NET_ERROR, + NET_NAME, + NET_LIST, + NET_HISTORY, + NET_MESSAGE, +}; + +struct net_history_item{ + char *username; + i64 timestamp; + char *message; +}; + +struct net_response{ + enum net_response_type type; + union { + char *error; + char *name; + struct { + int nitems; + char **items; + }; + struct { + int nhistory; + struct net_history_item *history; + }; + struct { + char *room; + char *username; + i64 timestamp; + char *message; + }; + }; +}; + +typedef void net_callback_t(int fd,struct net_response res,void *payload); + + +void net_set_push_callback(net_callback_t *callback); +void net_set_history_callback(net_callback_t *callback); + +bool net_sendf(int fd,net_callback_t *callback,void *payload,const char *format,...) + __attribute__((format (printf, 4, 5))); + +void net_handle_recv(int fd,const char *msg); -- cgit v1.2.3-54-g00ecf