Commit Graph

70 Commits

Author SHA1 Message Date
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
gdinit
bac141898b Correct spelling of some client messages, comments and function names 2017-10-20 14:57:17 +11: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
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
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
170b79c0d0 Switch /VER command to use ctcp_simple() 2017-04-11 01:24:36 +10:00
Kevin Easton
bad8c2fa02 Remove netfinger client code and repurpose /FINGER command to send a CTCP FINGER instead
No-one runs fingerd servers anymore so this code was entirely obsolete.
2017-04-11 01:19:32 +10:00
Kevin Easton
686344314f Unsetting CMDCHARS sets it back to the default
Previously you could unset CMDCHARS and the effect would be to treat it like it was set to DEFAULT_CMDCHARS,
except that some code was missing the fallback (eg. ignore_last_nick()) which would make it crash.

Instead of having the fallback everywhere, just make it so that you can't unset the variable - if you try, it
sets it to DEFAULT_CMDCHARS.  This reflects what the behaviour has always been, it just makes it explicit to
the user and the bonus is we don't have the test it for NULL everywhere.
2017-02-16 23:42:52 +11:00
Kevin Easton
da1618d393 Constify pointer return value of find_command() 2016-10-16 00:45:41 +11:00
Kevin Easton
c6ec1f4098 Reformat and remove some unnecessary tests in parse_line()
Remove some unnecessary tests for !line: next_expr(&line, ...) can't set line to NULL.

Fixes some whitespace breakage.
2016-10-15 11:59:39 +11:00
Kevin Easton
9a2792345f Fix crash and memory leak in $aliasctl(COMMAND MATCH)
glob_commands() would run off the end of the irc_command array if given a match that matched
the last command.  It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().

This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string.  Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().

Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
2016-10-15 00:41:34 +11:00
Kevin Easton
04cf832604 Change send_msg_to_channels() to remove 'channels' argument and always use PRIVMSG
The 'channels' argument was unnecessary because the channel list passed to it would
always be from get_server_channels(server) anyway.

Changing the message argument from a protocol message format string to a plain payload
string for PRIVMSG means printf-escaping of the argument is avoided in the caller.
This simplifies the callers and means we can remove the last use of quote_it().

This change also switches set_server_away() to use send_msg_to_channels() instead of
open-coding the equivalent, which simplifies that function a lot.

We are changing the signature of a function exported to modules here; however none
of the in-tree modules use this function so it should be OK.
2016-10-13 01:36:19 +11:00
Kevin Easton
5a91e0b1d8 Add /SCANB command to scan for users on the userlist with the BOT flag
This is analagous to the /SCANF command that scans for friends etc.
2016-05-25 23:41:34 +10:00
Kevin Easton
2c805c096f Use /FSET RELSN to format /RELSN relayed messages
The RELSN format already existed but wasn't used - instead it used SEND_NOTICE.  The other relay
types already used similar formats for their relayed messages.

The default /FSET RELSN looks just like the default /FSET SEND_NOTICE so this shouldn't be
noticeable to anyone using the defaults.

This required updating the NOTICE-sending code to correctly stash the 'to' in the right place.
2016-05-15 22:05:16 +10:00
Kevin Easton
83741aca7a Add configure check for <sys/sockio.h>
Some systems need <sys/sockio.h> for the SIOCGIFCONF ioctl - this switches
to using a proper configure check for that header rather than just assuming
it'll be there if we can't find SIOCGIFCONF.  Should be more robust.
2016-03-20 23:48:31 +11:00
Kevin Easton
857a5fa524 Fix /KB so that it kicks-then-bans as documented
This also fixes a few others - eg /KBI now kicks-then-bans, and
/BKI bans-then-kicks (previously these were the wrong way around).

Reported by profiler.
2015-09-20 21:54:54 +10:00
Kevin Easton
8cc9684c76 Ensure close_server() clears the who/ison/userhost queues for the right server
close_server() should call clear_server_queues() on the server that's being
closed, not from_server.  This also lets us remove a few other calls to
clear_server_queues() that are right next to calls to close_server().
2015-09-07 16:34:41 +10:00
Kevin Easton
498631e74a Introduce get_kick_reason() and switch all kick commands to use it
get_reason() is then used only for the implementation of get_kick_reason()
and for the $getreason() scripting function.  Add current nick as an
explicit argument for get_reason(), which pushes all use of from_server
out of the ransom reason functions.

