tcp: minor optimization
[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  *  2008-01-24  added CFG_DESCRIPTION used by cfg_var (Miklos)
78  *  2009-03-10  added SET_USERPHONE action (Miklos)
79 */
80
81
82 %{
83         #include "dprint.h"
84         #include "globals.h"
85         #include "mem/mem.h"
86         #include <string.h>
87         #include <stdlib.h>
88         #include "ip_addr.h"
89         #include "usr_avp.h"
90         #include "select.h"
91         #include "cfg.tab.h"
92
93         /* states */
94         #define INITIAL_S               0
95         #define COMMENT_S               1
96         #define COMMENT_LN_S            2
97         #define STRING_S                3
98         #define ATTR_S                  4
99         #define SELECT_S                5
100
101         #define STR_BUF_ALLOC_UNIT      128
102         struct str_buf{
103                 char* s;
104                 char* crt;
105                 int left;
106         };
107
108
109         static int comment_nest=0;
110         static int state=0, old_state=0, old_initial=0;
111         static struct str_buf s_buf;
112         int line=1;
113         int column=1;
114         int startcolumn=1;
115
116         static char* addchar(struct str_buf *, char);
117         static char* addstr(struct str_buf *, char*, int);
118         static void count();
119
120
121 %}
122
123 /* start conditions */
124 %x STRING1 STRING2 COMMENT COMMENT_LN ATTR SELECT
125
126 /* action keywords */
127 FORWARD forward
128 FORWARD_TCP     forward_tcp
129 FORWARD_UDP     forward_udp
130 FORWARD_TLS     forward_tls
131 FORWARD_SCTP    forward_sctp
132 DROP    "drop"|"exit"
133 RETURN  "return"
134 BREAK   "break"
135 SEND    send
136 SEND_TCP        send_tcp
137 LOG             log
138 ERROR   error
139 ROUTE   route
140 ROUTE_FAILURE failure_route
141 ROUTE_ONREPLY onreply_route
142 ROUTE_BRANCH branch_route
143 ROUTE_SEND onsend_route
144 EXEC    exec
145 FORCE_RPORT             "force_rport"|"add_rport"
146 FORCE_TCP_ALIAS         "force_tcp_alias"|"add_tcp_alias"
147 UDP_MTU         "udp_mtu"
148 UDP_MTU_TRY_PROTO       "udp_mtu_try_proto"
149 SETFLAG         setflag
150 RESETFLAG       resetflag
151 ISFLAGSET       isflagset
152 FLAGS_DECL      "flags"|"bool"
153 SETAVPFLAG      setavpflag
154 RESETAVPFLAG    resetavpflag
155 ISAVPFLAGSET    isavpflagset
156 AVPFLAGS_DECL   avpflags
157 SET_HOST                "rewritehost"|"sethost"|"seth"
158 SET_HOSTPORT    "rewritehostport"|"sethostport"|"sethp"
159 SET_HOSTPORTTRANS       "rewritehostporttrans"|"sethostporttrans"|"sethpt"
160 SET_USER                "rewriteuser"|"setuser"|"setu"
161 SET_USERPASS    "rewriteuserpass"|"setuserpass"|"setup"
162 SET_PORT                "rewriteport"|"setport"|"setp"
163 SET_URI                 "rewriteuri"|"seturi"
164 REVERT_URI              "revert_uri"
165 PREFIX                  "prefix"
166 STRIP                   "strip"
167 STRIP_TAIL              "strip_tail"
168 SET_USERPHONE           "userphone"
169 APPEND_BRANCH   "append_branch"
170 IF                              "if"
171 ELSE                    "else"
172 SET_ADV_ADDRESS "set_advertised_address"
173 SET_ADV_PORT    "set_advertised_port"
174 FORCE_SEND_SOCKET       "force_send_socket"
175
176 /*ACTION LVALUES*/
177 URIHOST                 "uri:host"
178 URIPORT                 "uri:port"
179
180 MAX_LEN                 "max_len"
181
182
183 /* condition keywords */
184 METHOD  method
185 /* hack -- the second element in first line is referable
186    as either uri or status; it only would makes sense to
187    call it "uri" from route{} and status from onreply_route{}
188 */
189 URI             "uri"|"status"
190 FROM_URI        "from_uri"
191 TO_URI          "to_uri"
192 SRCIP   src_ip
193 SRCPORT src_port
194 DSTIP   dst_ip
195 DSTPORT dst_port
196 SNDIP   snd_ip
197 SNDPORT snd_port
198 SNDPROTO        snd_proto|to_proto
199 SNDAF           snd_af|to_af
200 TOIP    to_ip
201 TOPORT  to_port
202 PROTO   proto
203 AF              af
204 MYSELF  myself
205 MSGLEN                  "msg:len"
206 RETCODE \$\?|\$retcode
207 /* operators */
208 EQUAL   =
209 EQUAL_T ==
210 GT      >
211 LT      <
212 GTE     >=
213 LTE     <=
214 DIFF    !=
215 MATCH   =~
216 ADDEQ     "+="
217 NOT             !|"not"
218 LOG_AND         "and"|"&&"
219 BIN_AND         "&"
220 LOG_OR          "or"|"||"
221 BIN_OR          "|"
222 PLUS    "+"
223 MINUS   "-"
224
225 /* Attribute specification */
226 ATTR_MARK   "$"|"%"
227 SELECT_MARK  "@"
228 ATTR_FROM         "f"
229 ATTR_TO           "t"
230 ATTR_FROMURI      "fr"
231 ATTR_TOURI       "tr"
232 ATTR_FROMUSER     "fu"
233 ATTR_TOUSER       "tu"
234 ATTR_FROMDOMAIN   "fd"
235 ATTR_TODOMAIN     "td"
236 ATTR_GLOBAL       "g"
237
238 /* config vars. */
239 DEBUG   debug
240 FORK    fork
241 LOGSTDERROR     log_stderror
242 LOGFACILITY     log_facility
243 LISTEN          listen
244 ALIAS           alias
245 DNS              dns
246 REV_DNS  rev_dns
247 DNS_TRY_IPV6    dns_try_ipv6
248 DNS_TRY_NAPTR   dns_try_naptr
249 DNS_SRV_LB              dns_srv_lb|dns_srv_loadbalancing
250 DNS_UDP_PREF    dns_udp_pref|dns_udp_preference
251 DNS_TCP_PREF    dns_tcp_pref|dns_tcp_preference
252 DNS_TLS_PREF    dns_tls_pref|dns_tls_preference
253 DNS_SCTP_PREF   dns_sctp_pref|dns_sctp_preference
254 DNS_RETR_TIME   dns_retr_time
255 DNS_RETR_NO             dns_retr_no
256 DNS_SERVERS_NO  dns_servers_no
257 DNS_USE_SEARCH  dns_use_search_list
258 DNS_SEARCH_FMATCH       dns_search_full_match
259 /* dns cache */
260 DNS_CACHE_INIT  dns_cache_init
261 DNS_USE_CACHE   use_dns_cache
262 DNS_USE_FAILOVER        use_dns_failover
263 DNS_CACHE_FLAGS         dns_cache_flags
264 DNS_CACHE_NEG_TTL       dns_cache_negative_ttl
265 DNS_CACHE_MIN_TTL       dns_cache_min_ttl
266 DNS_CACHE_MAX_TTL       dns_cache_max_ttl
267 DNS_CACHE_MEM           dns_cache_mem
268 DNS_CACHE_GC_INT        dns_cache_gc_interval
269 DNS_CACHE_DEL_NONEXP    dns_cache_del_nonexp|dns_cache_delete_nonexpired
270 /* blacklist */
271 DST_BLST_INIT   dst_blacklist_init
272 USE_DST_BLST            use_dst_blacklist
273 DST_BLST_MEM            dst_blacklist_mem
274 DST_BLST_TTL            dst_blacklist_expire|dst_blacklist_ttl
275 DST_BLST_GC_INT         dst_blacklist_gc_interval
276
277
278 PORT    port
279 STAT    statistics
280 MAXBUFFER maxbuffer
281 CHILDREN children
282 CHECK_VIA       check_via
283 PHONE2TEL       phone2tel
284 SYN_BRANCH syn_branch
285 MEMLOG          "memlog"|"mem_log"
286 MEMDBG          "memdbg"|"mem_dbg"
287 SIP_WARNING sip_warning
288 SERVER_SIGNATURE server_signature
289 REPLY_TO_VIA reply_to_via
290 USER            "user"|"uid"
291 GROUP           "group"|"gid"
292 CHROOT          "chroot"
293 WDIR            "workdir"|"wdir"
294 MHOMED          mhomed
295 DISABLE_TCP             "disable_tcp"
296 TCP_CHILDREN    "tcp_children"
297 TCP_ACCEPT_ALIASES      "tcp_accept_aliases"
298 TCP_SEND_TIMEOUT        "tcp_send_timeout"
299 TCP_CONNECT_TIMEOUT     "tcp_connect_timeout"
300 TCP_CON_LIFETIME        "tcp_connection_lifetime"
301 TCP_POLL_METHOD         "tcp_poll_method"
302 TCP_MAX_CONNECTIONS     "tcp_max_connections"
303 TCP_NO_CONNECT          "tcp_no_connect"
304 TCP_SOURCE_IPV4         "tcp_source_ipv4"
305 TCP_SOURCE_IPV6         "tcp_source_ipv6"
306 TCP_OPT_FD_CACHE        "tcp_fd_cache"
307 TCP_OPT_BUF_WRITE       "tcp_buf_write"|"tcp_async"
308 TCP_OPT_CONN_WQ_MAX     "tcp_conn_wq_max"
309 TCP_OPT_WQ_MAX          "tcp_wq_max"
310 TCP_OPT_RD_BUF          "tcp_rd_buf_size"
311 TCP_OPT_WQ_BLK          "tcp_wq_blk_size"
312 TCP_OPT_DEFER_ACCEPT "tcp_defer_accept"
313 TCP_OPT_DELAYED_ACK     "tcp_delayed_ack"
314 TCP_OPT_SYNCNT          "tcp_syncnt"
315 TCP_OPT_LINGER2         "tcp_linger2"
316 TCP_OPT_KEEPALIVE       "tcp_keepalive"
317 TCP_OPT_KEEPIDLE        "tcp_keepidle"
318 TCP_OPT_KEEPINTVL       "tcp_keepintvl"
319 TCP_OPT_KEEPCNT         "tcp_keepcnt"
320 TCP_OPT_CRLF_PING       "tcp_crlf_ping"
321 DISABLE_TLS             "disable_tls"|"tls_disable"
322 ENABLE_TLS              "enable_tls"|"tls_enable"
323 TLSLOG                  "tlslog"|"tls_log"
324 TLS_PORT_NO             "tls_port_no"
325 TLS_METHOD              "tls_method"
326 TLS_VERIFY              "tls_verify"
327 TLS_REQUIRE_CERTIFICATE "tls_require_certificate"
328 TLS_CERTIFICATE "tls_certificate"
329 TLS_PRIVATE_KEY "tls_private_key"
330 TLS_CA_LIST             "tls_ca_list"
331 TLS_HANDSHAKE_TIMEOUT   "tls_handshake_timeout"
332 TLS_SEND_TIMEOUT        "tls_send_timeout"
333 DISABLE_SCTP    "disable_sctp"
334 ENABLE_SCTP     "enable_sctp"
335 SCTP_CHILDREN   "sctp_children"
336 SCTP_SOCKET_RCVBUF      "sctp_socket_rcvbuf"|"sctp_socket_receive_buffer"
337 SCTP_SOCKET_SNDBUF      "sctp_socket_sndbuf"|"sctp_socket_send_buffer"
338 SCTP_AUTOCLOSE  "sctp_autoclose"
339 SCTP_SEND_TTL   "sctp_send_ttl"
340 SCTP_SEND_RETRIES       "sctp_send_retries"
341 ADVERTISED_ADDRESS      "advertised_address"
342 ADVERTISED_PORT         "advertised_port"
343 DISABLE_CORE            "disable_core_dump"
344 OPEN_FD_LIMIT           "open_files_limit"
345 SHM_FORCE_ALLOC         "shm_force_alloc"
346 MLOCK_PAGES                     "mlock_pages"
347 REAL_TIME                       "real_time"
348 RT_PRIO                         "rt_prio"
349 RT_POLICY                       "rt_policy"
350 RT_TIMER1_PRIO          "rt_timer1_prio"|"rt_fast_timer_prio"|"rt_ftimer_prio"
351 RT_TIMER1_POLICY        "rt_timer1_policy"|"rt_ftimer_policy"
352 RT_TIMER2_PRIO          "rt_timer2_prio"|"rt_stimer_prio"
353 RT_TIMER2_POLICY        "rt_timer2_policy"|"rt_stimer_policy"
354 MCAST_LOOPBACK          "mcast_loopback"
355 MCAST_TTL               "mcast_ttl"
356 TOS                     "tos"
357 PMTU_DISCOVERY  "pmtu_discovery"
358 KILL_TIMEOUT    "exit_timeout"|"ser_kill_timeout"
359
360 /* stun config variables */
361 STUN_REFRESH_INTERVAL "stun_refresh_interval"
362 STUN_ALLOW_STUN "stun_allow_stun"
363 STUN_ALLOW_FP "stun_allow_fp"
364
365 SERVER_ID     "server_id"
366
367 CFG_DESCRIPTION         "description"|"descr"|"desc"
368
369 LOADMODULE      loadmodule
370 LOADPATH        loadpath
371 MODPARAM        modparam
372
373 /* values */
374 YES                     "yes"|"true"|"on"|"enable"
375 NO                      "no"|"false"|"off"|"disable"
376 UDP                     "udp"|"UDP"
377 TCP                     "tcp"|"TCP"
378 TLS                     "tls"|"TLS"
379 SCTP            "sctp"|"SCTP"
380 INET            "inet"|"INET"
381 INET6           "inet6"|"INET6"
382 SSLv23                  "sslv23"|"SSLv23"|"SSLV23"
383 SSLv2                   "sslv2"|"SSLv2"|"SSLV2"
384 SSLv3                   "sslv3"|"SSLv3"|"SSLV3"
385 TLSv1                   "tlsv1"|"TLSv1"|"TLSV1"
386
387 LETTER          [a-zA-Z]
388 DIGIT           [0-9]
389 ALPHANUM        {LETTER}|{DIGIT}|[_]
390 ID                      {LETTER}{ALPHANUM}*
391 HEX                     [0-9a-fA-F]
392 HEXNUMBER       0x{HEX}+
393 OCTNUMBER       0[0-7]+
394 DECNUMBER       0|-?([1-9]{DIGIT}*)
395 BINNUMBER       [0-1]+b
396 HEX4            {HEX}{1,4}
397 IPV6ADDR        ({HEX4}":"){7}{HEX4}|({HEX4}":"){1,7}(":"{HEX4}){1,7}|":"(":"{HEX4}){1,7}|({HEX4}":"){1,7}":"|"::"
398 QUOTES          \"
399 TICK            \'
400 SLASH           "/"
401 SEMICOLON       ;
402 RPAREN          \)
403 LPAREN          \(
404 LBRACE          \{
405 RBRACE          \}
406 LBRACK          \[
407 RBRACK          \]
408 COMMA           ","
409 COLON           ":"
410 STAR            \*
411 DOT                     \.
412 CR                      \n
413
414
415
416 COM_LINE        #
417 COM_START       "/\*"
418 COM_END         "\*/"
419
420 EAT_ABLE        [\ \t\b\r]
421
422 %%
423
424
425 <INITIAL>{EAT_ABLE}     { count(); }
426
427 <INITIAL>{FORWARD}      {count(); yylval.strval=yytext; return FORWARD; }
428 <INITIAL>{FORWARD_TCP}  {count(); yylval.strval=yytext; return FORWARD_TCP; }
429 <INITIAL>{FORWARD_TLS}  {count(); yylval.strval=yytext; return FORWARD_TLS; }
430 <INITIAL>{FORWARD_SCTP} {count(); yylval.strval=yytext; return FORWARD_SCTP;}
431 <INITIAL>{FORWARD_UDP}  {count(); yylval.strval=yytext; return FORWARD_UDP; }
432 <INITIAL>{DROP} { count(); yylval.strval=yytext; return DROP; }
433 <INITIAL>{RETURN}       { count(); yylval.strval=yytext; return RETURN; }
434 <INITIAL>{BREAK}        { count(); yylval.strval=yytext; return BREAK; }
435 <INITIAL>{SEND} { count(); yylval.strval=yytext; return SEND; }
436 <INITIAL>{SEND_TCP}     { count(); yylval.strval=yytext; return SEND_TCP; }
437 <INITIAL>{LOG}  { count(); yylval.strval=yytext; return LOG_TOK; }
438 <INITIAL>{ERROR}        { count(); yylval.strval=yytext; return ERROR; }
439 <INITIAL>{SETFLAG}      { count(); yylval.strval=yytext; return SETFLAG; }
440 <INITIAL>{RESETFLAG}    { count(); yylval.strval=yytext; return RESETFLAG; }
441 <INITIAL>{ISFLAGSET}    { count(); yylval.strval=yytext; return ISFLAGSET; }
442 <INITIAL>{FLAGS_DECL}   { count(); yylval.strval=yytext; return FLAGS_DECL; }
443 <INITIAL>{SETAVPFLAG}   { count(); yylval.strval=yytext; return SETAVPFLAG; }
444 <INITIAL>{RESETAVPFLAG} { count(); yylval.strval=yytext; return RESETAVPFLAG; }
445 <INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
446 <INITIAL>{AVPFLAGS_DECL}        { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
447 <INITIAL>{MSGLEN}       { count(); yylval.strval=yytext; return MSGLEN; }
448 <INITIAL>{RETCODE}      { count(); yylval.strval=yytext; return RETCODE; }
449 <INITIAL>{ROUTE}        { count(); yylval.strval=yytext; return ROUTE; }
450 <INITIAL>{ROUTE_ONREPLY}        { count(); yylval.strval=yytext;
451                                                                 return ROUTE_ONREPLY; }
452 <INITIAL>{ROUTE_FAILURE}        { count(); yylval.strval=yytext;
453                                                                 return ROUTE_FAILURE; }
454 <INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
455 <INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
456 <INITIAL>{EXEC} { count(); yylval.strval=yytext; return EXEC; }
457 <INITIAL>{SET_HOST}     { count(); yylval.strval=yytext; return SET_HOST; }
458 <INITIAL>{SET_HOSTPORT} { count(); yylval.strval=yytext; return SET_HOSTPORT; }
459 <INITIAL>{SET_HOSTPORTTRANS}    { count(); yylval.strval=yytext; return SET_HOSTPORTTRANS; }
460 <INITIAL>{SET_USER}     { count(); yylval.strval=yytext; return SET_USER; }
461 <INITIAL>{SET_USERPASS} { count(); yylval.strval=yytext; return SET_USERPASS; }
462 <INITIAL>{SET_PORT}     { count(); yylval.strval=yytext; return SET_PORT; }
463 <INITIAL>{SET_URI}      { count(); yylval.strval=yytext; return SET_URI; }
464 <INITIAL>{REVERT_URI}   { count(); yylval.strval=yytext; return REVERT_URI; }
465 <INITIAL>{PREFIX}       { count(); yylval.strval=yytext; return PREFIX; }
466 <INITIAL>{STRIP}        { count(); yylval.strval=yytext; return STRIP; }
467 <INITIAL>{STRIP_TAIL}   { count(); yylval.strval=yytext; return STRIP_TAIL; }
468 <INITIAL>{APPEND_BRANCH}        { count(); yylval.strval=yytext;
469                                                                 return APPEND_BRANCH; }
470 <INITIAL>{SET_USERPHONE}        { count(); yylval.strval=yytext;
471                                                                 return SET_USERPHONE; }
472 <INITIAL>{FORCE_RPORT}  { count(); yylval.strval=yytext; return FORCE_RPORT; }
473 <INITIAL>{FORCE_TCP_ALIAS}      { count(); yylval.strval=yytext;
474                                                                 return FORCE_TCP_ALIAS; }
475 <INITIAL>{UDP_MTU}      { count(); yylval.strval=yytext; return UDP_MTU; }
476 <INITIAL>{UDP_MTU_TRY_PROTO}    { count(); yylval.strval=yytext;
477                                                                         return UDP_MTU_TRY_PROTO; }
478 <INITIAL>{IF}   { count(); yylval.strval=yytext; return IF; }
479 <INITIAL>{ELSE} { count(); yylval.strval=yytext; return ELSE; }
480
481 <INITIAL>{SET_ADV_ADDRESS}      { count(); yylval.strval=yytext;
482                                                                                 return SET_ADV_ADDRESS; }
483 <INITIAL>{SET_ADV_PORT} { count(); yylval.strval=yytext;
484                                                                                 return SET_ADV_PORT; }
485 <INITIAL>{FORCE_SEND_SOCKET}    {       count(); yylval.strval=yytext;
486                                                                         return FORCE_SEND_SOCKET; }
487
488 <INITIAL>{URIHOST}      { count(); yylval.strval=yytext; return URIHOST; }
489 <INITIAL>{URIPORT}      { count(); yylval.strval=yytext; return URIPORT; }
490
491 <INITIAL>{MAX_LEN}      { count(); yylval.strval=yytext; return MAX_LEN; }
492
493 <INITIAL>{METHOD}       { count(); yylval.strval=yytext; return METHOD; }
494 <INITIAL>{URI}  { count(); yylval.strval=yytext; return URI; }
495 <INITIAL>{FROM_URI}     { count(); yylval.strval=yytext; return FROM_URI; }
496 <INITIAL>{TO_URI}       { count(); yylval.strval=yytext; return TO_URI; }
497 <INITIAL>{SRCIP}        { count(); yylval.strval=yytext; return SRCIP; }
498 <INITIAL>{SRCPORT}      { count(); yylval.strval=yytext; return SRCPORT; }
499 <INITIAL>{DSTIP}        { count(); yylval.strval=yytext; return DSTIP; }
500 <INITIAL>{DSTPORT}      { count(); yylval.strval=yytext; return DSTPORT; }
501 <INITIAL>{SNDIP}        { count(); yylval.strval=yytext; return SNDIP; }
502 <INITIAL>{SNDPORT}      { count(); yylval.strval=yytext; return SNDPORT; }
503 <INITIAL>{SNDPROTO}     { count(); yylval.strval=yytext; return SNDPROTO; }
504 <INITIAL>{SNDAF}        { count(); yylval.strval=yytext; return SNDAF; }
505 <INITIAL>{TOIP}         { count(); yylval.strval=yytext; return TOIP; }
506 <INITIAL>{TOPORT}       { count(); yylval.strval=yytext; return TOPORT; }
507 <INITIAL>{PROTO}        { count(); yylval.strval=yytext; return PROTO; }
508 <INITIAL>{AF}   { count(); yylval.strval=yytext; return AF; }
509 <INITIAL>{MYSELF}       { count(); yylval.strval=yytext; return MYSELF; }
510
511 <INITIAL>{DEBUG}        { count(); yylval.strval=yytext; return DEBUG_V; }
512 <INITIAL>{FORK}         { count(); yylval.strval=yytext; return FORK; }
513 <INITIAL>{LOGSTDERROR}  { yylval.strval=yytext; return LOGSTDERROR; }
514 <INITIAL>{LOGFACILITY}  { yylval.strval=yytext; return LOGFACILITY; }
515 <INITIAL>{LISTEN}       { count(); yylval.strval=yytext; return LISTEN; }
516 <INITIAL>{ALIAS}        { count(); yylval.strval=yytext; return ALIAS; }
517 <INITIAL>{DNS}  { count(); yylval.strval=yytext; return DNS; }
518 <INITIAL>{REV_DNS}      { count(); yylval.strval=yytext; return REV_DNS; }
519 <INITIAL>{DNS_TRY_IPV6} { count(); yylval.strval=yytext;
520                                                                 return DNS_TRY_IPV6; }
521 <INITIAL>{DNS_TRY_NAPTR}        { count(); yylval.strval=yytext;
522                                                                 return DNS_TRY_NAPTR; }
523 <INITIAL>{DNS_SRV_LB}   { count(); yylval.strval=yytext;
524                                                                 return DNS_SRV_LB; }
525 <INITIAL>{DNS_UDP_PREF} { count(); yylval.strval=yytext;
526                                                                 return DNS_UDP_PREF; }
527 <INITIAL>{DNS_TCP_PREF} { count(); yylval.strval=yytext;
528                                                                 return DNS_TCP_PREF; }
529 <INITIAL>{DNS_TLS_PREF} { count(); yylval.strval=yytext;
530                                                                 return DNS_TLS_PREF; }
531 <INITIAL>{DNS_SCTP_PREF}        { count(); yylval.strval=yytext;
532                                                                 return DNS_SCTP_PREF; }
533 <INITIAL>{DNS_RETR_TIME}        { count(); yylval.strval=yytext;
534                                                                 return DNS_RETR_TIME; }
535 <INITIAL>{DNS_RETR_NO}  { count(); yylval.strval=yytext;
536                                                                 return DNS_RETR_NO; }
537 <INITIAL>{DNS_SERVERS_NO}       { count(); yylval.strval=yytext;
538                                                                 return DNS_SERVERS_NO; }
539 <INITIAL>{DNS_USE_SEARCH}       { count(); yylval.strval=yytext;
540                                                                 return DNS_USE_SEARCH; }
541 <INITIAL>{DNS_SEARCH_FMATCH}    { count(); yylval.strval=yytext;
542                                                                 return DNS_SEARCH_FMATCH; }
543 <INITIAL>{DNS_CACHE_INIT}       { count(); yylval.strval=yytext;
544                                                                 return DNS_CACHE_INIT; }
545 <INITIAL>{DNS_USE_CACHE}        { count(); yylval.strval=yytext;
546                                                                 return DNS_USE_CACHE; }
547 <INITIAL>{DNS_USE_FAILOVER}     { count(); yylval.strval=yytext;
548                                                                 return DNS_USE_FAILOVER; }
549 <INITIAL>{DNS_CACHE_FLAGS}      { count(); yylval.strval=yytext;
550                                                                 return DNS_CACHE_FLAGS; }
551 <INITIAL>{DNS_CACHE_NEG_TTL}    { count(); yylval.strval=yytext;
552                                                                 return DNS_CACHE_NEG_TTL; }
553 <INITIAL>{DNS_CACHE_MIN_TTL}    { count(); yylval.strval=yytext;
554                                                                 return DNS_CACHE_MIN_TTL; }
555 <INITIAL>{DNS_CACHE_MAX_TTL}    { count(); yylval.strval=yytext;
556                                                                 return DNS_CACHE_MAX_TTL; }
557 <INITIAL>{DNS_CACHE_MEM}        { count(); yylval.strval=yytext;
558                                                                 return DNS_CACHE_MEM; }
559 <INITIAL>{DNS_CACHE_GC_INT}     { count(); yylval.strval=yytext;
560                                                                 return DNS_CACHE_GC_INT; }
561 <INITIAL>{DNS_CACHE_DEL_NONEXP} { count(); yylval.strval=yytext;
562                                                                 return DNS_CACHE_DEL_NONEXP; }
563 <INITIAL>{DST_BLST_INIT}        { count(); yylval.strval=yytext;
564                                                                 return DST_BLST_INIT; }
565 <INITIAL>{USE_DST_BLST} { count(); yylval.strval=yytext;
566                                                                 return USE_DST_BLST; }
567 <INITIAL>{DST_BLST_MEM} { count(); yylval.strval=yytext;
568                                                                 return DST_BLST_MEM; }
569 <INITIAL>{DST_BLST_TTL} { count(); yylval.strval=yytext;
570                                                                 return DST_BLST_TTL; }
571 <INITIAL>{DST_BLST_GC_INT}      { count(); yylval.strval=yytext;
572                                                                 return DST_BLST_GC_INT; }
573 <INITIAL>{PORT} { count(); yylval.strval=yytext; return PORT; }
574 <INITIAL>{STAT} { count(); yylval.strval=yytext; return STAT; }
575 <INITIAL>{MAXBUFFER}    { count(); yylval.strval=yytext; return MAXBUFFER; }
576 <INITIAL>{CHILDREN}     { count(); yylval.strval=yytext; return CHILDREN; }
577 <INITIAL>{CHECK_VIA}    { count(); yylval.strval=yytext; return CHECK_VIA; }
578 <INITIAL>{PHONE2TEL}    { count(); yylval.strval=yytext; return PHONE2TEL; }
579 <INITIAL>{SYN_BRANCH}   { count(); yylval.strval=yytext; return SYN_BRANCH; }
580 <INITIAL>{MEMLOG}       { count(); yylval.strval=yytext; return MEMLOG; }
581 <INITIAL>{MEMDBG}       { count(); yylval.strval=yytext; return MEMDBG; }
582 <INITIAL>{SIP_WARNING}  { count(); yylval.strval=yytext; return SIP_WARNING; }
583 <INITIAL>{USER}         { count(); yylval.strval=yytext; return USER; }
584 <INITIAL>{GROUP}        { count(); yylval.strval=yytext; return GROUP; }
585 <INITIAL>{CHROOT}       { count(); yylval.strval=yytext; return CHROOT; }
586 <INITIAL>{WDIR} { count(); yylval.strval=yytext; return WDIR; }
587 <INITIAL>{MHOMED}       { count(); yylval.strval=yytext; return MHOMED; }
588 <INITIAL>{DISABLE_TCP}  { count(); yylval.strval=yytext; return DISABLE_TCP; }
589 <INITIAL>{TCP_CHILDREN} { count(); yylval.strval=yytext; return TCP_CHILDREN; }
590 <INITIAL>{TCP_ACCEPT_ALIASES}   { count(); yylval.strval=yytext;
591                                                                         return TCP_ACCEPT_ALIASES; }
592 <INITIAL>{TCP_SEND_TIMEOUT}             { count(); yylval.strval=yytext;
593                                                                         return TCP_SEND_TIMEOUT; }
594 <INITIAL>{TCP_CONNECT_TIMEOUT}          { count(); yylval.strval=yytext;
595                                                                         return TCP_CONNECT_TIMEOUT; }
596 <INITIAL>{TCP_CON_LIFETIME}             { count(); yylval.strval=yytext;
597                                                                         return TCP_CON_LIFETIME; }
598 <INITIAL>{TCP_POLL_METHOD}              { count(); yylval.strval=yytext;
599                                                                         return TCP_POLL_METHOD; }
600 <INITIAL>{TCP_MAX_CONNECTIONS}  { count(); yylval.strval=yytext;
601                                                                         return TCP_MAX_CONNECTIONS; }
602 <INITIAL>{TCP_NO_CONNECT}               { count(); yylval.strval=yytext;
603                                                                         return TCP_NO_CONNECT; }
604 <INITIAL>{TCP_SOURCE_IPV4}              { count(); yylval.strval=yytext;
605                                                                         return TCP_SOURCE_IPV4; }
606 <INITIAL>{TCP_SOURCE_IPV6}              { count(); yylval.strval=yytext;
607                                                                         return TCP_SOURCE_IPV6; }
608 <INITIAL>{TCP_OPT_FD_CACHE}             { count(); yylval.strval=yytext;
609                                                                         return TCP_OPT_FD_CACHE; }
610 <INITIAL>{TCP_OPT_CONN_WQ_MAX}  { count(); yylval.strval=yytext;
611                                                                         return TCP_OPT_CONN_WQ_MAX; }
612 <INITIAL>{TCP_OPT_WQ_MAX}       { count(); yylval.strval=yytext;
613                                                                         return TCP_OPT_WQ_MAX; }
614 <INITIAL>{TCP_OPT_RD_BUF}       { count(); yylval.strval=yytext;
615                                                                         return TCP_OPT_RD_BUF; }
616 <INITIAL>{TCP_OPT_WQ_BLK}       { count(); yylval.strval=yytext;
617                                                                         return TCP_OPT_WQ_BLK; }
618 <INITIAL>{TCP_OPT_BUF_WRITE}    { count(); yylval.strval=yytext;
619                                                                         return TCP_OPT_BUF_WRITE; }
620 <INITIAL>{TCP_OPT_DEFER_ACCEPT} { count(); yylval.strval=yytext;
621                                                                         return TCP_OPT_DEFER_ACCEPT; }
622 <INITIAL>{TCP_OPT_DELAYED_ACK}  { count(); yylval.strval=yytext;
623                                                                         return TCP_OPT_DELAYED_ACK; }
624 <INITIAL>{TCP_OPT_SYNCNT}               { count(); yylval.strval=yytext;
625                                                                         return TCP_OPT_SYNCNT; }
626 <INITIAL>{TCP_OPT_LINGER2}              { count(); yylval.strval=yytext;
627                                                                         return TCP_OPT_LINGER2; }
628 <INITIAL>{TCP_OPT_KEEPALIVE}    { count(); yylval.strval=yytext;
629                                                                         return TCP_OPT_KEEPALIVE; }
630 <INITIAL>{TCP_OPT_KEEPIDLE}             { count(); yylval.strval=yytext;
631                                                                         return TCP_OPT_KEEPIDLE; }
632 <INITIAL>{TCP_OPT_KEEPINTVL}    { count(); yylval.strval=yytext;
633                                                                         return TCP_OPT_KEEPINTVL; }
634 <INITIAL>{TCP_OPT_KEEPCNT}      { count(); yylval.strval=yytext;
635                                                                         return TCP_OPT_KEEPCNT; }
636 <INITIAL>{TCP_OPT_CRLF_PING}    { count(); yylval.strval=yytext;
637                                                                         return TCP_OPT_CRLF_PING; }
638 <INITIAL>{DISABLE_TLS}  { count(); yylval.strval=yytext; return DISABLE_TLS; }
639 <INITIAL>{ENABLE_TLS}   { count(); yylval.strval=yytext; return ENABLE_TLS; }
640 <INITIAL>{TLSLOG}               { count(); yylval.strval=yytext; return TLS_PORT_NO; }
641 <INITIAL>{TLS_PORT_NO}  { count(); yylval.strval=yytext; return TLS_PORT_NO; }
642 <INITIAL>{TLS_METHOD}   { count(); yylval.strval=yytext; return TLS_METHOD; }
643 <INITIAL>{TLS_VERIFY}   { count(); yylval.strval=yytext; return TLS_VERIFY; }
644 <INITIAL>{TLS_REQUIRE_CERTIFICATE}      { count(); yylval.strval=yytext;
645                                                                                 return TLS_REQUIRE_CERTIFICATE; }
646 <INITIAL>{TLS_CERTIFICATE}      { count(); yylval.strval=yytext;
647                                                                                 return TLS_CERTIFICATE; }
648 <INITIAL>{TLS_PRIVATE_KEY}      { count(); yylval.strval=yytext;
649                                                                                 return TLS_PRIVATE_KEY; }
650 <INITIAL>{TLS_CA_LIST}  { count(); yylval.strval=yytext;
651                                                                                 return TLS_CA_LIST; }
652 <INITIAL>{TLS_HANDSHAKE_TIMEOUT}        { count(); yylval.strval=yytext;
653                                                                                 return TLS_HANDSHAKE_TIMEOUT; }
654 <INITIAL>{TLS_SEND_TIMEOUT}     { count(); yylval.strval=yytext;
655                                                                                 return TLS_SEND_TIMEOUT; }
656 <INITIAL>{DISABLE_SCTP} { count(); yylval.strval=yytext; return DISABLE_SCTP;}
657 <INITIAL>{ENABLE_SCTP}  { count(); yylval.strval=yytext; return ENABLE_SCTP;}
658 <INITIAL>{SCTP_CHILDREN}        { count(); yylval.strval=yytext;
659                                                                                 return SCTP_CHILDREN; }
660 <INITIAL>{SCTP_SOCKET_RCVBUF}   { count(); yylval.strval=yytext;
661                                                                                 return SCTP_SOCKET_RCVBUF; }
662 <INITIAL>{SCTP_SOCKET_SNDBUF}   { count(); yylval.strval=yytext;
663                                                                                 return SCTP_SOCKET_SNDBUF; }
664 <INITIAL>{SCTP_AUTOCLOSE}       { count(); yylval.strval=yytext;
665                                                                                 return SCTP_AUTOCLOSE; }
666 <INITIAL>{SCTP_SEND_TTL}        { count(); yylval.strval=yytext;
667                                                                                 return SCTP_SEND_TTL; }
668 <INITIAL>{SCTP_SEND_RETRIES}    { count(); yylval.strval=yytext;
669                                                                                 return SCTP_SEND_RETRIES; }
670 <INITIAL>{SERVER_SIGNATURE}     { count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
671 <INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; }
672 <INITIAL>{ADVERTISED_ADDRESS}   {       count(); yylval.strval=yytext;
673                                                                         return ADVERTISED_ADDRESS; }
674 <INITIAL>{ADVERTISED_PORT}              {       count(); yylval.strval=yytext;
675                                                                         return ADVERTISED_PORT; }
676 <INITIAL>{DISABLE_CORE}         {       count(); yylval.strval=yytext;
677                                                                         return DISABLE_CORE; }
678 <INITIAL>{OPEN_FD_LIMIT}                {       count(); yylval.strval=yytext;
679                                                                         return OPEN_FD_LIMIT; }
680 <INITIAL>{SHM_FORCE_ALLOC}              {       count(); yylval.strval=yytext;
681                                                                         return SHM_FORCE_ALLOC; }
682 <INITIAL>{MLOCK_PAGES}          {       count(); yylval.strval=yytext;
683                                                                         return MLOCK_PAGES; }
684 <INITIAL>{REAL_TIME}            {       count(); yylval.strval=yytext;
685                                                                         return REAL_TIME; }
686 <INITIAL>{RT_PRIO}              {       count(); yylval.strval=yytext;
687                                                                         return RT_PRIO; }
688 <INITIAL>{RT_POLICY}            {       count(); yylval.strval=yytext;
689                                                                         return RT_POLICY; }
690 <INITIAL>{RT_TIMER1_PRIO}               {       count(); yylval.strval=yytext;
691                                                                         return RT_TIMER1_PRIO; }
692 <INITIAL>{RT_TIMER1_POLICY}             {       count(); yylval.strval=yytext;
693                                                                         return RT_TIMER1_POLICY; }
694 <INITIAL>{RT_TIMER2_PRIO}               {       count(); yylval.strval=yytext;
695                                                                         return RT_TIMER2_PRIO; }
696 <INITIAL>{RT_TIMER2_POLICY}             {       count(); yylval.strval=yytext;
697                                                                         return RT_TIMER2_POLICY; }
698 <INITIAL>{MCAST_LOOPBACK}               {       count(); yylval.strval=yytext;
699                                                                         return MCAST_LOOPBACK; }
700 <INITIAL>{MCAST_TTL}            {       count(); yylval.strval=yytext;
701                                                                         return MCAST_TTL; }
702 <INITIAL>{TOS}                  {       count(); yylval.strval=yytext;
703                                                                         return TOS; }
704 <INITIAL>{PMTU_DISCOVERY}               {       count(); yylval.strval=yytext;
705                                                                         return PMTU_DISCOVERY; }
706 <INITIAL>{KILL_TIMEOUT}                 {       count(); yylval.strval=yytext;
707                                                                         return KILL_TIMEOUT; }
708 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
709 <INITIAL>{CFG_DESCRIPTION}      { count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
710 <INITIAL>{LOADMODULE}   { count(); yylval.strval=yytext; return LOADMODULE; }
711 <INITIAL>{LOADPATH}             { count(); yylval.strval=yytext; return LOADPATH; }
712 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
713
714 <INITIAL>{STUN_REFRESH_INTERVAL} { count(); yylval.strval=yytext; return STUN_REFRESH_INTERVAL;}
715 <INITIAL>{STUN_ALLOW_STUN} { count(); yylval.strval=yytext; return STUN_ALLOW_STUN;}
716 <INITIAL>{STUN_ALLOW_FP} { count(); yylval.strval=yytext; return STUN_ALLOW_FP;}
717
718 <INITIAL>{EQUAL}        { count(); return EQUAL; }
719 <INITIAL>{ADDEQ}          { count(); return ADDEQ; }
720 <INITIAL>{EQUAL_T}      { count(); return EQUAL_T; }
721 <INITIAL>{GT}   { count(); return GT; }
722 <INITIAL>{LT}   { count(); return LT; }
723 <INITIAL>{GTE}  { count(); return GTE; }
724 <INITIAL>{LTE}  { count(); return LTE; }
725 <INITIAL>{DIFF} { count(); return DIFF; }
726 <INITIAL>{MATCH}        { count(); return MATCH; }
727 <INITIAL>{NOT}          { count(); return NOT; }
728 <INITIAL>{LOG_AND}      { count(); return LOG_AND; }
729 <INITIAL>{BIN_AND}      { count(); return BIN_AND; }
730 <INITIAL>{LOG_OR}       { count(); return LOG_OR;  }
731 <INITIAL>{BIN_OR}       { count(); return BIN_OR;  }
732 <INITIAL>{PLUS}         { count(); return PLUS; }
733 <INITIAL>{MINUS}        { count(); return MINUS; }
734
735 <INITIAL>{SELECT_MARK}  { count(); state = SELECT_S; BEGIN(SELECT); return SELECT_MARK; }
736 <SELECT>{ID}            { count(); addstr(&s_buf, yytext, yyleng);
737                           yylval.strval=s_buf.s;
738                           memset(&s_buf, 0, sizeof(s_buf));
739                           return ID;
740                         }
741 <SELECT>{DOT}           { count(); return DOT; }
742 <SELECT>{LBRACK}        { count(); return LBRACK; }
743 <SELECT>{RBRACK}        { count(); return RBRACK; }
744 <SELECT>{DECNUMBER}     { count(); yylval.intval=atoi(yytext);return NUMBER; }
745 <SELECT>{HEXNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 16); return NUMBER; }
746 <SELECT>{OCTNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 8); return NUMBER; }
747 <SELECT>{BINNUMBER}     { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
748
749
750 <INITIAL>{ATTR_MARK}    { count(); state = ATTR_S; BEGIN(ATTR); return ATTR_MARK; }
751 <ATTR>{ATTR_FROM}       { count(); return ATTR_FROM; }
752 <ATTR>{ATTR_TO}         { count(); return ATTR_TO; }
753 <ATTR>{ATTR_FROMURI}    { count(); return ATTR_FROMURI; }
754 <ATTR>{ATTR_TOURI}      { count(); return ATTR_TOURI; }
755 <ATTR>{ATTR_FROMUSER}   { count(); return ATTR_FROMUSER; }
756 <ATTR>{ATTR_TOUSER}     { count(); return ATTR_TOUSER; }
757 <ATTR>{ATTR_FROMDOMAIN} { count(); return ATTR_FROMDOMAIN; }
758 <ATTR>{ATTR_TODOMAIN}   { count(); return ATTR_TODOMAIN; }
759 <ATTR>{ATTR_GLOBAL}     { count(); return ATTR_GLOBAL; }
760 <ATTR>{DOT}             { count(); return DOT; }
761 <ATTR>{LBRACK}          { count(); return LBRACK; }
762 <ATTR>{RBRACK}          { count(); return RBRACK; }
763 <ATTR>{STAR}            { count(); return STAR; }
764 <ATTR>{DECNUMBER}       { count(); yylval.intval=atoi(yytext);return NUMBER; }
765 <ATTR>{ID}              { count(); addstr(&s_buf, yytext, yyleng);
766                            yylval.strval=s_buf.s;
767                            memset(&s_buf, 0, sizeof(s_buf));
768                            state = INITIAL_S;
769                            BEGIN(INITIAL);
770                            return ID;
771                         }
772
773 <INITIAL>{IPV6ADDR}             { count(); yylval.strval=yytext; return IPV6ADDR; }
774 <INITIAL>{DECNUMBER}            { count(); yylval.intval=atoi(yytext);return NUMBER; }
775 <INITIAL>{HEXNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 16);
776                                                         return NUMBER; }
777 <INITIAL>{OCTNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 8);
778                                                         return NUMBER; }
779 <INITIAL>{BINNUMBER}    { count(); yylval.intval=(int)strtol(yytext, 0, 2); return NUMBER; }
780 <INITIAL>{YES}                  { count(); yylval.intval=1; return NUMBER; }
781 <INITIAL>{NO}                   { count(); yylval.intval=0; return NUMBER; }
782 <INITIAL>{TCP}                  { count(); return TCP; }
783 <INITIAL>{UDP}                  { count(); return UDP; }
784 <INITIAL>{TLS}                  { count(); return TLS; }
785 <INITIAL>{SCTP}                 { count(); return SCTP; }
786 <INITIAL>{INET}                 { count(); yylval.intval=AF_INET; return NUMBER; }
787 <INITIAL>{INET6}                { count();
788                                                 #ifdef USE_IPV6
789                                                   yylval.intval=AF_INET6;
790                                                 #else
791                                                   yylval.intval=-1; /* no match*/
792                                                 #endif
793                                                   return NUMBER; }
794 <INITIAL>{SSLv23}               { count(); yylval.strval=yytext; return SSLv23; }
795 <INITIAL>{SSLv2}                { count(); yylval.strval=yytext; return SSLv2; }
796 <INITIAL>{SSLv3}                { count(); yylval.strval=yytext; return SSLv3; }
797 <INITIAL>{TLSv1}                { count(); yylval.strval=yytext; return TLSv1; }
798
799 <INITIAL>{COMMA}                { count(); return COMMA; }
800 <INITIAL>{SEMICOLON}    { count(); return SEMICOLON; }
801 <INITIAL>{COLON}        { count(); return COLON; }
802 <INITIAL>{STAR} { count(); return STAR; }
803 <INITIAL>{RPAREN}       { count(); return RPAREN; }
804 <INITIAL>{LPAREN}       { count(); return LPAREN; }
805 <INITIAL>{LBRACE}       { count(); return LBRACE; }
806 <INITIAL>{RBRACE}       { count(); return RBRACE; }
807 <INITIAL>{LBRACK}       { count(); return LBRACK; }
808 <INITIAL>{RBRACK}       { count(); return RBRACK; }
809 <INITIAL>{SLASH}        { count(); return SLASH; }
810 <INITIAL>{DOT}          { count(); return DOT; }
811 <INITIAL>\\{CR}         {count(); } /* eat the escaped CR */
812 <INITIAL>{CR}           { count();/* return CR;*/ }
813
814
815 <INITIAL,SELECT>{QUOTES} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING1); }
816 <INITIAL>{TICK} { count(); old_initial = YY_START; old_state = state; state=STRING_S; BEGIN(STRING2); }
817
818
819 <STRING1>{QUOTES} { count(); state=old_state; BEGIN(old_initial);
820                                                 yytext[yyleng-1]=0; yyleng--;
821                                                 addstr(&s_buf, yytext, yyleng);
822                                                 yylval.strval=s_buf.s;
823                                                 memset(&s_buf, 0, sizeof(s_buf));
824                                                 return STRING;
825                                         }
826 <STRING2>{TICK}  { count(); state=old_state; BEGIN(old_initial);
827                                                 yytext[yyleng-1]=0; yyleng--;
828                                                 addstr(&s_buf, yytext, yyleng);
829                                                 yylval.strval=s_buf.s;
830                                                 memset(&s_buf, 0, sizeof(s_buf));
831                                                 return STRING;
832                                         }
833 <STRING2>.|{EAT_ABLE}|{CR}      { yymore(); }
834
835 <STRING1>\\n            { count(); addchar(&s_buf, '\n'); }
836 <STRING1>\\r            { count(); addchar(&s_buf, '\r'); }
837 <STRING1>\\a            { count(); addchar(&s_buf, '\a'); }
838 <STRING1>\\t            { count(); addchar(&s_buf, '\t'); }
839 <STRING1>\\{QUOTES}     { count(); addchar(&s_buf, '"');  }
840 <STRING1>\\\\           { count(); addchar(&s_buf, '\\'); }
841 <STRING1>\\x{HEX}{1,2}  { count(); addchar(&s_buf,
842                                                                                         (char)strtol(yytext+2, 0, 16)); }
843  /* don't allow \[0-7]{1}, it will eat the backreferences from
844     subst_uri if allowed (although everybody should use '' in subt_uri) */
845 <STRING1>\\[0-7]{2,3}   { count(); addchar(&s_buf,
846                                                                                         (char)strtol(yytext+1, 0, 8));  }
847 <STRING1>\\{CR}         { count(); } /* eat escaped CRs */
848 <STRING1>.|{EAT_ABLE}|{CR}      { addchar(&s_buf, *yytext); }
849
850
851 <INITIAL,COMMENT>{COM_START}    { count(); comment_nest++; state=COMMENT_S;
852                                                                                 BEGIN(COMMENT); }
853 <COMMENT>{COM_END}                              { count(); comment_nest--;
854                                                                                 if (comment_nest==0){
855                                                                                         state=INITIAL_S;
856                                                                                         BEGIN(INITIAL);
857                                                                                 }
858                                                                 }
859 <COMMENT>.|{EAT_ABLE}|{CR}                              { count(); };
860
861 <INITIAL>{COM_LINE}.*{CR}       { count(); }
862
863 <INITIAL>{ID}                   { count(); addstr(&s_buf, yytext, yyleng);
864                                                                         yylval.strval=s_buf.s;
865                                                                         memset(&s_buf, 0, sizeof(s_buf));
866                                                                         return ID; }
867
868 <SELECT>.               { unput(yytext[0]); state = INITIAL_S; BEGIN(INITIAL); } /* Rescan the token in INITIAL state */
869
870
871 <<EOF>>                                                 {
872                                                                         switch(state){
873                                                                                 case STRING_S:
874                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF in"
875                                                                                                                 " unclosed string\n");
876                                                                                         if (s_buf.s){
877                                                                                                 pkg_free(s_buf.s);
878                                                                                                 memset(&s_buf, 0,
879                                                                                                                         sizeof(s_buf));
880                                                                                         }
881                                                                                         break;
882                                                                                 case COMMENT_S:
883                                                                                         LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF:"
884                                                                                                                 " %d comments open\n", comment_nest);
885                                                                                         break;
886                                                                                 case COMMENT_LN_S:
887                                                                                         LOG(L_CRIT, "ERROR: unexpected EOF:"
888                                                                                                                 "comment line open\n");
889                                                                                         break;
890                                                                         }
891                                                                         return 0;
892                                                                 }
893
894 %%
895
896
897 static char* addchar(struct str_buf* dst, char c)
898 {
899         return addstr(dst, &c, 1);
900 }
901
902
903
904 static char* addstr(struct str_buf* dst_b, char* src, int len)
905 {
906         char *tmp;
907         unsigned size;
908         unsigned used;
909
910         if (dst_b->left<(len+1)){
911                 used=(unsigned)(dst_b->crt-dst_b->s);
912                 size=used+len+1;
913                 /* round up to next multiple */
914                 size+= STR_BUF_ALLOC_UNIT-size%STR_BUF_ALLOC_UNIT;
915                 tmp=pkg_malloc(size);
916                 if (tmp==0) goto error;
917                 if (dst_b->s){
918                         memcpy(tmp, dst_b->s, used);
919                         pkg_free(dst_b->s);
920                 }
921                 dst_b->s=tmp;
922                 dst_b->crt=dst_b->s+used;
923                 dst_b->left=size-used;
924         }
925         memcpy(dst_b->crt, src, len);
926         dst_b->crt+=len;
927         *(dst_b->crt)=0;
928         dst_b->left-=len;
929
930         return dst_b->s;
931 error:
932         LOG(L_CRIT, "ERROR:lex:addstr: memory allocation error\n");
933         return 0;
934 }
935
936
937
938 static void count()
939 {
940         int i;
941
942         startcolumn=column;
943         for (i=0; i<yyleng;i++){
944                 if (yytext[i]=='\n'){
945                         line++;
946                         column=startcolumn=1;
947                 }else if (yytext[i]=='\t'){
948                         column++;
949                         /*column+=8 -(column%8);*/
950                 }else{
951                         column++;
952                 }
953         }
954 }
955
956
957
958 /* replacement yywrap, removes libfl dependency */
959 int yywrap()
960 {
961         return 1;
962 }