Author: Alex Badea <vampire@p16.pub.ro>
[ircu2.10.12-pk.git] / ircd / ircd_parser.y
1 /*
2  * ircd_parser.y: A yacc/bison parser for ircd config files.
3  * This is part of ircu, an Internet Relay Chat server.
4  * The contents of this file are Copyright(C) 2001 by Andrew Miller, the
5  * ircd-hybrid team and the ircu team.
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19  *  USA.
20  * $Id$
21  */
22 %{
23
24 #include "config.h"
25 #include "s_conf.h"
26 #include "class.h"
27 #include "client.h"
28 #include "crule.h"
29 #include "ircd_features.h"
30 #include "fileio.h"
31 #include "gline.h"
32 #include "hash.h"
33 #include "ircd.h"
34 #include "ircd_alloc.h"
35 #include "ircd_chattr.h"
36 #include "ircd_log.h"
37 #include "ircd_reply.h"
38 #include "ircd_snprintf.h"
39 #include "ircd_string.h"
40 #include "list.h"
41 #include "listener.h"
42 #include "match.h"
43 #include "motd.h"
44 #include "numeric.h"
45 #include "numnicks.h"
46 #include "opercmds.h"
47 #include "parse.h"
48 #include "res.h"
49 #include "s_bsd.h"
50 #include "s_debug.h"
51 #include "s_misc.h"
52 #include "send.h"
53 #include "struct.h"
54 #include "support.h"
55 #include "sys.h"
56 #include <stdlib.h>
57 #include <string.h>
58 #include <arpa/inet.h>
59 #define MAX_STRINGS 80 /* Maximum number of feature params. */
60   extern struct LocalConf   localConf;
61   extern struct DenyConf*   denyConfList;
62   extern struct CRuleConf*  cruleConfList;
63   extern struct ServerConf* serverConfList;
64
65   int yylex(void);
66   /* Now all the globals we need :/... */
67   int tping, tconn, maxlinks, sendq, port;
68   int stringno;
69   char *name, *pass, *host;
70   char *stringlist[MAX_STRINGS];
71   struct ConnectionClass *class;
72   struct ConfItem *aconf;
73   struct DenyConf *dconf;
74   struct ServerConf *sconf;
75 %}
76
77 %token <text> QSTRING
78 %token <num> NUMBER
79 %token <text> FNAME
80
81 %token GENERAL
82 %token ADMIN
83 %token LOCATION
84 %token CONTACT
85 %token CONNECT
86 %token CLASS
87 %token PINGFREQ
88 %token CONNECTFREQ
89 %token MAXLINKS
90 %token SENDQ
91 %token NAME
92 %token HOST
93 %token PASS
94 %token LOCAL
95 %token SECONDS
96 %token MINUTES
97 %token HOURS
98 %token DAYS
99 %token WEEKS
100 %token MONTHS
101 %token YEARS
102 %token DECADES
103 %token BYTES
104 %token KBYTES
105 %token MBYTES
106 %token GBYTES
107 %token TBYTES
108 %token SERVER
109 %token PORT
110 %token MASK
111 %token HUB
112 %token LEAF
113 %token UWORLD
114 %token YES
115 %token NO
116 %token OPER
117 %token PORT
118 %token VHOST
119 %token MASK
120 %token HIDDEN
121 %token MOTD
122 %token JUPE
123 %token NICK
124 %token NUMERIC
125 %token DESCRIPTION
126 %token CLIENT
127 %token KILL
128 %token CRULE
129 %token REAL
130 %token REASON
131 %token TFILE
132 %token RULE
133 %token ALL
134 %token IP
135 %token FEATURES
136 /* and now a lot of priviledges... */
137 %token TPRIV_CHAN_LIMIT, TPRIV_MODE_LCHAN, TPRIV_DEOP_LCHAN, TPRIV_WALK_LCHAN
138 %token TPRIV_KILL, TPRIV_LOCAL_KILL, TPRIV_REHASH, TPRIV_RESTART, TPRIV_DIE
139 %token TPRIV_GLINE, TPRIV_LOCAL_GLINE, TPRIV_JUPE, TPRIV_LOCAL_JUPE
140 %token TPRIV_LOCAL_OPMODE, TPRIV_OPMODE, TPRIV_SET, TPRIV_WHOX, TPRIV_BADCHAN
141 %token TPRIV_LOCAL_BADCHAN
142 %token TPRIV_SEE_CHAN, TPRIV_SHOW_INVIS, TPRIV_SHOW_ALL_INVIS, TPRIV_PROPAGATE
143 %token TPRIV_UNLIMIT_QUERY, TPRIV_DISPLAY, TPRIV_SEE_OPERS, TPRIV_WIDE_GLINE
144 /* and some types... */
145 %type <num> sizespec
146 %type <num> timespec, timefactor, factoredtimes, factoredtime
147 %type <num> expr, yesorno, privtype
148 %left '+' '-'
149 %left '*' '/'
150
151 %union{
152  char *text;
153  int num;
154 }
155
156 %%
157 /* Blocks in the config file... */
158 blocks: blocks block | block;
159 block: adminblock | generalblock | classblock | connectblock |
160        serverblock | operblock | portblock | jupeblock | clientblock |
161        killblock | cruleblock | motdblock | featuresblock;
162
163 /* The timespec, sizespec and expr was ripped straight from
164  * ircd-hybrid-7. */
165 timespec: expr | factoredtimes;
166
167 factoredtimes: factoredtimes factoredtime
168 {
169   $$ = $1 + $2;
170 } | factoredtime;
171
172 factoredtime: expr timefactor
173 {
174   $$ = $1 * $2;
175 };
176
177 timefactor: SECONDS { $$ = 1; }
178 | MINUTES { $$ = 60; }
179 | HOURS { $$ = 60 * 60; }
180 | DAYS { $$ = 60 * 60 * 24; }
181 | WEEKS { $$ = 60 * 60 * 24 * 7; }
182 | MONTHS { $$ = 60 * 60 * 24 * 7 * 4; }
183 | YEARS { $$ = 60 * 60 * 24 * 365; }
184 | DECADES { $$ = 60 * 60 * 24 * 365 * 10; };
185
186
187 sizespec:       expr    
188                 = {
189                         $$ = $1;
190                 }
191                 | expr BYTES
192                 = { 
193                         $$ = $1;
194                 }
195                 | expr KBYTES
196                 = {
197                         $$ = $1 * 1024;
198                 }
199                 | expr MBYTES
200                 = {
201                         $$ = $1 * 1024 * 1024;
202                 }
203                 | expr GBYTES
204                 = {
205                         $$ = $1 * 1024 * 1024 * 1024;
206                 }
207                 | expr TBYTES
208                 = {
209                         $$ = $1 * 1024 * 1024 * 1024;
210                 }
211                 ;
212
213 /* this is an arithmatic expression */
214 expr: NUMBER
215                 = { 
216                         $$ = $1;
217                 }
218                 | expr '+' expr
219                 = { 
220                         $$ = $1 + $3;
221                 }
222                 | expr '-' expr
223                 = { 
224                         $$ = $1 - $3;
225                 }
226                 | expr '*' expr
227                 = { 
228                         $$ = $1 * $3;
229                 }
230                 | expr '/' expr
231                 = { 
232                         $$ = $1 / $3;
233                 }
234 /* leave this out until we find why it makes BSD yacc dump core -larne
235                 | '-' expr  %prec NEG
236                 = {
237                         $$ = -$2;
238                 } */
239                 | '(' expr ')'
240                 = {
241                         $$ = $2;
242                 }
243                 ;
244
245 jupeblock: JUPE '{' jupeitems '}' ';' ;
246 jupeitems: jupeitem jupeitems | jupeitem;
247 jupeitem: jupenick;
248 jupenick: NICK '=' QSTRING
249 {
250   addNickJupes(yylval.text);
251 } ';';
252
253 generalblock: GENERAL '{' generalitems '}' ';' ;
254 generalitems: generalitem generalitems | generalitem;
255 generalitem: generalnumeric | generalname | generalvhost | generaldesc;
256 generalnumeric: NUMERIC '=' NUMBER ';'
257 {
258   if (localConf.numeric == 0)
259     localConf.numeric = yylval.num;
260 };
261
262 generalname: NAME '=' QSTRING ';'
263 {
264   if (localConf.name == NULL)
265     DupString(localConf.name, yylval.text);
266 };
267
268 generaldesc: DESCRIPTION '=' QSTRING ';'
269 {
270   MyFree(localConf.description);
271   DupString(localConf.description, yylval.text);
272 };
273
274 generalvhost: VHOST '=' QSTRING ';'
275 {
276   if (INADDR_NONE ==
277       (localConf.vhost_address.s_addr = inet_addr(yylval.text)))
278     localConf.vhost_address.s_addr = INADDR_ANY;
279 };
280
281 adminblock: ADMIN '{' adminitems '}'
282 {
283   if (localConf.location1 == NULL)
284     DupString(localConf.location1, "");
285   if (localConf.location2 == NULL)
286     DupString(localConf.location2, "");
287   if (localConf.contact == NULL)
288     DupString(localConf.contact, "");
289 } ';';
290 adminitems: adminitems adminitem | adminitem;
291 adminitem: adminlocation | admincontact;
292 adminlocation: LOCATION '=' QSTRING ';'
293 {
294  if (localConf.location1 == NULL)
295   DupString(localConf.location1, yylval.text);
296  else if (localConf.location2 == NULL)
297   DupString(localConf.location2, yylval.text);
298  /* Otherwise just drop it. -A1kmm */
299 };
300 admincontact: CONTACT '=' QSTRING ';'
301 {
302  if (localConf.contact != NULL)
303   free(localConf.contact);
304  DupString(localConf.contact, yylval.text);
305 };
306
307 classblock: CLASS {
308  name = NULL;
309  tping = 90;
310  tconn = 0;
311  maxlinks = 0;
312  sendq = 0;
313 } '{' classitems '}'
314 {
315  if (name != NULL)
316  {
317   add_class(name, tping, tconn, maxlinks, sendq);
318  }
319 } ';';
320 classitems: classitem classitems | classitem;
321 classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
322            classsendq;
323 classname: NAME '=' QSTRING ';'
324 {
325  MyFree(name);
326  DupString(name, yylval.text);
327 };
328 classpingfreq: PINGFREQ '=' timespec ';'
329 {
330  tping = yylval.num;
331 };
332 classconnfreq: CONNECTFREQ '=' timespec ';'
333 {
334  tconn = yylval.num;
335 };
336 classmaxlinks: MAXLINKS '=' expr ';'
337 {
338  maxlinks = yylval.num;
339 };
340 classsendq: SENDQ '=' sizespec ';'
341 {
342  sendq = yylval.num;
343 };
344
345 connectblock: CONNECT
346 {
347  name = pass = host = NULL;
348  class = NULL;
349  port = 0;
350 } '{' connectitems '}'
351 {
352  if (name != NULL && pass != NULL && host != NULL && class != NULL && 
353      /*ccount < MAXCONFLINKS &&*/ !strchr(host, '*') &&
354      !strchr(host, '?'))
355  {
356   aconf = MyMalloc(sizeof(*aconf));
357   aconf->status = CONF_SERVER;
358   aconf->name = name;
359   aconf->passwd = pass;
360   aconf->conn_class = class;
361   aconf->port = port;
362   aconf->status = CONF_SERVER;
363   aconf->host = host;
364   aconf->next = GlobalConfList;
365   GlobalConfList = aconf;
366   printf("Server added: %s\n", name);
367   /* ccount++; -- XXX fixme --- A1kmm */
368  }
369  else
370  {
371   MyFree(name);
372   MyFree(pass);
373   MyFree(host);
374   name = pass = host = NULL;
375  }
376 }';';
377 connectitems: connectitem connectitems | connectitem;
378 connectitem: connectname | connectpass | connectclass | connecthost
379               | connectport;
380 connectname: NAME '=' QSTRING ';'
381 {
382  MyFree(name);
383  DupString(name, yylval.text);
384 };
385 connectpass: PASS '=' QSTRING ';'
386 {
387  MyFree(pass);
388  DupString(pass, yylval.text);
389 };
390 connectclass: CLASS '=' QSTRING ';'
391 {
392  class = find_class(yylval.text);
393 };
394 connecthost: HOST '=' QSTRING ';'
395 {
396  MyFree(host);
397  DupString(host, yylval.text);
398 };
399 connectport: PORT '=' NUMBER ';'
400 {
401  port = yylval.num;
402 };
403
404 serverblock: SERVER
405 {
406  aconf = MyMalloc(sizeof(*aconf));
407  memset(aconf, 0, sizeof(*aconf));
408 } '{' serveritems '}'
409 {
410  if (aconf->status == 0)
411  {
412    MyFree(aconf->host);
413    MyFree(aconf->name);
414    MyFree(aconf);
415    aconf = NULL;
416  }
417  else
418  {
419    aconf->next = GlobalConfList;
420    GlobalConfList = aconf;
421  }
422 } ';';
423 serveritems: serveritem serveritems | serveritem;
424 serveritem: servername | servermask | serverhub | serverleaf |
425              serveruworld;
426 servername: NAME '=' QSTRING
427 {
428  MyFree(aconf->name);
429  DupString(aconf->name, yylval.text);
430 } ';' ;
431 servermask: MASK '=' QSTRING
432 {
433  MyFree(aconf->host);
434  DupString(aconf->host, yylval.text);
435 } ';' ;
436 /* XXX - perhaps we should do this the hybrid way in connect blocks
437  * instead -A1kmm. */
438 serverhub: HUB '=' YES ';'
439 {
440  aconf->status |= CONF_HUB;
441  aconf->status &= ~CONF_LEAF;
442 }
443 | HUB '=' NO
444 {
445  aconf->status &= ~CONF_HUB;
446 } ';'; 
447 serverleaf: LEAF '=' YES ';'
448 {
449  if (!(aconf->status & CONF_HUB && aconf->status & CONF_UWORLD))
450   aconf->status |= CONF_LEAF;
451 }
452 | LEAF '=' NO ';'
453 {
454  aconf->status &= ~CONF_LEAF;
455 };
456 serveruworld: UWORLD '=' YES ';'
457 {
458  aconf->status |= CONF_UWORLD;
459  aconf->status &= ~CONF_LEAF;
460 }
461 | UWORLD '=' NO ';'
462 {
463   aconf->status &= ~CONF_UWORLD;
464 };
465
466 operblock: OPER
467 {
468   aconf = MyMalloc(sizeof(*aconf));
469   memset(aconf, 0, sizeof(*aconf));
470   aconf->status = CONF_OPERATOR;
471   set_initial_oper_privs(aconf, (FLAGS_OPER | FLAGS_LOCOP));
472 } '{' operitems '}' ';'
473 {
474   if (aconf->name != NULL && aconf->passwd != NULL && aconf->host != NULL)
475   {
476     log_write(LS_CONFIG, L_ERROR, 0, "added an oper block for host %s", aconf->host);
477     aconf->next = GlobalConfList;
478     GlobalConfList = aconf;
479   }
480   else
481   {
482     log_write(LS_CONFIG, L_ERROR, 0, "operator blocks need a name, password, and host.");
483     MyFree(aconf->name);
484     MyFree(aconf->passwd);
485     MyFree(aconf->host);
486     MyFree(aconf);
487     aconf = NULL;
488   }
489 };
490 operitems: operitem | operitems operitem;
491 operitem: opername | operpass | operlocal | operhost | operclass | operpriv;
492
493 opername: NAME '=' QSTRING ';'
494 {
495   MyFree(aconf->name);
496   DupString(aconf->name, yylval.text);
497 };
498
499 operpass: PASS '=' QSTRING ';'
500 {
501   MyFree(aconf->passwd);
502   DupString(aconf->passwd, yylval.text);
503 };
504
505 operlocal: LOCAL '=' YES ';'
506 {
507   /* XXX it would be good to get rid of local operators and add same
508    * permission values here. But for now, I am just going with local 
509    * opers... */
510   aconf->status = CONF_LOCOP;
511   /* XXX blow away existing priviledges. */
512   set_initial_oper_privs(aconf, FLAGS_LOCOP);
513 } | LOCAL '=' NO ';'
514 {
515   /* XXX blow away existing priviledges. */
516   set_initial_oper_privs(aconf, (FLAGS_OPER|FLAGS_LOCOP));
517   aconf->status = CONF_OPERATOR;
518 };
519
520 operhost: HOST '=' QSTRING ';'
521 {
522  MyFree(aconf->host);
523  if (!strchr(yylval.text, '@'))
524  {
525    int uh_len;
526    char *b = MyMalloc((uh_len = strlen(yylval.text)+3));
527    ircd_snprintf(0, b, uh_len, "*@%s", yylval.text);
528    aconf->host = b;
529  }
530  else
531    DupString(aconf->host, yylval.text);
532 };
533
534 operclass: CLASS '=' QSTRING ';'
535 {
536  aconf->conn_class = find_class(yylval.text);
537 };
538
539 operpriv: privtype '=' yesorno ';'
540 {
541   if ($3 == 1)
542     PrivSet(&aconf->privs, $1);
543   else
544     PrivClr(&aconf->privs, $1);
545 };
546
547 privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_CHAN_LIMIT; } |
548           TPRIV_MODE_LCHAN { $$ = PRIV_MODE_LCHAN; } |
549           TPRIV_DEOP_LCHAN { $$ = PRIV_DEOP_LCHAN; } |
550           TPRIV_WALK_LCHAN { $$ = PRIV_WALK_LCHAN; } |
551           TPRIV_KILL { $$ = PRIV_KILL; } |
552           TPRIV_LOCAL_KILL { $$ = PRIV_LOCAL_KILL; } |
553           TPRIV_REHASH { $$ = PRIV_REHASH; } |
554           TPRIV_RESTART { $$ = PRIV_RESTART; } |
555           TPRIV_DIE { $$ = PRIV_DIE; } |
556           TPRIV_GLINE { $$ = PRIV_GLINE; } |
557           TPRIV_LOCAL_GLINE { $$ = PRIV_LOCAL_GLINE; } |
558           TPRIV_JUPE { $$ = PRIV_JUPE; } |
559           TPRIV_LOCAL_JUPE { $$ = PRIV_LOCAL_JUPE; } |
560           TPRIV_LOCAL_OPMODE { $$ = PRIV_LOCAL_OPMODE; } |
561           TPRIV_OPMODE { $$ = PRIV_OPMODE; }|
562           TPRIV_SET { $$ = PRIV_SET; } |
563           TPRIV_WHOX { $$ = PRIV_WHOX; } |
564           TPRIV_BADCHAN { $$ = PRIV_BADCHAN; } |
565           TPRIV_LOCAL_BADCHAN { $$ = TPRIV_LOCAL_BADCHAN; } |
566           TPRIV_SEE_CHAN { $$ = PRIV_SEE_CHAN; } |
567           TPRIV_SHOW_INVIS { $$ = PRIV_SHOW_INVIS; } |
568           TPRIV_SHOW_ALL_INVIS { $$ = PRIV_SHOW_ALL_INVIS; } |
569           TPRIV_PROPAGATE { $$ = PRIV_PROPAGATE; } |
570           TPRIV_UNLIMIT_QUERY { $$ = PRIV_UNLIMIT_QUERY; } |
571           TPRIV_DISPLAY { $$ = PRIV_DISPLAY; } |
572           TPRIV_SEE_OPERS { $$ = PRIV_SEE_OPERS; } |
573           TPRIV_WIDE_GLINE { $$ = PRIV_WIDE_GLINE; };
574
575 yesorno: YES { $$ = 1; } | NO { $$ = 0; };
576
577 /* The port block... */
578 portblock: PORT {
579   port = 0;
580   host = NULL;
581   /* Hijack these for is_server, is_hidden to cut down on globals... */
582   tconn = 0;
583   tping = 0;
584   /* and this for mask... */
585   pass = NULL;
586 } '{' portitems '}' ';'
587 {
588   if (port > 0 && port <= 0xFFFF)
589   {
590     add_listener(port, host, pass, tconn, tping);
591     host = pass = NULL;
592   }
593   else
594   {
595     MyFree(host);
596     MyFree(pass);
597   }
598 };
599 portitems: portitem portitems | portitem;
600 portitem: portnumber | portvhost | portmask | portserver | porthidden;
601 portnumber: PORT '=' NUMBER ';'
602 {
603   port = yylval.num;
604 };
605
606 portvhost: VHOST '=' QSTRING ';'
607 {
608   MyFree(host);
609   DupString(host, yylval.text);
610 };
611
612 portmask: MASK '=' QSTRING ';'
613 {
614   MyFree(pass);
615   DupString(pass, yylval.text);
616 };
617
618 portserver: SERVER '=' YES ';'
619 {
620   tconn = -1;
621 } | SERVER '=' NO ';'
622 {
623   tconn = 0;
624 };
625
626 porthidden: HIDDEN '=' YES ';'
627 {
628   tping = -1;
629 } | HIDDEN '=' NO ';'
630 {
631   tping = 0;
632 };
633
634 clientblock: CLIENT
635 {
636   aconf = MyMalloc(sizeof(*aconf));
637   memset(aconf, 0, sizeof(*aconf));
638   aconf->status = CONF_CLIENT;
639 } '{' clientitems '}'
640 {
641   if ((aconf->host != NULL || aconf->name!=NULL))
642   {
643     if (aconf->host == NULL)
644       DupString(aconf->host, "");
645     if (aconf->name == NULL)
646       DupString(aconf->name, "");
647     if (aconf->conn_class == NULL)
648       aconf->conn_class = find_class("default");
649     aconf->next = GlobalConfList;
650     GlobalConfList = aconf;
651     aconf = NULL;
652   }
653   else
654   {
655    MyFree(aconf->host);
656    MyFree(aconf->passwd);
657    MyFree(aconf);
658    aconf = NULL;
659   }
660 } ';';
661 clientitems: clientitem clientitems | clientitem;
662 clientitem: clienthost | clientclass | clientpass | clientip;
663 clientip: IP '=' QSTRING ';'
664 {
665   MyFree(aconf->host);
666   DupString(aconf->host, yylval.text);
667 };
668
669 clienthost: HOST '=' QSTRING ';'
670 {
671   MyFree(aconf->name);
672   DupString(aconf->name, yylval.text);
673 };
674
675 clientclass: CLASS '=' QSTRING ';'
676 {
677   aconf->conn_class = find_class(yylval.text);
678 };
679
680 clientpass: PASS '=' QSTRING ';'
681 {
682   MyFree(aconf->passwd);
683   DupString(aconf->passwd, yylval.text);
684 };
685
686 killblock: KILL
687 {
688   dconf = MyMalloc(sizeof(*dconf));
689   memset(dconf, 0, sizeof(*dconf));
690 } '{' killitems '}'
691 {
692   if (dconf->hostmask != NULL)
693   {
694     if (dconf->usermask == NULL)
695       DupString(dconf->usermask, "*");
696     dconf->next = denyConfList;
697     denyConfList = dconf;
698     dconf = NULL;
699   }
700   else
701   {
702     MyFree(dconf->hostmask);
703     MyFree(dconf->message);
704     MyFree(dconf);
705     dconf = NULL;
706   }
707 } ';';
708 killitems: killitem killitems | killitem;
709 killitem: killuhost | killreal | killreasonfile | killreason;
710 killuhost: HOST '=' QSTRING ';'
711 {
712   char *u, *h;
713   dconf->flags &= ~DENY_FLAGS_REALNAME;
714   MyFree(dconf->hostmask);
715   MyFree(dconf->usermask);
716   if ((h = strchr(yylval.text, '@')) == NULL)
717   {
718     u = "*";
719     h = yylval.text;
720   }
721   else
722   {
723     u = yylval.text;
724     h++;
725   }
726   DupString(dconf->hostmask, h);
727   DupString(dconf->usermask, u);
728   if (strchr(yylval.text, '.'))
729   {
730     int  c_class;
731     char ipname[16];
732     int  ad[4] = { 0 };
733     int  bits2 = 0;
734     dconf->flags |= DENY_FLAGS_IP;
735     c_class = sscanf(dconf->hostmask, "%d.%d.%d.%d/%d",
736                      &ad[0], &ad[1], &ad[2], &ad[3], &bits2);
737     if (c_class != 5) {
738       dconf->bits = c_class * 8;
739     }
740     else {
741       dconf->bits = bits2;
742     }
743     ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1],
744                   ad[2], ad[3]);
745     dconf->address = inet_addr(ipname);
746   }
747 };
748
749 killreal: REAL '=' QSTRING ';'
750 {
751  dconf->flags &= ~DENY_FLAGS_IP;
752  dconf->flags |= DENY_FLAGS_REALNAME;
753  MyFree(dconf->hostmask);
754  /* Leave usermask so you can specify user and real... */
755  DupString(dconf->hostmask, yylval.text);
756 };
757
758 killreason: REASON '=' QSTRING ';'
759 {
760  dconf->flags &= DENY_FLAGS_FILE;
761  MyFree(dconf->message);
762  DupString(dconf->message, yylval.text);
763 };
764
765 killreasonfile: TFILE '=' QSTRING ';'
766 {
767  dconf->flags |= DENY_FLAGS_FILE;
768  MyFree(dconf->message);
769  DupString(dconf->message, yylval.text);
770 };
771
772 cruleblock: CRULE
773 {
774   host = pass = NULL;
775   tconn = CRULE_AUTO;
776 } '{' cruleitems '}'
777 {
778   struct CRuleNode *node;
779   if (host != NULL && pass != NULL && (node=crule_parse(pass)) != NULL)
780   {
781     struct CRuleConf *p = MyMalloc(sizeof(*p));
782     p->hostmask = host;
783     p->rule = pass;
784     p->type = tconn;
785     p->node = node;
786     p->next = cruleConfList;
787     cruleConfList = p;
788   }
789   else
790   {
791     MyFree(host);
792     MyFree(pass);
793   }
794 } ';';
795
796 cruleitems: cruleitem cruleitems | cruleitem;
797 cruleitem: cruleserver | crulerule | cruleall;
798
799 cruleserver: SERVER '=' QSTRING ';'
800 {
801   MyFree(host);
802   collapse(yylval.text);
803   DupString(host, yylval.text);
804 };
805
806 crulerule: RULE '=' QSTRING ';'
807 {
808  MyFree(pass);
809  DupString(pass, yylval.text);
810 };
811
812 cruleall: ALL '=' YES ';'
813 {
814  tconn = CRULE_ALL;
815 } | ALL '=' NO ';'
816 {
817  tconn = CRULE_AUTO;
818 };
819
820 motdblock: MOTD {
821  pass = host = NULL;
822 } '{' motditems '}'
823 {
824   if (host != NULL && pass != NULL)
825     motd_add(host, pass);
826   MyFree(host);
827   MyFree(pass);
828   host = pass = NULL;
829 } ';';
830
831 motditems: motditem motditems | motditem;
832 motditem: motdhost | motdfile;
833 motdhost: HOST '=' QSTRING ';'
834 {
835   DupString(host, yylval.text);
836 };
837
838 motdfile: TFILE '=' QSTRING ';'
839 {
840   DupString(pass, yylval.text);
841 };
842
843 featuresblock: FEATURES '{' featureitems '}' ';';
844 featureitems: featureitems featureitem | featureitem;
845
846 featureitem: QSTRING
847 {
848   stringlist[0] = $1;
849   stringno = 1;
850 } '=' stringlist ';';
851
852 stringlist: QSTRING
853 {
854   stringlist[1] = $1;
855   stringno = 2;
856 } posextrastrings
857 {
858   feature_set(NULL, (const char * const *)stringlist, stringno);
859 };
860 posextrastrings: /* empty */ | extrastrings;
861 extrastrings: extrastrings extrastring | extrastring;
862 extrastring: QSTRING
863 {
864   if (stringno < MAX_STRINGS)
865     stringlist[stringno++] = $1;
866 };