Commit Graph

489 Commits

Author SHA1 Message Date
Kevin Easton
919b76fcef Correctly show time since offer for DCC CHAT offers in /DCC LIST
s->time on the SocketList is set to the time that the chat offer will expire, so it's in the future.
This shows up as a very large positive time.  Instead, use n->lasttime as that is set to the time
when the offer is made.

Also adjust the format for non-file offers so that it all lines up properly.
2016-10-27 15:14:57 +11:00
Kevin Easton
30e3e65af7 Move translation of DCC_ACTIVE / DCC_WAIT / DCC_OFFER state to string into new function
The same expression was open-coded in several places, so collect it into one.
2016-10-27 14:54:21 +11:00
Kevin Easton
3cba15f6b4 Further cleanups in dcc_glist()
This now calculates a 'pcomplete' value for proportion of transfer complete (0.0 to 1.0).
From this we can calculate most other things easily - percent complete, ETA, and the size
of the completion bars.

User-visible change is that the DCC_BAR_TYPE 1 bar now matches the % complete for the RESUMEd
file case.
2016-10-27 00:23:35 +11:00
Kevin Easton
ed12420755 Extensive cleanups and simplifications in dcc_glist()
The only user-visible change here is that the bar displayed for DCC_BAR_TYPE 1 is now shown
as empty for a zero-length file rather than full, matching the 0.0% complete that is shown
and the bar displayed in the DCC_BAR_TYPE 0 case.
2016-10-26 23:47:24 +11:00
Kevin Easton
d8a53ab045 Correctly align formatting of /DCC LIST line for /SET DCC_BAR_TYPE 1
With DCC_BAR_TYPE 1 set, the stat line for active DCC file connections was not aligned
correctly with the header (the mm:ss field spilled into the KB/s column.)

This also simplifies things by always generating the inline bar, so the only difference
between the line printed for DCC_BAR_TYPE 0 and 1 is now the format itself.
2016-10-25 13:56:56 +11:00
Kevin Easton
09e53eb6d4 Cleanups in open_listen_port()
This fixes a few issues in this function - the socket type should be 'int' not 'socklen_t', the
error cases should close() the socket so it doesn't leak.
2016-10-21 16:37:18 +11:00
Kevin Easton
caba4c830c Length-check copies to DCC_current_transfer_buffer 2016-10-21 00:47:51 +11:00
Kevin Easton
aacc4b2282 Fix unsigned/signed comparison in process_dcc_send1()
The result of read() can be -1, and if that is compared against the unsigned result of sizeof
it will be converted to SIZE_MAX.  Cast the result of sizeof to a signed type.
2016-10-20 21:42:10 +11:00
Kevin Easton
e49dfcf11f Remove unnecessary double-sprintf() in close_dcc_file() 2016-10-19 16:48:28 +11:00
Kevin Easton
b462cf0001 Simplify show_version()
Re-order the code to squash two copies of the formatting code into one.
2016-10-18 23:54:46 +11:00
Kevin Easton
0a90a9d9db Minor cleanups in commands2.c
Remove some unused expressions after comma operators.

parm.termid is an array so it is pointless to compare it to NULL.
2016-10-18 23:46:43 +11:00
Kevin Easton
c2d6a184a3 Act on channel mode lock as half-op
There's no reason you shouldn't be able to use modelock as a half-op.

Also a few other minor cleanups in this function - eg. use my_send_to_server()
with the passed server number instead of implicitly using from_server.
2016-10-18 23:32:23 +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
dec7caafd0 Change 'name' argument of find_fixed_array_item() to const char * 2016-10-15 00:17:31 +11:00
Kevin Easton
a7f2462395 Fix memory leaks and format string issues in CDCC
cdcc_numpacks is unsigned, so %u should be used instead of %d.

Fix some memory leaks in /CDCC PLIST and /CDCC NOTICE where malloc_sprintf() was called
and the string never freed.
2016-10-14 00:56:03 +11:00
Kevin Easton
6948d91f6b Simplify unnecessary tests in CDCC
!password || (password && x) can be simplified to !password || x.

There's no need to check if a string is equal to the destination before
copying it there: might as well just copy it.
2016-10-14 00:34:26 +11:00
Kevin Easton
eb4b2a29d6 Remove unused function quote_it()
This function is no longer needed.  It was problematic anyway because it didn't have a way for
the caller to specify the destination buffer size.
2016-10-13 01:44:29 +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
08e3c99720 Remove use of quote_it() from LameKick() and masskick()
The use of quote_it() is unnecessary - we can just directly use my_send_to_server()
to construct the message.

