Commit Graph
100 Commits
Author SHA1 Message Date
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
Kevin Easton 563ab3efeb Use current screen size rather than original terminal size in term_clear_screen()
Also renames the function term_clrscr() to term_clear_screen() and remove the term_clear_screen()
macro.
2018-05-05 13:34:13 +10:00
Kevin Easton 1e97709bd8 Use output_screen size instead of current_term in term_scroll
This fixes a regression in commmit 70ac43ce77,
where the original screen size would be used to scroll after the terminal had
been resized.  If the screen was shrunk, this caused display problems when
running under GNU Screen.

Using output_screen size means that it stands a better chance of working on
non-default screens, too.
2018-05-05 11:31:31 +10:00
Kevin Easton 208fddb9f5 Simplify dcc_send_socketread()
There should be no change in behaviour.  Replaces a code block of the form:

if (a || b)
{
    if (c && a)
    {
        /* one */
    }
    else if (b)
    {
        /* two */
    }
}

with the simpler equivalent:

if (c && a)
{
    /* one */
}
else if (b)
{
    /* two */
}
2018-04-12 00:20:13 +10:00
Kevin Easton 99c5ec9872 Change arcfour example module to use ARC4CHAT instead of SCHAT as the DCC type
The SCHAT type is already used by some other clients for SSL CHAT.  This example module doesn't work
yet anyway, so no-one can actually be using it.
2018-03-14 16:58:10 +11:00
Kevin Easton 9e7fc85ae1 Fix various problems with adding and removing module DCC bindings
Change remove_all_dcc_binds() so that it only removes DCC binds for the module supplied, as it's supposed to.

get_dcc_type() should ignore the first entry in dcc_types[] ("<none>") otherwise the client will try to
respond to DCC requests with that name.

Explicitly track the number of entries in the dcc_types[] array rather than using a NULL terminator.  This
allows us to change dcc_types[] to use NULL entries to mark unused slots in the array, rather than pointers
to entries with a NULL .name element.  Together, this means that the dcc_types[] array is only resized when it
actually needs to be grown and removal works correctly (without eg. prematurely marking the end of the array).

Make add_dcc_bind() fail if the requested DCC type has already been bound by a module (this still allows one
module at a time to rebind a built-in DCC type).  Previously the behaviour was ill-defined in this case.
2018-02-20 23:27:32 +11:00
Kevin Easton 5ae42802ec Fix crash when unloading the arcfour module
Remove the empty Arcfour_Cleanup() function so that the default module cleanup can happen.

Define MODULE_NAME and use that when registering the module callbacks so that the default
module cleanup will remove them correctly.
2018-02-20 23:00:00 +11:00
Kevin Easton 3687e532f0 Change declarations of several globals to 'static' in dcc.c 2018-02-12 17:16:27 +11:00
Kevin Easton fcdfecd78c Introduce get_dcc_type(), remove open-coded variants 2018-02-09 22:09:09 +11:00
Kevin Easton 61a926a766 Introduce a struct dcc_ops to contain all functions pointers for a custom DCC type
Modules now must pass a pointer to a struct dcc_ops when calling add_dcc_bind() instead of
a list of function pointers.
2018-02-08 22:39:49 +11:00
Kevin Easton 64ec300d5d Add full prototyped declarations for DCC hook function pointers 2018-02-08 16:57:41 +11:00
Kevin Easton d15a738ee9 Don't limit dcc_schat_input to DCC_CHAT type (which is never true) 2018-01-06 21:20:48 +11:00
Kevin Easton 5991b83e13 Fix spelling mistakes in /BHELP file
Typo in /lastlog reported by g0z.
2018-01-04 22:29:10 +11:00
Kevin Easton c7a72b79ae Fix redirecting to DCC CHATs with /REL* commands
to + 1 is the correct destination, not to + 3.
2017-12-20 20:25:27 +11:00
Kevin Easton 2c94010d65 Update arcfour example module to use exported dcc_chat_socketread() callback
This allows it to actually connect OK, but it's still nonfunctional at the moment.
2017-12-20 18:10:02 +11:00
Kevin Easton d7688075b6 Export dcc_chat_socketread() and dcc_send_socketread() callbacks to modules
The idea here is that if you have a module which implements a new DCC type that is essentially
a lightly-modified version of CHAT or SEND you can reuse these functions.
2017-12-20 17:36:05 +11:00
Kevin Easton a55feeef5f Rename process_dcc_*() functions to dcc_*_socketread()
This makes it clearer what those functions really do.  It's in preparation to export them
for modules.
2017-12-20 17:11:56 +11:00
Kevin Easton 3800e4b099 Replace get_server_flag() with get_server_umode()
This function gets the status of a single umode flag identified by umode char rather than
internal server flag number.

