added some error messages/cleanup
authorChristian Thaeter <ct@pipapo.org>
Fri, 5 Oct 2007 14:03:06 +0000 (16:03 +0200)
committerChristian Thaeter <ct@pipapo.org>
Fri, 5 Oct 2007 14:03:06 +0000 (16:03 +0200)
rxpd.c
rxpd.h

diff --git a/rxpd.c b/rxpd.c
index 93e5277..4c587d9 100644 (file)
--- a/rxpd.c
+++ b/rxpd.c
@@ -21,7 +21,7 @@
 
 #include "rxpd.h"
 
-static struct rxpd_base global_base = {NULL};
+static struct rxpd_base global_base;
 
 struct rxpd_base*
 rxpd_init (char* rulesdir)
@@ -473,7 +473,6 @@ rxpd_connection_suspend (struct rxpd_connection* self)
   return self;
 }
 
-
 void
 rxpd_connection_parse_cmd (int fd, short event, void* ptr)
 {
@@ -485,13 +484,11 @@ rxpd_connection_parse_cmd (int fd, short event, void* ptr)
 
   if (!line)
     {
-      printf ("got no data\n");
+      rxpd_buffer_printf (&self->out, "#ERROR: no data\n");
       close (fd);
       return;
     }
 
-
-
   static const struct cmd_table
   {
     enum rxpd_cmd_e nr;
@@ -533,54 +530,70 @@ case RXPD_CMD_##cmd:
 void
 rxpd_connection_cmd_CHECK (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_APPEND (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_PREPEND (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_REMOVE (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_REPLACE (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_LOAD (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_SAVE (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_DUMP (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
 void
 rxpd_connection_cmd_LIST (int fd, short event, void* ptr)
 {
-  printf ("%s\n", __func__);
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
+}
+
+void
+rxpd_connection_cmd_SHUTDOWN (int fd, short event, void* ptr)
+{
+  struct rxpd_connection* self = (struct rxpd_connection*) ptr;
+  rxpd_buffer_printf (&self->out, "#ERROR: unimplemented command %s\n", &__func__[20]);
 }
 
diff --git a/rxpd.h b/rxpd.h
index 43d0185..53ab46a 100644 (file)
--- a/rxpd.h
+++ b/rxpd.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)
+#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,
 enum rxpd_cmd_e {RXPD_COMMANDS};