Preparation to remove quote_it() entirely.
2016-10-09 23:22:18 +11:00
Kevin Easton
0fd11b3d75 Ensure masskick(), massban(), unban(), ban() and remove_bans() send command to correct server
These commands use prepare_command() to find a channel to act on, which returns the server to use.
The code should then use my_send_to_server() to ensure that it sends the command to that server -
these functions were using send_to_server() which sends to 'from_server', which means that they
could send the commands to the wrong place, for example if they were called from a hook on a
different server.

This patch was created with the following coccinelle script:

// Detects pairing preprare_command() with send_to_server() (which uses from_server)

@prepare3@
identifier s;
local idexpression c;
expression E1, E2, E3, E4, E5;
@@

(
if ((c = prepare_command(&s,...)) != NULL && ...)
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
|
if ((c = prepare_command(&s,...)) == NULL || ...) { ... return ...; }
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
)
2016-10-08 00:12:47 +11:00
Kevin Easton
58588946e0 Simplify send_to_server functions by adding server parameter to vsend_to_server() 2016-10-02 22:44:06 +11:00
Kevin Easton
729b029385 Code and comment cleanups to the Karll array functions
There should be no behavioural change.
2016-10-01 01:37:27 +10:00
Kevin Easton
e2b351b9ce Remove unnecessary NULL checks in expr.c
The first is unnecessary because after_expand() never returns NULL, and the 'rest' pointer has been
dereferenced multiple times anyway.

The second is unnecessary because parse_number(&ptr) cannot set ptr to NULL.
2016-09-30 23:44:15 +10:00
Kevin Easton
7e3c39a464 Fix implied operators under NEW_MATH
This fixes several issues with the implied operators when NEW_MATH is enabled:

* None of the implied operators were returning the correct value, which should be the value
assigned to the LHS.

* The &&=, ||= ad ^^= operators were also operating on uninitialized variables and so behaving
unpredictably.

* The /= and %= operators would crash the client when the RHS was zero, because after outputting
the "Divide by zero" error they would go on to perform the operation anyway.
2016-09-29 01:11:29 +10:00
Kevin Easton
a625650c4a Remove unnecessary NULL checks in assigncmd() and stubcmd()
In both cases, the args pointer has already been dereferenced so it cannot be NULL.
2016-09-28 14:58:43 +10:00
Kevin Easton
d9b522cd0b Add back Makefile rules to create .config.h
This fixes a bug introduced in commit f2ae2327, which improved the Makefiles for parallel builds
but in doing so removed the rule to create an empty .config.h file.

.config.h isn't included in the source distribution - it's created by bxconfigure if you run it.
If you don't run it, the build systems needs to create an empty one.  This commit adds a rule to
both the toplevel Makefile.in and source/Makefile.in (the latter in case you're running 'make' just
in the source/ directory).  The toplevel one is required for building the modules tree under dll/,
since the module Makefiles don't have the right dependencies wired up.

This also makes 'distclean' remove the .config.h file.
2016-08-02 23:36:01 +10: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
23967ba5be Wire up /FSET WHOIS_BOT for users on the userlist with the BOT flag
This FSET has existed for a long while but has been unused for some time,
since before the userlist was reworked to use flags instead of levels.  This
means that the default value for the FSET also has to be updated.
2016-05-25 23:38:11 +10:00
Kevin Easton
95a422cd27 Directly link string format to numargs in do_dirlasttype()
This is just a simplification - the string format should always match the arguments passed,
and none of the options are using anything but plain %s formats.

This also requires modifying /RELI to store the invited-channel in .last_msg so that it
can use the numargs = 3 format.
2016-05-15 22:43:01 +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
43d482a444 Change /FSETs SERVER_NOTICE_KLINE and SERVER_NOTICE_GLINE to show the ban type
The ban type (eg. K-Line, G-Line, D-Line etc.) is now passed in the second-last
argument of these formats.
2016-05-10 18:30:55 +10:00
Kevin Easton
df2e250ccf Clean up handling of oper server notices
This switches from somewhat gory string parsing based on strncmp() and next_arg() to a simpler alternative
based on sscanf().  I think these are much easier to understand now, and shouldn't have any subtle bugs
lurking like the old code.

This also removes support for some obsolete messages that don't seem to be in any modern ircds:
"Identd reponse differs"; bot messages like "Rejecting vlad/joh/com bot:" except for "is a possible spambot"
which is still in use; and the "High-traffic mode" messages.
2016-05-07 00:44:29 +10:00
Kevin Easton
e53d1cab7b Unify handling of SWATCH NONE between OperView and non-OperView modes
Previously, SWATCH NONE meant "show no server notices" if OperView was
enabled, but "show all server notices" if OperView was disabled.  Now,
it always means "show no server notices" (the default SWATCH is ALL,
so the default will behave the same).

