+struct listener_t {
+ server_io_t io;
+};
+
+struct client_t {
+ server_io_t io;
+
+ buffer_t ibuf;
+ buffer_t obuf;
+
+ run_client_t run;
+ delete_client_t clear_data;
+ void* data;
+};
+
+
+static PA(listener_t) listeners = ARRAY_INIT;
+static PA(client_t) client_pool = ARRAY_INIT;
+
+static struct ev_loop *gl_loop = NULL;
+static start_client_t gl_client_start = NULL;
+static delete_client_t gl_client_delete = NULL;
+static run_client_t gl_client_run = NULL;
+static refresh_t gl_config_refresh = NULL;
+static void *gl_config = NULL;
+
+
+/* Server io structure methods.
+ */
+
+static inline void server_io_wipe(server_io_t *io)
+{
+ if (io->fd >= 0) {
+ ev_io_stop(gl_loop, &io->io);
+ close(io->fd);
+ io->fd = -1;
+ }
+}
+
+
+/* Client methods.
+ */
+
+/* 1 - managing clients */
+
+static client_t* client_new(void)