Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / ircd_features.c
1 /*
2  * IRC - Internet Relay Chat, ircd/features.c
3  * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 1, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * $Id$
20  */
21 #include "config.h"
22 #include "ircd_features.h"
23 #include "client.h"
24 #include "hash.h"
25 #include "ircd.h"
26 #include "ircd_alloc.h"
27 #include "ircd_log.h"
28 #include "ircd_reply.h"
29 #include "ircd_string.h"
30 #include "match.h"
31 #include "msg.h"
32 #include "numeric.h"
33 #include "numnicks.h"
34 #include "s_bsd.h"
35 #include "s_debug.h"
36 #include "s_misc.h"
37 #include "send.h"
38 #include "struct.h"
39 #include "support.h"
40 #include "sys.h"    /* FALSE bleah */
41
42 #include <assert.h>
43 #include <stdlib.h>
44 #include <string.h>
45
46 /* List of log output types that can be set */
47 static struct LogTypes {
48   char *type;
49   int (*set)(const char *, const char *);
50   char *(*get)(const char *);
51 } logTypes[] = {
52   { "FILE", log_set_file, log_get_file },
53   { "FACILITY", log_set_facility, log_get_facility },
54   { "SNOMASK", log_set_snomask, log_get_snomask },
55   { "LEVEL", log_set_level, log_get_level },
56   { 0, 0, 0 }
57 };
58
59 /* Look up a struct LogType given the type string */
60 static struct LogTypes *
61 feature_log_desc(struct Client* from, const char *type)
62 {
63   int i;
64
65   assert(0 != type);
66
67   for (i = 0; logTypes[i].type; i++) /* find appropriate descriptor */
68     if (!ircd_strcmp(type, logTypes[i].type))
69       return &logTypes[i];
70
71   Debug((DEBUG_ERROR, "Unknown log feature type \"%s\"", type));
72   if (from) /* send an error; if from is NULL, called from conf parser */
73     send_reply(from, ERR_BADLOGTYPE, type);
74   else
75     log_write(LS_CONFIG, L_ERROR, 0, "Unknown log feature type \"%s\"", type);
76
77   return 0; /* not found */
78 }
79
80 /* Set the value of a log output type for a log subsystem */
81 static int
82 feature_log_set(struct Client* from, const char* const* fields, int count)
83 {
84   struct LogTypes *desc;
85   char *subsys;
86
87   if (count < 2) { /* set default facility */
88     if (log_set_default(count < 1 ? 0 : fields[0])) {
89       assert(count >= 1); /* should always accept default */
90
91       if (from) /* send an error */
92         send_reply(from, ERR_BADLOGVALUE, fields[0]);
93       else
94         log_write(LS_CONFIG, L_ERROR, 0,
95                   "Bad value \"%s\" for default facility", fields[0]);
96     } else
97       return count < 1 ? -1 : 1; /* tell feature to set or clear mark */
98   } else if (!(subsys = log_canon(fields[0]))) { /* no such subsystem */
99     if (from) /* send an error */
100       send_reply(from, ERR_BADLOGSYS, fields[0]);
101     else
102       log_write(LS_CONFIG, L_ERROR, 0,
103                 "No such logging subsystem \"%s\"", fields[0]);
104   } else if ((desc = feature_log_desc(from, fields[1]))) { /* set value */
105     if ((*desc->set)(fields[0], count < 3 ? 0 : fields[2])) {
106       assert(count >= 3); /* should always accept default */
107
108       if (from) /* send an error */
109         send_reply(from, ERR_BADLOGVALUE, fields[2]);
110       else
111         log_write(LS_CONFIG, L_ERROR, 0,
112                   "Bad value \"%s\" for log type %s (subsystem %s)",
113                   fields[2], desc->type, subsys);
114     }
115   }
116
117   return 0;
118 }
119
120 /* reset a log type for a subsystem to its default value */
121 static int
122 feature_log_reset(struct Client* from, const char* const* fields, int count)
123 {
124   struct LogTypes *desc;
125   char *subsys;
126
127   assert(0 != from); /* Never called by the .conf parser */
128
129   if (count < 1) { /* reset default facility */
130     log_set_default(0);
131     return -1; /* unmark this entry */
132   } else if (count < 2)
133     need_more_params(from, "RESET");
134   else if (!(subsys = log_canon(fields[0]))) /* no such subsystem */
135     send_reply(from, ERR_BADLOGSYS, fields[0]);
136   else if ((desc = feature_log_desc(from, fields[1]))) /* reset value */
137     (*desc->set)(fields[0], 0); /* default should always be accepted */
138
139   return 0;
140 }
141
142 /* report the value of a log setting */
143 static void
144 feature_log_get(struct Client* from, const char* const* fields, int count)
145 {
146   struct LogTypes *desc;
147   char *value, *subsys;
148
149   assert(0 != from); /* never called by .conf parser */
150
151   if (count < 1) /* return default facility */
152     send_reply(from, SND_EXPLICIT | RPL_FEATURE, ":Log facility: %s",
153                log_get_default());
154   else if (count < 2)
155     need_more_params(from, "GET");
156   else if (!(subsys = log_canon(fields[0]))) { /* no such subsystem */
157     send_reply(from, ERR_BADLOGSYS, fields[0]);
158   } else if ((desc = feature_log_desc(from, fields[1]))) {
159     if ((value = (*desc->get)(fields[0]))) /* send along value */
160       send_reply(from, SND_EXPLICIT | RPL_FEATURE,
161                  ":Log %s for subsystem %s: %s", desc->type, subsys,
162                  (*desc->get)(subsys));
163     else
164       send_reply(from, SND_EXPLICIT | RPL_FEATURE,
165                  ":No log %s is set for subsystem %s", desc->type, subsys);
166   }
167 }
168
169 /* sets a feature to the given value */
170 typedef int  (*feat_set_call)(struct Client*, const char* const*, int);
171 /* gets the value of a feature */
172 typedef void (*feat_get_call)(struct Client*, const char* const*, int);
173 /* unmarks all sub-feature values prior to reading .conf */
174 typedef void (*feat_unmark_call)(void);
175 /* resets to defaults all currently unmarked values */
176 typedef void (*feat_mark_call)(int);
177 /* reports features as a /stats f list */
178 typedef void (*feat_report_call)(struct Client*, int);
179
180 #define FEAT_NONE   0x0000      /* no value */
181 #define FEAT_INT    0x0001      /* set if entry contains an integer value */
182 #define FEAT_BOOL   0x0002      /* set if entry contains a boolean value */
183 #define FEAT_STR    0x0003      /* set if entry contains a string value */
184 #define FEAT_MASK   0x000f      /* possible value types */
185
186 #define FEAT_MARK   0x0010      /* set if entry has been changed */
187 #define FEAT_NULL   0x0020      /* NULL string is permitted */
188 #define FEAT_CASE   0x0040      /* string is case-sensitive */
189
190 #define FEAT_OPER   0x0100      /* set to display only to opers */
191 #define FEAT_MYOPER 0x0200      /* set to display only to local opers */
192
193 #define FEAT_READ   0x1000      /* feature is read-only (for now, perhaps?) */
194
195 static struct FeatureDesc {
196   enum Feature     feat;    /* feature identifier */
197   char*            type;    /* string describing type */
198   unsigned int     flags;   /* flags for feature */
199   int              v_int;   /* integer value */
200   int              def_int; /* default value */
201   char*            v_str;   /* string value */
202   char*            def_str; /* default value */
203   feat_set_call    set;     /* set feature values */
204   feat_set_call    reset;   /* reset feature values to defaults */
205   feat_get_call    get;     /* get feature values */
206   feat_unmark_call unmark;  /* unmark all feature change values */
207   feat_mark_call   mark;    /* reset to defaults all unchanged features */
208   feat_report_call report;  /* report feature values */
209 } features[] = {
210 #define F_N(type, flags, set, reset, get, unmark, mark, report)               \
211   { FEAT_ ## type, #type, FEAT_NONE | (flags), 0, 0, 0, 0,                    \
212     (set), (reset), (get), (unmark), (mark), (report) }
213 #define F_I(type, flags, v_int)                                               \
214   { FEAT_ ## type, #type, FEAT_INT | (flags), 0, (v_int), 0, 0,               \
215     0, 0, 0, 0, 0, 0 }
216 #define F_B(type, flags, v_int)                                               \
217   { FEAT_ ## type, #type, FEAT_BOOL | (flags), 0, (v_int), 0, 0,              \
218     0, 0, 0, 0, 0, 0 }
219 #define F_S(type, flags, v_str)                                               \
220   { FEAT_ ## type, #type, FEAT_STR | (flags), 0, 0, 0, (v_str),               \
221     0, 0, 0, 0, 0, 0 }
222
223   /* Misc. features */
224   F_N(LOG, FEAT_MYOPER, feature_log_set, feature_log_reset, feature_log_get,
225       log_feature_unmark, log_feature_mark, log_feature_report),
226   F_S(DOMAINNAME, 0, DOMAINNAME),
227   F_B(RELIABLE_CLOCK, 0, 0),
228   F_I(BUFFERPOOL, 0, 27000000),
229   F_B(HAS_FERGUSON_FLUSHER, 0, 0),
230   F_I(CLIENT_FLOOD, 0, 1024),
231   F_I(SERVER_PORT, FEAT_OPER, 4400),
232   F_B(NODEFAULTMOTD, 0, 1),
233   F_B(KILL_IPMISMATCH, FEAT_OPER, 0),
234   F_B(IDLE_FROM_MSG, 0, 1),
235   F_B(HUB, 0, 0),
236   F_B(WALLOPS_OPER_ONLY, 0, 0),
237
238   /* Some misc. default paths */
239   F_S(MPATH, FEAT_CASE | FEAT_MYOPER, "ircd.motd"),
240   F_S(RPATH, FEAT_CASE | FEAT_MYOPER, "remote.motd"),
241   F_S(PPATH, FEAT_CASE | FEAT_MYOPER | FEAT_READ, "ircd.pid"),
242
243   /* Networking features */
244   F_B(VIRTUAL_HOST, 0, 0),
245   F_I(TOS_SERVER, 0, 0x08),
246   F_I(TOS_CLIENT, 0, 0x08),
247
248   /* features that affect all operators */
249   F_B(CRYPT_OPER_PASSWORD, FEAT_MYOPER | FEAT_READ, 1),
250   F_B(OPER_NO_CHAN_LIMIT, 0, 1),
251   F_B(OPER_MODE_LCHAN, 0, 1),
252   F_B(OPER_WALK_THROUGH_LMODES, 0, 0),
253   F_B(NO_OPER_DEOP_LCHAN, 0, 0),
254   F_B(SHOW_INVISIBLE_USERS, 0, 1),
255   F_B(SHOW_ALL_INVISIBLE_USERS, 0, 1),
256   F_B(UNLIMIT_OPER_QUERY, 0, 0),
257   F_B(LOCAL_KILL_ONLY, 0, 0),
258   F_B(CONFIG_OPERCMDS, 0, 1), /* XXX change default before release */
259
260   /* features that affect global opers on this server */
261   F_B(OPER_KILL, 0, 1),
262   F_B(OPER_REHASH, 0, 1),
263   F_B(OPER_RESTART, 0, 1),
264   F_B(OPER_DIE, 0, 1),
265   F_B(OPER_GLINE, 0, 1),
266   F_B(OPER_LGLINE, 0, 1),
267   F_B(OPER_JUPE, 0, 1),
268   F_B(OPER_LJUPE, 0, 1),
269   F_B(OPER_OPMODE, 0, 1),
270   F_B(OPER_LOPMODE, 0, 1),
271   F_B(OPER_BADCHAN, 0, 0),
272   F_B(OPER_LBADCHAN, 0, 0),
273   F_B(OPER_SET, 0, 1),
274   F_B(OPERS_SEE_IN_SECRET_CHANNELS, 0, 1),
275
276   /* features that affect local opers on this server */
277   F_B(LOCOP_KILL, 0, 0),
278   F_B(LOCOP_REHASH, 0, 1),
279   F_B(LOCOP_RESTART, 0, 0),
280   F_B(LOCOP_DIE, 0, 0),
281   F_B(LOCOP_LGLINE, 0, 1),
282   F_B(LOCOP_LJUPE, 0, 1),
283   F_B(LOCOP_LOPMODE, 0, 1),
284   F_B(LOCOP_LBADCHAN, 0, 0),
285   F_B(LOCOP_SET, 0, 0),
286   F_B(LOCOP_SEE_IN_SECRET_CHANNELS, 0, 0),
287
288 #undef F_S
289 #undef F_B
290 #undef F_I
291 #undef F_N
292   { FEAT_LAST_F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
293 };
294
295 /* Given a feature's identifier, look up the feature descriptor */
296 static struct FeatureDesc *
297 feature_desc(struct Client* from, const char *feature)
298 {
299   int i;
300
301   assert(0 != feature);
302
303   for (i = 0; features[i].type; i++) /* find appropriate descriptor */
304     if (!ircd_strcmp(feature, features[i].type))
305       return &features[i];
306
307   Debug((DEBUG_ERROR, "Unknown feature \"%s\"", feature));
308   if (from) /* report an error */
309     send_reply(from, ERR_NOFEATURE, feature);
310   else
311     log_write(LS_CONFIG, L_ERROR, 0, "Unknown feature \"%s\"", feature);
312
313   return 0; /* not found */
314 }
315
316 /* Given a feature vector string, set the value of a feature */
317 int
318 feature_set(struct Client* from, const char* const* fields, int count)
319 {
320   int i;
321   struct FeatureDesc *feat;
322
323   if (from && !HasPriv(from, PRIV_SET))
324     return send_reply(from, ERR_NOPRIVILEGES);
325
326   if (count < 1) {
327     if (from) /* report an error in the number of arguments */
328       need_more_params(from, "SET");
329     else
330       log_write(LS_CONFIG, L_ERROR, 0, "Not enough fields in F line");
331   } else if ((feat = feature_desc(from, fields[0]))) { /* find feature */
332     if (from && feat->flags & FEAT_READ)
333       return send_reply(from, ERR_NOFEATURE, fields[0]);
334
335     switch (feat->flags & FEAT_MASK) {
336     case FEAT_NONE:
337       if (feat->set && (i = (*feat->set)(from, fields + 1, count - 1))) {
338         if (i > 0) /* call the set callback and do marking */
339           feat->flags |= FEAT_MARK;
340         else /* i < 0 */
341           feat->flags &= ~FEAT_MARK;
342         break;
343       }
344
345     case FEAT_INT: /* an integer value */
346       if (count < 2) { /* reset value */
347         feat->v_int = feat->def_int;
348         feat->flags &= ~FEAT_MARK;
349       } else { /* ok, figure out the value and whether to mark it */
350         feat->v_int = atoi(fields[1]);
351         if (feat->v_int == feat->def_int)
352           feat->flags &= ~FEAT_MARK;
353         else
354           feat->flags |= FEAT_MARK;
355       }
356       break;
357
358     case FEAT_BOOL: /* it's a boolean value--true or false */
359       if (count < 2) { /* reset value */
360         feat->v_int = feat->def_int;
361         feat->flags &= ~FEAT_MARK;
362       } else { /* figure out the value and whether to mark it */
363         if (!ircd_strncmp(fields[1], "TRUE", strlen(fields[1])) ||
364             !ircd_strncmp(fields[1], "YES", strlen(fields[1])) ||
365             (strlen(fields[1]) >= 2 &&
366              !ircd_strncmp(fields[1], "ON", strlen(fields[1]))))
367           feat->v_int = 1;
368         else if (!ircd_strncmp(fields[1], "FALSE", strlen(fields[1])) ||
369                  !ircd_strncmp(fields[1], "NO", strlen(fields[1])) ||
370                  (strlen(fields[1]) >= 2 &&
371                   !ircd_strncmp(fields[1], "OFF", strlen(fields[1]))))
372           feat->v_int = 0;
373         else if (from) /* report an error... */
374           return send_reply(from, ERR_BADFEATVALUE, fields[1], feat->type);
375         else {
376           log_write(LS_CONFIG, L_ERROR, 0, "Bad value \"%s\" for feature %s",
377                     fields[1], feat->type);
378           return 0;
379         }
380
381         if (feat->v_int == feat->def_int) /* figure out whether to mark it */
382           feat->flags &= ~FEAT_MARK;
383         else
384           feat->flags |= FEAT_MARK;
385       }
386       break;
387
388     case FEAT_STR: /* it's a string value */
389       if (count < 2 ||
390           !(feat->flags & FEAT_CASE ? strcmp(fields[1], feat->def_str) :
391             ircd_strcmp(fields[1], feat->def_str))) { /* reset to default */
392         if (feat->v_str && feat->v_str != feat->def_str)
393           MyFree(feat->v_str); /* free old value */
394         feat->v_str = feat->def_str; /* very special... */
395
396         feat->flags &= ~FEAT_MARK; /* unmark it */
397       } else {
398         if (!*fields[1]) { /* empty string translates to NULL */
399           if (feat->flags & FEAT_NULL) { /* permitted? */
400             if (feat->v_str && feat->v_str != feat->def_str)
401               MyFree(feat->v_str); /* free old value */
402             feat->v_str = 0; /* set it to NULL */
403           } else if (from) /* hmmm...not permitted; report error */
404             return send_reply(from, ERR_BADFEATVALUE, "NULL", feat->type);
405           else {
406             log_write(LS_CONFIG, L_ERROR, 0,
407                       "Bad value \"NULL\" for feature %s", feat->type);
408             return 0;
409           }
410         } else if ((feat->flags & FEAT_CASE ?
411                     strcmp(fields[1], feat->v_str) :
412                     ircd_strcmp(fields[1], feat->v_str))) { /* new value */
413           if (feat->v_str && feat->v_str != feat->def_str)
414             MyFree(feat->v_str); /* free old value */
415           DupString(feat->v_str, fields[1]); /* store new value */
416         }
417
418         feat->flags |= FEAT_MARK; /* mark it as having been touched */
419       }
420       break;
421     }
422   }
423
424   return 0;
425 }
426
427 /* reset a feature to its default values */
428 int
429 feature_reset(struct Client* from, const char* const* fields, int count)
430 {
431   int i;
432   struct FeatureDesc *feat;
433
434   assert(0 != from);
435
436   if (!HasPriv(from, PRIV_SET))
437     return send_reply(from, ERR_NOPRIVILEGES);
438
439   if (count < 1) /* check arguments */
440     need_more_params(from, "RESET");
441   else if ((feat = feature_desc(from, fields[0]))) { /* get descriptor */
442     if (from && feat->flags & FEAT_READ)
443       return send_reply(from, ERR_NOFEATURE, fields[0]);
444
445     switch (feat->flags & FEAT_MASK) {
446     case FEAT_NONE: /* None... */
447       if (feat->reset && (i = (*feat->reset)(from, fields + 1, count - 1))) {
448         if (i > 0) /* call reset callback and parse mark return */
449           feat->flags |= FEAT_MARK;
450         else /* i < 0 */
451           feat->flags &= ~FEAT_MARK;
452       }
453       break;
454
455     case FEAT_INT:  /* Integer... */
456     case FEAT_BOOL: /* Boolean... */
457       feat->v_int = feat->def_int; /* set the default */
458       feat->flags &= ~FEAT_MARK; /* unmark it */
459       break;
460
461     case FEAT_STR: /* string! */
462       if (feat->v_str && feat->v_str != feat->def_str)
463         MyFree(feat->v_str); /* free old value */
464       feat->v_str = feat->def_str; /* set it to default */
465       feat->flags &= ~FEAT_MARK; /* unmark it */
466       break;
467     }
468   }
469
470   return 0;
471 }
472
473 /* Gets the value of a specific feature and reports it to the user */
474 int
475 feature_get(struct Client* from, const char* const* fields, int count)
476 {
477   struct FeatureDesc *feat;
478
479   assert(0 != from);
480
481   if (count < 1) /* check parameters */
482     need_more_params(from, "GET");
483   else if ((feat = feature_desc(from, fields[0]))) {
484     if ((feat->flags & FEAT_MYOPER && !MyOper(from)) ||
485         (feat->flags & FEAT_OPER && !IsAnOper(from))) /* check privs */
486       return send_reply(from, ERR_NOPRIVILEGES);
487
488     switch (feat->flags & FEAT_MASK) {
489     case FEAT_NONE: /* none, call the callback... */
490       if (feat->get) /* if there's a callback, use it */
491         (*feat->get)(from, fields + 1, count - 1);
492       break;
493
494     case FEAT_INT: /* integer, report integer value */
495       send_reply(from, SND_EXPLICIT | RPL_FEATURE,
496                  ":Integer value of %s: %d", feat->type, feat->v_int);
497       break;
498
499     case FEAT_BOOL: /* boolean, report boolean value */
500       send_reply(from, SND_EXPLICIT | RPL_FEATURE,
501                  ":Boolean value of %s: %s", feat->type,
502                  feat->v_int ? "TRUE" : "FALSE");
503       break;
504
505     case FEAT_STR: /* string, report string value */
506       if (feat->v_str) /* deal with null case */
507         send_reply(from, SND_EXPLICIT | RPL_FEATURE,
508                    ":String value of %s: %s", feat->type, feat->v_str);
509       else
510         send_reply(from, SND_EXPLICIT | RPL_FEATURE,
511                    ":String value for %s not set", feat->type);
512       break;
513     }
514   }
515
516   return 0;
517 }
518
519 /* called before reading the .conf to clear all marks */
520 void
521 feature_unmark(void)
522 {
523   int i;
524
525   for (i = 0; features[i].type; i++) {
526     features[i].flags &= ~FEAT_MARK; /* clear the marks... */
527     if (features[i].unmark) /* call the unmark callback if necessary */
528       (*features[i].unmark)();
529   }
530 }
531
532 /* Called after reading the .conf to reset unmodified values to defaults */
533 void
534 feature_mark(void)
535 {
536   int i;
537
538   for (i = 0; features[i].type; i++)
539     switch (features[i].flags & FEAT_MASK) {
540     case FEAT_NONE:
541       if (features[i].mark) /* call the mark callback if necessary */
542         (*features[i].mark)(features[i].flags & FEAT_MARK ? 1 : 0);
543       break;
544
545     case FEAT_INT:  /* Integers or Booleans... */
546     case FEAT_BOOL:
547       if (!(features[i].flags & FEAT_MARK)) /* not changed? */
548         features[i].v_int = features[i].def_int;
549       break;
550
551     case FEAT_STR: /* strings... */
552       if (!(features[i].flags & FEAT_MARK)) { /* not changed? */
553         if (features[i].v_str && features[i].v_str != features[i].def_str)
554           MyFree(features[i].v_str); /* free old value */
555         features[i].v_str = features[i].def_str;
556       }
557       break;
558     }
559 }
560
561 /* report all F-lines */
562 void
563 feature_report(struct Client* to)
564 {
565   int i;
566
567   for (i = 0; features[i].type; i++) {
568     if ((features[i].flags & FEAT_MYOPER && !MyOper(to)) ||
569         (features[i].flags & FEAT_OPER && !IsAnOper(to)))
570       continue; /* skip this one */
571
572     switch (features[i].flags & FEAT_MASK) {
573     case FEAT_NONE:
574       if (features[i].report) /* let the callback handle this */
575         (*features[i].report)(to, features[i].flags & FEAT_MARK ? 1 : 0);
576       break;
577
578
579     case FEAT_INT: /* Report an F-line with integer values */
580       if (features[i].flags & FEAT_MARK) /* it's been changed */
581         send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %d",
582                    features[i].type, features[i].v_int);
583       break;
584
585     case FEAT_BOOL: /* Report an F-line with boolean values */
586       if (features[i].flags & FEAT_MARK) /* it's been changed */
587         send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s",
588                    features[i].type, features[i].v_int ? "TRUE" : "FALSE");
589       break;
590
591     case FEAT_STR: /* Report an F-line with string values */
592       if (features[i].flags & FEAT_MARK) { /* it's been changed */
593         if (features[i].v_str)
594           send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s %s",
595                      features[i].type, features[i].v_str);
596         else /* Actually, F:<type> would reset it; you want F:<type>: */
597           send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F %s",
598                      features[i].type);
599       }
600       break;
601     }
602   }
603 }
604
605 /* return a feature's integer value */
606 int
607 feature_int(enum Feature feat)
608 {
609   assert(features[feat].feat == feat);
610   assert((features[feat].flags & FEAT_MASK) == FEAT_INT);
611
612   return features[feat].v_int;
613 }
614
615 /* return a feature's boolean value */
616 int
617 feature_bool(enum Feature feat)
618 {
619   assert(features[feat].feat == feat);
620   assert((features[feat].flags & FEAT_MASK) == FEAT_BOOL);
621
622   return features[feat].v_int;
623 }
624
625 /* return a feature's string value */
626 const char *
627 feature_str(enum Feature feat)
628 {
629   assert(features[feat].feat == feat);
630   assert((features[feat].flags & FEAT_MASK) == FEAT_STR);
631
632   return features[feat].v_str;
633 }