Every call to create_dcc_int() was preceded by a call to parse_offer_params(), and the DCC_int
is where the address/port/size produced by the latter is stored, so this refactoring makes
sense and reduces the calling function complexity/size considerably.
Checking before truncation means you can sneak a privileged port past the check.
This change also collects the various broken-out parts of a CTCP DCC offer into a struct so that
it's easier to pass them all around together.
parse_offer_params() was being run unconditionally by check_dcc_init() even if it didn't find a
custom init_func() to call, which is the usual case. It then gets called again by the hardwired
DCC init function, which led to the error message appearing twice. This has check_dcc_init() only
call parse_offer_params() when its about to dispatch to a custom init func.
This also improves the message a bit (making it [host:port] rather than the other way around) and
combines the 'privileged port' message and "zero address" message together.
Previously waiting (inactive) file-type offers were shown different to others, omitting the
time-since-offer. Unify them to use the same format, which also cuts out a few lines of code.
Also tweaks the DCC_BAR_TYPE 1 format to include the DCC state (always Active) where the
completion bar would be in the DCC_BAR_TYPE 0 format. This just looks a bit more consistent.
get_stat_format() now returns the entire cparse string, not just the completion bar portion. This
means we don't need to call convert_output_format() twice.
This conversion (which conditionally prepends 'T' to the DCC type name depending on whether
TDCC is enabled or not) was open-coded in several places.
Also removes unused extern function get_dcc_type().
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.
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.
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.
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.
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.
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.
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.
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.
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.
!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.
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.
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.
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);
)
...>
}
)
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.
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.
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.
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.
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.
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.
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.
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().
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.
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.
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.
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().
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.