This allows us to simplify the code a great deal as well.

Also trim off leading "***" if the server messages are handled by
handle_oper_vision(), as they already are in parse_server_notice().
2016-04-15 00:11:08 +10:00
Kevin Easton
7c3648bb2c Don't hide first word of server notices containing "***"
Using strstr() here is entirely wrong.  The intention is to catch notices
prefixed by *** or similar, and that's already detected further up in the code,
stored in the flag variable.
2016-04-14 23:18:54 +10:00
Kevin Easton
6b0aa0f8fe Remove unnecssary space at the start of SERVER_NOTICE_* formats
Also fix up similar hardcoded formats in notice.c.

The space isn't needed because serversay() adds a space (and has done for
a very long time).
2016-04-14 22:22:05 +10:00
Kevin Easton
d236b19410 Don't double-up server notices in the /RELS list
serversay() calls add_last_type(), so there's no need for the callers to do so
as well.

Remove the first argument to serversay() because it was always called with 1
anyway.
2016-04-14 21:51:49 +10:00
Kevin Easton
d296739f6f Don't fire the SERVER_NOTICE hook more than once per NOTICE
The previous code would fire the hook twice per NOTICE if handle_oper_vision()
didn't handle the NOTICE (eg. /set SWATCH NONE).
2016-04-12 23:05:34 +10:00
Kevin Easton
0b91d61496 Fix conversion of SWATCH flags to string form
This was broken in commit [07cdd587], where 'sizeof' was used on a pointer
instead of the buffer pointed-to.

Fix this by having the caller of ircop_flags_to_str() supply a buffer and
length, since there's only two callers and both can use happily use stack
objects.
2016-04-10 21:38:38 +10:00
Kevin Easton
1f64201362 Always treat NOTICEs received before registration as local server notices
We don't know the server's proper name until registration, so the test against
that isn't reliable.  We shouldn't be able to receive messages from anyone else
until we're registered, so this should be safe.

This requires changing serversay() to accept the from name instead of the
from_server.  While we're there, replace the use of alloca() with simpler
logic based on m_sprintf().
2016-04-07 00:11:27 +10:00
Kevin Easton
d19c050837 Fix handling of "host.domain" style server names in ov_server()
The old code would return "omain" rather than "domain" in this case.

Also remove unneccesary checks on the return value of get_server_itsname() -
this function already falls back to 'name' if 'itsname' isn't set yet.
2016-04-06 22:22:39 +10:00
Kevin Easton
74ee653d24 Remove unnecessary extern declaration of ov_server()
It is declared in output.h, which is already included by status.c.
2016-04-06 21:33:06 +10:00
Kevin Easton
b1277f75d4 Add /on NOTICE_GROUP and /fset NOTICE_GROUP analogous to MSG_GROUP
This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org.  This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).

Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.

This will also catch server notices sent before you're registered.
2016-03-31 23:55:14 +11:00
Kevin Easton
d464bd91fb Remove unnecessary inclusions of <numbers.h>
Functions display_msg() and check_sync() are only used in numbers.c, so they
can be static.

Remove inclusions of <numbers.h> from .c files that don't need it.
2016-03-24 11:21:09 +11:00
Kevin Easton
f129ca29e7 Move got_initial_version_28() from notice.c to numbers.c, where it belongs 2016-03-24 00:08:57 +11: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
94f4e1c2a3 Don't #include <sys/ioctl.h> or <unistd.h> more than once
<unistd.h> is included by irc.h so it does not need to be included again here.

<sys/ioctl.h> only needs to be included once.
2016-03-18 16:46:36 +11:00
Kevin Easton
82d606979b Add HAVE_*_H checks around inclusions of netinet/in.h and sys/socket.h
Only include <netinet/in.h> and <sys/socket.h> if the system supplies them.
This is necessary to try and get the mingw32 build working again.

No need to include <sys/types.h> and <netinet/in.h> from cdns.c - these are
already included by <irc.h>.
2016-03-17 21:39:17 +11:00
Kevin Easton
f21b89e428 Improve /WINDOW DESCRIBE output
Instead of showing a meaningless pointer value for Screen:, we show the
screen number and ttyname.

Also take the CO, LI values from the window's screen.

Don't show the Prompt: unless one is set.
2016-03-16 23:50:38 +11:00