Reads Postfix's main.cf and expands parameter values the way Postfix
does, for Sovite.Core.Postfix.Migration.
The file has one name = value per logical line. Lines whose first
non-whitespace character is # are comments, and a line that starts
with whitespace continues the one before it. Values can refer to other
parameters as $name, ${name}, or $(name), and use the conditional
forms ${name?value} (value when $name is not empty),
${name:value} (when it is empty), and ${name?{value1}:{value2}}.
$$ is a literal $. Parameters not in the file get Postfix's
defaults, for the ones the migration needs.
The file is untrusted input: names stay strings.
Summary
Functions
Expands the parameter references in text.
The expanded value of name, split into a list. See split/1.
Splits Postfix configuration text into logical lines: comments and
blank lines are dropped, and lines starting with whitespace are joined
to the one before. Returns {line_number, text} pairs.
The names the file sets, in file order.
Parses contents. defaults override Postfix's built-in defaults,
such as "myhostname" (the system's host name) and
"config_directory".
The value of name as written in the file, or nil.
Whether the file sets name.
Splits a list value on whitespace and commas, keeping { ... } groups
(and type:{ ... } tables) together.
Strips the braces of a { ... } group and the whitespace inside.
Other text is returned trimmed.
The expanded value of name: from the file, or the default. Unknown
parameters are empty, as in Postfix.
Types
Functions
Expands the parameter references in text.
The expanded value of name, split into a list. See split/1.
@spec logical_lines(String.t()) :: [{pos_integer(), String.t()}]
Splits Postfix configuration text into logical lines: comments and
blank lines are dropped, and lines starting with whitespace are joined
to the one before. Returns {line_number, text} pairs.
iex> Sovite.Core.Postfix.MainCf.logical_lines("a = 1\n 2\n# c\nb = 3\n")
[{1, "a = 1 2"}, {4, "b = 3"}]
The names the file sets, in file order.
Parses contents. defaults override Postfix's built-in defaults,
such as "myhostname" (the system's host name) and
"config_directory".
The value of name as written in the file, or nil.
Whether the file sets name.
Splits a list value on whitespace and commas, keeping { ... } groups
(and type:{ ... } tables) together.
iex> Sovite.Core.Postfix.MainCf.split("a, b c,{ d, e }, inline:{ x=1, y=2 }")
["a", "b", "c", "{ d, e }", "inline:{ x=1, y=2 }"]
Strips the braces of a { ... } group and the whitespace inside.
Other text is returned trimmed.
iex> Sovite.Core.Postfix.MainCf.ungroup("{ a = b }")
"a = b"
The expanded value of name: from the file, or the default. Unknown
parameters are empty, as in Postfix.