Commit Graph

218 Commits

Author SHA1 Message Date
Kevin Easton e347375cb3 Very minor simplification/cleanup of is_channel() 2019-07-08 17:34:08 +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 6cf30d8ce1 Make finalize_server_connect() static
It is only called within server.c.
2019-01-16 23:26:39 +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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 50999b3d5b Remove six dll_ variables from the module exports table
The removed variables are:

	dll_functions
	dll_numeric
	dll_commands
	dll_variable
	dll_ctcp
	dll_window

These are not actually directly used by any modules, and hiding them allows us to more easily
change their implementation later.
2017-11-06 17:14:12 +11:00
Kevin Easton 3f047ab2a9 Add save_dllvar() function exported to modules
This helper function is for modules to save the contents of their module variables to a file
as SET commands.

It will remove the need to export the raw dll_variable list to modules.
2017-11-06 16:54:51 +11:00
Kevin Easton 574053da52 Split out set_var_value_dll() from set_var_value()
Also remove external declaration of set_var_value() from vars.h, since it is only used in
vars.c.
2017-11-03 01:14:30 +11:00
Kevin Easton a220b8aa7f Rename VIF_BITCHX to VF_BITCHX
This flag is part of ->flags, not ->int_flags, so name it appropriately.
2017-10-26 17:41:05 +11:00
Kevin Easton dc30b852e1 Add VF_NO_SAVE flag to mark variables that shouldn't be saved
This replaces an explicit test for the variable names "DISPLAY" and "CLIENT_INFORMATION".
2017-10-26 16:15:59 +11:00
Kevin Easton 796eef3f99 Removed unused VF_NODAEMON flag
No code ever tests for this flag, so just remove it.
2017-10-26 15:56:31 +11:00
Kevin Easton 46047b058c Remove unused function clear_sets() 2017-10-25 17:00:48 +11:00
Kevin Easton 5839f2b393 Support fractional-second intervals on recurring timers
A fractional-second timeout was already supported for the initial timeout of a /TIMER, but
if the timer was recurring then the interval was rounded to a whole number of seconds for
the subsequent timeouts.

Change the type of interval from long to double to fix this.
2017-10-11 23:21:14 +11:00
Kevin Easton bbd18ba47e Introduce time_offset() helper and replace open-coded versions in timer.c
This function takes a struct timeval and offsets it by a (potentially fractional)
number of seconds, given as a 'double'.
2017-09-20 23:07:52 +10:00
Kevin Easton 604fcf794b Remove unused kill_timer() and get_delete_timer() functions
These functions are completely unused.  Also remove the TimerList.delete member that is only used
by these functions.
2017-09-20 15:31:41 +10:00
Kevin Easton 70ac43ce77 Remove globals 'li' and 'co' in term.c
These globals were used to store the original terminal dimesions from the terminal database (or
in the case of reattaching, supplied by scr-bx) to be applied if the current terminal dimensions
could not be determined.

Instead, we leave the original terminal dimensions in current_term->TI_lines and current_term->TI_cols,
and create current_term->li and current_term->co to store the current terminal dimensions (as eg.
supplied by scr-bx).
2017-09-15 17:15:24 +10:00
Kevin Easton 05633c9bc3 Consistently use SIGNAL_HANDLER() macro to define signal handler functions
With this change, the signal handler signature is defined in only one place.

Also make most signal handler functions static (those that are only referred to in irc.c).
2017-08-22 22:48:06 +10:00
Kevin Easton 73148fa4a4 Remove unused server flags CLOSE_PENDING and CLOSING_SERVER, rename LOGGED_IN to SF_LOGGED_IN
CLOSING_SERVER was never referenced outside of server.h where it's defined, and CLOSE_PENDING was cleared
but never set by any code.

Rename LOGGED_IN to namespace it (in anticipation of other flag variables in the server struct being
consolidated into a set of server flags).

Also put correct parantheses around the definition of SF_LOGGED_IN.
2017-07-19 07:57:52 +10:00
Kevin Easton 0fea2b97a4 Remove exported function create_server_list()
The guts of this function doesn't need to be in server.c - it only uses extern server functions so it
makes sense just to move it into the body of function_servers(), the only caller.

That means it's no longer accessible for loadable modules, but it isn't much use for them anyway.  They
can always directly access the server list if they need that info.

(Requires rolling the module table version).
2017-07-17 12:59:49 +10:00
Kevin Easton cd9c358eed Fix CHANGE_NICK_ON_KILL feature
Remove the 'resend_only' flag option to fudge_nickname().  The only caller passing it was the CHANGE_NICK_ON_KILL
feature, and in that case it was the wrong thing too (and stopped that function from working at all).

Some other minor cleanups in fudge_nickname() while we're there.
2017-07-15 23:29:14 +10:00
Kevin Easton d68d06480c Remove unused argument from log_put_it(), move declaration to output.h 2017-07-15 00:16:18 +10:00
Kevin Easton bb616e0626 Change send_text() to combine command, hook and log arguments into one set of flags
This function is exported to modules, so it requires updating a few modules and rolling the module table version.
2017-07-09 00:08:04 +10:00
Kevin Easton 496bbc8b74 Add send_text() flag STXT_LOG
Eventually to replace the 'log' parameter to send_text().
2017-07-08 21:49:59 +10:00
Kevin Easton 1bceb5ed86 Pass STXT_NOTICE flag instead of command string to functions downstream of send_text()
This uses another bit in the existing flags argument in place of the command argument, and avoids
having to re-compare against fixed strings ("PRIVMSG", "NOTICE").
2017-07-08 21:37:08 +10:00
Kevin Easton a8e33b5efd Include irc.h in struct.h for required macros and typedefs
This fixes building the acro plugin.
2017-07-08 21:32:42 +10:00
Kevin Easton 2d0b3e728f Replace 'hook' and 'noisy' flags in functions downstream of send_text() with !(stxt_flags & STXT_QUIET)
This is in preparation for consolidating the various send_text() options into one set of consistent flags.
2017-07-07 15:19:39 +10:00
Kevin Easton ac84793dd6 Switch from direct tcl_interp->result access to Tcl_GetStringResult() and Tcl_AppendResult()
This allows building against recent libtcl versions.

A fallback definition of Tcl_GetStringResult() is included so that building against libtcl 7 still works.
2017-07-01 00:47:20 +10:00