diff -Nura Unreal3.2-cvs/Config Unreal3.2/Config
--- Unreal3.2-cvs/Config	2006-06-08 23:13:32.000000000 +0000
+++ Unreal3.2/Config	2006-11-05 15:23:12.000000000 +0000
@@ -62,6 +62,13 @@
 ARG="$ARG--enable-ziplinks=$ZIPLINKSDIR "
 fi
 fi
+if [ "$ICONV" = "1" ] ; then
+if test x"$ICONVDIR" = "x" ; then
+ARG="$ARG--enable-iconv "
+else
+ARG="$ARG--enable-iconv=$ICONVDIR "
+fi
+fi
 if [ "$REMOTEINC" = "1" ] ; then
 ARG="$ARG--enable-libcurl=$CURLDIR "
 fi
@@ -296,6 +303,8 @@
 MAXCONNECTIONS="1024"
 INET6=""
 REMOTEINC=""
+ICONV=""
+ICONVDIR=""
 CURLDIR=""
 PREFIXAQ="1"
 SHOWLISTMODES="1"
@@ -696,6 +705,48 @@
     esac
 done
 
+TEST=""
+while [ -z "$TEST" ] ; do
+    if [ "$ICONV" = "1" ] ; then
+        TEST="Yes"
+    else
+        TEST="No"
+    fi
+    echo ""
+    echo "Do you want to enable iconv (codepage) support?"
+    echo $n "[$TEST] -> $c"
+        read cc
+    if [ -z "$cc" ] ; then
+        cc=$TEST
+    fi
+    case "$cc" in
+        [Yy]*)
+	    ICONV="1"
+	    ;;
+	[Nn]*)
+	    ICONV=""
+	    ;;
+	*)
+	    echo ""
+	    echo "You must enter either Yes or No"
+	    TEST=""
+	    ;;
+    esac
+done
+
+if [ "$ICONV" = "1" ] ; then
+TEST=""
+echo ""
+echo "If you know the path to iconv on your system, enter it here. If not"
+echo "leave this blank"
+echo $n "[$TEST] -> $c"
+    read cc
+if [ -z "$cc" ] ; then
+    ICONVDIR=""
+else
+    ICONVDIR=`eval echo $cc` # modified
+fi
+fi
 
 TEST=""
 while [ -z "$TEST" ] ; do
diff -Nura Unreal3.2-cvs/codepage.conf Unreal3.2/codepage.conf
--- Unreal3.2-cvs/codepage.conf	1970-01-01 00:00:00.000000000 +0000
+++ Unreal3.2/codepage.conf	2006-11-05 15:24:18.000000000 +0000
@@ -0,0 +1,15 @@
+codepage {
+	default "CP1251";
+	codepages 
+	{
+		CP1251;
+		CP949;
+		UTF-8;
+		UTF-16;
+		KOI8-R;
+		iso8859-5;
+		MACCYRILLIC;
+		CP866;
+		TRANSLIT;
+	};
+};
diff -Nura Unreal3.2-cvs/configure Unreal3.2/configure
--- Unreal3.2-cvs/configure	2006-06-26 00:13:52.000000000 +0000
+++ Unreal3.2/configure	2006-11-05 11:51:34.000000000 +0000
@@ -309,7 +309,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT RM CP TOUCH OPENSSLPATH INSTALL MAKER GMAKE GUNZIP PKGCONFIG IRCDLIBS MKPASSWDLIBS CPP EGREP ALLOCA STRTOUL CRYPTOLIB MODULEFLAGS HAVE_ZLIB URL IRCDDIR BINDIR FD_SETSIZE TREINCDIR TRELIBS CARESINCDIR CARESLIBDIR CARESLIBS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT RM CP TOUCH OPENSSLPATH INSTALL MAKER GMAKE GUNZIP PKGCONFIG IRCDLIBS MKPASSWDLIBS CPP EGREP ALLOCA STRTOUL CRYPTOLIB MODULEFLAGS HAVE_ZLIB URL HAVE_ICONV IRCDDIR BINDIR FD_SETSIZE TREINCDIR TRELIBS CARESINCDIR CARESLIBDIR CARESLIBS LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -847,6 +847,7 @@
                           /usr/ssl /usr/pkg /usr/local /usr
   --enable-ziplinks       enable ziplinks will check /usr/local /usr /usr/pkg
   --enable-libcurl=DIR    enable libcurl (remote include) support
+  --enable-iconv=DIR      enable iconv (codepage changing) support
   --enable-dynamic-linking
                           Make the IRCd dynamically link shared objects rather
                           than statically
@@ -12165,6 +12166,47 @@
 
 fi;
 
+# Check whether --enable-iconv or --disable-iconv was given.
+if test "${enable_iconv+set}" = set; then
+  enableval="$enable_iconv"
+
+echo "$as_me:$LINENO: checking for iconv" >&5
+echo $ECHO_N "checking for iconv... $ECHO_C" >&6
+    for dir in $enableval /usr/local /usr /usr/pkg; do
+        iconvdir="$dir"
+        if test -f "$dir/include/iconv.h" ; then
+	   echo "$as_me:$LINENO: result: found in $iconvdir" >&5
+echo "${ECHO_T}found in $iconvdir" >&6
+            found_iconv="yes" ;
+           if test "$iconvdir" = "/usr" ; then
+	       CFLAGS="$CFLAGS -DWITH_ICONV" ;
+           else
+	       CFLAGS="$CFLAGS -I$iconvdir/include -DWITH_ICONV" ;
+           fi
+	    break ;
+        fi
+    done
+    if test x_$found_iconv != x_yes ; then
+       echo "$as_me:$LINENO: result: not found" >&5
+echo "${ECHO_T}not found" >&6
+       { echo "$as_me:$LINENO: WARNING: disabling iconv support" >&5
+echo "$as_me: WARNING: disabling iconv support" >&2;}
+    else
+       case `uname -s` in
+       *BSD*)
+           IRCDLIBS="$IRCDLIBS -liconv" ;
+          if test "$iconvdir" != "/usr" ; then
+               LDFLAGS="$LDFLAGS -L$iconvdir/lib" ;
+           fi
+           ;;
+       esac
+        HAVE_ICONV=yes
+
+    fi
+
+
+fi;
+
 # Check whether --enable-dynamic-linking or --disable-dynamic-linking was given.
 if test "${enable_dynamic_linking+set}" = set; then
   enableval="$enable_dynamic_linking"
@@ -13374,6 +13416,7 @@
 s,@MODULEFLAGS@,$MODULEFLAGS,;t t
 s,@HAVE_ZLIB@,$HAVE_ZLIB,;t t
 s,@URL@,$URL,;t t
+s,@HAVE_ICONV@,$HAVE_ICONV,;t t
 s,@IRCDDIR@,$IRCDDIR,;t t
 s,@BINDIR@,$BINDIR,;t t
 s,@FD_SETSIZE@,$FD_SETSIZE,;t t
