Created
December 29, 2013 17:32
-
-
Save Luzifer/8172663 to your computer and use it in GitHub Desktop.
Augeas lens to parse /etc/mail/sendmail.conf file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Module: Sendmail | |
Parses simple key = "value" conffiles | |
Author: Knut Ahlers <[email protected]> | |
About: License | |
This file is licenced under the LGPL v2+, like the rest of Augeas. | |
*) | |
module Sendmail = | |
autoload xfm | |
(* View: delim *) | |
let delim (op:string) = del (/[ \t]*/ . op . /[ \t]*/) | |
(" " . op . " ") | |
(* Variable: space_equal *) | |
let space_equal = delim "=" | |
(* Variable: word | |
An alphanumeric string *) | |
let word = /[A-Za-z0-9_.-]+/ | |
(************************************************************************ | |
* View: key_value | |
* Same as <key_value_line>, but does not end with an end of line | |
* | |
* Parameters: | |
* kw:regexp - the pattern to match as key | |
* sep:lens - the separator lens, which can be taken from the <Sep> module | |
* sto:lens - the storing lens | |
************************************************************************) | |
let key_value (kw: regexp) (sep:lens) (sto:lens) = | |
[ key kw . sep . sto ] | |
(* View: quote *) | |
let quote = del "\"" | |
(* Variable: to_comment_re *) | |
let to_comment_re = /[^"\n]*/ | |
(* View: entry *) | |
let entry = key_value word space_equal | |
(del /"/ "\"" . store to_comment_re . del /";/ "\";") | |
(* View: lns *) | |
let lns = (Util.empty | Util.comment | entry)* | |
(* Variable: filter *) | |
let filter = incl "/etc/mail/sendmail.conf" | |
let xfm = transform lns filter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment