1 Chris Hertel, Samba Team
4 This is a quick overview of the lexical analysis, syntax, and semantics
9 Basically, the file is processed on a line by line basis. There are
10 four types of lines that are recognized by the lexical analyzer
13 Blank lines - Lines containing only whitespace.
14 Comment lines - Lines beginning with either a semi-colon or a
15 pound sign (';' or '#').
16 Section header lines - Lines beginning with an open square bracket
18 Parameter lines - Lines beginning with any other character.
19 (The default line type.)
21 The first two are handled exclusively by the lexical analyzer, which
22 ignores them. The latter two line types are scanned for
28 These are the only tokens passed to the parameter loader
29 (loadparm.c). Parameter names and values are divided from one
30 another by an equal sign: '='.
33 Handling of Whitespace:
35 Whitespace is defined as all characters recognized by the isspace()
36 function (see ctype(3C)) except for the newline character ('\n')
37 The newline is excluded because it identifies the end of the line.
39 - The lexical analyzer scans past white space at the beginning of a
42 - Section and parameter names may contain internal white space. All
43 whitespace within a name is compressed to a single space character.
45 - Internal whitespace within a parameter value is kept verbatim with
46 the exception of carriage return characters ('\r'), all of which
49 - Leading and trailing whitespace is removed from names and values.
52 Handling of Line Continuation:
54 Long section header and parameter lines may be extended across
55 multiple lines by use of the backslash character ('\\'). Line
56 continuation is ignored for blank and comment lines.
58 If the last (non-whitespace) character within a section header or on
59 a parameter line is a backslash, then the next line will be
60 (logically) concatonated with the current line by the lexical
61 analyzer. For example:
63 param name = parameter value string \
64 with line continuation.
68 param name = parameter value string with line continuation.
70 Note that there are five spaces following the word 'string',
71 representing the one space between 'string' and '\\' in the top
72 line, plus the four preceeding the word 'with' in the second line.
73 (Yes, I'm counting the indentation.)
75 Line continuation characters are ignored on blank lines and at the end
76 of comments. They are *only* recognized within section and parameter
80 Line Continuation Quirks:
82 Note the following example:
84 param name = parameter value string \
86 with line continuation.
88 The middle line is *not* parsed as a blank line because it is first
89 concatonated with the top line. The result is
91 param name = parameter value string with line continuation.
93 The same is true for comment lines.
95 param name = parameter value string \
101 param name = parameter value string ; comment with a comment.
103 On a section header line, the closing bracket (']') is considered a
104 terminating character, and the rest of the line is ignored. The lines
106 [ section name ] garbage \
118 The syntax of the smb.conf file is as follows:
120 <file> :== { <section> } EOF
122 <section> :== <section header> { <parameter line> }
124 <section header> :== '[' NAME ']'
126 <parameter line> :== NAME '=' VALUE NL
129 Basically, this means that
131 - a file is made up of zero or more sections, and is terminated by
132 an EOF (we knew that).
134 - A section is made up of a section header followed by zero or more
137 - A section header is identified by an opening bracket and
138 terminated by the closing bracket. The enclosed NAME identifies
141 - A parameter line is divided into a NAME and a VALUE. The *first*
142 equal sign on the line separates the NAME from the VALUE. The
143 VALUE is terminated by a newline character (NL = '\n').
148 The parsing of the config file is a bit unusual if you are used to
149 lex, yacc, bison, etc. Both lexical analysis (scanning) and parsing
150 are performed by params.c. Values are loaded via callbacks to