This also lets us remove all the USER_MODE* constants because they're no longer required.

Invert the sense of the +w check in e_wall() - we only echo our OPERWALL if we're *not* +w,
because if we are +w then the server will echo it back to us anyway.
2017-12-07 00:23:43 +11:00
Kevin Easton 1769c03951 Replace set_server_flag() with update_server_umode() and remove get_possible_umodes()
The idea here is not to expose the internal server implementation for storing umodes,
but instead have callers just work in terms of umode characters.

The 'possible umodes' have always been the same for all servers anyway.  We just assume
that [a-zA-Z] is the bounding set.
2017-12-06 23:30:24 +11:00
Kevin Easton 305cfe2afb Move reinstate_user_modes() and update_user_mode() from funny.c to server.c and parse.c
Move these functions where they belong.
2017-12-06 22:13:34 +11:00
Kevin Easton c4ba093ca5 Rework update_user_mode() 2017-12-04 17:43:47 +11:00
Kevin Easton 7642e741b9 Switch to using NULL server.ssl_fd to mark new SSL connection instead of NULL server.ctx
server.ctx is now allocated once for each server on first connection, then reused for subsequent connections.

server.ctx wasn't being cleared when the server was closed (as server.ssl_fd is), so this was causing
reconnection to fail until try_connect() got called.

This also removes the last uses of the CHK_* macros in ssl.h, so remove them.
2017-12-03 02:16:39 +11:00
Kevin Easton 7b817dd9d2 Correctly handle zero value error return from SSL_write() 2017-12-03 01:09:06 +11:00
Kevin Easton abc9dbdf9e Use SSL_free() when closing an SSL server connection
This avoids leaking memory.

Also change to always call SSL_shutdown() regardless of whether a QUIT message was sent.  No
need to call SSL_shutdown() from write_to_server(), close_server() will do it for us.

Remove "Closing SSL connection" message.
2017-12-03 01:06:53 +11:00
Kevin Easton 5d131bcf01 Add SSL version and cipher to SSL connect message
Similar to what EPIC5 does.
2017-12-03 00:13:47 +11:00
Kevin Easton cdf53cbf86 Change switch_help from array of strings to plain string 2017-12-01 23:42:26 +11:00
Kevin Easton 035063abce Add BITCHXRC_NAME to config.h
(instead of hardcoding it in irc.c).  Simplify setting of ircrc_file and bircrc_file.

Use IRCRC_NAME and BITCHXRC_NAME in help strings.
2017-12-01 23:33:13 +11:00
Kevin Easton 973ae0e4da Correctly handle case when a nick comes between a -s flag and a server name on the command line
The -s flag resets after the next server on the command line, but it was also incorrectly resetting
if a nickname was seen as well. This meant that a command line like this failed to use SSL:

BitchX -s -p 9999 gauze irc.choopa.net

Also update the help text to correctly reflect the operation of the -s flag.

Reported by gauze.
2017-12-01 23:05:58 +11:00
Kevin Easton a4ef0798ac Use server argument instead of from_server in rebuild_notify_ison()
It is only called in one place, where from_server is already set to the same as the argument.

Rename rebuild_all_ison() to rebuild_notify_ison_all().

