Commit Graph

200 Commits

Author SHA1 Message Date
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
Kevin Easton
57827008a1 Change sed_encrypt_msg() so it doesn't modify the passed message in-place
This means the calling code in commands.c no longer needs to take a copy before calling the function.

Also remove code testing result of of ctcp_quote_it() and ctcp_unquote_it() - these functions never fail.
2017-06-29 00:10:24 +10:00
Kevin Easton
3c2028e167 Rename crypt_msg() / decrypt_msg() to sed_encrypt_msg() / sed_decrypt_msg() and move to ctcp.c
These functions are really specific to parsing and creating CTCP SED messages, which means they belong
in ctcp.c with the other CTCP code.

Also remove unnecessary inclusions of encrypt.h and ctcp.h.
2017-06-28 22:26:08 +10:00
Kevin Easton
9b0d3e4ab5 Type improvements to the internal encrypt/decrypt and CTCP quoting API
Use size_t for passing buffer lengths, and const char * for encryption keys and other non-modified buffer
arguments.

Remove pointless helper function do_crypt().
2017-06-28 16:57:35 +10:00
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
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
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
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
fb35a00d1d Add const to nick pointer passed to find_nicklist_in_channellist() 2017-05-29 15:54:57 +10:00
Kevin Easton
3f87eb31b1 Standardise header include guards
Tokens that begin with two underscores __* or an underscore and an uppercase letter _X* are reserved,
so we should avoid those for our own include guards.  The standard I'm settling on for foo.h is FOO_H_.
2017-05-10 23:30:11 +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
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
52b57d1576 Move the definition of the NotifyItem and NotifyList types from struct.h to notify.h
This change means that struct.h no longer needs to include alist.h, so it will be indirectly included in a lot
fewer other files.

As a consequence, server.h needs to include notify.h to get the definitions of those data types.
2017-05-04 23:50:47 +10:00
Kevin Easton
65646f6b71 Include irc_std.h instead of irc.h in alist.h
Only irc_std.h is needed here, for the u_32int_t type.
2017-05-04 23:26:47 +10:00
Kevin Easton
6d50e933ee Remove unnecessary struct.h include from hash.h 2017-05-04 23:14:00 +10:00
Kevin Easton
be65ab7adb Standardise include guard in modval.h
Move the #ifndef / #define together at the start of the file, to trigger the compiler's include
guard optimisation.
2017-05-04 00:05:02 +10:00