4 <firstname>Chris</firstname><surname>Hertel</surname>
6 <pubdate>November 1997</pubdate>
9 <title>The smb.conf file</title>
12 <title>Lexical Analysis</title>
15 Basically, the file is processed on a line by line basis. There are
16 four types of lines that are recognized by the lexical analyzer
22 Blank lines - Lines containing only whitespace.
25 Comment lines - Lines beginning with either a semi-colon or a
26 pound sign (';' or '#').
29 Section header lines - Lines beginning with an open square bracket ('[').
32 Parameter lines - Lines beginning with any other character.
33 (The default line type.)
38 The first two are handled exclusively by the lexical analyzer, which
39 ignores them. The latter two line types are scanned for
55 These are the only tokens passed to the parameter loader
56 (loadparm.c). Parameter names and values are divided from one
57 another by an equal sign: '='.
61 <title>Handling of Whitespace</title>
64 Whitespace is defined as all characters recognized by the isspace()
65 function (see ctype(3C)) except for the newline character ('\n')
66 The newline is excluded because it identifies the end of the line.
71 The lexical analyzer scans past white space at the beginning of a line.
75 Section and parameter names may contain internal white space. All
76 whitespace within a name is compressed to a single space character.
80 Internal whitespace within a parameter value is kept verbatim with
81 the exception of carriage return characters ('\r'), all of which
86 Leading and trailing whitespace is removed from names and values.
94 <title>Handling of Line Continuation</title>
97 Long section header and parameter lines may be extended across
98 multiple lines by use of the backslash character ('\\'). Line
99 continuation is ignored for blank and comment lines.
103 If the last (non-whitespace) character within a section header or on
104 a parameter line is a backslash, then the next line will be
105 (logically) concatonated with the current line by the lexical
106 analyzer. For example:
109 <para><programlisting>
110 param name = parameter value string \
111 with line continuation.
112 </programlisting></para>
114 <para>Would be read as</para>
116 <para><programlisting>
117 param name = parameter value string with line continuation.
118 </programlisting></para>
121 Note that there are five spaces following the word 'string',
122 representing the one space between 'string' and '\\' in the top
123 line, plus the four preceeding the word 'with' in the second line.
124 (Yes, I'm counting the indentation.)
128 Line continuation characters are ignored on blank lines and at the end
129 of comments. They are *only* recognized within section and parameter
136 <title>Line Continuation Quirks</title>
138 <para>Note the following example:</para>
140 <para><programlisting>
141 param name = parameter value string \
143 with line continuation.
144 </programlisting></para>
147 The middle line is *not* parsed as a blank line because it is first
148 concatonated with the top line. The result is
151 <para><programlisting>
152 param name = parameter value string with line continuation.
153 </programlisting></para>
155 <para>The same is true for comment lines.</para>
157 <para><programlisting>
158 param name = parameter value string \
161 </programlisting></para>
163 <para>This becomes:</para>
165 <para><programlisting>
166 param name = parameter value string ; comment with a comment.
167 </programlisting></para>
170 On a section header line, the closing bracket (']') is considered a
171 terminating character, and the rest of the line is ignored. The lines
174 <para><programlisting>
175 [ section name ] garbage \
177 </programlisting></para>
179 <para>are read as</para>
181 <para><programlisting>
184 </programlisting></para>
190 <title>Syntax</title>
192 <para>The syntax of the smb.conf file is as follows:</para>
194 <para><programlisting>
195 <file> :== { <section> } EOF
196 <section> :== <section header> { <parameter line> }
197 <section header> :== '[' NAME ']'
198 <parameter line> :== NAME '=' VALUE NL
199 </programlisting></para>
201 <para>Basically, this means that</para>
205 a file is made up of zero or more sections, and is terminated by
206 an EOF (we knew that).
210 A section is made up of a section header followed by zero or more
215 A section header is identified by an opening bracket and
216 terminated by the closing bracket. The enclosed NAME identifies
221 A parameter line is divided into a NAME and a VALUE. The *first*
222 equal sign on the line separates the NAME from the VALUE. The
223 VALUE is terminated by a newline character (NL = '\n').
229 <title>About params.c</title>
232 The parsing of the config file is a bit unusual if you are used to
233 lex, yacc, bison, etc. Both lexical analysis (scanning) and parsing
234 are performed by params.c. Values are loaded via callbacks to