The intention is to display this message when the client has failed to
connect to enough servers that it has to start back at the initially
requested server again.
The old code instead had some quite odd conditions.
The previous code relied on server[i].retries being equal to one less than the
number of connection attempts that had been made on entry to advance_server(), but
this was false for the initial connection attempt.
Change the code instead so that on entry to advance_server(), server[i].retries is
always the number of previous connection attempts that have been made. This does the
right thing for initial connection attempts since .retries starts at zero.
finalize_server_connect() can fail for SSL connections, because SSL_connect() can fail. Without this change, the client won't
try to reconnect after an initial SSL connection failure - it'll just wait forever.
Reported by g0z, thanks!
This code contained a bug where any argument to /HISTORY that _didn't_ start with "-CL" would clear history,
so no number or pattern argument could successfully be passed.
With this fix only an argument that case-insensitively matches "-clear" will clear history, so a pattern
argument will also work correctly.
This also counts beeps, tabs and non-destructive spaces in the same way.
To maintain historical behaviour, BEEP_MAX of zero indicates no beeps allowed (the same
as /SET BEEP OFF), but TAB_MAX and ND_SPACE_MAX of zero indicates no limit.
Change remove_all_dcc_binds() so that it only removes DCC binds for the module supplied, as it's supposed to.
get_dcc_type() should ignore the first entry in dcc_types[] ("<none>") otherwise the client will try to
respond to DCC requests with that name.
Explicitly track the number of entries in the dcc_types[] array rather than using a NULL terminator. This
allows us to change dcc_types[] to use NULL entries to mark unused slots in the array, rather than pointers
to entries with a NULL .name element. Together, this means that the dcc_types[] array is only resized when it
actually needs to be grown and removal works correctly (without eg. prematurely marking the end of the array).
Make add_dcc_bind() fail if the requested DCC type has already been bound by a module (this still allows one
module at a time to rebind a built-in DCC type). Previously the behaviour was ill-defined in this case.
Remove the empty Arcfour_Cleanup() function so that the default module cleanup can happen.
Define MODULE_NAME and use that when registering the module callbacks so that the default
module cleanup will remove them correctly.
The idea here is that if you have a module which implements a new DCC type that is essentially
a lightly-modified version of CHAT or SEND you can reuse these functions.
This function gets the status of a single umode flag identified by umode char rather than
internal server flag number.
This also lets us remove all the USER_MODE* constants because they're no longer required.
Invert the sense of the +w check in e_wall() - we only echo our OPERWALL if we're *not* +w,
because if we are +w then the server will echo it back to us anyway.
server.ctx is now allocated once for each server on first connection, then reused for subsequent connections.
server.ctx wasn't being cleared when the server was closed (as server.ssl_fd is), so this was causing
reconnection to fail until try_connect() got called.
This also removes the last uses of the CHK_* macros in ssl.h, so remove them.
This avoids leaking memory.
Also change to always call SSL_shutdown() regardless of whether a QUIT message was sent. No
need to call SSL_shutdown() from write_to_server(), close_server() will do it for us.
Remove "Closing SSL connection" message.
The -s flag resets after the next server on the command line, but it was also incorrectly resetting
if a nickname was seen as well. This meant that a command line like this failed to use SSL:
BitchX -s -p 9999 gauze irc.choopa.net
Also update the help text to correctly reflect the operation of the -s flag.
Reported by gauze.
The only external change here is that it now always sets *cnt to 0 when it returns NULL
Previously, it could set it to -1 in some cases, in particular when dll_commands is NULL.
This led to a bug where /HELP would show the wrong number of matching commands, because it
added the return value of find_dll_command() to the number of matching internal commands.
Also fixes a set-but-unused-variable warning.
Remove the 'how' parameter to rsindex(), making it reverse-search for only the first matching character,
as sindex() already does. There are only two callers, and one already passed a hardcoded value of 1.
Also change rsindex() so that it starts searching at the character BEFORE the passed in position. This
makes it easier to repeatedly call rsindex() in a loop to search for the Nth matching character, and
also fixes a technical instance of undefined behaviour where a pointer is decremented to point before
the start of the string.
Remove the 'mark' parameter to strsearch(). Instead, always forward-search from the beginning of the
string and reverse-search from the end of the string, as this is what the two callers want anyway.
Bump the module ABI version because these functions are exported to modules.
The removed variables are:
dll_functions
dll_numeric
dll_commands
dll_variable
dll_ctcp
dll_window
These are not actually directly used by any modules, and hiding them allows us to more easily
change their implementation later.
This helper function is for modules to save the contents of their module variables to a file
as SET commands.
It will remove the need to export the raw dll_variable list to modules.
As reported by Ancient, this is how it is documented to work. It's also how shitlist level 2 works, so
it's consistent this way.
Some other cleanups in check_auto() while we're here.
A fractional-second timeout was already supported for the initial timeout of a /TIMER, but
if the timer was recurring then the interval was rounded to a whole number of seconds for
the subsequent timeouts.
Change the type of interval from long to double to fix this.
Separate out the justification step of make_status() into a new function, so it can be wired in to
stat_convert_format() as well. This makes $statsparse() work correctly with right-justified status
formats.
Minimise the amount of copying around that is done during the justification - instead, we can just
remember pointers into the buffer returned by strip_ansi() for the left-hand-side, right-hand-side and
padding character.
Don't keep concatenating onto the same buffer with strlcat() when generating the padding - that gives
n^2 behaviour. Instead keep a pointer to the current end and concatenate there.
Ensure buffer is null-terminated before calling strlcat() on it, in stat_convert_format().
The guts of this function doesn't need to be in server.c - it only uses extern server functions so it
makes sense just to move it into the body of function_servers(), the only caller.
That means it's no longer accessible for loadable modules, but it isn't much use for them anyway. They
can always directly access the server list if they need that info.
(Requires rolling the module table version).
When $myservers() is called with an argument of 1 it is supposed to only return the refnums of servers
that are registered (ie. those which it is legal to send a command to). This is the way EPIC works, and
it was always intended to work this way in BX too.
Also fix the warning about a NULL itsname - we use our name for the server if it isn't registered yet.
Remove the slightly bogus use of strncat() while we're here, by removing the temporary stack buffer and
just directly creating the result string with m_s3cat().
Remove the 'resend_only' flag option to fudge_nickname(). The only caller passing it was the CHANGE_NICK_ON_KILL
feature, and in that case it was the wrong thing too (and stopped that function from working at all).
Some other minor cleanups in fudge_nickname() while we're there.
Unset MSGLOG_FILE or CTOOLZ_DIR could cause a null pointer dereference.
If stat() failed it dereferenced the bogus 'struct stat', and in the directory case
just silently failed. Now it falls through to the "error opening" path.
This allows building against recent libtcl versions.
A fallback definition of Tcl_GetStringResult() is included so that building against libtcl 7 still works.