diff -BNru iroffer1.2b13/ChangeLog iroffer1.2b13+cpitchfor11-doc/ChangeLog
--- iroffer1.2b13/ChangeLog	Thu Jan  1 01:00:00 1970
+++ iroffer1.2b13+cpitchfor11-doc/ChangeLog	Wed Apr  3 19:29:35 2002
@@ -0,0 +1,147 @@
+cpitchfor11-doc:	Wed Apr  3 19:14:05 BST 2002	cpitchford
+	*	Added badpack operatives to admin.c and misc.c
+		to cover control of ban on invalid pack send
+	*	Updated humiliate call to use simple format
+	*	Created simple format function that emulates snprintf
+		with the advantage you specify what %tags get replaced with
+		used to create "humiliate" lines
+
+
+cpitchfor10:	Thu Mar 21 23:33:22 GMT 2002	cpitchford	
+	*	Updated misc.c, defines.h, globals.h: added prejoin config	
+		file option to send a RAW command before joining any
+		channels. This will allow nicksrv commands to be sent for
+		IRC services such as those on DALNet. Thanks to
+		coombes_mark@hotmail.com for suggestion and DALNet help
+	*	bugfixed misc.c: config file parsing would allow
+		gdata.server[MAXSRVS] to be defined in the event there were
+		MAXSRVS+1 servers defined in the config file. This has been
+		limited and an error returned.
+	*	bugfixed misc.c: same as above but for gdata.advert
+
+cpitchfor9:	Wed Mar  6 01:47:46 GMT 2002	cpitchford
+	*	Updated admin.c u_psend so it will set the nolisttime to
+		zero before calling u_xdl otherwise it is not possible to
+		force a list to be sent to all the channels
+	*	Updated admin.c to include say admin command to talk to
+		a user or a channel
+
+cpitchfor8:	Wed Feb 27 03:00:30 GMT 2002	cpitchford
+	*	Moved the "timed advert" code from iroffer.c into
+		sendAdvert() in admin.c since it is required elsewhere now
+	*	Added fullignore() function to admin.c which will ignore
+		user/hostname if the fullignoretime is set
+	*	Added fullignore support to misc.c and admin.c
+		takes mins as an argument. Enfoced by fullignore
+	*	added calls to fullignore to queue full notices in iroffer.c
+	*	added adsend function to send adverts to channel or all
+		channels using sendAdvert
+	*	Added Adverts to admin.c to enable control over auto-advert
+		sends
+	*	Added noaverts configfile directive to misc.c
+	*	Fixed bug in getEngineerval() in utilities.c whereby
+		last char is ignored in quantifier array.
+
+cpitchfor7:	Tue Feb 12 22:56:54 GMT 2002	cpitchford
+	*	Fixed bug with advert rehash causing it to only use last
+		advert line in config file.
+
+
+cpitchfor6:	Tue Feb 12 02:01:35 GMT 2002	cpitchford
+	*	%l has been added to the list of tags for the advert
+		directive. It will be replaced with the minimum speed
+
+	*	Added "on" option to NOLIST admin command.. "on" will enable
+		NOLIST indefinitely until NOLIST is called again
+		with either zero or a number of minutes
+
+	*	Added "nolist" config file directives, which will disable
+		listing indefinitely or until nolist admin command is
+		issued to cancel nolist. It also takes an optional 
+		parameter of "-q" to drop list requests silently
+		or of m where it will auto-ban any user for m minutes
+		should they make a list request to the bot, in the same
+		way as the NOLIST admin command
+
+	*	Fixed a BUG in admin.c: void getconfig_set. If line
+		in the configuration file has no parameters (e.g. 
+		"nolist" the "var" and "var2" variables faced a buffer
+		overrun situation, as they are assigned after the
+		terminating NULL character and hence a configfile
+		with a single word on it could potentially lead to
+		a buffer overrun and a SEGV death. This is a bug in
+		iroffer, this patch fixes it.
+
+	*	Added configuration directives "speedwarnings" and 
+		"nospeedwarnings". These two directives turn off the
+		warnings notices sent to users when they reach bandwidth
+		limits
+
+	*	Added SPDWRN admin command with parameter + or - This
+		command turns off the notifications that are sent to a user
+		when they reach bandwidth limits
+
+
+cpitchfor5:		cpitchfor
+	*	%i was added to the humiliate list of replace tags. This
+		will be replaced in the string with the number of
+		minutes the user has been ignored for.
+
+
+cpitchfor4:		cpitchfor
+	*	Humiliate config file directive and admin command was
+		added. Like advert it takes a printf style string
+		in which %u is replaced with the username of a user
+		who has just been auto-banned.
+
+	*	"public" and "nopublic" config file directives were
+		added to allow the ability to control how the bot
+		responds to public triggers
+
+	*	the ignore admin command now accepts network ranges
+		in the form of strings starting with "*"
+		A hostname is checked to see if it ends with a network
+		range (excluding the prefixing *) to determine
+		a match
+	*	!strcmp was replaced with isbanned to determine
+		if a hostname matched an ignore entry to ensure
+		network ranges are catered for
+
+
+cpitchfor3:		cpitchfor
+	*	When a user was banned public triggers failed. This was
+		fixed
+
+	*	advert lines were silently unlinked and therefore caused
+		memory leaks. (Thanks to FarFetch'd for fix)
+
+	*	Files were not closed after finished reading. This is
+		an actual bug in iroffer. This patch fixes it.
+		(Thanks to FarFetch'd for fix)
+
+
+cpitchfor2:		cpitchfor
+	*	PUBLIC admin command added to toggle whether the bot will
+		respond to public messages, and public triggers (/CTCP)
+		using the admin command PUBLIC <+|->
+
+
+cpitchfor1:		cpitchfor
+	*	Altered NOLIST function to admin commands.
+		NOLIST now accepts two parameters. first still specifies
+		how long list is disabled, second new parameter specifies
+		that the list requests should be silently dropped "-q"
+		or the number of minutes to ignore a user after making
+		a list request. Quiet and banning NOLIST commands will
+		also drop the list command without queuing it for
+		processing.
+
+	* 	Added config file directive for custom adverts
+		Advert when used (multiple times also) will define
+		a printf like template for the advert sent out to 
+		channels with the -advert option enabled.
+		The advert is created from the advert lines in the config
+		file in the order they appear.
+		% was chosen as the escape character. The flag letter
+		was taken from the /ctcp status option as mentioned
+		on the iroffer documentation
diff -BNru iroffer1.2b13/README.cpitchfor-patch iroffer1.2b13+cpitchfor11-doc/README.cpitchfor-patch
--- iroffer1.2b13/README.cpitchfor-patch	Thu Jan  1 01:00:00 1970
+++ iroffer1.2b13+cpitchfor11-doc/README.cpitchfor-patch	Wed Apr  3 19:29:35 2002
@@ -0,0 +1,256 @@
+cpitchfor10   2002/03/20				<iroffer@itmakesmemad.com>
+http://iroffer.itmakesmemad.com/
+
+This patch adds a bunch of new features to iroffer. All have been requested
+by faithful people on a channel I frequent. See here for a summary:
+
+XDCC LIST handler:
+------------------
+This is an update to the admin command "NOLIST" and the config file
+directive nolist.
+
+The admin command "NOLIST" can be sent to the bot to control how it will
+react to a xdcc list request:
+
+NOLIST [ <on|m> [-q|n] ]
+
+	NOLIST with no paramters will turn listing back on.
+
+	The first parameter can be "on" or a number.
+		"on":	Turn listing off until it is enabled again
+			with the NOLIST command
+
+		n:	Turn listing off for n minutes
+
+		0:	Turn listing back on
+
+	The second optional parameter can be -q or a number
+		-q:	When a xdcc list request is received quietly
+			drop the request. Do not inform the requesting
+			user that lists have been disabled
+
+		m:	Ban any user that xdcc list requests this bot
+			for m minutes
+
+			if no second paramter is provided, the bot
+			will msg the requesting user to tell them
+			the bot is not accepting list requests.
+			
+
+NOLIST 10		# Will turn off list response for 10 minutes
+
+NOLIST 10 -q		# will turn off list responce for 10 minutes and
+			  drop list requests silently. The user will not
+			  get any response from the server at all. -q quiet
+
+NOLIST 10 100		# Will turn off list response for 10 minutes and
+			  auto ban any user who sends a list request for
+			  100 minutes
+
+NOLIST on 1000		# Will turn off listing and ban any requesting
+			  user for 1000 minutes
+
+The nolist directive has also been added to the configuration file
+
+nolist			# turns off listing
+
+nolist -q		# turns off listing and quietly drop list requests
+			  does NOT inform the user that lists have been
+			  disabled
+
+nolist 1000		# turns off listing and bans any user making a list
+			# request for 1000 minutes.
+
+
+
+Humiliate the user autobanned
+----------------------------
+You can set either as an admin command or in the config file a message to be
+sent to the channels the bot sits on in the event it should auto-ban a user
+
+humiliate I've just banned %u for %t for being naughty
+
+should cpitchfor send a xdcc list when nolist+ban is on the channel would
+see:
+
+<yourbot> I've just banned cpitchfor for 10 minutes for being naughty
+
+
+
+Custom Ads:
+-----------
+This is an additional flag to the channel directive in the configuration
+file:
+
+channel #mychannel -plist 30 -pformat summary -advert
+
+This instructs the bot that when sending an advert to the channel it should
+send a "custom" advert defined in the directive advert:
+
+
+advert This is the first line of the advert
+advert This is the second line of the advert
+advert 3rd line: SLOTS:[%a/%b]  QUEUE:[%c/%d]
+advert 4th line: Record Speed: %g  Total Offered: %x
+
+
+a % is a special character, much like in printf. It will be replaced with
+values as the advert is sent for example the above example would send
+
+<mybot> This is the first line of the advert
+<mybot> This is the second line of the advert
+<mybot> 3rd line: SLOTS:[4/10]  QUEUE:[0/0]
+<mybot> 4th line: Record Speed: 1245.3K/s  Total Offered: 3223.3 MB
+
+If a channel has a "-advert" flag but there are no "advert" lines defined in
+the config file, the bot will not advertise in that channel
+
+The conversions are as follows:
+
+%a	number of slots in use 
+%b	total slots 
+%c	number in main queue 
+%d	size of main queue 
+%e	number in pack queue 
+%f	size of pack queue 
+%g	pack speed record (K/sec) 
+%h	number of lines in send to server queue 
+%i	amount of data sent to network in past 120 seconds (K) 
+%j	average bandwidth of past 120 seconds (K/sec) 
+%k	record average bandwidth (K/sec) 
+%l	minimum bandwith required
+%w	number of packs offered 
+%x	total size of offered packs (MB) 
+%y	total completed transfers
+%z	total transfered (MB)
+%%	a single "%"
+
+Advert Control:
+---------------
+
+You can now disable adverts either permanently or for a number of minutes.
+Use the admin command "ADVERTS" to control the auto-adverts:
+
+ADVERTS 0
+	Enable auto advert posting to channels
+
+ADVERTS off
+	Disable adverts permanently
+
+ADVERTS 20
+	Disable adverts for at least the next 20 minutes
+
+You can also disable adverts (to be reenabled as above) from the config
+file. Use "noadverts" to disable them.
+
+Advertise NOW!
+--------------
+
+A new admin command has been added to force an advert to be sent to a
+single or all of the channels the bot is on
+
+
+ADSEND #mychannel
+	will force an advert to be sent to #mychannel
+
+ADSEND
+	will force an advert to be sent to ALl the channels the bot is on
+
+
+Public Triggers:
+----------------
+iroffer will respond to public triggers such as "xdcc list" or /ctcp
+#channel ping. The admin command "public" can control this functionality
+
+public -
+	will turn off the ability to respond to any public trigger
+
+public +
+	will turn it back on again
+
+you can set the default in you config file with either
+
+public	
+	# react to public triggers
+
+nopublic
+	# dont react to public triggers
+
+
+
+Baning Network ranges:
+----------------------
+ignore 10 cptf-adsl.demon.co.uk
+	will ignore all connections from cptf-adsl.demon.co.uk
+
+ignore 10 *.demon.co.uk
+	will ignore all connections from ANY host ending in .demon.co.uk
+
+
+
+Bandwidth Warning Notices
+-------------------------
+
+When a user is downloading a pack with bandwidth limits (or from a bot with 
+bandwidth limits) iroffer will send the user a warning regarding bandwidth
+limits and how much bandwidth they are using. This can now be controlled
+with these functions:
+
+SPDWRN Admin command
+
+	SPDWRN +	Enable bandwidth warning notices
+	SPDWRN -	Disable bandwidth warning notices
+
+Configuration file directives:
+
+speedwarnings		Enable bandwidth warning notices
+nospeedwarnings		Disable bandwidth warning notices
+
+Queue Auto-ignoring:
+--------------------
+
+When the queue is full and a user makes a send request, the bot will inform
+them that the queue is full and that they should try again later. Now you
+can auto-ignore these people (ideally for a SHORT time, lets not be mean
+here!). The admin command "fullignore" controls this:
+
+FULLIGNORE 1
+	Will automatically ignore any user for one minute should they
+	make a request when the queue is full. It will NOT send them any
+	queue-full notification.
+
+FULLIGNORE
+	Reenabled notifications. No users will be ignored, they will instead
+	receive a queue-full warning
+
+You can control this in the configuration file with "fullignore"
+
+fullignore 10
+	#	auto-ignore for 10 minutes on queue full request
+
+Speak To People And Channels:
+-----------------------------
+
+Now you can say things to people and to the channel with the admin command
+say. For example:
+
+say #yourchan Hello everybody
+	send a message to #yourchan
+
+say bob Hello bob
+	send a private message to bob
+
+Pre join RAW commands:
+----------------------
+
+Some services on networks (ie DALNet) require raw commands to be sent to the
+server before joining a channel (ie to register a nick with a password)
+The prejoin config file parameter allows you to specify multiple raw
+commands that will be sent prior to the bot joining a channel. It will also
+be sent in the event a bot changes server or is disconnected and reconnects.
+
+This can also be used to msg a nick when the bot comes up.. ie
+
+prejoin PRIVMSG cpitchfor : I've just joined a server and I'm serving!
+prejoin nickserv mybot mypassword
+
diff -BNru iroffer1.2b13/sample.config iroffer1.2b13+cpitchfor11-doc/sample.config
--- iroffer1.2b13/sample.config	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/sample.config	Wed Apr  3 19:29:35 2002
@@ -106,16 +106,36 @@
 server irc.east.gblx.net 6667
 
 ##############################################################################
+***                         - prejoin (upto 20) -                          ***
+***                                                                        ***
+*** prejoin format:                                                        ***
+***  "prejoin RAW COMMAND"                                                 ***
+*** the RAW command will be sent to the server before it joins any         ***
+*** channels. This can be used to msg a nick or use DALNet nickserv        ***
+*** services. Multiple commands can be specified on multiple lines.        ***
+*** It SHOULD BE USED WITH CARE!!!!!!                                      ***
+***                                                                        ***
+
+# Send msg to cpitchfor when the server join
+#prejoin PRIVMSG cpitchfor : I have joined and I'm ready to serve again!
+
+# DALNet nick services!
+#prejoin NICKSERV mybot mysecretpasswrd
+
+
+##############################################################################
 ###                         - channels (upto 50) -                         ###
 ### channel format:                                                        ###
 ### "channel <channel> [-plist <time>]                                     ###
-###    [-pformat <full|minimal|summary>] [-key <key>] "                    ###
+###    [-pformat <full|minimal|summary>] [-key <key>] [-advert] "          ###
 ### plist: time is number of minutes between plists.                       ###
 ### pformat: full is normal and default if pformat is not used             ###
 ###          minimal is similar to full but removes some lines             ###
 ###          summary displays only a 2 line summary                        ###
 ### key:     for +k channels, the key specified is used when joining       ###
 ### using same or multiples of the same number plist time is recomended    ###
+### advert: This channel will received a customised advert in the format
+###          defined by the advert directive
 channel #chan01
 channel #chan02 -plist 14
 channel #chan03 -plist 28 -pformat minimal
@@ -123,6 +143,82 @@
 
 
 ##############################################################################
+###                               - advert -                               ###
+### advert format:                                                         ###
+### "advert line 1 format"                                                 ###
+### "advert line 2 format"                                                 ###
+### "advert line n format"                                                 ###
+### The advert lines will be combined to form you channel advert           ###
+### Certain characters will be replaced by values:                         ###
+###    %a      number of slots in use                                      ###
+###    %b      total slots                                                 ###
+###    %c      number in main queue                                        ###
+###    %d      size of main queue                                          ###
+###    %e      number in pack queue                                        ###
+###    %f      size of pack queue                                          ###
+###    %g      pack speed record (K/sec)                                   ###
+###    %h      number of lines in send to server queue                     ###
+###    %i      amount of data sent to network in past 120 seconds (K)      ###
+###    %j      average bandwidth of past 120 seconds (K/sec)               ###
+###    %k      record average bandwidth (K/sec)                            ###
+###    %l      required minimum download bandwidth                         ###
+###    %w      number of packs offered                                     ###
+###    %x      total size of offered packs (MB)                            ###
+###    %y      total completed transfers                                   ###
+###    %z      total transfered (MB)                                       ###
+###    %%      a single "%"                                                ###
+
+
+advert my special bot Slots [%a/%b]
+advert queue [%c/%b] %x offered in %w packs
+
+##############################################################################
+###                              - noadverts -                             ###
+###                                                                        ###
+### This will disable the automatic adverts sent to the channels specified ###
+### in the channel directive above.                                        ###
+
+#noadverts
+
+
+##############################################################################
+###                              - nolist -                                ###
+### nolist format:                                                         ###
+### [-q|n]                                                                 ###
+### This function will control how the bot responds to list commands       ###
+### No parameters means the bot will not serve lists, instead it will      ###
+### inform the user lists are disabled                                     ###
+### -q will quietly drop any list request without processing them. The     ###
+### user will not see a response                                           ###
+### n, being a number, will ban any user making a list request to the bot  ###
+### for n minutes                                                          ###
+
+nolist -q
+
+
+
+##############################################################################
+###                             - humiliate -                              ###
+### humiliate format:                                                      ###
+### [message]                                                              ###
+### When a user is autobanned, this message will be sent to the channels   ###
+### as with the advert directive, %u will be replaced with the nick of     ###
+### the person being banned and %i will be replaced with the time before   ###
+### the ban is lifted                                                      ###
+
+humiliate %u has been banned for %i
+
+##############################################################################
+###                              - public -                                ###
+### public|nopublic:                                                       ###
+### sets the default reaction to public triggers. public means the bot     ###
+### responed to public triggers and nopublic means the bot will not        ###
+
+nopublic
+
+
+
+##############################################################################
 ###                          - user information -                          ###
 user_nick nickDCC
 user_realname NAME
@@ -185,6 +281,17 @@
 slotsmaxqueue 10
 
 ##############################################################################
+###                       - full queue autoignore -                        ###
+### This directive will allow you to specify the number of minutes to      ###
+### ignore a person should they make a request when the queue is full      ###
+### Not intended to be mean, this function will help again release         ###
+### hammering                                                              ###
+
+# Ignore user for 2 minutes if queue is full and they make requests
+fullignore 3
+
+
+##############################################################################
 ###                      - max transfers per person -                      ###
 ### maximum transfers per person at a time                                 ###
 maxtransfersperperson 1
@@ -213,8 +320,8 @@
 ### if yes, xdcc list and/or xdcc send will be restricted to users who are ###
 ### on a known channel. If a user is not on one of the known channels they ###
 ### will not be able to list and/or get packs                              ###
-restrictlist no
-restrictsend no
+restrictlist yes
+restrictsend yes
 
 
 ##############################################################################
diff -BNru iroffer1.2b13/src/admin.c iroffer1.2b13+cpitchfor11-doc/src/admin.c
--- iroffer1.2b13/src/admin.c	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/admin.c	Wed Apr  3 19:29:35 2002
@@ -73,6 +73,15 @@
 static void u_crash(const userinput * const u);
 static void u_chanl(const userinput * const u);
 
+static void u_public(const userinput * const u);
+static void u_humiliate(const userinput * const u);
+static void u_spdwrn(const userinput * const u);
+static void u_adsend(const userinput * const u);
+static void u_fullignore(const userinput * const u);
+static void u_adverts(const userinput * const u);
+static void u_say(const userinput * const u);
+static void u_badpack(const userinput * const u);
+static void u_bdpklmt(const userinput * const u);
 
 /* local info */
 static const userinput_parse_t userinput_parse[] = {
@@ -93,9 +102,10 @@
 {2,method_allow_all,u_nomin,    "NOMIN","n","Disables Minspeed For Transfer ID n"},
 {2,method_allow_all,u_nomax,    "NOMAX","n","Disables Maxspeed For Transfer ID n"},
 {2,method_allow_all,u_send,     "SEND","nick n","Sends Pack n to nick"},
+{2,method_allow_all,u_adsend,    "ADSEND", "[channel] send an advert to all the to a specific channel all channels"},
 {2,method_allow_all,u_psend,    "PSEND","<channel>","Sends XDCC LIST to <channel>"},
 {2,method_allow_all,u_qsend,    "QSEND",NULL,"Sends Out The First Queued Pack"},
-
+{2,method_allow_all,u_spdwrn,      "SPDWRN","<+|->","Turn on (+) or off (-) the notices sent to users when bandwidth limits are reached"},
 {3,method_allow_all,u_info,     "INFO","n","Show Info for Pack n"},
 {3,method_allow_all,u_remove,   "REMOVE","n","Removes Pack n"},
 {3,method_allow_all,u_renumber, "RENUMBER","x y","Moves Pack x to y"},
@@ -109,15 +119,20 @@
 
 {4,method_allow_all,u_mesg,     "MESG","<message>","Sends msg to all users who are transferring"},
 {4,method_allow_all,u_mesq,     "MESQ","<message>","Sends msg to all users in a queue"},
-{4,method_allow_all,u_ignore,   "IGNORE","n <host>","Ignore <host> (hostname) for n minutes"},
+{4,method_allow_all,u_ignore,   "IGNORE","n [<host>| *<hostmask>]","Ignore <host> (hostname) or any hostname ending in hostmask for n minutes"},
 {4,method_allow_all,u_nosave,   "NOSAVE","n","Disables XDCC AutoSave for next n minutes"},
 {4,method_allow_all,u_nosend,   "NOSEND","n","Disables XDCC Send for next n minutes"},
-{4,method_allow_all,u_nolist,   "NOLIST","n","Disables XDCC List and Plist for next n mins"},
+{4,method_allow_all,u_adverts,  "ADVERTS","<off|n>","Disables adverts for an optional time"},
+{4,method_allow_all,u_nolist,   "NOLIST","[on|n] [-q|m]","Disables XDCC List and Plist for next n mins and optionally makes output quiet (-q) or bans any user requesting a list for m minutes"},
+{4,method_allow_all,u_badpack,  "BADPACK","[on|n] [m]","Enables autobanning (for n minutes) for m minutes if they request an invalid pack"},
+{4,method_allow_all,u_bdpklmt, "BDPKLMT","n m","Used with BADPACK. Autoban user if they request invalid packs n times in m minutes"},
+{4,method_allow_all,u_fullignore,   "FULLIGNORE","n","Will automatically ignore any user who makes a send request when the queues are full. Their request is silently dropped"},
 {4,method_allow_all,u_msgread,  "MSGREAD",NULL,"Show MSG log"},
 {4,method_allow_all,u_msgdel,   "MSGDEL",NULL,"Delete MSG log"},
 {4,method_allow_all,u_rmul,     "RMUL","<file>","Delete a file in the Upload Dir"},
 {4,method_allow_all,u_raw,      "RAW","<command>","Send <command> to server (RAW IRC)"},
-
+{4,method_allow_all,u_say,      "SAY","<#channel|nick> <text...>","Say text in a channel or to a person"},
+{4,method_allow_all,u_humiliate,      "HUMILIATE","<list|badpack> [message]","Will announce this message (%u is replaced with nick and %t is replaced with the ban time) to all channels when user is autobanned by server"},
 {5,method_allow_all,u_servers,  "SERVERS",NULL,"Shows the server list"},
 {5,method_allow_all,u_jump,     "JUMP","<num>","Switches to a random server or server <num>"},
 {5,method_allow_all,u_status,   "STATUS",NULL,"Show Useful Information"},
@@ -130,6 +145,7 @@
 {5,method_msg,      u_chatme,   "CHATME",NULL,"Sends you a DCC Chat Request"},
 {5,method_stdin,    u_debug,    "DEBUG","n","Set Debugging to n [0,1,2]"},
 {5,method_allow_all,u_shutdown, "SHUTDOWN","<act>","Shutdown iroffer, <act> is \"now\", \"delayed\", or \"cancel\""},
+{5,method_allow_all,u_public,      "PUBLIC","<+|->","Turn on (+) or off (-) the ability to resond to public triggers"},
 
 {6,method_stdin,    u_crash, "CRASH",NULL,"Cause a segmentation fault"},
 };
@@ -291,6 +307,7 @@
       privmsg(u->snick,"%s",a);
       break;
    case method_xdl_channel_sum:
+   case method_xdl_channel_cust:
       privmsg(u->snick,"%s",a);
       break;
    case method_allow_all:
@@ -320,14 +337,26 @@
    
    if (!found)
       u_respond(u,"*** User Command Not Recognized, try \"HELP\"");
-   
-   if (found && u->method==method_stdin)
+   else
+     switch (u->method)
+       {
+       case method_stdin:
       ioutput(0,OUT_S|OUT_L|OUT_D,"0;35","ADMIN %s Requested (stdin)",u->cmd);
-   if (found && u->method==method_dcc)
+	 break;
+       case method_dcc:
       ioutput(0,OUT_S|OUT_L|OUT_D,"0;35","ADMIN %s Requested (DCC Chat)",u->cmd);
-   if (found && u->method==method_msg)
+	 break;
+       case method_msg:
       ioutput(0,OUT_S|OUT_L|OUT_D,"0;35","ADMIN %s Requested (MSG: %s)",u->cmd,u->snick);
-   
+       case method_xdl_channel:
+       case method_xdl_user:
+       case method_out_all:
+       case method_xdl_channel_min:
+       case method_xdl_channel_sum:
+       case method_xdl_channel_cust:
+       case method_allow_all:
+	 break;
+       }
    u_fillwith_clean(u);
    
    }
@@ -350,10 +379,10 @@
       u_respond(u,"Usage: \"HELP <section>\"");
       u_respond(u,"Help Sections Available:");
       u_respond(u,"  Info     - help, xdl, xds, dcl, dcld, trinfo, qul, ignl, listul, chanl");
-      u_respond(u,"  Transfer - close, rmq, rpq, nomin, nomax, send, psend, qsend");
+      u_respond(u,"  Transfer - close, rmq, rpq, nomin, nomax, send, adsend, psend, qsend, spdwrn");
       u_respond(u,"  Pack     - info, remove, renumber, add, adddir, chfile, chdesc, chnote, chmins, chmaxs");
-      u_respond(u,"  Misc     - mesg, mesq, ignore, nosave, nosend, nolist, msgread, msgdel, rmul, raw");
-      u_respond(u,"  Bot      - servers, jump, status, rehash, botinfo, memstat, clearrecords, redraw, quit, chatme, debug, shutdown");
+      u_respond(u,"  Misc     - mesg, mesq, ignore, nosave, nosend, adverts, nolist, badpack, bdpklmt, fullignore msgread, msgdel, rmul, raw, say, public, humiliate");
+      u_respond(u,"  Bot      - servers, jump, status, rehash, botinfo, memstat, clearrecords, redraw, quit, chatme, debug, shutdown, public");
       u_respond(u,"For additional help, see the complete documentation at http://iroffer.org/");
       return;
       }
@@ -394,9 +423,9 @@
    }
 
 static void u_xdl(const userinput * const u) {
-   char *tempstr,*tempstr2,*tempstr3;
+   char *tempstr,*tempstr2,*tempstr3, *cptr, *nptr;
    const char *spaces[] = { ""," ","  ","   ","    ","     ","      " };
-   int a,i,p,m,m1,s;
+   int a,i,p,m,m1,s,spaceleft,x;
    
    updatecontext(__FILE__,__FUNCTION__,__LINE__);
    
@@ -416,2199 +445,58 @@
    tempstr2 = mycalloc(maxtextlength,"u_xdl");
    tempstr3 = mycalloc(maxtextlengthshort,"u_xdl");
 
-   if (u->method==method_xdl_channel_min) m = 1; else m = 0;
-   if (u->method==method_xdl_channel_sum) m1 = 1; else m1 = 0;
-   
-   if (!m && !m1) {
-      if (gdata.slotsmax-gdata.slotsfull < 0) a = gdata.slotsfull;
-      else a = gdata.slotsmax;
-      
-      isnprintf(tempstr,maxtextlength-2,
-          "\2**\2 %i pack%s \2**\2  %i of %i slot%s open",
-          gdata.numpacks,gdata.numpacks!=1?"s":"",a-gdata.slotsfull,a,a!=1?"s":"");
-      if (gdata.slotsmax <= gdata.slotsfull) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, Queue: %i/%i",tempstr,gdata.inqueue,gdata.queuesize);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      if (gdata.overallminspeed > 0) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, Min: %1.1fKB/s",tempstr,gdata.overallminspeed);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      if (gdata.transfermaxspeed > 0) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, Max: %1.1fKB/s",tempstr,gdata.transfermaxspeed);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      if (gdata.record > 0.5) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, Record: %1.1fKB/s",tempstr,gdata.record);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      u_respond(u,tempstr);
-      
-      for (i=0,a=0; i<120; i++)
-         a += gdata.xdccsent[i];
-      isnprintf(tempstr,maxtextlength-2,
-          "\2**\2 Bandwidth Usage \2**\2 Current: %1.1fKB/s,",((float)a)/120.0/1024.0);
-      if (gdata.maxb) {
-         isnprintf(tempstr2,maxtextlength-2,"%s Cap: %i.0KB/s,",tempstr,gdata.maxb/4);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      if (gdata.sentrecord > 0.5) {
-         isnprintf(tempstr2,maxtextlength-2,"%s Record: %1.1fKB/s",tempstr,gdata.sentrecord);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      u_respond(u,tempstr);
-   
-   
-      isnprintf(tempstr,maxtextlength-2,
-          "\2**\2 To request a file type: \"/msg %s xdcc send #x\" \2**\2",gdata.user_nick);
-      u_respond(u,tempstr);
-      }
-   
-   if (m1) {
-      isnprintf(tempstr,maxtextlength-2,
-          "\2**\2 For a listing type: \"/msg %s xdcc list\" \2**\2",gdata.user_nick);
-      u_respond(u,tempstr);
-      
-      if (gdata.creditline)
+   if (u->method==method_xdl_channel_cust)
 	{
-	  isnprintf(tempstr,maxtextlength-2,"\2**\2 %s \2**\2",gdata.creditline);
-	  u_respond(u,tempstr);
-	}
-      
-      mydelete(tempstr);
-      mydelete(tempstr2);
-      mydelete(tempstr3);
-      return;
-      }
-   
-   s = 0;
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if (p>(MAXXDCCS-1))
-         break;
-      s = max2(s,gdata.xdccs[p]->gets);
-      }
-   i = s; s = 5;
-   if (i < 10000) s = 4;
-   if (i < 1000) s = 3;
-   if (i < 100) s = 2;
-   if (i < 10) s = 1;
-   isnprintf(tempstr3,maxtextlengthshort-2,"\2#%%-2i\2 %%%iix [%%s] %%s",s);
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if (p>(MAXXDCCS-1))
-         break;
-      
-      isnprintf(tempstr,maxtextlength-2,
-         tempstr3,
-         i,
-         gdata.xdccs[p]->gets,
-         sizestr(1,tempstr2,gdata.xdccs[p]->size),
-         gdata.xdccs[p]->desc);
-      
-      if (gdata.xdccs[p]->minspeed > 0 && gdata.xdccs[p]->minspeed != gdata.overallminspeed) {
-         isnprintf(tempstr2,maxtextlength-2,"%s [%1.1fK Min]",tempstr,gdata.xdccs[p]->minspeed);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      
-      if (gdata.xdccs[p]->maxspeed > 0 && gdata.xdccs[p]->maxspeed != gdata.transfermaxspeed) {
-         isnprintf(tempstr2,maxtextlength-2,"%s [%1.1fK Max]",tempstr,gdata.xdccs[p]->maxspeed);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      
-      u_respond(u,tempstr);
-      
-      if (gdata.xdccs[p]->note && strlen(gdata.xdccs[p]->note)) {
-         isnprintf(tempstr,maxtextlength-2," \2^-\2%s%s",spaces[s],gdata.xdccs[p]->note);
-         u_respond(u,tempstr);
-         }
-      
-      if (i == gdata.slotsmaxpack && gdata.inslotsmaxqueue) {
-         isnprintf(tempstr,maxtextlength-2," \2^-\2%sPack %i Has Slot Queue: %i/%i",
-            spaces[s],i,gdata.inslotsmaxqueue,gdata.slotsmaxqueue);
-         u_respond(u,tempstr);
-         }
-      }
-   
-   if (gdata.creditline) {
-      isnprintf(tempstr,maxtextlength-2,"\2**\2 %s \2**\2",gdata.creditline);
-      u_respond(u,tempstr);
-      }
-   
-   if (!m) {
-      float toffered = 0;
-   
-      for (i=0; i<MAXXDCCS; i++)
-         if (gdata.xdccs[i])
-            toffered += (float)gdata.xdccs[i]->size;
-   
-      isnprintf(tempstr,maxtextlength-2,
-         "Total Offered: %1.1f MB  Total Transferred: %1.2f %cB",
-         toffered/1024.0/1024.0,
-         (gdata.totalsent/1024/1024) > 1024 ? ( (gdata.totalsent/1024/1024/1024) > 1024 ? ((float)gdata.totalsent)/1024/1024/1024/1024 : ((float)gdata.totalsent)/1024/1024/1024 ) : ((float)gdata.totalsent)/1024/1024 ,
-         (gdata.totalsent/1024/1024) > 1024 ? ( (gdata.totalsent/1024/1024/1024) > 1024 ? 'T' : 'G' ) : 'M'
-         );
-      u_respond(u,tempstr);
-      }
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   mydelete(tempstr3);
-   }
-
-static void u_xds(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   xdccsave(0);
-   }
-
-static void u_dcl(const userinput * const u) {
-   char *tempstr;
-   const char *y;
-   int i,j;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   for (j=i=0; i<MAXUPLDS; i++)
-      if (gdata.uploads[i] != NULL) j++;
-
-   if (!gdata.slotsfull && !j) {
-      u_respond(u,"No Active Transfers");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_dcl");
-
-   isnprintf(tempstr,maxtextlength-2,"Current Transfer%s",gdata.slotsfull!=1?"s":"");
-   u_respond(u,tempstr);
-   u_respond(u,"   ID  User        File                               Status");
-   
-   for (i=0; i<MAXTRANS; i++)
-      if (gdata.trans[i] != NULL) {
-         
-         if (gdata.trans[i]->status == 'L') y = "Listening";
-         else if (gdata.trans[i]->status == 'W') y = "Finishing";
-         else if (gdata.trans[i]->status == 'D') y = "Closing";
-         else if (gdata.trans[i]->status == 'E') y = "Error";
-         else if (gdata.trans[i]->status == 'S') y = "Sending";
-         else y = "Unknown!";
-         
-         if (gdata.trans[i]->status == 'S') {
-            isnprintf(tempstr,maxtextlength-2,"   %2i  %-9s   %-32s   %s %2.0f%%",
-               i,gdata.trans[i]->nick,getfilename(gdata.trans[i]->xpack->file),y,
-               ((float)gdata.trans[i]->bytessent)*100.0/((float)gdata.trans[i]->xpack->size));
-            }
-         else
-            isnprintf(tempstr,maxtextlength-2,"   %2i  %-9s   %-32s   %s",
-               i,gdata.trans[i]->nick,getfilename(gdata.trans[i]->xpack->file),y);
-         
-         u_respond(u,tempstr);
-         
-         }
-   
-   for (i=0; i<MAXUPLDS; i++)
-      if (gdata.uploads[i] != NULL) {
-         
-         if (gdata.uploads[i]->status == 'T') y = "Connecting";
-         else if (gdata.uploads[i]->status == 'G') y = "Getting";
-         else if (gdata.uploads[i]->status == 'W') y = "Finishing";
-         else if (gdata.uploads[i]->status == 'E') y = "Error";
-         else if (gdata.uploads[i]->status == 'D') y = "Done";
-         else y = "Unknown!";
-         
-         if (gdata.uploads[i]->status == 'G') {
-            isnprintf(tempstr,maxtextlength-2,"   Ul  %-9s   %-32s   %s %2.0f%%",
-               gdata.uploads[i]->nick,getfilename(gdata.uploads[i]->file),y,
-               ((float)gdata.uploads[i]->bytesgot)*100.0/((float)gdata.uploads[i]->totalsize));
-            }
-         else
-            isnprintf(tempstr,maxtextlength-2,"   Ul  %-9s   %-32s   %s",
-               gdata.uploads[i]->nick,getfilename(gdata.uploads[i]->file),y);
-         
-         u_respond(u,tempstr);
-         
-         }
-   
-   mydelete(tempstr);
-   }
-
-static void u_dcld(const userinput * const u) {
-   char *tempstr, *tempstr2, *tempstr3, *tempstr4;
-   const char *y;
-   int i,j,left,started;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   for (j=i=0; i<MAXUPLDS; i++)
-      if (gdata.uploads[i] != NULL) j++;
-
-   if (!gdata.slotsfull && !j) {
-      u_respond(u,"No Active Transfers");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_dcld");
-   tempstr2 = mycalloc(maxtextlength,"u_dcld");
-   tempstr3 = mycalloc(maxtextlengthshort,"u_dcld");
-   tempstr4 = mycalloc(maxtextlengthshort,"u_dcld");
-
-   isnprintf(tempstr,maxtextlength-2,"Current Transfer%s",gdata.slotsfull!=1?"s":"");
-   u_respond(u,tempstr);
-   u_respond(u," ID  User        File                               Status");
-   u_respond(u,"  ^-    Speed    Current/    End   Start/Remain    Min/  Max  Resumed");
-   u_respond(u," --------------------------------------------------------------------");
-   
-   for (i=0; i<MAXTRANS; i++)
-      if (gdata.trans[i] != NULL) {
-         
-         if (gdata.trans[i]->status == 'L') y = "Listening";
-         else if (gdata.trans[i]->status == 'W') y = "Finishing";
-         else if (gdata.trans[i]->status == 'D') y = "Closing";
-         else if (gdata.trans[i]->status == 'E') y = "Error";
-         else if (gdata.trans[i]->status == 'S') y = "Sending";
-         else y = "Unknown!";
-         
-         if (gdata.trans[i]->status == 'S') {
-            isnprintf(tempstr,maxtextlength-2," %2i  %-9s   %-32s   %s %2.0f%%",
-               i,gdata.trans[i]->nick,getfilename(gdata.trans[i]->xpack->file),y,
-               ((float)gdata.trans[i]->bytessent)*100.0/((float)gdata.trans[i]->xpack->size));
-            }
-         else
-            isnprintf(tempstr,maxtextlength-2," %2i  %-9s   %-32s   %s",
-               i,gdata.trans[i]->nick,getfilename(gdata.trans[i]->xpack->file),y);
-         
-         u_respond(u,tempstr);
-         
-         if (gdata.trans[i]->status == 'S' || gdata.trans[i]->status == 'W') {
-            left = min2(359999,(gdata.trans[i]->xpack->size-gdata.trans[i]->bytessent)/((int)(max2(gdata.trans[i]->lastspeed,0.001)*1024)));
-            started = min2(359999,gdata.curtime-gdata.trans[i]->connecttime);
-            isnprintf(tempstr2,maxtextlength-2,"%1.1fK",gdata.trans[i]->xpack->minspeed);
-            isnprintf(tempstr3,maxtextlengthshort-2,"%6liK",(long)(gdata.trans[i]->startresume)/1024);
-            isnprintf(tempstr4,maxtextlengthshort-2,"%1.1fK",gdata.trans[i]->xpack->maxspeed);
-            
-            isnprintf(tempstr,maxtextlength-2,
-                "  ^- %5.1fK/s %c  %6liK/%6liK  %2i%c%02i%c/%2i%c%02i%c  %5s/%5s  %7s",
-                gdata.trans[i]->lastspeed,
-                gdata.trans[i]->needsdata > 0 ? 'L' : ' ' ,
-                (long)((gdata.trans[i]->bytessent)/1024),
-                (long)((gdata.trans[i]->xpack->size)/1024),
-                started < 3600 ? started/60 : started/60/60 ,
-                started < 3600 ? 'm' : 'h',
-                started < 3600 ? started%60 : (started/60)%60 ,
-                started < 3600 ? 's' : 'm',
-                left < 3600 ? left/60 : left/60/60 ,
-                left < 3600 ? 'm' : 'h',
-                left < 3600 ? left%60 : (left/60)%60 ,
-                left < 3600 ? 's' : 'm',
-                (gdata.trans[i]->nomin || (gdata.trans[i]->xpack->minspeed == 0.0)) ? "no" : tempstr2 ,
-                (gdata.trans[i]->nomax || (gdata.trans[i]->xpack->maxspeed == 0.0)) ? "no" : tempstr4 ,
-                gdata.trans[i]->startresume ? tempstr3 : "no"
-                );
-            u_respond(u,tempstr);
-            }
-         else {
-            isnprintf(tempstr,maxtextlength-2,
-                "  ^-    -----    -------/-------   -----/------  -----/-----      ---");
-            u_respond(u,tempstr);
-            }
-         }
-   
-   for (i=0; i<MAXUPLDS; i++)
-      if (gdata.uploads[i] != NULL) {
-         
-         if (gdata.uploads[i]->status == 'T') y = "Connecting";
-         else if (gdata.uploads[i]->status == 'G') y = "Getting";
-         else if (gdata.uploads[i]->status == 'W') y = "Finishing";
-         else if (gdata.uploads[i]->status == 'E') y = "Error";
-         else if (gdata.uploads[i]->status == 'D') y = "Done";
-         else y = "Unknown!";
-         
-         if (gdata.uploads[i]->status == 'G') {
-            isnprintf(tempstr,maxtextlength-2," Ul  %-9s   %-32s   %s %2.0f%%",
-               gdata.uploads[i]->nick,getfilename(gdata.uploads[i]->file),y,
-               ((float)gdata.uploads[i]->bytesgot)*100.0/((float)gdata.uploads[i]->totalsize));
-            }
-         else
-            isnprintf(tempstr,maxtextlength-2," Ul  %-9s   %-32s   %s",
-               gdata.uploads[i]->nick,getfilename(gdata.uploads[i]->file),y);
-         
-         u_respond(u,tempstr);
-         
-         if (gdata.uploads[i]->status == 'G' || gdata.uploads[i]->status == 'W') {
-            left = min2(359999,(gdata.uploads[i]->totalsize-gdata.uploads[i]->bytesgot)/((int)(max2(gdata.uploads[i]->lastspeed,0.001)*1024)));
-            started = min2(359999,gdata.curtime-gdata.uploads[i]->connecttime);
-            
-            isnprintf(tempstr,maxtextlength-2,
-                "  ^- %5.1fK/s    %6liK/%6liK  %2i%c%02i%c/%2i%c%02i%c  -----/-----      ---",
-                gdata.uploads[i]->lastspeed,
-                (long)((gdata.uploads[i]->bytesgot)/1024),
-                (long)((gdata.uploads[i]->totalsize)/1024),
-                started < 3600 ? started/60 : started/60/60 ,
-                started < 3600 ? 'm' : 'h',
-                started < 3600 ? started%60 : (started/60)%60 ,
-                started < 3600 ? 's' : 'm',
-                left < 3600 ? left/60 : left/60/60 ,
-                left < 3600 ? 'm' : 'h',
-                left < 3600 ? left%60 : (left/60)%60 ,
-                left < 3600 ? 's' : 'm'
-                );
-            u_respond(u,tempstr);
-            }
-         else {
-            isnprintf(tempstr,maxtextlength-2,
-                "  ^-    -----    -------/-------   -----/------  -----/-----      ---");
-            u_respond(u,tempstr);
-            }
-         
-         }
-      
-   u_respond(u," --------------------------------------------------------------------");
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   mydelete(tempstr3);
-   mydelete(tempstr4);
-   }
-
-static void u_qul(const userinput * const u) {
-   char *tempstr;
-   int i, j;
-   unsigned long rtime, lastrtime; 
-  
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.inqueue && !gdata.inslotsmaxqueue) {
-      u_respond(u,"No Users Queued");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_qul");
-   
-   u_respond(u,"Current Queue:");
-   u_respond(u,"    #Q  User        File                              Waiting     Left");
-   
-   lastrtime=0;
-   
-   /* if we are sending more than allowed, we need to skip the difference */
-   for (i=0; i<gdata.slotsfull-gdata.slotsmax; i++)
+       /* We are in a loop to display the formated stuff from the advert definition string */
+       for (a=0;a<MAXADVERTS && gdata.advert[a]!=NULL;a++)
+	 {
+	   memset(tempstr,0,maxtextlength);
+	   i=0;
+	   cptr=gdata.advert[a];
+	   nptr=tempstr;
+	   /* All strings will be null terminated.
+	      We must ensure we do no outstretch ourselves and write more than maxtextlength
+	      to the tempstring
+	   */
+	   spaceleft=maxtextlength-2;
+	   while (spaceleft>0)
+	     switch (*cptr)
+	       {
+	       case 0:
+		 spaceleft=0;
+         break;
+	       case '%':
+		 cptr++;tempstr2[0]=0;
+		 switch(capchar(*(cptr++)))
      {
-       rtime=-1;
-       for (j=0; j<MAXTRANS; j++)
-	 if (gdata.trans[j]) {
-	   int left = min2(359999,(gdata.trans[j]->xpack->size-gdata.trans[j]->bytessent)/((int)(max2(gdata.trans[j]->lastspeed,0.001)*1024)));
-	   if (left > lastrtime && left < rtime)
-	     rtime = left;
-	 }
-       if (rtime < 359999)
-	 lastrtime=rtime;
-     }
-   
-   for (i=1; i<=gdata.inqueue; i++) {
-     
-     rtime=-1;
-     for (j=0; j<MAXTRANS; j++)
-       if (gdata.trans[j]) {
-	 int left = min2(359999,(gdata.trans[j]->xpack->size-gdata.trans[j]->bytessent)/((int)(max2(gdata.trans[j]->lastspeed,0.001)*1024)));
-	 if (left > lastrtime && left < rtime)
-	   rtime = left;
-       }
-     lastrtime=rtime;
-     
-     if (rtime < 359999)
-      isnprintf(tempstr,maxtextlength-2,"   %2iM  %-9s   %-32s   %2lih%2lim   %2lih%2lim",
-         i,
-         gdata.mainqueue[i-1]->nick,
-         getfilename(gdata.mainqueue[i-1]->xpack->file),
-         (gdata.curtime-gdata.mainqueue[i-1]->queuedtime)/60/60,
-         ((gdata.curtime-gdata.mainqueue[i-1]->queuedtime)/60)%60,
-         rtime/60/60,
-         (rtime/60)%60);
-     else
-      isnprintf(tempstr,maxtextlength-2,"   %2iM  %-9s   %-32s   %2lih%2lim  Unknown",
-         i,
-         gdata.mainqueue[i-1]->nick,
-         getfilename(gdata.mainqueue[i-1]->xpack->file),
-         (gdata.curtime-gdata.mainqueue[i-1]->queuedtime)/60/60,
-         ((gdata.curtime-gdata.mainqueue[i-1]->queuedtime)/60)%60);
-
-
-      u_respond(u,tempstr);
-      }
-   
-   for (i=1; i<=gdata.inslotsmaxqueue; i++) {
-      isnprintf(tempstr,maxtextlength-2,"   %2iP  %-9s   %-32s   %2lih%2lim",
-         i,
-         gdata.packqueue[i-1]->nick,
-         getfilename(gdata.packqueue[i-1]->xpack->file),
-         (gdata.curtime-gdata.packqueue[i-1]->queuedtime)/60/60,
-         ((gdata.curtime-gdata.packqueue[i-1]->queuedtime)/60)%60);
-      u_respond(u,tempstr);
-      }
-   
-   mydelete(tempstr);
-   
-   }
-
-static void u_close(const userinput * const u) {
-   
-   int num = -1;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num > MAXTRANS-1 || num < 0 || gdata.trans[num] == NULL)
-      u_respond(u,"Invalid ID number, Try \"DCL\" for a list");
-   else
-      t_closeconn(gdata.trans[num],"Owner Requested Close");
-   
-   }
-
-static void u_nomin(const userinput * const u) {
-   
-   int num = -1;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num > MAXTRANS-1 || num < 0 || gdata.trans[num] == NULL)
-      u_respond(u,"Invalid ID number, Try \"DCL\" for a list");
-   else
-      gdata.trans[num]->nomin = 1;
-   
-   }
-
-static void u_nomax(const userinput * const u) {
-   
-   int num = -1;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num > MAXTRANS-1 || num < 0 || gdata.trans[num] == NULL)
-      u_respond(u,"Invalid ID number, Try \"DCL\" for a list");
-   else
-      gdata.trans[num]->nomax = 1;
-   
-   }
-
-static void u_rmq_rpq(const userinput * const u) {
-   int i;
-   int num = 0;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (u->cmd[1] == 'M') {
-      if ( (num > MAXQUEUE) || (num < 1) || gdata.mainqueue[num-1] == NULL )
-         u_respond(u,"Invalid ID number, Try \"QUL\" for a list");
-      else {
-         notice(gdata.mainqueue[num-1]->nick,"*** Removed From Queue: Owner Requested Remove");
-         mydelete(gdata.mainqueue[num-1]);
-         for (i=num; i<gdata.inqueue; i++)
-            gdata.mainqueue[i-1] = gdata.mainqueue[i];
-         gdata.mainqueue[i] = NULL;
-         gdata.inqueue--;
-         }
-      }
-   else if (u->cmd[1] == 'P') {
-      if ( (num > MAXQUEUE) || (num < 1) || gdata.packqueue[num-1] == NULL )
-         u_respond(u,"Invalid ID number, Try \"QUL\" for a list");
-      else {
-         notice(gdata.packqueue[num-1]->nick,"*** Removed From Queue: Owner Requested Remove");
-         mydelete(gdata.packqueue[num-1]);
-         for (i=num; i<gdata.inslotsmaxqueue; i++)
-            gdata.packqueue[i-1] = gdata.packqueue[i];
-         gdata.packqueue[i] = NULL;
-         gdata.inslotsmaxqueue--;
-         }
-      }
-   else {
-      u_respond(u,"internal iroffer error: u_rmq_rpq(): unexpected case, report problem to PMG");
-      }
-   
-   }
-
-static void u_raw(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   writeserver(u->arg1e);
-   }
-
-static void u_info(const userinput * const u) {
-   int num = 0;
-   int i,p;
-   char *tempstr, *tempstr2;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_info");
-   tempstr2 = mycalloc(maxtextlength,"u_info");
-   
-   isnprintf(tempstr,maxtextlength-2,"Pack Info for Pack #%i:",num);
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,"Gets: %i, Size: %s (%li), Min: %1.1fK/sec, Max: %1.1fK/sec, Xfered: >%liM",
-                gdata.xdccs[p]->gets,
-                sizestr(1,tempstr2,gdata.xdccs[p]->size),
-                (long)gdata.xdccs[p]->size,
-                gdata.xdccs[p]->minspeed,
-                gdata.xdccs[p]->maxspeed,
-	        (long)(((double)gdata.xdccs[p]->gets)*((double)gdata.xdccs[p]->size)/1024.0/1024.0));
-   u_respond(u,tempstr);
-   isnprintf(tempstr,maxtextlength-2,"Filename:    %s",gdata.xdccs[p]->file);
-   u_respond(u,tempstr);
-   isnprintf(tempstr,maxtextlength-2,"Description: %s",gdata.xdccs[p]->desc);
-   u_respond(u,tempstr);
-   isnprintf(tempstr,maxtextlength-2,"Note:        %s",gdata.xdccs[p]->note);
-   u_respond(u,tempstr);
-   
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   }
-
-static void u_remove(const userinput * const u) {
-   int i,p;
-   int num = 0;
-   char *tempstr;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if ( num < 1 || num > gdata.numpacks ) {
-      u_respond(u,"Try a valid pack number");
-      return;
-      }
-/*   if ( gdata.numpacks == 1 ) { */
-/*      u_respond(u,"You must offer at least one pack"); */
-/*      return; */
-/*      } */
-   
-   tempstr = mycalloc(maxtextlength,"u_remove");
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   isnprintf(tempstr,maxtextlength-2,"Removed Pack %i [%s]",
-      num,gdata.xdccs[p]->desc);
-   u_respond(u,tempstr);
-   
-   /* removed pack is leaked for now */
-   for (i=p+1; i<=gdata.numpacks; i++)
-      gdata.xdccs[i-1] = gdata.xdccs[i];
-   
-   gdata.numpacks--;
-   xdccsave(0);
-   
-   mydelete(tempstr);
-   }
-
-static void u_redraw(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   initscreen();
-   gotobot();
-   }
-
-static void u_send(const userinput * const u) {
-   int num = 0;
-   char *tempstr;
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg2) num = atoi(u->arg2);
-   
-   if (!u->arg1 || !strlen(u->arg1)) {
-      u_respond(u,"Try Specifying a Nick");
-      return;
-      }
-   
-   if (num > gdata.numpacks || num < 1) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_send");
-   
-   isnprintf(tempstr,maxtextlength-2,"Sending %s pack %i",u->arg1,num);
-   u_respond(u,tempstr);
-   
-   sendxdccfile(u->arg1,"man",num,NULL);
-   
-   mydelete(tempstr);
-   }
-
-static void u_psend(const userinput * const u) {
-   char *tempstr;
-   userinput manplist;
-  
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1 || !strlen(u->arg1)) {
-      u_respond(u,"Try Specifying a Channel");
-      return;
-      }
-   
-   u_fillwith_msg(&manplist,u->arg1,"A A A A A xdl");
-   manplist.method = method_xdl_channel;
-   u_parseit(&manplist);
-   
-   tempstr = mycalloc(maxtextlength,"u_psend");
-   isnprintf(tempstr,maxtextlength-2,"Sending PLIST to %s",u->arg1);
-   mydelete(tempstr);
-   
-   }
-
-static void u_mesg(const userinput * const u) {
-   int i;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1e || !strlen(u->arg1e)) {
-      u_respond(u,"Try Specifying a Message");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_mesg");
-   for (i=0; i<MAXTRANS; i++)
-      if (gdata.trans[i] != NULL) {
-      notice(gdata.trans[i]->nick,"MESSAGE FROM OWNER: %s",u->arg1e);
+		   case 'A': /* Number of slots in use */
+		     isnprintf(tempstr2, maxtextlength-1, "%i", gdata.slotsfull);
+		     break;
+		   case 'B': /* Totle slots */
+		     isnprintf(tempstr2, maxtextlength-1, "%i", gdata.slotsmax);
+         break;
+		   case 'C': /* Number in queue */
+		     isnprintf(tempstr2, maxtextlength-1, "%i", gdata.inqueue);		     
+		     break;
+		   case 'D': /* Size of queue */
+		     isnprintf(tempstr2, maxtextlength-1, "%i", gdata.queuesize);
+		     break;
+		   case 'E': /* number in packs queue */
+		     isnprintf(tempstr2, maxtextlength-1, "%i", gdata.inslotsmaxqueue);
+		     b    strncpy(tempstr1,line,maxtextlength-1);
+      for (i=strlen(u->cmd)+1; i<=sstrlen(line); i++)
+         tempstr1[i-strlen(u->cmd)-1] = tempstr1[i];
       }
-   isnprintf(tempstr,maxtextlength-2,"Sent message to %i user%s",gdata.slotsfull,gdata.slotsfull!=1?"s":"");
-   u_respond(u,tempstr);
+   u->arg1e = tempstr1;
    
-   mydelete(tempstr);
+   strncpy(tempstr2,"",maxtextlength-1);
+   if (u->arg1 && u->arg2) {
+      strncpy(tempstr2,line,maxtextlength-1);
+      for (i=sstrlen(u->cmd)+sstrlen(u->arg1)+2; i<=sstrlen(line); i++)
+         tempstr2[i-strlen(u->cmd)-strlen(u->arg1)-2] = tempstr2[i];
    }
+   u->arg2e = tempstr2;
 
-static void u_mesq(const userinput * const u) {
-   int i,count;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1e || !strlen(u->arg1e)) {
-      u_respond(u,"Try Specifying a Message");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_mesq");
-
-   count=0;
-   for (i=1; i<=gdata.inqueue; i++) {
-      notice(gdata.mainqueue[i-1]->nick,"MESSAGE FROM OWNER: %s",u->arg1e);
-      count++;
       }
-   for (i=1; i<=gdata.inslotsmaxqueue; i++) {
-      notice(gdata.packqueue[i-1]->nick,"MESSAGE FROM OWNER: %s",u->arg1e);
-      count++;
-      }
-   isnprintf(tempstr,maxtextlength-2,"Sent message to %i user%s",count,count!=1?"s":"");
-   u_respond(u,tempstr);
    
-   mydelete(tempstr);
-   }
-
-static void u_closedcc(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-      ioutput(0,OUT_S|OUT_L,"0;35","DCC CHAT: QUIT");
-      writedccchat("Bye.");
-      FD_CLR(gdata.dccchat, &gdata.readset);
-      msleep(100);
-      close(gdata.dccchat);
-      gdata.dccchat = 1000;
-      highestsock();
-   }
-
-static void u_status(const userinput * const u) {
-   char *tempstr = mycalloc(maxtextlength,"u_status");
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   getstatusline(tempstr);
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   }
-
-static void u_chfile(const userinput * const u) {
-   int num = 0;
-   char *tempstr;
-   int i,p,xfiledescriptor;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   if (u->arg3) {
-      u_respond(u,"Filenames can't contain spaces");
-      return;
-      }
-
-   if (!u->arg2 || !strlen(u->arg2)) {
-      u_respond(u,"Try Specifying a Filename");
-      return;
-      }
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   for (i=0; gdata.xdccs[i]; i++) ;
-   gdata.xdccs[i] = mycalloc(sizeof(xdcc),"u_chfile");
-   
-   strncpy(gdata.xdccs[i]->file,u->arg2,maxtextlength-1);
-   strncpy(gdata.xdccs[i]->desc,gdata.xdccs[p]->desc,maxtextlength-1);
-   if ( strlen(gdata.xdccs[p]->note) )
-      strncpy(gdata.xdccs[i]->note,gdata.xdccs[p]->note,maxtextlength-1);
-   else
-      strncpy(gdata.xdccs[i]->note,"",maxtextlength-1);
-   
-   gdata.xdccs[i]->gets = gdata.xdccs[p]->gets;
-   
-   gdata.xdccs[i]->minspeed = gdata.overallminspeed;
-   if ( gdata.xdccs[p]->minspeed != gdata.overallminspeed )
-      gdata.xdccs[i]->minspeed = gdata.xdccs[p]->minspeed;
-
-   gdata.xdccs[i]->maxspeed = gdata.transfermaxspeed;
-   if ( gdata.xdccs[p]->maxspeed != gdata.transfermaxspeed )
-      gdata.xdccs[i]->maxspeed = gdata.xdccs[p]->maxspeed;
-
-   xfiledescriptor=open(gdata.xdccs[i]->file, O_RDONLY | ADDED_OPEN_FLAGS);
-   
-   if (xfiledescriptor < 0 && gdata.filedir) {
-      isnprintf(gdata.xdccs[i]->file,maxtextlength-2,"%s/%s",gdata.filedir,u->arg2);
-      xfiledescriptor=open(gdata.xdccs[i]->file, O_RDONLY | ADDED_OPEN_FLAGS);
-      }
-   
-   if (xfiledescriptor < 0) {
-      u_respond(u,"File Could Not Be Opened Or Read");
-      mydelete(gdata.xdccs[i]);
-      return;
-      }
-   
-   gdata.xdccs[i]->size = lseek(xfiledescriptor, 0, SEEK_END);
-   
-   if ( gdata.xdccs[i]->size == 0 ) {
-      u_respond(u,"File has size of 0 bytes!");
-      mydelete(gdata.xdccs[i]);
-      return;
-      }
-   
-   close(xfiledescriptor);
-   
-   tempstr = mycalloc(maxtextlength,"u_chfile");
-   isnprintf(tempstr,maxtextlength-2,
-      "CHFILE: [Pack %i] Old: %s New: %s",
-      num,gdata.xdccs[p]->file,gdata.xdccs[i]->file);
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-
-   /* old is leaked for now */
-   gdata.xdccs[p] = gdata.xdccs[i];
-   gdata.xdccs[i] = NULL;
-   
-   xdccsave(0);
-   
-   }
-
-static void u_add(const userinput * const u) {
-   int i,xfiledescriptor;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1 || !strlen(u->arg1)) {
-      u_respond(u,"Try Specifying a Filename");
-      return;
-      }
-   
-   if (u->arg2) {
-      u_respond(u,"Filenames can't contain spaces");
-      return;
-      }
-   
-   for (i=0; gdata.xdccs[i]; i++) ;
-   
-   if (i==MAXXDCCS) {
-      u_respond(u,"Max Number of Packs Reached");
-      return;
-      }
-   
-   gdata.xdccs[i] = mycalloc(sizeof(xdcc),"u_add");
-   
-   strncpy(gdata.xdccs[i]->file,u->arg1,maxtextlength-1);
-   strncpy(gdata.xdccs[i]->note,"",maxtextlength-1);
-   strncpy(gdata.xdccs[i]->desc,"no description (",maxtextlength-1);
-   strncat(gdata.xdccs[i]->desc,u->arg1,sizeof(gdata.xdccs[i]->desc)-strlen(gdata.xdccs[i]->desc)-1);
-   strncat(gdata.xdccs[i]->desc,")",sizeof(gdata.xdccs[i]->desc)-strlen(gdata.xdccs[i]->desc)-1);
-   
-   gdata.xdccs[i]->gets = 0;
-   gdata.xdccs[i]->minspeed = gdata.overallminspeed;
-   gdata.xdccs[i]->maxspeed = gdata.transfermaxspeed;
-
-   xfiledescriptor=open(gdata.xdccs[i]->file, O_RDONLY | ADDED_OPEN_FLAGS);
-   
-   if (xfiledescriptor < 0 && gdata.filedir) {
-      isnprintf(gdata.xdccs[i]->file,maxtextlength-2,"%s/%s",gdata.filedir,u->arg1);
-      xfiledescriptor=open(gdata.xdccs[i]->file, O_RDONLY | ADDED_OPEN_FLAGS);
-      }
-   
-   if (xfiledescriptor < 0) {
-      u_respond(u,"File Could Not Be Opened Or Read");
-      mydelete(gdata.xdccs[i]);
-      return;
-      }
-   
-   gdata.xdccs[i]->size = lseek(xfiledescriptor, 0, SEEK_END);
-   
-   if ( gdata.xdccs[i]->size == 0 ) {
-      u_respond(u,"File has size of 0 bytes!");
-      mydelete(gdata.xdccs[i]);
-      return;
-      }
-   
-   close(xfiledescriptor);
-   
-   gdata.numpacks++;
-   
-   tempstr = mycalloc(maxtextlength,"u_add");
-   isnprintf(tempstr,maxtextlength-2,
-      "ADD PACK: [Pack: %i] [File: %s] Use CHDESC to change description",
-      gdata.numpacks,gdata.xdccs[i]->file);
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   xdccsave(0);
-   
-   }
-
-static void u_adddir(const userinput * const u) {
-   int count=0;
-   DIR *d;
-   struct dirent *f;
-   char *tempstr, *thedir;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1 || !strlen(u->arg1)) {
-      u_respond(u,"Try Specifying a Directory");
-      return;
-      }
-   
-   if (u->arg2) {
-      u_respond(u,"No spaces please");
-      return;
-      }
-   
-   if (u->arg1[strlen(u->arg1)-1] == '/') u->arg1[strlen(u->arg1)-1] = '\0';
-   if (u->arg1[strlen(u->arg1)-1] == '\\') u->arg1[strlen(u->arg1)-1] = '\0';
-   
-   thedir = mycalloc(maxtextlength,"u_adddir");
-   strncpy(thedir,u->arg1,maxtextlength-1);
-   
-   d = opendir(thedir);
-   
-   if (!d && gdata.filedir) {
-      isnprintf(thedir,maxtextlength-2,"%s/%s",gdata.filedir,u->arg1);
-      d = opendir(thedir);
-      }
-   
-   if (!d) {
-      u_respond(u,"Couldn't Read Directory.");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_adddir");
-   
-   isnprintf(tempstr,maxtextlength-2,"Adding contents of %s...",thedir);
-   u_respond(u,tempstr);
-   
-   while ((f = readdir(d))) {
-      if (strcmp(".",f->d_name) && strcmp("..",f->d_name)) {
-         count++;
-         isnprintf(tempstr,maxtextlength-2,"  Adding %s:",f->d_name);
-         u_respond(u,tempstr);
-         isnprintf(tempstr,maxtextlength-2,"%s/%s",thedir,f->d_name);
-         strncpy(u->arg1,tempstr,maxtextlength-1);
-         u_add(u);
-         }
-      }
-   
-   isnprintf(tempstr,maxtextlength-2,"Total of %i files added",count);
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   mydelete(thedir);
-   closedir(d);
-   
-   }
-
-static void u_chdesc(const userinput * const u) {
-   int num = 0;
-   int i,p;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   if (!u->arg2e || !strlen(u->arg2e)) {
-      u_respond(u,"Try Specifying a Description");
-      return;
-      }
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_chdesc");
-   isnprintf(tempstr,maxtextlength-2,
-      "CHDESC: [Pack %i] Old: %s New: %s",
-      num,gdata.xdccs[p]->desc,u->arg2e);
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   strncpy(gdata.xdccs[p]->desc,u->arg2e,maxtextlength-1);
-   
-   xdccsave(0);
-   
-   }
-
-static void u_chnote(const userinput * const u) {
-   int num = 0;
-   int i,p;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_chnote");
-   isnprintf(tempstr,maxtextlength-2,
-      "CHNOTE: [Pack %i] Old: %s New: %s",
-      num,gdata.xdccs[p]->note,u->arg2e);
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   if (!u->arg2e || !strlen(u->arg2e)) 
-      strncpy(gdata.xdccs[p]->note,"",maxtextlength-1);
-   else
-      strncpy(gdata.xdccs[p]->note,u->arg2e,maxtextlength-1);
-   
-   xdccsave(0);
-   
-   }
-
-static void u_chmins(const userinput * const u) {
-   int num = 0;
-   int i,p;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   if (!u->arg2 || !strlen(u->arg2)) {
-      u_respond(u,"Try Specifying a Minspeed");
-      return;
-      }
-
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_chmins");
-   isnprintf(tempstr,maxtextlength-2,
-      "CHMINS: [Pack %i] Old: %1.1f New: %1.1f",
-      num,gdata.xdccs[p]->minspeed,atof(u->arg2));
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   gdata.xdccs[p]->minspeed = gdata.overallminspeed;
-   if ( atof(u->arg2) != gdata.overallminspeed )
-      gdata.xdccs[p]->minspeed = atof(u->arg2);
-   
-   xdccsave(0);
-   
-   }
-
-static void u_chmaxs(const userinput * const u) {
-   int num = 0;
-   int i,p;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   if (num < 1 || num > gdata.numpacks) {
-      u_respond(u,"Try Specifying a Valid Pack Number");
-      return;
-      }
-   
-   if (!u->arg2 || !strlen(u->arg2)) {
-      u_respond(u,"Try Specifying a Maxspeed");
-      return;
-      }
-
-   for (i=1, p=0; i<=gdata.numpacks; i++, p++) {
-      while (gdata.xdccs[p] == NULL)
-         p++;
-      if ( i == num )
-         break;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_chmaxs");
-   isnprintf(tempstr,maxtextlength-2,
-      "CHMAXS: [Pack %i] Old: %1.1f New: %1.1f",
-      num,gdata.xdccs[p]->maxspeed,atof(u->arg2));
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   gdata.xdccs[p]->maxspeed = gdata.transfermaxspeed;
-   if ( atof(u->arg2) != gdata.transfermaxspeed )
-      gdata.xdccs[p]->maxspeed = atof(u->arg2);
-   
-   xdccsave(0);
-   
-   }
-
-static void u_chatme(const userinput * const u) {
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   u_respond(u,"Sending You A DCC Chat Request");
-   
-   if (setupdccchatout(u->snick))
-      u_respond(u,"[Failed to listen, try again]");
-   
-   
-   }
-
-static void u_rehash(const userinput * const u) {
-   
-   /* other variables */
-   char *templine = mycalloc(maxtextlength,"u_rehash_templine");
-   char *tempc = mycalloc(2,"u_rehash_tempc");
-   int h,i,j,k,found,filedescriptor,needtojump;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->method==method_out_all) u_respond(u,"Caught SIGUSR2, Rehashing...");
-   
-   /* clear old config items */
-   for (i=0; i<MAXAHOST; i++)
-      mydelete(gdata.adminhost[i]);
-   for (i=0; i<MAXSRVS; i++)
-      mydelete(gdata.server[i]);
-   for (i=0; i<MAXCHNLS; i++)
-      gdata.t_channel[i] = gdata.r_channel[i] = NULL;
-   
-   gdata.r_overallminspeed = gdata.overallminspeed;
-   gdata.r_transfermaxspeed = gdata.transfermaxspeed;
-   
-   mydelete(gdata.logfile);
-   gdata.logrotate = gdata.logstats = 0;
-   mydelete(gdata.ignorefile);
-   mydelete(gdata.messagefile);
-   mydelete(gdata.user_realname);
-   mydelete(gdata.user_modes);
-   gdata.firewall = 0;
-   gdata.dccrangestart = 4000;
-   mydelete(gdata.proxyinfo);
-   mydelete(gdata.proxyinfo2);
-   gdata.usenatip = 0;
-   gdata.slotsmax = gdata.queuesize = gdata.slotsmaxpack = gdata.slotsmaxslots = gdata.slotsmaxqueue = 0;
-   gdata.maxtransfersperperson = 1;
-   gdata.maxqueueditemsperperson = 1;
-   mydelete(gdata.filedir);
-   gdata.lowbdwth = 0;
-   gdata.overallminspeed = gdata.transfermaxspeed = 0.0;
-   gdata.overallmaxspeed = gdata.overallmaxspeeddayspeed = 0;
-   gdata.overallmaxspeeddaytimestart = gdata.overallmaxspeeddaytimeend = 0;
-   gdata.overallmaxspeeddaydays = 0x7F; /* all days */
-   gdata.debug = gdata.debug2 = 0;
-   gdata.autosend = gdata.autopack = 0;
-   mydelete(gdata.autoword);
-   mydelete(gdata.automsg);
-   gdata.xdccautosavetime = 0;
-   mydelete(gdata.creditline);
-   mydelete(gdata.periodicmsg_nick);
-   mydelete(gdata.periodicmsg_msg);
-   gdata.periodicmsg_time = 0;
-   gdata.uploadallowed = gdata.uploadmaxsize = 0;
-   mydelete(gdata.uploaddir);
-   gdata.restrictlist = gdata.restrictsend = 0;
-   
-   mydelete(gdata.loginname);
-   set_loginname();
-   
-   /* go */
-   gdata.highmeminfo=1;
-   
-   for (h=0; h<MAXCONFIG && gdata.configfile[h]; h++) {
-      isnprintf(templine,maxtextlength-2,"Reloading %s ...",gdata.configfile[h]);
-      u_respond(u,templine);
-      
-      filedescriptor=open(gdata.configfile[h], O_RDONLY | ADDED_OPEN_FLAGS);
-      if (filedescriptor < 0) {
-         u_respond(u,"Couldn't Open Config File, Aborting rehash");
-         u_respond(u,"***WARNING*** missing vital information, fix and re-rehash ASAP");
-         mydelete(templine);
-         mydelete(tempc);
-         return;
-         }
-   
-      i = 0;
-      while(read(filedescriptor,tempc,1) == 1) {
-         if (tempc[0] == '\n' || tempc[0] == 13) {  /* 13 is ^M */
-            templine[i] = '\0';
-            if ( templine[0] != '#' && strlen(templine) != 0 ) {
-               for (i=strlen(templine)-1; i>2 && templine[i] == ' '; i--)
-                  templine[i] = '\0';
-               getconfig_set(templine,1);
-               }
-            i = 0;
-            }
-         else {
-            templine[i] = tempc[0];
-            i++;
-            }
-         }
-      }
-   
-   /* see what needs to be redone */
-   
-   u_respond(u,"Reconfiguring...");
-   
-   needtojump=0;
-   if ( gdata.virthost != gdata.r_virthost ||
-       (gdata.virthost && gdata.r_virthost && gdata.vhost_ip && gdata.r_vhost_ip && strcmp(gdata.vhost_ip,gdata.r_vhost_ip)) )
-      needtojump=1;
-   
-   k=0;
-   /* part deleted channels, add common channels */
-   for (i=0; i<MAXCHNLS && gdata.channels[i]; i++) {
-      found = 0;
-      for (j=0; j<MAXCHNLS && gdata.r_channel[j] && !found; j++)
-         if (!strcmp(gdata.channels[i]->name,gdata.r_channel[j]->name)) found = 1;
-      j--;
-      if (!found) {
-         isnprintf(templine,maxtextlength-2,"PART %s",gdata.channels[i]->name);
-         if (!needtojump) writeserver(templine);
-	 clearmemberlist(gdata.channels[i]);
-         if (PRINTCHAN) printf("1 channels[%i] = %s parted\n",i,gdata.channels[i]->name);
-         }
-      else {
-         gdata.t_channel[k] = mycalloc(sizeof(channel_t),"u_rehash_t_channel[k]");
-         memcpy(gdata.t_channel[k],gdata.r_channel[j],sizeof(channel_t));
-         gdata.t_channel[k]->flags |= gdata.channels[i]->flags & CHAN_ONCHAN;
-	 gdata.t_channel[k]->members = gdata.channels[i]->members;
-	 if (PRINTCHAN) printf("2 t_channel[%i] <- r_channel[%i] = %s common\n",k,i,gdata.channels[i]->name);
-         k++;
-         }
-      }
-   
-   /* join/add new channels */
-   for (i=0; i<MAXCHNLS && gdata.r_channel[i]; i++) {
-      found = 0;
-      for (j=0; j<MAXCHNLS && gdata.channels[j]; j++)
-         if (!strcmp(gdata.r_channel[i]->name,gdata.channels[j]->name)) found = 1;
-      if (!found) {
-         gdata.t_channel[k] = mycalloc(sizeof(channel_t),"u_rehash_t_channel[k]");
-         memcpy(gdata.t_channel[k],gdata.r_channel[i],sizeof(channel_t));
-         if (!needtojump) joinchannel(gdata.t_channel[k]);
-         gdata.t_channel[k]->flags &= ~CHAN_ONCHAN;
-         if (PRINTCHAN) printf("3 t_channel[%i] <- r_channel[%i] = %s new\n",k,i,gdata.r_channel[i]->name);
-         k++;
-         }
-      }
-   
-   /* kill old channel lists */
-   for (i=0; i<MAXCHNLS && gdata.channels[i]; i++)
-      mydelete(gdata.channels[i]);
-   for (i=0; i<MAXCHNLS && gdata.r_channel[i]; i++)
-      mydelete(gdata.r_channel[i]);
-   
-   /* switch to new channel list */
-   for (i=0; i<MAXCHNLS && gdata.t_channel[i]; i++) {
-      gdata.channels[i] = gdata.t_channel[i];
-      gdata.t_channel[i] = NULL;
-      
-      if (PRINTCHAN) printf("4 channels[%i] = %s\n",i,gdata.channels[i]->name);
-      }
-   
-   if (needtojump) {
-      u_respond(u,"vhost changed, reconnecting");
-      mydelete(gdata.vhost_ip);
-      gdata.vhost_ip = gdata.r_vhost_ip;
-      gdata.r_vhost_ip = NULL;
-      gdata.virthost = gdata.r_virthost;
-      switchserver(-1);
-      /* switchserver takes care of joining channels */
-      }
-   else {
-      mydelete(gdata.vhost_ip);
-      gdata.vhost_ip = gdata.r_vhost_ip;
-      gdata.r_vhost_ip = NULL;
-      gdata.virthost = gdata.r_virthost;
-      }
-   
-   if (strcmp(gdata.pidfile,gdata.r_pidfile)) {
-      u_respond(u,"pidfile changed, switching");
-      unlink(gdata.pidfile);
-      writepidfile(gdata.r_pidfile);
-      }
-   mydelete(gdata.pidfile);
-   gdata.pidfile = gdata.r_pidfile;
-   gdata.r_pidfile = NULL;
-   
-   if (strcmp(gdata.user_nick,gdata.r_user_nick)) {
-      u_respond(u,"user_nick changed, renaming");
-      isnprintf(templine,maxtextlength-2,"NICK %s",gdata.r_user_nick);
-      writeserver2(templine,1);
-      }
-   mydelete(gdata.user_nick);
-   gdata.user_nick = gdata.r_user_nick;
-   gdata.r_user_nick = NULL;
-   strncpy(gdata.caps_nick,gdata.user_nick,maxtextlengthshort-1);
-   caps(gdata.caps_nick);
-   
-   
-   if (strcmp(gdata.xdccfile,gdata.r_xdccfile))
-      u_respond(u,"sorry, changing xdccfile is yet implemented");
-   mydelete(gdata.r_xdccfile);
-   
-   
-   gdata.maxb = gdata.overallmaxspeed;
-   if (gdata.overallmaxspeeddayspeed != gdata.overallmaxspeed) {
-      struct tm *localt;
-      localt = localtime(&gdata.curtime);
-
-      if (localt->tm_hour >= gdata.overallmaxspeeddaytimestart
-          && localt->tm_hour < gdata.overallmaxspeeddaytimeend
-          && ( gdata.overallmaxspeeddaydays & (1 << localt->tm_wday)) )
-         gdata.maxb = gdata.overallmaxspeeddayspeed;
-      }
-   
-   if ( gdata.r_overallminspeed != gdata.overallminspeed)
-      for (i=0; i<MAXXDCCS; i++)
-         if (gdata.xdccs[i] && (gdata.xdccs[i]->minspeed == gdata.r_overallminspeed))
-            gdata.xdccs[i]->minspeed = gdata.overallminspeed;
-   
-   if ( gdata.r_transfermaxspeed != gdata.transfermaxspeed)
-      for (i=0; i<MAXXDCCS; i++)
-         if (gdata.xdccs[i] && (gdata.xdccs[i]->maxspeed == gdata.r_transfermaxspeed))
-            gdata.xdccs[i]->maxspeed = gdata.transfermaxspeed;
-   
-   /* check for completeness */
-   u_respond(u,"Checking for completeness of config file ...");
-   
-   if ( gdata.server[0] == NULL
-        || gdata.user_nick == NULL || gdata.user_realname == NULL
-        || gdata.user_modes == NULL || gdata.channels[0] == NULL
-        || gdata.slotsmax == 0 || gdata.xdccautosavetime == 0 || gdata.xdccfile == 0)
-      u_respond(u,"***WARNING*** missing vital information, fix and re-rehash ASAP");
-   
-   if ( gdata.autosend && ( gdata.autoword == NULL || gdata.automsg == NULL || !gdata.autopack ) )
-      u_respond(u,"***WARNING*** incomplete autosend information, fix and re-rehash ASAP");
-   
-   if ( gdata.uploadallowed && ( gdata.uploaddir == NULL || strlen(gdata.uploaddir) < 2 ) )
-      u_respond(u,"***WARNING*** incomplete upload information, fix and re-rehash ASAP");
-      
-   u_respond(u,"Done.");
-   
-   for (i=0; i<100; i++)
-      if (!gdata.exiting && (gdata.inqueue || gdata.inslotsmaxqueue) && (gdata.slotsfull < gdata.slotsmax))
-         sendaqueue(0);
-   
-   gdata.highmeminfo=0;
-   
-   mydelete(tempc);
-   mydelete(templine);
-
-   }
-
-static void u_botinfo(const userinput * const u) {
-   char *tempstr = mycalloc(maxtextlength,"u_botinfo");
-   char *tempstr2 = mycalloc(maxtextlength,"u_botinfo");
-   int i;
-   struct rusage r;
-
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   u_respond(u,"BotInfo:");
-   
-   isnprintf(tempstr,maxtextlength-2,"iroffer v%s [%s] By PMG, http://iroffer.org/ - %s"
-           ,VERSION,VERSIONDATE,gdata.osstring);
-   u_respond(u,tempstr);
-
-   getuptime(tempstr2,0,gdata.startuptime);
-   isnprintf(tempstr,maxtextlength-2,"iroffer started up %s ago",tempstr2);
-   u_respond(u,tempstr);
-
-   getuptime(tempstr2,0,gdata.curtime-gdata.totaluptime);
-   isnprintf(tempstr,maxtextlength-2,"total running time of %s",tempstr2);
-   u_respond(u,tempstr);
-
-   getrusage(RUSAGE_SELF,&r);
-   
-   isnprintf(tempstr,maxtextlength-2,"cpu usage: %2.2fs user (%2.5f%%), %2.2fs system (%2.5f%%)",
-                  ((float)r.ru_utime.tv_sec+(((float)r.ru_utime.tv_usec)/1000000.0)),
-            100.0*((float)r.ru_utime.tv_sec+(((float)r.ru_utime.tv_usec)/1000000.0))/((float)(max2(1,gdata.curtime-gdata.startuptime))),
-                  ((float)r.ru_stime.tv_sec+(((float)r.ru_stime.tv_usec)/1000000.0)),
-            100.0*((float)r.ru_stime.tv_sec+(((float)r.ru_stime.tv_usec)/1000000.0))/((float)(max2(1,gdata.curtime-gdata.startuptime)))
-            );
-   u_respond(u,tempstr);
-
-   isnprintf(tempstr,maxtextlength-2,"nick: %s, realname: %s, modes: %s",gdata.user_nick,gdata.user_realname,gdata.user_modes);
-   u_respond(u,tempstr);
-   
-   switch (gdata.connectionmethod.how) {
-    case how_direct:
-       isnprintf(tempstr,maxtextlength-2,"current server: %s %s (direct)",
-       gdata.curserverip,gdata.curserverport);
-       break;
-    case how_bnc:
-       if (gdata.connectionmethod.vhost[0])
-          isnprintf(tempstr,maxtextlength-2,"current server: %s %s (bnc at %s:%i with %s)",
-          gdata.curserverip,gdata.curserverport,gdata.connectionmethod.host,gdata.connectionmethod.port,gdata.connectionmethod.vhost);
-       else
-          isnprintf(tempstr,maxtextlength-2,"current server: %s %s (bnc at %s:%i)",
-          gdata.curserverip,gdata.curserverport,gdata.connectionmethod.host,gdata.connectionmethod.port);
-       break;
-    case how_wingate:
-       isnprintf(tempstr,maxtextlength-2,"current server: %s %s (wingate at %s:%i)",
-       gdata.curserverip,gdata.curserverport,gdata.connectionmethod.host,gdata.connectionmethod.port);
-       break;
-    case how_custom:
-       isnprintf(tempstr,maxtextlength-2,"current server: %s %s (custom at %s:%i)",
-       gdata.curserverip,gdata.curserverport,gdata.connectionmethod.host,gdata.connectionmethod.port);
-       break;
-    }
-
-   u_respond(u,tempstr);
-   
-   for (i=0; gdata.channels[i] && i<MAXCHNLS; i++) {
-      isnprintf(tempstr,maxtextlength-2,"channel %10s: joined: %3s",
-               gdata.channels[i]->name,gdata.channels[i]->flags & CHAN_ONCHAN ? "yes" : "no ");
-      
-      if (strlen(gdata.channels[i]->key)) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, key: %s",tempstr,
-                  gdata.channels[i]->key);
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-               
-      if (gdata.channels[i]->plisttime) {
-         isnprintf(tempstr2,maxtextlength-2,"%s, plist every %2i min (%s)",tempstr,
-                  gdata.channels[i]->plisttime,
-                  gdata.channels[i]->flags & CHAN_MINIMAL ? "minimal" : (gdata.channels[i]->flags & CHAN_SUMMARY ? "summary" : "full"));
-         strncpy(tempstr,tempstr2,maxtextlength-1);
-         }
-      
-      u_respond(u,tempstr);
-      }
-   
-   isnprintf(tempstr,maxtextlength-2,
-            "bandwidth: lowsend: %i, minspeed: %1.1f, maxspeed: %1.1f, overallmaxspeed: %i",
-            gdata.lowbdwth,gdata.overallminspeed,gdata.transfermaxspeed,gdata.maxb/4);
-   u_respond(u,tempstr);
-   
-   if (gdata.overallmaxspeed != gdata.overallmaxspeeddayspeed)
-      isnprintf(tempstr,maxtextlength-2,
-            "           default max: %i, day max: %i ( %i:00 -> %i:59, days=\"%s%s%s%s%s%s%s\" )",
-            gdata.overallmaxspeed/4,gdata.overallmaxspeeddayspeed/4,
-            gdata.overallmaxspeeddaytimestart,gdata.overallmaxspeeddaytimeend-1,
-            (gdata.overallmaxspeeddaydays & (1 << 1)) ? "M":"",
-            (gdata.overallmaxspeeddaydays & (1 << 2)) ? "T":"",
-            (gdata.overallmaxspeeddaydays & (1 << 3)) ? "W":"",
-            (gdata.overallmaxspeeddaydays & (1 << 4)) ? "R":"",
-            (gdata.overallmaxspeeddaydays & (1 << 5)) ? "F":"",
-            (gdata.overallmaxspeeddaydays & (1 << 6)) ? "S":"",
-            (gdata.overallmaxspeeddaydays & (1 << 0)) ? "U":"");
-   else
-      isnprintf(tempstr,maxtextlength-2,
-            "           default max: %i, day max: (same)",
-            gdata.overallmaxspeed/4);
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,
-            "files: xdcc: %s, pid: %s, log: %s, msg: %s, ignl: %s",
-            (gdata.xdccfile?gdata.xdccfile:"(none)"),
-            (gdata.pidfile?gdata.pidfile:"(none)"),
-            (gdata.logfile?gdata.logfile:"(none)"),
-            (gdata.messagefile?gdata.messagefile:"(none)"),
-            (gdata.ignorefile?gdata.ignorefile:"(none)"));
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,
-            "config file%s: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
-            gdata.configfile[1]?"s":"",
-            gdata.configfile[0],
-            gdata.configfile[1]?", ":"",gdata.configfile[1]?gdata.configfile[1]:"",
-            gdata.configfile[2]?", ":"",gdata.configfile[2]?gdata.configfile[2]:"",
-            gdata.configfile[3]?", ":"",gdata.configfile[3]?gdata.configfile[3]:"",
-            gdata.configfile[4]?", ":"",gdata.configfile[4]?gdata.configfile[4]:"",
-            gdata.configfile[5]?", ":"",gdata.configfile[5]?gdata.configfile[5]:"",
-            gdata.configfile[6]?", ":"",gdata.configfile[6]?gdata.configfile[6]:"",
-            gdata.configfile[7]?", ":"",gdata.configfile[7]?gdata.configfile[7]:"",
-            gdata.configfile[8]?", ":"",gdata.configfile[8]?gdata.configfile[8]:"",
-            gdata.configfile[9]?", ":"",gdata.configfile[9]?gdata.configfile[9]:""
-            );
-   u_respond(u,tempstr);
-   
-   if (gdata.uploadallowed) {
-      isnprintf(tempstr2,maxtextlength-2,"%iMB",gdata.uploadmaxsize/1024/1024);
-      isnprintf(tempstr,maxtextlength-2,
-               "upload allowed, dir: %s, max size: %s",
-               gdata.uploaddir,gdata.uploadmaxsize?tempstr2:"none");
-      u_respond(u,tempstr);
-      }
-   
-   if (gdata.delayedshutdown) {
-      u_respond(u,"NOTICE: Delayed shutdown activated, iroffer will shutdown once there are no active transfers");
-      u_respond(u,"NOTICE: To cancel the delayed shutdown, issue \"SHUTDOWN CANCEL\"");
-      }
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   }
-
-
-static void u_ignl(const userinput * const u) {
-   int i,haveignored,left,ago;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   haveignored=0;
-   for (i=0; i<MAXIGNL && gdata.ignorelist[i]; i++)
-      if (gdata.ignorelist[i]->flags & IGN_IGNORING) haveignored++;
-   
-   if (!haveignored) {
-      u_respond(u,"No Hosts Ignored");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_ignl");
-   
-   isnprintf(tempstr,maxtextlength-2,"Current Ignore%s:",haveignored!=1?"s":"");
-   u_respond(u,tempstr);
-   u_respond(u,"   Last Request  Un-Ignore     Type   Hostname");
-   
-   for (i=0; i<MAXIGNL && gdata.ignorelist[i]; i++) {
-      if (gdata.ignorelist[i]->flags & IGN_IGNORING) {
-         ago = gdata.curtime-gdata.ignorelist[i]->lastcontact;
-         left = IGN_TL*(gdata.ignorelist[i]->bucket-IGN_OFF);
-         isnprintf(tempstr,maxtextlength-2,"   %4i%c%02i%c ago   %4i%c%02i%c   %6s   %-32s",
-                ago < 3600 ? ago/60 : ago/60/60 ,
-                ago < 3600 ? 'm' : 'h',
-                ago < 3600 ? ago%60 : (ago/60)%60 ,
-                ago < 3600 ? 's' : 'm',
-                left < 3600 ? left/60 : left/60/60 ,
-                left < 3600 ? 'm' : 'h',
-                left < 3600 ? left%60 : (left/60)%60 ,
-                left < 3600 ? 's' : 'm',
-
-            gdata.ignorelist[i]->flags & IGN_MANUAL ? "manual" : "auto",
-            gdata.ignorelist[i]->hostname);
-         u_respond(u,tempstr);
-         }
-      }
-   
-   mydelete(tempstr);
-   }
-
-static void u_ignore(const userinput * const u) {
-   int i, num=0, found;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   
-   if (!u->arg1)  {
-      u_respond(u,"Try specifying an amount of time to ignore");        
-      return;
-      }
-
-   if (!u->arg2 || strlen(u->arg2) < 4) {
-      u_respond(u,"Try specifying a hostname longer than 4 characters");
-      return;
-      }
-   
-   for (found=i=0; (i<MAXIGNL && gdata.ignorelist[i] && !found); i++)
-      if (!strcmp(gdata.ignorelist[i]->hostname,u->arg2)) found++;
-   
-   if (i == MAXIGNL) {
-      outerror(1,"Out of ignore slots!, This shouldn't happen");
-      u_respond(u,"Out of ignore slots!, This shouldn't happen");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_ignore");
-   
-   if (!found) {
-      gdata.ignorelist[i] = mycalloc(sizeof(igninfo),"u_ignore_ignorelist[i]");
-      strncpy(gdata.ignorelist[i]->hostname,u->arg2,maxtextlength-1);
-      gdata.ignorelist[i]->flags |= IGN_IGNORING;
-      gdata.ignorelist[i]->flags &= ~IGN_FIRSTIGNORE;
-      gdata.ignorelist[i]->lastcontact = gdata.curtime;
-      }
-   else
-      i--;
-   gdata.ignorelist[i]->flags |= IGN_MANUAL;
-   gdata.ignorelist[i]->bucket = (num*60)/IGN_TL;
-   
-   isnprintf(tempstr,maxtextlength-2,
-            "Ignore activated for *!*@%s which will last %i min",
-            u->arg2,num);
-   u_respond(u,tempstr);
-   write_ignorefile();
-
-   mydelete(tempstr);
-   }
-
-
-static void u_nosave(const userinput * const u) {
-   int num = 0;
-   char *tempstr = mycalloc(maxtextlength,"u_nosave");
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   gdata.noautosave=gdata.curtime + 60*num - 1;
-   isnprintf(tempstr,maxtextlength-2,
-   "*** XDCC AutoSave has been disabled for the next %i minute%s",num,num!=1?"s":"");
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   
-   }
-
-
-static void u_nosend(const userinput * const u) {
-   int num = 0;
-   char *tempstr = mycalloc(maxtextlength,"u_nosend");
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   gdata.nonewcons=gdata.curtime + 60*num - 1;
-   isnprintf(tempstr,maxtextlength-2,
-   "*** XDCC Send has been disabled for the next %i minute%s",num,num!=1?"s":"");
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   
-   }
-
-
-static void u_nolist(const userinput * const u) {
-   int num = 0;
-   char *tempstr = mycalloc(maxtextlength,"u_nolist");
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   gdata.nolisting=gdata.curtime + 60*num - 1;
-   isnprintf(tempstr,maxtextlength-2,
-   "*** XDCC List and PLIST have been disabled for the next %i minute%s",num,num!=1?"s":"");
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   
-   }
-
-
-static void u_renumber(const userinput * const u) {
-   int oldp = 0, newp = 0;
-   int i,op,np;
-   xdcc *t;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) oldp = atoi(u->arg1);
-   if (u->arg2) newp = atoi(u->arg2);
-   
-   if (oldp < 1 || oldp > gdata.numpacks || newp < 1 || newp > gdata.numpacks || newp == oldp ) {
-      u_respond(u,"Invalid pack number");
-      return;
-      }
-   
-   /* find old */
-   for (i=1, op=0; i<=gdata.numpacks; i++, op++) {
-      while (gdata.xdccs[op] == NULL)
-         op++;
-      if ( i == oldp )
-         break;
-      }
-   
-   /* find new */
-   for (i=1, np=0; i<=gdata.numpacks; i++, np++) {
-      while (gdata.xdccs[np] == NULL)
-         np++;
-      if ( i == newp )
-         break;
-      }
-   
-   t = gdata.xdccs[op];
-   if (np > op)
-      for (i=op; i<np; i++)
-         gdata.xdccs[i] = gdata.xdccs[i+1];
-   if (np < op)
-      for (i=op; i>np; i--)
-         gdata.xdccs[i] = gdata.xdccs[i-1];
-   gdata.xdccs[np] = t;
-   
-   tempstr = mycalloc(maxtextlength,"u_renumber");
-   isnprintf(tempstr,maxtextlength-2,"*** Moved pack %i to %i",oldp,newp);
-   u_respond(u,tempstr);
-   mydelete(tempstr);
-   
-   xdccsave(0);
-   
-   }
-
-
-static void u_msgread(const userinput * const u) {
-   int fd,count=0,i;
-   char *linedate, *linemask;
-   int msgoffset;
-   char *tempstr, *tempstr2;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.messagefile) {
-      u_respond(u,"no messagefile defined in config");
-      return;
-      }
-   
-   fd=open(gdata.messagefile, O_RDONLY | ADDED_OPEN_FLAGS);
-   if (fd < 0) {
-      u_respond(u,"messagefile couldn't be opened");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_msgread");
-   tempstr2 = mycalloc(maxtextlength,"u_msgread");
-   while (getfline(tempstr,fd,0) != NULL) {
-      count++;
-      linedate = getpart(tempstr,1,"u_msgread");
-      linemask = getpart(tempstr,2,"u_msgread");
-      msgoffset = sstrlen(linedate) + sstrlen(linemask) + 1;
-      
-      for (i=msgoffset; i<sstrlen(tempstr)+1; i++)
-         tempstr[i-msgoffset] = tempstr[i];
-      
-      
-      linedate = getdatestr(linedate,atoul(linedate));
-      
-      isnprintf(tempstr2,maxtextlength-2,
-      "%s: %s",linedate,linemask);
-      u_respond(u,tempstr2);
-      isnprintf(tempstr2,maxtextlength-2,
-      " ^- %s",tempstr);
-      u_respond(u,tempstr2);
-      
-      mydelete(linedate); mydelete(linemask);
-      }
-   
-   isnprintf(tempstr2,maxtextlength-2,
-   "msglog: %i message%s in log%s%s",
-           count,
-           count!=1?"s":"",
-           count?", use MSGDEL to remove ":"",
-           count>1?"them":(count==1?"it":""));
-   u_respond(u,tempstr2);
-   
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   close(fd);
-   
-   }
-
-
-static void u_msgdel(const userinput * const u) {
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.messagefile) {
-      u_respond(u,"no messagefile defined in config");
-      return;
-      }
-   
-   if (truncate(gdata.messagefile,0) < 0) {
-      u_respond(u,"couldn't delete messages");
-      return;
-      }
-   
-   u_respond(u,"msglog: deleted all messages");
-   
-   }
-
-
-static void u_memstat(const userinput * const u) {
-   int i;
-   long numcount, numcountrecent, sizecount;
-   struct rusage r;
-   char *tempstr = mycalloc(maxtextlength,"u_memstat");
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   u_respond(u,"iroffer memory usage:");
-
-   getrusage(RUSAGE_SELF,&r);
-   
-   isnprintf(tempstr,maxtextlength-2,"rusage: maxrss %li, ixrss %li, idrss %li, isrss %li, minflt %li, majflt %li, nswap %li",
-            r.ru_maxrss,r.ru_ixrss,r.ru_idrss,r.ru_isrss,r.ru_minflt,r.ru_majflt,r.ru_nswap);
-   u_respond(u,tempstr);
-   isnprintf(tempstr,maxtextlength-2,"        inbloc %li, oublock %li, msgsnd %li, msgrcv %li, nsignals %li, nvcsw %li, nivcsw %li",
-           r.ru_inblock,r.ru_oublock,r.ru_msgsnd,r.ru_msgrcv,r.ru_nsignals,r.ru_nvcsw,r.ru_nivcsw);
-   u_respond(u,tempstr);
-
-      
-   for (numcountrecent=numcount=sizecount=i=0; i<MAXMEMINFO; i++)
-      if (gdata.meminfo[i].ptr != NULL) {
-         numcount++;
-         sizecount += gdata.meminfo[i].size;
-         if (gdata.meminfo[i].alloctime > gdata.curtime-600)
-            numcountrecent++;
-         }
-      
-   isnprintf(tempstr,maxtextlength-2,
-     "%li bytes allocated for %li arrays (%li created in past 10 min)",
-     sizecount,numcount,numcountrecent);
-   u_respond(u,tempstr);
-   
-   if (u->arg1 && !strcmp(u->arg1,"list")) {
-      
-      u_respond(u,"iroffer memory usage details:");
-      u_respond(u,"  id |    address |  size |     when | comment");
-      
-      for (i=0; i<MAXMEMINFO; i++)
-         if (gdata.meminfo[i].ptr != NULL) {
-            
-            isnprintf(tempstr,maxtextlength-2,
-              "%4i | 0x%8.8lX | %4iB | %7lis | \"%s\"",
-              i,
-              (long)gdata.meminfo[i].ptr,
-              gdata.meminfo[i].size,
-              gdata.meminfo[i].alloctime-gdata.startuptime,
-              gdata.meminfo[i].src ? gdata.meminfo[i].src : "unknown" );
-            u_respond(u,tempstr);
-            
-            }
-      
-      }
-   else
-      u_respond(u,"for a detailed listing use \"memstat list\"");
-   
-   mydelete(tempstr);
-   
-   }
-
-
-static void u_qsend(const userinput * const u) {
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.inqueue && !gdata.inslotsmaxqueue) {
-      u_respond(u,"No Users Queued");
-      return;
-      }
-   
-   sendaqueue(2);
-   
-   }
-
-static void u_shutdown(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1 || (strcmp(caps(u->arg1),"NOW") && strcmp(caps(u->arg1),"DELAYED") && strcmp(u->arg1,"CANCEL")) ) {
-      u_respond(u,"Usage: SHUTDOWN <now|delayed|cancel>");
-      return;
-      }
-   
-   if (!strcmp(u->arg1,"NOW")) {
-      shutdowniroffer(0);
-      }
-   else if (!strcmp(u->arg1,"DELAYED")) {
-      u_respond(u,"Delayed shutdown activated, iroffer will shutdown once there are no active transfers");
-      u_respond(u,"To cancel the delayed shutdown, issue \"SHUTDOWN CANCEL\"");
-      gdata.delayedshutdown=1;
-      }
-   else if (!strcmp(u->arg1,"CANCEL")) {
-      u_respond(u,"Delayed shutdown canceled");
-      gdata.delayedshutdown=0;
-      }
-   
-   }
-
-static void u_debug(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!u->arg1) return;
-   
-   if (u->arg1[0] == '1') {
-      gdata.debug = 1;
-      gdata.debug2 = 0;
-      }
-   else if (u->arg1[0] == '2') {
-      gdata.debug = 1;
-      gdata.debug2 = 1;
-      }
-   else if (u->arg1[0] == '0') {
-      gdata.debug = 0;
-      gdata.debug2 = 0;
-      }
-   }
-
-static void u_jump(const userinput * const u) {
-  int num = 0;
-  
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-  if (u->arg1) num = atoi(u->arg1);
-  if (num < 0) num = 0;
-  
-  if (num > 0 && (num > MAXSRVS || !gdata.server[num-1]))
-    u_respond(u,"Try specifying a valid server number, use \"servers\" for a list");
-  else
-    switchserver(num-1);
-  
-}
-
-static void u_servers(const userinput * const u) {
-  int i;
-  char *tempstr = mycalloc(maxtextlength,"u_servers");
-  
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-  u_respond(u,"Server List:");
-  u_respond(u,"  Num  Server/Port");
-  
-  for (i=0; i<MAXSRVS; i++)
-    if (gdata.server[i]) {
-      isnprintf(tempstr,maxtextlength-2,"   %2i  %s",i+1,gdata.server[i]);
-      u_respond(u,tempstr);
-    }
-  
-  isnprintf(tempstr,maxtextlength-2,"Current Server: %s:%s",gdata.curserverip,gdata.curserverport);
-  u_respond(u,tempstr);
-  
-  mydelete(tempstr);
-  
-
-}
-
-static void u_trinfo(const userinput * const u) {
-   int num = -1;
-   char *tempstr, *tempstr2, *tempstr3;
-   const char *y;
-   int left,started,lcontact;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (u->arg1) num = atoi(u->arg1);
-   if (num < 0 || num > MAXTRANS || gdata.trans[num] == NULL) {
-      u_respond(u,"Try Specifying a Valid Transfer Number");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_trinfo");
-   tempstr2 = mycalloc(maxtextlength,"u_trinfo");
-   tempstr3 = mycalloc(maxtextlengthshort,"u_trinfo");
-   
-   isnprintf(tempstr,maxtextlength-2,"Transfer Info for ID %i:",num);
-   u_respond(u,tempstr);
-   
-   if (gdata.trans[num]->status == 'L') y = "Listening";
-   else if (gdata.trans[num]->status == 'W') y = "Finishing";
-   else if (gdata.trans[num]->status == 'D') y = "Closing";
-   else if (gdata.trans[num]->status == 'E') y = "Error";
-   else if (gdata.trans[num]->status == 'S') y = "Sending";
-   else y = "Unknown!";
-   
-   isnprintf(tempstr,maxtextlength-2,"User %s, Hostname %s, Status %s",
-             gdata.trans[num]->nick,gdata.trans[num]->hostname,y);
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,"File: %s",getfilename(gdata.trans[num]->xpack->file));
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,"Start %liK, Current %liK, End %liK (%2.0f%% File, %2.0f%% Xfer)",
-             (long)((gdata.trans[num]->startresume)/1024),
-             (long)((gdata.trans[num]->bytessent)/1024),
-             (long)((gdata.trans[num]->xpack->size)/1024),
-             ((float)gdata.trans[num]->bytessent)*100.0/((float)gdata.trans[num]->xpack->size),
-             ((float)(gdata.trans[num]->bytessent-gdata.trans[num]->startresume))*100.0/((float)max2(1,(gdata.trans[num]->xpack->size-gdata.trans[num]->startresume)))
-             );
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr2,maxtextlength-2,"%1.1fK/s",gdata.trans[num]->xpack->minspeed);
-   isnprintf(tempstr3,maxtextlengthshort-2,"%1.1fK/s",gdata.trans[num]->xpack->maxspeed);
-   
-   isnprintf(tempstr,maxtextlength-2,"Min %s, Current %1.1fK/s, Max %s, In Transit %liK, Limit factor %2.0f%%",
-             (gdata.trans[num]->nomin || (gdata.trans[num]->xpack->minspeed == 0.0)) ? "no" : tempstr2 ,
-             gdata.trans[num]->lastspeed,
-             (gdata.trans[num]->nomax || (gdata.trans[num]->xpack->maxspeed == 0.0)) ? "no" : tempstr3 ,
-             (long)(gdata.trans[num]->bytessent-gdata.trans[num]->lastack)/1024,
-             (float)(gdata.trans[num]->needsdata+(needsdatamin*(-1)))*100.0/(float)((needsdatamin*(-1)+needsdatamax))
-             );
-   u_respond(u,tempstr);
-   
-   left     = min2(359999,(gdata.trans[num]->xpack->size-gdata.trans[num]->bytessent)/((int)(max2(gdata.trans[num]->lastspeed,0.001)*1024)));
-   started  = min2(359999,gdata.curtime-gdata.trans[num]->connecttime);
-   lcontact = min2(359999,gdata.curtime-gdata.trans[num]->lastcontact);
-   isnprintf(tempstr,maxtextlength-2,"Transfer started %i%c %i%c ago, Finish in %i%c %i%c, Last contact %i%c %i%c ago.",
-             started < 3600 ? started/60 : started/60/60 ,
-             started < 3600 ? 'm' : 'h',
-             started < 3600 ? started%60 : (started/60)%60 ,
-             started < 3600 ? 's' : 'm',
-             left < 3600 ? left/60 : left/60/60 ,
-             left < 3600 ? 'm' : 'h',
-             left < 3600 ? left%60 : (left/60)%60 ,
-             left < 3600 ? 's' : 'm',
-             lcontact < 3600 ? lcontact/60 : lcontact/60/60 ,
-             lcontact < 3600 ? 'm' : 'h',
-             lcontact < 3600 ? lcontact%60 : (lcontact/60)%60 ,
-             lcontact < 3600 ? 's' : 'm'
-             );
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,"Local: %ld.%ld.%ld.%ld:%d, Remote: %ld.%ld.%ld.%ld:%d",
-             gdata.trans[num]->localip>>24, (gdata.trans[num]->localip>>16) & 0xFF, (gdata.trans[num]->localip>>8) & 0xFF, gdata.trans[num]->localip & 0xFF, gdata.trans[num]->listenport,
-             gdata.trans[num]->remoteip>>24, (gdata.trans[num]->remoteip>>16) & 0xFF, (gdata.trans[num]->remoteip>>8) & 0xFF, gdata.trans[num]->remoteip & 0xFF, gdata.trans[num]->remoteport
-             );
-   u_respond(u,tempstr);
-   
-   isnprintf(tempstr,maxtextlength-2,"Sockets: Listen %i, Transfer %i, File %i",
-             gdata.trans[num]->listensocket,
-             gdata.trans[num]->clientsocket,
-             gdata.trans[num]->filedescriptor
-             );
-   u_respond(u,tempstr);
-   
-   
-   mydelete(tempstr);
-   mydelete(tempstr2);
-   mydelete(tempstr3);
-   }
-
-
-static void u_listul(const userinput * const u) {
-   int count=0;
-   DIR *d;
-   struct dirent *f;
-   struct stat s;
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.uploadallowed || !gdata.uploaddir) {
-      u_respond(u,"Upload not Allowed or no Uploaddir defined.");
-      return;
-      }
-   
-   if (!(d = opendir(gdata.uploaddir))) {
-      u_respond(u,"Couldn't Read Directory.");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_listul");
-   
-   isnprintf(tempstr,maxtextlength-2,"Contents of %s",gdata.uploaddir);
-   u_respond(u,tempstr);
-   
-   while ((f = readdir(d))) {
-      if (strcmp(".",f->d_name) && strcmp("..",f->d_name)) {
-         count++;
-         isnprintf(tempstr,maxtextlength-2,"%s/%s",gdata.uploaddir,f->d_name);
-         stat(tempstr,&s);
-         isnprintf(tempstr,maxtextlength-2,"   %s (%liK)",
-                f->d_name,(long)s.st_size/1024);
-         u_respond(u,tempstr);
-         }
-      }
-   
-   isnprintf(tempstr,maxtextlength-2,"%i Total Files",count);
-   u_respond(u,tempstr);
-   
-   mydelete(tempstr);
-   
-   closedir(d);
-   
-   }
-
-static void u_clearrecords(const userinput * const u) {
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   gdata.record = 0;
-   gdata.sentrecord = 0;
-   gdata.totalsent = 0;
-   gdata.totaluptime = 0;
-   
-   u_respond(u,"Cleared transfer record, bandwidth record, total sent, and total uptime");
-   
-   }
-
-static void u_rmul(const userinput * const u) {
-   char *tempstr;
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   if (!gdata.uploadallowed || !gdata.uploaddir) {
-      u_respond(u,"Upload not Allowed or no Uploaddir defined.");
-      return;
-      }
-   
-   if (!u->arg1 || !strlen(u->arg1)) {
-      u_respond(u,"Try Specifying a Filename");
-      return;
-      }
-   
-   if (u->arg2) {
-      u_respond(u,"Filenames can't contain spaces");
-      return;
-      }
-   
-   if (strcmpany(u->arg1,"/")) {
-      u_respond(u,"Filename contains invalid characters");
-      return;
-      }
-   
-   tempstr = mycalloc(maxtextlength,"u_rmul");
-   isnprintf(tempstr,maxtextlength-2,"%s/%s",gdata.uploaddir,u->arg1);
-   
-   if (doesfileexist(tempstr)) {
-      if (unlink(tempstr) < 0)
-         u_respond(u,"Unable to remove the file");
-      else
-         u_respond(u,"Deleted");
-      }
-   else
-      u_respond(u,"That filename doesn't exist");
-   
-   mydelete(tempstr);
-   
-   }
-
-static void u_crash(const userinput * const u) {
-   
-   updatecontext(__FILE__,__FUNCTION__,__LINE__);
-   
-   *((int*)(0)) = 0;
-   
-}
-
-#define USERS_PER_CHAN_LINE  6
-
-static void u_chanl(const userinput * const u)
-{
-  int i,j;
-  channel_member_t *p;
-  char *tempstr = mycalloc(maxtextlength,"u_chanl");
-  
-  updatecontext(__FILE__,__FUNCTION__,__LINE__);
-  
-  u_respond(u,"Channel Members:");
-  
-  for (i=0; i<MAXCHNLS; i++)
-    if (gdata.channels[i])
-      {
-	j = 0;
-	p = gdata.channels[i]->members;
-	
-	if (p)
-	  {
-	    
-	    while ( p )
-	      {
-		nocaps(p->nick);
-		if (!(j%USERS_PER_CHAN_LINE))
-		  isnprintf(tempstr,maxtextlength-1,"%s: ",gdata.channels[i]->name);
-		strncat(tempstr,p->nick,maxtextlength-strlen(tempstr)-1);
-		strncat(tempstr," ",maxtextlength-strlen(tempstr)-1);
-		if (!((j+1)%USERS_PER_CHAN_LINE))
-		  {
-		    u_respond(u,tempstr);
-		    tempstr[0] = '\0';
-		  }
-		caps(p->nick);
-		
-		p = p->next;
-		j++;
-	      }
-	    
-	    if (j%USERS_PER_CHAN_LINE)
-	      u_respond(u,tempstr);
-
-	  }
-	
-	isnprintf(tempstr,maxtextlength-1,"%s: %i user%s",gdata.channels[i]->name,j,j!=1?"s":"");
-	u_respond(u,tempstr);
-	
-      }
-
-  mydelete(tempstr);
-  
-}
-/* End of File */
+void u_fillwith_dcc (useri                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
\ No newline at end of file
diff -BNru iroffer1.2b13/src/defines.h iroffer1.2b13+cpitchfor11-doc/src/defines.h
--- iroffer1.2b13/src/defines.h	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/defines.h	Wed Apr  3 19:29:35 2002
@@ -17,9 +17,9 @@
 #if !defined _IROFFER_DEFINES
 #define _IROFFER_DEFINES
 
-#define  VERSION "1.2b13"
-#define  VERSIONDATE "November 10th, 2001"
-#define  VERSIONDATEUTC 1005405514 /* "date +%s" */
+#define  VERSION "1.2b13+cpitchfor11-doc"
+#define  VERSIONDATE "April 3rd, 2002"
+#define  VERSIONDATEUTC 1017858012 /* "date +%s" */
 #define  RELEASE 1
 
 
@@ -98,7 +98,7 @@
 #define  SRVRTOUT  240
 
 /*       max number of people to keep track of in ignore list */
-#define  MAXIGNL  80
+#define  MAXIGNL  500
 /*       tollerance for ignore, seconds/request to decrement bucket */
 #define  IGN_TL    10
 /*       threshhold for ignore, number of requests in bucket */
@@ -141,11 +141,22 @@
 #define IGN_MANUAL      1
 #define IGN_IGNORING    2
 #define IGN_FIRSTIGNORE 4
+#define IGN_RANGE       8
 
 /* type definitions for channel_t flags */
 #define CHAN_ONCHAN     1
 #define CHAN_MINIMAL    2
 #define CHAN_SUMMARY    4
+#define CHAN_CUSTOM     8
+
+/* Maximum number of advert lines */
+#define MAXADVERTS      20
+
+/* Maximum number of pre channel join raw commands */
+#define MAXPREJOIN      20
+
+/* Maximum number of hosts to monitor for invalid packs */
+#define MAXBADPACK      500
 
 /* type definistions: Screen, Log, DCC CHAT */
 #define OUT_S    1
diff -BNru iroffer1.2b13/src/globals.h iroffer1.2b13+cpitchfor11-doc/src/globals.h
--- iroffer1.2b13/src/globals.h	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/globals.h	Wed Apr  3 19:29:35 2002
@@ -150,6 +150,34 @@
 upload *uploads[MAXUPLDS];
 
 meminfo_t meminfo[MAXMEMINFO];
+  /* The custom advert */
+  char* advert[MAXADVERTS];
+
+  /* Time to ban a user
+     -1: Disable, normal list operation response
+      0: Ignore all list requests silently
+    n>0: Ban a user for n minutes should they xdcc list this bot
+  */
+  int nolistbantime;
+  int publictriggers;
+  char* humiliate;
+  int nospeedwarnings;
+  int fullignoretime;
+  int noadverts;
+  char* prejoin[MAXPREJOIN];
+  struct {
+    int rotate;
+    int interval;
+    int maxattempts;
+    int badpacktime;
+    int bantime;
+    char* humiliate;
+    struct {
+      char *hostmask;
+      int first;
+      int last;
+    } list[MAXBADPACK];
+  } badpack;
 
 } gdata_t;
 
