Commit Graph

138 Commits

Author SHA1 Message Date
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
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
Kevin Easton
81ddf52909 Introduce an enum flood_type for the *_FLOOD constants
This allows the debugger to show the decoded constant name.
2017-01-19 17:10:32 +11:00
Kevin Easton
fef98f43ba Separate notion of _FLOOD constant from the flags stored in the Flooding struct
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.
2017-01-18 17:03:06 +11:00
Kevin Easton
78dbdea441 Remove 'type' argument of flood_prot()
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.
2017-01-18 00:11:49 +11:00
Kevin Easton
21a12c004b Correct issue where flood detection could become unreliable
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).
2016-11-26 00:08:59 +11:00
Kevin Easton
6cac0e6bb1 Truncate DCC port to unsigned short before checking for a privileged port
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.
2016-11-02 23:58:11 +11:00
Kevin Easton
a5b78db7db Remove pointless typedef my_uint in struct.h 2016-11-02 16:55:10 +11:00
Kevin Easton
da1618d393 Constify pointer return value of find_command() 2016-10-16 00:45:41 +11:00
Kevin Easton
9a2792345f Fix crash and memory leak in $aliasctl(COMMAND MATCH)
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.
2016-10-15 00:41:34 +11:00
Kevin Easton
dec7caafd0 Change 'name' argument of find_fixed_array_item() to const char * 2016-10-15 00:17:31 +11:00
Kevin Easton
eb4b2a29d6 Remove unused function quote_it()
This function is no longer needed.  It was problematic anyway because it didn't have a way for
the caller to specify the destination buffer size.
2016-10-13 01:44:29 +11:00
Kevin Easton
04cf832604 Change send_msg_to_channels() to remove 'channels' argument and always use PRIVMSG
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.
2016-10-13 01:36:19 +11:00
Kevin Easton
41d98dc5f5 Rename reserved identifiers in irc_std.h
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
2016-10-08 00:35:46 +11:00
Kevin Easton
23967ba5be Wire up /FSET WHOIS_BOT for users on the userlist with the BOT flag
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.
2016-05-25 23:38:11 +10:00
Kevin Easton
9fb317b07d Improve formatting of SERVER_NOTICE_CLIENT_CONNECT and SERVER_NOTICE_CLIENT_EXIT 2016-05-10 18:49:18 +10:00
Kevin Easton
43d482a444 Change /FSETs SERVER_NOTICE_KLINE and SERVER_NOTICE_GLINE to show the ban type
The ban type (eg. K-Line, G-Line, D-Line etc.) is now passed in the second-last
argument of these formats.
2016-05-10 18:30:55 +10:00
Kevin Easton
df2e250ccf Clean up handling of oper server notices
This switches from somewhat gory string parsing based on strncmp() and next_arg() to a simpler alternative
based on sscanf().  I think these are much easier to understand now, and shouldn't have any subtle bugs
lurking like the old code.

This also removes support for some obsolete messages that don't seem to be in any modern ircds:
"Identd reponse differs"; bot messages like "Rejecting vlad/joh/com bot:" except for "is a possible spambot"
which is still in use; and the "High-traffic mode" messages.
2016-05-07 00:44:29 +10:00
Kevin Easton
6b0aa0f8fe Remove unnecssary space at the start of SERVER_NOTICE_* formats
Also fix up similar hardcoded formats in notice.c.

The space isn't needed because serversay() adds a space (and has done for
a very long time).
2016-04-14 22:22:05 +10:00
Kevin Easton
d236b19410 Don't double-up server notices in the /RELS list
serversay() calls add_last_type(), so there's no need for the callers to do so
as well.

Remove the first argument to serversay() because it was always called with 1
anyway.
2016-04-14 21:51:49 +10:00
Kevin Easton
9e4602360a Remove the extra space from default SERVER_NOTICE format
Remove the extra space in the default /fset SERVER_NOTICE, and similarly
the extra space in the HUMBLE /set SERVER_PROMPT.

The code in the client always _intended_ to add a space between SERVER_PROMPT
and SERVER_NOTICE_FSET but a bug in 75p3 and below meant it that it didn't.
This bug was fixed in 1.0b but the formats were never updated.