Make rebuild_notify_ison() and rebuild_notify_ison_all() static, they are only called from
this file.
2017-11-30 17:27:05 +11:00
Kevin Easton f3f2ef6796 Remove unused variable hostname in nslookup()
Squashes a warning.
2017-11-30 00:11:24 +11:00
Kevin Easton 95b53cdd9f Remove unused variable hp in ar_procanswer()
Also mark unused variable ttl.  It's easiest to keep the variable because we still need to skip the
TTL in the header.
2017-11-30 00:08:11 +11:00
Kevin Easton 7a36be1c47 Only declare variable hp in parse_args() when !IPV6
Squashes an unused variable warning.
2017-11-30 00:01:30 +11:00
Kevin Easton 0905cf9528 Remove unused variable tcl_ret in do_hook()
Squashes a warning.
2017-11-29 23:50:32 +11:00
Kevin Easton b458082800 Simplify putchar_x() definition
Introduce an inline helper xlate_char() to isolate the character translation code.

This halves the permutations of putchar_x() required.
2017-11-28 14:40:19 +11:00
Kevin Easton 863263aa07 Make inclusion of tcl_bx.h unconditional
There's no need for the conditional compilation - tcl_bx.h itself has the WANT_TCL guards
necessary.

This makes generating the Makefile target dependencies easier.
2017-11-27 23:15:06 +11:00
Kevin Easton 256b33747c Replace use of _inline and __inline with inline
AC_C_INLINE in configure.in defines inline as a macro where necessary.
2017-11-27 23:02:35 +11:00
Kevin Easton a60937a8fd Move dll_commands and find_dll_command from commands.c to modules.c
Kind of where it belongs.
2017-11-27 20:07:28 +11:00
Kevin Easton 0ba25f02a5 Simplify and clean up find_dll_command()
The only external change here is that it now always sets *cnt to 0 when it returns NULL

Previously, it could set it to -1 in some cases, in particular when dll_commands is NULL.
This led to a bug where /HELP would show the wrong number of matching commands, because it
added the return value of find_dll_command() to the number of matching internal commands.

Also fixes a set-but-unused-variable warning.
2017-11-27 17:18:15 +11:00
Kevin Easton 860e7e28fb Fix unsigned char / char mismatch warnings in encrypt plugin
There's no need to dynamically allocate encode_string, so just make it static.

It does need to be unsigned char though, for the loop that intialises it.  So cast it
when calling my_encrypt() / my_decrypt().
2017-11-25 01:37:11 +11:00
Kevin Easton e63033e1d5 Include tcl.h via tcl_bx.h, not directly
This fixes 'const char **' vs 'char **' compiler warnings.

Additionally, tcl_bx.h always defines STDVAR and can be included without checking for WANT_TCL.
2017-11-25 01:18:13 +11:00
Kevin Easton c719a0ecb3 Test pointer against NULL rather than casting to int 2017-11-25 01:09:11 +11:00
Kevin Easton 2b84718039 Remove unused have_head variable in possum.c 2017-11-25 01:02:47 +11:00
Kevin Easton 21ed1a01a3 Numerous minor fixes to nap plugin 2017-11-25 00:53:43 +11:00
Kevin Easton 862137d975 Remove redundant test in fserv.c 2017-11-24 23:47:37 +11:00
Kevin Easton c426c0dcca Use correct *printf format specifiers in fserv.c
Format ints with %d, not %u.
2017-11-24 23:25:10 +11:00
Kevin Easton f621f48a25 Fix some obvious errors in do_dccbomb() 2017-11-24 23:17:39 +11:00
Kevin Easton 70ce80dced Minor cleanups in wserv.c
Rename global variable 's' to a longer name.  Rename function 'ignore' to a name that reflects what
it actually does.

Make sigint_handler() and my_exit() static, because they're only used in this file.
2017-11-24 17:29:51 +11:00
Kevin Easton ba1b9742ec Simplify calling of rsindex() and strsearch()
Remove the 'how' parameter to rsindex(), making it reverse-search for only the first matching character,
as sindex() already does.  There are only two callers, and one already passed a hardcoded value of 1.