Also switch a few instances of send_to_server() to my_send_to_server() where
the current server has been returned by prepare_command().
2015-06-28 00:35:50 +10:00
Kevin Easton
ff251080da Add get_kill_reason() that uses BitchX.kill, and convert all /KILL users to it
Previously only send_kill() used BitchX.kill - the other KILL commands (eg.
/WHOKILL) were using the random kick reasons.  Standardise them all on
BitchX.kill, and add this file to the source so it can be installed along
with the other random reason files.
2015-06-27 23:18:38 +10:00
Kevin Easton
28bd7a66b6 Remove useless check for !nick from userhostbase callbacks
The userhostbase callback is always called with non-null nick.  Checking for
this is just noise which also sometimes results in odd compiler warnings.
2015-06-24 23:20:53 +10:00
Kevin Easton
4ee6c6295b Add time_until() and time_since() utility functions
Adding these in preparation for converting server->connect_time from time_t
to struct timeval.  Also converts three existing open-coded versions over to
the new functions.
2015-05-13 21:50:30 +10:00
Kevin Easton
07c2291966 Add SERVERREQ flag to all send_2comm commands.
send_2comm() always sends the command on to the server, so it always requires a server connection.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@526 13b04d17-f746-0410-82c6-800466cd88b0
2014-11-04 10:54:23 +00:00
Kevin Easton
867f7f8327 Add SERVERREQ flag to all send_comm commands which were missing it.
send_comm() just passes the command directly to the connected server, so it obviously
requires a server connection.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@525 13b04d17-f746-0410-82c6-800466cd88b0
2014-11-04 10:36:54 +00:00
Kevin Easton
0b6725dbe2 Remove WANT_CHAN_NICK_SERV define and include services commands by default.
They're pretty widely used these days, and the cost is trivial.  And quite frankly,
the less #ifdefs I have to see, the better.

This covers /NICKSERV, /CHANSERV, /OPERSERV and /MEMOSERV.  It also brings 
in the bahamut / unreal /SILENCE server-side-ignore command, and unreal's /HELPOP.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@524 13b04d17-f746-0410-82c6-800466cd88b0
2014-11-04 10:27:19 +00:00
Kevin Easton
78aeaeb1cb Cleanups around WANT_CHAN_NICK.
Remove unused function declaration, add SERVERREQ flag to CHANSERV command and remove IRCIIHELP
command that no server has provided in a long time, as far as I can tell.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@523 13b04d17-f746-0410-82c6-800466cd88b0
2014-11-04 10:05:58 +00:00
Tim Cava
04e898bb57 Cleanup quotecmd() a little bit. Remove a set but unused variable.
Kill commented out code that normally prevents some commands from
being quoted.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@490 13b04d17-f746-0410-82c6-800466cd88b0
2014-03-01 20:02:16 +00:00
Tim Cava
3138017406 Remove a variable that is set but unused.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@489 13b04d17-f746-0410-82c6-800466cd88b0
2014-03-01 19:45:47 +00:00
Tim Cava
101204b0b9 Remove a variable that is set but unused.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@488 13b04d17-f746-0410-82c6-800466cd88b0
2014-03-01 19:44:55 +00:00
Kevin Easton
a5bfc81b04 Fix typo bufer -> buffer.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@395 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-16 11:58:14 +00:00
Tim Cava
9bc7e5c835 Cleanup help() a little bit. Use strlcat rather than strmcat.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@385 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-13 18:56:37 +00:00
Tim Cava
50d29b1f29 Use strlcat, rather than strmcat, in command_completion(). Pass sizeof buffer,
rather than a constant, to snprintf and strlcat.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@384 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-13 18:48:42 +00:00
Kevin Easton
3de05c07c1 Only build and use the compat.c bsd_setenv/bsd_putenv/bsd_unsetenv on systems
that don't provide the POSIX setenv().

This fixes building plugins that link to compat.c on OS X (shared libraries on
OS X don't have direct access to environ).  It also reduces the binary size on
platforms which provide setenv(), which these days is most of them.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@382 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-09 21:40:55 +00:00
Tim Cava
b1d55bce82 Use memcpy, rather than strmcpy or strlcpy, in parse_command(). Suggested
by caf.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@316 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-14 04:15:09 +00:00
Tim Cava
0460b22bb0 Use strlcpy, rather than strmcpy, in realname_cmd().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@315 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-12 10:57:52 +00:00
Tim Cava
18142f0abe Use strlcpy, rather than strmcpy, in set_username().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@314 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-12 10:37:10 +00:00
Kevin Easton
e99861dbfb Add /OBITS command showing obituaries for long-time BitchX friends.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@230 13b04d17-f746-0410-82c6-800466cd88b0
2013-02-21 22:29:34 +00:00
Kevin Easton
5da6c807c2 Remove old reference to BitchX.com
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@229 13b04d17-f746-0410-82c6-800466cd88b0
2013-02-21 11:04:35 +00:00
Kevin Easton
d22a4531d8 Update old email addresses in user-visible messages.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@206 13b04d17-f746-0410-82c6-800466cd88b0
2012-06-13 12:34:32 +00:00
Kevin Easton
02e4ced684 Add PC_TOPIC flag to prepare_command() for topic-change commands.
Clean up e_topic(), splitting out untopic() and using prepare_command()
to check for ops.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@136 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-05 12:57:31 +00:00
Kevin Easton
c89a718fa1 Change the channel mode flags from const ints in names.c to #define macros in names.h.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@134 13b04d17-f746-0410-82c6-800466cd88b0
2011-08-30 14:50:42 +00:00