Commit Graph

935 Commits

Author SHA1 Message Date
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
Kevin Easton ce55f5eaa8 Move unsetting of UPDATE_STATUS flag into update_window_status()
Also remove a buggy attempt to unset the flag from set_hold_mode().
2017-11-09 23:45:09 +11:00
Kevin Easton c881d1d20f Simplify condition in set_current_channel_by_refnum() 2017-11-09 23:35:28 +11:00
Kevin Easton f81126186c Simplifications in window_query()
Should be no user-visible changes.
2017-11-09 23:32:56 +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 a58078de7e Fix size argument in call to memset in MD5Final()
This function isn't used anyway, but the compiler was warning about the incorrect code.
2017-11-06 17:07:58 +11:00
Kevin Easton fcda7a4d55 Switch cavlink and nap plugins to use save_dllvar() function for saving SETs
This removes the only module uses of dll_variable, allowing it to be removed from the module
exports.
2017-11-06 17:01:36 +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 4b8ffbc52a Improve error message on module version mismatch 2017-11-06 16:52:14 +11:00
Kevin Easton ae4a45179e Remove unnecessary NULL check in whoreply()
new_w has already been checked for NULL further up the loop.
2017-11-03 16:32:33 +11:00
Kevin Easton 0703126773 Factor out common dll variable list lookup into lookup_dllvar() 2017-11-03 16:22:57 +11:00
Kevin Easton 3b2793877d Change set_var_value() argument from int to enum VAR_TYPES 2017-11-03 14:48:26 +11:00
Kevin Easton 59d237d819 Remove unused code branch in setcmd()
If cnt == 0, that implies that dll == NULL (if the list search returned an entry, it at least must match
the prefix we're looking for).
2017-11-03 01:18:04 +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 1797858d0b Extract common core from set_var_value() into helper function 2017-11-02 23:57:15 +11:00
Kevin Easton 1cb3775ced Fix typo testing VIF_CHANGED
This error seemed to be benign, because I don't think there was a way to get here with
int_flags non-zero without VIF_CHANGED already set.

Remove unnecessary tests for 'value' and '!value', because value is always non-NULL in that
code path.
2017-11-02 16:16:37 +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 571aafcb45 Add helper function save_vars_by_flags() for saving variables
The majority of save_variables() and savebitchx_variables() were common code, so pull it
out into a helper function.
2017-10-26 17:36:28 +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 481970b30d Use correct type for ircii_rem_str() 2017-10-25 16:59:18 +11:00
Kevin Easton ff048fbee9 Shitlist level 3/4 should kick regardless of /CSET KICK_IF_BANNED
As reported by Ancient, this is how it is documented to work.  It's also how shitlist level 2 works, so
it's consistent this way.

Some other cleanups in check_auto() while we're here.
2017-10-23 00:32:05 +11:00
Kevin Easton 60b40cf332 Simplify conditionals in check_prot() 2017-10-20 16:12:14 +11:00
gdinit bac141898b Correct spelling of some client messages, comments and function names 2017-10-20 14:57:17 +11:00
Kevin Easton b102b9d5c9 Remove pointless NULL test in translat.c
'args' is always non-NULL when this function is called (and has already been dereferenced before the point
where it was tested, anyway).
2017-10-14 23:18:26 +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 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