Commit Graph

935 Commits

Author SHA1 Message Date
Kevin Easton a329dd8404 Include vars.h in wserv.c and scr-bx.c for enum VAR_TYPES
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().
2017-05-10 23:19:57 +10:00
Kevin Easton 7173175adc Update "depend" target to include wterm.o, wnetwork.o and sterm.o
These special targets need to have their dependencies generated in a separate step.

Also update dependencies at the same time.
2017-05-10 23:16:40 +10:00
Kevin Easton 1c38eede94 Update source file dependencies in Makefile.in
Bring the dependencies up-to-date with a "make depend".

The major change seems to be adding modval.h and module.h as dependencies for most files.
2017-05-09 16:55:58 +10:00
Kevin Easton 84fc347f5a Move declarations of compat functions from ircaux.h to irc_std.h
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.
2017-05-05 00:28:21 +10:00
Kevin Easton 52b57d1576 Move the definition of the NotifyItem and NotifyList types from struct.h to notify.h
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.
2017-05-04 23:50:47 +10:00
Kevin Easton 65646f6b71 Include irc_std.h instead of irc.h in alist.h
Only irc_std.h is needed here, for the u_32int_t type.
2017-05-04 23:26:47 +10:00
Kevin Easton 6d50e933ee Remove unnecessary struct.h include from hash.h 2017-05-04 23:14:00 +10:00
Kevin Easton be65ab7adb Standardise include guard in modval.h
Move the #ifndef / #define together at the start of the file, to trigger the compiler's include
guard optimisation.
2017-05-04 00:05:02 +10:00
Kevin Easton 107774aa51 Remove unused opendir.c
opendir() / readdir() have been in POSIX since the beginning.  This file isn't hooked up to compile anyway.
2017-05-03 23:19:05 +10:00
Kevin Easton 6234efc2fd Remove unused scandir() compat implementation
scandir() isn't used anywhere within the client, so we don't need to bother with a compat
implementation for systems that don't have it.
2017-05-03 22:49:30 +10:00
Kevin Easton 74a0c89d26 Use the same compat.o and ircsig.o object files for all binaries
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.
2017-05-03 21:55:55 +10:00
Kevin Easton b3108dccff Remove last use of ltoa() from compat.c
Now that compat.c doesn't use any functions from the global table, it doesn't need to be differentially
compiled for wserv and scr-bx anymore.
2017-05-03 17:24:23 +10:00
Kevin Easton a0c4fc46b9 Remove long-dead snprintf compat code
These bogus compat implementations of snprintf() and vsnprintf() have long been superseded by the proper
implementations in the same file.
2017-05-03 17:07:28 +10:00
Kevin Easton 492d5658d1 Simplify handling of /DETACH socket path
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().
2017-05-03 00:13:24 +10:00
Kevin Easton aa04e465f3 Document and simplify the ltoa() / my_ltoa() distinction
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().
2017-04-30 23:33:58 +10:00
Kevin Easton 7ee8799b8e Minor fixes in dll_load()
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.
2017-04-24 17:34:07 +10:00
Kevin Easton afc4793cd8 Remove unnecessary variable from userhost_scanport() and findports() 2017-04-17 13:27:35 +10:00
Kevin Easton d851661942 Remove unused function argument from scan() 2017-04-16 23:28:18 +10:00
Kevin Easton 1ccd082cd2 Cleanup remove_channel()
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.
2017-04-16 16:19:55 +10:00
Kevin Easton 53f3a34ca5 Change channel argument of is_current_channel() to const char * 2017-04-16 16:14:13 +10:00
Kevin Easton 2eabfabc35 Change lookup_channel() channel argument to be const char * 2017-04-16 16:03:01 +10:00
Kevin Easton 274ba92c2e Remove useless NULL checks
m_strdup() never returns NULL.
2017-04-15 22:56:36 +10:00
Kevin Easton a01a93eaa3 Fix removal of DCC_PROC-type plugin addins
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().
2017-04-15 22:50:24 +10:00
Kevin Easton eca1e54602 Simplify addidle() a little 2017-04-11 01:54:31 +10:00
Kevin Easton 83770fd645 Simplify and clean up putlog() 2017-04-11 01:44:47 +10:00
Kevin Easton 3cf21ccc9d Simplify a conditional expression 2017-04-11 01:27:31 +10:00
Kevin Easton 170b79c0d0 Switch /VER command to use ctcp_simple() 2017-04-11 01:24:36 +10:00
Kevin Easton bad8c2fa02 Remove netfinger client code and repurpose /FINGER command to send a CTCP FINGER instead
No-one runs fingerd servers anymore so this code was entirely obsolete.
2017-04-11 01:19:32 +10:00
Kevin Easton eace841366 Enable use of cached whowas info for /IG* and /UNIG* commands
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.
2017-04-05 22:55:43 +10:00
Kevin Easton 484fc156ed Remove HAVE_SSL define from configure
This is no longer needed, we use the HAVE_LIBSSL from AC_CHECK_LIB now.
2017-03-17 01:27:30 +11:00
Kevin Easton 184af728c7 Add support for OpenSSL 1.1.0 to configure script
OpenSSL 1.1.0 removed the SSLeay() function and replaced it with a macro, that AC_CHECK_LIB can't see.

