HELP command
authorChristian Thaeter <ct@pipapo.org>
Tue, 16 Oct 2007 17:20:08 +0000 (19:20 +0200)
committerChristian Thaeter <ct@pipapo.org>
Tue, 16 Oct 2007 17:20:08 +0000 (19:20 +0200)
src/main.c
src/rxpd.h
src/rxpd_connection.c
src/rxpd_connection_cmd.c

index 59d1400..961c6eb 100644 (file)
@@ -39,7 +39,8 @@ version (void)
           "    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"
           );
 }
 
index 0a4e8ad..24ee56d 100644 (file)
 #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
 
@@ -253,7 +253,7 @@ 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
 
index 00acbff..2c99877 100644 (file)
@@ -140,7 +140,7 @@ rxpd_connection_parse_cmd (int fd, short event, void* ptr)
     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}
@@ -186,7 +186,7 @@ rxpd_connection_parse_cmd (int fd, short event, void* ptr)
   // 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);                                       \
index 5fb035c..ab6f72a 100644 (file)
@@ -404,7 +404,12 @@ rxpd_connection_cmd_HELP (int fd, short event, void* 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