diff -BNru iroffer1.2b13/src/headers.h iroffer1.2b13+cpitchfor11-doc/src/headers.h
--- iroffer1.2b13/src/headers.h	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/headers.h	Wed Apr  3 19:29:35 2002
@@ -162,7 +162,8 @@
    method_out_all         = 0x20,
    method_xdl_channel_min = 0x40,
    method_xdl_channel_sum = 0x80,
-   method_allow_all       = 0xFF
+   method_xdl_channel_cust= 0x100,
+   method_allow_all       = 0x1FF
    } userinput_method_e;
 
 typedef struct {
@@ -238,6 +239,8 @@
 int strcmppart (const char *str, const char *match);
 int strcmpany (const char *str1, const char *match1);
 int strcmpend (const char *str, const char *match);
+int simpleformat(char* buffer, const int length, char* format,
+		 char* params, ...);
 char* getpart(const char *line, int howmany, const char *src);
 char* caps(char *text);
 char* nocaps(char *text);
@@ -255,6 +258,7 @@
 unsigned long atoul (const char *str);
 unsigned long long atoull (const char *str);
 void ioutput(int beg, int dest, const char *color, const char *format, ...);
+void allchanmsg(const char *message);
 void privmsg(const char *nick, const char *format, ...);
 void notice(const char *nick, const char *format, ...);
 char* hostmasktoregex(char *str);
@@ -287,6 +291,10 @@
 int mysnprintf(char *str, size_t n, const char *format, ... );
 int myvsnprintf(char *str, size_t n, const char *format, va_list ap );
 #endif
+char capchar(const char c);
+double getEngineerval(const double value, const char *engfix, char *res);
+int badpackadd(const char* hostmask, int *count);
+void badpackrotate(int now);
 
 /* misc.cpp */
 void getconfig (void);
@@ -316,6 +324,7 @@
 char* getstatusline(char *str);
 char* getstatuslinenums(char *str);
 void sendxdlqueue(void);
+int addressedtome(const char *dest);
 int isthisforme (const char *dest, char *msg1);
 void initvars(void);
 void startupiroffer(void);
@@ -327,6 +336,7 @@
 void notifybandwidthtrans(void);
 void write_ignorefile(void);
 void read_ignorefile(void);
+int isbanned(const int i, const char* host);
 
 /* dccchat.cpp */
 int setupdccchatout(const char *nick);
@@ -371,8 +381,10 @@
 void u_fillwith_dcc(userinput * const u, char *line);
 void u_fillwith_msg(userinput * const u, char *n, const char *line);
 void u_fillwith_clean(userinput * const u);
-
+int sendAdvert(const char* ch, int force);
 void u_parseit(userinput * const u);
+int fullignore(const char* nick, const char* hostname);
+void ignoreuser(const char* hostname, int bantime);
 
 #endif
 
diff -BNru iroffer1.2b13/src/iroffer.c iroffer1.2b13+cpitchfor11-doc/src/iroffer.c
--- iroffer1.2b13/src/iroffer.c	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/iroffer.c	Wed Apr  3 19:29:35 2002
@@ -88,7 +88,6 @@
    static int i,j,length,changesec,changemin,changehour,linecut,linecutd,count,efficency;
    static long lasttime, lastmin, lasthour, last4sec, last5sec, last20sec;
    static long lastxminautosave, last3min, last2min, lastignoredec, lastperiodicmsg;
-   static userinput *pubplist;
    static userinput *urehash;
    static int first_loop = 1;
    
@@ -512,6 +511,9 @@
       /* time to rotate log ? */
       if (changehour && gdata.logrotate && gdata.logfile)
          isrotatelog();
+      if (changesec)
+	badpackrotate(0);
+      
 
       /*----- IGN_TL seconds ----- */
       if (changesec && (gdata.curtime - lastignoredec > IGN_TL)) {
@@ -629,72 +631,8 @@
       
       /*----- plist stuff ----- */
       if (gdata.serverstatus == 'C' && changemin && gdata.numpacks) {
-         if (!gdata.queuesize || gdata.inqueue < gdata.queuesize) {
-            char *tchanf = NULL, *tchanm = NULL, *tchans = NULL;
-            
-            for (i=0; gdata.channels[i] && i<MAXCHNLS; i++)
-               if (gdata.channels[i]->plisttime && !((gdata.curtime/60)%(gdata.channels[i]->plisttime))) {
-                  if (gdata.channels[i]->flags & CHAN_MINIMAL) {
-                     if (tchanm) {
-                        strncat(tchanm,",",maxtextlength-strlen(tchanm)-1);
-                        strncat(tchanm,gdata.channels[i]->name,maxtextlength-strlen(tchanm)-1);
-                        }
-                     else {
-                        tchanm = mycalloc(maxtextlength,"mainloop_pubplist1m");
-                        strncpy(tchanm,gdata.channels[i]->name,maxtextlength-1);
-                        }
-                     }
-                  else if (gdata.channels[i]->flags & CHAN_SUMMARY) {
-                     if (tchans) {
-                        strncat(tchans,",",maxtextlength-strlen(tchans)-1);
-                        strncat(tchans,gdata.channels[i]->name,maxtextlength-strlen(tchans)-1);
-                        }
-                     else {
-                        tchans = mycalloc(maxtextlength,"mainloop_pubplist1s");
-                        strncpy(tchans,gdata.channels[i]->name,maxtextlength-1);
-                        }
-                     }
-                  else {
-                     if (tchanf) {
-                        strncat(tchanf,",",maxtextlength-strlen(tchanf)-1);
-                        strncat(tchanf,gdata.channels[i]->name,maxtextlength-strlen(tchanf)-1);
-                        }
-                     else {
-                        tchanf = mycalloc(maxtextlength,"mainloop_pubplist1f");
-                        strncpy(tchanf,gdata.channels[i]->name,maxtextlength-1);
-                        }
-                     }
-                     
-                  }
-            if (tchans) {
-               ioutput(0,OUT_S|OUT_D,NULL,"Plist sent to %s (summary)",tchans);
-               pubplist = mycalloc(sizeof(userinput),"mainloop_pubplist2s");
-               u_fillwith_msg(pubplist,tchans,"A A A A A xdl");
-               pubplist->method = method_xdl_channel_sum;
-               u_parseit(pubplist);
-               mydelete(pubplist);
-               mydelete(tchans);
-               }
-            if (tchanf) {
-               ioutput(0,OUT_S|OUT_D,NULL,"Plist sent to %s (full)",tchanf);
-               pubplist = mycalloc(sizeof(userinput),"mainloop_pubplist2f");
-               u_fillwith_msg(pubplist,tchanf,"A A A A A xdl");
-               pubplist->method = method_xdl_channel;
-               u_parseit(pubplist);
-               mydelete(pubplist);
-               mydelete(tchanf);
-               }
-            if (tchanm) {
-               ioutput(0,OUT_S|OUT_D,NULL,"Plist sent to %s (minimal)",tchanm);
-               pubplist = mycalloc(sizeof(userinput),"mainloop_pubplist2m");
-               u_fillwith_msg(pubplist,tchanm,"A A A A A xdl");
-               pubplist->method = method_xdl_channel_min;
-               u_parseit(pubplist);
-               mydelete(pubplist);
-               mydelete(tchanm);
-               }
-            
-            }
+	if (!gdata.queuesize || gdata.inqueue < gdata.queuesize) 
+	  sendAdvert(NULL,0);
          else
             ioutput(0,OUT_S|OUT_D,NULL,"Plist skipped, we seem to be rather busy");
          }
@@ -1192,7 +1130,7 @@
       /* add/increment ignore list */
       j=0;
       for (i=0; i<MAXIGNL && gdata.ignorelist[i]; i++)
-         if (!strcmp(gdata.ignorelist[i]->hostname,hostname)) {
+         if (isbanned(i,hostname)) {
             /* already in list */
             j=1;
             gdata.ignorelist[i]->bucket++;
@@ -1219,14 +1157,14 @@
             gdata.ignorelist[i] = mycalloc(sizeof(igninfo),"privmsgparse_gdata.ignorelist[i]");
          strncpy(gdata.ignorelist[i]->hostname,hostname,maxtextlength-1);
          gdata.ignorelist[i]->bucket = 1;
-         gdata.ignorelist[i]->flags &= ~IGN_MANUAL & ~IGN_IGNORING & ~IGN_FIRSTIGNORE;
+         gdata.ignorelist[i]->flags &= ~IGN_RANGE & ~IGN_MANUAL & ~IGN_IGNORING & ~IGN_FIRSTIGNORE;
          gdata.ignorelist[i]->lastcontact = gdata.curtime;
          
          }
    
       /* see if we are ignoreing this person */
       for (i=0; i<MAXIGNL && gdata.ignorelist[i]; i++)
-         if (!strcmp(gdata.ignorelist[i]->hostname,hostname) && (gdata.ignorelist[i]->flags & IGN_IGNORING)) {
+         if (isbanned(i,hostname) && (gdata.ignorelist[i]->flags & IGN_IGNORING)) {
             if (gdata.ignorelist[i]->flags & IGN_FIRSTIGNORE) {
                 privmsg(nick,"Auto-ignore activated, ignoring *!*@%s until you calm down",hostname);
                 gdata.ignorelist[i]->flags &= ~IGN_FIRSTIGNORE;
@@ -1237,6 +1175,9 @@
 	    goto privmsgparse_cleanup; /* it's useful damnit! */
             }
       }
+   if (!gdata.publictriggers && !addressedtome(dest))
+     goto privmsgparse_cleanup;
+   
    
    /*----- CLIENTINFO ----- */
    if ( !gdata.ignore && (!strcmp(msg1,"\1CLIENTINFO")
@@ -1418,14 +1359,41 @@
    
    /*----- XDCC ----- */
    else if ( !gdata.ignore && (!strcmp(caps(msg1),"XDCC") || !strcmp(msg1,"\1XDCC") || !strcmp(caps(msg1),"CDCC") || !strcmp(msg1,"\1CDCC") )) {
-      gdata.inamnt[gdata.curtime%10]++;
       
+	 gdata.inamnt[gdata.curtime%10]++;
       caps(msg2);
       
       if (msg3 && msg3[strlen(msg3)-1] == '\1')
          msg3[strlen(msg3)-1] = '\0';
       
-      if ( msg2 && ( !strcmp(msg2,"LIST") || !strcmp(msg2,"LIST\1"))) {
+	 if ( msg2 && ( !strcmp(msg2,"LIST") || !strcmp(msg2,"LIST\1")))
+	   {
+	     if ((gdata.nolisting > gdata.curtime) && (gdata.nolistbantime!=-1))
+	       {
+		 if (gdata.nolistbantime>0)
+		   {
+		     /* We have someone to ban!! hurrah! */
+		     ignoreuser(hostname, gdata.nolistbantime);
+		     ioutput(0,OUT_S|OUT_L|OUT_D,"0;33","XDCC LIST banned: %s (%s)",nick,hostmask);
+
+		     if (gdata.humiliate)
+		       {
+			 char tempmessage[maxtextlength];
+			 simpleformat(tempmessage,maxtextlength,
+				      gdata.humiliate,
+				      "tp minute",gdata.nolistbantime,
+				      "us",nick,
+				      NULL);
+			 
+			 ioutput(0,OUT_S|OUT_L|OUT_D,"0;33",
+				 "XDCC BANSEND to %s: %s",
+				 nick,tempmessage);		
+			 allchanmsg(tempmessage);
+		       } 
+		   }
+	       }
+	     else
+	       {
          if (!gdata.attop) gototop();
          
 	 if (gdata.restrictlist && !isinmemberlist(nick))
@@ -1456,7 +1424,7 @@
          ioutput(0,OUT_S|OUT_L|OUT_D,"0;33","XDCC LIST %s: (%s)",(j==1?"ignored":(j==2?"denied":"queued")),hostmask);
          
          }
-      else if(!strcmp(gdata.caps_nick,dest))
+	   } else if(!strcmp(gdata.caps_nick,dest))
 	{
          if ( msg2 && msg3 && (!strcmp(msg2,"SEND") || !strcmp(msg2,"GET"))) {
          if (!gdata.attop) gototop();
@@ -1638,11 +1606,45 @@
       notice(nick,"*** You can only have %d transfer%s at a time",gdata.maxtransfersperperson,gdata.maxtransfersperperson!=1?"s":"");
       }
    else if (!man && (pack > gdata.numpacks || pack < 1)) {
+      int c=0;
       ioutput(2,OUT_S|OUT_L|OUT_D,"0;33"," (Bad Pack Number): ");
+      if (badpackadd(hostname,&c))
+	{ /* We need to ban this person */
+	  ignoreuser(hostname, gdata.badpack.bantime);
+	  ioutput(0,OUT_S|OUT_L|OUT_D,"0;33","XDCC BADPACK banned: %s (%s)",nick,hostname);
+	  if (gdata.badpack.humiliate)
+	    {
+	      char tempmessage[maxtextlength];
+	      simpleformat(tempmessage,maxtextlength,
+			   gdata.badpack.humiliate,
+			   "tp minute",gdata.badpack.bantime,
+			   "us",nick,
+			   "pp invalid pack",gdata.badpack.maxattempts,
+			   "mp minute",gdata.badpack.interval,
+			   NULL);
+	      ioutput(0,OUT_S|OUT_L|OUT_D,"0;33",
+		      "XDCC BANSEND to %s: %s",
+		      nick,tempmessage);		
+	      allchanmsg(tempmessage);
+	    }
+	}
+      else
+	{
+	  if (c==0)
       notice(nick,"*** Invalid Pack Number, Try Again");
+	  else
+	    {
+	      char cbuf[maxtextlength];
+	      char *cptr=cbuf;
+	      isnprintf(cptr,maxtextlength,"*** Invalid Pack Number, be more accurate or you may be banned %i/%i",c,gdata.badpack.maxattempts);
+	      notice (nick,cptr);
+	    }
       }
+   }
+   
    else if (!man && gdata.nonewcons > gdata.curtime ) {
       ioutput(2,OUT_S|OUT_L|OUT_D,"0;33"," (No New Cons): ");
+      if (fullignore(nick,hostname))
       notice(nick,"*** The Owner Has Requested That No New Connections Are Made In The Next %li Minute%s",(gdata.nonewcons-gdata.curtime+1)/60,((gdata.nonewcons-gdata.curtime+1)/60)!=1?"s":"");
       }   
    else if (!man && pack == gdata.slotsmaxpack && gdata.slotsmaxslots-gdata.slotsfull <= 0) {
@@ -1760,6 +1762,8 @@
             "%sQueue for pack %d of size %d is Full, Try Again Later",
             srvmsg,pack,gdata.slotsmaxqueue);
          strncpy(srvmsg,tempstr,maxtextlength-1);
+	 if (fullignore(nick,hostname)==0)
+	   srvmsg[0]=0;
          }
       else {
          ioutput(2,OUT_S|OUT_L|OUT_D,"0;33"," Queued (pack): ");
@@ -1784,6 +1788,8 @@
             "%sMain queue of size %d is Full, Try Again Later",
             srvmsg,gdata.queuesize);
          strncpy(srvmsg,tempstr,maxtextlength-1);
+	 if (fullignore(nick,hostname)==0)
+	   srvmsg[0]=0;
          }
       else {
          ioutput(2,OUT_S|OUT_L|OUT_D,"0;33"," Queued (slot): ");
diff -BNru iroffer1.2b13/src/misc.c iroffer1.2b13+cpitchfor11-doc/src/misc.c
--- iroffer1.2b13/src/misc.c	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/misc.c	Wed Apr  3 19:29:35 2002
@@ -23,7 +23,7 @@
 void getconfig (void) {
    char *templine = mycalloc(maxtextlength,"getconfig_templine");
    char *tempc = mycalloc(2,"getconfig_tempc");
-   int h,i,filedescriptor;
+   int h,i,filedescriptor=-1;
    
    updatecontext(__FILE__,__FUNCTION__,__LINE__);
 
@@ -53,7 +53,7 @@
             }
           }
        }
-   
+   close(filedescriptor);   
    printf("*** Checking for completeness of config file ...\n");
    
    if ( gdata.server[0] == NULL
@@ -103,7 +103,8 @@
       type[i] = line[i];
       }
    type[i] = '\0';
-   
+   if (line[i]==0)
+     i--;
    for (j=i+1; j<maxtextlength; j++) {
       if (line[j] == '\0')
          break;
@@ -160,9 +161,120 @@
       mydelete(var);
       }
    else if ( ! strcmp(type,"server")) {
-      for (i=0; gdata.server[i] && i<MAXSRVS; i++) ;
+      for (i=0;i<MAXSRVS && gdata.server[i]; i++) ;
+      if (i==MAXSRVS)
+	{
+	  ioutput(0,OUT_S|OUT_L|OUT_D,NULL," !!! Too many servers, ignoring %s in config file !!!",var);
+	}
+      else
       gdata.server[i] = var;
       }
+   else if ( ! strcmp(type,"advert")) {
+     for (i=0; i<MAXADVERTS && gdata.advert[i]!=NULL;i++);
+     if ((i!=MAXADVERTS) && (gdata.advert[i]==NULL))
+       gdata.advert[i]=var;
+   }
+   else if ( ! strcmp(type,"nolist")) {
+     char* cptr;
+     gdata.nolisting=(-3ul)>>1;
+     if ((cptr=getpart(var,1,"getconfig_set_nolist")))
+	 gdata.nolistbantime=(!strcasecmp(cptr,"-q"))?0:atoi(cptr);
+     else
+       gdata.nolistbantime=-1;
+     mydelete (cptr);
+   }
+   else if ( ! strcmp(type,"noadverts")) {
+     gdata.noadverts=(-3ul)>>1;
+   }
+   else if ( ! strcmp(type,"public")) {
+     gdata.publictriggers=1;
+   }
+   else if ( ! strcmp(type,"speedwarnings")) {
+     gdata.nospeedwarnings=0;
+   }
+   else if ( ! strcmp(type,"nospeedwarnings")) {
+     gdata.nospeedwarnings=10;
+   }
+   else if ( ! strcmp(type,"nopublic")) {
+     gdata.publictriggers=0;
+   }
+   else if ( ! strcmp(type, "badpack")) {
+     /* badpack <attempts> <in mins>  <banfor> */
+     char *tptr;
+     int i,num[4];
+
+     for(i=1;i<4;i++)
+       {
+	 if ((tptr=getpart(var,i,"badpackstring")))
+	   {
+	     if ((num[i]=atoi(tptr))<1)
+	       {
+		 
+		 ioutput(0,OUT_S|OUT_L|OUT_D,NULL," !!! Invalid badpack paramter %i in config file: %s",i,var);
+		 mydelete (tptr);
+		 i=9;
+	       }
+	   }
+	 else
+	   {
+	     ioutput(0,OUT_S|OUT_L|OUT_D,NULL," !!! Missing badpack paramter in config file: %s",var);
+	     mydelete (tptr);
+	     i=9;
+	   }
+       }
+     if (i!=9)
+       {
+	 gdata.badpack.badpacktime=(-3ul)>>1;
+	 gdata.badpack.maxattempts=num[1];
+	 gdata.badpack.interval=num[2];
+	 gdata.badpack.bantime=num[3];
+	 badpackrotate(1);
+       }
+   }
+   else if ( ! strcmp(type,"humiliate")) {
+     char** ccptr=NULL;
+     char* cptr=NULL;
+     int i;
+     for (i=0;var[i]!=0;i++)
+       if (var[i]==' ')
+	 {
+	   cptr=&(var[i+1]);
+	   var[i]=0;
+	   break;
+	 }
+     
+     if ( ! strcasecmp(var,"nolist") )
+       ccptr=&gdata.humiliate;
+     else if ( ! strcasecmp (var , "badpack") )
+       ccptr=&gdata.badpack.humiliate;
+     else
+       {
+	 ioutput(0,OUT_S|OUT_L|OUT_D,NULL," !!! Bad syntax for humiliate %s in config file !!!",var);
+       }
+     if (ccptr)
+       {
+	 if (*ccptr)
+	   {
+	     mydelete (*ccptr);
+	     *ccptr=NULL;
+	   }
+	 strncpy(*ccptr=mycalloc(maxtextlength,"u_humiliate"),
+		 cptr, maxtextlength-2);
+       }
+   }
+   else if ( ! strcmp(type,"fullignore")) {
+     char* cptr;
+     if ((cptr=getpart(var,1,"getconfig_set_fullignoretime")))
+       gdata.fullignoretime=atoi(cptr);
+     else
+       gdata.fullignoretime=0;
+     mydelete (cptr);
+   } 
+   else if ( ! strcmp(type,"prejoin")) {
+     for (i=0; i<MAXPREJOIN && gdata.prejoin[i]!=NULL;i++);
+     if ((i<MAXPREJOIN) && (gdata.prejoin[i]==NULL))
+       gdata.prejoin[i]=var;
+   }   
    else if ( ! strcmp(type,"channel")) {
       char *tptr = NULL, *tptr2 = NULL, *tname;
       int ok=1;
@@ -206,6 +318,11 @@
                strncpy(cptr->key,tptr2,maxtextlengthshort-1);
             else ok=0;
             }
+	 else if ((!strcmp(tptr,"-advert")) && (cptr->flags | CHAN_CUSTOM))
+	   {
+	     i++;
+	     cptr->flags |= CHAN_CUSTOM;
+	   }
          else ok=0;
          
          mydelete(tptr);
@@ -738,6 +855,10 @@
       isnprintf(tempstr,maxtextlength-2,"MODE %s %s",gdata.user_nick,gdata.user_modes);
       writeserver2(tempstr,1);
       }
+
+   for (i=0; i<MAXPREJOIN && gdata.prejoin[i]!=NULL;i++)
+     writeserver(gdata.prejoin[i]);
+     
    for (i=0; i<MAXCHNLS; i++)
       if (gdata.channels[i]) {
          joinchannel(gdata.channels[i]);
@@ -1611,6 +1732,12 @@
    mydelete(tempstr);
    }
 
+int addressedtome(const char *dest)
+{
+     if (!dest) { outerror(1,"addressedtome() got NULL value"); return 1; }
+     return (!strcmp(gdata.caps_nick,dest));
+}
+
 int isthisforme (const char *dest, char *msg1) {
    if (!msg1 || !dest) { outerror(1,"isthisforme() got NULL value"); return 1; }
    
@@ -1632,6 +1759,7 @@
    }
 
 void initvars(void) {
+  int i;
   
    bzero((char *) gdata.serverq, MAXSENDQ * sizeof(char*) );
    bzero((char *) gdata.inamnt, 10 * sizeof(int) );
@@ -1693,7 +1821,20 @@
    gdata.restrictlist = gdata.restrictsend = 0;
    
    gdata.startuptime = gdata.curtime = time(NULL);
-   
+   for (i=0;i<MAXADVERTS;i++)
+     gdata.advert[i]=NULL;
+   gdata.nolistbantime=-1;
+   gdata.publictriggers=1;
+   gdata.humiliate=NULL;
+   gdata.nospeedwarnings=0;
+   gdata.fullignoretime=0;
+   gdata.noadverts=0;
+   for (i=0;i<MAXPREJOIN;i++)
+     gdata.prejoin[i]=NULL;
+   gdata.badpack.interval=gdata.badpack.maxattempts=1;
+   gdata.badpack.badpacktime=gdata.badpack.bantime=0;
+   for (i=0;i<MAXBADPACK;i++)
+     gdata.badpack.list[i].hostmask=NULL;
    }
    
 void startupiroffer(void) {
@@ -2016,7 +2157,7 @@
    updatecontext(__FILE__,__FUNCTION__,__LINE__);
 
    if (gdata.exiting) return;
-   if (!gdata.maxb) return;
+   if (!gdata.maxb || gdata.nospeedwarnings) return;
    
    
    j = 0;
@@ -2046,7 +2187,7 @@
    
    updatecontext(__FILE__,__FUNCTION__,__LINE__);
 
-   if (gdata.exiting) return;
+   if (gdata.exiting || gdata.nospeedwarnings) return;
    
    for (i=0; i<MAXTRANS; i++)
       if (gdata.trans[i] != NULL
@@ -2140,6 +2281,32 @@
    ioutput(3,OUT_S|OUT_D,NULL,"Done");
    }
 
+
+
+int isbanned(const int i, const char* host)
+{
+  /* This function check to see if the host is in the list either
+     directly or via a netmask */
+  int x,y;
+  char *hptr;
+
+  if (!gdata.ignorelist[i] || !host)
+    return 0;
+  hptr=gdata.ignorelist[i]->hostname;
+  if (gdata.ignorelist[i]->flags & IGN_RANGE)
+    {
+      /* Its a range so we have to check the host name matches */
+      x=strlen(++hptr);
+      y=strlen(host);
+      if (y<x)
+	return 0;
+      return (!strcmp(&(host[y-x]),hptr))?1:0;
+    }
+  return (!strcmp(hptr,host));
+}
+  
+      
+	  
 
 /* End of File */
 
diff -BNru iroffer1.2b13/src/utilities.c iroffer1.2b13+cpitchfor11-doc/src/utilities.c
--- iroffer1.2b13/src/utilities.c	Sat Nov 10 17:06:40 2001
+++ iroffer1.2b13+cpitchfor11-doc/src/utilities.c	Wed Apr  3 19:29:35 2002
@@ -124,6 +124,11 @@
    return part;
    }
 
+char capchar(const char c)
+{
+  return (c>='a' && c<='z')?(c-32):c;
+}
+
 char* caps(char *text) {
    int i;
    if (text)
@@ -168,6 +173,126 @@
    return str;
    }
 
+int simpleformat(char* buffer, const int length, char* format,
+		   char* params, ...) {
+  /* This function will take format and replace %x with the corresponding values in the following string ie
+
+(buffera, 200, "%x is an integer, %y is a string", "xi", 200, "ys", "BLARGH", NULL);
+  */
+  va_list args;
+  struct {
+    enum {SMPFMT_NULL, SMPFMT_INT, SMPFMT_STR, SMPFMT_PLR, SMPFMT_BYT} type;
+    struct {
+      double fl;
+      int number;
+      char *string;
+    } value;
+  } fmt[128];
+  int x,spaceleft=length-2, used=0;
+  char* cptr=params;
+  double flo;
+  
+  if (length<2)
+    return 0;
+  if (fmt==NULL)
+    return buffer[0]=0,0;
+  for (x=0;x<128;x++)
+    fmt[x].type=SMPFMT_NULL;
+  va_start(args, params);
+  cptr=params;
+  while (cptr!=NULL) {
+    x=cptr[0];
+    if (x<0 || x>127)
+      return 0;
+    switch (cptr[1])
+      {
+      case 'i':
+	fmt[x].type=SMPFMT_INT;
+	fmt[x].value.number=va_arg(args,int);
+	break;
+      case 's':
+	fmt[x].type=SMPFMT_STR;
+	fmt[x].value.string=va_arg(args,char*);
+	break;
+      case 'p':
+	fmt[x].type=SMPFMT_PLR;
+	fmt[x].value.number=va_arg(args,int);
+	fmt[x].value.string=cptr+2;
+	break;
+      case 'b':
+	flo=(double)(va_arg(args,double));
+	printf("setting %c: %f%s\n",x,flo,cptr+2);
+      	fmt[x].type=SMPFMT_BYT;
+	fmt[x].value.fl=flo;
+	printf("got.. %1.2f\n",fmt[x].value.fl);
+	fmt[x].value.string=cptr+2;
+	break;
+      default:
+	return 0;
+      }
+    cptr=va_arg(args,char*);
+  }
+  fmt[0].type=fmt['%'].type=SMPFMT_STR;
+  fmt[0].value.string=fmt['%'].value.string="%\0";
+  cptr=format;
+  while (spaceleft>0)
+    {
+      x=0;
+      switch(*cptr)
+	{
+	case 0:
+	  buffer[0]=0;
+	  spaceleft=0;
+	  break;
+	case '%':
+	  cptr++;
+	  /*switch ((*cptr>=0 && *cptr<128)?fmt[(int)*cptr].type:SMPFMT_NULL)*/
+	  switch (fmt[(int)*cptr].type)
+	    {
+	    case SMPFMT_STR:
+	      x=isnprintf(buffer,spaceleft+1,"%s",fmt[(int)*cptr].value.string);
+	      break;
+	    case SMPFMT_INT:
+	      x=isnprintf(buffer,spaceleft+1,"%i",fmt[(int)*cptr].value.number);
+	      break;
+	    case SMPFMT_PLR:
+	      x=isnprintf(buffer,spaceleft+1,"%i%s%s",fmt[(int)*cptr].value.number,
+			  fmt[(int)*cptr].value.string,(fmt[(int)*cptr].value.number==1)?"":"s");
+	      break;
+	    case SMPFMT_BYT:
+	      {
+		double f;
+		char c;
+		f=getEngineerval(fmt[(int)*cptr].value.fl," KMGTPE\0", &c);
+		x=isnprintf(buffer,spaceleft+1,"%1.2f %c%s",
+			    f,c,fmt[(int)*cptr].value.string);
+	      }
+	      break;
+	    case SMPFMT_NULL:
+	      x=isnprintf(buffer,spaceleft+1,"%%%c", *cptr);
+	      break;
+	    }
+	  cptr++;
+	  break;
+	default:
+	  x=1;
+	  buffer[0]=*cptr;
+	  buffer[1]=0;
+	  cptr++;
+	}
+      
+      buffer+=x;
+      used+=x;
+      spaceleft-=x;
+  }
+  return used;
+}
+ 		
+
+	      
+
+
+
 int highestsock (void) {
    int i,highest;
    highest = 0;
@@ -198,6 +323,21 @@
    return highest;
    }
 
+double getEngineerval(const double value, const char *engfix, char *res)
+{
+  double fval=value;
+  int x,y;
+
+  if ((engfix==NULL) || ((y=strlen(engfix))<1) || (res==NULL))
+    return 0;
+  y--;
+  for (x=0;x<y && fval>1024;x++, fval/=1024.0);
+  *res=engfix[x];
+  return fval;
+}
+
+
+
 void getos (void) {
 
    struct utsname u1;
@@ -592,6 +732,20 @@
    
    }
 
+void allchanmsg(const char *message)
+{
+  int i;
+  char temp[maxtextlength];
+  temp[0]=0;
+  for (i=0; gdata.channels[i] && i<MAXCHNLS; i++)
+    {
+      if (temp[0]!=0)
+	strncat(temp,",",maxtextlength-strlen(temp)-1);
+      strncat(temp,gdata.channels[i]->name,maxtextlength-strlen(temp)-1);
+    }
+  privmsg (temp, "%s", message);
+}
+
 void privmsg(const char *nick, const char *format, ...) {
    char tempstr[maxtextlength];
    char tempstr2[maxtextlength];
@@ -1290,6 +1444,116 @@
    }
 
 #endif
+
+
+void badpackrotate(int now)
+{
+  if (gdata.curtime>gdata.badpack.badpacktime)
+    {
+      int i;
+      for (i=0;i<MAXBADPACK && gdata.badpack.list[i].hostmask;i++)
+	{
+	  mydelete (gdata.badpack.list[i].hostmask);
+	  gdata.badpack.list[i].hostmask=NULL;
+	  gdata.badpack.list[i].first=gdata.badpack.list[i].last=0;
+	}
+    }
+  else if (now || gdata.curtime>gdata.badpack.rotate)
+    {
+      int i,j;
+      for (i=j=0;i<MAXBADPACK && gdata.badpack.list[i].hostmask ; i++)
+	if 
+	  (gdata.badpack.list[i].first==0)
+	  {
+	    /* We can delete this entry.. */
+	    mydelete (gdata.badpack.list[i].hostmask);
+	    gdata.badpack.list[i].hostmask=NULL;
+	  }
+      else
+	{
+	  /* We have to rotated the data, and shuffle in necessary */
+	  gdata.badpack.list[j].last=gdata.badpack.list[i].first;
+	  gdata.badpack.list[j].first=0;
+	  if (j!=i)
+	    {
+	      gdata.badpack.list[j].hostmask=gdata.badpack.list[i].hostmask;
+	      gdata.badpack.list[i].hostmask=NULL;
+	    }
+	  j++;
+	}
+      gdata.badpack.rotate=gdata.curtime+(30*gdata.badpack.interval);
+    }
+}
+
+
+
+
+void _badpackremove(int pos)
+{
+  if (pos>=0 && pos<MAXBADPACK)
+    {
+      int i;
+      mydelete(gdata.badpack.list[pos].hostmask);
+      gdata.badpack.list[pos].hostmask=NULL;
+      for (i=pos+1;i<MAXBADPACK &&gdata.badpack.list[i].hostmask; i++)
+	{
+	  gdata.badpack.list[pos].first=gdata.badpack.list[i].first;
+	  gdata.badpack.list[pos].last=gdata.badpack.list[i].last;
+	  gdata.badpack.list[pos].hostmask=gdata.badpack.list[i].hostmask;
+	  pos++;
+	}
+      if (i<MAXBADPACK)
+	{
+	  gdata.badpack.list[i].first=gdata.badpack.list[i].last=0;
+	  gdata.badpack.list[i].hostmask=NULL;
+	}
+    }
+}
+
+int badpackadd(const char* hostmask, int *count)
+{
+  if (!hostmask || gdata.curtime>gdata.badpack.badpacktime)
+    return 0;
+  else
+    {
+      int i,q;
+      *count=0;
+      /* Step one, find the host in the list. Case insensitive */
+      for (i=0;i<MAXBADPACK && gdata.badpack.list[i].hostmask;i++)
+	if (!strcasecmp(gdata.badpack.list[i].hostmask,hostmask))
+	  break;
+      if (i==MAXBADPACK)
+	/* we have searched and all slots are full, and do not match
+	   therefore we silently let this person abuse us.. :( by returning 
+	   false... we could instantly ban them by returning true though!
+	   but that would be evil :)
+	*/
+	return 0;
+      if (!gdata.badpack.list[i].hostmask)
+	{
+	  strcpy(
+		 gdata.badpack.list[i].hostmask=
+		 mycalloc(strlen(hostmask)+1,"badpackadd"),
+		 hostmask);
+	  gdata.badpack.list[i].first=0;
+	  gdata.badpack.list[i].last=0;
+	}
+      
+      /* Found at location i */
+      if ((*count=(
+	   gdata.badpack.list[i].last + 
+	   (++gdata.badpack.list[i].first))) >= gdata.badpack.maxattempts)
+	{
+	  _badpackremove(i);
+	  return -1;
+	}
+      else
+	return 0;
+    }
+  
+}
+
+
 
 /* End of File */
 