Search for ERR_get_error() instead.
2017-03-17 00:38:46 +11:00
Kevin Easton 2fa0bf818a Replace uses of HAVE_SSL with HAVE_LIBSSL
autoconf's AC_CHECK_LIB automatically sets HAVE_LIBSSL, whereas HAVE_SSL has to be set manually.

This prepares us to remove some code from configure.
2017-03-17 00:07:38 +11:00
Kevin Easton 1fbafddc59 UNBAN <nick> can use cached whowas info to unset bans
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().
2017-02-25 00:34:58 +11:00
Kevin Easton 3a5a489f25 Add option to check_whowas_nick_buffer() to scan all channels in whowas list
Passing NULL channel lets you scan the full whowas list, which is useful for functions not tied to a channel
like ignore.
2017-02-22 23:03:17 +11:00
Kevin Easton 2363ea709d Remove unused 'unlink' argument from check_whowas_nick_buffer()
Every caller was passing 0 for unlink, so remove it.  This simplifies the function.

Also change the nick and channel arguments to const char *.
2017-02-22 22:28:17 +11:00
Kevin Easton 0c721de2a5 Remove dead code and clean up convert_output_format_raw()
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.
2017-02-18 01:04:39 +11:00
Kevin Easton 61ff399b3d Remove superfluous test for current_window
It is always non-NULL, and we dereference it unconditionally anyway.
2017-02-18 00:32:23 +11:00
Kevin Easton 5574ff043b Replace an alloca() call with new_malloc() / new_free()
This also cleans up the code here a bit.
2017-02-18 00:00:45 +11:00
Kevin Easton e5b2a65fe2 Remove pointless NULL test and unreachable return
There is no point testing ptr for NULL - we dereference it anyway, this function can't be called with a
NULL pointer for the first argument.
2017-02-17 21:55:11 +11:00
Kevin Easton a0e8bd5742 Cast pid_t to long for fprintf()
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.
2017-02-17 16:50:41 +11:00
Kevin Easton 686344314f Unsetting CMDCHARS sets it back to the default
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.
2017-02-16 23:42:52 +11:00
Kevin Easton debfebf3a7 Fix a double-free bug when a window on an alternate screen queries an exec process
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).
2017-02-16 23:12:38 +11:00
Kevin Easton 790cb771ed Use 127.0.0.1 for wserv socket, which fixes /WINDOW CREATE with IPv6
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.
2017-02-16 22:06:32 +11:00
Kevin Easton 1f062fb7de Remove unnecessary repeated check
tmp has already been tested in the previous line.
2017-02-12 23:55:16 +11:00
Kevin Easton 3d353f5a48 Remove dead store to a variable 2017-02-11 22:42:32 +11:00
Kevin Easton 95ad004ff0 Remove unused function is_ignored() 2017-02-08 23:56:36 +11:00
Kevin Easton ce92ddc8fc Fix typo in unused function is_ignored() 2017-02-05 00:09:51 +11:00
Kevin Easton bbaeca3bc3 Allow INVITE and WALLOP floods to trigger auto-ignore
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.
2017-01-25 17:12:38 +11:00
Kevin Easton 27b2f3e939 Change ignore_type() arguments to (const char *, size_t)
This just changes the arguments to match the strncmp() calls in the function.
2017-01-21 14:23:57 +11:00
Kevin Easton 69296c2c5a Switch *_FLOOD constants to sequential rather than bits and add flood type lookup table
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.
2017-01-21 14:17:42 +11:00