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,
54 enum rxpd_cmd_e {RXPD_COMMANDS};
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*);
103 psplay node; // key points to basename part of filename
104 const char* filename; // full filename
105 //TODO later struct stat last_stat;
110 rxpd_file_new (struct rxpd_base* base, const char* filename);
113 rxpd_file_delete (PSplay file);
116 rxpd_file_load (struct rxpd_file* self);
119 rxpd_file_cmp (const void* A, const void* B);
129 struct rxpd_base* base;
134 rxpd_socket_new_tcp4 (struct rxpd_base* base, const char* addr, unsigned short port);
136 //struct rxpd_socket*
137 //rxpd_socket_new_unix (struct rxpd_base* base, const char* name);
140 rxpd_socket_delete (struct rxpd_socket* self);
143 rxpd_socket_accept (int sock, short event, void* ptr);
146 rxpd_socket_schedule (struct rxpd_socket* self);
149 rxpd_socket_suspend (struct rxpd_socket* self);
154 enum rxpd_buffer_state_e
156 RXPD_OK, // operational
157 RXPD_EOF, // connection closed
158 RXPD_ERROR // some other error
163 struct rxpd_connection* conn;
164 enum rxpd_buffer_state_e state;
171 rxpd_buffer_init (struct rxpd_buffer* self, struct rxpd_connection* conn);
174 rxpd_buffer_readline (struct rxpd_buffer* self, int again);
176 inline static enum rxpd_buffer_state_e
177 rxpd_buffer_state (struct rxpd_buffer* self)
184 struct rxpd_connection
189 struct rxpd_base* base;
190 struct rxpd_file* file;
193 struct sockaddr peer_addr;
195 struct rxpd_buffer in;
196 struct rxpd_buffer out;
200 struct rxpd_connection*
201 rxpd_connection_new (struct rxpd_base* base, int accept_fd);
204 rxpd_connection_delete (struct rxpd_connection* self);
207 struct rxpd_connection*
208 rxpd_connection_schedule (struct rxpd_connection* self);
211 struct rxpd_connection*
212 rxpd_connection_suspend (struct rxpd_connection* self);
216 rxpd_connection_readline (struct rxpd_connection* self);
219 rxpd_connection_parse_cmd (int fd, short event, void* ptr);
221 /* generate prototypes for each defined command */
222 #define RXPD_CMD(cmd) void rxpd_connection_cmd_##cmd (int fd, short event, void* ptr);