Also change rsindex() so that it starts searching at the character BEFORE the passed in position.  This
makes it easier to repeatedly call rsindex() in a loop to search for the Nth matching character, and
also fixes a technical instance of undefined behaviour where a pointer is decremented to point before
the start of the string.

Remove the 'mark' parameter to strsearch().  Instead, always forward-search from the beginning of the
string and reverse-search from the end of the string, as this is what the two callers want anyway.

Bump the module ABI version because these functions are exported to modules.
2017-11-23 17:22:38 +11:00
Kevin Easton de303ba554 Change scr-bx to list the detached screens if more than one matches
This appears to be the original intention.  It's certainly more friendly, anyway.
2017-11-18 00:20:36 +11:00
Kevin Easton a3e6f10be4 Simplify find_detach_socket() in scr-bx
This should cause no user-visible change.
2017-11-17 23:51:05 +11:00
Kevin Easton 0abfa67aa8 Don't pass -1 as the length to write() if read() fails 2017-11-17 23:06:46 +11:00
Kevin Easton 149b3206e0 Improve error handling around file descriptors in wserv 2017-11-17 22:55:06 +11:00
Kevin Easton abfe84eb5c Use correct formats / types in snprintf() calls in tcl.c 2017-11-17 22:48:03 +11:00
Kevin Easton 1569d859af Clean up upper() and lower() 2017-11-17 17:43:22 +11:00
Kevin Easton 0d5698d41b Add inv_strpbrk() function and convert equivalent sindex() calls
inv_strpbrk() is the inverse of the standard function strpbrk().

Calls to sindex() where both strings are not NULL and the second string begins with ^ are equivalent
to calls to inv_strpbrk() (but without the ^).  Convert those calls.
2017-11-17 17:19:07 +11:00
Kevin Easton 8c7d9334dd Replace uses of sindex() with constant accept strings with strpbrk() / strchr()
sindex(), where neither argument is NULL and the accept string does not start with ^, is exactly equivalent
to the standard function strpbrk().

Further, strpbrk() where the accept string is only one character long, is exactly equivalent to strchr().
2017-11-17 16:32:28 +11:00
Kevin Easton eb6ffc7395 Convert strsearch() arguments to const char *
Also clean up the implementation a little.
2017-11-17 15:47:33 +11:00
Kevin Easton e8ce5fb973 Convert sindex() and rsindex() to use const char * arguments
Also simply sindex() considerably using standard strspn() / strcspn() functions.
2017-11-17 12:21:12 +11:00
Kevin Easton fea88185f8 Clean up function move_to_abs_word() and rename to move_to_word()
Remove the output argument, as it's the same as the function return value anyway, so
the callers should just use that.
2017-11-14 23:15:33 +11:00
Kevin Easton 5e40c1ac01 Don't move pointer before start of object in move_word_rel()
The old code could move the variable 'pointer' backwards one character before the start
of the string (then incremented it again before returning).  Formally this is undefined
behaviour, so fix it.
2017-11-12 23:34:54 +11:00
Kevin Easton a71ee883e1 Make "You can't hide an invisible window" message respect /SET WINDOW_QUIET
Also remove unnecessary NULL check, window->screen is already checked for NULL.
2017-11-10 17:16:58 +11:00
Kevin Easton c6f420b53d Simplify get_window_by_desc()
The '#' case never worked anyway, so just remove it and simplify.
2017-11-10 17:12:09 +11:00
Kevin Easton 3ec950a7d7 Allow $mychannels() to query a window attached to a different server
Otherwise, there's really no point in passing this function a window refnum at all.
2017-11-10 16:57:26 +11:00
Kevin Easton a028aebdb9 Fix crash when passing $mychannels() a non-existent window refnum 2017-11-10 16:53:32 +11:00
Kevin Easton 8a176c6950 Remove pointless check for unsigned number < 0 in get_window_by_refnum() 2017-11-09 23:50:13 +11:00