diff -Nura Unreal3.2-cvs/example.conf Unreal3.2/example.conf
--- Unreal3.2-cvs/example.conf	1970-01-01 00:00:00.000000000 +0000
+++ Unreal3.2/example.conf	2006-11-07 01:57:08.000000000 +0000
@@ -0,0 +1,805 @@
+/*
+ * example.conf by Daniel Hawton AKA Osiris (osiris@unrealircd.org).
+ * $Id: example.conf,v 1.1.1.1.2.21 2006/06/16 18:29:13 syzop Exp $
+ * 
+ * Works for Unreal3.2 and up
+ * 
+ * Okay guys.  This is the new example.conf. Its look is much like C++, kinda.
+ * Anyway it is time to go over this.  It's hard to pick up at first, but
+ * with some pratice and reading you'll understand.
+ *
+ * Just copy this file to your main unrealircd dir and call it 'unrealircd.conf'.
+ * 
+ * NOTE:  All lines, except the opening { line, end in an ;, including the
+ * closing } line. The IRCd will ignore commented lines.
+ *
+ * PLEASE READ doc/unreal32docs.html! The online version is also available at:
+ * www.vulnscan.org/UnrealIRCd/unreal32docs.html
+ * It contains a lot information about the configfile: gives information about
+ * every block, variable, etc..
+ * If you try to edit this file without reading the documentation properly
+ * then you are pretty much guaranteed to fail!
+ */
+
+/* Type of comments */
+#Comment type 1 (Shell type)
+// Comment type 2(C++ style)
+/* Comment type 3 (C Style) */
+#those lines are ignored by the ircd.
+
+/*
+ * UnrealIRCd supports modules, loading some of them is required.
+ * You need at least the commands module and a cloaking module.
+ */
+
+/* FOR *NIX, uncomment the following 2lines: */
+//loadmodule "src/modules/commands.so";
+//loadmodule "src/modules/cloak.so";
+
+/* FOR Windows, uncomment the following 2 lines: */
+//loadmodule "modules/commands.dll";
+//loadmodule "modules/cloak.dll";
+
+/*
+ * You can also include other configuration files.
+ * help.conf contains all the /helpop text. The badwords.*.conf
+ * files contain all the badword entries for mode +G...
+ * spamfilter.conf contains some good rules for current trojans.
+ * You probably want to include them:
+ */
+include "help.conf";
+include "badwords.channel.conf";
+include "badwords.message.conf";
+include "badwords.quit.conf";
+include "spamfilter.conf";
+include	"codepage.conf";
+
+/*
+ * NEW: me {} 
+ * OLD: M:Line 
+ * me {} defines the name, description and unreal server numeric for
+ * this server. Syntax is as follows: 
+ * me { 
+ *  name "server.name"; 
+ *  info "Server Description";
+ *  numeric (server numeric*);
+ * }; 
+ * If linking, this numeric may not be used by any other server on the network.
+ */
+me
+{
+	name "irc.foonet.com";
+	info "FooNet Server";
+	numeric 1;
+};
+
+/*
+ * NEW: admin {} 
+ * OLD: A:Line
+ * Admin gives information on the server admin. you
+ * may put as many lines under admin { as you wish. 
+ * Syntax is as follows:
+ * admin {
+ *   "first line"; 
+ *   "second line"; 
+ *   [etc]
+ * };
+ */
+admin {
+	"Bob Smith";
+	"bob";
+	"widely@used.name";
+};
+
+/*
+ * NEW: class {} 
+ * OLD: Y:line (old was confusing) 
+ * These define settings for classes. A class is a group setting for 
+ * connections. Example, server connections, instead of going to a client's
+ * class, you direct it to the server class. Syntax is as follows
+ * class (class name)
+ * {
+ *     pingfreq (how often to ping a user/server in seconds);
+ *     maxclients (how many connections for this class);
+ *     sendq (maximum send queue from a connection);
+ *     recvq (maximum receive queue from a connection [flood control]);
+ *  };
+ */
+
+class           clients
+{
+	pingfreq 90;
+	maxclients 500;
+	sendq 100000;
+	recvq 8000;
+};
+
+class           servers
+{
+	pingfreq 90;
+	maxclients 10;		/* Max servers we can have linked at a time */
+	sendq 1000000;
+	connfreq 100; /* How many seconds between each connection attempt */
+};
+
+/*
+ * NEW: allow {} 
+ * OLD: I:Line
+ * This defines allowing of connections...
+ * Basically for clients, it allows them to connect so you can have some
+ * control and/or set a password. 
+ * Syntax is as follows: 
+ * allow {
+ *    ip (ip mask to allow);
+ *    hostname (host mask);
+ *    class (class to send them to [see class {}]);
+ *    password "(password)"; (optional)
+ *    maxperip (how many connections per ip); (optional) 
+ * };
+ */
+
+allow {
+	ip             *@*;
+	hostname       *@*;
+	class           clients;
+	maxperip 5;
+};
+
+/* Passworded allow line */
+allow {
+	ip             *@255.255.255.255;
+	hostname       *@*.passworded.ugly.people;
+	class           clients;
+	password "f00Ness";
+	maxperip 1;
+};
+
+/*
+ * NEW: allow channel {} 
+ * OLD: chrestrict 
+ * Allows a user to join a channel...
+ * like an except from deny channel. 
+ * Syntax:
+ * allow channel {
+ *   channel "channel name";
+ * };
+ */
+allow           channel {
+	channel "#WarezSucks";
+};
+
+/*
+ * NEW: oper {} 
+ * OLD: O:Line 
+ * Defines an IRC Operator
+ * IRC operators are there to keep sanity to the server and usually keep it
+ * maintained and connected to the network. 
+ * The syntax is as follows: 
+ * oper (login) { 
+ *     class (class to put them in, if different from I, moves them to new
+ *                class); 
+ *     from { 
+ *        userhost (ident@host);
+ *        userhost (ident@host);
+ *     }; 
+ *     flags
+ *     { 
+ *       (flags here*);
+ *     };
+ *     OR
+ *     flags "old type flags, like OAaRD";
+ * };
+ */
+
+
+/* For a list of oper flags, see doc/unreal32docs.html#operblock
+ * [HIGHLY recommended to read]
+ */
+
+oper bobsmith {
+	class           clients;
+	from {
+		userhost bob@smithco.com;
+	};
+	password "f00";
+	flags
+	{
+		netadmin;
+		can_zline;
+		can_gzline;
+		can_gkline;
+		global;
+	};
+};
+
+/*
+ * NEW: listen {}
+ * OLD: P:Line
+ * This defines a port for the ircd to bind to, to
+ * allow users/servers to connect to the server. 
+ * Syntax is as follows:
+ * listen (ip number):(port number) 
+ * { 
+ *   options {
+ *     (options here);
+ *   };
+ * };
+ * or for a plain
+ * listen: listen (ip):(port);
+ * 
+ * NOTICE: for ipv6 ips (3ffe:b80:2:51d::2 etc), use listen [ip]:port;
+ * 
+ * That works also.
+ */
+
+/* Options for listen:
+	OLD	| 	NEW
+	S		serversonly
+	C		clientsonly
+	J		java
+	s		ssl
+	*		standard
+*/
+
+/* NOTE ON SSL PORTS: SSL ports are pretty non-standardized,
+ * besides numerous high-SSL ports, some people say you should run
+ * it at 994 because that's the official SSL port.. but that
+ * requires root! Besides, port 194 is the official irc port and
+ * have you ever seen an ircd running on that?
+ * So, our suggestion is to use port 6697 for SSL, this is used by
+ * quite some networks and is recognized by for example StunTour.
+ * You are free to open up as many SSL ports as you want, but
+ * by (also) using 6697 you help the world standardize a bit ;).
+ */
+listen         *:6697
+{
+	codepage "CP1251";
+	options
+	{
+		ssl;
+		clientsonly;
+	};
+};
+
+listen         *:8067
+{
+	codepage "CP1251";
+};
+listen         *:6667
+{
+	codepage "CP1251";
+};
+
+/* NOTE: If you are on an IRCd shell with multiple IP's you are
+ *       likely to get 'Address already in use' errors in your log
+ *       and the ircd won't start. This means you MUST bind
+ *       to a specific IP instead of '*', so for example:
+ *       listen 1.2.3.4:6667;
+ *       Obviously, replace the IP with the IP that was assigned to you.
+ */
+
+/*
+ * NEW: link {}
+ * OLD: C/N:Lines
+ * This defines an okay for a server connection.
+ * NOTE: BOTH SERVERS NEED A LINK {} SETTING TO CONNECT PROPERLY!
+ * Syntax is as follows:
+ * link (server name)
+ * {
+ *	username	(username, * works too);
+ * 	hostname	(ip number/hostmask);
+ *	bind-ip		(What IP to bind to when connecting, or *);
+ *	port		(port to connect to, if any);
+ *	hub (If this is a hub, * works, or servermasks it may bring in);
+ *	[or leaf *;]
+ *	password-connect "(pass to send)";
+ *	password-receive "(pass we should receive)";
+ *	class		(class to direct servers into);
+ *	options {
+ *		(options here*);
+ *	};
+ *      /* If we use SSL, we can choose what cipher to use in SSL mode
+ *       * Retrieve a list by "openssl ciphers", seperate ciphers with :'s
+ *      */
+ *      ciphers "DES-CBC3-MD5";
+ * 
+ * };
+*/
+
+/*
+	options:
+	OLD	|	NEW
+	S		ssl
+	Z		zip
+	N/A		autoconnect
+	N/A		quarantine
+	N/A		nodnscache
+*/
+
+
+link            hub.mynet.com
+{
+	username	*;
+	hostname 	1.2.3.4;
+	bind-ip 	*;
+	port 		7029;
+	hub             *;
+	password-connect "LiNk";
+	password-receive "LiNk";
+	class           servers;
+		options {
+			/* Note: You should not use autoconnect when linking services */
+			autoconnect;
+			ssl;
+			zip;
+		};
+};
+/*
+ *
+ * NEW: ulines {}
+ * OLD: U:Line
+ * U-lines give servers more power/commands, this should ONLY be set
+ * for services/stats servers and NEVER for normal UnrealIRCd servers!
+ * Syntax is as follows:
+ * ulines {
+ *	(server to uline);
+ *	(server to uline);
+ *  [etc]
+ * };
+*/
+ulines {
+	services.roxnet.org;
+	stats.roxnet.org;
+};
+
+/*
+ * NEW: drpass {}
+ * OLD: X:Line
+ * This defines the passwords for /die and /restart.
+ * Syntax is as follows:
+ * drpass { 
+ *  restart		"(password for restarting)";
+ *  die		        "(password for die)";
+ * };
+ */
+drpass {
+	restart "I-love-to-restart";
+	die "die-you-stupid";
+};
+
+/*
+ * NEW: log {} OLD: N/A Tells the ircd where and what to log(s). You can have
+ * as many as you wish.
+ * 
+ * FLAGS: errors, kills, tkl, connects, server-connects, kline, oper
+ * 
+ * Syntax: 
+ * log "log file" 
+ * {
+ *    flags
+ *    {
+ *        flag;
+ *        flag; 
+ *        etc.. 
+ *    }; 
+ * };
+ */
+
+log "ircd.log" {
+	/* Delete the log file and start a new one when it reaches 2MB, leave this out to always use the 
+	   same log */
+	maxsize 2097152;
+	flags {
+		oper;
+		kline;
+		connects;
+		server-connects;
+		kills;
+		errors;
+		sadmin-commands;
+		chg-commands;
+		oper-override;
+		spamfilter;
+	};
+};
+
+/*
+ * NEW: alias {}
+ * OLD: N/A
+ * This allows you to set command aliases such as /nickserv, /chanserv etc
+ * FLAGS: services, stats, normal
+ *
+ * Syntax:
+ * alias "name" {
+ *	target "points to";
+ *	type aliastype;
+ * };
+ *
+ * [NOTE: You could also include a pre-defined alias file here, see doc/unreal32docs.html section 2.9]
+ */
+
+// This points the command /nickserv to the user NickServ who is connected to the set::services-server server
+/*alias NickServ {
+	target "NickServ";
+	type services;
+};*/
+
+// If you want the command to point to the same nick as the command, you can leave the nick entry out
+//alias ChanServ { type services; };
+
+// Points the /statserv command to the user StatServ on the set::stats-server server
+//alias StatServ { type stats; };
+
+// Points the /superbot command to the user SuperBot
+//alias SuperBot { type normal; };
+
+
+/* Standard aliases */
+alias NickServ { type services; };
+alias ChanServ { type services; };
+alias OperServ { type services; };
+alias HelpServ { type services; };
+alias StatServ { type stats; };
+
+/*
+ * NEW: alias {}
+ * OLD: N/A
+ * This allows you to set command aliases such as /identify, /services, etc
+ *
+ * Syntax:
+ * alias "name" {
+ *	format "format string" {
+ *		target "points to";
+ *              type aliastype;
+ *		parameters "parameters to send";
+ *	};
+ *	type command;
+ * };
+ */
+/* This is shown seperately because even though it has teh same name as the previous directive, it is very
+ * different in syntax, although it provides a similar function and relys on the standard aliases to work.
+ */
+/*
+alias "identify" {
+	format "^#" {
+		target "chanserv";
+		type services;
+		parameters "IDENTIFY %1-";
+	};
+	format "^[^#]" {
+		target "nickserv";
+		type services;
+		parameters "IDENTIFY %1-";
+	};
+	type command;
+};
+*/
+/* The alias::format directive is a regular expression. The first format matches the /identify command when
+ * the first character is a #. It then passes this along to the chanserv alias with the parameters IDENTIFY
+ * %1-. The second format matches then /identify command when the first character is not a #. It then
+ * passes the command to the nickserv alias with parameters IDENTIFY %1-.
+ */
+
+/* The alias::format::parameters is similar to scripting languages. %N (where N is a number) represents a
+ * parameter sent to the command (in this case /identify). If you specify %N- it means all parameters from
+ * N until the last parameter in the string. You may also specify %n which is replaced by
+ * the user's nickname.
+*/
+
+/* Standard aliases */
+alias "services" {
+	format "^#" {
+		target "chanserv";
+		type services;
+		parameters "%1-";
+	};
+	format "^[^#]" {
+		target "nickserv";
+		type services;
+		parameters "%1-";
+	};
+	type command;
+};
+
+alias "identify" {
+	format "^#" {
+		target "chanserv";
+		type services;
+		parameters "IDENTIFY %1-";
+	};
+	format "^[^#]" {
+		target "nickserv";
+		type services;
+		parameters "IDENTIFY %1-";
+	};
+	type command;
+};
+
+/* This is an example of a real command alias */
+/* This maps /GLINEBOT to /GLINE <parameter> 2d etc... */
+alias "glinebot" {
+	format ".+" {
+		command "gline";
+		type real;
+		parameters "%1 2d Bots are not allowed on this server, please read the faq at http://www.example.com/faq/123";
+	};
+	type command;
+};
+
+
+
+/*
+ * NEW: tld {}
+ * OLD: T:Line
+ * This sets a different motd and rules files
+ * depending on the clients hostmask.
+ * Syntax is as follows: 
+ * tld {
+ *    mask (ident@host);
+ *    motd "(motd file)";
+ *    rules "(rules file)";
+ * };
+ */
+
+tld {
+	mask *@*.fr;
+	motd "ircd.motd.fr";
+	rules "ircd.rules.fr";
+};
+
+/* note: you can just delete the example block above,
+ * in which case the defaults motd/rules files (ircd.motd, ircd.rules)
+ * will be used for everyone.
+ */
+
+/*
+ * NEW: ban nick {}
+ * OLD: Q:Line
+ * Bans a nickname, so it can't be used.
+ * Syntax is as follows:
+ * ban nick {
+ *	mask "(nick to ban)";
+ *	reason "(reason)";
+ * };
+*/
+ban nick {
+	mask "*C*h*a*n*S*e*r*v*";
+	reason "Reserved for Services";
+};
+/*
+ * NEW: ban ip {}
+ * OLD: Z:Line
+ * Bans an ip from connecting to the network.
+ * Syntax:
+ * ban ip { mask (ip number/hostmask); reason "(reason)"; };
+*/
+ban ip {
+	mask 195.86.232.81;
+	reason "Delinked server";
+};
+/*
+ * NEW: ban server {}
+ * OLD: Server Q:Line
+ * Disables a server from connecting to the network.
+ * if the server links to a remote server, local server
+ * will disconnect from the network.
+ * Syntax is as follows:
+ * ban server {
+ *	mask "(server name)";
+ *	reason "(reason to give)";
+ * };
+*/
+
+ban server {
+	mask eris.berkeley.edu;
+	reason "Get out of here.";
+};
+/*
+ * NEW: ban user {}
+ * OLD: K:Line
+ * This makes it so a user from a certain mask can't connect
+ * to your server.
+ * Syntax:
+ * ban user { mask (hostmask/ip number); reason "(reason)"; };
+*/
+
+ban user {
+	mask *tirc@*.saturn.bbn.com;
+        reason "Idiot";
+};
+
+/*
+ * NEW: ban realname {}
+ * OLD: n:Line
+ * This bans a certain realname from being used.
+ * Syntax:
+ * ban realname {
+ *	mask "(real name)";
+ * 	reason "(reason)";
+ * };
+*/
+
+ban realname {
+	mask "Swat Team";
+	reason "mIRKFORCE";
+};
+
+ban realname {
+	mask "sub7server";
+	reason "sub7";
+};
+
+/*
+ * NOTE FOR ALL BANS, they may be repeated for addition entries!
+ * 
+ * NEW: except ban {} 
+ * OLD: E:Line
+ * This makes it so you can't get banned. 
+ * Syntax:
+ * except ban { mask (ident@host); };
+ * Repeat the except ban {} as many times
+ * as you want for different hosts.
+ */
+
+except ban {
+	/* don't ban stskeeps */
+	mask           *stskeeps@212.*;
+};
+
+/*
+ * NEW: deny dcc {} 
+ * OLD: dccdeny.conf
+ * Use this to block dcc send's... stops
+ * viruses better. 
+ * Syntax: 
+ * deny dcc 
+ * { 
+ *   filename "file to block (ie, *exe)";
+ *   reason "reason";
+ * };
+ */
+deny dcc {
+	filename "*sub7*";
+	reason "Possible Sub7 Virus";
+};
+
+/*
+ * NEW: deny channel {}
+ * OLD: N/A (NEW)
+ * This blocks channels from being joined.
+ * Syntax:
+ * deny channel {
+ * 	channel "(channel)";
+ * 	reason "reason";
+ * };
+*/
+deny channel {
+	channel "*warez*";
+	reason "Warez is illegal";
+};
+
+/*
+ * NEW: vhost {}
+ * OLD: Vhost.conf file
+ * This sets a fake ip for non-opers, or
+ * opers too lazy to /sethost :P
+ * Syntax:  
+ *   vhost { 
+ *       vhost (vhost.com); 
+ *       from {
+ *            userhost (ident@host to allow to use it);
+ *       };
+ *       login (login name);
+ *       password (password);
+ *   };
+ *        then to use this vhost, do /vhost (login) (password) in IRC
+ */
+vhost {
+	vhost           i.hate.microsefrs.com;
+	from {
+		userhost       *@*.image.dk;
+	};
+	login           stskeeps;
+	password        moocowsrulemyworld;
+};
+
+/* You can include other configuration files */
+/* include "klines.conf"; */
+
+/* Network configuration */
+set {
+	network-name 		"ROXnet";
+	default-server 		"irc.roxnet.org";
+	services-server 	"services.roxnet.org";
+	stats-server 		"stats.roxnet.org";
+	help-channel 		"#ROXnet";
+	hiddenhost-prefix	"rox";
+	/* prefix-quit 		"no"; */
+	/* Cloak keys should be the same at all servers on the network.
+	 * They are used for generating masked hosts and should be kept secret.
+	 * The keys should be 3 random strings of 5-100 characters
+	 * (10-20 chars is just fine) and must consist of lowcase (a-z),
+	 * upcase (A-Z) and digits (0-9) [see first key example].
+	 */
+	cloak-keys {
+		"aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW";
+		"and another one";
+		"and another one";
+	};
+	/* on-oper host */
+	hosts {
+		local		"locop.roxnet.org";
+		global		"ircop.roxnet.org";
+		coadmin		"coadmin.roxnet.org";
+		admin		"admin.roxnet.org";
+		servicesadmin 	"csops.roxnet.org";
+		netadmin 	"netadmin.roxnet.org";
+		host-on-oper-up "no";
+	};
+};
+
+/* Server specific configuration */
+
+set {
+	kline-address "set.this.email";
+	modes-on-connect "+ixw";
+	modes-on-oper	 "+xwgs";
+	oper-auto-join "#opers";
+	dns {
+		nameserver 127.0.0.1;
+		timeout 2s;
+		retries 2;
+	};
+	options {
+		hide-ulines;
+		/* You can enable ident checking here if you want */
+		/* identd-check; */
+		show-connect-info;
+	};
+
+	maxchannelsperuser 10;
+	/* The minimum time a user must be connected before being allowed to use a QUIT message,
+	 * This will hopefully help stop spam */
+	anti-spam-quit-message-time 10s;
+	/* Make the message in static-quit show in all quits - meaning no
+           custom quits are allowed on local server */
+	/* static-quit "Client quit";	*/
+
+	/* You can also block all part reasons by uncommenting this and say 'yes',
+	 * or specify some other text (eg: "Bye bye!") to always use as a comment.. */
+	/* static-part yes; */
+
+	/* This allows you to make certain stats oper only, use * for all stats,
+	 * leave it out to allow users to see all stats. Type '/stats' for a full list.
+	 * Some admins might want to remove the 'kGs' to allow normal users to list
+	 * klines, glines and shuns.
+	 */
+	oper-only-stats "okfGsMRUEelLCXzdD";
+
+	/* Throttling: this example sets a limit of 3 connection attempts per 60s (per host). */
+	throttle {
+		connections 3;
+		period 60s;
+	};
+
+	/* Anti flood protection */
+	anti-flood {
+		nick-flood 3:60;	/* 3 nickchanges per 60 seconds (the default) */
+	};
+
+	/* Spam filter */
+	spamfilter {
+		ban-time 1d; /* default duration of a *line ban set by spamfilter */
+		ban-reason "Spam/Advertising"; /* default reason */
+		virus-help-channel "#help"; /* channel to use for 'viruschan' action */
+		/* except "#help"; channel to exempt from filtering */
+	};
+};
+
+/*
+ * Problems or need more help?
+ * 1) www.vulnscan.org/UnrealIRCd/unreal32docs.html
+ * 2) www.vulnscan.org/UnrealIRCd/faq/ <- contains 80% of your questions!
+ * 3) If you still have problems you can go irc.ircsystems.net #unreal-support,
+ *    note that we require you to READ THE DOCUMENTATION and FAQ first!
+ */
diff -Nura Unreal3.2-cvs/include/dynconf.h Unreal3.2/include/dynconf.h
--- Unreal3.2-cvs/include/dynconf.h	2006-05-21 17:17:30.000000000 +0000
+++ Unreal3.2/include/dynconf.h	2006-11-07 21:07:56.000000000 +0000
@@ -83,6 +83,10 @@
 	unsigned allow_part_if_shunned:1;
 	unsigned check_target_nick_bans:1;
 	unsigned use_egd;
