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 \
52 #define RXPD_CMD(cmd) RXPD_CMD_##cmd,
53 enum rxpd_cmd_e {RXPD_COMMANDS};
61 struct rxpd_connection;
68 llist sockets_pending;
70 llist connections_pending;
71 llist connections_active;
76 rxpd_init (char* rulesdir);
92 rxpd_rule_new (const char* buf);
95 rxpd_rule_delete (struct rxpd_rule*);
103 //TODO later struct stat last_stat;
108 rxpd_file_load (struct rxpd_base* base, const char* filename);
111 rxpd_file_delete (PSplay file);
114 rxpd_file_cmp (const void* A, const void* B);
124 struct rxpd_base* base;
129 rxpd_socket_new_tcp4 (struct rxpd_base* base, const char* addr, unsigned short port);
131 //struct rxpd_socket*
132 //rxpd_socket_new_unix (struct rxpd_base* base, const char* name);
135 rxpd_socket_delete (struct rxpd_socket* self);
138 rxpd_socket_accept (int sock, short event, void* ptr);
141 rxpd_socket_activate (struct rxpd_socket* self);
144 rxpd_socket_suspend (struct rxpd_socket* self);
149 enum rxpd_buffer_state_e
151 RXPD_OK, // operational
152 RXPD_EOF, // connection closed
153 RXPD_ERROR // some other error
158 struct rxpd_connection* conn;
159 enum rxpd_buffer_state_e state;
166 rxpd_buffer_init (struct rxpd_buffer* self, struct rxpd_connection* conn);
169 rxpd_buffer_readline (struct rxpd_buffer* self, int again);
171 inline static enum rxpd_buffer_state_e
172 rxpd_buffer_state (struct rxpd_buffer* self)
179 struct rxpd_connection
184 struct rxpd_base* base;
185 struct rxpd_file* file;
187 struct sockaddr peer_addr;
189 struct rxpd_buffer in;
190 struct rxpd_buffer out;
194 struct rxpd_connection*
195 rxpd_connection_new (struct rxpd_base* base, int accept_fd);
198 rxpd_connection_delete (struct rxpd_connection* self);
201 struct rxpd_connection*
202 rxpd_connection_activate (struct rxpd_connection* self);
205 struct rxpd_connection*
206 rxpd_connection_suspend (struct rxpd_connection* self);
210 rxpd_connection_readline (struct rxpd_connection* self);
213 rxpd_connection_parse_cmd (int fd, short event, void* ptr);
215 /* generate prototypes for each defined command */
216 #define RXPD_CMD(cmd) void rxpd_connection_cmd_##cmd (int fd, short event, void* ptr);