#ifndef CONTEXT_H_ #define CONTEXT_H_ #include #include #include enum mxdbg_packet_type; struct packet; struct mxdbg_packet; struct debug_context; typedef void (*event_callback_t)(struct debug_context *, struct packet *); struct debug_context { bool ctx_quit; int ctx_sock; pthread_mutex_t ctx_sock_lock; fx_queue ctx_packets; pthread_mutex_t ctx_packet_lock; pthread_cond_t ctx_packet_cond; pthread_t ctx_packet_thread; pthread_t ctx_event_thread; event_callback_t ctx_on_event; }; extern void debug_context_init(struct debug_context *ctx); extern void debug_context_cleanup(struct debug_context *ctx); extern void debug_context_start_threads(struct debug_context *ctx); extern int debug_context_connect_net( struct debug_context *ctx, const char *address, int port); extern int debug_context_recv( struct debug_context *ctx, void *p, size_t len, size_t *nr_read); extern int debug_context_send_packet( struct debug_context *ctx, const struct mxdbg_packet *packet); extern int debug_context_recv_packet_data( struct debug_context *ctx, struct mxdbg_packet *packet, size_t *nr_read); extern struct packet *debug_context_await_packet( struct debug_context *ctx, enum mxdbg_packet_type packet_type); #endif