#include <netinet/in.h>
#include <arpa/inet.h>
#include <event.h>
-
-#define RXPD_COMMANDS \
- RXPD_CMD(CHECK) \
- RXPD_CMD(APPEND) \
- RXPD_CMD(PREPEND) \
- RXPD_CMD(REMOVE) \
- RXPD_CMD(REPLACE) \
- RXPD_CMD(LOAD) \
- RXPD_CMD(SAVE) \
- RXPD_CMD(DUMP) \
- RXPD_CMD(LIST) \
- RXPD_CMD(SHUTDOWN)
-
-#define RXPD_CMD(cmd) RXPD_CMD_##cmd,
+#include <time.h>
+
+#define RXPD_COMMANDS \
+ RXPD_CMD(CHECK, "data against regular expressions") \
+ RXPD_CMD(APPEND, "new rules to a list") \
+ RXPD_CMD(PREPEND, "new rules in front of a list") \
+ RXPD_CMD(REMOVE, "rules from a list") \
+ RXPD_CMD(REPLACE, "a rule in a list with new rules") \
+ RXPD_CMD(DELETE, "a list from memory") \
+ RXPD_CMD(LOAD, "a list from disk") \
+ RXPD_CMD(SAVE, "a list to disk") \
+ RXPD_CMD(EXPIRE, "aged rules from a list") \
+ RXPD_CMD(DUMP, "rules in a list") \
+ RXPD_CMD(LIST, "all existing lists") \
+ RXPD_CMD(VERSION, "of this rxpd is "PACKAGE_VERSION) \
+ RXPD_CMD(HELP, "is what you see right now") \
+ RXPD_CMD(SHUTDOWN, "the daemon")
+
+#define RXPD_CMD(cmd, _) RXPD_CMD_##cmd,
enum rxpd_cmd_e {RXPD_COMMANDS};
#undef RXPD_CMD
/*
* characters which are absolutely not allowed in rule filenames
- * for finer control use policies
+ * for finer control use policies, note that this are arbitary
+ * decisions also reserving some chars for later extension
*/
-#define RXPD_FILE_ILG_CHARS "/: \t\n*?"
+#define RXPD_FILE_ILG_CHARS "@&?<>|/: \t\n\r*?\\"
struct rxpd_base;
struct rxpd_file;
struct rxpd_file* policy;
struct event_base* eventbase;
- //-r resolve names
+ // TODO
//FILE* -l log log hits to logfile
psplayroot files;
{
llist node;
char* string;
+ time_t atime;
regex_t rx;
};
psplay node; // key points to basename part of filename
const char* filename; // full filename
//TODO later struct stat last_stat;
+ struct rxpd_base* base;
llist rules;
};
rxpd_file_new (struct rxpd_base* base, const char* filename);
void
-rxpd_file_delete (PSplay file);
+rxpd_file_delete (struct rxpd_file* file);
int
rxpd_file_load (struct rxpd_file* self);
int fd;
struct event ev;
struct rxpd_base* base;
+ int (*rxpd_socket_addr)(struct rxpd_connection* conn, char* dst, const char* pfx, size_t size);
};
struct rxpd_socket*
rxpd_socket_new_tcp4 (struct rxpd_base* base, const char* addr, unsigned short port);
+int
+rxpd_socket_tcp4addr (struct rxpd_connection* conn, char* dst, const char* pfx, size_t size);
+
+//TODO
//struct rxpd_socket*
//rxpd_socket_new_unix (struct rxpd_base* base, const char* name);
char*
rxpd_buffer_readline (struct rxpd_buffer* self, int again);
+int
+rxpd_buffer_printf (struct rxpd_buffer* self, const char* fmt, ...);
+
inline static enum rxpd_buffer_state_e
rxpd_buffer_state (struct rxpd_buffer* self)
{
{
int fd;
struct event ev;
- struct rxpd_base* base;
struct rxpd_file* file;
+ struct rxpd_socket* socket;
char* tmp_str;
llist tmp_list;
- struct sockaddr peer_addr;
-
struct rxpd_buffer in;
struct rxpd_buffer out;
};
struct rxpd_connection*
-rxpd_connection_new (struct rxpd_base* base, int accept_fd);
+rxpd_connection_new (struct rxpd_socket* socket, int accept_fd);
void
rxpd_connection_delete (struct rxpd_connection* self);
-
struct rxpd_connection*
rxpd_connection_schedule (struct rxpd_connection* self);
-
int
rxpd_connection_readline (struct rxpd_connection* self);
+int
+rxpd_connection_check_policy (struct rxpd_connection* self, char* line);
+
void
rxpd_connection_parse_cmd (int fd, short event, void* ptr);
/* generate prototypes for each defined command */
-#define RXPD_CMD(cmd) void rxpd_connection_cmd_##cmd (int fd, short event, void* ptr);
+#define RXPD_CMD(cmd, _) void rxpd_connection_cmd_##cmd (int fd, short event, void* ptr);
RXPD_COMMANDS
#undef RXPD_CMD