Commit Graph

611 Commits

Author SHA1 Message Date
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
5bd8a40cf8 Change $geom() to return current screen's geometry, not the original terminal's
This only affects additional screens created with /window create, which is an unusual
configuration.
2017-09-15 17:39:52 +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
c9b0e654b5 Remove unused variables BC, UP and my_PC
These appear to be a hangover from old termcap-using code, but there's nothing in BX that uses them anymore.
2017-09-02 07:03:10 +10:00
Kevin Easton
9080475ff7 Remove unnecessary typecasts in initialisation of tcaps[] 2017-09-02 04:55:19 +10:00
Kevin Easton
4a3cff53f4 Simplify and improve justification step of status formatting, and use the same code for $statsparse()
Separate out the justification step of make_status() into a new function, so it can be wired in to
stat_convert_format() as well.  This makes $statsparse() work correctly with right-justified status
formats.

Minimise the amount of copying around that is done during the justification - instead, we can just
remember pointers into the buffer returned by strip_ansi() for the left-hand-side, right-hand-side and
padding character.

Don't keep concatenating onto the same buffer with strlcat() when generating the padding - that gives
n^2 behaviour.  Instead keep a pointer to the current end and concatenate there.

Ensure buffer is null-terminated before calling strlcat() on it, in stat_convert_format().
2017-08-23 02:21:42 +10:00
Kevin Easton
f7de661f2f Use L suffixed constant to match type of server.flags / server.flags2 field in (get|set)_server_flag()
Also squash return value of get_server_flag() to 1 / 0.
2017-08-22 23:16:43 +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
742eeb33f7 Restore terminal settings after flushing output, not before 2017-08-22 22:26:50 +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
d2e576a774 Fix $myservers(1) to only return registered server refnums
When $myservers() is called with an argument of 1 it is supposed to only return the refnums of servers
that are registered (ie. those which it is legal to send a command to).  This is the way EPIC works, and
it was always intended to work this way in BX too.

Also fix the warning about a NULL itsname - we use our name for the server if it isn't registered yet.

Remove the slightly bogus use of strncat() while we're here, by removing the temporary stack buffer and
just directly creating the result string with m_s3cat().
2017-07-17 12:48:28 +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
b481ed1e6e Remove pointless NULL check in repaint_window()
The function has already dereferenced the pointer and passing NULL to this function is just a bug.
2017-07-15 22:24:09 +10:00
Kevin Easton
ce780c5b63 Use character constants instead of bare integers for escape character in strip_ansi()
Also use '\t' instead of '\011' in prepare_display().

Should be no functional changes, just looks nicer.
2017-07-15 22:22:58 +10:00
Kevin Easton
df12f6860a Remove unused 'in_help' flag from log_put_it()
The flag was set, but never tested.
2017-07-15 00:33:24 +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
9c46ddddb6 Check for unset MSGLOG_FILE or CTOOLZ_DIR, or failed stat(), in readlog()
Unset MSGLOG_FILE or CTOOLZ_DIR could cause a null pointer dereference.

If stat() failed it dereferenced the bogus 'struct stat', and in the directory case
just silently failed.  Now it falls through to the "error opening" path.
2017-07-15 00:07:25 +10:00
Kevin Easton
a6a5a19e28 Fix memory leak in /QUEUE -FLUSH
The queue->name must be freed.
2017-07-11 19:01:09 +10:00
Kevin Easton
dbd37bc35d Messages sent by /SV and /PASTE should be logged in the send log
This looks like an oversight.
2017-07-09 00:14:15 +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
2c8671f3dd Simplify send_text() by separating out special targets into another function
Also rename the double-negative flag 'not_done' to the more description 'done_forward'.
2017-07-05 17:36:52 +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
356eb699d0 Remove unnecessary repeated lines in parse_command()
There was no need for the same lines both in the WANT_TCL and !WANT_TCL branches.
2017-06-30 23:05:05 +10:00
Kevin Easton
19639ed608 Minor cleanups in send_text()
This removes some unused variables and some unnecessary copies of the text to be sent.
2017-06-29 16:51:26 +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
0c51ac19d4 Cleanups and simplifications in p_privmsg 2017-06-26 17:11:08 +10:00
Kevin Easton
0e9925f122 Minor simplification to beep_em 2017-06-26 16:54:50 +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
fb8dfc3946 Handle SED-encrypted CTCP replies properly
When a SED-encrypted NOTICE is scanned for CTCPs within the decrypted portion, they should be
handled with do_notice_ctcp() so they are treated as CTCP replies.
2017-06-22 00:03:53 +10:00
Kevin Easton
64d524804c Test sent_kick instead of kickcount for KICKFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:36:53 +10:00
Kevin Easton
07ab60f3ff Test sent_kick instead of kickcount for NICKFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.

The userlist and isme() tests are already done prior to calling handle_nickflood() so they are
not needed here.
2017-06-11 00:33:33 +10:00
Kevin Easton
50608f65ff Test sent_kick instead of kickcount for DEOPFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:26:57 +10:00
Kevin Easton
3caf308ea0 Test sent_kick instead of kickcount for JOINFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:23:39 +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
b4ec2f6a0e Minor cleanups in p_kick()
Remove dead store to ptr.  Rename 'who' to 'target'.
2017-06-10 23:34:22 +10:00
Kevin Easton
5237136083 Replace writestr() with a simple fputs() call 2017-06-09 16:15:47 +10:00
Kevin Easton
4ae2c5ebdd Write correct length to terminal for unflash sequences
Introduce a wrapper for fwrite() of a full string to the current_ftarget.
2017-06-09 00:42:57 +10:00