Compare commits

..

27 Commits

Author SHA1 Message Date
Christine Dodrill f0fc7fa407 Make format string for RPL_WHOISWEBCLIENT include target
Closes #62
2015-03-24 07:53:17 -07:00
Sam Dodrill 79bd2087c4 add usermode for webchat users
Closes #54
2015-03-24 07:51:15 -07:00
Christine Dodrill ad62a8365f atheme module: add support for +u
Closes #25
2015-03-22 05:23:49 -07:00
Christine Dodrill a03437b725 Add user mode extban
Cherry-picked from:
 - atheme/charybdis@0b18e32cad
 - atheme/charybids@11f2e78727
 - atheme/charybdis@a8eae73002
 - atheme/charybdis@63dd387b13
2015-03-22 05:17:42 -07:00
Christine Dodrill 81c857c332 Update my name 2015-03-11 00:38:09 -07:00
Sam Dodrill 417a320324 Remove m_olist
Operspy support for /list exists. Use that.
2015-02-21 08:18:47 -08:00
Sam Dodrill e1657f04ec addset -x for #travis op sinthetix 2015-02-21 08:18:47 -08:00
Sam Dodrill daac54878c modules/core/m_message: fix build 2015-02-21 08:18:16 -08:00
Sam Dodrill e7f3a5ad93 modules/core/m_message: don't apply local policy remotely
Closes #33
2015-02-21 08:18:16 -08:00
Sam Dodrill 9c83aac397 Add ability to disable channel mode +u
Closes #43
2015-02-21 08:18:16 -08:00
Sam Dodrill 0c372c65fc disable IRC notifications again 2015-02-21 08:17:04 -08:00
Sam Dodrill 8cff086fc5 Remove git history from docker builds 2015-02-20 23:21:28 -08:00
Sam Dodrill 48a3589d5e Merge branch 'master' of github.com:Elemental-IRCd/elemental-ircd 2015-02-20 23:21:07 -08:00
Sam Dodrill 7c4267175b ycm extra conf: fix paths for headers 2015-02-20 22:41:53 -08:00
Sam Dodrill aa4ebff4a5 Add YouCompleteMe semantic completion support 2015-02-20 22:41:42 -08:00
Sam Dodrill a3e2e47b86 Merge pull request #47 from Elemental-IRCd/doc/contributing/revision-2015-02-20
Update contributing guidelines
2015-02-20 11:14:42 -08:00
Sam Dodrill 88cd0168ad Merge branch 'testsuite-astyle-fixes'
Conflicts:
	.travis.yml

Closes #48
2015-02-20 11:12:46 -08:00
Sam Dodrill 874ca05045 Revert "remove IRC notifications from travis"
This reverts commit 0361eeeedf.
2015-02-20 00:35:50 -08:00
Sam Dodrill 2c0ee6900c Add travis tests for astyle 2015-02-20 00:33:55 -08:00
Sam Dodrill 9b969de641 testsuite/astyle: Add script to check coding style 2015-02-20 00:31:20 -08:00
Sam Dodrill cc0c8d338d Update contributing guidelines 2015-02-20 00:11:51 -08:00
Sam Dodrill 0361eeeedf remove IRC notifications fron travis 2015-02-16 00:52:59 -08:00
Sam Dodrill a6eb07553e Merge pull request #40 from Elemental-IRCd/fix/39/deprecated-entries-example-config
Remove deprecated settings from example configs

Thanks @YodaNetwork for finding this!
2015-02-16 00:51:49 -08:00
Sam Dodrill 62a511ab7b Remove deprecated settings from example configs
Ref #39
Ref #38
2015-02-16 00:48:32 -08:00
Sam Dodrill 3e6d026b38 Merge pull request #37 from Elemental-IRCd/staging/6.6.2
Staging/6.6.2
2014-12-16 08:26:52 -08:00
Sam Dodrill 100324f5c9 Elemental-ircd 6.6.2 2014-12-16 08:26:32 -08:00
Sam Dodrill 771cc10e92 Fix ban list add logic 2014-12-16 08:24:50 -08:00
97 changed files with 1224 additions and 486 deletions

1
.dockerignore Symbolic link
View File

@ -0,0 +1 @@
.gitignore

2
.gitignore vendored
View File

@ -40,3 +40,5 @@ tools/mkpasswd
tools/viconf
include/serno.h
libratbox/src/version.c.last
*.pyc
.git

View File

@ -5,8 +5,5 @@ compiler:
before-install:
- sudo apt-get update
install:
- sudo apt-get install build-essential libssl-dev flex bison
script: "./configure && make"
notifications:
irc: "irc.yolo-swag.com#elemental-ircd"
- sudo apt-get install build-essential libssl-dev flex bison astyle
script: "(cd ./testsuite/astyle && ./check_style.sh) && ./configure && make"

118
.ycm_extra_conf.py Normal file
View File

@ -0,0 +1,118 @@
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-g',
'-g',
'-Iinclude',
'-Ilibratbox/include',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}

View File

