Commit Graph

935 Commits

Author SHA1 Message Date
Kevin Easton eaf6456854 Improve efficiency of m_3cat() algorithm
Use exact memcpy() instead of repeated strcat().
2019-12-28 17:30:01 +11:00
Kevin Easton 4f63d48929 Remove duplicate global definitions
This fixes compiling with gcc-10.

Reported by ixz.
2019-12-28 17:20:30 +11:00
Kevin Easton 9fe7de361e Minor fixes and improvements to channel_stats()
Show total channel memory use for /CHANST -ALL (previously it just showed the size of a single channel struct).

Fix stray cyan-coloured [ for /CHANST -ALL.

Fix display of "Channel created" and "in memory", which were displayed the wrong way around.
2019-08-27 16:29:40 +10:00
Kevin Easton 960e2d8087 Reformat and simplify channel_stats() and make_channel() 2019-08-27 15:36:29 +10:00
Kevin Easton ddfbec0b4b Remove queueing of wildcard CSETs and fix use-after-free with queued CSETs
A queued CSET is one that is set before the matching channel is joined.  The CSetList is allocated and linked to
the cset_queue list.

The use-after-free bug was caused because the CSetList wasn't removed from the cset_queue after it was attached
to a joined channel.  If the channel is parted, it eventually ages out of the Whowas-Chan-List and the CSetList
is freed, but there is now a dangling pointer to it in the cset_queue.  This is fixed by removing the CSetList
from the cset_queue when it is attached to a channel, so the net result of /CSET #chan ; /JOIN #chan is the same
as doing the reverse.

Queued wildcard CSETs never worked properly - the queued CSET with the wildcard name would end up attached to any
subsequent matching channel that was joined.  Channel names with wildcards in them are legal anyway, so the best
medium-term solution (pending a full redesign of the whole CSET command) is to just enforce that queued CSETs are
always literal channel names, not wildcards.
2019-08-03 01:09:21 +10:00
Kevin Easton f714e3e951 Combine cset_variable_case1() and cset_variable_casedef() into cset_variable_range()
There's no point having two functions that two essentially the same thing.  Also implement
cset_variable_noargs() as a call to cset_variable_range().
2019-07-18 14:17:04 +10:00
Kevin Easton e0ad103153 Simplify cset_variable_casedef()
This should make no functional change.
2019-07-17 16:29:53 +10:00
Kevin Easton 43ace65cb3 Simplifications to cset_variable()
Remove some unnecessary variables and reorder the code slightly. This should have no functional change.
2019-07-13 01:14:15 +10:00
Kevin Easton e347375cb3 Very minor simplification/cleanup of is_channel() 2019-07-08 17:34:08 +10:00
Kevin Easton b9803e69d1 Avoid reading an uninitialized byte in dgets()
This was caused by an off-by-one error in the case when a line exceeded the buffer size provided to
dgets().  Found with valgrind.
2019-06-27 17:37:35 +10:00
Kevin Easton 6ef78086f8 Bump MAXPARA (maximum protocol message arguments) to 20 as per EPIC5
Needed to bump it to 16 anyway (the RFC says 15 plus the protocol command itself, so 16), but EPIC5 bumped it
up to 20 based on a report from users of RusNet so we might as well go up to that as well.
2019-06-26 17:26:02 +10:00
Kevin Easton 0cbf8014ff Correctly handle a last argument prefixed with : for any protocol message
The previous handling for this had the : prefixing the last protocol argument reappear after
a PasteArgs() call.  This caused problems with the inspircd server, which prefixes the final
argument for every protocol message with :.  In particular the MODE command was problematic.

See https://github.com/inspircd/inspircd/issues/1636

Reported-by: trn
2019-06-26 17:16:35 +10:00
Kevin Easton 8d4808d744 Fix SHOW_AWAY_ONCE so it shows away message if the nick has changed
This was always the intent of the code, but it was using the server name
instead of the nick.
2019-06-21 16:24:27 +10:00
Kevin Easton bdd4f624c7 Handle 301 numeric with missing message away message argument
Reported-by: trn
2019-06-21 16:04:15 +10:00
Kevin Easton ae515a2b15 Minor simplification to remove one #ifdef/#endif pair 2019-02-05 17:39:24 +11:00
Kevin Easton f27d4d6599 Move find_old_server() nearby to only caller and make static 2019-02-03 00:59:18 +11:00
Kevin Easton 488c5bd9ba Remove obsolete check_host() function
This does nothing except fail when particular usernames are in use.
2019-01-31 22:24:11 +11:00
Kevin Easton ec8dee84b1 Remove my_from_server argument to finalize_server_connect()
This argument is always equal to the refnum argument at all three call sites.
2019-01-24 17:32:47 +11:00
Kevin Easton 062a5b781f Simplification of logic in server_lost()
Should have no change to behaviour.
2019-01-24 17:27:57 +11:00
Kevin Easton 18227203d9 Display "Servers exhausted. Restarting." message at the right time
The intention is to display this message when the client has failed to
connect to enough servers that it has to start back at the initially
requested server again.

The old code instead had some quite odd conditions.
2019-01-22 16:20:54 +11:00
Kevin Easton 32e5a0f281 Retry the initial server connection the correct number of times
The previous code relied on server[i].retries being equal to one less than the
number of connection attempts that had been made on entry to advance_server(), but
this was false for the initial connection attempt.

Change the code instead so that on entry to advance_server(), server[i].retries is
always the number of previous connection attempts that have been made.  This does the
right thing for initial connection attempts since .retries starts at zero.
2019-01-21 17:01:20 +11:00
Kevin Easton 080d26e4e1 Simplify next_server()
Replace the overly complex recursive implementation with a simple iterative one
that should behave exactly the same.
2019-01-19 00:52:20 +11:00
Kevin Easton 8072aea782 Improve error messages for SSL connection failures
This now shows the underlying failure reason, and includes the server name.
2019-01-16 23:54:59 +11:00
Kevin Easton 6cf30d8ce1 Make finalize_server_connect() static
It is only called within server.c.
2019-01-16 23:26:39 +11:00
Kevin Easton 95b57cc3cc Correctly handle reconnection after finalize_server_connect() fails
finalize_server_connect() can fail for SSL connections, because SSL_connect() can fail.  Without this change, the client won't
try to reconnect after an initial SSL connection failure - it'll just wait forever.

Reported by g0z, thanks!
2019-01-16 17:13:29 +11:00
Kevin Easton ad93fed710 Rename 'lines' identifiers that clash with <term.h>
Also pull out common part of scrollback_fowards() and scrollback_backwards() into a
helper function.
2018-12-14 17:55:52 +11:00
Kevin Easton f8ed18becb Rename 'pad_char' argument to padc
This avoids a clash with pad_char defined in <term.h>.
2018-12-12 00:22:59 +11:00
Kevin Easton 6a6f235db3 Rename 'lines' variables
This avoids a clash with the 'lines' macro declared in <term.h>.
2018-12-12 00:16:56 +11:00
Kevin Easton 76fc3b1b04 Rename 'lines' variable to 'line_range'
This avoids a conflict with the macro defined in <term.h>.
2018-12-11 22:29:20 +11:00
Kevin Easton e3750c7c1b Remove #include <ircterm.h> from source files that don't use it
Update Makefile dependencies as a result of header file inclusion changes.
2018-12-11 20:30:27 +11:00
Kevin Easton ac1c95c4ec Rename Window.columns to Window.saved_columns
This more accurately describes what it's for, and also avoids a conflict with the columns identifier
defined by terminfo's <term.h>.
2018-12-10 23:46:24 +11:00
Kevin Easton 9524f8996c Rename clear_screen() to input_clear_screen()
This matches input_unclear_screen(), and avoids a clash with the clear_screen identifier defined in
terminfo's <term.h>.
2018-12-10 23:29:45 +11:00
Kevin Easton 902ee7c455 Remove unused function irc_clear_screen 2018-12-10 23:25:17 +11:00
Kevin Easton 66b6fa4345 Add /EXEC -WINTARGET <target> argument
This allows you to choose a specific target window for the output of an /EXEC.
2018-11-30 13:17:27 +11:00
Kevin Easton 830572b91f Simplify and improve ov_strcpy()
The new implementation calls into strlen() and memmove(), and is safe to use even if the arguments don't
point into the same string.

The return value is now the same as the first argument (just like strcpy()), but no existing callers care
about the return value anyway.
2018-11-27 17:26:53 +11:00
Kevin Easton e51469568e Update command-line help text to explain server descriptions
Makes it clear that a each server can also specify port/password/nick/network if desired.

Reported by Ant.
2018-11-14 13:17:48 +11:00
Kevin Easton 076850f81b Move declaration to top of block
This fixes building with gcc2.  Reported by <https://github.com/fbrosson>.
2018-11-11 01:27:09 +11:00
Kevin Easton fe22025c01 Remove configure check for bcopy(), no longer required
This fixes building on Haiku OS (where bcopy() is a macro, not a function).
2018-11-11 01:22:31 +11:00
Kevin Easton b5afd1d596 Replace last uses of bcopy() with memcpy()
memcpy() / memmove() are standard everywhere, this lets us remove the configure script checking around bcopy()
which helps building on Haiku OS.
2018-11-11 01:07:31 +11:00
Kevin Easton d897a3b753 Fix /HISTORY *pattern* and /HISTORY -CLEAR
This code contained a bug where any argument to /HISTORY that _didn't_ start with "-CL" would clear history,
so no number or pattern argument could successfully be passed.

With this fix only an argument that case-insensitively matches "-clear" will clear history, so a pattern
argument will also work correctly.
2018-11-05 23:25:01 +11:00
Kevin Easton a3e8364bc9 Straight conversion of prepare_display() from pds.pos integer to pds.dest pointer
This means that the prepare_display_state struct includes the pointer into the destination
buffer, not just the offset.
2018-07-07 12:03:22 +10:00
Kevin Easton 6d432d458f Group variables representing the current prepare_display() state into a struct
This should have no functional effect, but groups together the variables required to
'rewind' prepare_display() to a particular point in the source string all together.
2018-06-16 14:28:40 +10:00
Kevin Easton d4c6123002 No tabs should be shown when /SET TAB is OFF
This also counts beeps, tabs and non-destructive spaces in the same way.

To maintain historical behaviour, BEEP_MAX of zero indicates no beeps allowed (the same
as /SET BEEP OFF), but TAB_MAX and ND_SPACE_MAX of zero indicates no limit.
2018-05-25 11:19:02 +10:00
Kevin Easton 255c25158c In prepare_display() set firstwb on tab as well as space 2018-05-17 23:20:15 +10:00
Kevin Easton f859f9e2f8 Count columns used by ND_SPACE character when splitting lines
ND_SPACE take up a printable column, so they need to be counted.  Reproducer:

/eval echo $repeat(160 $chr(19))XXXXXXXXXXXXXXXXXXXXXXX
2018-05-17 16:26:17 +10:00
Kevin Easton 9bffcf91ba Use main_screen->co instead of current_term->TI_cols as fallback width for never-visible windows
Window management should be getting its idea of screen geometry from screens, rather than
directly from the terminal.
2018-05-14 15:25:21 +10:00
Kevin Easton 5cc052ee6c Use target window width rather than terminal width to wrap /list -wide output
This should make the output correct in more circumstances.  It's the same wrapping used by add_to_window, anyway.
2018-05-10 17:33:35 +10:00
Kevin Easton 14a501bd04 Add window_columns() function to determine number of columns used for splitting window output
Replaces two open-coded versions of the same pattern.
2018-05-10 17:02:16 +10:00
Kevin Easton eb14b44413 Use current terminal size in term_reset()
Fixes a regression introduced by 70ac43ce77 where
the scroll region would be reset to the original terminal size, not current.
2018-05-07 20:13:23 +10:00
Kevin Easton caaba512c2 Remove dead code in refresh_screen() 2018-05-07 17:14:49 +10:00