Also remove replace the embedded ANSI in the default SERVER_PROMPT with
% color code.
2016-04-09 00:36:08 +10:00
Kevin Easton
1f64201362 Always treat NOTICEs received before registration as local server notices
We don't know the server's proper name until registration, so the test against
that isn't reliable.  We shouldn't be able to receive messages from anyone else
until we're registered, so this should be safe.

This requires changing serversay() to accept the from name instead of the
from_server.  While we're there, replace the use of alloca() with simpler
logic based on m_sprintf().
2016-04-07 00:11:27 +10:00
Kevin Easton
b1277f75d4 Add /on NOTICE_GROUP and /fset NOTICE_GROUP analogous to MSG_GROUP
This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org.  This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).

Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.

This will also catch server notices sent before you're registered.
2016-03-31 23:55:14 +11:00
Kevin Easton
05eb8d946f Removed unused DEFAULT_FORMAT_MSG_GROUP_AR_FSET macros
There is no MSG_GROUP_AR fset.
2016-03-31 21:39:20 +11:00
Kevin Easton
d464bd91fb Remove unnecessary inclusions of <numbers.h>
Functions display_msg() and check_sync() are only used in numbers.c, so they
can be static.

Remove inclusions of <numbers.h> from .c files that don't need it.
2016-03-24 11:21:09 +11:00
Kevin Easton
f129ca29e7 Move got_initial_version_28() from notice.c to numbers.c, where it belongs 2016-03-24 00:08:57 +11:00
Kevin Easton
83741aca7a Add configure check for <sys/sockio.h>
Some systems need <sys/sockio.h> for the SIOCGIFCONF ioctl - this switches
to using a proper configure check for that header rather than just assuming
it'll be there if we can't find SIOCGIFCONF.  Should be more robust.
2016-03-20 23:48:31 +11:00
Kevin Easton
82d606979b Add HAVE_*_H checks around inclusions of netinet/in.h and sys/socket.h
Only include <netinet/in.h> and <sys/socket.h> if the system supplies them.
This is necessary to try and get the mingw32 build working again.

No need to include <sys/types.h> and <netinet/in.h> from cdns.c - these are
already included by <irc.h>.
2016-03-17 21:39:17 +11:00
Kevin Easton
a2e8e103e0 Modularise handling of DCC offers
There's several different types of DCC offers, all of which need slightly
different handling.  Previously they were all handled by the monster function
register_dcc_type() - this breaks them out into seperate functions for handling
SEND, RESEND, CHAT and BOT offers, moves common code into static helper
functions and renames the entry point from ctcp.c to handle_dcc_offer().

This will allow adding a way for modules to register DCC offer types that
they're interested in.

This also moves rename_file() from misc.c into dcc.c, where its only user is.
2015-10-28 21:46:38 +11:00
Kevin Easton
af3b0c920a Change find_name_in_genericlist() to take const char * argument 2015-10-28 21:42:33 +11:00
Kevin Easton
f2262d5b01 Change hash_nickname() to take a const char * argument 2015-10-28 21:38:26 +11:00
Kevin Easton
a24f1d12ec Convert lookup_userlevelc() to accept const char * parameters
Also converted dependant functions check_channel_match() and
find_bestmatch() to use const char *.
2015-10-20 23:12:33 +11:00
Kevin Easton
cfe6735ef0 Simplify find_dcc() and find_dcc_pending()
Extract the common DCC matching code into one function and simplify
it a little.
2015-10-12 16:26:23 +11:00
Kevin Easton
ce3fd79652 Global spelling fix s/recieve/receive/ across codebase
This includes some user-visible messages and help files, so if anyone has
hooked them with /ON WINDOW their hooks will need updating.
2015-10-04 09:06:38 +11:00
Kevin Easton
726884b0b0 Ignore DCC ACCEPT if we didn't request a DCC RESUME
Mark DCC connections that we have requested RESUME on, so that we know
whether or not to act on a DCC ACCEPT that is received.

