Commit Graph

44 Commits

Author SHA1 Message Date
Kevin Easton
0a16ab16ac Introduce strbegins() macro and replace all open-coded instances
This test is done quite a bit across the tree, and the open-coded variants make it easy to have an
accidental mismatch between the length of the prefix being tested and the length actually passed to
strncmp().

This fixes an issue of that type comparing the server version against the prefix "u2.10", where the old
code used an incorrect length of 4.
2017-06-06 23:47:10 +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
00ae33b67f Clean up formatting in function_sar() and function_msar(), remove redundant test
The test for !search in function_msar() wasn't necessary because it is assigned from a pointer
that was just tested for NULL above.
2017-01-02 00:47:43 +11:00
Kevin Easton
8975ba93dd Change $indextoword() so that the return value numbers the words from 0 rather than 1
This aligns the function with the documentation and what EPIC4/5 do. I couldn't find any example of an existing
script that actually called this function, so hopefully no-one is relying on the old behaviour.
2017-01-01 23:33:25 +11:00
Kevin Easton
678adbdd40 Rework and simplify $remw() implementation
This replaces calls to alloca() followed by two strcpy()s with a single
call to memmove(), and removes a confusing for/break structure.

The function should behave exactly as it did before.
2016-12-14 23:39:31 +11:00
Kevin Easton
ce3fd79652 Global spelling fix s/recieve/receive/ across codebase
This includes some user-visible messages and help files, so if anyone has
hooked them with /ON WINDOW their hooks will need updating.
2015-10-04 09:06:38 +11: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
91d6169cb7 Fix unsigned char / char mismatches in a few remaining places in functions.c
Also slightly clean up function_stripansi(), removing a redundant mask.
2015-06-21 18:01:11 +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
563493dd6a Add COLOR_CHAR and BELL_CHAR defines to replace open-coded values 2015-06-16 19:06:30 +10:00
Tim Cava
dd030f6e67 Make function_channelnicks() use the sort_type optionally passed in.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@494 13b04d17-f746-0410-82c6-800466cd88b0
2014-03-02 21:15:36 +00:00
Tim Cava
deb1c71b8c Remove a variable that is set but unused.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@493 13b04d17-f746-0410-82c6-800466cd88b0
2014-03-02 21:09:37 +00:00
Kevin Easton
de3d310678 Change RETURN_STR() macro to silence 'always evaluates to true' warnings.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@475 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-16 11:35:41 +00:00
Kevin Easton
5a3a74d38a functions.c: Fix mismatched format strings in several aliases and functions.
Affected functions are alias_idle(), alias_serverlag(), alias_awaytime(),
function_serverpass(), function_checkuser() and function_isuser().

This fixes $serverpass(), which seems to have never worked right.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@470 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-16 01:33:53 +00:00
Kevin Easton
77ee55f33f Simplify function_uptime() and change it to use long instead of time_t.
This fixes a series of compiler warnings on netbsd i386.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@465 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-15 12:55:44 +00:00
Kevin Easton
70b1c060f3 Change function_tdiff2() to use long instead of time_t, which fixes warnings on netbsd i386.
Also rework function to use snprintf() instead of sprintf().


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@464 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-15 12:11:19 +00:00
Tim Cava
db8c5cdc4f Convert sprintf calls to snprintf. From pvaldes.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@444 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-11 21:22:00 +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
Kevin Easton
751c53678d Use sizeof instead of size constant when passing buffers to getcwd().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@394 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-14 14:13:42 +00:00
Tim Cava
f5ef9ae80d Use strlcat, rather than strmcat, in function_ftime().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@391 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-13 20:28:11 +00:00
Tim Cava
501d960800 Use strlcat, rather than strmcat, in function_fsize().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@390 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-13 20:26:23 +00:00
Tim Cava
a8db6437aa Use strlcat, rather than strmcat, in function_fexist().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@389 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-13 20:24:12 +00:00
Tim Cava
536aea4704 Use strlcpy, rather than strmcpy, in function_prefix. From caf.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@378 13b04d17-f746-0410-82c6-800466cd88b0
2013-10-02 00:02:54 +00:00
Kevin Easton
4118a120bc Don't truncate the password and salt passed to crypt() by the $crypt()
scripting function - this allows alternate hashing methods to be selected
if supported by the C library.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@361 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-20 12:50:39 +00:00
Kevin Easton
5582171286 Switch random_number() to always use the best entropy source for internal
client purposes.  The RANDOM_SOURCE setting now only affects the $rand()
scripting function.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@357 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 14:47:04 +00:00
Tim Cava
44c4f2baf9 Use strlcpy, rather than strmcpy, in function_ftime().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@348 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 06:05:22 +00:00
Tim Cava
86e3064d2c Use strlcpy, rather than strmcpy, in function_rot13().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@347 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 06:03:32 +00:00
Tim Cava
23d1f6ad74 Use strlcpy, rather than strmcpy, in function_fsize().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@346 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 06:02:08 +00:00
Tim Cava
e095a1f373 Use strlcpy, rather than strmcpy, in function_fexist().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@345 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 05:58:39 +00:00
Kevin Easton
3ed7f68d4e Rename include/bitchx to include/options.h. This fixes building on
case-insensitive filesystems like NTFS or HFS+, where it clashes with
the BitchX binary.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@204 13b04d17-f746-0410-82c6-800466cd88b0
2012-06-02 14:53:37 +00:00
Kevin Easton
1569a5233f Fix a regression with the previous changes to $help() - topics with embedded
spaces are enclosed in quotes eg. $help("cdcc tresend").


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@129 13b04d17-f746-0410-82c6-800466cd88b0
2011-05-03 11:55:34 +00:00
Kevin Easton
7c36bdd4ad Cleanups to $help() function, removing some half-baked functionality that
never worked properly.  Search LOAD_PATH for the SCRIPT_HELP file.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@128 13b04d17-f746-0410-82c6-800466cd88b0
2011-05-02 12:34:39 +00:00
Kevin Easton
c5b5fdd4af Sort the chelp index after loading - ensures that all topics are reachable.
Use correct define for PUBLIC_ACCESS.

Some cleanups - separate out help index freeing, change get_help_topic() to return
void.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@127 13b04d17-f746-0410-82c6-800466cd88b0
2011-05-02 11:43:38 +00:00
Kevin Easton
1838a37a6c Cleanups in get_help_topic(). Topic now displays correctly, rather than the
argument supplied to /bhelp.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@126 13b04d17-f746-0410-82c6-800466cd88b0
2011-04-18 14:30:03 +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
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
e338d2d9fd Fix the $servernum() function - no matter what string
you gave it, it would return the first server in the list
where server.itsname == server.name, due to a misplaced
variable.  It also returned an empty string for
$servernum(  ) when it should return the current server.

Also removed the useless function_serverport() function -
it was a character-for-character duplicate of
function_servports().


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@70 13b04d17-f746-0410-82c6-800466cd88b0
2009-09-17 13:38:09 +00:00
Kevin Easton
62e70f98e2 Add halfop (%) support to the $channel() scripting function.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@49 13b04d17-f746-0410-82c6-800466cd88b0
2008-06-12 14:52:16 +00:00
Kevin Easton
bca8ce0a1c Fix call to RESIZE.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@47 13b04d17-f746-0410-82c6-800466cd88b0
2008-06-05 14:16:16 +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
533c3dbcbf Turn on SVN keyword replacement for $Date$, $Author$, $Revision$, $Id$ for all
*.c and *.h files.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/branches/ircii-pana-1.1@3 13b04d17-f746-0410-82c6-800466cd88b0
2008-02-25 09:49:14 +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