" 2007, Christian Thaeter <ct@pipapo.org>\n\n"
" This is free software. You may redistribute copies of it under the terms of\n"
" the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n"
- " There is NO WARRANTY, to the extent permitted by law.\n"
+ " There is NO WARRANTY, to the extent permitted by law.\n\n"
+ " http://www.pipapo.org/pipawiki/RegexPolicyDaemon\n"
);
}
#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(VERSION) \
- RXPD_CMD(HELP) \
- RXPD_CMD(EXPIRE) \
- RXPD_CMD(SHUTDOWN)
-
-#define RXPD_CMD(cmd) RXPD_CMD_##cmd,
+#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(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_STRING) \
+ 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
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
size_t sz;
} cmds[] =
{
-#define RXPD_CMD(cmd) {RXPD_CMD_##cmd, #cmd":", sizeof (#cmd)},
+#define RXPD_CMD(cmd, _) {RXPD_CMD_##cmd, #cmd":", sizeof (#cmd)},
RXPD_COMMANDS
#undef RXPD_CMD
{0, NULL, 0}
// dispatch
switch (i->nr)
{
-#define RXPD_CMD(cmd) \
+#define RXPD_CMD(cmd, _) \
case RXPD_CMD_##cmd: \
event_set (&self->ev, self->fd, EV_READ, rxpd_connection_cmd_##cmd, self); \
rxpd_connection_cmd_##cmd (fd, 0, ptr); \
(void) event;
struct rxpd_connection* self = (struct rxpd_connection*) ptr;
//struct rxpd_base* base = self->socket->base;
- rxpd_die ("Unimplemented\n");
+ rxpd_buffer_printf (&self->out, "# Available commands:\n\n");
+#define RXPD_CMD(cmd, help) rxpd_buffer_printf (&self->out, "%s %s.\n", #cmd, help);
+ RXPD_COMMANDS
+#undef RXPD_CMD
+ rxpd_buffer_printf (&self->out, "\n# general syntax is: 'COMMAND:listname\\n..data..'\n");
+ rxpd_connection_delete (self);
}
void