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