+#ifdef WITH_ICONV
+	char *default_codepage;
+	ConfigItem_codepage *cp;
+#endif
 	long host_timeout;
 	int  host_retries;
 	char *name_server;
@@ -300,6 +304,11 @@
 	unsigned has_egd_path:1;
 	unsigned has_static_quit:1;
 	unsigned has_static_part:1;
+#ifdef WITH_ICONV
+	unsigned has_codepage:1;
+	unsigned has_cp_default:1;
+	unsigned has_cplist:1;
+#endif
 #ifdef USE_SSL
 	unsigned has_ssl_certificate:1;
 	unsigned has_ssl_key:1;
diff -Nura Unreal3.2-cvs/include/h.h Unreal3.2/include/h.h
--- Unreal3.2-cvs/include/h.h	2006-11-04 07:27:28.000000000 +0000
+++ Unreal3.2/include/h.h	2006-11-07 21:09:10.000000000 +0000
@@ -101,6 +101,9 @@
 extern MODVAR ConfigItem_include	*conf_include;
 extern MODVAR ConfigItem_help		*conf_help;
 extern MODVAR ConfigItem_offchans	*conf_offchans;
+#ifdef WITH_ICONV
+extern MODVAR ConfigItem_codepage      *conf_codepage;
+#endif
 extern int		completed_connection(aClient *);
 extern void clear_unknown();
 extern EVENT(e_unload_module_delayed);
