Commit Graph

61 Commits

Author SHA1 Message Date
Kevin Easton
61ff399b3d Remove superfluous test for current_window
It is always non-NULL, and we dereference it unconditionally anyway.
2017-02-18 00:32:23 +11: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
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
a2e8e103e0 Modularise handling of DCC offers
There's several different types of DCC offers, all of which need slightly
different handling.  Previously they were all handled by the monster function
register_dcc_type() - this breaks them out into seperate functions for handling
SEND, RESEND, CHAT and BOT offers, moves common code into static helper
functions and renames the entry point from ctcp.c to handle_dcc_offer().

This will allow adding a way for modules to register DCC offer types that
they're interested in.

This also moves rename_file() from misc.c into dcc.c, where its only user is.
2015-10-28 21:46:38 +11:00
Kevin Easton
9606ab312f Remove now-unused stripansi() function. 2015-09-06 22:54:12 +10:00
Kevin Easton
d62914af15 Optimise add_last_type() and change it to accept const char * pointers
The optimisation reduces the number of malloc_strcpy() calls, from 50 to 5
for most last types.
2015-09-03 01:04:12 +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
27e32a0319 Cleanup and simplify get_reason() and related functions
Rename randreason() to fread_random() to better reflect its function,
and change it to a one-pass algorithm.  Have it write into a caller-provided
buffer instead of a static buffer.  Fixes a file leak when an empty
file is given to this function.

Change freadln() so that it never returns an empty line - it only returns
0 at end-of-file now.  This simplifies its callers.

Factor out some common code from the several get_reason()-type functions,
which greatly simplifies them.
2015-06-27 00:38:40 +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
69bbcfd83d Convert stripansi() from unsigned char to char
This silences a few compiler warnings.

This also cleans the function up by removing some always-true checks.
I'm not convinced that this function makes a whole lot of sense, though.
Will look into it further...
2015-06-21 00:18:03 +10:00
Kevin Easton
b0f0124779 Don't compile convert_output_format2() in non-GUI builds
This function is only used by the GUI menu code, so we don't need to
build it for normal builds.

Also clean up some unsigned char / char mismatches that the compiler warned
about.
2015-06-20 23:42:04 +10:00
Kevin Easton
64860729b3 Convert read_netfinger() to use char instead of unsigned char 2015-06-20 23:18:13 +10:00
Kevin Easton
716a8ec33a Change ar_* resolver functions from char to unsigned char where appropriate
This gets rid of all the unsigned char / char mismatch warnings in these
functions.
2015-06-20 22:36:05 +10:00
Kevin Easton
cce8b30079 Switch write_sockets() and read_sockets() from unsigned char * to char * 2015-06-20 08:43:00 +10:00
Kevin Easton
e646ab42d2 Move char_fucknut() and caps_fucknut() from misc.c to parse.c.
These functions are only used by parse.c:annoy_kicks(), so move them next
to that function and make them static.

This also changes their arguments from unsigned char * to char *, getting rid
of some signed/unsigned mismatch warnings.
2015-05-05 20:30:07 +10:00
Kevin Easton
9f7cf6b6c2 Alter the way PINGs for /sping and lag check are used.
We now send PING <server> :<server> for /spings, and
PING LAG!<cookie>.<tv_sec>.<tv_usec> :<server> for lag checks.  The cookie is
set randomly at server connect time, and means that clients connected to the
same bouncer shouldn't act on each other's lag checks.

We can now remove in_sping entirely - previously it would get out of synch if
you disconnected with a sping in progress.
2015-05-04 00:13:08 +10:00
Kevin Easton
34c34b9a43 Add ccTLDs for .cw (Curacao) and .sx (Sint Maarten).
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@511 13b04d17-f746-0410-82c6-800466cd88b0
2014-10-21 12:21:24 +00:00
Kevin Easton
a3170cf578 Fix regression introduced in r480, where /BKI on non-joined clients no longer ignored.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@499 13b04d17-f746-0410-82c6-800466cd88b0
2014-09-23 13:46:47 +00:00
Kevin Easton
e808dbe94b Change the lag check so that it does not try to format a time_t using %lu.
Recent OpenBSD and NetBSD have changed time_t to be a 64 bit type on all
platforms.  This means that on 32 bit systems, time_t is now longer than
long, and %lu can't be used to format it.

