diff options
Diffstat (limited to 'src/lib/include/kogata/gip.h')
-rw-r--r-- | src/lib/include/kogata/gip.h | 56 |
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 :*/ |