@@ -132,6 +135,10 @@
 ConfigItem_deny_channel *Find_channel_allowed(char *name);
 ConfigItem_alias	*Find_alias(char *name);
 ConfigItem_help 	*Find_Help(char *command);
+#ifdef WITH_ICONV 
+ConfigItem_codepage    *Find_codepage(char *name);
+ConfigItem_codepage    *Find_def_codepage(void);
+#endif
 int			AllowClient(aClient *cptr, struct hostent *hp, char *sockhost, char *username);
 int parse_netmask(const char *text, struct irc_netmask *netmask);
 int match_ip(struct IN_ADDR addr, char *uhost, char *mask, struct irc_netmask *netmask);
diff -Nura Unreal3.2-cvs/include/msg.h Unreal3.2/include/msg.h
--- Unreal3.2-cvs/include/msg.h	2006-02-26 03:06:10.000000000 +0000
+++ Unreal3.2/include/msg.h	2006-11-07 21:10:16.000000000 +0000
@@ -297,6 +297,13 @@
 #define MSG_EOS		"EOS"
 #define TOK_EOS		"ES"
 
+#ifdef WITH_ICONV
+#define MSG_CODEPAGE   "CODEPAGE"
+#define TOK_CODEPAGE   "CP"
+#define MSG_CODEPAGES  "CODEPAGES"
+#define TOK_CODEPAGES  "CPS"
+#endif
+
 #define MAXPARA    	15
 
 extern int m_error();
diff -Nura Unreal3.2-cvs/include/numeric.h Unreal3.2/include/numeric.h
--- Unreal3.2-cvs/include/numeric.h	2005-09-26 00:49:18.000000000 +0000
+++ Unreal3.2/include/numeric.h	2006-11-07 21:11:16.000000000 +0000
@@ -358,6 +358,14 @@
 
 #define RPL_WHOISSECURE      671
 
+#ifdef WITH_ICONV
+#define RPL_CODEPAGE         700
+#define RPL_CODEPAGES        701
+#define RPL_ENDOFCODEPAGES   702
+#define RPL_WHOISSCHEME      703
+#define RPL_STATSCODEPAGE    704
+#endif
+
 #define ERR_CANNOTDOCOMMAND 972
 #define ERR_CANNOTCHANGECHANMODE 974
 #define ERR_NUMERICERR       999
diff -Nura Unreal3.2-cvs/include/struct.h Unreal3.2/include/struct.h
--- Unreal3.2-cvs/include/struct.h	2006-07-07 11:12:10.000000000 +0000
+++ Unreal3.2/include/struct.h	2006-11-07 22:55:46.000000000 +0000
@@ -124,6 +124,9 @@
 typedef struct _configitem_include ConfigItem_include;
 typedef struct _configitem_help ConfigItem_help;
 typedef struct _configitem_offchans ConfigItem_offchans;
+#ifdef WITH_ICONV 
+typedef struct _configitem_codepage ConfigItem_codepage;
+#endif
 typedef struct liststruct ListStruct;
 
 #define CFG_TIME 0x0001
@@ -938,6 +941,9 @@
 	char info[REALLEN + 1];	/* Free form additional client information */
 	aClient *srvptr;	/* Server introducing this.  May be &me */
 	short status;		/* client type */
