commit b2e402231d8f06859bb7b8ab30e9945f2f858b38 Author: cmunk Date: Sun May 28 08:45:31 2000 +0000 Addition of Unreal3.1-beta3 diff --git a/devel/aln.doc b/devel/aln.doc new file mode 100644 index 000000000..77193a736 --- /dev/null +++ b/devel/aln.doc @@ -0,0 +1,26 @@ + +ALN, Alphanumeric System +(C) Stskeeps 2000 + +ALN is a quick hack to short down usage of bandwidth-using servernames +in prefixes, NICK commands, etc etc. It replaces the name with a +1 or 2 byte prefix in a system, look at src/aln.c for the prefix +types/values. It will be an PROTOCTL, and used in NICK messages and so on, +and introduce a new prefix server<->server called |server. The value of the +server is calculated by a hash value, the scache system, so that the server +can lookup with a new scache function, scache_find_by_hash(int i). The +question of it will conflict in similar-hash server names, is a wonder to me +:P, we will find out, but scache will fail at same time then. + + +Examples: +& Medb 4 957458466 ~Medb bservice.org D2 0 +iwrx * +:BotService Bot - bservice.org - Owner: terri{J} + +where D2 is the hash value of oxygen.phrozen.org (/stats s on a +#define DEVELOP server). irc.flirt.org has hash 96 (ALN code AX) for +instance. + +@D2 GLOBOPS :message +will be a message from server with hash D2, found find-by-hash(256) + diff --git a/devel/new.plines b/devel/new.plines new file mode 100644 index 000000000..022041db3 --- /dev/null +++ b/devel/new.plines @@ -0,0 +1,48 @@ +From cmunk@draconic.fyremoon.net Wed Apr 5 18:09:55 2000 +Date: Wed, 5 Apr 2000 18:07:55 +0100 (BST) +From: "The Nightwalker (Stskeeps)" +To: unreal-dev@lists.sourceforge.net +Subject: [Unreal-dev] P:Lines + + +Some stuff i got ideas about.. stripping the IP and port from the M:Line +and enforcing the main port to be in a M:line + +M:irc.fyremoon.net:*:Forever is gonna start tonight:* + +P:ip:flags:password1,password2,password3:port + | | | \- port to bind to + | | | + | | \- Commaseperated lists of accepted passwords + | | * if none + | | + | \--- C = Allow clients + | S = Allow servers + | R = ONLY allow our remote admin connections + | (may only be on a P:line of its own) + | J = Clients that connect here are counted as Java(Confroomhack) + | * = CS + | + \--- IP to bind to, * = INADDR_ANY (all interfaces) + +Will make P:Lines more efficent + +--------------------------------------------------------------------- +Carsten V. Munk - The Nightwalker, known on IRC as Stskeeps or techie + * ICQ: 16465977 - E-Mail: stskeeps@tspre.org + * Author of UnrealIRCd (http://unreal.tspre.org) + * Technical Admin @ irc.roxnet.org, server admin of irc.fyremoon.net +"To understand a program you must become both the machine and the program." +---------------------------------------------------------------------- + +-----BEGIN GEEK CODE BLOCK----- +Version: 3.1 +GCS/CC d- s: a--- C+++ UL P L++ E-- W++ N+ o-- K- w--- O- M V-- PS+ PE- Y+ +PGP t+ 5 X R- tv- b+ DI++ D++ G e-- h! r z** +------END GEEK CODE BLOCK------ + + +_______________________________________________ +Unreal-dev mailing list +Unreal-dev@lists.sourceforge.net +http://lists.sourceforge.net/mailman/listinfo/unreal-dev diff --git a/doc/History/Elite.Changes b/doc/History/Elite.Changes new file mode 100644 index 000000000..00889a143 --- /dev/null +++ b/doc/History/Elite.Changes @@ -0,0 +1,129 @@ +[ $Id$ ] +Take this with a grain of salt.. it's heaps old and this isn't Elite anymore + + +--------------------------- +Version Elite2.0 ========== +=========================== +- Since +x was rewritten, the ban bug is 100% fixed. :) +- Rewrote +x hidden host function completely. +- Fixed FUNNY bug with hiddenhost and /who (Reported by Prod|gy) +- Added/Removed irc networks +- Fixed bug in /watch (Reported/Fixed by Despise) +- Added nick-change flood protection. +- Added an awesome manual... ./manual to run +- Removed /who notice for opers. +- Added protection of /akill *@* :) +- Removed java stuff completely. (Java clients are like normal IRC clients...right?) +- Added new +a mode. This mode can only be set by +q channel owners. When you are +a in a + channel, you cannot be deopped or kicked. (Syntax: /mode #chan +a ) +- Added new +q channel mode. ChanServ must set the channel founder +q so they are also + known as channel owners via the ircd. Channel owners are protected and may set + other users +a which they will also be protected (but not chan owners). + (Syntax: /mode #chan +q ) +- Re-coded /MAP +- Changed GLINE notices from sendto_ops to send to all opers with +e flag on. +- Added (addnet) script, you can run this to add your net settings to the next release. +- Changed to in whois "Blah is an oper on " +- Added new +L channel mode. If a #chat has a limit (+l) of 10 users, and +L set to channel + #chat2, when a user trys to join #chat, they won't get "#chat is full", they will be + auto-joined to #chat2 - (Linked channels in other words). + (Syntax: /mode #chan +L ) +- Changes user@shadow-33.com to user@user-33.one.com (noone will know one.com is the realhost) +- Changed +x for IP's from (x.x.x.***) to (x.x.x.network-#) +- In oline flags * will introduce +e on oper up. (before: required +e in oline flag) +- Removed +t usermode (UMODE_ALL) - wasn't used. +- Made 'create your own network setting' feature more stable. +- Added new channel mode (+x) to disable colored text in channel. +- Added +C (Co Administrator) +- Added +T (Technical Administrator) +- Changed /map to numerics... +- Made startup message when booting more stable. + +Version Elite1.3 (02/23/99) +============================ +- Cleaned up version.c.SH +- Added new net settings (netdomain & helpchan) +- Added new net config creator in ./Config +- Made ./Config more easier... +- Created new usermode +j (Java user) +- New hostname (java.shadownet.org) for java users. +- Removed RUN_SERVICES code from entire ircd. + +Version Elite1.2.4 (02/14/99) +============================ +- Fixed the nick crash bug! (damn m_kill small error) +- New network(s) added. +- Changed one thing in m_gline (nothing big) + +Version Elite1.2.3 (02/10/99) +============================ +- Removed SOCKS checking. (possibly cause of crashing) +- Added new networks + +Version Elite1.2.2 (02/02/99) +============================ +- Fixed the crashing bug. (Changing nicks with linked servers) +- Modified AceStar net settings. +- Q-line notices are back (except for ULined clients). +- Fixed /kill bug with services. + +Version Elite1.2.1 (01/29/99) +============================ +- Fixed multiple notices from +N / -N +- Added some text to s_err.c +- Possibly fixed the odd crashing... ? + +Version Elite1.2 (01/24/99) +============================ +- Netadmin can be used via +N in the oline slot now. +- When +N is executed, net-wide oper msg's are sent about it. +- Completely removed the freeze function (it's a toy unlike a command) +- Changed abit of the GLINE adding notice. +- Added logging to a file for glines (gline.log) +- Implemented SOCKS checking (thx Rhom). +- Changed channel lists only when 2 ppl in chan to 1. +- Changed sendto_ops function in many places in s_user.c/s_serv.c to + sendto_locfailops. +- Changed GNOTICE in s_user.c/s_serv.c to GLOBOPS +- Fixed hiddenhost bug with /kill (+w could see real host of oper) +- Fixed hiddenhost bug with /oper (+s could see real host of oper) + +[Special thanks goes out to Rhom for reporting/help patch bugs] + +Version Elite1.1.1 (12/12/98) +============================= +- Fixed /whois bug (had problems with mIRC clients *sigh*) +- Fixed /topic bug (didn't allow topic changes at all.) + +Version Elite1.1 (12/6/98) +============================ +- Fixed ./Config script (Net select) +- Fixed /remgline bug. +- If ULined clients, channels are not shown which they are in. +- Fixed +e / +t / +b (non-opers could get +et before) +- Fixed OperMode notice. +- Fixed Gline sending extra Global on expire. +- Fixed /whowas wrong hostname bug (by Thiago) +- Fixed chkconf ZLINE error (by matt) +- Added PhazeNet configuration +- Added option for auto +x in ./Config +- Freeze was disabled in this version (It will be back in 1.2) + +Version Elite1.0 (09/20/98) +============================ +- Changed Shadow3.9 to Elite1.0 (Starting a new IRCD) +- Changed some numeric's around in src/s_err.c +- Auto +x on Oper up. +- Fixed small error in ./ircd script. +- Made ./Config more Linux-redhat friendly. +- Added RelicNet to the ircd. +- include/config.h is much more compatible with all IRC nets. +- Added /gline (works 100%) [/gline ]. +- Fixed up /map. +- Added UMODE's +e & +t + * e: EYES [Can see ppl who /whois, and other notices.] + * t: ALL [See's all net notices ie: See's all Client connectings...] +- Fixed the hiddenhost bug with IP's... +- Fixed major bug with hiddenhost which caused coredump. +- Made a new script (makeconf) -- generates the ircd.conf file. diff --git a/include/badwords.h b/include/badwords.h new file mode 100644 index 000000000..df3d4374b --- /dev/null +++ b/include/badwords.h @@ -0,0 +1,20 @@ +#ifndef __BADWORDS_H +#define __BADWORDS_H + +#include +#include +#include +#include + +#define MAX_MATCH 1 +#define MAX_WORDLEN 64 +#define MAX_WORDS 30 + +#define PATTERN "\\w*%s\\w*" +#define REPLACEWORD "" + +char *stripbadwords(char *, int); +int loadbadwords(char *, int); +void freebadwords(void); + +#endif diff --git a/include/ircsprintf.h b/include/ircsprintf.h new file mode 100644 index 000000000..381c700ac --- /dev/null +++ b/include/ircsprintf.h @@ -0,0 +1,21 @@ +/* + * sprintf_irc.h + * + * $Id$ + */ + +#ifndef IRCSPRINTF_H +#define IRCSPRINTF_H +#include +#include + + +/* + * Proto types + */ + +extern char *ircvsprintf(char *str, const char *format, va_list); +extern char *ircsprintf(char *str, const char *format, ...); +extern const char atoi_tab[4000]; + +#endif diff --git a/networks/axenet.network b/networks/axenet.network new file mode 100644 index 000000000..5aa900e5c --- /dev/null +++ b/networks/axenet.network @@ -0,0 +1,56 @@ +ver^2.2 + +# These two specify the name of the IRC network, set the same in both fields +Network >..........: Axenet +Set ircnetwork ....: Axenet + +# This is where your DNS pool is (like irc.dal.net) +Set defserv .......: irc.axenet.org + +# This is the name of your Services Server +Set SERVICES_NAME .: services.axenet.org + +# This is the virtual hostname IRCops will get if iNAH option is enabled +# on oper up +Set oper_host .....: Oper.axenet.org + +# This is the virtual hostname Server Admins will get if iNAH option is enabled +# on oper up +Set admin_host ....: Admin.axenet.org + +# This is the virtual hostname Local IRCops will get if iNAH option is enabled +# on oper up + +Set locop_host ....: Locop.axenet.org + +# This is the virtual hostname Services Operators/Admins will get +# if iNAH option is enabled on oper up + +Set sadmin_host ...: Csop.axenet.org + +# This is the virtual hostname NetAdmins will get +# if iNAH option is enabled on oper up + +Set netadmin_host .: Netadmin.axenet.org + +# This is the virtual hostname CoAdmins will get +# if iNAH option is enabled on oper up +Set coadmin_host ..: Coadmin.axenet.org + + +# This is the virtual hostname TechAdmins will get +# if iNAH option is enabled on oper up +Set techadmin_host : Techadmin.axenet.org + +# This is the prefix of the hidden host (cloaking) hostname +Set hidden_host ...: axe +# This is the domain of the IRC network +Set netdomain .....: Axenet.org +# This is where people can go for help +Set helpchan ......: #Axenethelp +# This is the name of the stats server +Set STATS_SERVER ..: stats.axenet.org +# This enables the auto-setting of f.x @netadmin.network.net +# on oper up +Set iNAH ..........: 1 + diff --git a/networks/cc2.network b/networks/cc2.network new file mode 100644 index 000000000..16af09490 --- /dev/null +++ b/networks/cc2.network @@ -0,0 +1,71 @@ +ver^2.2 +# +# Network Configuration File Template +# ----------------------------------------- +# Added-at: GMT +# Author: () +# E-Mail: +# $Id$ +# ----------------------------------------- +# This is a template so you can create your own network configuration files +# Just follow the instructions and it will prolly work ;) +# 0 = No 1 = Yes +# ------------------------------------------------------- +# +# These two specify the name of the IRC network, set the same in both fields +Network >..........: CC2 +Set ircnetwork ....: CC2 + +# This is where your DNS pool is (like irc.dal.net) +Set defserv .......: irc.cc2.org + +# This is the name of your Services Server +Set SERVICES_NAME .: services.cc2.org + +# This is the virtual hostname IRCops will get if iNAH option is enabled +# on oper up +Set oper_host .....: ircop.cc2.org + +# This is the virtual hostname Server Admins will get if iNAH option is enabled +# on oper up +Set admin_host ....: admin.cc2.org + +# This is the virtual hostname Local IRCops will get if iNAH option is enabled +# on oper up + +Set locop_host ....: locop.cc2.org + +# This is the virtual hostname Services Operators/Admins will get +# if iNAH option is enabled on oper up + +Set sadmin_host ...: services.cc2.org + +# This is the virtual hostname NetAdmins will get +# if iNAH option is enabled on oper up + +Set netadmin_host .: netadmin.cc2.org + +# This is the virtual hostname CoAdmins will get +# if iNAH option is enabled on oper up +Set coadmin_host ..: coadmin.cc2.org + + +# This is the virtual hostname TechAdmins will get +# if iNAH option is enabled on oper up +Set techadmin_host : technician.cc2.org + +# This is the prefix of the hidden host (cloaking) hostname +Set hidden_host ...: user +# This is the domain of the IRC network +Set netdomain .....: cc2.org +# This is where people can go for help +Set helpchan ......: #help +# This is the name of the stats server +Set STATS_SERVER ..: stats.ircnet.org +# -- Not in use-- +Set HUB ...........: 1 +# This enables the auto-setting of f.x @netadmin.network.net +# on oper up +Set iNAH ..........: 1 +# -- Not in use but still here -- +Set net_quit ......: cc2 diff --git a/networks/chatplace.network b/networks/chatplace.network new file mode 100644 index 000000000..d6089cc9b --- /dev/null +++ b/networks/chatplace.network @@ -0,0 +1,30 @@ +ver^2.2 +# +# ChatPlace (irc.chatplace.net) Network Configuration File +# -------------------------------------------------- +# Added-at: 14 July 1999 00:00 GMT +# Author: Stskeeps (Carsten Munk) +# E-Mail: stskeeps@roxnet.org +# $Id$ +# ----------------------------------------- +# + +Network >..........: ChatPlace +Set ircnetwork ....: ChatPlace +Set defserv .......: irc.chatplace.net +Set SERVICES_NAME .: services.chatplace.net +Set oper_host .....: oper.chatplace.net +Set admin_host ....: admin.chatplace.net +Set locop_host ....: locop.chatplace.net +Set sadmin_host ...: csop.chatplace.net +Set netadmin_host .: netadmin.chatplace.net +Set coadmin_host ..: coadmin.chatplace.net +Set techadmin_host : techadmin.chatplace.net +Set hidden_host ...: cp +Set netdomain .....: chatplace.net +Set helpchan ......: #HelpDesk +Set STATS_SERVER ..: stats.chatplace.net +Set HUB ...........: 1 +Set iNAH ..........: 1 +Set net_quit ......: CP + diff --git a/networks/digital-irc.network b/networks/digital-irc.network new file mode 100644 index 000000000..2da5208ea --- /dev/null +++ b/networks/digital-irc.network @@ -0,0 +1,70 @@ +ver^2.2 +# +# Network Configuration File Template +# ----------------------------------------- +# Added-at: GMT +# Author: () +# E-Mail: +# $Id$ +# ----------------------------------------- +# This is a template so you can create your own network configuration files +# Just follow the instructions and it will prolly work ;) +# 0 = No 1 = Yes +# ------------------------------------------------------- +# +# These two specify the name of the IRC network, set the same in both fields +Network >..........: digital-irc.net +Set ircnetwork ....: digital-irc.net + +# This is where your DNS pool is (like irc.dal.net) +Set defserv .......: irc.digital-irc.net + +# This is the name of your Services Server +Set SERVICES_NAME .: services.digital-irc.net + +# This is the virtual hostname IRCops will get if iNAH option is enabled +# on oper up +Set oper_host .....: ircop.digital-irc.net + +# This is the virtual hostname Server Admins will get if iNAH option is enabled +# on oper up +Set admin_host ....: admin.digital-irc.net + +# This is the virtual hostname Local IRCops will get if iNAH option is enabled +# on oper up + +Set locop_host ....: locop.digital-irc.net + +# This is the virtual hostname Services Operators/Admins will get +# if iNAH option is enabled on oper up + +Set sadmin_host ...: serviceop.digital-irc.net + +# This is the virtual hostname NetAdmins will get +# if iNAH option is enabled on oper up + +Set netadmin_host .: netadmin.digital-irc.net + +# This is the virtual hostname CoAdmins will get +# if iNAH option is enabled on oper up +Set coadmin_host ..: coadmin.digital-irc.net + +# This is the virtual hostname TechAdmins will get +# if iNAH option is enabled on oper up +Set techadmin_host : techadmin.digital-irc.net + +# This is the prefix of the hidden host (cloaking) hostname +Set hidden_host ...: digital-irc +# This is the domain of the IRC network +Set netdomain .....: digital-irc.net +# This is where people can go for help +Set helpchan ......: #Digital-IRC +# This is the name of the stats server +Set STATS_SERVER ..: stats.digital-irc.net +# -- Not in use-- +Set HUB ...........: 1 +# This enables the auto-setting of f.x @netadmin.network.net +# on oper up +Set iNAH ..........: 0 +# -- Not in use but still here -- +Set net_quit ......: ic diff --git a/networks/interturk.network b/networks/interturk.network new file mode 100644 index 000000000..6c201dea4 --- /dev/null +++ b/networks/interturk.network @@ -0,0 +1,29 @@ +ver^2.2 +# +# ROXnet (irc.rox.za.net) Network Configuration File +# -------------------------------------------------- +# Added-at: 14 July 1999 00:00 GMT +# Author: Stskeeps (Carsten Munk) +# E-Mail: stskeeps@roxnet.org +# $Id$ +# ----------------------------------------- +# + +Network >..........: InterTurk +Set ircnetwork ....: InterTurk +Set defserv .......: irc.interturk.net +Set SERVICES_NAME .: services.egenet.com.tr +Set oper_host .....: ircop.interturk.net +Set admin_host ....: admin.interturk.net +Set locop_host ....: locop.interturk.net +Set sadmin_host ...: csops.interturk.net +Set netadmin_host .: netadmin.interturk.net +Set coadmin_host ..: coadmin.interturk.net +Set techadmin_host : techadmin.interturk.net +Set hidden_host ...: InterTurk +Set netdomain .....: interturk.net +Set helpchan ......: #Help +Set STATS_SERVER ..: stats.interturk.net +Set HUB ...........: 1 +Set iNAH ..........: 0 +Set net_quit ......: iN diff --git a/networks/ircthai.network b/networks/ircthai.network new file mode 100644 index 000000000..235cdb8f7 --- /dev/null +++ b/networks/ircthai.network @@ -0,0 +1,29 @@ +ver^2.2 +# +# Global-IRC.net Network Configuration File +# ----------------------------------------- +# Added-at: 14 July 1999 00:00 GMT +# Author: Stskeeps (Carsten Munk) +# E-Mail: stskeeps@global-irc.net +# $Id$ +# ----------------------------------------- +# + +Network >..........: IRCThai.com +Set ircnetwork ....: IRCThai.com +Set defserv .......: irc.ircthai.com +Set SERVICES_NAME .: services.ircthai.com +Set oper_host .....: IRCop.ircthai.com +Set admin_host ....: Admin.ircthai.com +Set locop_host ....: LOCop.ircthai.com +Set sadmin_host ...: ServiceAdmin.ircthai.com +Set netadmin_host .: NetAdmin.ircthai.com +Set coadmin_host ..: CoAdmin.ircthai.com +Set techadmin_host : TechAdmin.ircthai.com +Set hidden_host ...: IRCThai +Set netdomain .....: ircthai.com +Set helpchan ......: #ThaiHelp +Set STATS_SERVER ..: stats.ircthai.com +Set HUB ...........: 1 +Set iNAH ..........: 1 +Set net_quit ......: IT diff --git a/networks/kammtech.network b/networks/kammtech.network new file mode 100644 index 000000000..ce46c7c73 --- /dev/null +++ b/networks/kammtech.network @@ -0,0 +1,71 @@ +ver^2.2 +# +# Network Configuration File Template +# ----------------------------------------- +# Added-at: GMT +# Author: () +# E-Mail: +# $Id$ +# ----------------------------------------- +# This is a template so you can create your own network configuration files +# Just follow the instructions and it will prolly work ;) +# 0 = No 1 = Yes +# ------------------------------------------------------- +# +# These two specify the name of the IRC network, set the same in both fields +Network >..........: KammTecH +Set ircnetwork ....: KammTecH + +# This is where your DNS pool is (like irc.dal.net) +Set defserv .......: irc.kammtech.dhs.org + +# This is the name of your Services Server +Set SERVICES_NAME .: services.kammtech.dhs.org + +# This is the virtual hostname IRCops will get if iNAH option is enabled +# on oper up +Set oper_host .....: ircop.kammtech.dhs.org + +# This is the virtual hostname Server Admins will get if iNAH option is enabled +# on oper up +Set admin_host ....: admin.kammtech.dhs.org + +# This is the virtual hostname Local IRCops will get if iNAH option is enabled +# on oper up + +Set locop_host ....: locop.kammtech.dhs.org + +# This is the virtual hostname Services Operators/Admins will get +# if iNAH option is enabled on oper up + +Set sadmin_host ...: serviceop.kammtech.dhs.org + +# This is the virtual hostname NetAdmins will get +# if iNAH option is enabled on oper up + +Set netadmin_host .: netadmin.kammtech.dhs.org + +# This is the virtual hostname CoAdmins will get +# if iNAH option is enabled on oper up +Set coadmin_host ..: coadmin.kammtech.dhs.org + + +# This is the virtual hostname TechAdmins will get +# if iNAH option is enabled on oper up +Set techadmin_host : techadmin.kammtech.dhs.org + +# This is the prefix of the hidden host (cloaking) hostname +Set hidden_host ...: kammtech +# This is the domain of the IRC network +Set netdomain .....: kammtech.dhs.org +# This is where people can go for help +Set helpchan ......: #KammTecH +# This is the name of the stats server +Set STATS_SERVER ..: stats.kammtech.dhs.org +# -- Not in use-- +Set HUB ...........: 1 +# This enables the auto-setting of f.x @netadmin.network.net +# on oper up +Set iNAH ..........: 1 +# -- Not in use but still here -- +Set net_quit ......: KammTecH diff --git a/networks/kissland.network b/networks/kissland.network new file mode 100644 index 000000000..f98cb20f1 --- /dev/null +++ b/networks/kissland.network @@ -0,0 +1,29 @@ + +# +# KissLand IRC Network Configuration File +# ----------------------------------------- +# Author: Plague33 (Frank Laszlo) +# E-Mail: plague33@premis.lod.com +# +# ----------------------------------------- +# + + +Network >..........: Kissland +Set ircnetwork ....: Kissland +Set defserv .......: irc.Kissland.Com +Set SERVICES_NAME .: Services.Kissland.Com +Set oper_host .....: IRCop.Kissland.Com +Set admin_host ....: Admin.Kissland.Com +Set locop_host ....: Oper.Kissland.Com +Set sadmin_host ...: Services.Admin.Kissland.Com +Set netadmin_host .: Network.Admin.Kissland.Com +Set coadmin_host ..: Co.Admin.Kissland.Com +Set techadmin_host : Technical.Admin.Kissland.Com +Set hidden_host ...: Kiss +Set netdomain .....: Kissland.Com +Set helpchan ......: #Services +Set STATS_SERVER ..: Stats.Kissland.Com +Set HUB ...........: 1 +Set iNAH ..........: 1 +Set net_quit ......: KL diff --git a/networks/linuxactive.network b/networks/linuxactive.network new file mode 100644 index 000000000..3caeeba1a --- /dev/null +++ b/networks/linuxactive.network @@ -0,0 +1,20 @@ +ver^2.2 + +Network >..........: Linuxactive +Set ircnetwork ....: Linuxactive +Set defserv .......: irc.linuxactive.net +Set SERVICES_NAME .: services.linuxactive.net +Set oper_host .....: ircop.linuxactive.net +Set admin_host ....: admin.linuxactive.net +Set locop_host ....: locop.linuxactive.net +Set sadmin_host ...: csops.linuxactive.net +Set netadmin_host .: netadmin.linuxactive.net +Set coadmin_host ..: coadmin.linuxactive.net +Set techadmin_host : techadmin.linuxactive.net +Set hidden_host ...: LinuxActive +Set netdomain .....: linuxactive.net +Set helpchan ......: #Linux +Set STATS_SERVER ..: stats.linuxactive.net +Set HUB ...........: 1 +Set iNAH ..........: 0 +Set net_quit ......: TR diff --git a/networks/stormdancing.network b/networks/stormdancing.network new file mode 100644 index 000000000..be68c57e1 --- /dev/null +++ b/networks/stormdancing.network @@ -0,0 +1,71 @@ +ver2^2 +# +# Network Configuration File Template +# ----------------------------------------- +# Added-at: GMT +# Author: () +# E-Mail: +# $Id$ +# ----------------------------------------- +# This is a template so you can create your own network configuration files +# Just follow the instructions and it will prolly work ;) +# 0 = No 1 = Yes +# ------------------------------------------------------- +# +# These two specify the name of the IRC network, set the same in both fields +Network >..........: Stormdancing.Net +Set ircnetwork ....: Stormdancing.Net + +# This is where your DNS pool is (like irc.dal.net) +Set defserv .......: irc.stormdancing.net + +# This is the name of your Services Server +Set SERVICES_NAME .: Services.Stormdancing.Net + +# This is the virtual hostname IRCops will get if iNAH option is enabled +# on oper up +Set oper_host .....: IRCop.Stormdancing.Net + +# This is the virtual hostname Server Admins will get if iNAH option is enabled +# on oper up +Set admin_host ....: Admin.Stormdancing.Net + +# This is the virtual hostname Local IRCops will get if iNAH option is enabled +# on oper up + +Set locop_host ....: LocOp.Stormdancing.Net + +# This is the virtual hostname Services Operators/Admins will get +# if iNAH option is enabled on oper up + +Set sadmin_host ...: ServiceOp.Stormdancing.Net + +# This is the virtual hostname NetAdmins will get +# if iNAH option is enabled on oper up + +Set netadmin_host .: NetAdmin.Stormdancing.Net + +# This is the virtual hostname CoAdmins will get +# if iNAH option is enabled on oper up +Set coadmin_host ..: CoAdmin.Stormdancing.Net + + +# This is the virtual hostname TechAdmins will get +# if iNAH option is enabled on oper up +Set techadmin_host : TechAdmin.Stormdancing.Net + +# This is the prefix of the hidden host (cloaking) hostname +Set hidden_host ...: Stormdancing +# This is the domain of the IRC network +Set netdomain .....: Stormdancing.Net +# This is where people can go for help +Set helpchan ......: #Help +# This is the name of the stats server +Set STATS_SERVER ..: stats.ircnet.org +# -- Not in use-- +Set HUB ...........: 1 +# This enables the auto-setting of f.x @netadmin.network.net +# on oper up +Set iNAH ..........: 1 +# -- Not in use but still here -- +Set net_quit ......: SD diff --git a/networks/treklink.network b/networks/treklink.network new file mode 100644 index 000000000..1a60fceeb --- /dev/null +++ b/networks/treklink.network @@ -0,0 +1,29 @@ +ver^2.2 +# +# DragonWings.org Network Configuration File +# ----------------------------------------- +# Added-at: 14 July 1999 00:00 GMT +# Author: Stskeeps (Carsten Munk) +# E-Mail: stskeeps@global-irc.net +# $Id$ +# ----------------------------------------- +# + +Network >..........: Treklink +Set ircnetwork ....: Treklink +Set defserv .......: irc.treklink.net +Set SERVICES_NAME .: services.uip.org +Set oper_host .....: ircop.treklink.net +Set admin_host ....: admin.treklink.net +Set locop_host ....: locop.treklink.net +Set sadmin_host ...: serviceop.treklink.net +Set netadmin_host .: netadmin.treklink.net +Set coadmin_host ..: coadmin.treklink.net +Set techadmin_host : techadmin.treklink.net +Set hidden_host ...: TL +Set netdomain .....: treklink.net +Set helpchan ......: #uip +Set STATS_SERVER ..: stats.treklink.net +Set HUB ...........: 1 +Set iNAH ..........: 1 +Set net_quit ......: TL diff --git a/networks/unreal-test.network b/networks/unreal-test.network new file mode 100644 index 000000000..dc5ec44cf --- /dev/null +++ b/networks/unreal-test.network @@ -0,0 +1,29 @@ +ver^2.2 +# +# Unreal-Team () Network Configuration File +# -------------------------------------------------- +# Added-at: 14 July 1999 00:00 GMT +# Author: Stskeeps (Carsten Munk) +# E-Mail: stskeeps@tspre.org +# $Id$ +# ----------------------------------------- +# + +Network >..........: TESTnet +Set ircnetwork ....: TESTnet +Set defserv .......: irc.testnet.ircsystems.net +Set SERVICES_NAME .: services.testnet.ircsystems.net +Set oper_host .....: ircop.testnet.ircsystems.net +Set admin_host ....: admin.testnet.ircsystems.net +Set locop_host ....: locop.testnet.ircsystems.net +Set sadmin_host ...: csops.testnet.ircsystems.net +Set netadmin_host .: netadmin.testnet.ircsystems.net +Set coadmin_host ..: coadmin.testnet.ircsystems.net +Set techadmin_host : techadmin.testnet.ircsystems.net +Set hidden_host ...: unreal +Set netdomain .....: testnet.ircsystems.net +Set helpchan ......: #testnet +Set STATS_SERVER ..: stats.testnet.ircsystems.net +Set HUB ...........: 1 +Set iNAH ..........: 0 +Set net_quit ......: test diff --git a/src/agent.c b/src/agent.c new file mode 100644 index 000000000..184d7caf8 --- /dev/null +++ b/src/agent.c @@ -0,0 +1,45 @@ +/************************************************************************ + * Unreal Internet Relay Chat Daemon, src/agent.c + * (C) 1999 Carsten Munk (Techie/Stskeeps) + * + * 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 "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include "userload.h" +#include "version.h" +#include +#include +#include +#include +#include +#ifndef _WIN32 +#include +#else +#include +#endif +#include +#include "h.h" + +ID_CVS("$Id$"); +ID_Copyright("(C) Carsten Munk 1999"); diff --git a/src/aln.c b/src/aln.c new file mode 100644 index 000000000..8dee2e0af --- /dev/null +++ b/src/aln.c @@ -0,0 +1,159 @@ +/************************************************************************ + * IRC - Internet Relay Chat, aln.c + * (C) 2000 Carsten Munk (Techie/Stskeeps) + * + * 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. + */ + +#ifndef STANDALONE +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include "userload.h" +#include "version.h" +#endif + +#include +#include +#include +#include +#include +#ifndef _WIN32 +#include +#else +#include +#endif +#include +#ifndef STANDALONE +#include "h.h" + +ID_CVS("$Id$"); +ID_Copyright("(C) Carsten Munk 2000"); +#endif + +static char *aln_chars[] = { + /* 0-9 */ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + /* 10-19 */ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", + /* 20-29 */ "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", + /* 30-35 */ "U", "V", "W", "X", "Y", "Z", + /* 36-45 */ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", + /* 46-55 */ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", + /* 56-61 */ "u", "v", "w", "x", "y", "z", + /* 62-71 */ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", + /* 73-82 */ "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", + /* 83-92 */ "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", + /* 93-98 */ "AU", "AV", "AW", "AX", "AY", "AZ", + /* 99-108 */ "Aa", "Ab", "Ac", "Ad", "Ae", "Af", "Ag", "Ah", "Ai", "Aj", + /* 109-118 */ "Ak", "Al", "Am", "An", "Ao", "Ap", "Aq", "Ar", "As", + "At", + /* 119-124 */ "Au", "Av", "Aw", "Ax", "Ay", "Az", + /* 125-134 */ "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", + "B9", + /* 135-144 */ "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", + "BJ", + /* 145-154 */ "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", + "BT", + /* 155-160 */ "BU", "BV", "BW", "BX", "BY", "BZ", + /* 161-170 */ "Ba", "Bb", "Bc", "Bd", "Be", "Bf", "Bg", "Bh", "Bi", + "Bj", + /* 171-180 */ "Bk", "Bl", "Bm", "Bn", "Bo", "Bp", "Bq", "Br", "Bs", + "Bt", + /* 181-186 */ "Bu", "Bv", "Bw", "Bx", "By", "Bz", + /* 187-196 */ "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", + "C9", + /* 196-205 */ "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", + "CJ", + /* 206-215 */ "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "CR", "CS", + "CT", + /* 216-227 */ "CU", "CV", "CW", "CX", "CY", "CZ", + /* 228-237 */ "Ca", "Cb", "Cc", "Cd", "Ce", "Cf", "Cg", "Ch", "Ci", + "Cj", + /* 238-247 */ "Ck", "Cl", "Cm", "Cn", "Co", "Cp", "Cq", "Cr", "Cs", + "Ct", + /* 248-253 */ "Cu", "Cv", "Cw", "Cx", "Cy", "Cz", + /* 254-257 */ "D0", "D1", "D2", "D3", "D4", "D5", "D6", + /* */ "D7", "D8", "D9", "DA", "DB", "DC", "DD", + /* EOT */ NULL +}; + +int a_row = 62; +int b_row = 124; +int c_row = 186; +int d_row = 248; + +char *convert2aln(int i) +{ + return (aln_chars[i]); +} + +int convertfromaln(char *s) +{ + int i; + if (strlen(s) == 1) + { + for (i = 0; i < a_row; i++) + if (!strcmp(s, aln_chars[i])) + return (i); + /* no matches? we return 0 */ + return 0; + } + else + { + switch (*s) + { + case 'A': + i = a_row; + break; + case 'B': + i = b_row; + break; + case 'C': + i = c_row; + break; + case 'D': + i = d_row; + break; + default: + i = 0; + } + for (; i < 257; i++) + if (!strcmp(s, aln_chars[i])) + return (i); + + /* no matches? we return 0 */ + return 0; + } +} + +#ifdef STANDALONE +main() +{ + int i; + + for (i = 0; i <= 100; i++) + printf("(%i = %s)\n", i, aln_chars[i]); + + printf("62 = %s\n", convert2aln(62)); + printf("256 = %s\n", convert2aln(256)); + printf("C0 = %i\n", convertfromaln("C0")); + printf("D = %i\n", convertfromaln("D")); +} +#endif diff --git a/src/badwords.c b/src/badwords.c new file mode 100644 index 000000000..7b4027a5b --- /dev/null +++ b/src/badwords.c @@ -0,0 +1,262 @@ +/* + * IRC - Internet Relay Chat, badwords.c + * Copyleft (C) 2000 meow + * + * Provides functions, for loading and filtering unwanted words out of + * a string, or in this case part of a message. Please note that this + * is flawed because when mode_strip is set, mode_stripbadwords is not + * active. This is due to the structure of m_message(), and therefore + * will not change until I (or someone else) revamps the code. + * + * You can redistribute and/or modify this under the terms of the GNU + * General Public License as published by the Free Software Foundation. + * + * Disclaimer: You have no rights. Use at your own risk. Don't drink + * too much pepsi. + */ + +#include +#include "config.h" +#ifdef STRIPBADWORDS +#include "badwords.h" + +static char *channelword[MAX_WORDS]; +static char *messageword[MAX_WORDS]; +static int channel_wordlist; +static int message_wordlist; + +/* + * Returns a string, which has been filtered by the words loaded via + * the loadbadwords() function. It's primary use is to filter swearing + * in both private and public messages + */ + +char *stripbadwords_channel(char *str) +{ + regmatch_t pmatch[MAX_MATCH]; + regex_t pcomp; + static char cleanstr[4096]; + char buf[4096]; + char errbuf[2048]; + char *ptr; + int errorcode, matchlen, stringlen, this_word; + + if (!channel_wordlist) + return str; + strncpy(cleanstr, str, sizeof(cleanstr) - 1); /* Let's work on a backup */ + memset(&pmatch, 0, sizeof(pmatch)); + stringlen = strlen(cleanstr); + matchlen = 0; + buf[0] = '\0'; + + for (this_word = 0; channelword[this_word] != NULL; this_word++) + { + if ((errorcode = + regcomp(&pcomp, channelword[this_word], REG_ICASE)) > 0) + { + regfree(&pcomp); + return cleanstr; + } + + ptr = cleanstr; /* Set pointer to start of string */ + while (regexec(&pcomp, ptr, MAX_MATCH, pmatch, + 0) != REG_NOMATCH) + { + if (pmatch[0].rm_so == -1) + break; + matchlen += pmatch[0].rm_eo - pmatch[0].rm_so; + strncat(buf, ptr, pmatch[0].rm_so); + strcat(buf, REPLACEWORD); /* Who's afraid of the big bad buffer overflow? */ + ptr += pmatch[0].rm_eo; /* Set pointer after the match pos */ + memset(&pmatch, 0, sizeof(pmatch)); + } + strcat(buf, ptr); /* All the better to eat you with! */ + strncpy(cleanstr, buf, sizeof(cleanstr)); + memset(buf, 0, sizeof(buf)); + regfree(&pcomp); + if (matchlen == stringlen) + break; + } + + return (cleanstr); +} + +char *stripbadwords_message(char *str) +{ + regmatch_t pmatch[MAX_MATCH]; + regex_t pcomp; + static char cleanstr[4096]; + char buf[4096]; + char errbuf[2048]; + char *ptr; + int errorcode, matchlen, stringlen, this_word; + + if (!message_wordlist) + return str; + strncpy(cleanstr, str, sizeof(cleanstr) - 1); /* Let's work on a backup */ + memset(&pmatch, 0, sizeof(pmatch)); + stringlen = strlen(cleanstr); + matchlen = 0; + buf[0] = '\0'; + + for (this_word = 0; messageword[this_word] != NULL; this_word++) + { + if ((errorcode = + regcomp(&pcomp, messageword[this_word], REG_ICASE)) > 0) + { + regfree(&pcomp); + return cleanstr; + } + + ptr = cleanstr; /* Set pointer to start of string */ + while (regexec(&pcomp, ptr, MAX_MATCH, pmatch, + 0) != REG_NOMATCH) + { + if (pmatch[0].rm_so == -1) + break; + matchlen += pmatch[0].rm_eo - pmatch[0].rm_so; + strncat(buf, ptr, pmatch[0].rm_so); + strcat(buf, REPLACEWORD); /* Who's afraid of the big bad buffer overflow? */ + ptr += pmatch[0].rm_eo; /* Set pointer after the match pos */ + memset(&pmatch, 0, sizeof(pmatch)); + } + strcat(buf, ptr); /* All the better to eat you with! */ + strncpy(cleanstr, buf, sizeof(cleanstr)); + memset(buf, 0, sizeof(buf)); + regfree(&pcomp); + if (matchlen == stringlen) + break; + } + + return (cleanstr); +} + +/* + * Loads bad words from a file, into a char array. This puts a limitation on + * how many words may be slurped (which is probably a good thing). The words + * are then called by stripbadwords, to filter unwanted (swear) words. + */ +int loadbadwords_channel(char *wordfile) +{ + FILE *fin; + char buf[MAX_WORDLEN]; + char *ptr; + int i, j, isregex; + + channel_wordlist = 0; + memset(channelword, 0, sizeof(messageword)); + + if ((fin = fopen(wordfile, "r")) == NULL) + return 0; + + for (i = 0; i < MAX_WORDS; i++) + { + if (fgets(buf, MAX_WORDLEN, fin) == NULL) + break; + if ((ptr = strchr(buf, '\r')) != NULL + || (ptr = strchr(buf, '\n')) != NULL) + *ptr = '\0'; + if (buf[0] == '\0') + continue; + + for (j = 0, isregex = 0; j < strlen(buf); j++) + { + if ((int)buf[j] < 65 || (int)buf[j] > 123) + { + isregex++; /* Probably is */ + break; + } + } + + if (isregex) + { + /* We don't have to apply a pattern to the word because + * it already *is* a pattern. + */ + channelword[i] = (char *)MyMalloc(strlen(buf) + 1); + strncpy(channelword[i], buf, strlen(buf) + 1); + } + else + { + /* PATTERN contains the %s format specifier so we must + * remove 2 chars, and 1 for the \0, which gives us -1 + */ + channelword[i] = + (char *)MyMalloc(strlen(buf) + strlen(PATTERN) - 1); + sprintf(channelword[i], PATTERN, buf); + } + channel_wordlist++; + } + fclose(fin); + + return i; +} + +int loadbadwords_message(char *wordfile) +{ + FILE *fin; + char buf[MAX_WORDLEN]; + char *ptr; + int i, j, isregex; + + message_wordlist = 0; + memset(messageword, 0, sizeof(messageword)); + + if ((fin = fopen(wordfile, "r")) == NULL) + return 0; + + for (i = 0; i < MAX_WORDS; i++) + { + if (fgets(buf, MAX_WORDLEN, fin) == NULL) + break; + if ((ptr = strchr(buf, '\r')) != NULL + || (ptr = strchr(buf, '\n')) != NULL) + *ptr = '\0'; + if (buf[0] == '\0') + continue; + + for (j = 0, isregex = 0; j < strlen(buf); j++) + { + if ((int)buf[j] < 65 || (int)buf[j] > 123) + { + isregex++; /* Probably is */ + break; + } + } + + if (isregex) + { + /* We don't have to apply a pattern to the word because + * it already *is* a pattern. + */ + messageword[i] = (char *)MyMalloc(strlen(buf) + 1); + strncpy(messageword[i], buf, strlen(buf) + 1); + } + else + { + /* PATTERN contains the %s format specifier so we must + * remove 2 chars, and 1 for the \0, which gives us -1 + */ + messageword[i] = + (char *)MyMalloc(strlen(buf) + strlen(PATTERN) - 1); + sprintf(messageword[i], PATTERN, buf); + } + message_wordlist++; + } + fclose(fin); + + return i; +} + + +void freebadwords(void) +{ + int i; + + for (i = 0; channelword[i] != NULL && i < MAX_WORDS; i++) + free(channelword[i]); + for (i = 0; messageword[i] != NULL && i < MAX_WORDS; i++) + free(messageword[i]); + return; +} +#endif diff --git a/src/ircsprintf.c b/src/ircsprintf.c new file mode 100644 index 000000000..e560f4fa4 --- /dev/null +++ b/src/ircsprintf.c @@ -0,0 +1,451 @@ +/* + * Unreal Internet Relay Chat Daemon, src/ircsprintf.c + * + * (C) Copyright 1997 + * + * Author: + * + * 1024/624ACAD5 1997/01/26 Carlo Wood, Run on IRC + * Key fingerprint = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 + * Get key from pgp-public-keys server or + * finger carlo@runaway.xs4all.nl for public key (dialin, try at 21-22h GMT). + * + * 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, 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. + * + * $Id$ + */ +#include "ircsprintf.h" +#include + + +/* *INDENT-OFF* */ + +const char atoi_tab[4000] = { + '0','0','0',0, '0','0','1',0, '0','0','2',0, '0','0','3',0, '0','0','4',0, + '0','0','5',0, '0','0','6',0, '0','0','7',0, '0','0','8',0, '0','0','9',0, + '0','1','0',0, '0','1','1',0, '0','1','2',0, '0','1','3',0, '0','1','4',0, + '0','1','5',0, '0','1','6',0, '0','1','7',0, '0','1','8',0, '0','1','9',0, + '0','2','0',0, '0','2','1',0, '0','2','2',0, '0','2','3',0, '0','2','4',0, + '0','2','5',0, '0','2','6',0, '0','2','7',0, '0','2','8',0, '0','2','9',0, + '0','3','0',0, '0','3','1',0, '0','3','2',0, '0','3','3',0, '0','3','4',0, + '0','3','5',0, '0','3','6',0, '0','3','7',0, '0','3','8',0, '0','3','9',0, + '0','4','0',0, '0','4','1',0, '0','4','2',0, '0','4','3',0, '0','4','4',0, + '0','4','5',0, '0','4','6',0, '0','4','7',0, '0','4','8',0, '0','4','9',0, + '0','5','0',0, '0','5','1',0, '0','5','2',0, '0','5','3',0, '0','5','4',0, + '0','5','5',0, '0','5','6',0, '0','5','7',0, '0','5','8',0, '0','5','9',0, + '0','6','0',0, '0','6','1',0, '0','6','2',0, '0','6','3',0, '0','6','4',0, + '0','6','5',0, '0','6','6',0, '0','6','7',0, '0','6','8',0, '0','6','9',0, + '0','7','0',0, '0','7','1',0, '0','7','2',0, '0','7','3',0, '0','7','4',0, + '0','7','5',0, '0','7','6',0, '0','7','7',0, '0','7','8',0, '0','7','9',0, + '0','8','0',0, '0','8','1',0, '0','8','2',0, '0','8','3',0, '0','8','4',0, + '0','8','5',0, '0','8','6',0, '0','8','7',0, '0','8','8',0, '0','8','9',0, + '0','9','0',0, '0','9','1',0, '0','9','2',0, '0','9','3',0, '0','9','4',0, + '0','9','5',0, '0','9','6',0, '0','9','7',0, '0','9','8',0, '0','9','9',0, + '1','0','0',0, '1','0','1',0, '1','0','2',0, '1','0','3',0, '1','0','4',0, + '1','0','5',0, '1','0','6',0, '1','0','7',0, '1','0','8',0, '1','0','9',0, + '1','1','0',0, '1','1','1',0, '1','1','2',0, '1','1','3',0, '1','1','4',0, + '1','1','5',0, '1','1','6',0, '1','1','7',0, '1','1','8',0, '1','1','9',0, + '1','2','0',0, '1','2','1',0, '1','2','2',0, '1','2','3',0, '1','2','4',0, + '1','2','5',0, '1','2','6',0, '1','2','7',0, '1','2','8',0, '1','2','9',0, + '1','3','0',0, '1','3','1',0, '1','3','2',0, '1','3','3',0, '1','3','4',0, + '1','3','5',0, '1','3','6',0, '1','3','7',0, '1','3','8',0, '1','3','9',0, + '1','4','0',0, '1','4','1',0, '1','4','2',0, '1','4','3',0, '1','4','4',0, + '1','4','5',0, '1','4','6',0, '1','4','7',0, '1','4','8',0, '1','4','9',0, + '1','5','0',0, '1','5','1',0, '1','5','2',0, '1','5','3',0, '1','5','4',0, + '1','5','5',0, '1','5','6',0, '1','5','7',0, '1','5','8',0, '1','5','9',0, + '1','6','0',0, '1','6','1',0, '1','6','2',0, '1','6','3',0, '1','6','4',0, + '1','6','5',0, '1','6','6',0, '1','6','7',0, '1','6','8',0, '1','6','9',0, + '1','7','0',0, '1','7','1',0, '1','7','2',0, '1','7','3',0, '1','7','4',0, + '1','7','5',0, '1','7','6',0, '1','7','7',0, '1','7','8',0, '1','7','9',0, + '1','8','0',0, '1','8','1',0, '1','8','2',0, '1','8','3',0, '1','8','4',0, + '1','8','5',0, '1','8','6',0, '1','8','7',0, '1','8','8',0, '1','8','9',0, + '1','9','0',0, '1','9','1',0, '1','9','2',0, '1','9','3',0, '1','9','4',0, + '1','9','5',0, '1','9','6',0, '1','9','7',0, '1','9','8',0, '1','9','9',0, + '2','0','0',0, '2','0','1',0, '2','0','2',0, '2','0','3',0, '2','0','4',0, + '2','0','5',0, '2','0','6',0, '2','0','7',0, '2','0','8',0, '2','0','9',0, + '2','1','0',0, '2','1','1',0, '2','1','2',0, '2','1','3',0, '2','1','4',0, + '2','1','5',0, '2','1','6',0, '2','1','7',0, '2','1','8',0, '2','1','9',0, + '2','2','0',0, '2','2','1',0, '2','2','2',0, '2','2','3',0, '2','2','4',0, + '2','2','5',0, '2','2','6',0, '2','2','7',0, '2','2','8',0, '2','2','9',0, + '2','3','0',0, '2','3','1',0, '2','3','2',0, '2','3','3',0, '2','3','4',0, + '2','3','5',0, '2','3','6',0, '2','3','7',0, '2','3','8',0, '2','3','9',0, + '2','4','0',0, '2','4','1',0, '2','4','2',0, '2','4','3',0, '2','4','4',0, + '2','4','5',0, '2','4','6',0, '2','4','7',0, '2','4','8',0, '2','4','9',0, + '2','5','0',0, '2','5','1',0, '2','5','2',0, '2','5','3',0, '2','5','4',0, + '2','5','5',0, '2','5','6',0, '2','5','7',0, '2','5','8',0, '2','5','9',0, + '2','6','0',0, '2','6','1',0, '2','6','2',0, '2','6','3',0, '2','6','4',0, + '2','6','5',0, '2','6','6',0, '2','6','7',0, '2','6','8',0, '2','6','9',0, + '2','7','0',0, '2','7','1',0, '2','7','2',0, '2','7','3',0, '2','7','4',0, + '2','7','5',0, '2','7','6',0, '2','7','7',0, '2','7','8',0, '2','7','9',0, + '2','8','0',0, '2','8','1',0, '2','8','2',0, '2','8','3',0, '2','8','4',0, + '2','8','5',0, '2','8','6',0, '2','8','7',0, '2','8','8',0, '2','8','9',0, + '2','9','0',0, '2','9','1',0, '2','9','2',0, '2','9','3',0, '2','9','4',0, + '2','9','5',0, '2','9','6',0, '2','9','7',0, '2','9','8',0, '2','9','9',0, + '3','0','0',0, '3','0','1',0, '3','0','2',0, '3','0','3',0, '3','0','4',0, + '3','0','5',0, '3','0','6',0, '3','0','7',0, '3','0','8',0, '3','0','9',0, + '3','1','0',0, '3','1','1',0, '3','1','2',0, '3','1','3',0, '3','1','4',0, + '3','1','5',0, '3','1','6',0, '3','1','7',0, '3','1','8',0, '3','1','9',0, + '3','2','0',0, '3','2','1',0, '3','2','2',0, '3','2','3',0, '3','2','4',0, + '3','2','5',0, '3','2','6',0, '3','2','7',0, '3','2','8',0, '3','2','9',0, + '3','3','0',0, '3','3','1',0, '3','3','2',0, '3','3','3',0, '3','3','4',0, + '3','3','5',0, '3','3','6',0, '3','3','7',0, '3','3','8',0, '3','3','9',0, + '3','4','0',0, '3','4','1',0, '3','4','2',0, '3','4','3',0, '3','4','4',0, + '3','4','5',0, '3','4','6',0, '3','4','7',0, '3','4','8',0, '3','4','9',0, + '3','5','0',0, '3','5','1',0, '3','5','2',0, '3','5','3',0, '3','5','4',0, + '3','5','5',0, '3','5','6',0, '3','5','7',0, '3','5','8',0, '3','5','9',0, + '3','6','0',0, '3','6','1',0, '3','6','2',0, '3','6','3',0, '3','6','4',0, + '3','6','5',0, '3','6','6',0, '3','6','7',0, '3','6','8',0, '3','6','9',0, + '3','7','0',0, '3','7','1',0, '3','7','2',0, '3','7','3',0, '3','7','4',0, + '3','7','5',0, '3','7','6',0, '3','7','7',0, '3','7','8',0, '3','7','9',0, + '3','8','0',0, '3','8','1',0, '3','8','2',0, '3','8','3',0, '3','8','4',0, + '3','8','5',0, '3','8','6',0, '3','8','7',0, '3','8','8',0, '3','8','9',0, + '3','9','0',0, '3','9','1',0, '3','9','2',0, '3','9','3',0, '3','9','4',0, + '3','9','5',0, '3','9','6',0, '3','9','7',0, '3','9','8',0, '3','9','9',0, + '4','0','0',0, '4','0','1',0, '4','0','2',0, '4','0','3',0, '4','0','4',0, + '4','0','5',0, '4','0','6',0, '4','0','7',0, '4','0','8',0, '4','0','9',0, + '4','1','0',0, '4','1','1',0, '4','1','2',0, '4','1','3',0, '4','1','4',0, + '4','1','5',0, '4','1','6',0, '4','1','7',0, '4','1','8',0, '4','1','9',0, + '4','2','0',0, '4','2','1',0, '4','2','2',0, '4','2','3',0, '4','2','4',0, + '4','2','5',0, '4','2','6',0, '4','2','7',0, '4','2','8',0, '4','2','9',0, + '4','3','0',0, '4','3','1',0, '4','3','2',0, '4','3','3',0, '4','3','4',0, + '4','3','5',0, '4','3','6',0, '4','3','7',0, '4','3','8',0, '4','3','9',0, + '4','4','0',0, '4','4','1',0, '4','4','2',0, '4','4','3',0, '4','4','4',0, + '4','4','5',0, '4','4','6',0, '4','4','7',0, '4','4','8',0, '4','4','9',0, + '4','5','0',0, '4','5','1',0, '4','5','2',0, '4','5','3',0, '4','5','4',0, + '4','5','5',0, '4','5','6',0, '4','5','7',0, '4','5','8',0, '4','5','9',0, + '4','6','0',0, '4','6','1',0, '4','6','2',0, '4','6','3',0, '4','6','4',0, + '4','6','5',0, '4','6','6',0, '4','6','7',0, '4','6','8',0, '4','6','9',0, + '4','7','0',0, '4','7','1',0, '4','7','2',0, '4','7','3',0, '4','7','4',0, + '4','7','5',0, '4','7','6',0, '4','7','7',0, '4','7','8',0, '4','7','9',0, + '4','8','0',0, '4','8','1',0, '4','8','2',0, '4','8','3',0, '4','8','4',0, + '4','8','5',0, '4','8','6',0, '4','8','7',0, '4','8','8',0, '4','8','9',0, + '4','9','0',0, '4','9','1',0, '4','9','2',0, '4','9','3',0, '4','9','4',0, + '4','9','5',0, '4','9','6',0, '4','9','7',0, '4','9','8',0, '4','9','9',0, + '5','0','0',0, '5','0','1',0, '5','0','2',0, '5','0','3',0, '5','0','4',0, + '5','0','5',0, '5','0','6',0, '5','0','7',0, '5','0','8',0, '5','0','9',0, + '5','1','0',0, '5','1','1',0, '5','1','2',0, '5','1','3',0, '5','1','4',0, + '5','1','5',0, '5','1','6',0, '5','1','7',0, '5','1','8',0, '5','1','9',0, + '5','2','0',0, '5','2','1',0, '5','2','2',0, '5','2','3',0, '5','2','4',0, + '5','2','5',0, '5','2','6',0, '5','2','7',0, '5','2','8',0, '5','2','9',0, + '5','3','0',0, '5','3','1',0, '5','3','2',0, '5','3','3',0, '5','3','4',0, + '5','3','5',0, '5','3','6',0, '5','3','7',0, '5','3','8',0, '5','3','9',0, + '5','4','0',0, '5','4','1',0, '5','4','2',0, '5','4','3',0, '5','4','4',0, + '5','4','5',0, '5','4','6',0, '5','4','7',0, '5','4','8',0, '5','4','9',0, + '5','5','0',0, '5','5','1',0, '5','5','2',0, '5','5','3',0, '5','5','4',0, + '5','5','5',0, '5','5','6',0, '5','5','7',0, '5','5','8',0, '5','5','9',0, + '5','6','0',0, '5','6','1',0, '5','6','2',0, '5','6','3',0, '5','6','4',0, + '5','6','5',0, '5','6','6',0, '5','6','7',0, '5','6','8',0, '5','6','9',0, + '5','7','0',0, '5','7','1',0, '5','7','2',0, '5','7','3',0, '5','7','4',0, + '5','7','5',0, '5','7','6',0, '5','7','7',0, '5','7','8',0, '5','7','9',0, + '5','8','0',0, '5','8','1',0, '5','8','2',0, '5','8','3',0, '5','8','4',0, + '5','8','5',0, '5','8','6',0, '5','8','7',0, '5','8','8',0, '5','8','9',0, + '5','9','0',0, '5','9','1',0, '5','9','2',0, '5','9','3',0, '5','9','4',0, + '5','9','5',0, '5','9','6',0, '5','9','7',0, '5','9','8',0, '5','9','9',0, + '6','0','0',0, '6','0','1',0, '6','0','2',0, '6','0','3',0, '6','0','4',0, + '6','0','5',0, '6','0','6',0, '6','0','7',0, '6','0','8',0, '6','0','9',0, + '6','1','0',0, '6','1','1',0, '6','1','2',0, '6','1','3',0, '6','1','4',0, + '6','1','5',0, '6','1','6',0, '6','1','7',0, '6','1','8',0, '6','1','9',0, + '6','2','0',0, '6','2','1',0, '6','2','2',0, '6','2','3',0, '6','2','4',0, + '6','2','5',0, '6','2','6',0, '6','2','7',0, '6','2','8',0, '6','2','9',0, + '6','3','0',0, '6','3','1',0, '6','3','2',0, '6','3','3',0, '6','3','4',0, + '6','3','5',0, '6','3','6',0, '6','3','7',0, '6','3','8',0, '6','3','9',0, + '6','4','0',0, '6','4','1',0, '6','4','2',0, '6','4','3',0, '6','4','4',0, + '6','4','5',0, '6','4','6',0, '6','4','7',0, '6','4','8',0, '6','4','9',0, + '6','5','0',0, '6','5','1',0, '6','5','2',0, '6','5','3',0, '6','5','4',0, + '6','5','5',0, '6','5','6',0, '6','5','7',0, '6','5','8',0, '6','5','9',0, + '6','6','0',0, '6','6','1',0, '6','6','2',0, '6','6','3',0, '6','6','4',0, + '6','6','5',0, '6','6','6',0, '6','6','7',0, '6','6','8',0, '6','6','9',0, + '6','7','0',0, '6','7','1',0, '6','7','2',0, '6','7','3',0, '6','7','4',0, + '6','7','5',0, '6','7','6',0, '6','7','7',0, '6','7','8',0, '6','7','9',0, + '6','8','0',0, '6','8','1',0, '6','8','2',0, '6','8','3',0, '6','8','4',0, + '6','8','5',0, '6','8','6',0, '6','8','7',0, '6','8','8',0, '6','8','9',0, + '6','9','0',0, '6','9','1',0, '6','9','2',0, '6','9','3',0, '6','9','4',0, + '6','9','5',0, '6','9','6',0, '6','9','7',0, '6','9','8',0, '6','9','9',0, + '7','0','0',0, '7','0','1',0, '7','0','2',0, '7','0','3',0, '7','0','4',0, + '7','0','5',0, '7','0','6',0, '7','0','7',0, '7','0','8',0, '7','0','9',0, + '7','1','0',0, '7','1','1',0, '7','1','2',0, '7','1','3',0, '7','1','4',0, + '7','1','5',0, '7','1','6',0, '7','1','7',0, '7','1','8',0, '7','1','9',0, + '7','2','0',0, '7','2','1',0, '7','2','2',0, '7','2','3',0, '7','2','4',0, + '7','2','5',0, '7','2','6',0, '7','2','7',0, '7','2','8',0, '7','2','9',0, + '7','3','0',0, '7','3','1',0, '7','3','2',0, '7','3','3',0, '7','3','4',0, + '7','3','5',0, '7','3','6',0, '7','3','7',0, '7','3','8',0, '7','3','9',0, + '7','4','0',0, '7','4','1',0, '7','4','2',0, '7','4','3',0, '7','4','4',0, + '7','4','5',0, '7','4','6',0, '7','4','7',0, '7','4','8',0, '7','4','9',0, + '7','5','0',0, '7','5','1',0, '7','5','2',0, '7','5','3',0, '7','5','4',0, + '7','5','5',0, '7','5','6',0, '7','5','7',0, '7','5','8',0, '7','5','9',0, + '7','6','0',0, '7','6','1',0, '7','6','2',0, '7','6','3',0, '7','6','4',0, + '7','6','5',0, '7','6','6',0, '7','6','7',0, '7','6','8',0, '7','6','9',0, + '7','7','0',0, '7','7','1',0, '7','7','2',0, '7','7','3',0, '7','7','4',0, + '7','7','5',0, '7','7','6',0, '7','7','7',0, '7','7','8',0, '7','7','9',0, + '7','8','0',0, '7','8','1',0, '7','8','2',0, '7','8','3',0, '7','8','4',0, + '7','8','5',0, '7','8','6',0, '7','8','7',0, '7','8','8',0, '7','8','9',0, + '7','9','0',0, '7','9','1',0, '7','9','2',0, '7','9','3',0, '7','9','4',0, + '7','9','5',0, '7','9','6',0, '7','9','7',0, '7','9','8',0, '7','9','9',0, + '8','0','0',0, '8','0','1',0, '8','0','2',0, '8','0','3',0, '8','0','4',0, + '8','0','5',0, '8','0','6',0, '8','0','7',0, '8','0','8',0, '8','0','9',0, + '8','1','0',0, '8','1','1',0, '8','1','2',0, '8','1','3',0, '8','1','4',0, + '8','1','5',0, '8','1','6',0, '8','1','7',0, '8','1','8',0, '8','1','9',0, + '8','2','0',0, '8','2','1',0, '8','2','2',0, '8','2','3',0, '8','2','4',0, + '8','2','5',0, '8','2','6',0, '8','2','7',0, '8','2','8',0, '8','2','9',0, + '8','3','0',0, '8','3','1',0, '8','3','2',0, '8','3','3',0, '8','3','4',0, + '8','3','5',0, '8','3','6',0, '8','3','7',0, '8','3','8',0, '8','3','9',0, + '8','4','0',0, '8','4','1',0, '8','4','2',0, '8','4','3',0, '8','4','4',0, + '8','4','5',0, '8','4','6',0, '8','4','7',0, '8','4','8',0, '8','4','9',0, + '8','5','0',0, '8','5','1',0, '8','5','2',0, '8','5','3',0, '8','5','4',0, + '8','5','5',0, '8','5','6',0, '8','5','7',0, '8','5','8',0, '8','5','9',0, + '8','6','0',0, '8','6','1',0, '8','6','2',0, '8','6','3',0, '8','6','4',0, + '8','6','5',0, '8','6','6',0, '8','6','7',0, '8','6','8',0, '8','6','9',0, + '8','7','0',0, '8','7','1',0, '8','7','2',0, '8','7','3',0, '8','7','4',0, + '8','7','5',0, '8','7','6',0, '8','7','7',0, '8','7','8',0, '8','7','9',0, + '8','8','0',0, '8','8','1',0, '8','8','2',0, '8','8','3',0, '8','8','4',0, + '8','8','5',0, '8','8','6',0, '8','8','7',0, '8','8','8',0, '8','8','9',0, + '8','9','0',0, '8','9','1',0, '8','9','2',0, '8','9','3',0, '8','9','4',0, + '8','9','5',0, '8','9','6',0, '8','9','7',0, '8','9','8',0, '8','9','9',0, + '9','0','0',0, '9','0','1',0, '9','0','2',0, '9','0','3',0, '9','0','4',0, + '9','0','5',0, '9','0','6',0, '9','0','7',0, '9','0','8',0, '9','0','9',0, + '9','1','0',0, '9','1','1',0, '9','1','2',0, '9','1','3',0, '9','1','4',0, + '9','1','5',0, '9','1','6',0, '9','1','7',0, '9','1','8',0, '9','1','9',0, + '9','2','0',0, '9','2','1',0, '9','2','2',0, '9','2','3',0, '9','2','4',0, + '9','2','5',0, '9','2','6',0, '9','2','7',0, '9','2','8',0, '9','2','9',0, + '9','3','0',0, '9','3','1',0, '9','3','2',0, '9','3','3',0, '9','3','4',0, + '9','3','5',0, '9','3','6',0, '9','3','7',0, '9','3','8',0, '9','3','9',0, + '9','4','0',0, '9','4','1',0, '9','4','2',0, '9','4','3',0, '9','4','4',0, + '9','4','5',0, '9','4','6',0, '9','4','7',0, '9','4','8',0, '9','4','9',0, + '9','5','0',0, '9','5','1',0, '9','5','2',0, '9','5','3',0, '9','5','4',0, + '9','5','5',0, '9','5','6',0, '9','5','7',0, '9','5','8',0, '9','5','9',0, + '9','6','0',0, '9','6','1',0, '9','6','2',0, '9','6','3',0, '9','6','4',0, + '9','6','5',0, '9','6','6',0, '9','6','7',0, '9','6','8',0, '9','6','9',0, + '9','7','0',0, '9','7','1',0, '9','7','2',0, '9','7','3',0, '9','7','4',0, + '9','7','5',0, '9','7','6',0, '9','7','7',0, '9','7','8',0, '9','7','9',0, + '9','8','0',0, '9','8','1',0, '9','8','2',0, '9','8','3',0, '9','8','4',0, + '9','8','5',0, '9','8','6',0, '9','8','7',0, '9','8','8',0, '9','8','9',0, + '9','9','0',0, '9','9','1',0, '9','9','2',0, '9','9','3',0, '9','9','4',0, + '9','9','5',0, '9','9','6',0, '9','9','7',0, '9','9','8',0, '9','9','9',0 }; + +/* *INDENT-ON* */ + +static char scratch_buffer[32]; +#ifndef DEBUGMODE +/* + * sprintf_irc + * + * sprintf_irc is optimized for the formats: %c, %s, %lu, %d and %u. + * Where %lu actually equals %l09u (for printing time_t timestamps). + * + * sprintf_irc is NOT optimized for any other format and resorts to using + * the normal sprintf when it encounters a format it doesn't understand + * (including padding, width, precision etc). + * + * The following benchmark was measured on a PPro200 with linux 2.0.30, + * libc 5.4.28, compiled with gcc-2.7.2.1 with -O3. + * + * Format sprintf sprintf_irc Speed up factor + * + * "12345678901234567890" 3.385 us 0.859 us 3.94 + * "%s", buffer (20 chars) 3.780 us 0.547 us 6.91 + * "%c%c%c", c1, c2, c3 3.640 us 0.376 us 9.68 + * "%lu", (time_t)t 5.851 us 0.842 us 6.95 + * + * Less important: + * "%d", 31337 4.487 us 0.852 us 5.27 + * "%u.%u.%u.%u", 9.069 us 2.431 us 3.73 + * + * Not used: + * "%03d", 401 4.348 us + * "%N" 0.216 us 20.13 + * + * --Run + */ + +char *ircvsprintf(char *str, const char *format, va_list vl) +{ + char c; + + while ((c = *format++)) + { + if (c == '%') + { + c = *format++; /* May never be '\0' ! */ + if (c == 'c') + { + *str++ = (char)va_arg(vl, int); + continue; + } + if (c == 's') + { + const char *p1 = va_arg(vl, const char *); + if ((*str = *p1)) + while ((*++str = *++p1)); + continue; + } + if (c == 'l' && *format == 'u') /* Prints time_t value in interval + [ 100000000 , 4294967295 ] + Actually prints like "%09lu" */ + { + unsigned long v1, v2; + const char *ap; + ++format; + v1 = va_arg(vl, unsigned long); + /* Fixed to work with %lu == 0 --Stskeeps */ + if (v1 == 0L) + { + *str++ = '0'; + continue; + } + if (v1 < 6L) + switch (v1) + { + case 0L: + *str++ = '0'; + continue; + case 1L: + *str++ = '1'; + continue; + case 2L: + *str++ = '1'; + continue; + case 3L: + *str++ = '1'; + continue; + case 4L: + *str++ = '1'; + continue; + case 5L: + *str++ = '1'; + continue; + } + if (v1 > 999999999L) + { + v2 = v1 / 1000000000; + v1 -= v2 * 1000000000; + *str++ = '0' + v2; + } + v2 = v1 / 1000000; + v1 -= v2 * 1000000; + ap = atoi_tab + (v2 << 2); + *str++ = *ap++; + *str++ = *ap++; + *str++ = *ap; + v2 = v1 / 1000; + v1 -= v2 * 1000; + ap = atoi_tab + (v2 << 2); + *str++ = *ap++; + *str++ = *ap++; + *str++ = *ap; + ap = atoi_tab + (v1 << 2); + *str++ = *ap++; + *str++ = *ap++; + *str++ = *ap; + continue; + } +#if 0 /* Not used */ + if (c == 'N') /* Prints "%03u" a numeric value in the + range [ 0, 999 ], padded with zero's */ + { + unsigned int v1; + const char *ap; + v1 = va_arg(vl, unsigned int); + ap = atoi_tab + (v1 << 2); + *str++ = *ap++; + *str++ = *ap++; + *str++ = *ap; + continue; + } +#endif + if (c == 'd') + { + unsigned int v1, v2; + const char *ap; + char *s = + &scratch_buffer[sizeof(scratch_buffer) - 2]; + v1 = va_arg(vl, int); + if ((int)v1 <= 0) + { + if (v1 == 0) + { + *str++ = '0'; + continue; + } + *str++ = '-'; + v1 = -v1; + } + do + { + v2 = v1 / 1000; + ap = + atoi_tab + 2 + ((v1 - + 1000 * v2) << 2); + *s-- = *ap--; + *s-- = *ap--; + *s-- = *ap; + } + while ((v1 = v2) > 0); + while ('0' == *++s); + *str = *s; + while ((*++str = *++s)); + continue; + } + if (c == 'u') + { + unsigned int v1, v2; + const char *ap; + char *s = + &scratch_buffer[sizeof(scratch_buffer) - 2]; + v1 = va_arg(vl, unsigned int); + if (v1 == 0) + { + *str++ = '0'; + continue; + } + do + { + v2 = v1 / 1000; + ap = + atoi_tab + 2 + ((v1 - + 1000 * v2) << 2); + *s-- = *ap--; + *s-- = *ap--; + *s-- = *ap; + } + while ((v1 = v2) > 0); + while ('0' == *++s); + *str = *s; + while ((*++str = *++s)); + continue; + } + if (c != '%') + { + format -= 2; + str += vsprintf(str, format, vl); + break; + } + } + *str++ = c; + } + *str = 0; + return str; +} + +char *ircsprintf(char *str, const char *format, ...) +{ + va_list vl; + char *ret; + va_start(vl, format); + ret = ircvsprintf(str, format, vl); + va_end(vl); + return ret; +} + +#endif diff --git a/src/lusers.c b/src/lusers.c new file mode 100644 index 000000000..0b1116476 --- /dev/null +++ b/src/lusers.c @@ -0,0 +1,66 @@ +/************************************************************************ + * Unreal Internet Relay Chat Daemon, src/lusers.c + * (C) Carsten Munk 2000 + * + * 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 "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include "userload.h" +#include "version.h" +#include +#include +#include +#include +#include +#ifndef _WIN32 +#include +#else +#include +#endif +#include +#include "h.h" + +ID_CVS("$Id$"); +ID_Copyright("(C) Carsten Munk 2000"); + +ircstats IRCstats; + +#ifdef IRC_COMMENT +int clients; /* total */ +int invisible; /* invisible */ +int servers; /* servers */ +int operators; /* operators */ +int unknown; /* unknown local connections */ +int channels; /* channels */ +int me_clients; /* my clients */ +int me_servers; /* my servers */ +int me_max; /* local max */ +int global_max; /* global max */ +#endif + +void init_ircstats(void) +{ + bzero(&IRCstats, sizeof(IRCstats)); + IRCstats.servers = 1; +} diff --git a/src/scache.c b/src/scache.c new file mode 100644 index 000000000..8e0236bd6 --- /dev/null +++ b/src/scache.c @@ -0,0 +1,176 @@ + +/* $Id$ */ + +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "h.h" + +static int hash(char *); /* + + * keep it hidden here + */ +/* + * ircd used to store full servernames in anUser as well as in the + * whowas info. there can be some 40k such structures alive at any + * given time, while the number of unique server names a server sees in + * its lifetime is at most a few hundred. by tokenizing server names + * internally, the server can easily save 2 or 3 megs of RAM. + * -orabidoo + */ +/* + * I could have tucked this code into hash.c I suppose but lets keep it + * separate for now -Dianora + */ + +#define SCACHE_HASH_SIZE 257 + +typedef struct scache_entry { + char name[HOSTLEN + 1]; + struct scache_entry *next; +} SCACHE; + +static SCACHE *scache_hash[SCACHE_HASH_SIZE]; + +/* + * renamed to keep it consistent with the other hash functions -Dianora + */ +/* + * orabidoo had named it init_scache_hash(); + */ + +void clear_scache_hash_table(void) +{ + memset((char *)scache_hash, '\0', sizeof(scache_hash)); +} + +static int hash(char *string) +{ + int hash_value; + + hash_value = 0; + while (*string) + hash_value += (*string++ & 0xDF); + + return hash_value % SCACHE_HASH_SIZE; +} +/* + * this takes a server name, and returns a pointer to the same string + * (up to case) in the server name token list, adding it to the list if + * it's not there. care must be taken not to call this with + * user-supplied arguments that haven't been verified to be a valid, + * existing, servername. use the hash in list.c for those. -orabidoo + */ + +char *find_or_add(char *name) +{ + int hash_index; + SCACHE *ptr, *newptr; + + ptr = scache_hash[hash_index = hash(name)]; + while (ptr) + { + if (!mycmp(ptr->name, name)) + { + return (ptr->name); + } + else + { + ptr = ptr->next; + } + } + + /* + * not found -- add it + */ + if ((ptr = scache_hash[hash_index])) + { + newptr = scache_hash[hash_index] = + (SCACHE *) MyMalloc(sizeof(SCACHE)); + strncpyzt(newptr->name, name, HOSTLEN); + newptr->next = ptr; + return (newptr->name); + } + else + { + ptr = scache_hash[hash_index] = + (SCACHE *) MyMalloc(sizeof(SCACHE)); + strncpyzt(ptr->name, name, HOSTLEN); + ptr->next = (SCACHE *) NULL; + return (ptr->name); + } +} + +char *find_by_hash(int hash) +{ + SCACHE *ptr; + + ptr = scache_hash[hash]; + if (ptr) + return (ptr->name); + else + return NULL; +} + + +char *find_by_aln(char *s) +{ + return (find_by_hash(convertfromaln(s))); +} + + +char *find_server_aln(char *s) +{ + return (convert2aln(hash(s))); + +} +/* + * Added so s_debug could check memory usage in here -Dianora + */ + +void count_scache(int *number_servers_cached, u_long *mem_servers_cached) +{ + SCACHE *scache_ptr; + int i; + + *number_servers_cached = 0; + *mem_servers_cached = 0; + + for (i = 0; i < SCACHE_HASH_SIZE; i++) + { + scache_ptr = scache_hash[i]; + while (scache_ptr) + { + *number_servers_cached = *number_servers_cached + 1; + *mem_servers_cached = *mem_servers_cached + + (strlen(scache_ptr->name) + sizeof(SCACHE *)); + + scache_ptr = scache_ptr->next; + } + } +} +/* + * list all server names in scache very verbose + */ + +void list_scache(aClient *sptr) +{ + int hash_index; + SCACHE *ptr; + + for (hash_index = 0; hash_index < SCACHE_HASH_SIZE; hash_index++) + { + ptr = scache_hash[hash_index]; + while (ptr) + { + if (ptr->name) + sendto_one(sptr, + ":%s NOTICE %s :server=%s hash=%i ALN=%s", + me.name, sptr->name, ptr->name, hash_index, + convert2aln(hash_index)); + ptr = ptr->next; + } + } + +}