ALSA project - the C library reference
|
Configuration files use a simple format allowing modern data description like nesting and array assignments.
Whitespace is the collective name given to spaces (blanks), horizontal and vertical tabs, newline characters, and comments. Whitespace can indicate where configuration tokens start and end, but beyond this function, any surplus whitespace is discarded. For example, the two sequences
and
are lexically equivalent and parse identically to give the four tokens:
The ASCII characters representing whitespace can occur within literal strings, in which case they are protected from the normal parsing process (they remain as part of the string). For example:
parses to two tokens, including the single literal-string token "John Smith".
A special case occurs if a newline character in a string is preceded by a backslash (). The backslash and the new line are both discarded, allowing two physical lines of text to be treated as one unit.
is parsed as "John Smith".
A single-line comment begins with the character #. The comment can start at any position, and extends to the end of the line.
To include another configuration file, write the file name in angle brackets. The prefix confdir:
will reference the global configuration directory.
The configuration punctuators (also known as separators) are:
Opening and closing braces { } indicate the start and end of a compound statement:
Opening and closing brackets indicate a single array definition. The identifiers are automatically generated starting with zero.
The above code is equal to
The comma (,) or semicolon (;) can separate value assignments. It is not strictly required to use these separators because whitespace suffices to separate tokens.
The equal sign (=) can separate variable declarations from initialization lists:
Using equal signs is not required because whitespace suffices to separate tokens.
The configuration file defines id (key) and value pairs. The id (key) can be composed from ASCII digits, characters from a to z and A to Z, and the underscore (_). The value can be either a string, an integer, a real number, or a compound statement.
By default, the node operation mode is 'merge+create', i.e., if a configuration node is not present a new one is created, otherwise the latest assignment is merged (if possible - type checking). The 'merge+create' operation mode is specified with the prefix character plus (+).
The operation mode 'merge' merges the node with the old one (which must exist). Type checking is done, so strings cannot be assigned to integers and so on. This mode is specified with the prefix character minus (-).
The operation mode 'do not override' ignores a new configuration node if a configuration node with the same name exists. This mode is specified with the prefix character question mark (?).
The operation mode 'override' always overrides the old configuration node with new contents. This mode is specified with the prefix character exclamation mark (!).
Runtime arguments in configuration files Runtime functions in configuration files Hooks in configuration files