+#ifdef WITH_ICONV	
+	char *codepage;		/* Codepage */
+#endif
 	/*
 	   ** The following fields are allocated only for local clients
 	   ** (directly connected to *this* server with a socket.
@@ -1184,6 +1190,9 @@
 	ConfigItem 	*prev, *next;
 	ConfigFlag 	flag;
 	char		*ip;
+#ifdef WITH_ICONV 
+	char		*codepage;
+#endif
 	int		port;
 	int		options, clients;
 	aClient		*listener;
@@ -1359,6 +1368,18 @@
 	regex_t expr;
 };
 
+#ifdef WITH_ICONV
+struct _configitem_codepage {
+	ConfigItem *prev, *next;
+	ConfigFlag flag;
+	short defcpage;
+	char *file;
+	char repl1[256];
+	char repl2[256];
+	char *name;
+};
+#endif
+
 #define INCLUDE_NOTLOADED  0x1
 #define INCLUDE_REMOTE     0x2
 #define INCLUDE_DLQUEUED   0x4
diff -Nura Unreal3.2-cvs/makefile.win32 Unreal3.2/makefile.win32
--- Unreal3.2-cvs/makefile.win32	2006-11-05 22:50:26.000000000 +0000
+++ Unreal3.2/makefile.win32	2006-11-07 01:54:36.000000000 +0000
@@ -54,6 +54,21 @@
 #
 ######### END SSL ########
 
+##### ICONV SUPPORT ######
+#To enable ICONV support you must have libiconv installed on your system
+#
+#
+#To enable ICONV uncomment the next line:
+#USE_ICONV=1
+#
+#If your ICONV library and include files are not in your compiler's
+#default locations, specify the locations here:
+#ICONV_INC_DIR="c:\libiconv\include"
+#ICONV_LIB_DIR="c:\libiconv\lib"
+#
+#
+####### END ICONV ########
+
 ###### _EXTRA_ DEBUGGING #####
 # We always build releases with debugging information, since otherwise
 # we cannot trace the source of a crash. Plus we do not mind the extra
@@ -108,6 +123,17 @@
 !ENDIF
 !ENDIF
 
+!IFDEF USE_ICONV
+ICONVCFLAGS=/D WITH_ICONV
+ICONVLIB=libiconv.lib
+!IFDEF ICONV_INC_DIR
+ICONV_INC=/I "$(ICONV_INC_DIR)"
+!ENDIF
+!IFDEF ICONV_LIB_DIR
+ICONV_LIB=/LIBPATH:"$(ICONV_LIB_DIR)"
+!ENDIF
+!ENDIF
+
 !IFDEF DEBUGEXTRA
 DBGCFLAG=/MDd /Zi /Od
 DBGLFLAG=/debug
@@ -119,17 +145,17 @@
 !ENDIF 
 
 FD_SETSIZE=/D FD_SETSIZE=16384
-CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /J /I ./INCLUDE /I ./INCLUDE/WIN32/ARES /Fosrc/ /nologo \
- $(ZIPCFLAGS) $(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) $(NS_ADDRESS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
+CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) $(ICONV_INC) /J /I ./INCLUDE /I ./INCLUDE/WIN32/ARES /Fosrc/ /nologo \
+ $(ZIPCFLAGS) $(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) $(ICONVCFLAGS) $(NS_ADDRESS) /D NOSPOOF=1 /c /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
 LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib ws2_32.lib advapi32.lib \
  dbghelp.lib oldnames.lib comctl32.lib comdlg32.lib $(ZLIB_LIB) $(ZIPLIB) \
- $(OPENSSL_LIB) $(SSLLIBS) $(LIBCURL_LIB) $(CURLLIB) /def:wircd.def /implib:wircd.lib \
+ $(OPENSSL_LIB) $(SSLLIBS) $(LIBCURL_LIB) $(CURLLIB) $(ICONV_LIB) $(ICONVLIB) /def:wircd.def /implib:wircd.lib \
  /nologo $(DBGLFLAG) /out:WIRCD.EXE
-MODCFLAGS=$(MODDBGCFLAG) $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) /J /Fesrc/modules/ \
- /Fosrc/modules/ /nologo $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /I ./INCLUDE /D \
+MODCFLAGS=$(MODDBGCFLAG) $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) $(ICONVCFLAGS) /J /Fesrc/modules/ \
+ /Fosrc/modules/ /nologo $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) $(ICONV_INC) /I ./INCLUDE /D \
  DYNAMIC_LINKING /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _USE_32BIT_TIME_T
 MODLFLAGS=/link /def:src/modules/module.def wircd.lib $(OPENSSL_LIB) $(SSLLIBS) \
- $(ZLIB_LIB) $(ZIPLIB) $(LIBCURL_LIB) $(CURLLIB)
+ $(ZLIB_LIB) $(ZIPLIB) $(LIBCURL_LIB) $(CURLLIB) $(ICONV_LIB) $(ICONVLIB)
 
 INCLUDES=./include/struct.h ./include/config.h ./include/sys.h \
  ./include/common.h ./include/version.h ./include/h.h ./include/numeric.h \
@@ -183,7 +209,7 @@
  SRC/MODULES/M_NICK.C SRC/MODULES/M_USER.C SRC/MODULES/M_MODE.C \
  SRC/MODULES/M_WATCH.C SRC/MODULES/M_PART.C SRC/MODULES/M_JOIN.C \
  SRC/MODULES/M_MOTD.C SRC/MODULES/M_OPERMOTD.C SRC/MODULES/M_BOTMOTD.C \
- SRC/MODULES/M_LUSERS.C SRC/MODULES/M_NAMES.C
+ SRC/MODULES/M_LUSERS.C SRC/MODULES/M_NAMES.C SRC/MODULES/M_CODEPAGE.C
 
 DLL_FILES=SRC/MODULES/M_CHGHOST.DLL SRC/MODULES/M_SDESC.DLL SRC/MODULES/M_SETIDENT.DLL \
  SRC/MODULES/M_SETNAME.DLL SRC/MODULES/M_SETHOST.DLL SRC/MODULES/M_CHGIDENT.DLL \
@@ -219,7 +245,7 @@
  SRC/MODULES/M_WATCH.DLL SRC/MODULES/M_PART.DLL SRC/MODULES/M_JOIN.DLL \
  SRC/MODULES/M_MOTD.DLL SRC/MODULES/M_OPERMOTD.DLL SRC/MODULES/M_BOTMOTD.DLL \
  SRC/MODULES/M_LUSERS.DLL SRC/MODULES/M_NAMES.DLL \
- SRC/MODULES/CLOAK.DLL
+ SRC/MODULES/CLOAK.DLL SRC/MODULES/M_CODEPAGE.DLL
 
 
 ALL: CONF UNREAL.EXE WIRCD.EXE src/modules/commands.dll MODULES 
@@ -462,8 +488,8 @@
 MODULES: $(DLL_FILES)
 
 src/modules/commands.dll: $(MOD_FILES) $(INCLUDES)
-	$(CC) $(MODDBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /nologo \
-	      $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) /Fosrc/modules/ \
+	$(CC) $(MODDBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) $(ICONV_INC) /nologo \
+	      $(SSLCFLAGS) $(ZIPCFLAGS) $(CURLCFLAGS) $(ICONVCFLAGS) /Fosrc/modules/ \
 	      /I ./INCLUDE /D NOSPOOF /D MODULE_COMPILE /D _CRT_SECURE_NO_DEPRECATE \
 	      /D _USE_32BIT_TIME_T $(MOD_FILES) \
 	      $(MODLFLAGS) src/win32/tre.lib /OUT:src/modules/commands.dll
@@ -774,6 +800,9 @@
 src/modules/cloak.dll: src/modules/cloak.c $(INCLUDES)
         $(CC) $(MODCFLAGS) src/modules/cloak.c $(MODLFLAGS)
 
+src/modules/m_codepage.dll: src/modules/m_codepage.c $(INCLUDES)
+        $(CC) $(MODCFLAGS) src/modules/m_codepage.c $(MODLFLAGS)
+
 dummy:
 
 
diff -Nura Unreal3.2-cvs/src/api-isupport.c Unreal3.2/src/api-isupport.c
--- Unreal3.2-cvs/src/api-isupport.c	2006-02-26 03:06:10.000000000 +0000
+++ Unreal3.2/src/api-isupport.c	2006-11-07 22:31:28.000000000 +0000
@@ -145,6 +145,9 @@
 	ircsprintf(tmpbuf, "#:%d", MAXCHANNELSPERUSER);
 	IsupportAdd(NULL, "CHANLIMIT", tmpbuf);
 	IsupportAdd(NULL, "MAXCHANNELS", my_itoa(MAXCHANNELSPERUSER));
+#ifdef WITH_ICONV
+	IsupportAdd(NULL, "CODEPAGES", NULL);
+#endif
 	IsupportAdd(NULL, "HCN", NULL);
 	IsupportAdd(NULL, "SAFELIST", NULL);
 	IsupportAdd(NULL, "NAMESX", NULL);
diff -Nura Unreal3.2-cvs/src/modules/Makefile.in Unreal3.2/src/modules/Makefile.in
--- Unreal3.2-cvs/src/modules/Makefile.in	2006-11-04 01:32:06.000000000 +0000
+++ Unreal3.2/src/modules/Makefile.in	2006-11-05 15:44:20.000000000 +0000
@@ -55,7 +55,7 @@
 	 m_svsfline.so m_dccdeny.so m_undccdeny.so m_whowas.so \
 	 m_connect.so m_dccallow.so m_userip.so m_nick.so m_user.so \
 	 m_mode.so m_watch.so m_part.so m_join.so m_motd.so m_opermotd.so \
-	 m_botmotd.so m_lusers.so m_names.so cloak.so 
+	 m_botmotd.so m_lusers.so m_names.so m_codepage.so cloak.so 
 
 #note change of .c to .o
 COMMANDS=m_sethost.o m_chghost.o m_chgident.o m_setname.o m_setident.o \
@@ -77,7 +77,7 @@
 	 m_svsfline.o m_dccdeny.o m_undccdeny.o m_whowas.o \
 	 m_connect.o m_dccallow.o m_userip.o m_nick.o m_user.o \
 	 m_mode.o m_watch.o m_part.o m_join.o m_motd.o m_opermotd.o \
-	 m_botmotd.o m_lusers.o m_names.o
+	 m_botmotd.o m_lusers.o m_names.o m_codepage.o
 
 
 MODULES=commands.so $(R_MODULES)
@@ -405,6 +405,9 @@
 m_names.o: m_names.c $(INCLUDES)
 	$(CC) $(CFLAGS) $(MODULEFLAGS)  -c m_names.c
 
+m_codepage.o: m_codepage.c $(INCLUDES)
+	$(CC) $(CFLAGS) $(MODULEFLAGS)  -c m_codepage.c
+
 #############################################################################
 #             .so's section
 #############################################################################
@@ -813,6 +816,10 @@
 	$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
 	       -o m_names.so m_names.c
 
+m_codepage.so: m_codepage.c $(INCLUDES)
+	$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
+	        -o m_codepage.so m_codepage.c
+
 #############################################################################
 #             and now the remaining modules...
 #############################################################################
diff -Nura Unreal3.2-cvs/src/modules/l_commands.c Unreal3.2/src/modules/l_commands.c
--- Unreal3.2-cvs/src/modules/l_commands.c	2006-05-22 12:21:54.000000000 +0000
+++ Unreal3.2/src/modules/l_commands.c	2006-11-07 21:16:00.000000000 +0000
@@ -125,6 +125,10 @@
 extern int m_guest_Init(ModuleInfo *modinfo);
 #endif
 
+#ifdef WITH_ICONV
+extern int m_codepage_Init(ModuleInfo *modinfo);
+#endif
+
 extern int m_sethost_Load(int module_load), m_setname_Load(int module_load), m_chghost_Load(int module_load);
 extern int m_chgident_Load(int module_load), m_setident_Load(int module_load), m_sdesc_Load(int module_load);
 extern int m_svsmode_Load(int module_load), m_swhois_Load(int module_load), m_svsmotd_Load(int module_load);
@@ -173,6 +177,10 @@
 extern int m_guest_Load(int module_load);
 #endif
 
+#ifdef WITH_ICONV
+extern int m_codepage_Load(int module_load);
+#endif
+
 extern int m_sethost_Unload(), m_setname_Unload(), m_chghost_Unload(), m_chgident_Unload();
 extern int m_setident_Unload(), m_sdesc_Unload(), m_svsmode_Unload(), m_swhois_Unload();
 extern int m_svsmotd_Unload(), m_svsnline_Unload(), m_who_Unload(), m_mkpasswd_Unload();
@@ -208,6 +216,10 @@
 extern int m_guest_Unload();
 #endif
 
+#ifdef WITH_ICONV 
+extern int m_codepage_Unload();
+#endif
+
 #ifdef DYNAMIC_LINKING
 DLLFUNC int Mod_Test(ModuleInfo *modinfo)
 #else
@@ -347,6 +359,11 @@
 #ifdef GUEST
 	m_guest_Init(ModCmdsInfo);
 #endif
+
+#ifdef WITH_ICONV
+	m_codepage_Init(ModCmdsInfo);
+#endif
+
 	MARK_AS_OFFICIAL_MODULE(modinfo);
 	return MOD_SUCCESS;
 }
@@ -459,6 +476,11 @@
 #ifdef GUEST
 	m_guest_Load(module_load);
 #endif
+
+#ifdef WITH_ICONV
+	m_codepage_Load(module_load);
+#endif
+
 	return MOD_SUCCESS;
 }
 
@@ -571,6 +593,11 @@
 #ifdef GUEST
 	m_guest_Unload();
 #endif
+
+#ifdef WITH_ICONV
+	m_codepage_Unload();
+#endif
+
 	return MOD_SUCCESS;
 }
 
diff -Nura Unreal3.2-cvs/src/modules/m_codepage.c Unreal3.2/src/modules/m_codepage.c
--- Unreal3.2-cvs/src/modules/m_codepage.c	1970-01-01 00:00:00.000000000 +0000
+++ Unreal3.2/src/modules/m_codepage.c	2006-11-08 01:10:28.000000000 +0000
@@ -0,0 +1,197 @@
+/*
+ *   IRC - Internet Relay Chat, src/modules/m_codepage.c
+ *   (C) 1999-2001 Carsten Munk (Techie/Stskeeps) <stskeeps@tspre.org>
+ *
+ *   See file AUTHORS in IRC package for additional names of
+ *   the programmers. 
+ *
+ *   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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "config.h"
+#include "struct.h"
+#include "common.h"
+#include "sys.h"
+#include "numeric.h"
+#include "msg.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"
+#include "proto.h"
+#ifdef STRIPBADWORDS
+#include "badwords.h"
+#endif
+#ifdef _WIN32
+#include "version.h"
+#endif
+
+DLLFUNC int m_codepage(aClient *cptr, aClient *sptr, int parc, char *parv[]);
+DLLFUNC int m_codepages(aClient *cptr, aClient *sptr, int parc, char *parv[]);
+
+ModuleHeader MOD_HEADER(m_codepage)
+	= {
+	"codepage",    /* Name of module */
+	"$Id: m_codepage.c,v 1.1.0.0 2002/12/29 14:20:45 i (admin@i386.net.ru) & Spider Exp $", /* Version */
+	"/codepage", /* Short description of module */
+	"3.2-b8-1",
+	};
+
+/*
+ * The purpose of these ifdefs, are that we can "static" link the ircd if we
+ * want to
+*/
+
+
+DLLFUNC int    MOD_INIT(m_codepage)(ModuleInfo *modinfo)
+{
+#ifdef WITH_ICONV
+	add_Command(MSG_CODEPAGE, TOK_CODEPAGE, m_codepage, MAXPARA);
+	add_Command(MSG_CODEPAGES, TOK_CODEPAGES, m_codepages, MAXPARA);
+#endif
+	return MOD_SUCCESS;
+    
+}
+
+DLLFUNC int    MOD_LOAD(m_codepage)(int module_load)
+{
+	return MOD_SUCCESS;
+}
+
+DLLFUNC int    MOD_UNLOAD(m_codepage)(int module_unload)
+{
+#ifdef WITH_ICONV
+	if (del_Command(MSG_CODEPAGE, TOK_CODEPAGE, m_codepage) < 0)
+	{
+		sendto_realops("Failed to delete commands when unloading %s",
+			MOD_HEADER(m_codepage).name);
+	}
+#endif	
+	return MOD_SUCCESS;
+}
+
+/* 
+ * m_codepage - 12/29/2002 - ECTb
+ * :prefix CODEPAGE <new codepage>
+ * parv[0] - sender
+ * parv[1] - codepage
+ *
+*/
+
+DLLFUNC int m_codepage(aClient *cptr, aClient *sptr, int parc, char *parv[])
+{
+	if (!MyClient(sptr)) 
+	{
+		aClient *acptr;
+#ifndef WITH_ICONV
+	if (MyClient(sptr))
+	{
+		sendto_one(sptr, ":%s NOTICE %s :*** The /codepage command is disabled on this server", 
+				me.name, sptr->name);
+		return 0;
+	}
+#else
+	if (parc < 3)
+		return 0;    
+	acptr = find_person(parv[1], (aClient *)NULL);
+		if (!acptr)
+			return 0;
+	if (Find_codepage(parv[2])) 
+	{
+		if (!acptr->codepage)
+			acptr->codepage=strdup(parv[2]);
+		else
+			strcpy(acptr->codepage, parv[2]);
+	}
+#endif
+	return 0;
+	}
+
+#ifdef WITH_ICONV
+	
+	if (parc < 2)
+	{
+	sendto_one(sptr,
+		":%s NOTICE %s :*** /codepage syntax is /codepage <new_codepage>",
+			me.name, sptr->name);
+	sendto_one(sptr,
+		":%s NOTICE %s :*** Your current codepage is: %s Port: %d",
+			me.name, sptr->name, sptr->codepage, cptr->listener->port);
+		return 0;
+	}
+
+	if (strlen(parv[1]) < 1)
+	{
+	sendto_one(sptr,
+		":%s NOTICE %s :*** Write atleast something to change the codepage to!",
+			me.name, sptr->name);
+		return 0;
+	}
+
+	if (strlen(parv[1]) > 16)
+	{
+		sendto_one(sptr,
+			":%s NOTICE %s :*** Codepage Error: Too long codepage!!",
+				me.name, sptr->name);
+		return 0;
+	}
+
+	if (Find_codepage(parv[1]))
+	{
+		sptr->codepage = strdup(parv[1]);
+		sendto_one(sptr, rpl_str(RPL_CODEPAGE), me.name, parv[0], sptr->codepage);
+		sendto_serv_butone_token(cptr, sptr->name,
+			MSG_CODEPAGE, TOK_CODEPAGE, "%s :%s", sptr->name, sptr->codepage);
+	return 0;
+	}
+	else
+	{
+		sendto_one(sptr,
+			":%s NOTICE %s :*** /Codepage Error: Unknown codepage %s",
+				me.name, parv[0], parv[1]);
+		return 0;
+	}
+#endif
+	return 0;
+
+}
+
+
+/* 
+ * m_codepages - 2/09/2003 - ECTb
+ * :prefix CODEPAGES
+ * parv[0] - sender
+ *
+*/
+
+DLLFUNC int m_codepages(aClient *cptr, aClient *sptr, int parc, char *parv[])
+{
+#ifdef WITH_ICONV
+	ConfigItem_codepage *cpage = NULL;
+	for (cpage = conf_codepage; cpage; cpage = (ConfigItem_codepage *)cpage->next) 
+	{
+		sendto_one(sptr, rpl_str(RPL_CODEPAGES), me.name, 
+			parv[0], cpage->name, cpage->defcpage?" default":"");
+	}
+	sendto_one(sptr, rpl_str(RPL_ENDOFCODEPAGES), me.name, parv[0]);
+#endif
+	return 0;
+}
diff -Nura Unreal3.2-cvs/src/modules/m_nick.c Unreal3.2/src/modules/m_nick.c
--- Unreal3.2-cvs/src/modules/m_nick.c	2006-11-04 07:27:30.000000000 +0000
+++ Unreal3.2/src/modules/m_nick.c	2006-11-07 21:20:24.000000000 +0000
@@ -811,6 +811,9 @@
 int _register_user(aClient *cptr, aClient *sptr, char *nick, char *username, char *umode, char *virthost, char *ip)
 {
 	ConfigItem_ban *bconf;
+#ifdef WITH_ICONV
+	ConfigItem_listen *plisten;
+#endif
 	char *parv[3], *tmpstr;
 #ifdef HOSTILENAME
 	char stripuser[USERLEN + 1], *u1 = stripuser, *u2, olduser[USERLEN + 1],
@@ -842,6 +845,21 @@
 	
 	if (MyConnect(sptr))
 	{
+#ifdef WITH_ICONV
+		plisten = Find_listen("*",cptr->listener->port);
+		if (plisten)
+		{
+			cptr->codepage = strdup(plisten->codepage);
+			sendto_one(cptr, ":%s NOTICE AUTH :*** You connected on %d port. Using %s translation scheme as default.", 
+				me.name, cptr->listener->port, cptr->codepage);
+		}
+		else
+		{
+			cptr->codepage = strdup(Find_def_codepage()->name);
+			sendto_one(cptr, ":%s NOTICE AUTH :*** You connected on %d port. Translation scheme not specified for this port.",
+					me.name, cptr->listener->port);
+               }
+#endif
 		if ((i = check_client(sptr, username))) {
 			/* This had return i; before -McSkaf */
 			if (i == -5)
@@ -1152,6 +1170,18 @@
 	    (!buf || *buf == '\0' ? "+" : buf),
 	    sptr->umodes & UMODE_SETHOST ? sptr->user->virthost : NULL);
 
+#ifdef WITH_ICONV
+	if (MyConnect(sptr))
+	{
+		if (sptr->codepage)
+		{
+			sendto_one(sptr, rpl_str(RPL_CODEPAGE), sptr->name, parv[0], sptr->codepage);
+			sendto_serv_butone_token(sptr, sptr->name,
+				MSG_CODEPAGE, TOK_CODEPAGE, "%s :%s", sptr->name, sptr->codepage);
+		}
+	}
+#endif
+
 	/* Send password from sptr->passwd to NickServ for identification,
 	 * if passwd given and if NickServ is online.
 	 * - by taz, modified by Wizzu
diff -Nura Unreal3.2-cvs/src/modules/m_server.c Unreal3.2/src/modules/m_server.c
--- Unreal3.2-cvs/src/modules/m_server.c	2006-08-24 12:18:20.000000000 +0000
+++ Unreal3.2/src/modules/m_server.c	2006-11-07 21:21:18.000000000 +0000
@@ -894,6 +894,14 @@
 					    MSG_SWHOIS), acptr->name,
 					    acptr->user->swhois);
 
+#ifdef WITH_ICONV
+			if (acptr->codepage)
+				if (*acptr->codepage != '\0')
+					sendto_one(cptr, "%s %s :%s",
+					    (IsToken(cptr) ? TOK_CODEPAGE :
+					    MSG_CODEPAGE), acptr->name, acptr->codepage);
+#endif
+
 			if (!SupportSJOIN(cptr))
 				send_user_joins(cptr, acptr);
 		}
diff -Nura Unreal3.2-cvs/src/modules/m_stats.c Unreal3.2/src/modules/m_stats.c
--- Unreal3.2-cvs/src/modules/m_stats.c	2006-05-29 23:43:16.000000000 +0000
+++ Unreal3.2/src/modules/m_stats.c	2006-11-07 21:28:12.000000000 +0000
@@ -120,6 +120,10 @@
 int stats_officialchannels(aClient *, char *);
 int stats_spamfilter(aClient *, char *);
 
+#ifdef WITH_ICONV
+int stats_codepages(aClient *, char *);
+#endif
+
 #define SERVER_AS_PARA 0x1
 #define FLAGS_AS_PARA 0x2
 
@@ -168,6 +172,9 @@
 	{ 'm', "command",	stats_command,		0 		},
 	{ 'n', "banrealname",	stats_banrealname,	0 		},
 	{ 'o', "oper",		stats_oper,		0 		},
+#ifdef WITH_ICONV
+	{ 'p', "codepages",	stats_codepages,	0		},
+#endif
 	{ 'q', "bannick",	stats_bannick,		FLAGS_AS_PARA	},
 	{ 'r', "chanrestrict",	stats_chanrestrict,	0 		},
 	{ 's', "shun",		stats_shun,		FLAGS_AS_PARA	},
@@ -273,6 +280,10 @@
 		"n - banrealname - Send the ban realname block list");
 	sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, sptr->name,
 		"O - oper - Send the oper block list");
+#ifdef WITH_ICONV
+	sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, sptr->name,
+		"p - codepages - Send information about codepages");
+#endif
 	sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, sptr->name,
 		"P - port - Send information about ports");
 	sendto_one(sptr, rpl_str(RPL_STATSHELP), me.name, sptr->name,
@@ -684,12 +695,19 @@
 			continue;
 	  	if (!IsListening(acptr))
 	  		continue;
-	  	sendto_one(sptr, ":%s %s %s :*** Listener on %s:%i, clients %i. is %s %s",
-	  		me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name,
-	  		((ConfigItem_listen *)acptr->class)->ip,
+#ifdef WITH_ICONV
+		sendto_one(sptr, ":%s %s %s :*** Listener on %s:%i, clients %i. is %s %s %s",
+#else
+		sendto_one(sptr, ":%s %s %s :*** Listener on %s:%i, clients %i. is %s %s %s",
+#endif
+			me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name,
+			((ConfigItem_listen *)acptr->class)->ip,
 			((ConfigItem_listen *)acptr->class)->port,
 			((ConfigItem_listen *)acptr->class)->clients,
 			((ConfigItem_listen *)acptr->class)->flag.temporary ? "TEMPORARY" : "PERM",
+#ifdef WITH_ICONV
+			((ConfigItem_listen *)acptr->class)->codepage ? ((ConfigItem_listen *)acptr->class)->codepage : (conf_codepage->defcpage?Find_def_codepage()->name:"CP1251"),
+#endif
 			stats_port_helper(acptr));
 	}
 	return 0;
@@ -709,6 +727,17 @@
 	return 0;
 }
 
+#ifdef WITH_ICONV
+int stats_codepages(aClient *sptr, char *para)
+{
+	ConfigItem_codepage *x;
+	for (x = conf_codepage; x; x = (ConfigItem_codepage *)x->next)
+		sendto_one(sptr, ":%s %i %s :%s %s",
+			me.name, RPL_TEXT, sptr->name, x->name, x->defcpage ? "- default" : "");
+	return 0;
+}
+#endif
+
 int stats_traffic(aClient *sptr, char *para)
 {
 	aClient *acptr;
diff -Nura Unreal3.2-cvs/src/modules/m_whois.c Unreal3.2/src/modules/m_whois.c
--- Unreal3.2-cvs/src/modules/m_whois.c	2006-07-07 11:12:12.000000000 +0000
+++ Unreal3.2/src/modules/m_whois.c	2006-11-07 21:28:46.000000000 +0000
@@ -320,6 +320,13 @@
 					    me.name, RPL_WHOISSPECIAL, parv[0],
 					    name, acptr->user->swhois);
 
+                       /* CODEPAGE USE by i (admin@i386.net.ru) */
+#ifdef WITH_ICONV
+		sendto_one(sptr, rpl_str(RPL_WHOISSCHEME),
+			me.name, parv[0], name,
+			acptr->codepage ? acptr->codepage : Find_def_codepage()->name);
+#endif
+
 			/*
 			 * Fix /whois to not show idle times of
 			 * global opers to anyone except another
diff -Nura Unreal3.2-cvs/src/s_bsd.c Unreal3.2/src/s_bsd.c
--- Unreal3.2-cvs/src/s_bsd.c	2006-11-05 10:57:42.000000000 +0000
+++ Unreal3.2/src/s_bsd.c	2006-11-07 21:31:54.000000000 +0000
@@ -79,6 +79,11 @@
 int  rr;
 
 #endif
+
+#ifdef WITH_ICONV
+#include <iconv.h>
+#endif
+
 #ifdef INET6
 static unsigned char minus_one[] =
     { 255, 255, 255, 255, 255, 255, 255, 255, 255,
@@ -1381,6 +1386,43 @@
 	start_auth(acptr);
 }
 
+#ifdef WITH_ICONV
+/*
+ *  decoding codepage...
+ */
+
+int	dech_codepage(char *codepage, int *length) 
+{
+	static char buf[READBUF_SIZE];
+	const char *p1 = readbuf;
+	char *p2 = buf;
+	size_t s1, s2, bytes;
+	iconv_t cd;
+	ConfigItem_codepage *cp = Find_def_codepage();
+	if (!codepage || !cp) 
+		return 0;
+	if (!stricmp(codepage, cp->name)) 
+	{ 
+		return 0; 
+	}
+	cd = iconv_open (cp->name, codepage);
+	if (cd == (iconv_t)(-1)) 
+		return 0;
+	s1 = *length;
+	s2 = READBUF_SIZE;
+	bytes = iconv (cd, &p1, &s1, &p2, &s2);
+	if (bytes < 0 || s1 != 0) 
+	{
+		iconv_close (cd);
+		return 0;
+	}
+	*length = READBUF_SIZE - s2;
+	memcpy(readbuf,buf,*length);
+	readbuf[*length]='\0';
+	iconv_close(cd);
+}    
+#endif
+
 void proceed_normal_client_handshake(aClient *acptr, struct hostent *he)
 {
 	ClearDNS(acptr);
@@ -1416,6 +1458,9 @@
 		else
 #endif
 			length = recv(cptr->fd, readbuf, sizeof(readbuf), 0);
+#ifdef WITH_ICONV
+		if (!IsServer(cptr)) dech_codepage(cptr->codepage,&length);
+#endif
 		cptr->lasttime = now;
 		if (cptr->lasttime > cptr->since)
 			cptr->since = cptr->lasttime;
diff -Nura Unreal3.2-cvs/src/s_conf.c Unreal3.2/src/s_conf.c
--- Unreal3.2-cvs/src/s_conf.c	2006-07-24 17:06:40.000000000 +0000
+++ Unreal3.2/src/s_conf.c	2006-11-08 00:14:42.000000000 +0000
@@ -108,7 +108,10 @@
 static int	_conf_help		(ConfigFile *conf, ConfigEntry *ce);
 static int	_conf_offchans		(ConfigFile *conf, ConfigEntry *ce);
 static int	_conf_spamfilter	(ConfigFile *conf, ConfigEntry *ce);
-static int	_conf_cgiirc	(ConfigFile *conf, ConfigEntry *ce);
+static int	_conf_cgiirc		(ConfigFile *conf, ConfigEntry *ce);
+#ifdef WITH_ICONV
+static int	_conf_codepage		(ConfigFile *conf, ConfigEntry *ce);
+#endif
 
 /* 
  * Validation commands 
@@ -141,7 +144,10 @@
 static int	_test_help		(ConfigFile *conf, ConfigEntry *ce);
 static int	_test_offchans		(ConfigFile *conf, ConfigEntry *ce);
 static int	_test_spamfilter	(ConfigFile *conf, ConfigEntry *ce);
-static int	_test_cgiirc	(ConfigFile *conf, ConfigEntry *ce);
+static int	_test_cgiirc		(ConfigFile *conf, ConfigEntry *ce);
+#ifdef WITH_ICONV
+static int	_test_codepage		(ConfigFile *conf, ConfigEntry *ce);
+#endif
  
 /* This MUST be alphabetized */
 static ConfigCommand _ConfigCommands[] = {
@@ -152,8 +158,11 @@
 	{ "badword",		_conf_badword,		_test_badword	},
 #endif
 	{ "ban", 		_conf_ban,		_test_ban	},
-	{ "cgiirc", 	_conf_cgiirc,	_test_cgiirc	},
+	{ "cgiirc",		_conf_cgiirc,		_test_cgiirc	},
 	{ "class", 		_conf_class,		_test_class	},
+#ifdef WITH_ICONV 
+        { "codepage",		_conf_codepage,		_test_codepage  },
+#endif
 	{ "deny",		_conf_deny,		_test_deny	},
 	{ "drpass",		_conf_drpass,		_test_drpass	},
 	{ "except",		_conf_except,		_test_except	},
@@ -164,10 +173,10 @@
 	{ "loadmodule",		NULL,		 	_test_loadmodule},
 	{ "log",		_conf_log,		_test_log	},
 	{ "me", 		_conf_me,		_test_me	},
-	{ "official-channels", 		_conf_offchans,		_test_offchans	},
+	{ "official-channels",	_conf_offchans,		_test_offchans	},
 	{ "oper", 		_conf_oper,		_test_oper	},
 	{ "set",		_conf_set,		_test_set	},
-	{ "spamfilter",	_conf_spamfilter,	_test_spamfilter	},
+	{ "spamfilter",		_conf_spamfilter,	_test_spamfilter},
 	{ "tld",		_conf_tld,		_test_tld	},
 	{ "ulines",		_conf_ulines,		_test_ulines	},
 	{ "vhost", 		_conf_vhost,		_test_vhost	},
@@ -384,6 +393,10 @@
 #endif
 ConfigItem_offchans	*conf_offchans = NULL;
 
+#ifdef WITH_ICONV
+ConfigItem_codepage	*conf_codepage = NULL;
+#endif
+
 aConfiguration		iConf;
 MODVAR aConfiguration		tempiConf;
 MODVAR ConfigFile		*conf = NULL;
@@ -1817,6 +1830,9 @@
 	ConfigItem_help			*help_ptr;
 	ConfigItem_offchans		*of_ptr;
 	OperStat 			*os_ptr;
+#ifdef WITH_ICONV
+	ConfigItem_codepage		*codepage_ptr;
+#endif
 	ListStruct 	*next, *next2;
 	aTKline *tk, *tk_next;
 	SpamExcept *spamex_ptr;
@@ -2130,6 +2146,15 @@
 		DelListItem(alias_ptr, conf_alias);
 		MyFree(alias_ptr);
 	}
+#ifdef WITH_ICONV
+	for (codepage_ptr = conf_codepage; codepage_ptr; codepage_ptr = (ConfigItem_codepage *)next)
+	{
+		next = (ListStruct *)codepage_ptr->next;
+		ircfree(codepage_ptr->name);
+		DelListItem(codepage_ptr, conf_codepage);
+		MyFree(codepage_ptr);
+	}
+#endif
 	for (help_ptr = conf_help; help_ptr; help_ptr = (ConfigItem_help *)next) {
 		aMotd *text;
 		next = (ListStruct *)help_ptr->next;
@@ -2182,7 +2207,10 @@
 int	config_post_test()
 {
 #define Error(x) { config_error((x)); errors++; }
-	int 	errors = 0;
+#ifdef WITH_ICONV
+	ConfigItem_listen	*p = NULL;
+#endif
+	int	errors = 0;
 	Hook *h;
 	
 	if (!requiredstuff.conf_me)
@@ -2417,6 +2445,27 @@
 	}
 	return NULL;
 }
+#ifdef WITH_ICONV
+ConfigItem_codepage    *Find_codepage(char *name) {
+	ConfigItem_codepage *codepage;
+	if (!name)
+		return NULL;
+	for (codepage = conf_codepage; codepage; codepage = (ConfigItem_codepage *)codepage->next) {
+		if (!stricmp(codepage->name, name))
+			return codepage;
+	}
+	return NULL;
+}
+
+ConfigItem_codepage    *Find_def_codepage(void) {
+	ConfigItem_codepage *codepage;
+	for (codepage = conf_codepage; codepage; codepage = (ConfigItem_codepage *)codepage->next) {
+		if (codepage->defcpage)
+			return codepage;
+	}
+	return NULL;
+}
+#endif
 
 ConfigItem_class	*Find_class(char *name)
 {
@@ -4071,6 +4120,9 @@
 	char	    copy[256];
 	char	    *ip;
 	char	    *port;
+#ifdef WITH_ICONV
+	char	    *tempcodepage;
+#endif
 	int	    start, end, iport, isnew;
 	int tmpflags =0;
 
@@ -4105,6 +4157,13 @@
 					tmpflags |= ofp->flag;
 			}
 		}
+#ifdef WITH_ICONV
+		if (!strcmp(cep->ce_varname, "codepage"))
+		{
+			tempcodepage = strdup(cep->ce_vardata);
+		}
+#endif
+	
 	}
 #ifndef USE_SSL
 	tmpflags &= ~LISTENER_SSL;
@@ -4124,6 +4183,10 @@
 			tmpflags |= LISTENER_BOUND;
 
 		listen->options = tmpflags;
+#ifdef WITH_ICONV
+		if (!tempcodepage) listen->codepage = strdup(Find_def_codepage()->name);
+		else listen->codepage = strdup(tempcodepage);
+#endif
 		if (isnew)
 			AddListItem(listen, conf_listen);
 		listen->flag.temporary = 0;
@@ -4141,6 +4204,9 @@
 	int	    start, end;
 	int	    errors = 0;
 	char has_options = 0;
+#ifdef WITH_ICONV
+	char has_codepage = 0;
+#endif
 	OperFlag    *ofp;
 
 	if (!ce->ce_vardata)
@@ -4256,6 +4322,12 @@
 #endif
 			}
 		}