@ -1,20 +1,43 @@
# Contribution guidelines
Please open contributions as either issue reports or pull requests. We will ask
that anything that requires testing outside our normally supported platforms be
Please open contributions as either issue reports or pull requests. We will ask
that anything that requires testing outside our normally supported platforms be
marked as such.
As ircd is such an ancient project with varying code styles, please try to
follow the current coding style of the file you are in. If all else fails,
please use the [Linux Kernel](https://www.kernel.org/doc/Documentation/CodingStyle)
coding style.
Style
-----
Please run all code against the following `astyle` command before sending in
Please run all code against the following `astyle` command before sending in
a pull request:
```console
$ astyle --style=linux --mode=c -n $file
```
It should be trivial to set up your text editor to do this for you.
It should be trivial to set up your text editor to do this for you. If you use
vim, add this to your vim configuration:
```vimscript
" Lvimrc
" if .lvimrc exists in current or parent directory of the currently loaded file,
" load it as config
if filereadable('../.lvimrc')
source ../.lvimrc
endif
if filereadable('./.lvimrc')
source ./.lvimrc
endif
```
Otherwise please make sure the appropriate command is ran as part of your
editing process before you send a pull request. All pull requests that do not
follow the coding style will not be considered until they follow the coding
style.
Testing
-------
When testing Elemental, please be sure to test it on a network of at least
3 instances of elemental. Please also be sure to have one of these instances
run **without** the patch you are testing, to be able to show that there is
a difference.

View File

@ -4,7 +4,7 @@ Elemental-IRCd is a fork of the now-defunct ShadowIRCD project.
The Elemental-IRCd team is listed below in nick-alphabetical order:
Xena, Sam Dodrill <shadowh511 -at- gmail.com>
Xena, Christine Dodrill <xena -at- yolo-swag.com>
Some Elemental-IRCd features are modeled after or direct ports of
code from Charybdis.
@ -17,7 +17,7 @@ The ponychat-ircd team is listed in nick-alphabetical order:
aji, Alex Iadicico <alex -at- ajitek.net>
Kabaka, Kyle Johnson <kabaka -at- ponychat.net>
Xe, Sam Dodrill <shadowh511 -at- gmail.com>
Xena, Christine Dodrill <xena -at- yolo-swag.com>
ShadowIRCd 6 is a modern restart of the old ShadowIRCd project
based on Charybdis with a few additional features to make it appeal

4
NEWS
View File

@ -1,6 +1,10 @@
This is elemental-ircd 6.6.1, Copyright (c) 2014 elemental-ircd team.
See LICENSE for licensing details (GPL v2).
-- elemental-ircd 6.6.2
Fix ban logic
-- elemental-ircd 6.6.1
All code is now in the linux kernel coding style. Patches that do not

View File

@ -152,11 +152,11 @@ list_bans(void)
for(j = 0; j < table.row_count; j++) {
if(i == BANDB_KLINE)
snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][1], table.row[j][2], table.row[j][3]);
else
snprintf(buf, sizeof(buf), "%c %s %s :%s",
rb_snprintf(buf, sizeof(buf), "%c %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][2], table.row[j][3]);
@ -277,7 +277,7 @@ static void
db_error_cb(const char *errstr)
{
char buf[256];
snprintf(buf, sizeof(buf), "! :%s", errstr);
rb_snprintf(buf, sizeof(buf), "! :%s", errstr);
rb_helper_write(bandb_helper, buf);
rb_sleep(2 << 30, 0);
exit(1);

View File

@ -226,7 +226,7 @@ main(int argc, char *argv[])
/* checking for our files to import or export */
for(i = 0; i < LAST_BANDB_TYPE; i++) {
snprintf(conf, sizeof(conf), "%s/%s.conf%s",
rb_snprintf(conf, sizeof(conf), "%s/%s.conf%s",
etc, bandb_table[i], bandb_suffix[i]);
if(flag.import && flag.pretend == NO)
@ -286,11 +286,11 @@ export_config(const char *conf, int id)
return;
if(strstr(conf, ".perm") != 0)
snprintf(sql, sizeof(sql),
rb_snprintf(sql, sizeof(sql),
"SELECT DISTINCT mask1,mask2,reason,oper,time FROM %s WHERE perm = 1 ORDER BY time",
bandb_table[id]);
else
snprintf(sql, sizeof(sql),
rb_snprintf(sql, sizeof(sql),
"SELECT DISTINCT mask1,mask2,reason,oper,time FROM %s WHERE perm = 0 ORDER BY time",
bandb_table[id]);
@ -315,7 +315,7 @@ export_config(const char *conf, int id)
switch (id) {
case BANDB_DLINE:
case BANDB_DLINE_PERM:
snprintf(buf, sizeof(buf),
rb_snprintf(buf, sizeof(buf),
"\"%s\",\"%s\",\"\",\"%s\",\"%s\",%s\n",
table.row[j][mask1],
mangle_reason(table.row[j][reason]),
@ -325,7 +325,7 @@ export_config(const char *conf, int id)
case BANDB_XLINE:
case BANDB_XLINE_PERM:
snprintf(buf, sizeof(buf),
rb_snprintf(buf, sizeof(buf),
"\"%s\",\"0\",\"%s\",\"%s\",%s\n",
escape_quotes(table.row[j][mask1]),
mangle_reason(table.row[j][reason]),
@ -334,7 +334,7 @@ export_config(const char *conf, int id)
case BANDB_RESV:
case BANDB_RESV_PERM:
snprintf(buf, sizeof(buf),
rb_snprintf(buf, sizeof(buf),
"\"%s\",\"%s\",\"%s\",%s\n",
table.row[j][mask1],
mangle_reason(table.row[j][reason]),
@ -343,7 +343,7 @@ export_config(const char *conf, int id)
default: /* Klines */
snprintf(buf, sizeof(buf),
rb_snprintf(buf, sizeof(buf),
"\"%s\",\"%s\",\"%s\",\"\",\"%s\",\"%s\",%s\n",
table.row[j][mask1], table.row[j][mask2],
mangle_reason(table.row[j][reason]),
@ -476,9 +476,9 @@ import_config(const char *conf, int id)
/* append operreason_field to reason_field */
if(!EmptyString(f_oreason))
snprintf(newreason, sizeof(newreason), "%s | %s", f_reason, f_oreason);
rb_snprintf(newreason, sizeof(newreason), "%s | %s", f_reason, f_oreason);
else
snprintf(newreason, sizeof(newreason), "%s", f_reason);
rb_snprintf(newreason, sizeof(newreason), "%s", f_reason);
if(flag.pretend == NO) {
if(flag.dupes_ok == NO)
@ -811,7 +811,7 @@ bt_smalldate(const char *string)
lt = gmtime(&t);
if(lt == NULL)
return NULL;
snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
rb_snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min);
return buf;
}

View File

@ -45,7 +45,7 @@ mlog(const char *errstr, ...)
char buf[256];
va_list ap;
va_start(ap, errstr);
vsnprintf(buf, sizeof(buf), errstr, ap);
rb_vsnprintf(buf, sizeof(buf), errstr, ap);
va_end(ap);
error_cb(buf);
} else
@ -69,13 +69,13 @@ rsdb_init(rsdb_error_cb * ecb)
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) {
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
sqlite3_errmsg(rb_bandb));
mlog(errbuf);
return -1;
}
if(access(dbpath, W_OK)) {
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
mlog(errbuf);
return -1;
}

18
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for elemental-ircd 6.6.1.
# Generated by GNU Autoconf 2.69 for elemental-ircd 6.6.2.
#
# 2014 elemental-ircd Team
#
@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='elemental-ircd'
PACKAGE_TARNAME='elemental-ircd'
PACKAGE_VERSION='6.6.1'
PACKAGE_STRING='elemental-ircd 6.6.1'
PACKAGE_VERSION='6.6.2'
PACKAGE_STRING='elemental-ircd 6.6.2'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@ -1303,7 +1303,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures elemental-ircd 6.6.1 to adapt to many kinds of systems.
\`configure' configures elemental-ircd 6.6.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1364,7 +1364,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of elemental-ircd 6.6.1:";;
short | recursive ) echo "Configuration of elemental-ircd 6.6.2:";;
esac
cat <<\_ACEOF
@ -1488,7 +1488,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
elemental-ircd configure 6.6.1
elemental-ircd configure 6.6.2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2092,7 +2092,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by elemental-ircd $as_me 6.6.1, which was
It was created by elemental-ircd $as_me 6.6.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -10100,7 +10100,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by elemental-ircd $as_me 6.6.1, which was
This file was extended by elemental-ircd $as_me 6.6.2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -10166,7 +10166,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
elemental-ircd config.status 6.6.1
elemental-ircd config.status 6.6.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -10,7 +10,7 @@ AC_PREREQ(2.57)
dnl Sneaky way to get an Id tag into the configure script
AC_COPYRIGHT([2014 elemental-ircd Team])
AC_INIT([elemental-ircd],[6.6.1])
AC_INIT([elemental-ircd],[6.6.2])
AC_CONFIG_HEADER(include/setup.h)

View File

@ -57,13 +57,6 @@ serverinfo {
helpurl = "http://www.mynet.net/help";
hub = yes;
/* On multi-homed hosts you may need the following. These define
* the addresses we connect from to other servers. */
/* for IPv4 */
#vhost = "192.169.0.1";
/* for IPv6 */
#vhost6 = "3ffe:80e8:546::2";
/* ssl_private_key: our ssl private key */
ssl_private_key = "etc/ssl.key";

View File

@ -159,16 +159,6 @@ serverinfo {
*/
hub = no;
/* vhost: the IP to bind to when we connect outward to ipv4 servers.
* This should be an ipv4 IP only.
*/
#vhost = "192.169.0.1";
/* vhost6: the IP to bind to when we connect outward to ipv6 servers.
* This should be an ipv6 IP only.
*/
#vhost6 = "3ffe:80e8:546::2";
/* ssl_private_key: our ssl private key */
ssl_private_key = "etc/ssl.key";

View File

@ -155,16 +155,6 @@ serverinfo {
*/
hub = no;
/* vhost: the IP to bind to when we connect outward to ipv4 servers.
* This should be an ipv4 IP only.
*/
#vhost = "192.169.0.1";
/* vhost6: the IP to bind to when we connect outward to ipv6 servers.
* This should be an ipv6 IP only.
*/
#vhost6 = "3ffe:80e8:546::2";
/* ssl_private_key: our ssl private key */
ssl_private_key = "etc/ssl.key";

View File

@ -50,6 +50,7 @@ SRCS = \
extb_ssl.c \
extb_realname.c \
extb_extgecos.c \
extb_usermode.c \
force_user_invis.c \
hurt.c \
ip_cloaking.c \
@ -67,7 +68,6 @@ SRCS = \
m_mkpasswd.c \
m_oaccept.c \
m_ojoin.c \
m_olist.c \
m_okick.c \
m_omode.c \
m_opme.c \

View File

@ -41,13 +41,13 @@ static int eb_extended(const char *data, struct Client *client_p,
if (data == NULL)
return EXTBAN_INVALID;
snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->host, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p)) {
snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->orighost, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;

View File

@ -0,0 +1,79 @@
/*
* Usermode extban type: bans all users with a specific usermode
* -- nenolod
*/
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "ircd.h"
#include "send.h"
#include "hash.h"
#include "s_conf.h"
#include "s_user.h"
#include "s_serv.h"
#include "numeric.h"
static int _modinit(void);
static void _moddeinit(void);
static int eb_usermode(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
DECLARE_MODULE_AV1(extb_usermode, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision: 1299 $");
static int
_modinit(void)
{
extban_table['m'] = eb_usermode;
return 0;
}
static void
_moddeinit(void)
{
extban_table['m'] = NULL;
}
static int eb_usermode(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{
int dir = MODE_ADD;
unsigned int modes_ack = 0, modes_nak = 0;
const char *p;
(void)chptr;
/* $m must have a specified mode */
if (data == NULL)
return EXTBAN_INVALID;
for (p = data; *p != '\0'; p++)
{
switch (*p)
{
case '+':
dir = MODE_ADD;
break;
case '-':
dir = MODE_DEL;
break;
default:
switch (dir)
{
case MODE_DEL:
modes_nak |= user_modes[(unsigned char) *p];
break;
case MODE_ADD:
default:
modes_ack |= user_modes[(unsigned char) *p];
break;
}
break;
}
}
return ((client_p->umodes & modes_ack) == modes_ack &&
!(client_p->umodes & modes_nak)) ?
EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -36,7 +36,7 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha
return 0;
}
snprintf(text, sizeof(text), "O%s", source_p->id);
rb_snprintf(text, sizeof(text), "O%s", source_p->id);
/* Provide a nice error message if you try to OACCEPT someone
* who you've already OACCEPTed. */

View File

@ -132,7 +132,7 @@ mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
remove_user_from_channel(msptr);
snprintf(text, sizeof(text), "K%s", who->id);
rb_snprintf(text, sizeof(text), "K%s", who->id);
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)

View File

@ -1,149 +0,0 @@
/*
* ircd-ratbox: A slightly useful ircd.
* m_olist.c: List channels. olist is an oper only command
* that shows channels regardless of modes. This
* is kinda evil, and might be morally wrong, but
* somebody will likely need it.
*
* Copyright (C) 2002 by the past and present ircd coders, and others.
* Copyright (C) 2004 ircd-ratbox Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
#include "stdinc.h"
#include "channel.h"
#include "client.h"
#include "ircd.h"
#include "numeric.h"
#include "logger.h"
#include "s_serv.h"
#include "send.h"
#include "whowas.h"
#include "match.h"
#include "hash.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
#include "s_newconf.h"
static int mo_olist(struct Client *, struct Client *, int parc, const char *parv[]);
#ifndef STATIC_MODULES
struct Message olist_msgtab = {
"OLIST", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
};
mapi_clist_av1 olist_clist[] = { &olist_msgtab, NULL };
DECLARE_MODULE_AV1(okick, NULL, NULL, olist_clist, NULL, NULL, "$Revision: 6 $");
#endif
static void list_all_channels(struct Client *source_p);
static void list_named_channel(struct Client *source_p, const char *name);
/*
** mo_olist
** parv[1] = channel
*/
static int
mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(!IsOperSpy(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "oper_spy");
sendto_one(source_p, form_str(RPL_LISTEND),
me.name, source_p->name);
return 0;
}
/* If no arg, do all channels *whee*, else just one channel */
if(parc < 2 || EmptyString(parv[1]))
list_all_channels(source_p);
else
list_named_channel(source_p, parv[1]);
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0;
}
/*
* list_all_channels
* inputs - pointer to client requesting list
* output - 0/1
* side effects - list all channels to source_p
*/
static void
list_all_channels(struct Client *source_p)
{
struct Channel *chptr;
rb_dlink_node *ptr;
report_operspy(source_p, "LIST", NULL);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
RB_DLINK_FOREACH(ptr, global_channel_list.head) {
chptr = ptr->data;
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
me.name, source_p->name, chptr->chname,
rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me),
chptr->topic == NULL ? "" : chptr->topic);
}
return;
}
/*
* list_named_channel
* inputs - pointer to client requesting list
* output - 0/1
* side effects - list all channels to source_p
*/
static void
list_named_channel(struct Client *source_p, const char *name)
{
struct Channel *chptr;
char *p;
char *n = LOCAL_COPY(name);
if((p = strchr(n, ',')))
*p = '\0';
/* Put operspy notice before any output, but only if channel exists */
chptr = EmptyString(n) ? NULL : find_channel(n);
if(chptr != NULL)
report_operspy(source_p, "LIST", chptr->chname);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
if(EmptyString(n))
return;
if(chptr == NULL)
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), n);
else
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
chptr->chname, rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
}

View File

@ -172,9 +172,9 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
}
if(underline)
snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
rb_snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
else
snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
/* don't allow nicks to be empty after stripping
* this prevents nastiness like fake factions, etc. */
@ -184,9 +184,9 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
}
if(action)
snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
rb_snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
else
snprintf(text2, sizeof(text2), "%s", text);
rb_snprintf(text2, sizeof(text2), "%s", text);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",

View File

@ -130,6 +130,9 @@ mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char
}
}
/* Set UMODE_WEBCLIENT */
source_p->umodes = source_p->umodes | UMODE_WEBCLIENT;
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
return 0;
}

View File

@ -12,7 +12,30 @@
#include "atheme.h"
#include "uplink.h"
#include "pmodule.h"
#include "protocol/shadowircd.h"
/* Extended channel modes will eventually go here. */
/* Note that these are involved in atheme.db file format */
#define CMODE_NOCOLOR 0x00001000 /* hyperion +c */
#define CMODE_REGONLY 0x00002000 /* hyperion +r */
#define CMODE_OPMOD 0x00004000 /* hyperion +z */
#define CMODE_FINVITE 0x00008000 /* hyperion +g */
#define CMODE_EXLIMIT 0x00010000 /* charybdis +L */
#define CMODE_PERM 0x00020000 /* charybdis +P */
#define CMODE_FTARGET 0x00040000 /* charybdis +F */
#define CMODE_DISFWD 0x00080000 /* charybdis +Q */
#define CMODE_NOCTCP 0x00100000 /* charybdis +C */
#define CMODE_IMMUNE 0x00200000 /* shadowircd +M */
#define CMODE_ADMINONLY 0x00400000 /* shadowircd +A */
#define CMODE_OPERONLY 0x00800000 /* shadowircd +O */
#define CMODE_SSLONLY 0x01000000 /* shadowircd +S */
#define CMODE_NOACTIONS 0x02000000 /* shadowircd +D */
#define CMODE_NONOTICE 0x04000000 /* shadowircd +T */
#define CMODE_NOCAPS 0x08000000 /* shadowircd +G */
#define CMODE_NOKICKS 0x10000000 /* shadowircd +E */
#define CMODE_NONICKS 0x20000000 /* shadowircd +N */
#define CMODE_NOREPEAT 0x40000000 /* shadowircd +K */
#define CMODE_KICKNOREJOIN 0x80000000 /* shadowircd +J */
#define CMODE_HIDEBANS 0x100000000 /* elemental +u */
DECLARE_MODULE_V1("protocol/elemental-ircd", true, _modinit, NULL, PACKAGE_STRING, "PonyChat Development Group <http://www.ponychat.net>");
@ -71,6 +94,7 @@ struct cmode_ elemental_mode_list[] = {
{ 'd', CMODE_NONICKS },
{ 'K', CMODE_NOREPEAT },
{ 'J', CMODE_KICKNOREJOIN },
{ 'u', CMODE_HIDEBANS },
{ '\0', 0 }
};

View File

@ -28,3 +28,4 @@ User modes: (* designates that the umode is oper only)
+I - Prevents non-opers from seeing your channel list in
a whois query.
+Z - Is connected via SSL (set only on connection).
+W - Is connected via a web client (set only on connection).

View File

@ -22,3 +22,4 @@ User modes: (? designates that the umode is provided by an extension
anyone who's in a common channel with you to message you.
+V - Prevents you from receiving invites.
+Z - Is connected via SSL (set only on connection).
+W - Is connected via a web client (set only on connection).

View File

@ -425,6 +425,7 @@ struct ListClient {
#define UMODE_OPER 0x1000 /* Operator */
#define UMODE_ADMIN 0x2000 /* Admin on server */
#define UMODE_SSLCLIENT 0x4000 /* using SSL */
#define UMODE_WEBCLIENT 0x100000 /* user is connected via a web client */
#define UMODE_OVERRIDE 0x20000 /* able to override */
#define IsOverride(x) ((x)->umodes & UMODE_OVERRIDE)

View File

@ -330,6 +330,7 @@ extern const char *form_str(int);
#define ERR_HELPNOTFOUND 524
#define RPL_WHOISSECURE 671 /* Unreal3.2 --nenolod */
#define RPL_WHOISWEBIRC 672 /* plexus -- Xe */
#define RPL_MODLIST 702
#define RPL_ENDOFMODLIST 703

View File

@ -38,9 +38,26 @@
/*
* rb_sprintf - optimized sprintf
*/
int sprintf_append(char *str, const char *format, ...);
int snprintf_append(char *str, const size_t size, const char *, ...);
int vsnprintf_append(char *str, const size_t size, const char *fmt, va_list args);
int vsprintf_append(char *str, const char *fmt, va_list args);
#ifdef __GNUC__
int
rb_sprintf(char *str, const char *fmt, ...)
__attribute((format(printf, 2, 3)));
int rb_snprintf(char *str, const size_t size, const char *, ...)
__attribute__ ((format(printf, 3, 4)));
int rb_sprintf_append(char *str, const char *format, ...) __attribute((format(printf, 2, 3)));
int rb_snprintf_append(char *str, size_t len, const char *format, ...)
__attribute__ ((format(printf, 3, 4)));
#else
int rb_sprintf(char *str, const char *format, ...);
int rb_snprintf(char *str, const size_t size, const char *, ...);
int rb_sprintf_append(char *str, const char *format, ...);
int rb_snprintf_append(char *str, const size_t size, const char *, ...);
#endif
int rb_vsnprintf(char *str, const size_t size, const char *fmt, va_list args);
int rb_vsprintf(char *str, const char *fmt, va_list args);
int rb_vsnprintf_append(char *str, const size_t size, const char *fmt, va_list args);
int rb_vsprintf_append(char *str, const char *fmt, va_list args);
#endif /* SPRINTF_IRC */

View File

@ -1134,7 +1134,7 @@ inetntoa(const char *in)
* SOFTWARE.
*/
#define SPRINTF(x) ((size_t)sprintf x)
#define SPRINTF(x) ((size_t)rb_sprintf x)
/*
* WARNING: Don't even consider trying to compile this on a system where
@ -1513,7 +1513,7 @@ rb_inet_pton(int af, const char *src, void *dst)
/* Somebody might have passed as an IPv4 address this is sick but it works */
if(inet_pton4(src, dst)) {
char tmp[HOSTIPLEN];
sprintf(tmp, "::ffff:%s", src);
rb_sprintf(tmp, "::ffff:%s", src);
return (inet_pton6(tmp, dst));
} else
return (inet_pton6(src, dst));

View File

@ -454,7 +454,7 @@ rb_epoll_sched_event_timerfd(struct ev_entry *event, int when)
close(fd);
return 0;
}
snprintf(buf, sizeof(buf), "timerfd: %s", event->name);
rb_snprintf(buf, sizeof(buf), "timerfd: %s", event->name);
F = rb_open(fd, RB_FD_UNKNOWN, buf);
rb_set_nb(F);
event->comm_ptr = F;

View File

@ -272,7 +272,7 @@ rb_dump_events(void (*func) (char *, void *), void *ptr)
struct ev_entry *ev;
len = sizeof(buf);
snprintf(buf, len, "Last event to run: %s", last_event_ran);
rb_snprintf(buf, len, "Last event to run: %s", last_event_ran);
func(buf, ptr);
rb_strlcpy(buf, "Operation Next Execution", len);
@ -280,7 +280,7 @@ rb_dump_events(void (*func) (char *, void *), void *ptr)
RB_DLINK_FOREACH(dptr, event_list.head) {
ev = dptr->data;
snprintf(buf, len, "%-28s %-4ld seconds", ev->name,
rb_snprintf(buf, len, "%-28s %-4ld seconds", ev->name,
ev->when - (long)rb_current_time());
func(buf, ptr);
}

View File

@ -529,7 +529,7 @@ rb_supports_ssl(void)
void
rb_get_ssl_info(char *buf, size_t len)
{
snprintf(buf, len, "GNUTLS: compiled (%s), library(%s)",
rb_snprintf(buf, len, "GNUTLS: compiled (%s), library(%s)",
LIBGNUTLS_VERSION, gnutls_check_version(NULL));
}

View File

@ -116,19 +116,19 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
helper = rb_malloc(sizeof(rb_helper));
snprintf(buf, sizeof(buf), "%s helper - read", name);
rb_snprintf(buf, sizeof(buf), "%s helper - read", name);
if(rb_pipe(&in_f[0], &in_f[1], buf) < 0) {
rb_free(helper);
return NULL;
}
snprintf(buf, sizeof(buf), "%s helper - write", name);
rb_snprintf(buf, sizeof(buf), "%s helper - write", name);
if(rb_pipe(&out_f[0], &out_f[1], buf) < 0) {
rb_free(helper);
return NULL;
}
snprintf(fx, sizeof(fx), "%d", rb_get_fd(in_f[1]));
snprintf(fy, sizeof(fy), "%d", rb_get_fd(out_f[0]));
rb_snprintf(fx, sizeof(fx), "%d", rb_get_fd(in_f[1]));
rb_snprintf(fy, sizeof(fy), "%d", rb_get_fd(out_f[0]));
rb_set_nb(in_f[0]);
rb_set_nb(in_f[1]);
@ -139,7 +139,7 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
rb_setenv("OFD", fx, 1);
rb_setenv("MAXFD", "256", 1);
snprintf(buf, sizeof(buf), "-ircd %s daemon", name);
rb_snprintf(buf, sizeof(buf), "-ircd %s daemon", name);
parv[0] = buf;
parv[1] = NULL;

View File

@ -506,12 +506,12 @@ rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args,
if(prefixfmt != NULL) {
va_start(prefix_args, prefixfmt);
len = vsnprintf(bufline->buf, BUF_DATA_SIZE, prefixfmt, prefix_args);
len = rb_vsnprintf(bufline->buf, BUF_DATA_SIZE, prefixfmt, prefix_args);
va_end(prefix_args);
}
if(va_args != NULL) {
len += vsnprintf((bufline->buf + len), (BUF_DATA_SIZE - len), format, *va_args);
len += rb_vsnprintf((bufline->buf + len), (BUF_DATA_SIZE - len), format, *va_args);
}
bufline->terminated = 1;
@ -608,7 +608,7 @@ rb_linebuf_put(buf_head_t * bufhead, const char *format, ...)
if(rb_unlikely(format != NULL)) {
va_start(args, format);
len = vsnprintf(bufline->buf, BUF_DATA_SIZE, format, args);
len = rb_vsnprintf(bufline->buf, BUF_DATA_SIZE, format, args);
va_end(args);
}

View File

@ -170,7 +170,7 @@ rb_ssl_clear_handshake_count(rb_fde_t *F)
void
rb_get_ssl_info(char *buf, size_t len)
{
snprintf(buf, len, "Not compiled with SSL support");
rb_snprintf(buf, len, "Not compiled with SSL support");
}
#endif /* !HAVE_OPENSSL */

View File

@ -622,7 +622,7 @@ rb_supports_ssl(void)
void
rb_get_ssl_info(char *buf, size_t len)
{
snprintf(buf, len, "Using SSL: %s compiled: 0x%lx, library 0x%lx",
rb_snprintf(buf, len, "Using SSL: %s compiled: 0x%lx, library 0x%lx",
SSLeay_version(SSLEAY_VERSION),
(long)OPENSSL_VERSION_NUMBER, SSLeay());
}

View File

@ -74,7 +74,7 @@ prefix_toa2x(rb_prefix_t *prefix, char *buf, int buf_len, int with_len)
}
inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len);
if(with_len) {
snprintf(tmp, sizeof(tmp), "/%d", prefix->bitlen);
rb_snprintf(tmp, sizeof(tmp), "/%d", prefix->bitlen);
strcat(buf, tmp);
}
return (buf);

View File

@ -82,7 +82,7 @@ rb_ctime(const time_t t, char *buf, size_t len)
return (p);
}
snprintf(p, tlen, "%s %s %d %02u:%02u:%02u %d",
rb_snprintf(p, tlen, "%s %s %d %02u:%02u:%02u %d",
s_weekdays[tp->tm_wday], s_month[tp->tm_mon],
tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_year + 1900);
return (p);
@ -106,7 +106,7 @@ rb_date(const time_t t, char *buf, size_t len)
return (buf);
}
snprintf(buf, len, "%s %s %d %d -- %02u:%02u:%02u +00:00",
rb_snprintf(buf, len, "%s %s %d %d -- %02u:%02u:%02u +00:00",
weekdays[gm->tm_wday], months[gm->tm_mon], gm->tm_mday,
gm->tm_year + 1900, gm->tm_hour, gm->tm_min, gm->tm_sec);
return (buf);
@ -131,7 +131,7 @@ rb_lib_log(const char *format, ...)
if(rb_log == NULL)
return;
va_start(args, format);
vsnprintf(errbuf, sizeof(errbuf), format, args);
rb_vsnprintf(errbuf, sizeof(errbuf), format, args);
va_end(args);
rb_log(errbuf);
}
@ -143,7 +143,7 @@ rb_lib_die(const char *format, ...)
if(rb_die == NULL)
abort();
va_start(args, format);
vsnprintf(errbuf, sizeof(errbuf), format, args);
rb_vsnprintf(errbuf, sizeof(errbuf), format, args);
va_end(args);
rb_die(errbuf);
}
@ -155,7 +155,7 @@ rb_lib_restart(const char *format, ...)
if(rb_restart == NULL)
abort();
va_start(args, format);
vsnprintf(errbuf, sizeof(errbuf), format, args);
rb_vsnprintf(errbuf, sizeof(errbuf), format, args);
va_end(args);
rb_restart(errbuf);
}
@ -184,7 +184,7 @@ rb_lib_version(void)
static char version_info[512];
char ssl_info[512];
rb_get_ssl_info(ssl_info, sizeof(ssl_info));
snprintf(version_info, sizeof(version_info), "libratbox version: %s - %s", libratbox_serno, ssl_info);
rb_snprintf(version_info, sizeof(version_info), "libratbox version: %s - %s", libratbox_serno, ssl_info);
return version_info;
}

View File

@ -26,43 +26,606 @@
#include <libratbox_config.h>
#include <ratbox_lib.h>
#include <string.h>
/*
* vsprintf_append()
* appends sprintf formatted string to the end of the buffer
*/
int
vsprintf_append(char *str, const char *format, va_list ap)
static int
skip_atoi(const char **s)
{
size_t x = strlen(str);
return (vsprintf(str + x, format, ap) + x);
int i = 0;
while(isdigit(**s))
i = i * 10 + *((*s)++) - '0';
return i;
}
/* Decimal conversion is by far the most typical, and is used
* for /proc and /sys data. This directly impacts e.g. top performance
* with many processes running. We optimize it for speed
* using code from
* http://www.cs.uiowa.edu/~jones/bcd/decimal.html
* (with permission from the author, Douglas W. Jones). */
/* Formats correctly any integer in [0,99999].
* Outputs from one to five digits depending on input.
* On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
static char *
put_dec_trunc(char *buf, unsigned q)
{
unsigned d3, d2, d1, d0;
d1 = (q >> 4) & 0xf;
d2 = (q >> 8) & 0xf;
d3 = (q >> 12);
d0 = 6 * (d3 + d2 + d1) + (q & 0xf);
q = (d0 * 0xcd) >> 11;
d0 = d0 - 10 * q;
*buf++ = d0 + '0'; /* least significant digit */
d1 = q + 9 * d3 + 5 * d2 + d1;
if(d1 != 0) {
q = (d1 * 0xcd) >> 11;
d1 = d1 - 10 * q;
*buf++ = d1 + '0'; /* next digit */
d2 = q + 2 * d2;
if((d2 != 0) || (d3 != 0)) {
q = (d2 * 0xd) >> 7;
d2 = d2 - 10 * q;
*buf++ = d2 + '0'; /* next digit */
d3 = q + 4 * d3;
if(d3 != 0) {
q = (d3 * 0xcd) >> 11;
d3 = d3 - 10 * q;
*buf++ = d3 + '0'; /* next digit */
if(q != 0)
*buf++ = q + '0'; /* most sign. digit */
}
}
}
return buf;
}
/* Same with if's removed. Always emits five digits */
static char *
put_dec_full(char *buf, unsigned q)
{
/* BTW, if q is in [0,9999], 8-bit ints will be enough, */
/* but anyway, gcc produces better code with full-sized ints */
unsigned d3, d2, d1, d0;
d1 = (q >> 4) & 0xf;
d2 = (q >> 8) & 0xf;
d3 = (q >> 12);
/* Possible ways to approx. divide by 10 */
/* gcc -O2 replaces multiply with shifts and adds */
// (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386)
// (x * 0x67) >> 10: 1100111
// (x * 0x34) >> 9: 110100 - same
// (x * 0x1a) >> 8: 11010 - same
// (x * 0x0d) >> 7: 1101 - same, shortest code (on i386)
d0 = 6 * (d3 + d2 + d1) + (q & 0xf);
q = (d0 * 0xcd) >> 11;
d0 = d0 - 10 * q;
*buf++ = d0 + '0';
d1 = q + 9 * d3 + 5 * d2 + d1;
q = (d1 * 0xcd) >> 11;
d1 = d1 - 10 * q;
*buf++ = d1 + '0';
d2 = q + 2 * d2;
q = (d2 * 0xd) >> 7;
d2 = d2 - 10 * q;
*buf++ = d2 + '0';
d3 = q + 4 * d3;
q = (d3 * 0xcd) >> 11; /* - shorter code */
/* q = (d3 * 0x67) >> 10; - would also work */
d3 = d3 - 10 * q;
*buf++ = d3 + '0';
*buf++ = q + '0';
return buf;
}
static char *
put_dec(char *buf, unsigned long long int num)
{
while(1) {
unsigned rem;
if(num < 100000)
return put_dec_trunc(buf, num);
rem = num % 100000;
num = num / 100000;
buf = put_dec_full(buf, rem);
}
}
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
static size_t
number(char *const buf, const size_t size, size_t idx, unsigned long long int num, int base, int field_width, int precision,
int type)
{
char sign, tmp[66];
const char *digits;
/* we are called with base 8, 10 or 16, only, thus don't need "g..." */
static const char small_digits[] = "0123456789abcdefx"; /* "ghijklmnopqrstuvwxyz"; */
static const char large_digits[] = "0123456789ABCDEFX"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
int need_pfx = ((type & SPECIAL) && base != 10);
int i;
digits = (type & LARGE) ? large_digits : small_digits;
if(type & LEFT)
type &= ~ZEROPAD;
if(base < 2 || base > 36)
return idx;
sign = 0;
if(type & SIGN) {
if((signed long long int)num < 0) {
sign = '-';
num = -(signed long long int)num;
field_width--;
} else if(type & PLUS) {
sign = '+';
field_width--;
} else if(type & SPACE) {
sign = ' ';
field_width--;
}
}
if(need_pfx) {
field_width--;
if(base == 16)
field_width--;
}
/* generate full string in tmp[], in reverse order */
i = 0;
if(num == 0)
tmp[i++] = '0';
/* Generic code, for any base:
else do {
tmp[i++] = digits[do_div(num,base)];
} while (num != 0);
*/
else if(base != 10) {
/* 8 or 16 */
int mask = base - 1;
int shift = 3;
if(base == 16)
shift = 4;
do {
tmp[i++] = digits[((unsigned char)num) & mask];
num >>= shift;
} while(num);
} else {
/* base 10 */
i = put_dec(tmp, num) - tmp;
}
/* printing 100 using %2d gives "100", not "00" */
if(i > precision)
precision = i;
/* leading space padding */
field_width -= precision;
if(!(type & (ZEROPAD + LEFT))) {
while(--field_width >= 0) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
}
/* sign */
if(sign) {
if(idx < size)
buf[idx] = sign;
++idx;
}
/* "0x" / "0" prefix */
if(need_pfx) {
if(idx < size)
buf[idx] = '0';
++idx;
if(base == 16) {
if(idx < size)
buf[idx] = digits[16]; /* for arbitrary base: digits[33]; */
++idx;
}
}
/* zero or space padding */
if(!(type & LEFT)) {
char c = (type & ZEROPAD) ? '0' : ' ';
while(--field_width >= 0) {
if(idx < size)
buf[idx] = c;
++idx;
}
}
/* hmm even more zero padding? */
while(i <= --precision) {
if(idx < size)
buf[idx] = '0';
++idx;
}
/* actual digits of result */
while(--i >= 0) {
if(idx < size)
buf[idx] = tmp[i];
++idx;
}
/* trailing space padding */
while(--field_width >= 0) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
return idx;
}
/**
* vsnprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @size: The size of the buffer, including the trailing null space
* @fmt: The format string to use
* @args: Arguments for the format string
*
* The return value is the number of characters which would
* be generated for the given input, excluding the trailing
* '\0', as per ISO C99. If you want to have the exact
* number of characters written into @buf as return value
* (not including the trailing '\0'), use vscnprintf(). If the
* return is greater than or equal to @size, the resulting
* string is truncated.
*
* Call this function if you are already dealing with a va_list.
* You probably want snprintf() instead.
*/
int
rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int len;
unsigned long long int num;
int i, base;
char c;
size_t idx;
const char *s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
/* 'z' support added 23/7/1999 S.H. */
/* 'z' changed to 'Z' --davidm 1/25/99 */
/* 't' added for ptrdiff_t */
/* Reject out-of-range values early. Large positive sizes are
used for unknown buffer sizes. */
if(rb_unlikely(size > INT_MAX)) {
return 0;
}
idx = 0;
for(; *fmt; ++fmt) {
if(*fmt != '%') {
if(idx < size)
buf[idx] = *fmt;
++idx;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-':
flags |= LEFT;
goto repeat;
case '+':
flags |= PLUS;
goto repeat;
case ' ':
flags |= SPACE;
goto repeat;
case '#':
flags |= SPECIAL;
goto repeat;
case '0':
flags |= ZEROPAD;
goto repeat;
}
/* get field width */
field_width = -1;
if(isdigit(*fmt))
field_width = skip_atoi(&fmt);
else if(*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if(field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if(*fmt == '.') {
++fmt;
if(isdigit(*fmt))
precision = skip_atoi(&fmt);
else if(*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if(precision < 0)
precision = 0;
}
/* get the conversion qualifier */
qualifier = -1;
if(*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
*fmt == 'Z' || *fmt == 'z' || *fmt == 't') {
qualifier = *fmt;
++fmt;
if(qualifier == 'l' && *fmt == 'l') {
qualifier = 'L';
++fmt;
}
}
/* default base */
base = 10;
switch (*fmt) {
case 'c':
if(!(flags & LEFT)) {
while(--field_width > 0) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
}
c = (unsigned char)va_arg(args, int);
if(idx < size)
buf[idx] = c;
++idx;
while(--field_width > 0) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
continue;
case 's':
s = va_arg(args, char *);
if(s == NULL) {
abort(); /* prefer blowing up vs corrupt data */
}
len = rb_strnlen(s, precision);
if(!(flags & LEFT)) {
while(len < field_width--) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
}
for(i = 0; i < len; ++i) {
if(idx < size)
buf[idx] = *s;
++idx;
++s;
}
while(len < field_width--) {
if(idx < size)
buf[idx] = ' ';
++idx;
}
continue;
case 'p':
if(field_width == -1) {
field_width = 2 * sizeof(void *);
flags |= ZEROPAD;
}
idx = number(buf, size, idx,
(unsigned long)va_arg(args, void *),
16, field_width, precision, flags);
continue;
case 'n':
/* FIXME:
* What does C99 say about the overflow case here? */
if(qualifier == 'l') {
long *ip = va_arg(args, long *);
*ip = idx;
} else if(qualifier == 'Z' || qualifier == 'z') {
size_t *ip = va_arg(args, size_t *);
*ip = idx;
} else {
int *ip = va_arg(args, int *);
*ip = idx;
}
continue;
case '%':
if(idx < size)
buf[idx] = '%';
++idx;
continue;
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
default:
if(idx < size)
buf[idx] = '%';
++idx;
if(*fmt) {
if(idx < size)
buf[idx] = *fmt;
++idx;
} else {
--fmt;
}
continue;
}
if(qualifier == 'L')
num = va_arg(args, long long int);
else if(qualifier == 'l') {
num = va_arg(args, unsigned long);
if(flags & SIGN)
num = (signed long)num;
} else if(qualifier == 'Z' || qualifier == 'z') {
num = va_arg(args, size_t);
} else if(qualifier == 't') {
num = va_arg(args, ptrdiff_t);
} else if(qualifier == 'h') {
num = (unsigned short)va_arg(args, int);
if(flags & SIGN)
num = (signed short)num;
} else {
num = va_arg(args, unsigned int);
if(flags & SIGN)
num = (signed int)num;
}
idx = number(buf, size, idx, num, base, field_width, precision, flags);
}
if(size > 0) {
if(idx < size)
buf[idx] = '\0';
else
buf[size - 1] = '\0';
}
/* the trailing null byte doesn't count towards the total */
return idx;
}
/**
* snprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @size: The size of the buffer, including the trailing null space
* @fmt: The format string to use
* @...: Arguments for the format string
*
* The return value is the number of characters which would be
* generated for the given input, excluding the trailing null,
* as per ISO C99. If the return is greater than or equal to
* @size, the resulting string is truncated.
*/
int
rb_snprintf(char *buf, size_t size, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i = rb_vsnprintf(buf, size, fmt, args);
va_end(args);
return i;
}
/**
* vsprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @fmt: The format string to use
* @args: Arguments for the format string
*
* The function returns the number of characters written
* into @buf. Use vsnprintf() or vscnprintf() in order to avoid
* buffer overflows.
*
* Call this function if you are already dealing with a va_list.
* You probably want sprintf() instead.
*/
int
rb_vsprintf(char *buf, const char *fmt, va_list args)
{
return rb_vsnprintf(buf, INT_MAX, fmt, args);
}
/**
* sprintf - Format a string and place it in a buffer
* @buf: The buffer to place the result into
* @fmt: The format string to use
* @...: Arguments for the format string
*
* The function returns the number of characters written
* into @buf. Use snprintf() or scnprintf() in order to avoid
* buffer overflows.
*/
int
rb_sprintf(char *buf, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i = rb_vsnprintf(buf, INT_MAX, fmt, args);
va_end(args);
return i;
}
/*
* sprintf_append()
* rb_vsprintf_append()
* appends sprintf formatted string to the end of the buffer
*/
int
rb_vsprintf_append(char *str, const char *format, va_list ap)
{
size_t x = strlen(str);
return (rb_vsprintf(str + x, format, ap) + x);
}
/*
* rb_sprintf_append()
* appends sprintf formatted string to the end of the buffer
*/
int
sprintf_append(char *str, const char *format, ...)
rb_sprintf_append(char *str, const char *format, ...)
{
int x;
va_list ap;
va_start(ap, format);
x = vsprintf_append(str, format, ap);
x = rb_vsprintf_append(str, format, ap);
va_end(ap);
return (x);
}
/*
* vsnprintf_append()
* rb_vsnprintf_append()
* appends sprintf formatted string to the end of the buffer but not
* exceeding len
*/
int
vsnprintf_append(char *str, size_t len, const char *format, va_list ap)
rb_vsnprintf_append(char *str, size_t len, const char *format, va_list ap)
{
size_t x;
if(len == 0)
@ -73,22 +636,22 @@ vsnprintf_append(char *str, size_t len, const char *format, va_list ap)
str[len - 1] = '\0';
return len - 1;
}
return (vsnprintf(str + x, len - x, format, ap) + x);
return (rb_vsnprintf(str + x, len - x, format, ap) + x);
}
/*
* snprintf_append()
* rb_snprintf_append()
* appends snprintf formatted string to the end of the buffer but not
* exceeding len
*/
int
nprintf_append(char *str, size_t len, const char *format, ...)
rb_snprintf_append(char *str, size_t len, const char *format, ...)
{
int x;
va_list ap;
va_start(ap, format);
x = vsnprintf_append(str, len, format, ap);
x = rb_vsnprintf_append(str, len, format, ap);
va_end(ap);
return (x);
}

View File

@ -134,7 +134,7 @@ rb_setenv(const char *name, const char *value, int overwrite)
return -1;
len = strlen(name) + strlen(value) + 5;
buf = rb_malloc(len);
snprintf(buf, len, "%s=%s", name, value);
rb_snprintf(buf, len, "%s=%s", name, value);
len = putenv(buf);
rb_free(buf);
return (len);

View File

@ -57,7 +57,7 @@ is_safe_error(const char *message)
if (!strncmp(message, "Closing Link: 127.0.0.1 (", 25))
return 1;
snprintf(prefix2, sizeof prefix2,
rb_snprintf(prefix2, sizeof prefix2,
"Closing Link: 127.0.0.1 %s (", me.name);
if (!strncmp(message, prefix2, strlen(prefix2)))
return 1;

View File

@ -494,7 +494,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
else
modes = empty_modes;
mlen_uid = sprintf(buf_uid, ":%s SJOIN %ld %s %s :",
mlen_uid = rb_sprintf(buf_uid, ":%s SJOIN %ld %s %s :",
use_id(source_p), (long) chptr->channelts, parv[2], modes);
ptr_uid = buf_uid + mlen_uid;
@ -579,7 +579,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
}
/* copy the nick to the two buffers */
len = sprintf(ptr_uid, "%s ", use_id(target_p));
len = rb_sprintf(ptr_uid, "%s ", use_id(target_p));
ptr_uid += len;
len_uid += len;
@ -937,7 +937,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
dir = MODE_DEL;
}
*mbuf++ = 'k';
len = sprintf(pbuf, "%s ", oldmode->key);
len = rb_sprintf(pbuf, "%s ", oldmode->key);
pbuf += len;
}
if(oldmode->join_num && !mode->join_num) {
@ -960,7 +960,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
dir = MODE_ADD;
}
*mbuf++ = 'l';
len = sprintf(pbuf, "%d ", mode->limit);
len = rb_sprintf(pbuf, "%d ", mode->limit);
pbuf += len;
}
if(mode->key[0] && strcmp(oldmode->key, mode->key)) {
@ -969,7 +969,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
dir = MODE_ADD;
}
*mbuf++ = 'k';
len = sprintf(pbuf, "%s ", mode->key);
len = rb_sprintf(pbuf, "%s ", mode->key);
pbuf += len;
}
if(mode->join_num && (oldmode->join_num != mode->join_num || oldmode->join_time != mode->join_time)) {
@ -978,7 +978,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
dir = MODE_ADD;
}
*mbuf++ = 'j';
len = sprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time);
len = rb_sprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time);
pbuf += len;
}
if(mode->forward[0] && strcmp(oldmode->forward, mode->forward) && ConfigChannel.use_forward) {
@ -987,7 +987,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
dir = MODE_ADD;
}
*mbuf++ = 'f';
len = sprintf(pbuf, "%s ", mode->forward);
len = rb_sprintf(pbuf, "%s ", mode->forward);
pbuf += len;
}
*mbuf = '\0';
@ -1393,7 +1393,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p,
pbuf = lparabuf;
cur_len = mlen = sprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname);
cur_len = mlen = rb_sprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname);
mbuf = lmodebuf + mlen;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) {
@ -1417,7 +1417,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p,
*mbuf++ = c;
cur_len += plen;
pbuf += sprintf(pbuf, "%s ", banptr->banstr);
pbuf += rb_sprintf(pbuf, "%s ", banptr->banstr);
count++;
free_ban(banptr);

View File

@ -221,7 +221,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p
use_id(source_p), chptr->chname, use_id(who), comment);
remove_user_from_channel(msptr);
snprintf(text, sizeof(text), "K%s", who->id);
rb_snprintf(text, sizeof(text), "K%s", who->id);
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)

View File

@ -140,7 +140,7 @@ mo_kill(struct Client *client_p, struct Client *source_p, int parc, const char *
target_p->flags |= FLAGS_KILLED;
}
sprintf(buf, "Killed (%s (%s))", source_p->name, reason);
rb_sprintf(buf, "Killed (%s (%s))", source_p->name, reason);
exit_client(client_p, target_p, source_p, buf);
@ -247,7 +247,7 @@ ms_kill(struct Client *client_p, struct Client *source_p, int parc, const char *
/* FLAGS_KILLED prevents a quit being sent out */
target_p->flags |= FLAGS_KILLED;
sprintf(buf, "Killed (%s %s)", source_p->name, reason);
rb_sprintf(buf, "Killed (%s %s)", source_p->name, reason);
exit_client(client_p, target_p, source_p, buf);
@ -263,11 +263,11 @@ relay_kill(struct Client *one, struct Client *source_p,
char buffer[BUFSIZE];
if(MyClient(source_p))
snprintf(buffer, sizeof(buffer),
rb_snprintf(buffer, sizeof(buffer),
"%s!%s!%s!%s (%s)",
me.name, source_p->host, source_p->username, source_p->name, reason);
else
snprintf(buffer, sizeof(buffer), "%s %s", inpath, reason);
rb_snprintf(buffer, sizeof(buffer), "%s %s", inpath, reason);
RB_DLINK_FOREACH(ptr, serv_list.head) {
client_p = ptr->data;

View File

@ -485,6 +485,10 @@ msg_channel(int p_or_n, const char *command,
rb_strlcpy(text2, text, BUFSIZE);
strip_unprintable(text2);
if(!MyClient(source_p)) {
goto skip_NOCAPS_check;
}
// Don't count the "ACTION" part of action as part of the message --SnoFox
if (p_or_n != NOTICE && *text == '\001' &&
!strncasecmp(text + 1, "ACTION ", 7)) {
@ -503,6 +507,7 @@ msg_channel(int p_or_n, const char *command,
return;
}
}
skip_NOCAPS_check:
if(chptr->mode.mode & MODE_NOCOLOR && (!ConfigChannel.exempt_cmode_c || !is_any_op(msptr))) {
rb_strlcpy(text2, text, BUFSIZE);
@ -768,7 +773,7 @@ msg_client(int p_or_n, const char *command,
(IsSetSCallerId(target_p) && !has_common_channel(source_p, target_p)) ||
(IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]))) {
if (IsOper(source_p)) {
snprintf(text3, sizeof(text3), "O%s", source_p->id);
rb_snprintf(text3, sizeof(text3), "O%s", source_p->id);
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) {
if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text3)) {
oaccept = 1;

View File

@ -293,7 +293,7 @@ ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char
fakesource_p = &me;
else
fakesource_p = source_p;
mlen = sprintf(modebuf, ":%s MODE %s +", fakesource_p->name, chptr->chname);
mlen = rb_sprintf(modebuf, ":%s MODE %s +", fakesource_p->name, chptr->chname);
mbuf = modebuf + mlen;
pbuf = parabuf;
@ -337,7 +337,7 @@ ms_bmask(struct Client *client_p, struct Client *source_p, int parc, const char
}
*mbuf++ = parv[3][0];
arglen = sprintf(pbuf, "%s ", s);
arglen = rb_sprintf(pbuf, "%s ", s);
pbuf += arglen;
plen += arglen;
modecount++;

View File

@ -311,7 +311,7 @@ ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *p
"with %d arguments (expecting 10)", client_p->name, parc);
ilog(L_SERVER, "Excess parameters (%d) for command 'UID' from %s.",
parc, client_p->name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Excess parameters (%d) to %s command, expecting %d",
parc, "UID", 10);
exit_client(client_p, client_p, client_p, squitreason);
@ -325,7 +325,7 @@ ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *p
}
if(!clean_uid(parv[8])) {
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Invalid UID %s for nick %s on %s",
parv[8], parv[1], source_p->name);
exit_client(client_p, client_p, client_p, squitreason);
@ -394,7 +394,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
"with %d arguments (expecting 12)", client_p->name, parc);
ilog(L_SERVER, "Excess parameters (%d) for command 'EUID' from %s.",
parc, client_p->name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Excess parameters (%d) to %s command, expecting %d",
parc, "EUID", 12);
exit_client(client_p, client_p, client_p, squitreason);
@ -408,7 +408,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
}
if(!clean_uid(parv[8])) {
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Invalid UID %s for nick %s on %s",
parv[8], parv[1], source_p->name);
exit_client(client_p, client_p, client_p, squitreason);
@ -601,7 +601,7 @@ set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
strcpy(source_p->name, nick);
add_to_client_hash(nick, source_p);
snprintf(note, sizeof(note), "Nick: %s", nick);
rb_snprintf(note, sizeof(note), "Nick: %s", nick);
rb_note(client_p->localClient->F, note);
if(source_p->flags & FLAGS_SENTUSER) {
@ -710,7 +710,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
rb_dlinkDestroy(ptr, &source_p->on_allow_list);
}
snprintf(note, sizeof(note), "Nick: %s", nick);
rb_snprintf(note, sizeof(note), "Nick: %s", nick);
rb_note(client_p->localClient->F, note);
return;
@ -1158,7 +1158,7 @@ static void bad_nickname(struct Client *client_p, const char *nick)
ilog(L_SERVER, "Link %s cancelled, bad nickname %s sent (NICKLEN mismatch?)",
client_p->name, nick);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Bad nickname introduced [%s]", nick);
exit_client(client_p, client_p, &me, squitreason);
}

View File

@ -65,7 +65,7 @@ m_quit(struct Client *client_p, struct Client *source_p, int parc, const char *p
strip_colour(comment);
if(ConfigFileEntry.client_exit && comment[0]) {
snprintf(reason, sizeof(reason), "Quit: %s", comment);
rb_snprintf(reason, sizeof(reason), "Quit: %s", comment);
comment = reason;
}

View File

@ -113,7 +113,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
if (!(client_p->localClient->caps & cap->cap)) {
char exitbuf[BUFSIZE];
snprintf(exitbuf, BUFSIZE, "Missing required CAPAB [%s]", cap->name);
rb_snprintf(exitbuf, BUFSIZE, "Missing required CAPAB [%s]", cap->name);
exit_client(client_p, client_p, client_p, exitbuf);
return 0;
@ -309,7 +309,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
ilog(L_SERVER, "Link %s cancelled, server %s already exists",
client_p->name, name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Server %s already exists",
name);
exit_client(client_p, client_p, &me, squitreason);
@ -391,7 +391,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
ilog(L_SERVER, "Non-Hub link %s introduced %s.",
client_p->name, name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"No matching hub_mask for %s",
name);
exit_client(NULL, client_p, &me, squitreason);
@ -407,7 +407,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
ilog(L_SERVER, "Link %s introduced leafed server %s.",
client_p->name, name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Matching leaf_mask for %s",
name);
exit_client(NULL, client_p, &me, squitreason);
@ -483,7 +483,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
ilog(L_SERVER, "Link %s cancelled, server %s already exists",
client_p->name, parv[1]);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Server %s already exists",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);
@ -501,7 +501,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
ilog(L_SERVER, "Link %s cancelled, SID %s for server %s already in use by %s",
client_p->name, parv[3], parv[1], target_p->name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"SID %s for %s already in use by %s",
parv[3], parv[1], target_p->name);
exit_client(NULL, client_p, &me, squitreason);
@ -556,7 +556,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
ilog(L_SERVER, "Non-Hub link %s introduced %s.",
client_p->name, parv[1]);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"No matching hub_mask for %s",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);
@ -571,7 +571,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
ilog(L_SERVER, "Link %s introduced leafed server %s.",
client_p->name, parv[1]);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Matching leaf_mask for %s",
parv[1]);
exit_client(NULL, client_p, &me, squitreason);

View File

@ -228,7 +228,7 @@ list_accepts(struct Client *source_p)
*nicks = '\0';
}
len += snprintf(nicks + len, sizeof(nicks) - len, "%s ", target_p->name);
len += rb_snprintf(nicks + len, sizeof(nicks) - len, "%s ", target_p->name);
count++;
}
}

View File

@ -173,7 +173,7 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
int curlen, mlen;
size_t i;
mlen = sprintf(buf, ":%s CAP %s %s",
mlen = rb_sprintf(buf, ":%s CAP %s %s",
me.name,
EmptyString(source_p->name) ? "*" : source_p->name,
subcmd);
@ -237,7 +237,7 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
}
}
curlen = sprintf(p, "%s ", clicap_list[i].name);
curlen = rb_sprintf(p, "%s ", clicap_list[i].name);
p += curlen;
buflen += curlen;
}
@ -345,7 +345,7 @@ cap_req(struct Client *source_p, const char *arg)
if(EmptyString(arg))
return;
buflen = snprintf(buf, sizeof(buf), ":%s CAP %s ACK",
buflen = rb_snprintf(buf, sizeof(buf), ":%s CAP %s ACK",
me.name, EmptyString(source_p->name) ? "*" : source_p->name);
pbuf[0][0] = '\0';

View File

@ -77,7 +77,7 @@ ms_encap(struct Client *client_p, struct Client *source_p, int parc, const char
if((size_t)(cur_len + len) >= sizeof(buffer))
return 0;
snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
rb_snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
cur_len += len;
ptr += len;
}
@ -86,9 +86,9 @@ ms_encap(struct Client *client_p, struct Client *source_p, int parc, const char
/* if its a command without parameters, dont prepend a ':' */
if(parc == 3)
snprintf(ptr, sizeof(buffer) - cur_len, "%s", parv[2]);
rb_snprintf(ptr, sizeof(buffer) - cur_len, "%s", parv[2]);
else
snprintf(ptr, sizeof(buffer) - cur_len, ":%s", parv[parc-1]);
rb_snprintf(ptr, sizeof(buffer) - cur_len, ":%s", parv[parc-1]);
/* add a trailing \0 if it was too long */
if((cur_len + len) >= BUFSIZE)

View File

@ -75,7 +75,7 @@ m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *p
current_insert_point2 = buf2;
*buf2 = '\0';
sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
len = strlen(buf);
current_insert_point = buf + len;

View File

@ -103,7 +103,7 @@ dump_map(struct Client *client_p, struct Client *root_p, char *pbuf)
}
frac = (1000 * rb_dlink_list_length(&root_p->serv->users) + Count.total / 2) / Count.total;
snprintf(buf + USER_COL, BUFSIZE - USER_COL,
rb_snprintf(buf + USER_COL, BUFSIZE - USER_COL,
" | Users: %5lu (%2d.%1d%%)", rb_dlink_list_length(&root_p->serv->users),
frac / 10, frac % 10);

View File

@ -86,9 +86,9 @@ add_monitor(struct Client *client_p, const char *nicks)
sendto_one(client_p, "%s", offbuf);
if(p)
snprintf(buf, sizeof(buf), "%s,%s", name, p);
rb_snprintf(buf, sizeof(buf), "%s,%s", name, p);
else
snprintf(buf, sizeof(buf), "%s", name);
rb_snprintf(buf, sizeof(buf), "%s", name);
sendto_one(client_p, form_str(ERR_MONLISTFULL),
me.name, client_p->name,

View File

@ -128,7 +128,7 @@ names_global(struct Client *source_p)
chptr = ptr->data;
channel_member_names(chptr, source_p, 0);
}
cur_len = mlen = sprintf(buf, form_str(RPL_NAMREPLY),
cur_len = mlen = rb_sprintf(buf, form_str(RPL_NAMREPLY),
me.name, source_p->name, "*", "*");
t = buf + mlen;
@ -167,7 +167,7 @@ names_global(struct Client *source_p)
t = buf + mlen;
}
tlen = sprintf(t, "%s ", target_p->name);
tlen = rb_sprintf(t, "%s ", target_p->name);
cur_len += tlen;
t += tlen;
}

View File

@ -82,7 +82,7 @@ ms_operspy(struct Client *client_p, struct Client *source_p,
if((size_t)(cur_len + len) >= sizeof(buffer))
return 0;
snprintf(ptr, sizeof(buffer) - cur_len, "%s ",
rb_snprintf(ptr, sizeof(buffer) - cur_len, "%s ",
parv[i]);
ptr += len;
cur_len += len;

View File

@ -123,7 +123,7 @@ do_restart(struct Client *source_p, const char *servername)
me.name, get_client_name(source_p, HIDE_IP));
}
sprintf(buf, "Server RESTART by %s", get_client_name(source_p, HIDE_IP));
rb_sprintf(buf, "Server RESTART by %s", get_client_name(source_p, HIDE_IP));
restart(buf);
return 0;

View File

@ -218,7 +218,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc,
continue;
if (mask != NULL) {
snprintf(maskbuf, BUFSIZE, "%s!%s@%s",
rb_snprintf(maskbuf, BUFSIZE, "%s!%s@%s",
target_p->name, target_p->username, target_p->host);
if (!match(mask, maskbuf))

View File

@ -196,7 +196,7 @@ me_rsfnc(struct Client *client_p, struct Client *source_p,
kill_client_serv_butone(NULL, exist_p, "%s (Nickname regained by services)",
me.name);
snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
rb_snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
me.name);
exit_client(NULL, exist_p, &me, buf);
}
@ -234,7 +234,7 @@ me_rsfnc(struct Client *client_p, struct Client *source_p,
del_all_accepts(target_p);
snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
rb_snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
rb_note(target_p->localClient->F, note);
return 0;
}

View File

@ -201,7 +201,7 @@ me_svslogin(struct Client *client_p, struct Client *source_p,
kill_client_serv_butone(NULL, exist_p, "%s (Nickname regained by services)",
me.name);
snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
rb_snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
me.name);
exit_client(NULL, exist_p, &me, buf);
} else if((exist_p = find_client(nick)) && IsUnknown(exist_p) && exist_p != target_p) {
@ -240,7 +240,7 @@ me_svslogin(struct Client *client_p, struct Client *source_p,
send_signon(NULL, target_p, nick, user, host, rb_current_time(), login);
snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
rb_snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
rb_note(target_p->localClient->F, note);
}

View File

@ -69,7 +69,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s dropped, wrong TS protocol version (%s,%s)",
source_p->name, parv[1], parv[2]);
snprintf(squitreason, sizeof squitreason, "Incompatible TS version (%s,%s)",
rb_snprintf(squitreason, sizeof squitreason, "Incompatible TS version (%s,%s)",
parv[1], parv[2]);
exit_client(source_p, source_p, source_p, squitreason);
return 0;
@ -92,7 +92,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
"Link %s dropped, excessive TS delta"
" (my TS=%ld, their TS=%ld, delta=%d)",
log_client_name(source_p, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat);
snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%d)",
rb_snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%d)",
(long) rb_current_time(), (long) theirtime, deltat);
disable_server_conf_autoconn(source_p->name);
exit_client(source_p, source_p, source_p, squitreason);

View File

@ -123,7 +123,7 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
if(aconf && aconf->status & CONF_DLINE) {
get_printable_kline(source_p, aconf, &phost, &reason, &puser, &operreason);
snprintf(reasonbuf, sizeof(reasonbuf), "%s%s%s", reason,
rb_snprintf(reasonbuf, sizeof(reasonbuf), "%s%s%s", reason,
operreason ? "|" : "", operreason ? operreason : "");
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name,
@ -170,9 +170,9 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
if(aconf->status & CONF_KILL) {
get_printable_kline(source_p, aconf, &phost, &reason, &puser, &operreason);
snprintf(buf, sizeof(buf), "%s@%s",
rb_snprintf(buf, sizeof(buf), "%s@%s",
puser, phost);
snprintf(reasonbuf, sizeof(reasonbuf), "%s%s%s", reason,
rb_snprintf(reasonbuf, sizeof(reasonbuf), "%s%s%s", reason,
operreason ? "|" : "", operreason ? operreason : "");
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name,

View File

@ -108,7 +108,7 @@ date(void)
if(minswest < 0)
minswest = -minswest;
sprintf(buf, "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
rb_sprintf(buf, "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
weekdays[lt->tm_wday], months[lt->tm_mon], lt->tm_mday,
lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
plus, minswest / 60, minswest % 60);

View File

@ -135,7 +135,7 @@ m_topic(struct Client *client_p, struct Client *source_p, int parc, const char *
}
if(ConfigChannel.host_in_topic)
sprintf(topic_info, "%s!%s@%s",
rb_sprintf(topic_info, "%s!%s@%s",
source_p->name, source_p->username, source_p->host);
else
rb_strlcpy(topic_info, source_p->name, sizeof(topic_info));

View File

@ -69,7 +69,7 @@ mr_user(struct Client *client_p, struct Client *source_p, int parc, const char *
if((p = strchr(parv[1], '@')))
*p = '\0';
snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]);
rb_snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]);
rb_free(source_p->localClient->fullcaps);
source_p->localClient->fullcaps = rb_strdup(buf);

View File

@ -62,7 +62,7 @@ m_userhost(struct Client *client_p, struct Client *source_p, int parc, const cha
int cur_len;
int rl;
cur_len = sprintf(buf, form_str(RPL_USERHOST), me.name, source_p->name, "");
cur_len = rb_sprintf(buf, form_str(RPL_USERHOST), me.name, source_p->name, "");
t = buf + cur_len;
for (i = 1; i <= 5; i++) {
@ -77,14 +77,14 @@ m_userhost(struct Client *client_p, struct Client *source_p, int parc, const cha
* is. Useful for things like NAT, and dynamic dial-up users.
*/
if(MyClient(target_p) && (target_p == source_p)) {
rl = sprintf(response, "%s%s=%c%s@%s ",
rl = rb_sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
(target_p->user->away) ? '-' : '+',
target_p->username,
target_p->sockhost);
} else {
rl = sprintf(response, "%s%s=%c%s@%s ",
rl = rb_sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
(target_p->user->away) ? '-' : '+',
@ -92,7 +92,7 @@ m_userhost(struct Client *client_p, struct Client *source_p, int parc, const cha
}
if((rl + cur_len) < (BUFSIZE - 10)) {
sprintf(t, "%s", response);
rb_sprintf(t, "%s", response);
t += rl;
cur_len += rl;
} else

View File

@ -441,7 +441,7 @@ append_format(char *buf, size_t bufsize, size_t *pos, const char *fmt, ...)
max = *pos >= bufsize ? 0 : bufsize - *pos;
va_start(ap, fmt);
result = vsnprintf(buf + *pos, max, fmt, ap);
result = rb_vsnprintf(buf + *pos, max, fmt, ap);
va_end(ap);
*pos += result;
}
@ -465,7 +465,7 @@ do_who(struct Client *source_p, struct Client *target_p, struct membership *mspt
size_t pos;
const char *q;
sprintf(status, "%c%s%s",
rb_sprintf(status, "%c%s%s",
target_p->user->away ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : "");
if (fmt->fields == 0)

View File

@ -187,7 +187,7 @@ do_whois(struct Client *client_p, struct Client *source_p, int parc, const char
if(operspy) {
char buffer[BUFSIZE];
snprintf(buffer, sizeof(buffer), "%s!%s@%s %s",
rb_snprintf(buffer, sizeof(buffer), "%s!%s@%s %s",
target_p->name, target_p->username,
target_p->host, target_p->servptr->name);
report_operspy(source_p, "WHOIS", buffer);
@ -244,7 +244,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
target_p->name, target_p->username,
target_p->host, target_p->info);
cur_len = mlen = sprintf(buf, form_str(RPL_WHOISCHANNELS),
cur_len = mlen = rb_sprintf(buf, form_str(RPL_WHOISCHANNELS),
get_id(&me, source_p), get_id(source_p, source_p),
target_p->name);
@ -276,7 +276,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
t = buf + mlen;
}
tlen = sprintf(t, "%s%s%s ",
tlen = rb_sprintf(t, "%s%s%s ",
visible ? "" : "*",
find_channel_status(msptr, 1),
chptr->chname);
@ -313,6 +313,12 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
if(IsSSLClient(target_p))
sendto_one_numeric(source_p, RPL_WHOISSECURE, form_str(RPL_WHOISSECURE),
target_p->name);
if(!(target_p->umodes & UMODE_WEBCLIENT)) {
sendto_one_numeric(source_p, RPL_WHOISWEBIRC, form_str(RPL_WHOISWEBIRC),
target_p->name);
}
if((source_p == target_p || IsOper(source_p)) &&
target_p->certfp != NULL)
sendto_one_numeric(source_p, RPL_WHOISCERTFP,

View File

@ -83,11 +83,11 @@ start_bandb(void)
rb_setenv("BANDB_DBPATH", PKGLOCALSTATEDIR "/ban.db", 1);
if(bandb_path == NULL) {
snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix);
rb_snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix);
if(access(fullpath, X_OK) == -1) {
snprintf(fullpath, sizeof(fullpath), "%s/bin/bandb%s",
ConfigFileEntry.dpath, suffix);
rb_snprintf(fullpath, sizeof(fullpath), "%s/bin/bandb%s",
ConfigFileEntry.dpath, suffix);
if(access(fullpath, X_OK) == -1) {
ilog(L_MAIN,
@ -122,16 +122,16 @@ bandb_add(bandb_type type, struct Client *source_p, const char *mask1,
static char buf[BUFSIZE];
snprintf(buf, sizeof(buf), "%c %s ", bandb_add_letter[type], mask1);
rb_snprintf(buf, sizeof(buf), "%c %s ", bandb_add_letter[type], mask1);
if(!EmptyString(mask2))
snprintf_append(buf, sizeof(buf), "%s ", mask2);
rb_snprintf_append(buf, sizeof(buf), "%s ", mask2);
snprintf_append(buf, sizeof(buf), "%s %ld %d :%s",
rb_snprintf_append(buf, sizeof(buf), "%s %ld %d :%s",
get_oper_name(source_p), (long int)rb_current_time(), perm, reason);
if(!EmptyString(oper_reason))
snprintf_append(buf, sizeof(buf), "|%s", oper_reason);
rb_snprintf_append(buf, sizeof(buf), "|%s", oper_reason);
rb_helper_write(bandb_helper, "%s", buf);
}
@ -150,10 +150,10 @@ bandb_del(bandb_type type, const char *mask1, const char *mask2)
buf[0] = '\0';
snprintf_append(buf, sizeof(buf), "%c %s", bandb_del_letter[type], mask1);
rb_snprintf_append(buf, sizeof(buf), "%c %s", bandb_del_letter[type], mask1);
if(!EmptyString(mask2))
snprintf_append(buf, sizeof(buf), " %s", mask2);
rb_snprintf_append(buf, sizeof(buf), " %s", mask2);
rb_helper_write(bandb_helper, "%s", buf);
}

View File

@ -121,7 +121,7 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client *
ip = (uint8_t *)&((struct sockaddr_in *)&client_p->localClient->ip)->sin_addr.s_addr;
/* becomes 2.0.0.127.torbl.ahbl.org or whatever */
snprintf(buf, sizeof buf, "%d.%d.%d.%d.%s",
rb_snprintf(buf, sizeof buf, "%d.%d.%d.%d.%s",
(unsigned int) ip[3],
(unsigned int) ip[2],
(unsigned int) ip[1],
@ -147,8 +147,8 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client *
uint8_t hi = (ip[i] >> 4) & 0x0F;
uint8_t lo = ip[i] & 0x0F;
/* One part... (why 5? snprintf adds \0) */
snprintf(bufptr, 5, "%1x.%1x.",
/* One part... (why 5? rb_snprintf adds \0) */
rb_snprintf(bufptr, 5, "%1x.%1x.",
(unsigned int) lo, /* Remember, backwards */
(unsigned int) hi);

View File

@ -172,7 +172,7 @@ cache_links(void *unused)
/* if the below is ever modified, change LINKSLINELEN */
links_line = rb_malloc(LINKSLINELEN);
snprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
rb_snprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
target_p->name, me.name,
target_p->info[0] ? target_p->info :
"(Unknown Location)");
@ -241,7 +241,7 @@ load_help(void)
while((ldirent = readdir(helpfile_dir)) != NULL) {
if(ldirent->d_name[0] == '.')
continue;
snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
rb_snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
irc_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
}
@ -255,7 +255,7 @@ load_help(void)
while((ldirent = readdir(helpfile_dir)) != NULL) {
if(ldirent->d_name[0] == '.')
continue;
snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
rb_snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
if(lstat(filename, &sb) < 0)
@ -319,7 +319,7 @@ cache_user_motd(void)
local_tm = localtime(&sb.st_mtime);
if(local_tm != NULL) {
snprintf(user_motd_changed, sizeof(user_motd_changed),
rb_snprintf(user_motd_changed, sizeof(user_motd_changed),
"%d/%d/%d %d:%d",
local_tm->tm_mday, local_tm->tm_mon + 1,
1900 + local_tm->tm_year, local_tm->tm_hour,

View File

@ -565,7 +565,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
if(ShowChannel(client_p, chptr)) {
is_member = IsMember(client_p, chptr);
cur_len = mlen = sprintf(lbuf, form_str(RPL_NAMREPLY),
cur_len = mlen = rb_sprintf(lbuf, form_str(RPL_NAMREPLY),
me.name, client_p->name,
channel_pub_or_secret(chptr), chptr->chname);
@ -586,7 +586,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
t = lbuf + mlen;
}
tlen = sprintf(t, "%s%s ", find_channel_status(msptr, stack),
tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
target_p->name);
cur_len += tlen;
@ -648,8 +648,8 @@ is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
/* if the buffers havent been built, do it here */
if(s == NULL) {
sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
s = src_host;
s2 = src_iphost;
@ -657,13 +657,13 @@ is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
if(who->localClient->mangledhost != NULL) {
/* if host mangling mode enabled, also check their real host */
if(!strcmp(who->host, who->localClient->mangledhost)) {
sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
s3 = src_althost;
}
/* if host mangling mode not enabled and no other spoof,
* also check the mangled form of their host */
else if (!IsDynSpoof(who)) {
sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
s3 = src_althost;
}
}
@ -741,8 +741,8 @@ is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
/* if the buffers havent been built, do it here */
if(s == NULL) {
sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
s = src_host;
s2 = src_iphost;
@ -750,13 +750,13 @@ is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
if(who->localClient->mangledhost != NULL) {
/* if host mangling mode enabled, also check their real host */
if(!strcmp(who->host, who->localClient->mangledhost)) {
sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
s3 = src_althost;
}
/* if host mangling mode not enabled and no other spoof,
* also check the mangled form of their host */
else if (!IsDynSpoof(who)) {
sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
s3 = src_althost;
}
}
@ -834,18 +834,18 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
s_assert(source_p->localClient != NULL);
sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost);
rb_sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
rb_sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost);
if(source_p->localClient->mangledhost != NULL) {
/* if host mangling mode enabled, also check their real host */
if(!strcmp(source_p->host, source_p->localClient->mangledhost)) {
sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->orighost);
rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->orighost);
use_althost = 1;
}
/* if host mangling mode not enabled and no other spoof,
* also check the mangled form of their host */
else if (!IsDynSpoof(source_p)) {
sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->localClient->mangledhost);
rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->localClient->mangledhost);
use_althost = 1;
}
}
@ -853,7 +853,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key)
if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN)
return (ERR_BANNEDFROMCHAN);
snprintf(text, sizeof(text), "K%s", source_p->id);
rb_snprintf(text, sizeof(text), "K%s", source_p->id);
DICTIONARY_FOREACH(md, &iter, chptr->metadata) {
if(!strcmp(md->value, "KICKNOREJOIN") && !strcmp(md->name, text) && (md->timevalue + 2 > rb_current_time()))
@ -1036,8 +1036,8 @@ find_bannickchange_channel(struct Client *client_p)
if (!MyClient(client_p) || IsOverride(client_p))
return NULL;
sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
rb_sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
rb_sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
RB_DLINK_FOREACH(ptr, client_p->user->channel.head) {
msptr = ptr->data;
@ -1289,21 +1289,21 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
*mbuf++ = 'l';
if(!IsClient(client_p) || IsMember(client_p, chptr))
pbuf += sprintf(pbuf, " %d", chptr->mode.limit);
pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit);
}
if(*chptr->mode.key) {
*mbuf++ = 'k';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += sprintf(pbuf, " %s", chptr->mode.key);
pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key);
}
if(chptr->mode.join_num) {
*mbuf++ = 'j';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += sprintf(pbuf, " %d:%d", chptr->mode.join_num,
pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num,
chptr->mode.join_time);
}
@ -1311,7 +1311,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
*mbuf++ = 'f';
if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
pbuf += sprintf(pbuf, " %s", chptr->mode.forward);
pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward);
}
*mbuf = '\0';
@ -1453,7 +1453,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
cap = chcap_combos[j].cap_yes;
nocap = chcap_combos[j].cap_no;
mbl = preflen = sprintf(modebuf, ":%s TMODE %ld %s ",
mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
use_id(source_p), (long) chptr->channelts,
chptr->chname);
@ -1513,7 +1513,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
nc++;
if(arg != NULL) {
len = sprintf(pbuf, "%s ", arg);
len = rb_sprintf(pbuf, "%s ", arg);
pbuf += len;
pbl += len;
mc++;

View File

@ -140,7 +140,7 @@ construct_cflag_param_string(void)
{
*cflagsparaminfo = '\0';
snprintf(cflagsparaminfo, sizeof cflagsparaminfo, "%s%sb%s%s%s%sklov%s%s",
rb_snprintf(cflagsparaminfo, sizeof cflagsparaminfo, "%s%sb%s%s%s%sklov%s%s",
ConfigChannel.use_owner ? "y" : "",
ConfigChannel.use_admin ? "a" : "",
ConfigChannel.use_except ? "e" : "",
@ -219,7 +219,7 @@ get_channel_access(struct Client *source_p, struct membership *msptr)
/* check_bans_number()
*
* inputs - client, channel ban list
* outputs - 0 on ban being allowed, 1 on ban being disallowed
* outputs - 1 on ban being allowed, 0 on ban being disallowed
* side effects - none
*/
int
@ -227,10 +227,10 @@ check_bans_number(struct Client *source_p, struct Channel *chptr, rb_dlink_list
{
if (rb_dlink_list_length(list) >= (chptr->mode.mode & MODE_EXLIMIT ?
ConfigChannel.max_bans_large : ConfigChannel.max_bans)) {
return 0;
return 1;
}
return 1;
return 0;
}
/* add_id()
@ -277,7 +277,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
if(IsPerson(source_p))
sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
rb_sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
else
rb_strlcpy(who, source_p->name, sizeof(who));
@ -383,7 +383,7 @@ pretty_mask(const char *idmask)
old_mask_pos = mask_pos;
if (*mask == '$') {
mask_pos += sprintf(mask_buf + mask_pos, "%s", mask) + 1;
mask_pos += rb_sprintf(mask_buf + mask_pos, "%s", mask) + 1;
t = mask_buf + old_mask_pos + 1;
if (*t == '!')
*t = '~';
@ -440,7 +440,7 @@ pretty_mask(const char *idmask)
host[HOSTLEN] = '\0';
}
mask_pos += sprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host) + 1;
mask_pos += rb_sprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host) + 1;
/* restore mask, since we may need to use it again later */
if(at)
@ -1462,7 +1462,7 @@ chm_limit(struct Client *source_p, struct Channel *chptr,
if(EmptyString(lstr) || (limit = atoi(lstr)) <= 0)
return;
sprintf(limitstr, "%d", limit);
rb_sprintf(limitstr, "%d", limit);
mode_changes[mode_count].letter = c;
mode_changes[mode_count].dir = MODE_ADD;
@ -2102,9 +2102,9 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
return;
if(IsServer(source_p))
sprintf(cmdbuf, ":%s MODE %s ", fakesource_p->name, chptr->chname);
rb_sprintf(cmdbuf, ":%s MODE %s ", fakesource_p->name, chptr->chname);
else
sprintf(cmdbuf, ":%s!%s@%s MODE %s ",
rb_sprintf(cmdbuf, ":%s!%s@%s MODE %s ",
source_p->name, source_p->username,
source_p->host, chptr->chname);
@ -2186,7 +2186,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
if(mode_changes[i].arg != NULL) {
paracount++;
len = sprintf(pbuf, "%s ", mode_changes[i].arg);
len = rb_sprintf(pbuf, "%s ", mode_changes[i].arg);
pbuf += len;
paralen += len;
}

View File

@ -329,7 +329,7 @@ check_pings_list(rb_dlink_list * list)
"No response from %s, closing link",
log_client_name(client_p, HIDE_IP));
}
(void) snprintf(scratch, sizeof(scratch),
(void) rb_snprintf(scratch, sizeof(scratch),
"Ping timeout: %d seconds",
(int) (rb_current_time() - client_p->localClient->lasttime));
@ -759,16 +759,16 @@ get_client_name(struct Client *client, int showip)
/* And finally, let's get the host information, ip or name */
switch (showip) {
case SHOW_IP:
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
client->name, client->username,
client->sockhost);
break;
case MASK_IP:
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
client->name, client->username);
break;
default:
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
client->name, client->username, client->host);
}
return nbuf;
@ -799,16 +799,16 @@ log_client_name(struct Client *target_p, int showip)
switch (showip) {
case SHOW_IP:
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", target_p->name,
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", target_p->name,
target_p->username, target_p->sockhost);
break;
case MASK_IP:
snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
target_p->name, target_p->username);
default:
snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", target_p->name,
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]", target_p->name,
target_p->username, target_p->host);
}
@ -1064,7 +1064,7 @@ dead_link(struct Client *client_p, int sendqex)
if(sendqex)
rb_strlcpy(abt->notice, "Max SendQ exceeded", sizeof(abt->notice));
else
snprintf(abt->notice, sizeof(abt->notice), "Write error: %s", strerror(errno));
rb_snprintf(abt->notice, sizeof(abt->notice), "Write error: %s", strerror(errno));
abt->client = client_p;
SetIOError(client_p);
@ -1196,7 +1196,7 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
strcat(comment1, source_p->name);
}
if (IsPerson(from))
snprintf(newcomment, sizeof(newcomment), "by %s: %s",
rb_snprintf(newcomment, sizeof(newcomment), "by %s: %s",
from->name, comment);
if(source_p->serv != NULL)
@ -1274,7 +1274,7 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
/* Always show source here, so the server notices show
* which side initiated the split -- jilles
*/
snprintf(newcomment, sizeof(newcomment), "by %s: %s",
rb_snprintf(newcomment, sizeof(newcomment), "by %s: %s",
from == source_p ? me.name : from->name, comment);
if (!IsIOError(source_p))
sendto_one(source_p, "SQUIT %s :%s", use_id(source_p),
@ -1824,7 +1824,7 @@ error_exit_client(struct Client *client_p, int error)
if(error == 0)
rb_strlcpy(errmsg, "Remote host closed the connection", sizeof(errmsg));
else
snprintf(errmsg, sizeof(errmsg), "Read error: %s", strerror(current_error));
rb_snprintf(errmsg, sizeof(errmsg), "Read error: %s", strerror(current_error));
exit_client(client_p, client_p, &me, errmsg);
}

View File

@ -825,15 +825,15 @@ void irc_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line,
s_assert(dict != NULL);
if (dict->id != NULL)
snprintf(str, sizeof str, "Dictionary stats for %s (%d)",
rb_snprintf(str, sizeof str, "Dictionary stats for %s (%d)",
dict->id, dict->count);
else
snprintf(str, sizeof str, "Dictionary stats for <%p> (%d)",
rb_snprintf(str, sizeof str, "Dictionary stats for <%p> (%d)",
(void *)dict, dict->count);
cb(str, privdata);
maxdepth = 0;
sum = stats_recurse(dict->root, 0, &maxdepth);
snprintf(str, sizeof str, "Depth sum %d Avg depth %d Max depth %d", sum, sum / dict->count, maxdepth);
rb_snprintf(str, sizeof str, "Depth sum %d Avg depth %d Max depth %d", sum, sum / dict->count, maxdepth);
cb(str, privdata);
return;
}

View File

@ -377,7 +377,7 @@ write_pidfile(const char *filename)
if((fb = fopen(filename, "w"))) {
unsigned int pid = (unsigned int) getpid();
snprintf(buff, sizeof(buff), "%u\n", pid);
rb_snprintf(buff, sizeof(buff), "%u\n", pid);
if((fputs(buff, fb) == -1)) {
ilog(L_MAIN, "Error writing %u to pid file %s (%s)",
pid, filename, strerror(errno));

View File

@ -116,7 +116,7 @@ get_listener_name(const struct Listener *listener)
#endif
port = ntohs(((const struct sockaddr_in *)&listener->addr)->sin_port);
snprintf(buf, sizeof(buf), "%s[%s/%u]", me.name, listener->name, port);
rb_snprintf(buf, sizeof(buf), "%s[%s/%u]", me.name, listener->name, port);
return buf;
}
@ -484,7 +484,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi
ServerStats.is_ref++;
if(ConfigFileEntry.dline_with_reason) {
len = snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", get_user_ban_reason(aconf));
len = rb_snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", get_user_ban_reason(aconf));
if (len >= (int)(sizeof(buf)-1)) {
buf[sizeof(buf) - 3] = '\r';
buf[sizeof(buf) - 2] = '\n';

View File

@ -80,7 +80,7 @@ verify_logfile_access(const char *filename)
rb_free(d);
if(access(dirname, F_OK) == -1) {
snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - parent directory %s does not exist", filename, dirname);
rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - parent directory %s does not exist", filename, dirname);
if(testing_conf || server_state_foreground)
fprintf(stderr, "%s\n", buf);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
@ -89,7 +89,7 @@ verify_logfile_access(const char *filename)
if(access(filename, F_OK) == -1) {
if(access(dirname, W_OK) == -1) {
snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - access to parent directory %s failed: %s",
rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - access to parent directory %s failed: %s",
filename, dirname, strerror(errno));
if(testing_conf || server_state_foreground)
fprintf(stderr, "%s\n", buf);
@ -99,7 +99,7 @@ verify_logfile_access(const char *filename)
}
if(access(filename, W_OK) == -1) {
snprintf(buf, sizeof(buf), "WARNING: Access denied for logfile %s: %s", filename, strerror(errno));
rb_snprintf(buf, sizeof(buf), "WARNING: Access denied for logfile %s: %s", filename, strerror(errno));
if(testing_conf || server_state_foreground)
fprintf(stderr, "%s\n", buf);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
@ -165,10 +165,10 @@ ilog(ilogfile dest, const char *format, ...)
return;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
rb_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
snprintf(buf2, sizeof(buf2), "%s %s\n",
rb_snprintf(buf2, sizeof(buf2), "%s %s\n",
smalldate(rb_current_time()), buf);
if(fputs(buf2, logfile) < 0) {
@ -196,7 +196,7 @@ inotice(const char *format, ...)
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
rb_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
_iprint("notice", buf);
@ -211,7 +211,7 @@ iwarn(const char *format, ...)
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
rb_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
_iprint("warning", buf);
@ -226,7 +226,7 @@ ierror(const char *format, ...)
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
rb_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
_iprint("error", buf);
@ -261,7 +261,7 @@ smalldate(time_t ltime)
lt = localtime(&ltime);
snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
rb_snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
lt->tm_year + 1900, lt->tm_mon + 1,
lt->tm_mday, lt->tm_hour, lt->tm_min);

View File

@ -693,7 +693,7 @@ static const char * replies[] = {
/* 669 */ NULL,
/* 670 */ NULL,
/* 671 RPL_WHOISSECURE, */ "%s :is using a secure connection",
/* 672 */ NULL,
/* 672 RPL_WHOISWEBIRC, */ "%s :is using a web IRC client",
/* 673 */ NULL,
/* 674 */ NULL,
/* 675 */ NULL,

View File

@ -248,7 +248,7 @@ load_all_modules(int warn)
while ((ldirent = readdir(system_module_dir)) != NULL) {
len = strlen(ldirent->d_name);
if((len > 3) && !strcmp(ldirent->d_name+len-3, SHARED_SUFFIX)) {
(void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
(void) rb_snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name);
(void) load_a_module(module_fq_name, warn, 0);
}
@ -270,7 +270,7 @@ load_core_modules(int warn)
for (i = 0; core_module_table[i]; i++) {
snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
rb_snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH,
core_module_table[i], SHARED_SUFFIX);
if(load_a_module(module_name, warn, 1) == -1) {
@ -303,7 +303,7 @@ load_one_module(const char *path, int coremodule)
RB_DLINK_FOREACH(pathst, mod_paths.head) {
mpath = pathst->data;
snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL)) {
if(stat(modpath, &statbuf) == 0) {
if(S_ISREG(statbuf.st_mode)) {

View File

@ -99,7 +99,7 @@ monitor_signon(struct Client *client_p)
if(monptr == NULL)
return;
snprintf(buf, sizeof(buf), "%s!%s@%s", client_p->name, client_p->username, client_p->host);
rb_snprintf(buf, sizeof(buf), "%s!%s@%s", client_p->name, client_p->username, client_p->host);
sendto_monitor(monptr, form_str(RPL_MONONLINE), me.name, "*", buf);
}

View File

@ -1814,7 +1814,7 @@ conf_report_error(const char *fmt, ...)
char msg[IRCD_BUFSIZE + 1] = { 0 };
va_start(ap, fmt);
vsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
rb_vsnprintf(msg, IRCD_BUFSIZE, fmt, ap);
va_end(ap);
if (testing_conf) {

View File

@ -330,7 +330,7 @@ handle_command(struct Message *mptr, struct Client *client_p,
ilog(L_SERVER,
"Insufficient parameters (%d < %d) for command '%s' from %s.",
i, ehandler.min_para, mptr->cmd, client_p->name);
snprintf(squitreason, sizeof squitreason,
rb_snprintf(squitreason, sizeof squitreason,
"Insufficient parameters (%d < %d) for command '%s'",
i, ehandler.min_para, mptr->cmd);
exit_client(client_p, client_p, client_p, squitreason);
@ -567,10 +567,10 @@ do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, int
int i;
int tl; /* current length of presently being built string in t */
for (i = 2; i < (parc - 1); i++) {
tl = sprintf(t, " %s", parv[i]);
tl = rb_sprintf(t, " %s", parv[i]);
t += tl;
}
sprintf(t, " :%s", parv[parc - 1]);
rb_sprintf(t, " :%s", parv[parc - 1]);
}
if((target_p = find_client(parv[1])) != NULL) {

View File

@ -444,7 +444,7 @@ static void do_query_number(struct DNSQuery *query, const struct rb_sockaddr_sto
const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr;
cp = (const unsigned char *)&v4->sin_addr.s_addr;
sprintf(request->queryname, "%u.%u.%u.%u.in-addr.arpa", (unsigned int)(cp[3]),
rb_sprintf(request->queryname, "%u.%u.%u.%u.in-addr.arpa", (unsigned int)(cp[3]),
(unsigned int)(cp[2]), (unsigned int)(cp[1]), (unsigned int)(cp[0]));
}
#ifdef RB_IPV6

View File

@ -76,7 +76,7 @@ server_reboot(void)
execv(SPATH, (void *)myargv);
/* use this if execv of SPATH fails */
snprintf(path, sizeof(path), "%s/bin/ircd", ConfigFileEntry.dpath);
rb_snprintf(path, sizeof(path), "%s/bin/ircd", ConfigFileEntry.dpath);
execv(path, (void *)myargv);
exit(-1);

View File

@ -503,7 +503,7 @@ auth_connect_callback(rb_fde_t *F, int error, void *data)
return;
}
snprintf(authbuf, sizeof(authbuf), "%u , %u\r\n",
rb_snprintf(authbuf, sizeof(authbuf), "%u , %u\r\n",
auth->rport, auth->lport);
if(rb_write(auth->F, authbuf, strlen(authbuf)) != strlen(authbuf)) {

View File

@ -1002,6 +1002,9 @@ validate_conf(void)
cflag_orphan('M');
continue;
}
if(*dm == 'u') {
cflag_orphan('u');
}
}
}
construct_cflag_param_string();
@ -1310,13 +1313,13 @@ get_oper_name(struct Client *client_p)
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
if(MyOper(client_p)) {
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
rb_snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
client_p->name, client_p->username,
client_p->host, client_p->localClient->opername);
return buffer;
}
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
rb_snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}",
client_p->name, client_p->username,
client_p->host, client_p->servptr->name);
return buffer;
@ -1360,7 +1363,7 @@ get_user_ban_reason(struct ConfItem *aconf)
if (aconf->flags & CONF_FLAGS_TEMPORARY &&
(aconf->status == CONF_KILL || aconf->status == CONF_DLINE))
snprintf(reasonbuf, sizeof reasonbuf,
rb_snprintf(reasonbuf, sizeof reasonbuf,
"Temporary %c-line %d min. - ",
aconf->status == CONF_DLINE ? 'D' : 'K',
(int)((aconf->hold - aconf->created) / 60));
@ -1394,7 +1397,7 @@ get_printable_kline(struct Client *source_p, struct ConfItem *aconf,
if(!IsOper(source_p))
*oper_reason = NULL;
else {
snprintf(operreasonbuf, sizeof operreasonbuf, "%s%s(%s)",
rb_snprintf(operreasonbuf, sizeof operreasonbuf, "%s%s(%s)",
EmptyString(aconf->spasswd) ? "" : aconf->spasswd,
EmptyString(aconf->spasswd) ? "" : " ",
aconf->info.oper);

View File

@ -193,7 +193,7 @@ propagate_generic(struct Client *source_p, const char *command,
va_list args;
va_start(args, format);
vsnprintf(buffer, sizeof(buffer), format, args);
rb_vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
sendto_match_servs(source_p, target, cap, NOCAPS,
@ -214,7 +214,7 @@ cluster_generic(struct Client *source_p, const char *command,
rb_dlink_node *ptr;
va_start(args, format);
vsnprintf(buffer, sizeof(buffer), format, args);
rb_vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
RB_DLINK_FOREACH(ptr, cluster_conf_list.head) {

View File

@ -29,8 +29,6 @@
#include <openssl/rsa.h>
#endif
#include <rb_snprintf.h>
#include "s_serv.h"
#include "class.h"
#include "client.h"
@ -377,7 +375,7 @@ send_capabilities(struct Client *client_p, int cap_can_send)
for (cap = captab; cap->name; ++cap) {
if(cap->cap & cap_can_send) {
tl = sprintf(t, "%s ", cap->name);
tl = rb_sprintf(t, "%s ", cap->name);
t += tl;
}
}
@ -472,8 +470,8 @@ burst_modes_TS6(struct Client *client_p, struct Channel *chptr,
int mlen;
int cur_len;
cur_len = mlen = sprintf(buf, ":%s BMASK %ld %s %c :",
me.id, (long) chptr->channelts, chptr->chname, flag);
cur_len = mlen = rb_sprintf(buf, ":%s BMASK %ld %s %c :",
me.id, (long) chptr->channelts, chptr->chname, flag);
t = buf + mlen;
RB_DLINK_FOREACH(ptr, list->head) {
@ -496,7 +494,7 @@ burst_modes_TS6(struct Client *client_p, struct Channel *chptr,
t = buf + mlen;
}
sprintf(t, "%s ", banptr->banstr);
rb_sprintf(t, "%s ", banptr->banstr);
t += tlen;
cur_len += tlen;
}
@ -600,9 +598,9 @@ burst_TS6(struct Client *client_p)
if(*chptr->chname != '#')
continue;
cur_len = mlen = sprintf(buf, ":%s SJOIN %ld %s %s :", me.id,
(long) chptr->channelts, chptr->chname,
channel_modes(chptr, client_p));
cur_len = mlen = rb_sprintf(buf, ":%s SJOIN %ld %s %s :", me.id,
(long) chptr->channelts, chptr->chname,
channel_modes(chptr, client_p));
t = buf + mlen;
@ -628,8 +626,8 @@ burst_TS6(struct Client *client_p)
t = buf + mlen;
}
sprintf(t, "%s%s ", find_channel_status(msptr, 1),
use_id(msptr->client_p));
rb_sprintf(t, "%s%s ", find_channel_status(msptr, 1),
use_id(msptr->client_p));
cur_len += tlen;
t += tlen;
@ -706,7 +704,7 @@ show_capabilities(struct Client *target_p)
for (cap = captab; cap->cap; ++cap) {
if(cap->cap & target_p->serv->caps)
snprintf_append(msgbuf, sizeof(msgbuf), " %s", cap->name);
rb_snprintf_append(msgbuf, sizeof(msgbuf), " %s", cap->name);
}
return msgbuf + 1;
@ -841,7 +839,7 @@ server_estab(struct Client *client_p)
hdata.target = client_p;
call_hook(h_server_introduced, &hdata);
snprintf(note, sizeof(note), "Server: %s", client_p->name);
rb_snprintf(note, sizeof(note), "Server: %s", client_p->name);
rb_note(client_p->localClient->F, note);
/*
@ -1109,7 +1107,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
return 0;
}
snprintf(note, sizeof note, "Server: %s", server_p->name);
rb_snprintf(note, sizeof note, "Server: %s", server_p->name);
rb_note(F, note);
/* Create a local client */

View File

@ -88,7 +88,7 @@ int user_modes[256] = {
0, /* T */
0, /* U */
UMODE_NOINVITE, /* V */
0, /* W */
UMODE_WEBCLIENT, /* W */
0, /* X */
0, /* Y */
UMODE_SSLCLIENT, /* Z */
@ -295,7 +295,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
rb_strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
add_to_client_hash(source_p->name, source_p);
snprintf(note, NICKLEN + 10, "Nick: %s", source_p->name);
rb_snprintf(note, NICKLEN + 10, "Nick: %s", source_p->name);
rb_note(source_p->localClient->F, note);
}
@ -469,7 +469,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Your username is invalid. Please make sure that your username contains "
"only alphanumeric characters.");
sprintf(tmpstr2, "Invalid username [%s]", source_p->username);
rb_sprintf(tmpstr2, "Invalid username [%s]", source_p->username);
exit_client(client_p, source_p, &me, tmpstr2);
return (CLIENT_EXITED);
}
@ -1011,13 +1011,14 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
}
break;
/* we may not get these,
* but they shouldnt be in default
*/
/* we may not get these,
* but they shouldnt be in default
*/
/* can only be set on burst */
/* can only be set on burst */
case 'S':
case 'Z':
case 'W':
case ' ':
case '\n':
case '\r':
@ -1046,7 +1047,7 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
source_p->umodes &= ~UMODE_SERVNOTICE;
break;
}
/* FALLTHROUGH */
/* FALLTHROUGH */
default:
if (MyConnect(source_p) && *pm == 'Q' && !ConfigChannel.use_forward) {
badflag = YES;

View File

@ -460,7 +460,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
current_serial++;
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
if(IsServer(source_p))
@ -881,7 +881,7 @@ sendto_match_butone(struct Client *one, struct Client *source_p,
rb_linebuf_newbuf(&rb_linebuf_id);
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
if(IsServer(source_p))
@ -946,7 +946,7 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap,
rb_linebuf_newbuf(&rb_linebuf_id);
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL,
@ -1082,7 +1082,7 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
if (level & L_NETWIDE && ConfigFileEntry.global_snotices) {
/* rather a lot of copying around, oh well -- jilles */
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
rb_linebuf_putmsg(&linebuf, pattern, NULL,
":%s NOTICE * :*** Notice -- %s", me.name, buf);
@ -1094,7 +1094,7 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...)
} else if (remote_rehash_oper_p != NULL) {
/* rather a lot of copying around, oh well -- jilles */
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
rb_linebuf_putmsg(&linebuf, pattern, NULL,
":%s NOTICE * :*** Notice -- %s", me.name, buf);
@ -1252,7 +1252,7 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char
rb_linebuf_newbuf(&rb_linebuf_id);
va_start(args, pattern);
vsnprintf(buf, sizeof(buf), pattern, args);
rb_vsnprintf(buf, sizeof(buf), pattern, args);
va_end(args);
rb_linebuf_putmsg(&rb_linebuf_id, NULL, NULL, ":%s KILL %s :%s",

View File

@ -252,10 +252,10 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
last_spin = rb_current_time();
if(ssld_path == NULL) {
snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", PKGLIBEXECDIR, suffix);
rb_snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", PKGLIBEXECDIR, suffix);
if(access(fullpath, X_OK) == -1) {
snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld%s",
rb_snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld%s",
ConfigFileEntry.dpath, suffix);
if(access(fullpath, X_OK) == -1) {
ilog(L_MAIN,
@ -279,15 +279,15 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
rb_set_buffers(F1, READBUF_SIZE);
rb_set_buffers(F2, READBUF_SIZE);
snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(F2));
rb_snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(F2));
rb_setenv("CTL_FD", fdarg, 1);
if(rb_pipe(&P1, &P2, "SSL/TLS pipe") == -1) {
ilog(L_MAIN, "Unable to create ssld - rb_pipe failed: %s", strerror(errno));
return started;
}
snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(P1));
rb_snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(P1));
rb_setenv("CTL_PIPE", fdarg, 1);
snprintf(s_pid, sizeof(s_pid), "%d", (int)getpid());
rb_snprintf(s_pid, sizeof(s_pid), "%d", (int)getpid());
rb_setenv("CTL_PPID", s_pid, 1);
#ifdef _WIN32
SetHandleInformation((HANDLE) rb_get_fd(F2), HANDLE_FLAG_INHERIT, 1);
@ -404,7 +404,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
rb_free(client_p->certfp);
certfp_string = rb_malloc(RB_SSL_CERTFP_LEN * 2 + 1);
for(i = 0; i < RB_SSL_CERTFP_LEN; i++)
snprintf(certfp_string + 2 * i, 3, "%02x",
rb_snprintf(certfp_string + 2 * i, 3, "%02x",
certfp[i]);
client_p->certfp = certfp_string;
}
@ -580,7 +580,7 @@ send_new_ssl_certs_one(ssl_ctl_t * ctl, const char *ssl_cert, const char *ssl_pr
len, sizeof(tmpbuf));
return;
}
len = snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c", nul, ssl_cert, nul,
len = rb_snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c", nul, ssl_cert, nul,
ssl_private_key, nul, ssl_dh_params, nul);
ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, len);
}
@ -608,7 +608,7 @@ send_init_prng(ssl_ctl_t * ctl, prng_seed_t seedtype, const char *path)
return;
}
len = snprintf(tmpbuf, sizeof(tmpbuf), "I%c%s%c", seed, s, nul);
len = rb_snprintf(tmpbuf, sizeof(tmpbuf), "I%c%s%c", seed, s, nul);
ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, len);
}

View File

@ -190,7 +190,7 @@ const char *
isupport_intptr(const void *ptr)
{
static char buf[15];
snprintf(buf, sizeof buf, "%d", *(const int *)ptr);
rb_snprintf(buf, sizeof buf, "%d", *(const int *)ptr);
return buf;
}
@ -219,7 +219,7 @@ isupport_chanmodes(const void *ptr)
{
static char result[80];
snprintf(result, sizeof result, "%s%sb%s,k,%sl%s,%s",
rb_snprintf(result, sizeof result, "%s%sb%s,k,%sl%s,%s",
ConfigChannel.use_except ? "e" : "",
ConfigChannel.use_invex ? "I" : "",
strchr(ConfigChannel.disabledmodes, 'q') ? "" : "q",
@ -240,7 +240,7 @@ isupport_chanlimit(const void *ptr)
{
static char result[30];
snprintf(result, sizeof result, "%s:%i",
rb_snprintf(result, sizeof result, "%s:%i",
ConfigChannel.use_local_channels ? "&#" : "#",
ConfigChannel.max_chans_per_user);
return result;
@ -251,7 +251,7 @@ isupport_prefix(const void *ptr)
{
static char result[13];
snprintf(result, sizeof result, "(%s%so%sv)%s%s@%s+",
rb_snprintf(result, sizeof result, "(%s%so%sv)%s%s@%s+",
ConfigChannel.use_owner ? "y" : "",
ConfigChannel.use_admin ? "a" : "",
ConfigChannel.use_halfop ? "h" : "",
@ -266,7 +266,7 @@ isupport_maxlist(const void *ptr)
{
static char result[30];
snprintf(result, sizeof result, "bq%s%s:%i",
rb_snprintf(result, sizeof result, "bq%s%s:%i",
ConfigChannel.use_except ? "e" : "",
ConfigChannel.use_invex ? "I" : "",
ConfigChannel.max_bans);
@ -278,7 +278,7 @@ isupport_targmax(const void *ptr)
{
static char result[200];
snprintf(result, sizeof result, "NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:%d,NOTICE:%d,ACCEPT:,MONITOR:",
rb_snprintf(result, sizeof result, "NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:%d,NOTICE:%d,ACCEPT:,MONITOR:",
ConfigFileEntry.max_targets,
ConfigFileEntry.max_targets);
return result;
@ -293,7 +293,7 @@ isupport_extban(const void *ptr)
p = get_extban_string();
if (EmptyString(p))
return NULL;
snprintf(result, sizeof result, "$,%s", p);
rb_snprintf(result, sizeof result, "$,%s", p);
return result;
}
@ -305,7 +305,7 @@ isupport_ownermode(const void *ptr)
if(!ConfigChannel.use_owner)
return NULL;
snprintf(result, sizeof result, "y");
rb_snprintf(result, sizeof result, "y");
return result;
}

View File

@ -267,7 +267,7 @@ close_conn(conn_t * conn, int wait_plain, const char *fmt, ...)
rb_setselect(conn->plain_fd, RB_SELECT_READ, conn_plain_read_shutdown_cb, conn);
rb_setselect(conn->plain_fd, RB_SELECT_WRITE, NULL, NULL);
va_start(ap, fmt);
vsnprintf(reason, sizeof(reason), fmt, ap);
rb_vsnprintf(reason, sizeof(reason), fmt, ap);
va_end(ap);
buf[0] = 'D';
@ -758,7 +758,7 @@ process_stats(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
if(conn == NULL)
return;
snprintf(outstat, sizeof(outstat), "S %s %llu %llu %llu %llu", odata,
rb_snprintf(outstat, sizeof(outstat), "S %s %llu %llu %llu %llu", odata,
conn->plain_out, conn->mod_in, conn->plain_in, conn->mod_out);
conn->plain_out = 0;
conn->plain_in = 0;

66
testsuite/astyle/check_style.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash -e
set -x
cd ../..
for file in $(find **/*.c)
do
if [[ $file = "bandb/sqlite3.c" ]]
then
continue
fi
if [[ $file = "src/lex.yy.c" ]]
then
continue
fi
if [[ $file = "src/y.tab.c" ]]
then
continue
fi
if [[ $file = "tools/convertilines.c" ]]
then
continue
fi
if [[ $file = "tools/convertklines.c" ]]
then
continue
fi
if [[ $file = "tools/mkpasswd.c" ]]
then
continue
fi
if [[ $file = "tools/viconf.c" ]]
then
continue
fi
if [[ $file = "unsupported/make_override_immune.c" ]]
then
continue
fi
if [[ $file = "unsupported/m_clearchan.c" ]]
then
continue
fi
if [[ $file = "unsupported/sno_channeljoin.c" ]]
then
continue
fi
if [[ $(astyle --style=linux --mode=c -n $file 2>&1 | cut -f1 -d' ') = "Unchanged" ]]
then
echo "$file passed coding standards"
else
echo "$file is not at coding standards."
exit 1
fi
done