handle file part of a command
authorChristian Thaeter <ct@pipapo.org>
Fri, 5 Oct 2007 14:03:44 +0000 (16:03 +0200)
committerChristian Thaeter <ct@pipapo.org>
Fri, 5 Oct 2007 14:03:44 +0000 (16:03 +0200)
rxpd.c

diff --git a/rxpd.c b/rxpd.c
index 4c587d9..2e67559 100644 (file)
--- a/rxpd.c
+++ b/rxpd.c
@@ -508,11 +508,27 @@ rxpd_connection_parse_cmd (int fd, short event, void* ptr)
       break;
   if (!i->cmd)
     {
-      printf ("no command\n");
+      rxpd_buffer_printf (&self->out, "#ERROR: no command\n");
       rxpd_connection_delete (self);
       return;
     }
-  // TODO policy check
+  // TODO policy check here
+
+  if (line[i->sz])
+    {
+      // rulename provided
+      self->file = (struct rxpd_file*) psplay_find (&self->base->files, &line[i->sz]);
+      if (!self->file)
+        {
+          self->file = rxpd_file_new (self->base, &line[i->sz]);
+          if (!self->file)
+            {
+              rxpd_buffer_printf (&self->out, "#ERROR: illegal rule\n");
+              rxpd_connection_delete (self);
+              return;
+            }
+        }
+    }
 
   // dispatch
   switch (i->nr)