+#ifdef WITH_ICONV
+		else if (!strcmp(cep->ce_varname, "codepage")) {
+			/*do nothing*/
+			has_codepage = 1;
+		}
+#endif
 		else
 		{
 			config_error_unknown(cep->ce_fileptr->cf_filename, cep->ce_varlinenum,
@@ -4265,6 +4337,13 @@
 		}
 
 	}
+#ifdef WITH_ICONV
+	if (!has_codepage) {
+		config_error("%s:%i: listen: without default codepage define",
+			ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
+		return 1;
+	}
+#endif	
 	requiredstuff.conf_listen = 1;
 	return errors;
 }
@@ -7933,6 +8012,65 @@
 	return errors;
 }
 
+#ifdef WITH_ICONV
+int	_conf_codepage(ConfigFile *conf, ConfigEntry *ce)
+{
+	ConfigEntry *cep,*cepp;
+	ConfigItem_codepage *cp;
+	char *defcp;
+	cep = config_find_entry(ce->ce_entries, "default");
+	defcp = strdup(cep->ce_vardata);
+	cep = config_find_entry(ce->ce_entries, "codepages");
+	for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next)
+	{
+		cp = MyMallocEx(sizeof(ConfigItem_codepage));
+		ircstrdup(cp->name, cepp->ce_varname);
+		if (!stricmp(cepp->ce_varname,defcp)) { cp->defcpage = 1; }
+		else cp->defcpage = 0;
+		AddListItem(cp, conf_codepage);
+	}
+	config_status("default codepage = %s",defcp);
+	ircfree(defcp);
+	return 1;
+}
+
+int	_test_codepage(ConfigFile *conf, ConfigEntry *ce)
+{
+	ConfigEntry     *cep, *cepp;
+	char *defcp;
+	short find=0;
+	if (!(cep = config_find_entry(ce->ce_entries, "default")))
+ 	{
+		config_status("%s:%i: codepage::default: no dafult codepage given",
+		ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
+		return -1;
+	}
+	defcp = strdup(cep->ce_vardata);
+	if ((cep = config_find_entry(ce->ce_entries, "codepages")))
+	{
+		for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next)
+		{
+			if (!cepp->ce_varname)
+			{
+				config_error("%s:%i: codepage::codepages: item without variable name",
+					cepp->ce_fileptr->cf_filename, cepp->ce_varlinenum);
+				continue;
+			}
+			if (!find && (stricmp(cepp->ce_varname,defcp)==0)) find=1;
+		}
+	}
+	else
+	{
+		config_status("%s:%i: codepage::codepages: no allowed codepages given",
+			ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
+		ircfree(defcp);
+		return -1;
+	}
+	ircfree(defcp);
+	return 0;
+}
+#endif
+
 int	_conf_loadmodule(ConfigFile *conf, ConfigEntry *ce)
 {
 #ifdef GLOBH
diff -Nura Unreal3.2-cvs/src/s_err.c Unreal3.2/src/s_err.c
--- Unreal3.2-cvs/src/s_err.c	2006-01-16 22:46:48.000000000 +0000
+++ Unreal3.2/src/s_err.c	2006-11-07 21:37:08.000000000 +0000
@@ -756,11 +756,19 @@
 /* 697 */ NULL,
 /* 698 */ NULL,
 /* 699 */ NULL,
+#ifdef WITH_ICONV
+/* 700 RPL_CODEPAGE */ ":%s 700 %s :Your codepage is now %s",
+/* 701 RPL_CODEPAGES */ ":%s 701 %s :%s%s",
+/* 702 RPL_ENDOFCODEPAGES */ ":%s 702 %s :End of /CODEPAGES list",
+/* 703 RPL_WHOISSCHEME */ ":%s 703 %s %s :is using codepage %s",
+/* 704 RPL_STATSCODEPAGE */ ":%s 704 %s j %s %d :%s",
+#else
 /* 700 */ NULL,
 /* 701 */ NULL,
 /* 702 */ NULL,
 /* 703 */ NULL,
 /* 704 */ NULL,
+#endif
 /* 705 */ NULL,
 /* 706 */ NULL,
 /* 707 */ NULL,
diff -Nura Unreal3.2-cvs/src/send.c Unreal3.2/src/send.c
--- Unreal3.2-cvs/src/send.c	2006-05-21 17:17:32.000000000 +0000
+++ Unreal3.2/src/send.c	2006-11-07 21:40:04.000000000 +0000
@@ -39,6 +39,9 @@
 #include <io.h>
 #endif
 #include <string.h>
+#ifdef WITH_ICONV
+#include <iconv.h>
+#endif
 
 void vsendto_one(aClient *to, char *pattern, va_list vl);
 void sendbufto_one(aClient *to, char *msg, unsigned int quick);
@@ -67,7 +70,9 @@
 ** connected to them
 */
 static int sentalong[MAXCONNECTIONS];
-
+#ifdef WITH_ICONV
+char *translit(char *text, char *res);
+#endif
 void vsendto_prefix_one(struct Client *to, struct Client *from,
     const char *pattern, va_list vl);
 
@@ -238,6 +243,77 @@
 	va_end(vl);
 }
 
+#ifdef WITH_ICONV
+char *translit(char *text, char *res)
+{
+	int index;
+	char rusalfa[] = "ÀÁÂÃÄÅ¨ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäå¸æçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
+	char transalfa[][3] = { "A","B","V","G","D","E","E","J","Z","I","Q",
+				"K","L","M","N","O","P","R","S","T","U","F","H",
+				"C","4","W","W","'","Y","`","E","U","A","a",
+				"b","v","g","d","e","e","j","z","i","q","k","l",
+				"m","n","o","p","r","s","t","u","f","h","c","4",
+				"w","w","'","y","`","e","u","a" };
+	char cur[2];
+	int i;
+	for (i=0;i<strlen(text);i++)
+	{
+		cur[0] = text[i];
+		cur[1] = '\0';
+		if (strspn(cur,rusalfa))
+		{
+			index = strcspn(rusalfa,cur);
+			strcat(res,transalfa[index]);
+		}
+	else
+		strcat(res,cur);
+	}
+	return res;
+}
+
+char *ch_codepage(char *codepage,char *text,int *len) {
+	int one = 1;
+	static char buf[2048]; /* for unicode messages */
+	char my_result[2048]="";
+	const char *msghold = text;
+	char *res = my_result, *holder = &buf[0];
+	size_t outsize, r;
+	iconv_t cd;
+	ConfigItem_codepage *cp = Find_def_codepage();
+	if (!codepage || !cp) 
+		{ 
+			return text; 
+		}
+	if (!stricmp(codepage, cp->name)) 
+		{ 
+			return text; 
+		}
+	cd = iconv_open (codepage, cp->name);
+	if (cd == (iconv_t)(-1)) 
+	{
+	if (!strcasecmp(codepage,"TRANSLIT"))
+		{
+			translit(text,res);
+			return res; 
+		}
+	return text;
+	}
+	outsize = 2048;
+	iconvctl(cd,ICONV_SET_DISCARD_ILSEQ,&one);
+	r = iconv (cd, &msghold, len, &holder, &outsize);
+	if (r < 0 || (*len) != 0) 
+		{
+			ircd_log(LOG_ERROR, "iconv: errno=%d", errno);
+			iconv_close (cd);
+			return text;
+		}
+	*len = 2048 - outsize;
+	buf[*len] = 0;
+	iconv_close (cd);
+	return &buf[0];
+}
+#endif
+
 void vsendto_one(aClient *to, char *pattern, va_list vl)
 {
 	ircvsprintf(sendbuf, pattern, vl);
@@ -259,6 +335,9 @@
 void sendbufto_one(aClient *to, char *msg, unsigned int quick)
 {
 	int  len;
+#ifdef WITH_ICONV
+	char *holder=msg;
+#endif
 	
 	Debug((DEBUG_ERROR, "Sending [%s] to %s", msg, to->name));
 
@@ -279,9 +358,15 @@
 		return;
 	}
 
+#ifdef WITH_ICONV
 	if (!quick)
 	{
 		len = strlen(msg);
+#else
+	if (!quick)
+        {
+		len = strlen(msg);
+
 		if (!len || (msg[len - 1] != '\n'))
 		{
 			if (len > 510)
@@ -290,10 +375,29 @@
 			msg[len++] = '\n';
 			msg[len] = '\0';
 		}
+#endif
 	} else
+#ifdef WITH_ICONV
+		len = quick;
+#else
 		len = quick;
 
 	if (len > 512)
+#endif
+
+#ifdef WITH_ICONV 
+	if (!IsServer(to)) msg=ch_codepage(to->codepage,msg,&len);
+
+	if (!len || (msg[len - 1] != '\n'))
+	{
+	        if (len > 2048) /* need for correct work Unicode */
+		        len = 2048; /* need for correct work Unicode */
+		msg[len++] = '\r';
+		msg[len++] = '\n';
+		msg[len] = '\0';
+	}
+	if (len > 2048) /* need for correct work Unicode */
+#endif
 	{
 		ircd_log(LOG_ERROR, "sendbufto_one: len=%u, quick=%u", len, quick);
 		abort();
