Commit Graph

676 Commits

Author SHA1 Message Date
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
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
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
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
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
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