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.
Neither compat.c nor ircsig.c are compiled different for wserv or scr-bx, so there's no reason these
binaries can't just link to the same .o files as the main BitchX binary.
This also cleans up the build rules around wserv and scr-bx a little.
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().
The test for p != NULL is pointless, it has already been dereferenced and modified.
The argument to tolower() and toupper() must be in the range of unsigned char.
Fix some spelling errors in user-visible messages.
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().
Previously these codepaths were dead because it was passing an argument like "+HOST" to check_whowas_nick_buffer()
in place of the channel name, so it would never find anything.
Now that function supports a NULL channel to mean "any channel", so we can use that. The actual code itself needed to be
fixed as well, it's now similar to the way userhost_unban() is written.
The use of the whowas cache in userhost_unban() would never work, because it was passing 'args' as the channel
name which also included the window number.
Rework this substantially, including using lookup_channel() and set_display_target() in place of prepare_command().
The second branch of if (str) ... else if (str) is dead code, remove it. Also remove the if() entirely because
the while condition covers it exactly anyway.
Move the static variables used only in this function to function scope.
Change color_mod to const static and remove unneeded variable c_mod.
Move the increment of cparse_recurse to after the point where we bail.
None of this should have any user-visible impact.
pid_t is defined by POSIX to be a signed integer type, so the %u format is wrong.
Cast to long and print with %ld - it is unlikely that any real-world system has pid_t bigger than long.
Previously you could unset CMDCHARS and the effect would be to treat it like it was set to DEFAULT_CMDCHARS,
except that some code was missing the fallback (eg. ignore_last_nick()) which would make it crash.
Instead of having the fallback everywhere, just make it so that you can't unset the variable - if you try, it
sets it to DEFAULT_CMDCHARS. This reflects what the behaviour has always been, it just makes it explicit to
the user and the bonus is we don't have the test it for NULL everywhere.
The 'free_it' variable was only initialised to zero at the start of the function, so when non-main screens
were processed in the later iterations of the loop, it could keep a value of 1 from the previous iteration.
We don't actually need a free_it variable at all - just use a NULL value of ptr_free to indicate that there
is nothing to free (and passing a NULL to new_free() is a no-op).
This also simplifies a test because ptr is always non-NULL (strip_ansi() never returns NULL).
If wserv is told to connect to "localhost" it might try to connect to ::1, which won't work because
the wserv socket is AF_INET only.
So explicitly bind the socket and make the connection to "127.0.0.1" instead.
Previously, INVITE and WALLOP were tracked for flooding, but if the flood triggered then the auto-ignore
didn't happen. As far as I can tell, this was just an oversight.
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.