Commit Graph

577 Commits

Author SHA1 Message Date
Kevin Easton
c62e099d80 Add /FSET SEND_ENCRYPTED_PUBLIC format
Used when sending an encrypted message to a channel.
2017-06-28 00:03:09 +10:00
Kevin Easton
88f93c1de3 Only include color.h in source files that require it
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.
2017-06-27 18:22:45 +10:00
Kevin Easton
72ee3e6297 Correct order of arguments to /FSET SEND_ENCRYPTED_MSG and SEND_ENCRYPTED_NOTICE and improve default formatting
The argument order and default format now mirrors SEND_MSG / SEND_NOTICE but with different colours.
2017-06-27 16:27:59 +10:00
Kevin Easton
ed597221f2 Add ENCRYPTED_PUBLIC and ENCRYPTED_PUBLIC_NOTICE formats
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.
2017-06-27 14:21:12 +10:00
Kevin Easton
0c51ac19d4 Cleanups and simplifications in p_privmsg 2017-06-26 17:11:08 +10:00
Kevin Easton
0e9925f122 Minor simplification to beep_em 2017-06-26 16:54:50 +10:00
Kevin Easton
06aa5cb671 Move all handling of SED messages and notices into ctcp.c, re-enable SED notices
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.
2017-06-26 15:13:40 +10:00
Kevin Easton
fb8dfc3946 Handle SED-encrypted CTCP replies properly
When a SED-encrypted NOTICE is scanned for CTCPs within the decrypted portion, they should be
handled with do_notice_ctcp() so they are treated as CTCP replies.
2017-06-22 00:03:53 +10:00
Kevin Easton
64d524804c Test sent_kick instead of kickcount for KICKFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:36:53 +10:00
Kevin Easton
07ab60f3ff Test sent_kick instead of kickcount for NICKFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.

The userlist and isme() tests are already done prior to calling handle_nickflood() so they are
not needed here.
2017-06-11 00:33:33 +10:00
Kevin Easton
50608f65ff Test sent_kick instead of kickcount for DEOPFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:26:57 +10:00
Kevin Easton
3caf308ea0 Test sent_kick instead of kickcount for JOINFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:23:39 +10:00
Kevin Easton
6b1fcf9c75 Add sent_nick flag to NickList struct, bump MODULE_VERSION
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.
2017-06-11 00:08:07 +10:00
Kevin Easton
b4ec2f6a0e Minor cleanups in p_kick()
Remove dead store to ptr.  Rename 'who' to 'target'.
2017-06-10 23:34:22 +10:00
Kevin Easton
5237136083 Replace writestr() with a simple fputs() call 2017-06-09 16:15:47 +10:00
Kevin Easton
4ae2c5ebdd Write correct length to terminal for unflash sequences
Introduce a wrapper for fwrite() of a full string to the current_ftarget.
2017-06-09 00:42:57 +10:00
Kevin Easton
917a04ce66 Use correct printf format for current_numeric 2017-06-08 23:31:10 +10:00
Kevin Easton
60dc1afdca Remove unnecessary duplicated NULL tests in handle_server_stats()
Also make handle_server_stats() static.
2017-06-08 23:17:06 +10:00
Kevin Easton
529b1e0aa0 Small cleanup of code for CTCPs over DCC CHAT 2017-06-07 00:30:12 +10:00
Kevin Easton
0a16ab16ac Introduce strbegins() macro and replace all open-coded instances
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.
2017-06-06 23:47:10 +10:00
Kevin Easton
09395464ff Don't check notifies if the interval is zero, even if the clock has gone backwards 2017-05-30 22:52:42 +10:00
Kevin Easton
09ab7a2130 Cleanup check_auto_invite() and make it static 2017-05-29 16:12:11 +10:00
Kevin Easton
fb35a00d1d Add const to nick pointer passed to find_nicklist_in_channellist() 2017-05-29 15:54:57 +10:00
Kevin Easton
8f4b5600a5 Make the tcaps table const and static
This table isn't modified or referenced outside of term.c, so it can be const static.

The 'const' moves ~20K from the data segment to the text segment (on 64 bit), reducing the total size of
the BitchX data segment by 10%.
2017-05-12 11:24:00 +10:00
Kevin Easton
790ba5b428 Remove irc.h include from ircsig.c
Nothing in the irc.h header is required.
2017-05-10 23:41:32 +10:00
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
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