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