2 rxpd.h - regex policy daemon
5 2007, Christian Thaeter <ct@pipapo.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
41 #define RXPD_COMMANDS \
53 #define RXPD_CMD(cmd) RXPD_CMD_##cmd,
62 struct rxpd_connection;
69 llist sockets_pending;
71 llist connections_pending;
72 llist connections_active;
77 rxpd_init (char* rulesdir);
93 rxpd_rule_new (const char* buf);
96 rxpd_rule_delete (struct rxpd_rule*);
104 //TODO later struct stat last_stat;
109 rxpd_file_load (struct rxpd_base* base, const char* filename);
112 rxpd_file_delete (PSplay file);
115 rxpd_file_cmp (const void* A, const void* B);
125 struct rxpd_base* base;
130 rxpd_socket_new_tcp4 (struct rxpd_base* base, const char* addr, unsigned short port);
132 //struct rxpd_socket*
133 //rxpd_socket_new_unix (struct rxpd_base* base, const char* name);
136 rxpd_socket_delete (struct rxpd_socket* self);
139 rxpd_socket_accept (int sock, short event, void* ptr);
142 rxpd_socket_activate (struct rxpd_socket* self);
145 rxpd_socket_suspend (struct rxpd_socket* self);
150 enum rxpd_buffer_state_e
152 RXPD_OK, // operational
153 RXPD_EOF, // connection closed
154 RXPD_ERROR // some other error
159 struct rxpd_connection* conn;
160 enum rxpd_buffer_state_e state;
167 rxpd_buffer_init (struct rxpd_buffer* self, struct rxpd_connection* conn);
170 rxpd_buffer_readline (struct rxpd_buffer* self, int again);
172 inline static enum rxpd_buffer_state_e
173 rxpd_buffer_state (struct rxpd_buffer* self)
180 struct rxpd_connection
185 struct rxpd_base* base;
186 struct rxpd_file* file;
188 struct sockaddr peer_addr;
190 struct rxpd_buffer in;
191 struct rxpd_buffer out;
195 struct rxpd_connection*
196 rxpd_connection_new (struct rxpd_base* base, int accept_fd);
199 rxpd_connection_delete (struct rxpd_connection* self);
202 struct rxpd_connection*
203 rxpd_connection_activate (struct rxpd_connection* self);
206 struct rxpd_connection*
207 rxpd_connection_suspend (struct rxpd_connection* self);
211 rxpd_connection_readline (struct rxpd_connection* self);
214 rxpd_connection_parse_cmd (int sock, short event, void* ptr);
216 /* generate prototypes for each defined command */
217 #define RXPD_CMD(cmd) void rxpd_connection_cmd_##cmd (int sock, short event, void* ptr);