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