The lag check doesn't actually care what is in the first field of the PING
command, so change it to be our nick (which is arguably what it should be).


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@498 13b04d17-f746-0410-82c6-800466cd88b0
2014-09-21 14:54:12 +00:00
Tim Cava
112b38ac7a Revert the last commit. It accidentally had autogenerated files in it.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@432 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-07 03:00:24 +00:00
Tim Cava
276fd24258 Use snprintf rather than sprintf. From pvaldes.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@431 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-07 02:41:16 +00:00
Tim Cava
8e8a4022f9 Cleanup check_serverlag(), with suggestions from caf.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@427 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-01 11:32:57 +00:00
Kevin Easton
717d2e88b7 Fix incorrect truncation in cluster() caused by strlcpy().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@377 13b04d17-f746-0410-82c6-800466cd88b0
2013-09-28 14:26:57 +00:00
Tim Cava
ea5aa01f87 Use strlcpy, rather than strmcpy, in cluster().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@372 13b04d17-f746-0410-82c6-800466cd88b0
2013-09-18 23:28:07 +00:00
Tim Cava
fafd888528 Cleanup rename_file() a little bit. Use strlcpy, rather than strmcpy.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@368 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-26 08:04:21 +00:00
Tim Cava
94f99bfdbb Use strlcpy, rather than strmcpy, in make_channel().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@354 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 09:11:04 +00:00
Tim Cava
41e52c7cf5 Use strlcpy, rather than strmcpy, in do_newuser().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@353 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 09:07:32 +00:00
Kevin Easton
c7cefb1c05 Don't look beyond the end of a cparse format if it ends with % or $.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@310 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-10 15:59:04 +00:00
Kevin Easton
6691732900 Make add_socketread() close the new socket if it can't be added to the
socket manager because it exceeds FD_SETSIZE.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@307 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-07 23:03:45 +00:00
Tim Cava
80cfa9c5d8 Make the namelen passed to getpeername() a socklen_t everywhere.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@279 13b04d17-f746-0410-82c6-800466cd88b0
2013-07-14 03:18:47 +00:00
Kevin Easton
bad477f9dc Fix off-by-one error in the check for s against FD_SETSIZE in add_socketread()
and set_socketwrite().  This was found by Coverity.



git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@237 13b04d17-f746-0410-82c6-800466cd88b0
2013-06-16 06:04:29 +00:00
Kevin Easton
2027f75969 Move inclusion of system headers in misc.c to top, which fixes building on
recent Cygwin (including windows.h after the macros defined in modval.h
causes the build to fail due to our 'load' macro).  Reported by VICODAN.

Also define WIN32_LEAN_AND_MEAN in misc.c, which should speed up Cygwin
build times a little.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@219 13b04d17-f746-0410-82c6-800466cd88b0
2013-01-02 22:40:58 +00:00
Kevin Easton
d13eee6683 The Cygwin resolver library doesn't fill out the list of name servers in
res_init() if /etc/resolv.conf doesn't exist, which is usual.

Add code to handle this by calling GetNetworkParams().


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@198 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-28 13:52:18 +00:00
Kevin Easton
79625bf516 Define BIND_4_COMPAT everywhere (except OS X, who just _had_ to be different)
and switch to using BIND4 macros (GETSHORT / GETLONG).

Should fix /nslookup on OpenBSD.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@196 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-27 04:42:09 +00:00
Kevin Easton
9ec4f49540 Apply patch from snadge to set BIND_4_COMPAT on OpenBSD. This is similar
to the existing BIND_8_COMPAT fix for OSX.

Oh how I hate the /nslookup function.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@187 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-15 13:16:11 +00:00
Kevin Easton
87f24694b9 Remove unnecessary ns_init() function.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@149 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-10 11:22:14 +00:00
Kevin Easton
122849f247 Replace _getshort() and _getlong() with NS_GET16() and NS_GET32() respectively.
Fixes compilation on cygwin (and possibly other targets).


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@148 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-08 12:53:16 +00:00
Kevin Easton
7978a87c9f Change async DNS resolver code to register its file descriptor with the IO
core.  This fixes /nslookup.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@147 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-08 11:24:48 +00:00
Kevin Easton
89b77f68fe Cleanups and simplifications in mircansi(), removal of some more warnings.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@141 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-07 14:41:06 +00:00
Kevin Easton
206df688ba Fix mircansi() so that it properly handles non-numeric characters
after a comma.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@140 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-07 12:48:35 +00:00
Kevin Easton
cc0a27d7fe Rework stripansicodes() to take a const char * argument rather than const unsigned char *,
fixing a large number of warnings. 


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@139 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-07 10:13:18 +00:00
Kevin Easton
43aaf645e2 Use PC_SILENT macro in BX_prepare_command()
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@138 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-06 06:55:38 +00:00
Kevin Easton
736777bea3 Change instances of open-coded "3" in calls to prepare_command() with PC_SILENT macro.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@137 13b04d17-f746-0410-82c6-800466cd88b0
2011-09-06 06:48:57 +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
83ac47c4f5 Minor cleanup for error_not_opped().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@135 13b04d17-f746-0410-82c6-800466cd88b0
2011-08-30 14:52:56 +00:00
Kevin Easton
df5547af72 Add .xxx TLD to country(), and some more const-correctness.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@122 13b04d17-f746-0410-82c6-800466cd88b0
2011-04-17 03:33:00 +00:00
Kevin Easton
719279790e Add some more TLDs to $country(), synchronised with the IANA list: .ax, .eu,
.me, .rs, .tl, .asia, .cat, .jobs, .tel and .travel.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@113 13b04d17-f746-0410-82c6-800466cd88b0
2011-03-31 08:32:23 +00:00
Kevin Easton
b17b09949b Improve country() by using "static const" for lookup table (makes function 25% smaller)
and const-correctness.  Add .mobi TLD.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@112 13b04d17-f746-0410-82c6-800466cd88b0
2011-03-23 11:17:23 +00:00