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