@cfg_get.<group_name>.<var_name> is documented
[sip-router] / cfg.lex
1 /*
2  * $Id$
3  *
4  * scanner for cfg files
5  *
6  * Copyright (C) 2001-2003 FhG Fokus
7  *
8  * This file is part of ser, a free SIP server.
9  *
10  * ser is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version
14  *
15  * For a license to use the ser software under conditions
16  * other than those described here, or to purchase support for this
17  * software, please contact iptel.org by e-mail at the following addresses:
18  *    info@iptel.org
19  *
20  * ser is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  *
29  * History:
30  * -------
31  *  2003-01-29  src_port added (jiri)
32  *  2003-01-23  mhomed added (jiri)
33  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
34  *  2003-04-01  added dst_port, proto (tcp, udp, tls), af(inet, inet6) (andrei)
35  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
36  *  2003-04-12  added force_rport, chdir and wdir (andrei)
37  *  2003-04-22  strip_tail added (jiri)
38  *  2003-07-03  tls* (disable, certificate, private_key, ca_list, verify,
39  *               require_certificate added (andrei)
40  *  2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
41  *  2003-10-02  added {,set_}advertised_{address,port} (andrei)
42  *  2003-10-07  added hex and octal numbers support (andrei)
43  *  2003-10-10  replaced len_gt w/ msg:len (andrei)
44  *  2003-10-13  added fifo_dir (andrei)
45  *  2003-10-28  added tcp_accept_aliases (andrei)
46  *  2003-11-29  added {tcp_send, tcp_connect, tls_*}_timeout (andrei)
47  *  2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
48  *  2004-04-28  added sock_mode (replaces fifo_mode), sock_user &
49  *               sock_group  (andrei)
50  *  2004-05-03  applied multicast support patch from janakj
51  *              added MCAST_TTL (andrei)
52  *  2004-10-08  more escapes: \", \xHH, \nnn and minor optimizations (andrei)
53  *  2004-10-19  added FROM_URI and TO_URI (andrei)
54  *  2004-11-30  added force_send_socket
55  *  2005-07-08  added tcp_connection_lifetime, tcp_poll_method,
56  *               tcp_max_connections (andrei)
57  *  2005-07-11  added dns_retr_{time,no}, dns_servers_no, dns_use_search_list,
58  *              dns_try_ipv6 (andrei)
59  *  2005-12-11  added onsend_route, snd_{ip,port,proto,af},
60  *              to_{ip,port} (andrei)
61  *  2005-12-12  separated drop, exit, break, return, added RETCODE (andrei)
62  *  2005-12-19  select framework (mma)
63  *  2006-09-11  added dns cache (use, flags, ttls, mem ,gc) & dst blacklist
64  *              options (andrei)
65  *  2006-10-13  added STUN_ALLOW_STUN, STUN_ALLOW_FP, STUN_REFRESH_INTERVAL
66  *              (vlada)
67  *  2007-06-07  added SHM_FORCE_ALLOC, MLOCK_PAGES, REAL_TIME, RT_PRIO,
68  *              RT_POLICY, RT_TIMER1_PRIO, RT_TIMER1_POLICY, RT_TIMER2_PRIO,
69  *              RT_TIMER2_POLICY (andrei)
70  *  2007-06-16  added DNS_SRV_LB, DNS_TRY_NAPTR (andrei)
71  *  2007-06-18  added DNS_{UDP,TCP,TLS}_PREF (andrei)
72  *  2007-09-10  introduced phone2tel option which allows NOT to consider
73  *              user=phone URIs as TEL URIs (jiri)
74  *  2007-10-10  added DNS_SEARCH_FMATCH (mma)
75  *  2007-11-28  added TCP_OPT_{FD_CACHE, DEFER_ACCEPT, DELAYED_ACK, SYNCNT,
76  *              LINGER2, KEEPALIVE, KEEPIDLE, KEEPINTVL, KEEPCNT} (andrei)
77 */
78
79
80 %{
81         #include "dprint.h"
82         #include "globals.h"
83         #include "mem/mem.h"
84         #include <string.h>
85         #include <stdlib.h>
86         #include "ip_addr.h"
87         #include "usr_avp.h"
88         #include "select.h"
89         #include "cfg.tab.h"
90
91         /* states */
92         #define INITIAL_S               0
93         #define COMMENT_S               1
94         #define COMMENT_LN_S            2
95         #define STRING_S                3
96         #define ATTR_S                  4
97         #define SELECT_S                5
98
99         #define STR_BUF_ALLOC_UNIT      128
100         struct str_buf{
101                 char* s;
102                 char* crt;
103                 int left;
104         };
105
106
107         static int comment_nest=0;
108         static int state=0, old_state=0, old_initial=0;
109         static struct str_buf s_buf;
110         int line=1;
111         int column=1;
112         int startcolumn=1;
113
114         static char* addchar(struct str_buf *, char);
115         static char* addstr(struct str_buf *, char*, int);
116         static void count();
117
118
119 %}
120
121 /* start conditions */
122 %x STRING1 STRING2 COMMENT COMMENT_LN ATTR SELECT
123
124 /* action keywords */
125 FORWARD forward
126 FORWARD_TCP     forward_tcp
127 FORWARD_UDP     forward_udp
128 FORWARD_TLS     forward_tls
129 DROP    "drop"|"exit"
130 RETURN  "return"
131 BREAK   "break"
132 SEND    send
133 SEND_TCP        send_tcp
134 LOG             log
135 ERROR   error
136 ROUTE   route
137 ROUTE_FAILURE failure_route
138 ROUTE_ONREPLY onreply_route
139 ROUTE_BRANCH branch_route
140 ROUTE_SEND onsend_route
141 EXEC    exec
142 FORCE_RPORT             "force_rport"|"add_rport"
143 FORCE_TCP_ALIAS         "force_tcp_alias"|"add_tcp_alias"
144 SETFLAG         setflag
145 RESETFLAG       resetflag
146 ISFLAGSET       isflagset
147 FLAGS_DECL      "flags"|"bool"
148 SETAVPFLAG      setavpflag
149 RESETAVPFLAG    resetavpflag
150 ISAVPFLAGSET    isavpflagset
151 AVPFLAGS_DECL   avpflags
152 SET_HOST                "rewritehost"|"sethost"|"seth"
153 SET_HOSTPORT    "rewritehostport"|"sethostport"|"sethp"
154 SET_USER                "rewriteuser"|"setuser"|"setu"
155 SET_USERPASS    "rewriteuserpass"|"setuserpass"|"setup"
156 SET_PORT                "rewriteport"|"setport"|"setp"
157 SET_URI                 "rewriteuri"|"seturi"
158 REVERT_URI              "revert_uri"
159 PREFIX                  "prefix"
160 STRIP                   "strip"
161 STRIP_TAIL              "strip_tail"
162 APPEND_BRANCH   "append_branch"
163 IF                              "if"
164 ELSE                    "else"
165 SET_ADV_ADDRESS "set_advertised_address"
166 SET_ADV_PORT    "set_advertised_port"
167 FORCE_SEND_SOCKET       "force_send_socket"
168
169 /*ACTION LVALUES*/
170 URIHOST                 "uri:host"
171 URIPORT                 "uri:port"
172
173 MAX_LEN                 "max_len"
174
175
176 /* condition keywords */
177 METHOD  method
178 /* hack -- the second element in first line is referable
179    as either uri or status; it only would makes sense to
180    call it "uri" from route{} and status from onreply_route{}
181 */
182 URI             "uri"|"status"
183 FROM_URI        "from_uri"
184 TO_URI          "to_uri"
185 SRCIP   src_ip
186 SRCPORT src_port
187 DSTIP   dst_ip
188 DSTPORT dst_port
189 SNDIP   snd_ip
190 SNDPORT snd_port
191 SNDPROTO        snd_proto|to_proto
192 SNDAF           snd_af|to_af
193 TOIP    to_ip
194 TOPORT  to_port
195 PROTO   proto
196 AF              af
197 MYSELF  myself
198 MSGLEN                  "msg:len"
199 RETCODE \$\?|\$retcode
200 /* operators */
201 EQUAL   =
202 EQUAL_T ==
203 GT      >
204 LT      <
205 GTE     >=
206 LTE     <=
207 DIFF    !=
208 MATCH   =~
209 ADDEQ     "+="
210 NOT             !|"not"
211 LOG_AND         "and"|"&&"
212 BIN_AND         "&"
213 LOG_OR          "or"|"||"
214 BIN_OR          "|"
215 PLUS    "+"
216 MINUS   "-"
217
218 /* Attribute specification */
219 ATTR_MARK   "$"|"%"
220 SELECT_MARK  "@"
221 ATTR_FROM         "f"
222 ATTR_TO           "t"
223 ATTR_FROMURI      "fr"
224 ATTR_TOURI       "tr"
225 ATTR_FROMUSER     "fu"
226 ATTR_TOUSER       "tu"
227 ATTR_FROMDOMAIN   "fd"
228 ATTR_TODOMAIN     "td"
229 ATTR_GLOBAL       "g"
230
231 /* config vars. */
232 DEBUG   debug
233 FORK    fork
234 LOGSTDERROR     log_stderror
235 LOGFACILITY     log_facility
236 LISTEN          listen
237 ALIAS           alias
238 DNS              dns
239 REV_DNS  rev_dns
240 DNS_TRY_IPV6    dns_try_ipv6
241 DNS_TRY_NAPTR   dns_try_naptr
242 DNS_SRV_LB              dns_srv_lb|dns_srv_loadbalancing
243 DNS_UDP_PREF    dns_udp_pref|dns_udp_preference
244 DNS_TCP_PREF    dns_tcp_pref|dns_tcp_preference
245 DNS_TLS_PREF    dns_tls_pref|dns_tls_preference
246 DNS_RETR_TIME   dns_retr_time
247 DNS_RETR_NO             dns_retr_no
248 DNS_SERVERS_NO  dns_servers_no
249 DNS_USE_SEARCH  dns_use_search_list
250 DNS_SEARCH_FMATCH       dns_search_full_match
251 /* dns cache */
252 DNS_USE_CACHE   use_dns_cache
253 DNS_USE_FAILOVER        use_dns_failover
254 DNS_CACHE_FLAGS         dns_cache_flags
255 DNS_CACHE_NEG_TTL       dns_cache_negative_ttl
256 DNS_CACHE_MIN_TTL       dns_cache_min_ttl
257 DNS_CACHE_MAX_TTL       dns_cache_max_ttl
258 DNS_CACHE_MEM           dns_cache_mem
259 DNS_CACHE_GC_INT        dns_cache_gc_interval
260 DNS_CACHE_DEL_NONEXP    dns_cache_del_nonexp|dns_cache_delete_nonexpired
261 /* blacklist */
262 USE_DST_BLST            use_dst_blacklist
263 DST_BLST_MEM            dst_blacklist_mem
264 DST_BLST_TTL            dst_blacklist_expire|dst_blacklist_ttl
265 DST_BLST_GC_INT         dst_blacklist_gc_interval
266
267
268 PORT    port
269 STAT    statistics
270 MAXBUFFER maxbuffer
271 CHILDREN children
272 CHECK_VIA       check_via
273 PHONE2TEL       phone2tel
274 SYN_BRANCH syn_branch
275 MEMLOG          "memlog"|"mem_log"
276 MEMDBG          "memdbg"|"mem_dbg"
277 SIP_WARNING sip_warning
278 SERVER_SIGNATURE server_signature
279 REPLY_TO_VIA reply_to_via
280 USER            "user"|"uid"
281 GROUP           "group"|"gid"
282 CHROOT          "chroot"
283 WDIR            "workdir"|"wdir"
284 MHOMED          mhomed
285 DISABLE_TCP             "disable_tcp"
286 TCP_CHILDREN    "tcp_children"
287 TCP_ACCEPT_ALIASES      "tcp_accept_aliases"
288 TCP_SEND_TIMEOUT        "tcp_send_timeout"
289 TCP_CONNECT_TIMEOUT     "tcp_connect_timeout"
290 TCP_CON_LIFETIME        "tcp_connection_lifetime"
291 TCP_POLL_METHOD         "tcp_poll_method"
292 TCP_MAX_CONNECTIONS     "tcp_max_connections"
293 TCP_SOURCE_IPV4         "tcp_source_ipv4"
294 TCP_SOURCE_IPV6         "tcp_source_ipv6"
295 TCP_OPT_FD_CACHE        "tcp_fd_cache"
296 TCP_OPT_BUF_WRITE       "tcp_buf_write"
297 TCP_OPT_CONN_WQ_MAX     "tcp_conn_wq_max"
298 TCP_OPT_WQ_MAX          "tcp_wq_max"
299 TCP_OPT_DEFER_ACCEPT "tcp_defer_accept"
300 TCP_OPT_DELAYED_ACK     "tcp_delayed_ack"
301 TCP_OPT_SYNCNT          "tcp_syncnt"
302 TCP_OPT_LINGER2         "tcp_linger2"
303 TCP_OPT_KEEPALIVE       "tcp_keepalive"
304 TCP_OPT_KEEPIDLE        "tcp_keepidle"
305 TCP_OPT_KEEPINTVL       "tcp_keepintvl"
306 TCP_OPT_KEEPCNT         "tcp_keepcnt"
307 DISABLE_TLS             "disable_tls"|"tls_disable"
308 ENABLE_TLS              "enable_tls"|"tls_enable"
309 TLSLOG                  "tlslog"|"tls_log"
310 TLS_PORT_NO             "tls_port_no"
311 TLS_METHOD              "tls_method"
312 TLS_VERIFY              "tls_verify"
313 TLS_REQUIRE_CERTIFICATE "tls_require_certificate"
314 TLS_CERTIFICATE "tls_certificate"
315 TLS_PRIVATE_KEY "tls_private_key"
316 TLS_CA_LIST             "tls_ca_list"
317 TLS_HANDSHAKE_TIMEOUT   "tls_handshake_timeout"
318 TLS_SEND_TIMEOUT        "tls_send_timeout"
319 ADVERTISED_ADDRESS      "advertised_address"
320 ADVERTISED_PORT         "advertised_port"
321 DISABLE_CORE            "disable_core_dump"
322 OPEN_FD_LIMIT           "open_files_limit"
323 SHM_FORCE_ALLOC         "shm_force_alloc"
324 MLOCK_PAGES                     "mlock_pages"
325 REAL_TIME                       "real_time"
326 RT_PRIO                         "rt_prio"
327 RT_POLICY                       "rt_policy"
328 RT_TIMER1_PRIO          "rt_timer1_prio"|"rt_fast_timer_prio"|"rt_ftimer_prio"
329 RT_TIMER1_POLICY        "rt_timer1_policy"|"rt_ftimer_policy"
330 RT_TIMER2_PRIO          "rt_timer2_prio"|"rt_stimer_prio"
331 RT_TIMER2_POLICY        "rt_timer2_policy"|"rt_stimer_policy"
332 MCAST_LOOPBACK          "mcast_loopback"
333 MCAST_TTL               "mcast_ttl"
334 TOS                     "tos"
335 PMTU_DISCOVERY  "pmtu_discovery"
336 KILL_TIMEOUT    "exit_timeout"|"ser_kill_timeout"
337
338 /* stun config variables */
339 STUN_REFRESH_INTERVAL "stun_refresh_interval"
340 STUN_ALLOW_STUN "stun_allow_stun"
341 STUN_ALLOW_FP "stun_allow_fp"
342
343 LOADMODULE      loadmodule
344 MODPARAM        modparam
345
346 /* values */
347 YES                     "yes"|"true"|"on"|"enable"
348 NO                      "no"|"false"|"off"|"disable"
349 UDP                     "udp"|"UDP"
350 TCP                     "tcp"|"TCP"
351 TLS                     "tls"|"TLS"
352 INET            "inet"|"INET"
353 INET6           "inet6"|"INET6"
354 SSLv23                  "sslv23"|"SSLv23"|"SSLV23"
355 SSLv2                   "sslv2"|"SSLv2"|"SSLV2"
356 SSLv3                   "sslv3"|"SSLv3"|"SSLV3"
357 TLSv1                   "tlsv1"|"TLSv1"|"TLSV1"
358
359 LETTER          [a-zA-Z]
360 DIGIT           [0-9]
361 ALPHANUM        {LETTER}|{DIGIT}|[_]
362 ID                      {LETTER}{ALPHANUM}*
363 HEX                     [0-9a-fA-F]
364 HEXNUMBER       0x{HEX}+
365 OCTNUMBER       0[0-7]+
366 DECNUMBER       0|-?([1-9]{DIGIT}*)
367 BINNUMBER       [0-1]+b
368 HEX4            {HEX}{1,4}
369 IPV6ADDR        ({HEX4}":"){7}{HEX4}|({HEX4}":"){1,7}(":"{HEX4}){1,7}|":"(":"{HEX4}){1,7}|({HEX4}":"){1,7}":"|"::"
370 QUOTES          \"
371 TICK            \'
372 SLASH           "/"
373 SEMICOLON       ;
374 RPAREN          \)
375 LPAREN          \(
376 LBRACE          \{
377 RBRACE          \}
378 LBRACK          \[
379 RBRACK          \]
380 COMMA           ","
381 COLON           ":"
382 STAR            \*
383 DOT                     \.
384 CR                      \n
385
386
387
388 COM_LINE        #
389 COM_START       "/\*"
390 COM_END         "\*/"
391
392 EAT_ABLE        [\ \t\b\r]
393
394 %%
395
396
397 <INITIAL>{EAT_ABLE}     { count(); }
398
399 <INITIAL>{FORWARD}      {count(); yylval.strval=yytext; return FORWARD; }
400 <INITIAL>{FORWARD_TCP}  {count(); yylval.strval=yytext; return FORWARD_TCP; }
401 <INITIAL>{FORWARD_TLS}  {count(); yylval.strval=yytext; return FORWARD_TLS; }
402 <INITIAL>{FORWARD_UDP}  {count(); yylval.strval=yytext; return FORWARD_UDP; }
403 <INITIAL>{DROP} { count(); yylval.strval=yytext; return DROP; }
404 <INITIAL>{RETURN}       { count(); yylval.strval=yytext; return RETURN; }
405 <INITIAL>{BREAK}        { count(); yylval.strval=yytext; return BREAK; }
406 <INITIAL>{SEND} { count(); yylval.strval=yytext; return SEND; }
407 <INITIAL>{SEND_TCP}     { count(); yylval.strval=yytext; return SEND_TCP; }
408 <INITIAL>{LOG}  { count(); yylval.strval=yytext; return LOG_TOK; }
409 <INITIAL>{ERROR}        { count(); yylval.strval=yytext; return ERROR; }
410 <INITIAL>{SETFLAG}      { count(); yylval.strval=yytext; return SETFLAG; }
411 <INITIAL>{RESETFLAG}    { count(); yylval.strval=yytext; return RESETFLAG; }
412 <INITIAL>{ISFLAGSET}    { count(); yylval.strval=yytext; return ISFLAGSET; }
413 <INITIAL>{FLAGS_DECL}   { count(); yylval.strval=yytext; return FLAGS_DECL; }
414 <INITIAL>{SETAVPFLAG}   { count(); yylval.strval=yytext; return SETAVPFLAG; }
415 <INITIAL>{RESETAVPFLAG} { count(); yylval.strval=yytext; return RESETAVPFLAG; }
416 <INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
417 <INITIAL>{AVPFLAGS_DECL}        { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
418 <INITIAL>{MSGLEN}       { count(); yylval.strval=yytext; return MSGLEN; }
419 <INITIAL>{RETCODE}      { count(); yylval.strval=yytext; return RETCODE; }
420 <INITIAL>{ROUTE}        { count(); yylval.strval=yytext; return ROUTE; }
421 <INITIAL>{ROUTE_ONREPLY}        { count(); yylval.strval=yytext;
422                                                                 return ROUTE_ONREPLY; }
423 <INITIAL>{ROUTE_FAILURE}        { count(); yylval.strval=yytext;
424                                                                 return ROUTE_FAILURE; }
425 <INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
426 <INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
427 <INITIAL>{EXEC} { count(); yylval.strval=yytext; return EXEC; }
428 <INITIAL>{SET_HOST}     { count(); yylval.strval=yytext; return SET_HOST; }
429 <INITIAL>{SET_HOSTPORT} { count(); yylval.strval=yytext; return SET_HOSTPORT; }
430 <INITIAL>{SET_USER}     { count(); yylval.strval=yytext; return SET_USER; }
431 <INITIAL>{SET_USERPASS} { count(); yylval.strval=yytext; return SET_USERPASS; }
432 <INITIAL>{SET_PORT}     { count(); yylval.strval=yytext; return SET_PORT; }
433 <INITIAL>{SET_URI}      { count(); yylval.strval=yytext; return SET_URI; }
434 <INITIAL>{REVERT_URI}   { count(); yylval.strval=yytext; return REVERT_URI; }
435 <INITIAL>{PREFIX}       { count(); yylval.strval=yytext; return PREFIX; }
436 <INITIAL>{STRIP}        { count(); yylval.strval=yytext; return STRIP; }
437 <INITIAL>{STRIP_TAIL}   { count(); yylval.strval=yytext; return STRIP_TAIL; }
438 <INITIAL>{APPEND_BRANCH}        { count(); yylval.strval=yytext;
439                                                                 return APPEND_BRANCH; }
440 <INITIAL>{FORCE_RPORT}  { count(); yylval.strval=yytext; return FORCE_RPORT; }
441 <INITIAL>{FORCE_TCP_ALIAS}      { count(); yylval.strval=yytext;
442                                                                 return FORCE_TCP_ALIAS; }
443 <INITIAL>{IF}   { count(); yylval.strval=yytext; return IF; }
444 <INITIAL>{ELSE} { count(); yylval.strval=yytext; return ELSE; }
445
446 <INITIAL>{SET_ADV_ADDRESS}      { count(); yylval.strval=yytext;
447                                                                                 return SET_ADV_ADDRESS; }
448 <INITIAL>{SET_ADV_PORT} { count(); yylval.strval=yytext;
449                                                                                 return SET_ADV_PORT; }
450 <INITIAL>{FORCE_SEND_SOCKET}    {       count(); yylval.strval=yytext;
451                                                                         return FORCE_SEND_SOCKET; }
452
453 <INITIAL>{URIHOST}      { count(); yylval.strval=yytext; return URIHOST; }
454 <INITIAL>{URIPORT}      { count(); yylval.strval=yytext; return URIPORT; }
455
456 <INITIAL>{MAX_LEN}      { count(); yylval.strval=yytext; return MAX_LEN; }
457
458 <INITIAL>{METHOD}       { count(); yylval.strval=yytext; return METHOD; }
459 <INITIAL>{URI}  { count(); yylval.strval=yytext; return URI; }
460 <INITIAL>{FROM_URI}     { count(); yylval.strval=yytext; return FROM_URI; }
461 <INITIAL>{TO_URI}       { count(); yylval.strval=yytext; return TO_URI; }
462 <INITIAL>{SRCIP}        { count(); yylval.strval=yytext; return SRCIP; }
463 <INITIAL>{SRCPORT}      { count(); yylval.strval=yytext; return SRCPORT; }
464 <INITIAL>{DSTIP}        { count(); yylval.strval=yytext; return DSTIP; }
465 <INITIAL>{DSTPORT}      { count(); yylval.strval=yytext; return DSTPORT; }
466 <INITIAL>{SNDIP}        { count(); yylval.strval=yytext; return SNDIP; }
467 <INITIAL>{SNDPORT}      { count(); yylval.strval=yytext; return SNDPORT; }
468 <INITIAL>{SNDPROTO}     { count(); yylval.strval=yytext; return SNDPROTO; }
469 <INITIAL>{SNDAF}        { count(); yylval.strval=yytext; return SNDAF; }
470 <INITIAL>{TOIP}         { count(); yylval.strval=yytext; return TOIP; }
471 <INITIAL>{TOPORT}       { count(); yylval.strval=yytext; return TOPORT; }
472 <INITIAL>{PROTO}        { count(); yylval.strval=yytext; return PROTO; }
473 <INITIAL>{AF}   { count(); yylval.strval=yytext; return AF; }
474 <INITIAL>{MYSELF}       { count(); yylval.strval=yytext; return MYSELF; }
475
476 <INITIAL>{DEBUG}        { count(); yylval.strval=yytext; return DEBUG_V; }
477 <INITIAL>{FORK}         { count(); yylval.strval=yytext; return FORK; }
478 <INITIAL>{LOGSTDERROR}  { yylval.strval=yytext; return LOGSTDERROR; }
479 <INITIAL>{LOGFACILITY}  { yylval.strval=yytext; return LOGFACILITY; }
480 <INITIAL>{LISTEN}       { count(); yylval.strval=yytext; return LISTEN; }
481 <INITIAL>{ALIAS}        { count(); yylval.strval=yytext; return ALIAS; }
482 <INITIAL>{DNS}  { count(); yylval.strval=yytext; return DNS; }
483 <INITIAL>{REV_DNS}      { count(); yylval.strval=yytext; return REV_DNS; }
484 <INITIAL>{DNS_TRY_IPV6} { count(); yylval.strval=yytext;
485                                                                 return DNS_TRY_IPV6; }
486 <INITIAL>{DNS_TRY_NAPTR}        { count(); yylval.strval=yytext;
487                                                                 return DNS_TRY_NAPTR; }
488 <INITIAL>{DNS_SRV_LB}   { count(); yylval.strval=yytext;
489                                                                 return DNS_SRV_LB; }
490 <INITIAL>{DNS_UDP_PREF} { count(); yylval.strval=yytext;
491                                                                 return DNS_UDP_PREF; }
492 <INITIAL>{DNS_TCP_PREF} { count(); yylval.strval=yytext;
493                                                                 return DNS_TCP_PREF; }
494 <INITIAL>{DNS_TLS_PREF} { count(); yylval.strval=yytext;
495                                                                 return DNS_TLS_PREF; }
496 <INITIAL>{DNS_RETR_TIME}        { count(); yylval.strval=yytext;
497                                                                 return DNS_RETR_TIME; }
498 <INITIAL>{DNS_RETR_NO}  { count(); yylval.strval=yytext;
499                                                                 return DNS_RETR_NO; }
500 <INITIAL>{DNS_SERVERS_NO}       { count(); yylval.strval=yytext;
501                                                                 return DNS_SERVERS_NO; }
502 <INITIAL>{DNS_USE_SEARCH}       { count(); yylval.strval=yytext;
503                                                                 return DNS_USE_SEARCH; }
504 <INITIAL>{DNS_SEARCH_FMATCH}    { count(); yylval.strval=yytext;
505                                                                 return DNS_SEARCH_FMATCH; }
506 <INITIAL>{DNS_USE_CACHE}        { count(); yylval.strval=yytext;
507                                                                 return DNS_USE_CACHE; }
508 <INITIAL>{DNS_USE_FAILOVER}     { count(); yylval.strval=yytext;
509                                                                 return DNS_USE_FAILOVER; }
510 <INITIAL>{DNS_CACHE_FLAGS}      { count(); yylval.strval=yytext;
511                                                                 return DNS_CACHE_FLAGS; }
512 <INITIAL>{DNS_CACHE_NEG_TTL}    { count(); yylval.strval=yytext;
513                                                                 return DNS_CACHE_NEG_TTL; }
514 <INITIAL>{DNS_CACHE_MIN_TTL}    { count(); yylval.strval=yytext;
515                                                                 return DNS_CACHE_MIN_TTL; }
516 <INITIAL>{DNS_CACHE_MAX_TTL}    { count(); yylval.strval=yytext;
517                                                                 return DNS_CACHE_MAX_TTL; }
518 <INITIAL>{DNS_CACHE_MEM}        { count(); yylval.strval=yytext;
519                                                                 return DNS_CACHE_MEM; }
520 <INITIAL>{DNS_CACHE_GC_INT}     { count(); yylval.strval=yytext;
521                                                                 return DNS_CACHE_GC_INT; }
522 <INITIAL>{DNS_CACHE_DEL_NONEXP} { count(); yylval.strval=yytext;
523                                                                 return DNS_CACHE_DEL_NONEXP; }
524 <INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext;
525                                                                 return USE_DST_BLST; }
526 <INITIAL>{DST_BLST_MEM} { count(); yylval.strval=yytext;
527                                                                 return DST_BLST_MEM; }
528 <INITIAL>{DST_BLST_TTL} { count(); yylval.strval=yytext;
529                                                                 return DST_BLST_TTL; }
530 <INITIAL>{DST_BLST_GC_INT}      { count(); yylval.strval=yytext;
531                                                                 return DST_BLST_GC_INT; }
532 <INITIAL>{PORT} { count(); yylval.strval=yytext; return PORT; }
533 <INITIAL>{STAT} { count(); yylval.strval=yytext; return STAT; }
534 <INITIAL>{MAXBUFFER}    { count(); yylval.strval=yytext; return MAXBUFFER; }
535 <INITIAL>{CHILDREN}     { count(); yylval.strval=yytext; return CHILDREN; }
536 <INITIAL>{CHECK_VIA}    { count(); yylval.strval=yytext; return CHECK_VIA; }
537 <INITIAL>{PHONE2TEL}    { count(); yylval.strval=yytext; return PHONE2TEL; }
538 <INITIAL>{SYN_BRANCH}   { count(); yylval.strval=yytext; return SYN_BRANCH; }
539 <INITIAL>{MEMLOG}       { count(); yylval.strval=yytext; return MEMLOG; }
540 <INITIAL>{MEMDBG}       { count(); yylval.strval=yytext; return MEMDBG; }
541 <INITIAL>{SIP_WARNING}  { count(); yylval.strval=yytext; return SIP_WARNING; }
542 <INITIAL>{USER}         { count(); yylval.strval=yytext; return USER; }
543 <INITIAL>{GROUP}        { count(); yylval.strval=yytext; return GROUP; }
544 <INITIAL>{CHROOT}       { count(); yylval.strval=yytext; return CHROOT; }
545 <INITIAL>{WDIR} { count(); yylval.strval=yytext; return WDIR; }
546 <INITIAL>{MHOMED}       { count(); yylval.strval=yytext; return MHOMED; }
547 <INITIAL>{DISABLE_TCP}  { count(); yylval.strval=yytext; return DISABLE_TCP; }
548 <INITIAL>{TCP_CHILDREN} { count(); yylval.strval=yytext; return TCP_CHILDREN; }
549 <INITIAL>{TCP_ACCEPT_ALIASES}   { count(); yylval.strval=yytext;
550                                                                         return TCP_ACCEPT_ALIASES; }
551 <INITIAL>{TCP_SEND_TIMEOUT}             { count(); yylval.strval=yytext;
552                                                                         return TCP_SEND_TIMEOUT; }
553 <INITIAL>{TCP_CONNECT_TIMEOUT}          { count(); yylval.strval=yytext;
554                                                                         return TCP_CONNECT_TIMEOUT; }
555 <INITIAL>{TCP_CON_LIFETIME}             { count(); yylval.strval=yytext;
556                                                                         return TCP_CON_LIFETIME; }
557 <INITIAL>{TCP_POLL_METHOD}              { count(); yylval.strval=yytext;
558                                                                         return TCP_POLL_METHOD; }
559 <INITIAL>{TCP_MAX_CONNECTIONS}  { count(); yylval.strval=yytext;
560                                                                         return TCP_MAX_CONNECTIONS; }
561 <INITIAL>{TCP_SOURCE_IPV4}              { count(); yylval.strval=yytext;
562                                                                         return TCP_SOURCE_IPV4; }
563 <INITIAL>{TCP_SOURCE_IPV6}              { count(); yylval.strval=yytext;
564                                                                         return TCP_SOURCE_IPV6; }
565 <INITIAL>{TCP_OPT_FD_CACHE}             { count(); yylval.strval=yytext;
566                                                                         return TCP_OPT_FD_CACHE; }
567 <INITIAL>{TCP_OPT_CONN_WQ_MAX}  { count(); yylval.strval=yytext;
568                                                                         return TCP_OPT_CONN_WQ_MAX; }
569 <INITIAL>{TCP_OPT_WQ_MAX}       { count(); yylval.strval=yytext;
570                                                                         return TCP_OPT_WQ_MAX; }
571 <INITIAL>{TCP_OPT_BUF_WRITE}    { count(); yylval.strval=yytext;
572                                                                         return TCP_OPT_BUF_WRITE; }
573 <INITIAL>{TCP_OPT_DEFER_ACCEPT} { count(); yylval.strval=yytext;
574                                                                         return TCP_OPT_DEFER_ACCEPT; }
575 <INITIAL>{TCP_OPT_DELAYED_ACK}  { count(); yylval.strval=yytext;
576                                                                         return TCP_OPT_DELAYED_ACK; }
577 <INITIAL>{TCP_OPT_SYNCNT}               { count(); yylval.strval=yytext;
578                                                                         return TCP_OPT_SYNCNT; }
579 <INITIAL>{TCP_OPT_LINGER2}              { count(); yylval.strval=yytext;
580                                                                         return TCP_OPT_LINGER2; }
581 <INITIAL>{TCP_OPT_KEEPALIVE}    { count(); yylval.strval=yytext;
582                                                                         return TCP_OPT_KEEPALIVE; }
583 <INITIAL>{TCP_OPT_KEEPIDLE}             { count(); yylval.strval=yytext;
584                                                                         return TCP_OPT_KEEPIDLE; }
585 <INITIAL>{TCP_OPT_KEEPINTVL}    { count(); yylval.strval=yytext;
586                                                                         return TCP_OPT_KEEPINTVL; }
587 <INITIAL>{TCP_OPT_KEEPCNT}      { count(); yylval.strval=yytext;
588                                                                         return TCP_OPT_KEEPCNT; }
589 <INITIAL>{DISABLE_TLS}  { count(); yylval.strval=yytext; return DISABLE_TLS; }
590 <INITIAL>{ENABLE_TLS}   { count(); yylval.strval=yytext; return ENABLE_TLS; }
591 <INITIAL>{TLSLOG}               { count(); yylval.strval=yytext; return TLS_PORT_NO; }
592 <INITIAL>{TLS_PORT_NO}  { count(); yylval.strval=yytext; return TLS_PORT_NO; }
593 <INITIAL>{TLS_METHOD}   { count(); yylval.strval=yytext; return TLS_METHOD; }
594 <INITIAL>{TLS_VERIFY}   { count(); yylval.strval=yytext; return TLS_VERIFY; }
595 <INITIAL>{TLS_REQUIRE_CERTIFICATE}      { count(); yylval.strval=yytext;
596                                                                                 return TLS_REQUIRE_CERTIFICATE; }
597 <INITIAL>{TLS_CERTIFICATE}      { count(); yylval.strval=yytext;
598                                                                                 return TLS_CERTIFICATE; }
599 <INITIAL>{TLS_PRIVATE_KEY}      { count(); yylval.strval=yytext;
600                                                                                 return TLS_PRIVATE_KEY; }
601 <INITIAL>{TLS_CA_LIST}  { count(); yylval.strval=yytext;
602                                                                                 return TLS_CA_LIST; }
603 <INITIAL>{TLS_HANDSHAKE_TIMEOUT}        { count(); yylval.strval=yytext;
604                                                                                 return TLS_HANDSHAKE_TIMEOUT; }
605 <INITIAL>{TLS_SEND_TIMEOUT}     { count(); yylval.strval=yytext;
606                                                                                 return TLS_SEND_TIMEOUT; }
607 <INITIAL>{SERVER_SIGNATURE}     { count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
608 <INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; }
609 <INITIAL>{ADVERTISED_ADDRESS}   {       count(); yylval.strval=yytext;
610                                                                         return ADVERTISED_ADDRESS; }
611 <INITIAL>{ADVERTISED_PORT}              {       count(); yylval.strval=yytext;
612                                                                         return ADVERTISED_PORT; }
613 <INITIAL>{DISABLE_CORE}         {       count(); yylval.strval=yytext;
614                                                                         return DISABLE_CORE; }
615 <INITIAL>{OPEN_FD_LIMIT}                {       count(); yylval.strval=yytext;
616                                                                         return OPEN_FD_LIMIT; }
617 <INITIAL>{SHM_FORCE_ALLOC}              {       count(); yylval.strval=yytext;
618                                                                         return SHM_FORCE_ALLOC; }
619 <INITIAL>{MLOCK_PAGES}          {       count(); yylval.strval=yytext;
620                                                                         return MLOCK_PAGES; }
621 <INITIAL>{REAL_TIME}            {       count(); yylval.strval=yytext;
622                                                                         return REAL_TIME; }
623 <INITIAL>{RT_PRIO}              {       count(); yylval.strval=yytext;
624                                                                         return RT_PRIO; }
625 <INITIAL>{RT_POLICY}            {       count(); yylval.strval=yytext;
626                                                                         return RT_POLICY; }
627 <INITIAL>{RT_TIMER1_PRIO}               {       count(); yylval.strval=yytext;
628                                                                         return RT_TIMER1_PRIO; }
629 <INITIAL>{RT_TIMER1_POLICY}             {       count(); yylval.strval=yytext;
630                                                                         return RT_TIMER1_POLICY; }
631 <INITIAL>{RT_TIMER2_PRIO}               {       count(); yylval.strval=yytext;
632                                                                         return RT_TIMER2_PRIO; }
633 <INITIAL>{RT_TIMER2_POLICY}             {       count(); yylval.strval=yytext;
634                                                                         return RT_TIMER2_POLICY; }
635 <INITIAL>{MCAST_LOOPBACK}               {       count(); yylval.strval=yytext;
636                                                                         return MCAST_LOOPBACK; }
637 <INITIAL>{MCAST_TTL}            {       count(); yylval.strval=yytext;
638                                                                         return MCAST_TTL; }
639 <INITIAL>{TOS}                  {       count(); yylval.strval=yytext;
640                                                                         return TOS; }
641 <INITIAL>{PMTU_DISCOVERY}               {       count(); yylval.strval=yytext;
642                                                                         return PMTU_DISCOVERY; }
643 <INITIAL>{KILL_TIMEOUT}                 {       count(); yylval.strval=yytext;
644                                                                         return KILL_TIMEOUT; }
645 <INITIAL>{LOADMODULE}   { count(); yylval.strval=yytext; return LOADMODULE; }
646 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
647
648 <INITIAL>{STUN_REFRESH_INTERVAL} { count(); yylval.strval=yytext; return STUN_REFRESH_INTERVAL;}
649 <INITIAL>{STUN_ALLOW_STUN} { count(); yylval.strval=yytext; return STUN_ALLOW_STUN;}
650 <INITIAL>{STUN_ALLOW_FP} { count(); yylval.strval=yytext; return STUN_ALLOW_FP;}
651
652 <INITIAL>{EQUAL}        { count(); return EQUAL; }
653 <INITIAL>{ADDEQ}          { count(); return ADDEQ; }
654 <INITIAL>{EQUAL_T}      { count(); return EQUAL_T; }
655 <INITIAL>{GT}   { count(); return GT; }
656 <INITIAL>{LT}   { count(); return LT; }
657 <INITIAL>{GTE}  { count(); return GTE; }
658 <INITIAL>{LTE}  { count(); return LTE; }
659 <INITIAL>{DIFF} { count(); return DIFF; }
660 <INITIAL>{MATCH}        { count(); return MATCH; }
661 <INITIAL>{NOT}          { count(); return NOT; }
662 <INITIAL>{LOG_AND}      { count(); return LOG_AND; }
663 <INITIAL>{BIN_AND}      { count(); return BIN_AND; }
664 <INITIAL>{LOG_OR}       { count(); return LOG_OR;  }
665 <INITIAL>{BIN_OR}       { count(); return BIN_OR;  }
666 <INITIAL>{PLUS}         { count(); return PLUS; }
667 <INITIAL>{MINUS}        { count(); return MINUS; }
668
669 <INITIAL>{SELECT_MARK}  { count(); state = SELECT_S; BEGIN(SELECT); return SELECT_MARK; }
670 <SELECT>{ID}            { count(); addstr(&s_buf, yytext, yyleng);
671                           yylval.strval=s_buf.s;
672                           memset(&s_buf, 0, sizeof(s_buf));
673                           return ID;
674                         }
675 <SELECT>{DOT}           { count(); return DOT; }
676 <SELECT>{LBRACK}        { count(); return LBRACK; }
677 <SELECT>{RBRACK}        { count(); return RBRACK; }
678 <SELECT>{DECNUMBER}     { count(); yylval.intval=atoi(yytext);return NUMBER; }
679 <SELECT>{HEXNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 16); return NUMBER; }
680 <SELECT>{OCTNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 8); return NUMBER; }
681 <SELECT>{BINNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
682
683
684 <INITIAL>{ATTR_MARK}    { count(); state = ATTR_S; BEGIN(ATTR); return ATTR_MARK; }
685 <ATTR>{ATTR_FROM}       { count(); return ATTR_FROM; }
686 <ATTR>{ATTR_TO}         { count(); return ATTR_TO; }
687 <ATTR>{ATTR_FROMURI}    { count(); return ATTR_FROMURI; }
688 <ATTR>{ATTR_TOURI}      { count(); return ATTR_TOURI; }
689 <ATTR>{ATTR_FROMUSER}   { count(); return ATTR_FROMUSER; }
690 <ATTR>{ATTR_TOUSER}     { count(); return ATTR_TOUSER; }
691 <ATTR>{ATTR_FROMDOMAIN} { count(); return ATTR_FROMDOMAIN; }
692 <ATTR>{ATTR_TODOMAIN}   { count(); return ATTR_TODOMAIN; }
693 <ATTR>{ATTR_GLOBAL}     { count(); return ATTR_GLOBAL; }
694 <ATTR>{DOT}             { count(); return DOT; }
695 <ATTR>{LBRACK}          { count(); return LBRACK; }
696 <ATTR>{RBRACK}          { count(); return RBRACK; }
697 <ATTR>{STAR}            { count(); return STAR; }
698 <ATTR>{DECNUMBER}       { count(); yylval.intval=atoi(yytext);return NUMBER; }
699 <ATTR>{ID}              { count(); addstr(&s_buf, yytext, yyleng);
700                            yylval.strval=s_buf.s;
701                            memset(&s_buf, 0, sizeof(s_buf));
702                            state = INITIAL_S;
703                            BEGIN(INITIAL);
704                            return ID;
705                         }
706
707 <INITIAL>{IPV6ADDR}             { count(); yylval.strval=yytext; return IPV6ADDR; }
708 <INITIAL>{DECNUMBER}            { count(); yylval.intval=atoi(yytext);return NUMBER; }
709 <INITIAL>{HEXNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 16);
710                                                         return NUMBER; }
711 <INITIAL>{OCTNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 8);
712                                                         return NUMBER; }
713 <INITIAL>{BINNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
714 <INITIAL>{YES}                  { count(); yylval.intval=1; return NUMBER; }
715 <INITIAL>{NO}                   { count(); yylval.intval=0; return NUMBER; }
716 <INITIAL>{TCP}                  { count(); return TCP; }
717 <INITIAL>{UDP}                  { count(); return UDP; }
718 <INITIAL>{TLS}                  { count(); return TLS; }
719 <INITIAL>{INET}                 { count(); yylval.intval=AF_INET; return NUMBER; }
720 <INITIAL>{INET6}                { count();
721                                                 #ifdef USE_IPV6
722                                                   yylval.intval=AF_INET6;
723                                                 #else
724                                                   yylval.intval=-1; /* no match*/
725                                                 #endif
726                                                   return NUMBER; }
727 <INITIAL>{SSLv23}               { count(); yylval.strval=yytext; return SSLv23; }
728 <INITIAL>{SSLv2}                { count(); yylval.strval=yytext; return SSLv2; }
729 <INITIAL>{SSLv3}                { count(); yylval.strval=yytext; return SSLv3; }
730 <INITIAL>{TLSv1}                { count(); yylval.strval=yytext; return TLSv1; }
731
732 <INITIAL>{COMMA}                { count(); return COMMA; }
733 <INITIAL>{SEMICOLON}    { count(); return SEMICOLON; }
734 <INITIAL>{COLON}        { count(); return COLON; }
735 <INITIAL>{STAR} { count(); return STAR; }
736 <INITIAL>{RPAREN}       { count(); return RPAREN; }
737 <INITIAL>{LPAREN}       { count(); return LPAREN; }
738 <INITIAL>{LBRACE}       { count(); return LBRACE; }
739 <INITIAL>{RBRACE}       { count(); return RBRACE; }
740 <INITIAL>{LBRACK}       { count(); return LBRACK; }
741 <INITIAL>{RBRACK}       { count(); return RBRACK; }
742 <INITIAL>{SLASH}        { count(); return SLASH; }
743 <INITIAL>{DOT}          { count(); return DOT; }
744 <INITIAL>\\{CR}         {count(); } /* eat the escaped CR */
745 <INITIAL>{CR}           { count();/* return CR;*/ }
746
747
748 <INITIAL,SELECT>{QUOTES} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING1); }
749 <INITIAL>{TICK} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING2); }
750
751
752 <STRING1>{QUOTES} { count(); state=old_state; BEGIN(old_initial);
753                                                 yytext[yyleng-1]=0; yyleng--;
754                                                 addstr(&s_buf, yytext, yyleng);
755                                                 yylval.strval=s_buf.s;
756                                                 memset(&s_buf, 0, sizeof(s_buf));
757                                                 return STRING;
758                                         }
759 <STRING2>{TICK}  { count(); state=old_state; BEGIN(old_initial);
760                                                 yytext[yyleng-1]=0; yyleng--;
761                                                 addstr(&s_buf, yytext, yyleng);
762                                                 yylval.strval=s_buf.s;
763                                                 memset(&s_buf, 0, sizeof(s_buf));
764                                                 return STRING;
765                                         }
766 <STRING2>.|{EAT_ABLE}|{CR}      { yymore(); }
767
768 <STRING1>\\n            { count(); addchar(&s_buf, '\n'); }
769 <STRING1>\\r            { count(); addchar(&s_buf, '\r'); }
770 <STRING1>\\a            { count(); addchar(&s_buf, '\a'); }
771 <STRING1>\\t            { count(); addchar(&s_buf, '\t'); }
772 <STRING1>\\{QUOTES}     { count(); addchar(&s_buf, '"');  }
773 <STRING1>\\\\           { count(); addchar(&s_buf, '\\'); }
774 <STRING1>\\x{HEX}{1,2}  { count(); addchar(&s_buf,
775                                                                                         (char)strtol(yytext+2, 0, 16)); }
776  /* don't allow \[0-7]{1}, it will eat the backreferences from
777     subst_uri if allowed (although everybody should use '' in subt_uri) */
778 <STRING1>\\[0-7]{2,3}   { count(); addchar(&s_buf,
779                                                                                         (char)strtol(yytext+1, 0, 8));  }
780 <STRING1>\\{CR}         { count(); } /* eat escaped CRs */
781 <STRING1>.|{EAT_ABLE}|{CR}      { addchar(&s_buf, *yytext); }
782
783
784 <INITIAL,COMMENT>{COM_START}    { count(); comment_nest++; state=COMMENT_S;
785                                                                                 BEGIN(COMMENT); }
786 <COMMENT>{COM_END}                              { count(); comment_nest--;
787                                                                                 if (comment_nest==0){
788                                                                                         state=INITIAL_S;
789                                                                                         BEGIN(INITIAL);
790                                                                                 }
791                                                                 }
792 <COMMENT>.|{EAT_ABLE}|{CR}                              { count(); };
793
794 <INITIAL>{COM_LINE}.*{CR}       { count(); }
795
796 <INITIAL>{ID}                   { count(); addstr(&s_buf, yytext, yyleng);
797                                                                         yylval.strval=s_buf.s;
798                                                                         memset(&s_buf, 0, sizeof(s_buf));
799                                                                         return ID; }
800
801 <SELECT>.               { unput(yytext[0]); state = INITIAL_S; BEGIN(INITIAL); } /* Rescan the token in INITIAL state */
802
803
804 <<EOF>>                                                 {
805                                                                         switch(state){
806                                                                                 case STRING_S:
807                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF in"
808                                                                                                                 " unclosed string\n");
809                                                                                         if (s_buf.s){
810                                                                                                 pkg_free(s_buf.s);
811                                                                                                 memset(&s_buf, 0,
812                                                                                                                         sizeof(s_buf));
813                                                                                         }
814                                                                                         break;
815                                                                                 case COMMENT_S:
816                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF:"
817                                                                                                                 " %d comments open\n", comment_nest);
818                                                                                         break;
819                                                                                 case COMMENT_LN_S:
820                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF:"
821                                                                                                                 "comment line open\n");
822                                                                                         break;
823                                                                         }
824                                                                         return 0;
825                                                                 }
826
827 %%
828
829
830 static char* addchar(struct str_buf* dst, char c)
831 {
832         return addstr(dst, &c, 1);
833 }
834
835
836
837 static char* addstr(struct str_buf* dst_b, char* src, int len)
838 {
839         char *tmp;
840         unsigned size;
841         unsigned used;
842
843         if (dst_b->left<(len+1)){
844                 used=(unsigned)(dst_b->crt-dst_b->s);
845                 size=used+len+1;
846                 /* round up to next multiple */
847                 size+= STR_BUF_ALLOC_UNIT-size%STR_BUF_ALLOC_UNIT;
848                 tmp=pkg_malloc(size);
849                 if (tmp==0) goto error;
850                 if (dst_b->s){
851                         memcpy(tmp, dst_b->s, used);
852                         pkg_free(dst_b->s);
853                 }
854                 dst_b->s=tmp;
855                 dst_b->crt=dst_b->s+used;
856                 dst_b->left=size-used;
857         }
858         memcpy(dst_b->crt, src, len);
859         dst_b->crt+=len;
860         *(dst_b->crt)=0;
861         dst_b->left-=len;
862
863         return dst_b->s;
864 error:
865         LOG(L_CRIT, "ERROR:lex:addstr: memory allocation error\n");
866         return 0;
867 }
868
869
870
871 static void count()
872 {
873         int i;
874
875         startcolumn=column;
876         for (i=0; i<yyleng;i++){
877                 if (yytext[i]=='\n'){
878                         line++;
879                         column=startcolumn=1;
880                 }else if (yytext[i]=='\t'){
881                         column++;
882                         /*column+=8 -(column%8);*/
883                 }else{
884                         column++;
885                 }
886         }
887 }
888
889
890
891 /* replacement yywrap, removes libfl dependency */
892 int yywrap()
893 {
894         return 1;
895 }