static struct {
const char * name;
const char * plural;
- time_t val;
+ time_t val;
} ircd_times[] = {
{"second", "seconds", 1},
{"minute", "minutes", 60},
{"fortnight", "fortnights", 60 * 60 * 24 * 14},
{"month", "months", 60 * 60 * 24 * 7 * 4},
{"year", "years", 60 * 60 * 24 * 365},
- /* ok-- we now do sizes here too. they aren't times, but
+ /* ok-- we now do sizes here too. they aren't times, but
it's close enough */
{"byte", "bytes", 1},
{"kb", NULL, 1024},
static void free_cur_list(conf_parm_t* list)
{
- switch (list->type & CF_MTYPE)
- {
- case CF_STRING:
- case CF_QSTRING:
- rb_free(list->v.string);
- break;
- case CF_LIST:
- free_cur_list(list->v.list);
- break;
- default: break;
+ if (list->type == CF_STRING || list->type == CF_QSTRING) {
+ rb_free(list->v.string);
+ } else if (list->type == CF_FLIST) {
+ /* Even though CF_FLIST is a flag, comparing with == is valid
+ * because conf_parm_t.type must be either a type or one flag.
+ */
+ free_cur_list(list->v.list);
}
- if (list->next)
+ if (list->next) {
free_cur_list(list->next);
+ }
+
+ rb_free(list);
}
-
+
conf_parm_t * cur_list = NULL;
static void add_cur_list_cpt(conf_parm_t *new)
if (cur_list == NULL)
{
cur_list = rb_malloc(sizeof(conf_parm_t));
- cur_list->type |= CF_FLIST;
+ cur_list->type = CF_FLIST;
cur_list->v.list = new;
}
else
%}
%union {
- int number;
- char string[IRCD_BUFSIZE + 1];
+ int number;
+ char string[IRCD_BUFSIZE + 1];
conf_parm_t * conf_parm;
}
%token <number> NUMBER
%type <string> qstring string
-%type <number> number timespec
+%type <number> number timespec
%type <conf_parm> oneitem single itemlist
%start conf
%%
-conf:
- | conf conf_item
+conf:
+ | conf conf_item
| error
;
| loadmodule
;
-block: string
- {
+block: string
+ {
conf_start_block($1, NULL);
}
- '{' block_items '}' ';'
+ '{' block_items '}' ';'
{
if (conf_cur_block)
- conf_end_block(conf_cur_block);
+ conf_end_block(conf_cur_block);
}
- | string qstring
- {
+ | string qstring
+ {
conf_start_block($1, $2);
}
'{' block_items '}' ';'
{
if (conf_cur_block)
- conf_end_block(conf_cur_block);
+ conf_end_block(conf_cur_block);
}
;
-block_items: block_items block_item
- | block_item
+block_items: block_items block_item
+ | block_item
;
block_item: string '=' itemlist ';'
{
- conf_call_set(conf_cur_block, $1, cur_list, CF_LIST);
+ conf_call_set(conf_cur_block, $1, cur_list);
free_cur_list(cur_list);
cur_list = NULL;
}
| oneitem TWODOTS oneitem
{
/* "1 .. 5" meaning 1,2,3,4,5 - only valid for integers */
- if (($1->type & CF_MTYPE) != CF_INT ||
- ($3->type & CF_MTYPE) != CF_INT)
+ if ($1->type != CF_INT || $3->type != CF_INT)
{
conf_report_error("Both arguments in '..' notation must be integers.");
break;
}
| string
{
- /* a 'string' could also be a yes/no value ..
+ /* a 'string' could also be a yes/no value ..
so pass it as that, if so */
int val = conf_get_yesno_value($1);
#ifndef STATIC_MODULES
char *m_bn;
- m_bn = irc_basename((char *) $2);
+ m_bn = rb_basename((char *) $2);
if (findmodule_byname(m_bn) == -1)
load_one_module($2, 0);
+
+ rb_free(m_bn);
#endif
}
';'
number: NUMBER { $$ = $1; } ;
timespec: number string
- {
+ {
time_t t;
if ((t = conf_find_time($2)) == 0)
conf_report_error("Unrecognised time type/size '%s'", $2);
t = 1;
}
-
+
$$ = $1 * t;
}
| timespec timespec