aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/kogata/gip.h
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2016-07-15 23:12:14 +0200
committerAlex Auvolat <alex@adnab.me>2016-07-15 23:12:14 +0200
commit32407e728971006ed3d0885e01c22fb66c8adc57 (patch)
tree89483d39e8e2638383f815d4e73b647334fe2fe9 /src/lib/include/kogata/gip.h
parentba4e59a1d687173ac5cfa74d26d71d6059dc6bc6 (diff)
downloadkogata-32407e728971006ed3d0885e01c22fb66c8adc57.tar.gz
kogata-32407e728971006ed3d0885e01c22fb66c8adc57.zip
Move stuff around, again
Diffstat (limited to 'src/lib/include/kogata/gip.h')
-rw-r--r--src/lib/include/kogata/gip.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/lib/include/kogata/gip.h b/src/lib/include/kogata/gip.h
new file mode 100644
index 0000000..1d1725a
--- /dev/null
+++ b/src/lib/include/kogata/gip.h
@@ -0,0 +1,56 @@
+#pragma once
+
+// Not thread safe
+
+#include <kogata/hashtbl.h>
+#include <kogata/mainloop.h>
+
+#include <proto/gip.h>
+
+typedef struct gip_handler gip_handler_t;
+
+typedef void (*noarg_gip_callback_t)(gip_handler_t *s, gip_msg_header *m);
+typedef void (*gip_reply_callback_t)(gip_handler_t *s, gip_msg_header *m, void* msg_data, void* cb_data);
+
+typedef struct {
+ noarg_gip_callback_t
+ reset, initiate, ok, failure,
+ enable_features, disable_features,
+ query_mode, set_mode, switch_buffer,
+ key_down, key_up;
+ void (*buffer_info)(gip_handler_t *s, gip_msg_header *m, gip_buffer_info_msg *i);
+ void (*mode_info)(gip_handler_t *s, gip_msg_header *m, gip_mode_info_msg *i);
+ void (*buffer_damage)(gip_handler_t *s, gip_msg_header *m, gip_buffer_damage_msg *i);
+ void (*unknown_msg)(gip_handler_t *s, gip_msg_header *m);
+ void (*fd_error)(gip_handler_t *s);
+} gip_handler_callbacks_t;
+
+typedef struct gip_handler {
+ gip_handler_callbacks_t* cb;
+ void* data;
+
+ gip_msg_header msg_buf;
+ gip_buffer_info_msg buffer_info_msg_buf;
+ gip_mode_info_msg mode_info_msg_buf;
+ gip_buffer_damage_msg buffer_damage_msg_buf;
+
+ hashtbl_t *requests_in_progress;
+ uint32_t next_req_id;
+
+ mainloop_fd_t mainloop_item;
+} gip_handler_t;
+
+gip_handler_t *new_gip_handler(gip_handler_callbacks_t *cb, void* data);
+void delete_gip_handler(gip_handler_t *h);
+
+// GIP send messages
+
+bool gip_cmd(gip_handler_t *h, gip_msg_header *msg, void* msg_data, gip_reply_callback_t cb, void* cb_data);
+
+bool gip_reply(gip_handler_t *h, gip_msg_header *orig_request, gip_msg_header *msg, void* msg_data);
+bool gip_reply_fail(gip_handler_t *h, gip_msg_header *o);
+bool gip_reply_ok(gip_handler_t *h, gip_msg_header *o);
+
+bool gip_notify(gip_handler_t *h, gip_msg_header *msg, void* msg_data);
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/