+void conf_add_deny(const char* const* fields, int count, int ip_kill)
+{
+ struct DenyConf* conf;
+
+ if (count < 4 || EmptyString(fields[1]) || EmptyString(fields[3]))
+ return;
+
+ conf = (struct DenyConf*) MyMalloc(sizeof(struct DenyConf));
+ assert(0 != conf);
+ memset(conf, 0, sizeof(struct DenyConf));
+
+ DupString(conf->hostmask, fields[1]);
+ collapse(conf->hostmask);
+
+ if (!EmptyString(fields[2])) {
+ const char* p = fields[2];
+ if ('!' == *p) {
+ conf->is_file = 1;
+ ++p;
+ }
+ DupString(conf->message, p);
+ }
+ DupString(conf->usermask, fields[3]);
+ collapse(conf->usermask);
+
+ if (ip_kill) {
+ /*
+ * Here we use the same kludge as in listener.c to parse
+ * a.b.c.d, or a.b.c.*, or a.b.c.d/e.
+ */
+ int c_class;
+ char ipname[16];
+ int ad[4] = { 0 };
+ int bits2 = 0;
+ c_class = sscanf(conf->hostmask, "%d.%d.%d.%d/%d",
+ &ad[0], &ad[1], &ad[2], &ad[3], &bits2);
+ if (c_class != 5) {
+ conf->bits = c_class * 8;
+ }
+ else {
+ conf->bits = bits2;
+ }
+ sprintf_irc(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]);
+
+ /*
+ * This ensures endian correctness
+ */
+ conf->s_addr = inet_addr(ipname);
+ Debug((DEBUG_DEBUG, "IPkill: %s = %08x/%i (%08x)", ipname,
+ conf->s_addr, conf->bits, NETMASK(conf->bits)));
+ }
+ conf->next = denyConfList;
+ denyConfList = conf;
+}
+
+void conf_erase_deny_list(void)
+{
+ struct DenyConf* next;
+ struct DenyConf* p = denyConfList;
+ for ( ; p; p = next) {
+ next = p->next;
+ MyFree(p->hostmask);
+ MyFree(p->usermask);
+ MyFree(p->message);
+ MyFree(p);
+ }
+ denyConfList = 0;
+}
+
+const struct DenyConf* conf_get_deny_list(void)
+{
+ return denyConfList;
+}