Commit Graph

42 Commits

Author SHA1 Message Date
Kevin Easton
9e7fc85ae1 Fix various problems with adding and removing module DCC bindings
Change remove_all_dcc_binds() so that it only removes DCC binds for the module supplied, as it's supposed to.

get_dcc_type() should ignore the first entry in dcc_types[] ("<none>") otherwise the client will try to
respond to DCC requests with that name.

Explicitly track the number of entries in the dcc_types[] array rather than using a NULL terminator.  This
allows us to change dcc_types[] to use NULL entries to mark unused slots in the array, rather than pointers
to entries with a NULL .name element.  Together, this means that the dcc_types[] array is only resized when it
actually needs to be grown and removal works correctly (without eg. prematurely marking the end of the array).

Make add_dcc_bind() fail if the requested DCC type has already been bound by a module (this still allows one
module at a time to rebind a built-in DCC type).  Previously the behaviour was ill-defined in this case.
2018-02-20 23:27:32 +11:00
Kevin Easton
61a926a766 Introduce a struct dcc_ops to contain all functions pointers for a custom DCC type
Modules now must pass a pointer to a struct dcc_ops when calling add_dcc_bind() instead of
a list of function pointers.
2018-02-08 22:39:49 +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
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
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
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
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
0fea2b97a4 Remove exported function create_server_list()
The guts of this function doesn't need to be in server.c - it only uses extern server functions so it
makes sense just to move it into the body of function_servers(), the only caller.

That means it's no longer accessible for loadable modules, but it isn't much use for them anyway.  They
can always directly access the server list if they need that info.

(Requires rolling the module table version).
2017-07-17 12:59:49 +10:00
Kevin Easton
cd9c358eed Fix CHANGE_NICK_ON_KILL feature
Remove the 'resend_only' flag option to fudge_nickname().  The only caller passing it was the CHANGE_NICK_ON_KILL
feature, and in that case it was the wrong thing too (and stopped that function from working at all).

Some other minor cleanups in fudge_nickname() while we're there.
2017-07-15 23:29:14 +10: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
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
fb35a00d1d Add const to nick pointer passed to find_nicklist_in_channellist() 2017-05-29 15:54:57 +10:00
Kevin Easton
a329dd8404 Include vars.h in wserv.c and scr-bx.c for enum VAR_TYPES
Also define STERM_C and include modval.h in scr-bx.c.

This allows us to remove the slightly bogus dummy definition of enum VAR_TYPES from modval.h, and use a simple
macro to redirect the declaration and use of get_int_var() to BX_get_int_var().
2017-05-10 23:19:57 +10:00
Kevin Easton
be65ab7adb Standardise include guard in modval.h
Move the #ifndef / #define together at the start of the file, to trigger the compiler's include
guard optimisation.
2017-05-04 00:05:02 +10:00
Kevin Easton
aa04e465f3 Document and simplify the ltoa() / my_ltoa() distinction
The function provided (either by #define to the module table or directly in the case of scr-bx.c)
is called my_ltoa(), and the #define in irc_std.h aliases this to ltoa().
2017-04-30 23:33:58 +10:00
Kevin Easton
1ccd082cd2 Cleanup remove_channel()
remove_channel() is only called in direct response to a message from a server,
so it always acts on from_server - remove the unnecessary server argument.

The channel argument is always non-NULL - remove the dead code that removed all
channels if a NULL channel was passed.
2017-04-16 16:19:55 +10:00
Kevin Easton
53f3a34ca5 Change channel argument of is_current_channel() to const char * 2017-04-16 16:14:13 +10:00
Kevin Easton
2eabfabc35 Change lookup_channel() channel argument to be const char * 2017-04-16 16:03:01 +10:00
Kevin Easton
81ddf52909 Introduce an enum flood_type for the *_FLOOD constants
This allows the debugger to show the decoded constant name.
2017-01-19 17:10:32 +11:00
Kevin Easton
78dbdea441 Remove 'type' argument of flood_prot()
All callers of flood_prot() were supplying { get_flood_types(flood_type), flood_type } as the second and third arguments,
except one that supplied { get_flood_types(CTCP_FLOOD), CTCP_ACTION_FLOOD }.

Hardwiring this logic in to flood_prot() lets us remove the 'type' argument without changing the behaviour.
2017-01-18 00:11:49 +11:00
Kevin Easton
da1618d393 Constify pointer return value of find_command() 2016-10-16 00:45:41 +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
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
af3b0c920a Change find_name_in_genericlist() to take const char * argument 2015-10-28 21:42:33 +11:00
Kevin Easton
cfe6735ef0 Simplify find_dcc() and find_dcc_pending()
Extract the common DCC matching code into one function and simplify
it a little.
2015-10-12 16:26:23 +11: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
53f7c374cf Convert strip_ansi() from unsigned char to char
This required a few careful changes to ensure that the result does the same
thing.

Also included a few little cleanups in this function.
2015-06-19 23:12:10 +10:00
Kevin Easton
d0b0a95330 Convert skip_ctl_c_seq() and its callers (except strip_ansi()) from unsigned char to char
This should make no functional difference, and cuts out a large number of
unsigned char * / char * mismatch warnings.
2015-06-17 22:50:49 +10:00
Kevin Easton
7eae2aba86 Change arguments of my_strnstr() from const unsigned char * to const char *
This kills warnings in both ircaux.c and input.c.
2015-06-07 00:30:05 +10:00
Kevin Easton
f22dc54b13 Change BX_add_to_screen() and BX_skip_incoming_mirc() to use char * rather than unsigned char * arguments.
This clears up a few pointer type mismatch warnings.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@477 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-18 12:38:07 +00:00
Kevin Easton
08cca81993 Rework cset functions to remove non-standard void * arithmetic.
Fixes compiling on Irix.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@108 13b04d17-f746-0410-82c6-800466cd88b0
2011-02-02 12:13:54 +00:00
Kevin Easton
789ed916cd Backport changes from epic5 to make recv_nick, sent_nick and sent_body
per-server, and apply new version of do_oops from flewid (the BX2 version). 

This means that /oops, "/query .", "/query ,", "/msg ." and "/msg ," are now
per-server, along with the $. $, and $B aliases.



git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@87 13b04d17-f746-0410-82c6-800466cd88b0
2010-06-26 08:18:34 +00:00
Kevin Easton
7ac4b8520c Convert my_stricmp, my_strnicmp and wild_match from unsigned char * to char *.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@80 13b04d17-f746-0410-82c6-800466cd88b0
2009-11-24 10:21:30 +00:00
Kevin Easton
d809649484 Merge r23 from branches/ircii-pana-1.1
Changes to allow compiling on gcc-4.0.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@40 13b04d17-f746-0410-82c6-800466cd88b0
2008-05-07 11:07:31 +00:00
Kevin Easton
285b02c36a Add $ishalfop(<nick> <channel>) scripting function, as per EPIC.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@34 13b04d17-f746-0410-82c6-800466cd88b0
2008-05-07 08:48:49 +00:00
Kevin Easton
3de93b1dbc Far-reaching changes to make BitchX compatible with 64 bit architectures
like x86-64, where sizeof(int) != sizeof (void *).  This involves correctly
casting every function pointer from the global table to the correct
function type, which has the added benefit of allowing type-checking of
function arguments and return values.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@26 13b04d17-f746-0410-82c6-800466cd88b0
2008-04-30 13:57:56 +00:00
Kevin Easton
28febcfea9 Initial import of the ircii-pana-1.1-final source tree.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/tags/ircii-pana-1.1-final@1 13b04d17-f746-0410-82c6-800466cd88b0
2008-02-25 09:25:32 +00:00