This allows building against recent libtcl versions.
A fallback definition of Tcl_GetStringResult() is included so that building against libtcl 7 still works.
This means the calling code in commands.c no longer needs to take a copy before calling the function.
Also remove code testing result of of ctcp_quote_it() and ctcp_unquote_it() - these functions never fail.
These functions are really specific to parsing and creating CTCP SED messages, which means they belong
in ctcp.c with the other CTCP code.
Also remove unnecessary inclusions of encrypt.h and ctcp.h.
Use size_t for passing buffer lengths, and const char * for encryption keys and other non-modified buffer
arguments.
Remove pointless helper function do_crypt().
Remove the inclusion of color.h from config.h, which is included by every file via irc.h, and instead
include it only in debug.c, fset.c and vars.c which are the only files that use it.
This minimises the number of files that need to be rebuilt when changing default format strings.
Encrypted messages to a channel need to use their own format. This also fixes the use of ENCRYPTED_PRIVMSG
and ENCRYPTED_NOTICE - they were being called with too many arguments so the destination nick was being prepended
to the message text.
Actual encryped messages and notices are now printed directly from do_sed() / do_reply_sed().
Inline CTCP replacement is only done if the message cannot be decrypted (for the [ENCRYPTED MESSAGE]
placeholder).
This removes the need for the global flag 'sed' to alter the NOTICE and PRIVMSG handling.
A side-effect of this is that SED PRIVMSGs now do not go through the usual PRIVMSG ignore
and flood handling. This is acceptable because messages can only go through this path if
the sender has actually been added as a SED peer with /ENCRYPT, and it still goes through
the CTCP ignore and flood handling.
This flag is for tracking if we've sent a KICK for a nick. It means we can avoid
sending duplicate KICKs (eg for floods, channel protection etc).
MODULE_VERSION is bumped because NickList is a struct exported to modules.
This test is done quite a bit across the tree, and the open-coded variants make it easy to have an
accidental mismatch between the length of the prefix being tested and the length actually passed to
strncmp().
This fixes an issue of that type comparing the server version against the prefix "u2.10", where the old
code used an incorrect length of 4.
Tokens that begin with two underscores __* or an underscore and an uppercase letter _X* are reserved,
so we should avoid those for our own include guards. The standard I'm settling on for foo.h is FOO_H_.
Also define STERM_C and include modval.h in scr-bx.c.
This allows us to remove the slightly bogus dummy definition of enum VAR_TYPES from modval.h, and use a simple
macro to redirect the declaration and use of get_int_var() to BX_get_int_var().
irc_std.h is where these belong - it's where the normal declarations (via the system headers) come from on
systems which don't need the compat functions.
This change means that struct.h no longer needs to include alist.h, so it will be indirectly included in a lot
fewer other files.
As a consequence, server.h needs to include notify.h to get the definitions of those data types.
init_socketpath() was building a sprintf() format string intended to be used by /DETACH to create the socket
file name. This included the actual socket path, plus a %d for the port, plus the sanitised tty name and
hostname.
Only one caller needed all this though - the /DETACH command - and the other callers (in scr-bx.c) just
wanted to truncate it to the actual socket path. The format string also wasn't safe - if the home directory
path, hostname or ttyname contained % characters these werent being escaped.
It simplifies things to have init_socketpath() just return the actual socket path, after creating the 'screens'
directory if necessary. This lets the code in scr-bx.c use it as-is, and removes the need for the global
socket_path variable. The code to include the sanitised tty name and hostname in the socket file name can
be moved to the create_ipc_socket() function.
There's no need to check access() for the socket path before trying to create it - just call mkdir() regardless,
since it will fail if the path already exists, which is fine.
This commit also adds error handling to the create_ipc_socket() function for the case where creation of the
socket file fails, and switches the chmod() and chown() for the opened file to the more appropriate fchmod()
and fchown().
The function provided (either by #define to the module table or directly in the case of scr-bx.c)
is called my_ltoa(), and the #define in irc_std.h aliases this to ltoa().
remove_channel() is only called in direct response to a message from a server,
so it always acts on from_server - remove the unnecessary server argument.
The channel argument is always non-NULL - remove the dead code that removed all
channels if a NULL channel was passed.
The declaration of dcc_dllcommands in modules.c was wrong - add it to dcc.h so it's checked against the definition in dcc.c
and include it from there.
The DCC_dllcommands structure isn't structured like a "List2" so remove_module() doesn't work - use remove_from_list_ext().
Using sequential constants for *_FLOOD constants means that we can use a simple lookup table to convert them
into text for display and IGNORE_* constants.
This adds a FLOOD_FLAG() macro to convert a _FLOOD constant to the appropriate flag. For now this just
casts the argument to unsigned int.
Rename Flooding.type to Flooding.flags and change it to unsigned int, to reflect that it's a bitfield of
flags for multiple flooding types.
All callers of flood_prot() were supplying { get_flood_types(flood_type), flood_type } as the second and third arguments,
except one that supplied { get_flood_types(CTCP_FLOOD), CTCP_ACTION_FLOOD }.
Hardwiring this logic in to flood_prot() lets us remove the 'type' argument without changing the behaviour.
The static 'pos' variable in check_flooding() would not stay in sync with the number of entries in
flood_list after clean_flood_list() was called. This meant that check_flooding() would always end up
removing all previous entries if it tried to add a new one.
Fix this by removing the tracking of number of flood_list entries, and just removing stale ones (older
than /SET FLOOD_RATE).
Checking before truncation means you can sneak a privileged port past the check.
This change also collects the various broken-out parts of a CTCP DCC offer into a struct so that
it's easier to pass them all around together.
glob_commands() would run off the end of the irc_command array if given a match that matched
the last command. It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().
This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string. Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().
Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
The 'channels' argument was unnecessary because the channel list passed to it would
always be from get_server_channels(server) anyway.
Changing the message argument from a protocol message format string to a plain payload
string for PRIVMSG means printf-escaping of the argument is avoided in the caller.
This simplifies the callers and means we can remove the last use of quote_it().
This change also switches set_server_away() to use send_msg_to_channels() instead of
open-coding the equivalent, which simplifies that function a lot.
We are changing the signature of a function exported to modules here; however none
of the in-tree modules use this function so it should be OK.
Identifiers beginning with two underscores or one underscore and a capital
letter are reserved in all contexts, including macros.
The __N macro in irc_std.h is in this space, and was conflicting with a macro
definition in gcc 5.4.0's xmmintrin.h under cygwin, making the build fail.
Reported-By: ice-man
This FSET has existed for a long while but has been unused for some time,
since before the userlist was reworked to use flags instead of levels. This
means that the default value for the FSET also has to be updated.