#!/usr/bin/perl -w
#
# CIDR Calculating for XChat
# Copyright (C) 2005 Nils Hulsch
#
# WWW: www.cash-area.de
#
# 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.
#
#



use Net::CIDR;

IRC::register("CIDR Calculating","1.1","","");
IRC::add_command_handler("cidr","cidr");
IRC::add_command_handler("cidrsay","cidrsay");
IRC::print("CIDR Calculating 1.1 by Nils Hulsch loaded!");

sub cidr {
	if ($_[0] eq "") {
		IRC::print("Usage: /cidr IP-Range");
		return 1;
	} else {
		IRC::print(">> CIDR for ".$_[0]);
		IRC::print(join(" - ", Net::CIDR::range2cidr($_[0])));
		IRC::print("<<");
		return 1;
	}
}

sub cidrsay {
	if ($_[0] eq "") {
		IRC::print("Usage /cidrsay IP-Range");
		return 1;
	} else {
	        IRC::command("/say >> CIDR for ".$_[0]);
        	IRC::command("/say ".join(" - ", Net::CIDR::range2cidr($_[0])));
	        IRC::command("/say <<");
        	return 1;
	}
}
