static void policy_answer(server_t *pcy, const char *fmt, ...)
{
va_list args;
- query_t* query = pcy->data;
+ const query_t* query = pcy->data;
buffer_addstr(&pcy->obuf, "action=");
va_start(args, fmt);
epoll_modify(pcy->fd, EPOLLIN | EPOLLOUT, pcy);
}
+static bool policy_run_filter(const query_t* query, void* filter, void* conf)
+{
+ return false;
+}
+
static void policy_process(server_t *pcy)
{
- policy_answer(pcy, "DUNNO");
+ const query_t* query = pcy->data;
+ if (!policy_run_filter(query, NULL, NULL)) {
+ policy_answer(pcy, "DUNNO");
+ }
}
static int policy_run(server_t *pcy, void* config)
#include "server.h"
#include "epoll.h"
+static server_t *listeners[1024];
+static int listener_count = 0;
+
+
static server_t* server_new(void)
{
server_t* server = p_new(server_t, 1);
}
}
+static void server_shutdown(void)
+{
+ for (int i = 0 ; i < listener_count ; ++i) {
+ server_delete(&listeners[i]);
+ }
+}
+
+module_exit(server_shutdown);
+
int start_server(int port, start_listener_t starter, delete_client_t deleter)
{
struct sockaddr_in addr = {
tmp->data = data;
tmp->clear_data = deleter;
epoll_register(sock, EPOLLIN, tmp);
+ listeners[listener_count++] = tmp;
return 0;
}