[augeas-devel] [PATCH 3/4] new lens for Thttpd.

Marc Fournier marc.fournier at camptocamp.com
Mon Oct 8 07:01:26 UTC 2012


---
 lenses/tests/test_thttpd.aug |   45 ++++++++++++++++++++++++++++++++++++++++++
 lenses/thttpd.aug            |   34 +++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
 create mode 100644 lenses/tests/test_thttpd.aug
 create mode 100644 lenses/thttpd.aug

diff --git a/lenses/tests/test_thttpd.aug b/lenses/tests/test_thttpd.aug
new file mode 100644
index 0000000..26ba5f1
--- /dev/null
+++ b/lenses/tests/test_thttpd.aug
@@ -0,0 +1,45 @@
+(*
+Module: Test_Thttpd
+  Provides unit tests for the <Thttpd> lens.
+*)
+
+module Test_Thttpd =
+
+let conf = "# This file is for thttpd processes created by /etc/init.d/thttpd.
+# Commentary is based closely on the thttpd(8) 2.25b manpage, by Jef Poskanzer.
+
+# Specifies an alternate port number to listen on.
+port=80
+host=
+
+  dir=/var/www
+chroot
+  novhost
+
+  # Specifies what user to switch to after initialization when started as root.
+user=www-data # EOL comment
+nosymlinks # EOL comment
+"
+
+test Thttpd.lns get conf =
+  { "#comment" = "This file is for thttpd processes created by /etc/init.d/thttpd." }
+  { "#comment" = "Commentary is based closely on the thttpd(8) 2.25b manpage, by Jef Poskanzer." }
+  { }
+  { "#comment" = "Specifies an alternate port number to listen on." }
+  { "port" = "80" }
+  { "host" = "" }
+  { }
+  { "dir" = "/var/www" }
+  { "chroot" }
+  { "novhost" }
+  { }
+  { "#comment" = "Specifies what user to switch to after initialization when started as root." }
+  { "user" = "www-data"
+    { "#comment" = "EOL comment" }
+  }
+  { "nosymlinks"
+    { "#comment" = "EOL comment" }
+  }
+
+(* There must not be spaces around the '=' *)
+test Thttpd.lns get "port = 80" = *
diff --git a/lenses/thttpd.aug b/lenses/thttpd.aug
new file mode 100644
index 0000000..84a4337
--- /dev/null
+++ b/lenses/thttpd.aug
@@ -0,0 +1,34 @@
+(*
+Module: Thttpd
+  Parses Thttpd's configuration files
+
+Author: Marc Fournier <marc.fournier at camptocamp.com>
+
+About: License
+  This file is licensed under the LGPL v2+, like the rest of Augeas.
+*)
+
+module Thttpd =
+autoload xfm
+
+let comment     = Util.comment
+let comment_eol = Util.comment_generic /[ \t]*[#][ \t]*/ " # "
+let empty       = Util.empty
+let eol         = Util.del_str "\n"
+let bol         = Util.del_opt_ws ""
+
+let kvkey       = /(port|dir|data_dir|user|cgipat|throttles|host|logfile|pidfile|charset|p3p|max_age)/
+let flag        = /(no){0,1}(chroot|symlinks|vhost|globalpasswd)/
+let val         = /[^\n# \t]*/
+
+let kventry     = key kvkey . Util.del_str "=" . store val
+let flagentry   = key flag
+
+let kvline      = [ bol . kventry . (eol|comment_eol) ]
+let flagline    = [ bol . flagentry . (eol|comment_eol) ]
+
+let lns         = (kvline|flagline|comment|empty)*
+
+let filter      = incl "/etc/thttpd/thttpd.conf"
+
+let xfm         = transform lns filter
-- 
1.7.10.4




More information about the augeas-devel mailing list