DLLFUNC int htm_config_run(ConfigFile *cf, ConfigEntry *ce, int type) { ConfigEntry *cep; if (type != CONFIG_SET) return 0; if (!strcmp(ce->ce_varname, "htm")) { for (cep = ce->ce_entries; cep; cep = cep->ce_next) { if (!strcmp(cep->ce_varname, "mode")) { if (!stricmp(cep->ce_vardata, "noisy")) noisy_htm = 1; else noisy_htm = 0; } else if (!strcmp(cep->ce_varname, "incoming-rate")) { LRV = config_checkval(cep->ce_vardata, CFG_SIZE); LRV /= 1024; } } return 1; } return 0; }
DLLFUNC int nopost_config_run(ConfigFile *cf, ConfigEntry *ce, int type) { ConfigEntry *cep, *cep2; DynList *d; if (type != CONFIG_SET) return 0; /* We are only interrested in set::nopost... */ if (!ce || !ce->ce_varname || strcmp(ce->ce_varname, "nopost")) return 0; for (cep = ce->ce_entries; cep; cep = cep->ce_next) { if (!strcmp(cep->ce_varname, "except-hosts")) { for (cep2 = cep->ce_entries; cep2; cep2 = cep2->ce_next) { d = MyMallocEx(sizeof(DynList)); d->entry = strdup(cep2->ce_varname); AddListItem(d, cfg.except_hosts); } } else if (!strcmp(cep->ce_varname, "ban-action")) { cfg.ban_action = banact_stringtoval(cep->ce_vardata); } else if (!strcmp(cep->ce_varname, "ban-reason")) { if (cfg.ban_reason) MyFree(cfg.ban_reason); cfg.ban_reason = strdup(cep->ce_vardata); } else if (!strcmp(cep->ce_varname, "ban-time")) { cfg.ban_time = config_checkval(cep->ce_vardata, CFG_TIME); } } return 1; }
DLLFUNC int htm_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs) { ConfigEntry *cep; int errors = 0; if (type != CONFIG_SET) return 0; if (!strcmp(ce->ce_varname, "htm")) { for (cep = ce->ce_entries; cep; cep = cep->ce_next) { if (!cep->ce_varname) { config_error("%s:%i: blank set::htm item", cep->ce_fileptr->cf_filename, cep->ce_varlinenum); errors++; continue; } if (!cep->ce_vardata) { config_error("%s:%i: set::htm::%s item without value", cep->ce_fileptr->cf_filename, cep->ce_varlinenum, cep->ce_varname); errors++; continue; } if (!strcmp(cep->ce_varname, "mode")) { if (stricmp(cep->ce_vardata, "noisy") && stricmp(cep->ce_vardata, "quiet")) { config_error("%s%i: set::htm::mode: illegal mode", cep->ce_fileptr->cf_filename, cep->ce_varlinenum); errors++; } } else if (!strcmp(cep->ce_varname, "incoming-rate")) { int value = config_checkval(cep->ce_vardata, CFG_SIZE); if (value < 10240) { config_error("%s%i: set::htm::incoming-rate: must be at least 10kb", cep->ce_fileptr->cf_filename, cep->ce_varlinenum); errors++; } } else { config_error("%s:%i: unknown directive set::htm::%s", cep->ce_fileptr->cf_filename, cep->ce_varlinenum, cep->ce_varname); errors++; } } *errs = errors; return errors ? -1 : 1; } else return 0; }