#ifndef HOSTINFOD_H
#define HOSTINFOD_H
+#include <time.h>
+
#include <apr_general.h>
#include <apr_errno.h>
+#include <apr_pools.h>
+#include <apr_network_io.h>
+#include <apr_poll.h>
+
+enum guest_state {
+ guest_state_connecting, /* Connecting to socket. */
+ guest_state_request, /* Waiting or reading the request. */
+ guest_state_reply, /* Sending the reply. */
+ guest_state_dead /* Connection is dead. */
+};
+
+struct guest_description {
+ int counter;
+ apr_pool_t *pool; /* Pool for lifetime of guest connection. */
+ const char *name; /* "driver-name" */
+ const char *sock_path; /* Full path to socket. */
+ int sock; /* Real socket. */
+ apr_socket_t *aprsock; /* APR socket. */
+ apr_pollfd_t pollfd; /* APR poll descriptor. */
+ enum guest_state state; /* State of the connection. */
+
+ /* Increments every time guest does something bad, decremented once per min */
+ unsigned penalty;
+ time_t last_penalty_decr;
+
+ unsigned request_max; /* Max. length of request buffer. */
+ unsigned request_posn; /* Position in request buffer. */
+ char *request; /* Request buffer. */
+
+ unsigned reply_alloc; /* Allocated for reply buffer. */
+ unsigned reply_size; /* Size used in reply buffer. */
+ unsigned reply_posn; /* Position in reply buffer. */
+ char *reply; /* Reply buffer. */
+};
/* main.c */
extern const char *conf_file;
extern int sockets_inotify_fd;
extern void monitor_socket_dir (void);
+/* commands.c */
+extern void execute_command (time_t now, struct guest_description *hval, const char *command);
+
#endif /* HOSTINFOD_H */