1 dnl userv - language.i4
2 dnl definition of the configuration language, used for tokens.h and lexer.l
4 dnl Copyright (C)1996-1997 Ian Jackson
6 dnl This is free software; you can redistribute it and/or modify it
7 dnl under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with userv; if not, write to the Free Software
18 dnl Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 dnl 1,2,4: sections of token enum list
26 define(`makename',`translit(``$1'',`-_')')
28 define(`hasvalistype',`pushdef(`odiv',divnum)dnl
30 format(``%-50s'',`toki_$1=')`$2',
32 format(``%-30s'',`tokv_$1=')`$3|toki_$1',
33 divert(odiv)popdef(`odiv')')
35 define(`cautotoki',eval(`0x1'))
36 define(`cautotokt',eval(`0x1000'))
38 define(`autovalistype',`hasvalistype(`$1',format(``0x%08x'',cautotoki),`$2')`'define(`cautotoki',incr(cautotoki))')
40 define(`autovaldeftype',`pushdef(`odiv',divnum)divert(4)dnl
41 format(``%-25s'',`tokt_$1=')format(``0x%08x'',cautotokt),
42 divert(odiv)popdef(`odiv')define(`cautotokt',eval(cautotokt`*2'))')
44 define(`nametypelexpatexec',`
45 autovalistype(`$1',`$2')
46 pushdef(`odiv',divnum)divert(3)dnl
47 `$3 { $4'`return tokv_$1; }'
48 divert(odiv)popdef(`odiv')')
50 define(`wordtypelexexec',
51 `nametypelexpatexec(`word_'makename(`$1'),`$2|tokr_word',`$1',`$3')')
54 autovaldeftype(`directive')
55 autovaldeftype(`controlstart')
56 autovaldeftype(`controlend')
57 autovaldeftype(`exception')
58 autovaldeftype(`parmcondition')
59 autovaldeftype(`condop')
60 autovaldeftype(`parameter')
61 autovaldeftype(`number')
62 autovaldeftype(`fdrange')
63 autovaldeftype(`logfacility')
64 autovaldeftype(`loglevel')
65 autovaldeftype(`readwrite')
66 autovaldeftype(`string')
67 autovaldeftype(`execmode')
68 autovaldeftype(`ehandlemode')
69 autovaldeftype(`builtinservice')
70 autovaldeftype(`misc')
71 autovaldeftype(`internal')
73 dnl simple isdirectives
74 define(`isdirectivefn',`dnl
75 wordtypelexexec(`$1',`tokt_directive$3',`lr_dir= $2; $4')dnl
76 pushdef(`odiv',divnum)
77 divert(odiv)popdef(`odiv')')
78 define(`isdirective',`isdirectivefn(`$1',`df_'makename(`$1'),`$2')')
79 define(`isdirectiveinternal',`isdirectivefn(`$1',`dfi_'makename(`$1'),
81 define(`isexecmode',`isdirective(`$1',`|tokt_execmode')')
82 define(`isehandlemode',`isdirective(`$1',`|tokt_ehandlemode')')
83 define(`isfdwant',`isdirectivefn(`$1',`dfg_fdwant',`',
84 `lr_fdwant_readwrite=$2; ')')
85 define(`isflagpair',`isdirectivefn(`$1',`dfg_setflag',`',
86 `lr_flag= &'makename(`$1')`; lr_flagval= 1; ')
87 isdirectivefn(`no-$1',`dfg_setflag',`',
88 `lr_flag= &'makename(`$1')`; lr_flagval= 0; ')')
89 dnl `reset' is also a builtin service
91 dnl `execute' is also a builtin service
92 isexecmode(`execute-from-directory')
93 isexecmode(`execute-from-path')
94 isexecmode(`execute-builtin')
95 isehandlemode(`errors-to-stderr')
96 isehandlemode(`errors-to-syslog')
97 isehandlemode(`errors-to-file')
98 isfdwant(`require-fd',`1')
99 isfdwant(`allow-fd',`0')
100 isfdwant(`null-fd',`0')
101 isfdwant(`reject-fd',`-1')
102 isfdwant(`ignore-fd',`-1')
103 isflagpair(`set-environment')
104 isflagpair(`suppress-args')
105 isflagpair(`disconnect-hup')
107 isdirective(`user-rcfile')
108 isdirective(`include')
109 isdirectivefn(`include-ifexist',`df_include')
110 isdirective(`include-lookup')
111 isdirectivefn(`include-lookup-all',`df_includelookup')
112 isdirective(`include-directory')
113 isdirective(`message')
114 isdirectivefn(`_include-sysconfig',`df_include',`|tokt_internal')
115 isdirectiveinternal(`_include-user-rcfile')
116 isdirectiveinternal(`_include-client-config')
118 dnl quit and eof are each a directive _and_ an exception
119 dnl as separate tokens. A true end of file is returned by yylex
120 dnl as the exception. The directive (word) tokens are
121 dnl tokv_word_{eof,quit}; the exceptions are tokv_{eof,quit}.
125 dnl control construct starters
126 define(`iscontrolstart',
127 `isdirective(`$1',`|tokt_controlstart')')
129 iscontrolstart(`catch-quit')
130 iscontrolstart(`errors-push')
132 dnl control construct enders
133 define(`iscontrolend',
134 `wordtypelexexec(`$1',`tokt_controlend$3',
135 `lr_controlend= tokv_word_'makename(`$2')`; ')')
136 iscontrolend(`elif', `if', `|tokt_controlstart')
137 iscontrolend(`else', `if', `|tokt_controlstart')
138 iscontrolend(`fi', `if')
139 iscontrolend(`hctac', `catch-quit')
140 iscontrolend(`srorre', `errors-push')
143 define(`isparmcondition',`wordtypelexexec(`$1',`tokt_parmcondition',
144 `lr_parmcond= pcf_'makename(`$1')`; ')')
145 isparmcondition(`glob')
146 isparmcondition(`range')
147 isparmcondition(`grep')
150 define(`isbuiltinservice',`wordtypelexexec(`$1',`tokt_builtinservice',
151 `lr_bispa= bispa_'makename(`$2')`; lr_bisexec= bisexec_'makename(`$1')`; ')')
152 isbuiltinservice(`environment',`none')
153 isbuiltinservice(`parameter',`parameter')
154 isbuiltinservice(`version',`none')
155 isbuiltinservice(`toplevel',`none')
156 isbuiltinservice(`override',`none')
158 dnl builtin services that are also directive names
159 define(`isdirectivebuiltinservice',
160 `wordtypelexexec(`$1',`tokt_directive|tokt_builtinservice$3',
161 `lr_dir= df_'makename(`$1')`; lr_bispa= bispa_'makename(`$2')`; lr_bisexec= bisexec_'makename(`$1')`; ')')
162 isdirectivebuiltinservice(`reset',`none')
163 isdirectivebuiltinservice(`execute',`none',`|tokt_execmode')
166 define(`isparameter',`wordtypelexexec(`$1',`tokt_parameter',
167 `lr_parameter= pf_'makename(`$1')`; ')')
168 isparameter(`service')
169 isparameter(`calling-user')
170 isparameter(`calling-group')
171 isparameter(`calling-user-shell')
172 isparameter(`service-user')
173 isparameter(`service-group')
174 isparameter(`service-user-shell')
177 define(`isloglevellexpat',
178 `nametypelexpatexec(`syslog_$1',`tokt_loglevel|tokr_word',`$2',
179 `lr_loglevel= LOG_'translit(``$1'',`a-z',`A-Z')`; ')')
180 define(`isloglevel',`isloglevellexpat(`$1',`$1')')
184 isloglevellexpat(`warning',`warn(ing)?')
185 isloglevel(`err')dnl also the word error, which has dual meaning (below)
188 isloglevellexpat(`emerg',`emerg|panic')
190 dnl syslog facilities
191 define(`islogfacilitylexpat',
192 `nametypelexpatexec(`syslog_$1',`tokt_logfacility|tokr_word',`$2',
193 `lr_logfacility= LOG_'translit(``$1'',`a-z',`A-Z')`; ')')
194 define(`islogfacility',`islogfacilitylexpat(`$1',`$1')')
195 islogfacilitylexpat(`authpriv',`auth(priv)?|security')
196 islogfacility(`cron')
197 islogfacility(`daemon')
198 islogfacilitylexpat(`kern',`kern(el)?')
200 islogfacility(`mail')
201 islogfacility(`news')
202 islogfacility(`syslog')
203 islogfacility(`user')
204 islogfacility(`uucp')
205 islogfacility(`local0')
206 islogfacility(`local1')
207 islogfacility(`local2')
208 islogfacility(`local3')
209 islogfacility(`local4')
210 islogfacility(`local5')
211 islogfacility(`local6')
212 islogfacility(`local7')
214 dnl misc. word-like things
215 wordtypelexexec(`read',`tokt_readwrite',`')
216 wordtypelexexec(`write',`tokt_readwrite',`')
218 dnl small nonnegative integers and fd ranges
219 dnl some of these have two tokt_ bits set, because they can be several things.
220 autovalistype(`ordinal', `tokt_number|tokt_fdrange|tokr_word')
221 autovalistype(`fdrange', `tokt_fdrange|tokr_punct')
222 autovalistype(`fdstoend', `tokt_fdrange|tokr_punct')
223 nametypelexpatexec(`dollar',`tokt_misc|tokr_punct',`\$',`')
226 autovalistype(`lwsp', `tokt_misc|tokr_nonstring')
227 autovalistype(`newline', `tokt_misc|tokr_nonstring')
228 autovalistype(`barestring', `tokt_string|tokr_string')
229 autovalistype(`quotedstring', `tokt_string|tokr_string')
231 dnl exceptions - NB that there are also tokv_word_{eof,quit}
232 dnl - see above, near the directives.
233 autovalistype(`eof', `tokt_exception|tokr_nonstring')
234 autovalistype(`quit', `tokt_exception|tokr_nonstring')
235 autovalistype(`error', `tokt_exception|tokr_nonstring')
237 define(`iscondop',`nametypelexpatexec(`$2',`tokt_condop|tokr_punct',`$1',`')')
238 iscondop(`\(',`openparen')
239 iscondop(`\)',`closeparen')
244 dnl words that could be two things
245 wordtypelexexec(`error',`tokt_directive|tokt_loglevel',
246 `lr_dir= df_error; lr_loglevel= LOG_ERR; ')