All pastes #260790 Raw Edit

Unnamed

public c v1 · immutable
#260790 ·published 2006-11-28 18:15 UTC
rendered paste body
/* * CIDR ban.  Copyright Zach Stein [ChickServ] *         * This program is free software; you can redistribute it and/or         * modify it under the terms of the GNU General Public License         * as published by the Free Software Foundation; either version 2         * of the License, or (at your option) any later version.         *         * This program is distributed in the hope that it will be useful,         * but WITHOUT ANY WARRANTY; without even the implied warranty of         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * GNU General Public License for more details.         *         * You should have received a copy of the GNU General Public License         * along with this program; if not, write to the Free Software         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.         *         *         * m_cidrban.c, ChickServ*/        #include <string.h>        #include "config.h"        #include "struct.h"        #include "common.h"        #include "sys.h"        #include "numeric.h"        #include "msg.h"        #include "proto.h"        #include "channel.h"        #include <time.h>        #include <sys/stat.h>        #include <stdio.h>        #include <stdlib.h>        #include <string.h>        #ifdef _WIN32        #include <io.h>        #endif        #include <fcntl.h>        #include "h.h"        #ifdef STRIPBADWORDS        #include "badwords.h"        #endif        #ifdef _WIN32        #include <io.h>        #endif        #include <fcntl.h>        #include "h.h"        #ifdef STRIPBADWORDS        #include "badwords.h"        #endif        #ifdef _WIN32        #include "version.h"        #endif        ModuleHeader MOD_HEADER(m_regexcept)          = {                "m_cidrban",                "v0.2",                "ExtBan ~C",                "3.2.3",                NULL            };        Extban *extbanC;        /* this one can remain the same */        char *extban_modeC_conv_param(char *para)        {                if (strstr(para,"~C:~")) {                        return NULL;               }                static char retbuf[64];                strlcpy(retbuf, para, sizeof(retbuf));                return retbuf;        };        int extban_modeC_is_banned(aClient *sptr, aChannel *chptr, char *xban, int type)        {                struct irc_netmask tmp;                struct irc_netmask *nmask;                char *tempchar = strtok(xban,"~C:");                tmp.type = parse_netmask(tempchar, &tmp);                if (&xban != NULL) {                       if (tmp.type != HM_HOST) {                        nmask = MyMallocEx(sizeof(struct irc_netmask));                        bcopy(&tmp, nmask, sizeof(struct irc_netmask));                        if (match_ip(sptr->ip,NULL, NULL, nmask)) {                                free(nmask);                                return 1;                         }                }                }                free(nmask);                return 0;}DLLFUNC int MOD_INIT(m_cidrban)(ModuleInfo *modinfo){ExtbanInfo req;        memset(&req, 0, sizeof(ExtbanInfo));        req.flag = 'C';        req.conv_param = extban_modeC_conv_param;        req.is_banned = extban_modeC_is_banned;        extbanC = ExtbanAdd(modinfo->handle, req);        if (!extbanC)        {                config_error("m_regexcept module: adding extban ~C failed! module NOT loaded");                return MOD_FAILED;        }        ModuleSetOptions(modinfo->handle, MOD_OPT_PERM);        return MOD_SUCCESS;}DLLFUNC int MOD_LOAD(m_regexcept)(int module_load){        return MOD_SUCCESS;}DLLFUNC int MOD_UNLOAD(m_regexcept)(int module_unload){        ExtbanDel(extbanC);        return MOD_SUCCESS;}