1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % global_entities SYSTEM '../entities/global.entities'>
10 <firstname>Chris</firstname><surname>Hertel</surname>
12 <pubdate>November 1997</pubdate>
15 <title>The smb.conf file</title>
18 <title>Lexical Analysis</title>
21 Basically, the file is processed on a line by line basis. There are
22 four types of lines that are recognized by the lexical analyzer
28 Blank lines - Lines containing only whitespace.
31 Comment lines - Lines beginning with either a semi-colon or a
32 pound sign (';' or '#').
35 Section header lines - Lines beginning with an open square bracket ('[').
38 Parameter lines - Lines beginning with any other character.
39 (The default line type.)
44 The first two are handled exclusively by the lexical analyzer, which
45 ignores them. The latter two line types are scanned for
61 These are the only tokens passed to the parameter loader
62 (loadparm.c). Parameter names and values are divided from one
63 another by an equal sign: '='.
67 <title>Handling of Whitespace</title>
70 Whitespace is defined as all characters recognized by the isspace()
71 function (see ctype(3C)) except for the newline character ('\n')
72 The newline is excluded because it identifies the end of the line.
77 The lexical analyzer scans past white space at the beginning of a line.
81 Section and parameter names may contain internal white space. All
82 whitespace within a name is compressed to a single space character.
86 Internal whitespace within a parameter value is kept verbatim with
87 the exception of carriage return characters ('\r'), all of which
92 Leading and trailing whitespace is removed from names and values.
100 <title>Handling of Line Continuation</title>
103 Long section header and parameter lines may be extended across
104 multiple lines by use of the backslash character ('\\'). Line
105 continuation is ignored for blank and comment lines.
109 If the last (non-whitespace) character within a section header or on
110 a parameter line is a backslash, then the next line will be
111 (logically) concatonated with the current line by the lexical
112 analyzer. For example:
115 <para><programlisting>
116 param name = parameter value string \
117 with line continuation.
118 </programlisting></para>
120 <para>Would be read as</para>
122 <para><programlisting>
123 param name = parameter value string with line continuation.
124 </programlisting></para>
127 Note that there are five spaces following the word 'string',
128 representing the one space between 'string' and '\\' in the top
129 line, plus the four preceeding the word 'with' in the second line.
130 (Yes, I'm counting the indentation.)
134 Line continuation characters are ignored on blank lines and at the end
135 of comments. They are *only* recognized within section and parameter
142 <title>Line Continuation Quirks</title>
144 <para>Note the following example:</para>
146 <para><programlisting>
147 param name = parameter value string \
149 with line continuation.
150 </programlisting></para>
153 The middle line is *not* parsed as a blank line because it is first
154 concatonated with the top line. The result is
157 <para><programlisting>
158 param name = parameter value string with line continuation.
159 </programlisting></para>
161 <para>The same is true for comment lines.</para>
163 <para><programlisting>
164 param name = parameter value string \
167 </programlisting></para>
169 <para>This becomes:</para>
171 <para><programlisting>
172 param name = parameter value string ; comment with a comment.
173 </programlisting></para>
176 On a section header line, the closing bracket (']') is considered a
177 terminating character, and the rest of the line is ignored. The lines
180 <para><programlisting>
181 [ section name ] garbage \
183 </programlisting></para>
185 <para>are read as</para>
187 <para><programlisting>
190 </programlisting></para>
196 <title>Syntax</title>
198 <para>The syntax of the smb.conf file is as follows:</para>
200 <para><programlisting>
201 <file> :== { <section> } EOF
202 <section> :== <section header> { <parameter line> }
203 <section header> :== '[' NAME ']'
204 <parameter line> :== NAME '=' VALUE NL
205 </programlisting></para>
207 <para>Basically, this means that</para>
211 a file is made up of zero or more sections, and is terminated by
212 an EOF (we knew that).
216 A section is made up of a section header followed by zero or more
221 A section header is identified by an opening bracket and
222 terminated by the closing bracket. The enclosed NAME identifies
227 A parameter line is divided into a NAME and a VALUE. The *first*
228 equal sign on the line separates the NAME from the VALUE. The
229 VALUE is terminated by a newline character (NL = '\n').
235 <title>About params.c</title>
238 The parsing of the config file is a bit unusual if you are used to
239 lex, yacc, bison, etc. Both lexical analysis (scanning) and parsing
240 are performed by params.c. Values are loaded via callbacks to