Also fixes up a slightly wrong message in /DCC RESUME.
2015-10-04 00:44:47 +10:00
Kevin Easton
c173af3f65 Remove unused DCC_CNCT_PEND flag and always define DCC_SSL
DCC_CNCT_PEND was only ever set, not tested, so it was pointless.

There's no point only defining DCC_SSL when HAVE_SSL is defined: we can't
re-use that flag bit anyway, so might as well just define it always.

Also fixes a "flags && DCC_WAIT" that should have been "flags & DCC_WAIT".
This has no practical effect though I believe, since as far as I can tell
DCC_WAIT would always be set at that point anyway.
2015-10-03 22:10:15 +10:00
Kevin Easton
9606ab312f Remove now-unused stripansi() function. 2015-09-06 22:54:12 +10:00
Kevin Easton
d62914af15 Optimise add_last_type() and change it to accept const char * pointers
The optimisation reduces the number of malloc_strcpy() calls, from 50 to 5
for most last types.
2015-09-03 01:04:12 +10:00
Kevin Easton
c881dd7a9a Change 'from' and 'format' arguments of logmsg() to const char *
This allows callers to pass const char * pointers to them.
2015-09-02 23:39:53 +10:00
Kevin Easton
498631e74a Introduce get_kick_reason() and switch all kick commands to use it
get_reason() is then used only for the implementation of get_kick_reason()
and for the $getreason() scripting function.  Add current nick as an
explicit argument for get_reason(), which pushes all use of from_server
out of the ransom reason functions.

Also switch a few instances of send_to_server() to my_send_to_server() where
the current server has been returned by prepare_command().
2015-06-28 00:35:50 +10:00
Kevin Easton
ff251080da Add get_kill_reason() that uses BitchX.kill, and convert all /KILL users to it
Previously only send_kill() used BitchX.kill - the other KILL commands (eg.
/WHOKILL) were using the random kick reasons.  Standardise them all on
BitchX.kill, and add this file to the source so it can be installed along
with the other random reason files.
2015-06-27 23:18:38 +10:00
Kevin Easton
27e32a0319 Cleanup and simplify get_reason() and related functions
Rename randreason() to fread_random() to better reflect its function,
and change it to a one-pass algorithm.  Have it write into a caller-provided
buffer instead of a static buffer.  Fixes a file leak when an empty
file is given to this function.

Change freadln() so that it never returns an empty line - it only returns
0 at end-of-file now.  This simplifies its callers.

Factor out some common code from the several get_reason()-type functions,
which greatly simplifies them.
2015-06-27 00:38:40 +10:00
Kevin Easton
69bbcfd83d Convert stripansi() from unsigned char to char
This silences a few compiler warnings.

This also cleans the function up by removing some always-true checks.
I'm not convinced that this function makes a whole lot of sense, though.
Will look into it further...
2015-06-21 00:18:03 +10:00
Kevin Easton
b0f0124779 Don't compile convert_output_format2() in non-GUI builds
This function is only used by the GUI menu code, so we don't need to
build it for normal builds.

Also clean up some unsigned char / char mismatches that the compiler warned
about.
2015-06-20 23:42:04 +10:00
Kevin Easton
cce8b30079 Switch write_sockets() and read_sockets() from unsigned char * to char * 2015-06-20 08:43:00 +10:00
Kevin Easton
8649c17912 Change edit_char() from unsigned char to char
This squashes a few more warnings.
2015-06-20 00:03:15 +10:00
Kevin Easton
53f7c374cf Convert strip_ansi() from unsigned char to char
This required a few careful changes to ensure that the result does the same
thing.

Also included a few little cleanups in this function.
2015-06-19 23:12:10 +10:00
Kevin Easton
d0b0a95330 Convert skip_ctl_c_seq() and its callers (except strip_ansi()) from unsigned char to char
This should make no functional difference, and cuts out a large number of
unsigned char * / char * mismatch warnings.
2015-06-17 22:50:49 +10:00
Kevin Easton
563493dd6a Add COLOR_CHAR and BELL_CHAR defines to replace open-coded values 2015-06-16 19:06:30 +10:00