mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01:00
Copied libratbox and related stuff from shadowircd upstream.
This commit is contained in:
parent
dffb83aa69
commit
3202e24921
56 changed files with 3565 additions and 2392 deletions
|
@ -1,3 +1,488 @@
|
|||
androsyn 2008/11/11 00:00:12 UTC (20081111_0-26180)
|
||||
Log:
|
||||
fix build errors on os x leopard
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/11/07 02:10:19 UTC (20081107_0-26178)
|
||||
Log:
|
||||
untested fix for building on os x -- environ is not accessible to shared libraries...
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/10/26 20:59:07 UTC (20081026_2-26170)
|
||||
Log:
|
||||
add rb_basename and rb_dirname
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/rb_tools.h (File Modified)
|
||||
libratbox/trunk/src/export-syms.txt (File Modified)
|
||||
libratbox/trunk/src/tools.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/10/26 20:58:40 UTC (20081026_1-26168)
|
||||
Log:
|
||||
remove -O0 from configure.ac and configure
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/10/26 20:48:56 UTC (20081026_0-26166)
|
||||
Log:
|
||||
do an ERR_get_error() if opening the dhparams file fails
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/10/03 18:02:13 UTC (20081003_0-26126)
|
||||
Log:
|
||||
fix up the timerfd autoconf stuff a bit better
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/acinclude.m4 (File Modified)
|
||||
libratbox/trunk/configure (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/29 22:58:42 UTC (20080929_0-26122)
|
||||
Log:
|
||||
fix the timerfd_create check
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/acinclude.m4 (File Modified)
|
||||
libratbox/trunk/configure (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/20 01:27:19 UTC (20080920_1-26100)
|
||||
Log:
|
||||
properly cast a few things when doing pointer math and the like
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/20 01:05:42 UTC (20080920_0-26096)
|
||||
Log:
|
||||
make rb_close_all be a no-op on win32, its not too useful there either as windows doesn't inherit sockets/files by default
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/19 15:13:52 UTC (20080919_0-26092)
|
||||
Log:
|
||||
update indent.pro and rerun through indent
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/.indent.pro (File Modified)
|
||||
libratbox/trunk/include/arc4random.h (File Modified)
|
||||
libratbox/trunk/include/commio-int.h (File Modified)
|
||||
libratbox/trunk/include/commio-ssl.h (File Modified)
|
||||
libratbox/trunk/include/rb_balloc.h (File Modified)
|
||||
libratbox/trunk/include/rb_commio.h (File Modified)
|
||||
libratbox/trunk/include/rb_event.h (File Modified)
|
||||
libratbox/trunk/include/rb_helper.h (File Modified)
|
||||
libratbox/trunk/include/rb_linebuf.h (File Modified)
|
||||
libratbox/trunk/include/rb_memory.h (File Modified)
|
||||
libratbox/trunk/include/rb_patricia.h (File Modified)
|
||||
libratbox/trunk/include/rb_rawbuf.h (File Modified)
|
||||
libratbox/trunk/include/rb_snprintf.h (File Modified)
|
||||
libratbox/trunk/include/rb_tools.h (File Modified)
|
||||
libratbox/trunk/src/arc4random.c (File Modified)
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
libratbox/trunk/src/crypt.c (File Modified)
|
||||
libratbox/trunk/src/devpoll.c (File Modified)
|
||||
libratbox/trunk/src/epoll.c (File Modified)
|
||||
libratbox/trunk/src/event.c (File Modified)
|
||||
libratbox/trunk/src/gnutls.c (File Modified)
|
||||
libratbox/trunk/src/helper.c (File Modified)
|
||||
libratbox/trunk/src/kqueue.c (File Modified)
|
||||
libratbox/trunk/src/linebuf.c (File Modified)
|
||||
libratbox/trunk/src/nossl.c (File Modified)
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
libratbox/trunk/src/patricia.c (File Modified)
|
||||
libratbox/trunk/src/poll.c (File Modified)
|
||||
libratbox/trunk/src/ports.c (File Modified)
|
||||
libratbox/trunk/src/ratbox_lib.c (File Modified)
|
||||
libratbox/trunk/src/rawbuf.c (File Modified)
|
||||
libratbox/trunk/src/rb_memory.c (File Modified)
|
||||
libratbox/trunk/src/select.c (File Modified)
|
||||
libratbox/trunk/src/sigio.c (File Modified)
|
||||
libratbox/trunk/src/snprintf.c (File Modified)
|
||||
libratbox/trunk/src/tools.c (File Modified)
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
libratbox/trunk/src/win32.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/18 18:56:55 UTC (20080918_1-26088)
|
||||
Log:
|
||||
on win32 add randomness from RtlGenRandom if its available
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/arc4random.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/18 18:41:19 UTC (20080918_0-26086)
|
||||
Log:
|
||||
add timerfd_create support on linux with glibc 2.8
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/acinclude.m4 (File Modified)
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
libratbox/trunk/include/libratbox_config.h.in (File Modified)
|
||||
libratbox/trunk/src/Makefile.in (File Modified)
|
||||
libratbox/trunk/src/epoll.c (File Modified)
|
||||
libratbox/trunk/src/version.c.SH (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/15 15:47:42 UTC (20080915_0-26082)
|
||||
Log:
|
||||
cast svptr a bit harder to deal with 32bit systems. Also use sizeof our_signalfd_siginfo.
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/epoll.c (File Modified)
|
||||
|
||||
|
||||
jilles 2008/09/14 22:24:27 UTC (20080914_0-26078)
|
||||
Log:
|
||||
Fix infinite recursion crash on non-win32.
|
||||
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/10 01:45:22 UTC (20080910_1-26072)
|
||||
Log:
|
||||
fix a typo
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/select.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/10 00:23:41 UTC (20080910_0-26068)
|
||||
Log:
|
||||
attempt to override FD_SETSIZE for select and if rb_maxconnections is greater than FD_SETSIZE, lower rb_maxconnections. Also prefer select to win32
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
libratbox/trunk/src/select.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 22:58:11 UTC (20080909_8-26066)
|
||||
Log:
|
||||
actually make that use BIO_new_file
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 22:19:14 UTC (20080909_7-26064)
|
||||
Log:
|
||||
avoid using FILE with openssl as this causes openssl to need OPENSSL_applink on some platforms which is annoying
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 17:08:10 UTC (20080909_6-26060)
|
||||
Log:
|
||||
those symbols don't exist..oops
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/export-syms.txt (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 17:05:19 UTC (20080909_5-26058)
|
||||
Log:
|
||||
move that down a little
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 16:47:03 UTC (20080909_4-26052)
|
||||
Log:
|
||||
change ifdef WIN32 to _WIN32
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/commio-int.h (File Modified)
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
libratbox/trunk/include/rb_commio.h (File Modified)
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
libratbox/trunk/src/helper.c (File Modified)
|
||||
libratbox/trunk/src/openssl.c (File Modified)
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
libratbox/trunk/src/win32.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 16:40:19 UTC (20080909_3-26048)
|
||||
Log:
|
||||
- Implement fd passing for win32 so that ssld will work on there.
|
||||
- Add a few symbols to the library for portability issues
|
||||
Note that this commit changes the API for rb_send_fd_buf as it now
|
||||
also takes a pid option as this is needed on windows. This process
|
||||
id should be the target process. Note that unix will just ignore
|
||||
this.
|
||||
|
||||
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/Makefile.in (File Modified)
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
libratbox/trunk/include/rb_commio.h (File Modified)
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
libratbox/trunk/src/export-syms.txt (File Modified)
|
||||
libratbox/trunk/src/helper.c (File Modified)
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
libratbox/trunk/src/win32.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 16:37:30 UTC (20080909_2-26046)
|
||||
Log:
|
||||
pass libraries to LDFLAGS as well
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/Makefile.am (File Modified)
|
||||
libratbox/trunk/src/Makefile.in (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 16:36:15 UTC (20080909_1-26044)
|
||||
Log:
|
||||
make SSL_LIBS actually pass the path to the openssl libraries
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/09 14:40:41 UTC (20080909_0-26036)
|
||||
Log:
|
||||
make that an ifdef
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/08 16:54:58 UTC (20080908_1-26034)
|
||||
Log:
|
||||
add a datagram socketpair for platforms that don't have it..mostly based on what is in perl for this
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/08 16:53:53 UTC (20080908_0-26032)
|
||||
Log:
|
||||
make rb_strerror be char instead of const char
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/05 23:44:06 UTC (20080905_1-26022)
|
||||
Log:
|
||||
fix the define of the fake rb_sockaddr_storage so that m4 does not eat up our [ ]
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/05 18:19:25 UTC (20080905_0-26012)
|
||||
Log:
|
||||
revert part of r25994
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/04 21:43:03 UTC (20080904_3-26008)
|
||||
Log:
|
||||
change hard asserts to call both the soft assert code and the C library assert so that it gets in the ircd log files as well
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/04 19:32:55 UTC (20080904_2-26000)
|
||||
Log:
|
||||
If somebody really wants to do profiling work..they can change rb_close_all the hard way. Also stop doing the weird stderr.log hack in libratbox let callers deal with stderr on their own
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/04 16:08:27 UTC (20080904_1-25998)
|
||||
Log:
|
||||
add missing rb_strerror prototypes
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
libratbox/trunk/src/win32.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/04 15:06:21 UTC (20080904_0-25994)
|
||||
Log:
|
||||
some portability cleanups
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/aclocal.m4 (File Modified)
|
||||
libratbox/trunk/config.guess (File Modified)
|
||||
libratbox/trunk/config.sub (File Modified)
|
||||
libratbox/trunk/configure (File Modified)
|
||||
libratbox/trunk/configure.ac (File Modified)
|
||||
libratbox/trunk/include/arc4random.h (File Modified)
|
||||
libratbox/trunk/include/libratbox_config.h.in (File Modified)
|
||||
libratbox/trunk/include/ratbox_lib.h (File Modified)
|
||||
libratbox/trunk/ltmain.sh (File Modified)
|
||||
libratbox/trunk/src/Makefile.in (File Modified)
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
libratbox/trunk/src/export-syms.txt (File Modified)
|
||||
libratbox/trunk/src/helper.c (File Modified)
|
||||
libratbox/trunk/src/nossl.c (File Modified)
|
||||
libratbox/trunk/src/unix.c (File Modified)
|
||||
libratbox/trunk/src/win32.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/03 00:20:22 UTC (20080903_0-25992)
|
||||
Log:
|
||||
change the event stuff to just strndup the event name
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/event-int.h (File Modified)
|
||||
libratbox/trunk/src/event.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/02 21:40:49 UTC (20080902_0-25990)
|
||||
Log:
|
||||
fix makefile on bsd make
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/Makefile.am (File Modified)
|
||||
libratbox/trunk/src/Makefile.in (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 05:00:31 UTC (20080901_3-25984)
|
||||
Log:
|
||||
make extern not nested
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/ratbox_lib.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 04:59:19 UTC (20080901_2-25982)
|
||||
Log:
|
||||
and add version.c.SH too
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/version.c.SH (File Added)
|
||||
|
||||
|
||||
androsyn 2008/09/01 04:58:51 UTC (20080901_1-25980)
|
||||
Log:
|
||||
fix up version output stuff
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/Makefile.am (File Modified)
|
||||
libratbox/trunk/src/Makefile.in (File Modified)
|
||||
libratbox/trunk/src/ratbox_lib.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 04:50:17 UTC (20080901_0-25978)
|
||||
Log:
|
||||
test commit
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/README (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 03:18:34 UTC (25975)
|
||||
Log:
|
||||
remove NOBALLOC code from linebuf.c and fill in the rb_bh_usage stuff for NOBALLOC
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
libratbox/trunk/src/linebuf.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 03:12:32 UTC (25973)
|
||||
Log:
|
||||
remove an #if 0
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/event.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/09/01 03:07:46 UTC (25971)
|
||||
Log:
|
||||
change u_char to uint8_t
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/crypt.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/27 19:28:26 UTC (25963)
|
||||
Log:
|
||||
deal with rb_vsnprintf_append having a string passed to it that is longer than len, in such case we truncate the string..
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/snprintf.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/27 14:59:09 UTC (25961)
|
||||
Log:
|
||||
the way ev->name was assigned was pretty bogus and pretty much only worked because we always used strings that always were statically allocated in the executable. fix this and do it correctly
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/include/event-int.h (File Modified)
|
||||
libratbox/trunk/src/event.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/25 19:19:35 UTC (25955)
|
||||
Log:
|
||||
make that a %s instead of a %d
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/commio.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/15 16:29:35 UTC (25897)
|
||||
Log:
|
||||
order of operations in C can be a real bitch sometimes
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/14 18:23:23 UTC (25885)
|
||||
Log:
|
||||
fix block heap garbage collection properly
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/12 15:43:58 UTC (25871)
|
||||
Log:
|
||||
fix a crash in the rb_bh_gc code
|
||||
|
||||
Modified:
|
||||
libratbox/trunk/src/balloc.c (File Modified)
|
||||
|
||||
|
||||
androsyn 2008/08/06 19:51:44 UTC (25861)
|
||||
Log:
|
||||
put back in the pad to even pointer boundaries stuff
|
||||
|
|
|
@ -123,7 +123,6 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
|
@ -205,7 +204,6 @@ psdir = @psdir@
|
|||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
|
@ -8,4 +8,3 @@ This is libircd from ircd-ratbox. A few notes about this library:
|
|||
ircd stuff its fine.
|
||||
3. The helper code when transmitting data between helpers, the same 512 byte
|
||||
limit applies there as we recycle the linebuf code for this.
|
||||
|
||||
|
|
|
@ -111,3 +111,42 @@ case $rb__cv_timer_create_works in
|
|||
esac
|
||||
])
|
||||
|
||||
|
||||
|
||||
AC_DEFUN([RB_CHECK_TIMERFD_CREATE],
|
||||
[AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)],
|
||||
[rb__cv_timerfd_create_works],
|
||||
[AC_TRY_RUN([
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMERFD_H
|
||||
#include <sys/timerfd.h>
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
|
||||
if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
],
|
||||
[rb__cv_timerfd_create_works=yes],
|
||||
[rb__cv_timerfd_create_works=no])
|
||||
])
|
||||
case $rb__cv_timerfd_create_works in
|
||||
yes) AC_DEFINE([USE_TIMERFD_CREATE], 1,
|
||||
[Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);;
|
||||
esac
|
||||
])
|
||||
|
||||
|
|
30
libratbox/config.guess
vendored
30
libratbox/config.guess
vendored
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2007-07-22'
|
||||
timestamp='2008-01-23'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -56,8 +56,8 @@ version="\
|
|||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
@ -532,7 +532,7 @@ EOF
|
|||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit ;;
|
||||
*:AIX:*:[45])
|
||||
*:AIX:*:[456])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
|
@ -799,6 +799,9 @@ EOF
|
|||
EM64T | authenticamd)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
IA64)
|
||||
echo ia64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
esac ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
|
@ -833,7 +836,14 @@ EOF
|
|||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit ;;
|
||||
arm*:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_EABI__
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
|
||||
fi
|
||||
exit ;;
|
||||
avr32*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
|
@ -954,8 +964,8 @@ EOF
|
|||
x86_64:Linux:*:*)
|
||||
echo x86_64-unknown-linux-gnu
|
||||
exit ;;
|
||||
xtensa:Linux:*:*)
|
||||
echo xtensa-unknown-linux-gnu
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
|
@ -1474,9 +1484,9 @@ This script, last modified $timestamp, has failed to recognize
|
|||
the operating system you are using. It is advised that you
|
||||
download the most up to date version of the config scripts from
|
||||
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
and
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
|
||||
|
||||
If the version you run ($0) is already up to date, please
|
||||
send the following data and any information you think might be
|
||||
|
|
44
libratbox/config.sub
vendored
44
libratbox/config.sub
vendored
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2007-06-28'
|
||||
timestamp='2008-01-16'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
|
@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
|
|||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
@ -369,10 +369,14 @@ case $basic_machine in
|
|||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
|
||||
| xstormy16-* | xtensa-* \
|
||||
| xstormy16-* | xtensa*-* \
|
||||
| ymp-* \
|
||||
| z8k-*)
|
||||
;;
|
||||
# Recognize the basic CPU types without company name, with glob match.
|
||||
xtensa*)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
386bsd)
|
||||
|
@ -443,6 +447,14 @@ case $basic_machine in
|
|||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
blackfin)
|
||||
basic_machine=bfin-unknown
|
||||
os=-linux
|
||||
;;
|
||||
blackfin-*)
|
||||
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
c90)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
|
@ -668,6 +680,14 @@ case $basic_machine in
|
|||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m68knommu)
|
||||
basic_machine=m68k-unknown
|
||||
os=-linux
|
||||
;;
|
||||
m68knommu-*)
|
||||
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
|
@ -813,6 +833,14 @@ case $basic_machine in
|
|||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
parisc)
|
||||
basic_machine=hppa-unknown
|
||||
os=-linux
|
||||
;;
|
||||
parisc-*)
|
||||
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
|
@ -1021,6 +1049,10 @@ case $basic_machine in
|
|||
basic_machine=tic6x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tile*)
|
||||
basic_machine=tile-unknown
|
||||
os=-linux-gnu
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
|
|
502
libratbox/configure
vendored
502
libratbox/configure
vendored
|
@ -2,7 +2,7 @@
|
|||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.61 for libratbox devel.
|
||||
#
|
||||
# $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $
|
||||
# $Id: configure.ac 26168 2008-10-26 20:58:40Z androsyn $
|
||||
#
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
@ -855,9 +855,6 @@ RM
|
|||
CP
|
||||
MV
|
||||
LN
|
||||
AR
|
||||
LD
|
||||
RANLIB
|
||||
TOUCH
|
||||
build
|
||||
build_cpu
|
||||
|
@ -869,6 +866,8 @@ host_vendor
|
|||
host_os
|
||||
LN_S
|
||||
ECHO
|
||||
AR
|
||||
RANLIB
|
||||
DSYMUTIL
|
||||
NMEDIT
|
||||
CPP
|
||||
|
@ -883,7 +882,6 @@ F77
|
|||
FFLAGS
|
||||
ac_ct_F77
|
||||
LIBTOOL
|
||||
subdirs
|
||||
MINGW_TRUE
|
||||
MINGW_FALSE
|
||||
NEED_CRYPT_TRUE
|
||||
|
@ -919,7 +917,7 @@ FFLAGS
|
|||
PKG_CONFIG
|
||||
GNUTLS_CFLAGS
|
||||
GNUTLS_LIBS'
|
||||
ac_subdirs_all='libltdl'
|
||||
|
||||
|
||||
# Initialize some variables set by options.
|
||||
ac_init_help=
|
||||
|
@ -1616,7 +1614,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
|||
This configure script is free software; the Free Software Foundation
|
||||
gives unlimited permission to copy, distribute and modify it.
|
||||
|
||||
$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $
|
||||
$Id: configure.ac 26168 2008-10-26 20:58:40Z androsyn $
|
||||
_ACEOF
|
||||
exit
|
||||
fi
|
||||
|
@ -4853,126 +4851,6 @@ echo "${ECHO_T}no" >&6; }
|
|||
fi
|
||||
|
||||
|
||||
# Extract the first word of "ar", so it can be a program name with args.
|
||||
set dummy ar; ac_word=$2
|
||||
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_path_AR+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
case $AR in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_AR="$AR" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext"
|
||||
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AR=$ac_cv_path_AR
|
||||
if test -n "$AR"; then
|
||||
{ echo "$as_me:$LINENO: result: $AR" >&5
|
||||
echo "${ECHO_T}$AR" >&6; }
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
# Extract the first word of "ld", so it can be a program name with args.
|
||||
set dummy ld; ac_word=$2
|
||||
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_path_LD+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
case $LD in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_path_LD="$as_dir/$ac_word$ac_exec_ext"
|
||||
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
LD=$ac_cv_path_LD
|
||||
if test -n "$LD"; then
|
||||
{ echo "$as_me:$LINENO: result: $LD" >&5
|
||||
echo "${ECHO_T}$LD" >&6; }
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_path_RANLIB+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
case $RANLIB in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_RANLIB="$RANLIB" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_path_RANLIB="$as_dir/$ac_word$ac_exec_ext"
|
||||
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
RANLIB=$ac_cv_path_RANLIB
|
||||
if test -n "$RANLIB"; then
|
||||
{ echo "$as_me:$LINENO: result: $RANLIB" >&5
|
||||
echo "${ECHO_T}$RANLIB" >&6; }
|
||||
else
|
||||
{ echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
# Extract the first word of "touch", so it can be a program name with args.
|
||||
set dummy touch; ac_word=$2
|
||||
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
|
@ -5617,7 +5495,7 @@ ia64-*-hpux*)
|
|||
;;
|
||||
*-*-irix6*)
|
||||
# Find out which ABI we are using.
|
||||
echo '#line 5620 "configure"' > conftest.$ac_ext
|
||||
echo '#line 5498 "configure"' > conftest.$ac_ext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>&5
|
||||
ac_status=$?
|
||||
|
@ -8669,11 +8547,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:8672: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:8550: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:8676: \$? = $ac_status" >&5
|
||||
echo "$as_me:8554: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -8959,11 +8837,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:8962: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:8840: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:8966: \$? = $ac_status" >&5
|
||||
echo "$as_me:8844: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -9063,11 +8941,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:9066: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:8944: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
echo "$as_me:9070: \$? = $ac_status" >&5
|
||||
echo "$as_me:8948: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
|
@ -11440,7 +11318,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 11443 "configure"
|
||||
#line 11321 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -11540,7 +11418,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 11543 "configure"
|
||||
#line 11421 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -13941,11 +13819,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:13944: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:13822: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:13948: \$? = $ac_status" >&5
|
||||
echo "$as_me:13826: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -14045,11 +13923,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:14048: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:13926: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
echo "$as_me:14052: \$? = $ac_status" >&5
|
||||
echo "$as_me:13930: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
|
@ -15643,11 +15521,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:15646: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:15524: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:15650: \$? = $ac_status" >&5
|
||||
echo "$as_me:15528: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -15747,11 +15625,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:15750: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:15628: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
echo "$as_me:15754: \$? = $ac_status" >&5
|
||||
echo "$as_me:15632: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
|
@ -17967,11 +17845,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:17970: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:17848: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:17974: \$? = $ac_status" >&5
|
||||
echo "$as_me:17852: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -18257,11 +18135,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:18260: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:18138: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:18264: \$? = $ac_status" >&5
|
||||
echo "$as_me:18142: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
|
@ -18361,11 +18239,11 @@ else
|
|||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
(eval echo "\"\$as_me:18364: $lt_compile\"" >&5)
|
||||
(eval echo "\"\$as_me:18242: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
echo "$as_me:18368: \$? = $ac_status" >&5
|
||||
echo "$as_me:18246: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
|
@ -21054,10 +20932,6 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
|||
|
||||
LIBTOOL="$LIBTOOL --silent"
|
||||
|
||||
subdirs="$subdirs libltdl"
|
||||
|
||||
|
||||
|
||||
case "$host_os" in
|
||||
*cygwin*)
|
||||
|
||||
|
@ -21350,6 +21224,16 @@ echo "$as_me: error: ** MinGW and no winsock2.h. I give up." >&2;}
|
|||
fi
|
||||
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
_ACEOF
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_WINSOCK_H 1
|
||||
_ACEOF
|
||||
|
||||
LIBS="$LIBS -lws2_32 -liphlpapi"
|
||||
is_mingw="yes"
|
||||
;;
|
||||
|
@ -21374,7 +21258,7 @@ fi
|
|||
|
||||
|
||||
# backwards support for IRC_CFLAGS
|
||||
CFLAGS="$IRC_CFLAGS $CFLAGS -O0 -Wall"
|
||||
CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
|
||||
|
||||
if test "$libexecdir" = '${exec_prefix}/libexec' &&
|
||||
test "$localstatedir" = '${prefix}/var'; then
|
||||
|
@ -21805,7 +21689,8 @@ fi
|
|||
|
||||
|
||||
|
||||
for ac_header in crypt.h unistd.h sys/socket.h sys/stat.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h sys/uio.h spawn.h sys/poll.h sys/epoll.h sys/select.h sys/devpoll.h sys/event.h port.h signal.h sys/signalfd.h
|
||||
|
||||
for ac_header in crypt.h unistd.h sys/socket.h sys/stat.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h sys/uio.h spawn.h sys/poll.h sys/epoll.h sys/select.h sys/devpoll.h sys/event.h port.h signal.h sys/signalfd.h sys/timerfd.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
|
||||
|
@ -22293,9 +22178,15 @@ cat confdefs.h >>conftest.$ac_ext
|
|||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
int getpeername (int, $arg2 *, $t *);
|
||||
|
||||
int
|
||||
|
@ -22342,9 +22233,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|||
done
|
||||
|
||||
if test "x$rb_socklen_t" = x; then
|
||||
{ { echo "$as_me:$LINENO: error: Cannot find a type to use in place of socklen_t" >&5
|
||||
echo "$as_me: error: Cannot find a type to use in place of socklen_t" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
{ echo "$as_me:$LINENO: WARNING: Cannot find a type to use in place of socklen_t using int" >&5
|
||||
echo "$as_me: WARNING: Cannot find a type to use in place of socklen_t using int" >&2;}
|
||||
rb_socklen_t=int
|
||||
fi
|
||||
|
||||
fi
|
||||
|
@ -22936,7 +22827,8 @@ fi
|
|||
|
||||
|
||||
|
||||
for ac_func in socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage
|
||||
|
||||
for ac_func in socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage timerfd_create
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
|
@ -23294,6 +23186,95 @@ _ACEOF
|
|||
;;
|
||||
esac
|
||||
|
||||
{ echo "$as_me:$LINENO: checking for a working timerfd_create(CLOCK_REALTIME)" >&5
|
||||
echo $ECHO_N "checking for a working timerfd_create(CLOCK_REALTIME)... $ECHO_C" >&6; }
|
||||
if test "${rb__cv_timerfd_create_works+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then
|
||||
{ { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
|
||||
See \`config.log' for more details." >&5
|
||||
echo "$as_me: error: cannot run test program while cross compiling
|
||||
See \`config.log' for more details." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMERFD_H
|
||||
#include <sys/timerfd.h>
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
|
||||
if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
rm -f conftest$ac_exeext
|
||||
if { (ac_try="$ac_link"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_link") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
rb__cv_timerfd_create_works=yes
|
||||
else
|
||||
echo "$as_me: program exited with status $ac_status" >&5
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
( exit $ac_status )
|
||||
rb__cv_timerfd_create_works=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
|
||||
|
||||
|
||||
fi
|
||||
{ echo "$as_me:$LINENO: result: $rb__cv_timerfd_create_works" >&5
|
||||
echo "${ECHO_T}$rb__cv_timerfd_create_works" >&6; }
|
||||
case $rb__cv_timerfd_create_works in
|
||||
yes)
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define USE_TIMERFD_CREATE 1
|
||||
_ACEOF
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
|
||||
# for constant arguments. Useless!
|
||||
|
@ -24783,7 +24764,6 @@ fi
|
|||
|
||||
fi
|
||||
|
||||
|
||||
if test "$cf_enable_openssl" != no; then
|
||||
CPPFLAGS="$CPPFLAGS $SSL_LIBS"
|
||||
{ echo "$as_me:$LINENO: checking for SSL_read in -lssl" >&5
|
||||
|
@ -24848,7 +24828,7 @@ fi
|
|||
{ echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_SSL_read" >&5
|
||||
echo "${ECHO_T}$ac_cv_lib_ssl_SSL_read" >&6; }
|
||||
if test $ac_cv_lib_ssl_SSL_read = yes; then
|
||||
SSL_LIBS="-lssl -lcrypto"
|
||||
SSL_LIBS="$SSL_LIBS -lssl -lcrypto"
|
||||
else
|
||||
cf_enable_openssl=no
|
||||
fi
|
||||
|
@ -26054,9 +26034,6 @@ RM!$RM$ac_delim
|
|||
CP!$CP$ac_delim
|
||||
MV!$MV$ac_delim
|
||||
LN!$LN$ac_delim
|
||||
AR!$AR$ac_delim
|
||||
LD!$LD$ac_delim
|
||||
RANLIB!$RANLIB$ac_delim
|
||||
TOUCH!$TOUCH$ac_delim
|
||||
build!$build$ac_delim
|
||||
build_cpu!$build_cpu$ac_delim
|
||||
|
@ -26065,6 +26042,9 @@ build_os!$build_os$ac_delim
|
|||
host!$host$ac_delim
|
||||
host_cpu!$host_cpu$ac_delim
|
||||
host_vendor!$host_vendor$ac_delim
|
||||
host_os!$host_os$ac_delim
|
||||
LN_S!$LN_S$ac_delim
|
||||
ECHO!$ECHO$ac_delim
|
||||
_ACEOF
|
||||
|
||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
|
||||
|
@ -26106,9 +26086,8 @@ _ACEOF
|
|||
ac_delim='%!_!# '
|
||||
for ac_last_try in false false false false false :; do
|
||||
cat >conf$$subs.sed <<_ACEOF
|
||||
host_os!$host_os$ac_delim
|
||||
LN_S!$LN_S$ac_delim
|
||||
ECHO!$ECHO$ac_delim
|
||||
AR!$AR$ac_delim
|
||||
RANLIB!$RANLIB$ac_delim
|
||||
DSYMUTIL!$DSYMUTIL$ac_delim
|
||||
NMEDIT!$NMEDIT$ac_delim
|
||||
CPP!$CPP$ac_delim
|
||||
|
@ -26123,7 +26102,6 @@ F77!$F77$ac_delim
|
|||
FFLAGS!$FFLAGS$ac_delim
|
||||
ac_ct_F77!$ac_ct_F77$ac_delim
|
||||
LIBTOOL!$LIBTOOL$ac_delim
|
||||
subdirs!$subdirs$ac_delim
|
||||
MINGW_TRUE!$MINGW_TRUE$ac_delim
|
||||
MINGW_FALSE!$MINGW_FALSE$ac_delim
|
||||
NEED_CRYPT_TRUE!$NEED_CRYPT_TRUE$ac_delim
|
||||
|
@ -26142,7 +26120,7 @@ LIBOBJS!$LIBOBJS$ac_delim
|
|||
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
||||
_ACEOF
|
||||
|
||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 34; then
|
||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 32; then
|
||||
break
|
||||
elif $ac_last_try; then
|
||||
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
||||
|
@ -26802,7 +26780,7 @@ fi
|
|||
if test "x$rb_sockaddr_storage" = "xyes"; then
|
||||
echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
|
||||
else
|
||||
echo 'struct rb_sockaddr_storage { uint8_t _padding128; };' >> $outfile
|
||||
echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile
|
||||
fi
|
||||
|
||||
cat >> $outfile <<\_______EOF
|
||||
|
@ -26850,186 +26828,6 @@ if test "$no_create" != yes; then
|
|||
$ac_cs_success || { (exit 1); exit 1; }
|
||||
fi
|
||||
|
||||
#
|
||||
# CONFIG_SUBDIRS section.
|
||||
#
|
||||
if test "$no_recursion" != yes; then
|
||||
|
||||
# Remove --cache-file and --srcdir arguments so they do not pile up.
|
||||
ac_sub_configure_args=
|
||||
ac_prev=
|
||||
eval "set x $ac_configure_args"
|
||||
shift
|
||||
for ac_arg
|
||||
do
|
||||
if test -n "$ac_prev"; then
|
||||
ac_prev=
|
||||
continue
|
||||
fi
|
||||
case $ac_arg in
|
||||
-cache-file | --cache-file | --cache-fil | --cache-fi \
|
||||
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
|
||||
ac_prev=cache_file ;;
|
||||
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
|
||||
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
|
||||
| --c=*)
|
||||
;;
|
||||
--config-cache | -C)
|
||||
;;
|
||||
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
|
||||
ac_prev=srcdir ;;
|
||||
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
|
||||
;;
|
||||
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
|
||||
ac_prev=prefix ;;
|
||||
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
|
||||
;;
|
||||
*)
|
||||
case $ac_arg in
|
||||
*\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
|
||||
esac
|
||||
ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Always prepend --prefix to ensure using the same prefix
|
||||
# in subdir configurations.
|
||||
ac_arg="--prefix=$prefix"
|
||||
case $ac_arg in
|
||||
*\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
|
||||
esac
|
||||
ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
|
||||
|
||||
# Pass --silent
|
||||
if test "$silent" = yes; then
|
||||
ac_sub_configure_args="--silent $ac_sub_configure_args"
|
||||
fi
|
||||
|
||||
ac_popdir=`pwd`
|
||||
for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
|
||||
|
||||
# Do not complain, so a configure script can configure whichever
|
||||
# parts of a large source tree are present.
|
||||
test -d "$srcdir/$ac_dir" || continue
|
||||
|
||||
ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
|
||||
echo "$as_me:$LINENO: $ac_msg" >&5
|
||||
echo "$ac_msg" >&6
|
||||
{ as_dir="$ac_dir"
|
||||
case $as_dir in #(
|
||||
-*) as_dir=./$as_dir;;
|
||||
esac
|
||||
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
|
||||
as_dirs=
|
||||
while :; do
|
||||
case $as_dir in #(
|
||||
*\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
|
||||
*) as_qdir=$as_dir;;
|
||||
esac
|
||||
as_dirs="'$as_qdir' $as_dirs"
|
||||
as_dir=`$as_dirname -- "$as_dir" ||
|
||||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$as_dir" : 'X\(//\)[^/]' \| \
|
||||
X"$as_dir" : 'X\(//\)$' \| \
|
||||
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$as_dir" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'`
|
||||
test -d "$as_dir" && break
|
||||
done
|
||||
test -z "$as_dirs" || eval "mkdir $as_dirs"
|
||||
} || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
|
||||
echo "$as_me: error: cannot create directory $as_dir" >&2;}
|
||||
{ (exit 1); exit 1; }; }; }
|
||||
ac_builddir=.
|
||||
|
||||
case "$ac_dir" in
|
||||
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
|
||||
*)
|
||||
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
|
||||
# A ".." for each directory in $ac_dir_suffix.
|
||||
ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
|
||||
case $ac_top_builddir_sub in
|
||||
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
|
||||
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
|
||||
esac ;;
|
||||
esac
|
||||
ac_abs_top_builddir=$ac_pwd
|
||||
ac_abs_builddir=$ac_pwd$ac_dir_suffix
|
||||
# for backward compatibility:
|
||||
ac_top_builddir=$ac_top_build_prefix
|
||||
|
||||
case $srcdir in
|
||||
.) # We are building in place.
|
||||
ac_srcdir=.
|
||||
ac_top_srcdir=$ac_top_builddir_sub
|
||||
ac_abs_top_srcdir=$ac_pwd ;;
|
||||
[\\/]* | ?:[\\/]* ) # Absolute name.
|
||||
ac_srcdir=$srcdir$ac_dir_suffix;
|
||||
ac_top_srcdir=$srcdir
|
||||
ac_abs_top_srcdir=$srcdir ;;
|
||||
*) # Relative name.
|
||||
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
|
||||
ac_top_srcdir=$ac_top_build_prefix$srcdir
|
||||
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
|
||||
esac
|
||||
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
|
||||
|
||||
|
||||
cd "$ac_dir"
|
||||
|
||||
# Check for guested configure; otherwise get Cygnus style configure.
|
||||
if test -f "$ac_srcdir/configure.gnu"; then
|
||||
ac_sub_configure=$ac_srcdir/configure.gnu
|
||||
elif test -f "$ac_srcdir/configure"; then
|
||||
ac_sub_configure=$ac_srcdir/configure
|
||||
elif test -f "$ac_srcdir/configure.in"; then
|
||||
# This should be Cygnus configure.
|
||||
ac_sub_configure=$ac_aux_dir/configure
|
||||
else
|
||||
{ echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5
|
||||
echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;}
|
||||
ac_sub_configure=
|
||||
fi
|
||||
|
||||
# The recursion is here.
|
||||
if test -n "$ac_sub_configure"; then
|
||||
# Make the cache file name correct relative to the subdirectory.
|
||||
case $cache_file in
|
||||
[\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
|
||||
*) # Relative name.
|
||||
ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
|
||||
esac
|
||||
|
||||
{ echo "$as_me:$LINENO: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
|
||||
echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
|
||||
# The eval makes quoting arguments work.
|
||||
eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
|
||||
--cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
|
||||
{ { echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5
|
||||
echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
|
||||
cd "$ac_popdir"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
dnl $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $
|
||||
dnl $Id: configure.ac 26168 2008-10-26 20:58:40Z androsyn $
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
dnl TODO: clean up all the OpenSSL and shared module checking stuff;
|
||||
dnl the most major changes have already been made and it looks like
|
||||
dnl said functions need to be just about as complex as they already are.
|
||||
|
||||
AC_PREREQ(2.60)
|
||||
AC_PREREQ(2.61)
|
||||
AUTOMAKE_OPTIONS = 1.10
|
||||
dnl Sneaky way to get an Id tag into the configure script
|
||||
AC_COPYRIGHT([$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $])
|
||||
AC_COPYRIGHT([$Id: configure.ac 26168 2008-10-26 20:58:40Z androsyn $])
|
||||
AC_INIT([libratbox],[devel])
|
||||
AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION, -)
|
||||
|
||||
|
@ -50,9 +50,6 @@ AC_PATH_PROG(RM, rm)
|
|||
AC_PATH_PROG(CP, cp)
|
||||
AC_PATH_PROG(MV, mv)
|
||||
AC_PATH_PROG(LN, ln)
|
||||
AC_PATH_PROG(AR, ar)
|
||||
AC_PATH_PROG(LD, ld)
|
||||
AC_PATH_PROG(RANLIB, ranlib)
|
||||
AC_PATH_PROG(TOUCH, touch)
|
||||
AC_LANG(C)
|
||||
|
||||
|
@ -60,9 +57,6 @@ AC_PROG_LIBTOOL
|
|||
|
||||
LIBTOOL="$LIBTOOL --silent"
|
||||
|
||||
AC_CONFIG_SUBDIRS(libltdl)
|
||||
|
||||
|
||||
case "$host_os" in
|
||||
*cygwin*)
|
||||
AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
|
||||
|
@ -73,6 +67,8 @@ case "$host_os" in
|
|||
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
|
||||
AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
|
||||
AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
|
||||
AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, [Have WINSOCK2_H])
|
||||
AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, [Have WINSOCK_H])
|
||||
LIBS="$LIBS -lws2_32 -liphlpapi"
|
||||
is_mingw="yes"
|
||||
;;
|
||||
|
@ -90,7 +86,7 @@ AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
|
|||
|
||||
|
||||
# backwards support for IRC_CFLAGS
|
||||
CFLAGS="$IRC_CFLAGS $CFLAGS -O0 -Wall"
|
||||
CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
|
||||
|
||||
dnl use directory structure of cached as default (hack)
|
||||
if test "$libexecdir" = '${exec_prefix}/libexec' &&
|
||||
|
@ -108,7 +104,7 @@ AC_TYPE_UID_T
|
|||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_CHECK_HEADERS([crypt.h unistd.h sys/socket.h sys/stat.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h sys/uio.h spawn.h sys/poll.h sys/epoll.h sys/select.h sys/devpoll.h sys/event.h port.h signal.h sys/signalfd.h])
|
||||
AC_CHECK_HEADERS([crypt.h unistd.h sys/socket.h sys/stat.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h sys/uio.h spawn.h sys/poll.h sys/epoll.h sys/select.h sys/devpoll.h sys/event.h port.h signal.h sys/signalfd.h sys/timerfd.h])
|
||||
AC_HEADER_TIME
|
||||
|
||||
dnl Networking Functions
|
||||
|
@ -140,9 +136,15 @@ AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[
|
|||
for arg2 in "struct sockaddr" void; do
|
||||
for t in int size_t unsigned long "unsigned long"; do
|
||||
AC_TRY_COMPILE([
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
int getpeername (int, $arg2 *, $t *);
|
||||
],[
|
||||
$t len;
|
||||
|
@ -155,7 +157,8 @@ getpeername(0,0,&len);
|
|||
done
|
||||
|
||||
if test "x$rb_socklen_t" = x; then
|
||||
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
||||
AC_MSG_WARN([Cannot find a type to use in place of socklen_t using int])
|
||||
rb_socklen_t=int
|
||||
fi
|
||||
])
|
||||
AC_MSG_RESULT($rb_socklen_t)],
|
||||
|
@ -224,11 +227,12 @@ AC_CHECK_TYPE([sa_family_t], [],
|
|||
|
||||
|
||||
dnl check for various functions...
|
||||
AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage])
|
||||
AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage timerfd_create])
|
||||
|
||||
AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
|
||||
AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
|
||||
RB_CHECK_TIMER_CREATE
|
||||
RB_CHECK_TIMERFD_CREATE
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_VFORK
|
||||
|
@ -343,11 +347,10 @@ if test "$cf_enable_openssl" != no; then
|
|||
[cf_enable_openssl=no])
|
||||
fi
|
||||
|
||||
|
||||
if test "$cf_enable_openssl" != no; then
|
||||
CPPFLAGS="$CPPFLAGS $SSL_LIBS"
|
||||
AC_CHECK_LIB(ssl, SSL_read,
|
||||
[SSL_LIBS="-lssl -lcrypto"],
|
||||
[SSL_LIBS="$SSL_LIBS -lssl -lcrypto"],
|
||||
[cf_enable_openssl=no], [-lcrypto])
|
||||
fi
|
||||
|
||||
|
@ -557,7 +560,7 @@ fi
|
|||
if test "x$rb_sockaddr_storage" = "xyes"; then
|
||||
echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
|
||||
else
|
||||
echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile
|
||||
echo 'struct rb_sockaddr_storage { uint8_t _padding[[128]]; };' >> $outfile
|
||||
fi
|
||||
|
||||
cat >> $outfile <<\_______EOF
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#define FD_DESC_SZ 128 /* hostlen + comment */
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0)
|
||||
#else
|
||||
#define rb_get_errno()
|
||||
|
@ -41,31 +41,31 @@
|
|||
#define rb_hash_fd(x) ((x ^ (x >> RB_FD_HASH_BITS) ^ (x >> (RB_FD_HASH_BITS * 2))) & RB_FD_HASH_MASK)
|
||||
|
||||
#ifdef HAVE_WRITEV
|
||||
#ifndef UIO_MAXIOV
|
||||
# if defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
#ifndef UIO_MAXIOV
|
||||
# if defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||
/* FreeBSD 4.7 defines it in sys/uio.h only if _KERNEL is specified */
|
||||
# define RB_UIO_MAXIOV 1024
|
||||
# elif defined(__sgi)
|
||||
# define RB_UIO_MAXIOV 1024
|
||||
# elif defined(__sgi)
|
||||
/* IRIX 6.5 has sysconf(_SC_IOV_MAX) which might return 512 or bigger */
|
||||
# define RB_UIO_MAXIOV 512
|
||||
# elif defined(__sun)
|
||||
# define RB_UIO_MAXIOV 512
|
||||
# elif defined(__sun)
|
||||
/* Solaris (and SunOS?) defines IOV_MAX instead */
|
||||
# ifndef IOV_MAX
|
||||
# define RB_UIO_MAXIOV 16
|
||||
# else
|
||||
# define RB_UIO_MAXIOV IOV_MAX
|
||||
# endif
|
||||
# ifndef IOV_MAX
|
||||
# define RB_UIO_MAXIOV 16
|
||||
# else
|
||||
# define RB_UIO_MAXIOV IOV_MAX
|
||||
# endif
|
||||
|
||||
# elif defined(IOV_MAX)
|
||||
# define RB_UIO_MAXIOV IOV_MAX
|
||||
# else
|
||||
# define RB_UIO_MAXIOV 16
|
||||
# endif
|
||||
#else
|
||||
#define RB_UIO_MAXIOV UIO_MAXIOV
|
||||
#endif
|
||||
# elif defined(IOV_MAX)
|
||||
# define RB_UIO_MAXIOV IOV_MAX
|
||||
# else
|
||||
# define RB_UIO_MAXIOV 16
|
||||
# endif
|
||||
#else
|
||||
#define RB_UIO_MAXIOV 16
|
||||
#define RB_UIO_MAXIOV UIO_MAXIOV
|
||||
#endif
|
||||
#else
|
||||
#define RB_UIO_MAXIOV 16
|
||||
#endif
|
||||
struct conndata
|
||||
{
|
||||
|
@ -119,10 +119,11 @@ struct _fde
|
|||
unsigned long ssl_errno;
|
||||
};
|
||||
|
||||
typedef void (*comm_event_cb_t)(void *);
|
||||
typedef void (*comm_event_cb_t) (void *);
|
||||
|
||||
#ifdef USE_TIMER_CREATE
|
||||
typedef struct timer_data {
|
||||
typedef struct timer_data
|
||||
{
|
||||
timer_t td_timer_id;
|
||||
comm_event_cb_t td_cb;
|
||||
void *td_udata;
|
||||
|
@ -230,4 +231,3 @@ void rb_setselect_win32(rb_fde_t *F, unsigned int type, PF * handler, void *clie
|
|||
int rb_init_netio_win32(void);
|
||||
int rb_select_win32(long);
|
||||
int rb_setup_fd_win32(rb_fde_t *F);
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@ int rb_init_prng(const char *path, prng_seed_t seed_type);
|
|||
|
||||
int rb_get_random(void *buf, size_t length);
|
||||
const char *rb_get_ssl_strerror(rb_fde_t *F);
|
||||
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout);
|
||||
void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout);
|
||||
void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout);
|
||||
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout);
|
||||
void rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout);
|
||||
void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen,
|
||||
CNCB * callback, void *data, int timeout);
|
||||
void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen);
|
||||
void rb_ssl_shutdown(rb_fde_t *F);
|
||||
ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count);
|
||||
ssize_t rb_ssl_write(rb_fde_t *F, const void *buf, size_t count);
|
||||
|
||||
|
||||
|
|
|
@ -20,16 +20,15 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: event-int.h 24840 2008-01-03 19:42:17Z androsyn $
|
||||
* $Id: event-int.h 25992 2008-09-03 00:20:22Z androsyn $
|
||||
*/
|
||||
|
||||
|
||||
struct ev_entry
|
||||
{
|
||||
rb_dlink_node node;
|
||||
EVH *func;
|
||||
void *arg;
|
||||
const char *name;
|
||||
char *name;
|
||||
time_t frequency;
|
||||
time_t when;
|
||||
void *data;
|
||||
|
|
|
@ -165,6 +165,9 @@
|
|||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/timerfd.h> header file. */
|
||||
#undef HAVE_SYS_TIMERFD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
|
@ -174,6 +177,9 @@
|
|||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#undef HAVE_SYS_UIO_H
|
||||
|
||||
/* Define to 1 if you have the `timerfd_create' function. */
|
||||
#undef HAVE_TIMERFD_CREATE
|
||||
|
||||
/* Define if you have timer_create */
|
||||
#undef HAVE_TIMER_CREATE
|
||||
|
||||
|
@ -195,6 +201,12 @@
|
|||
/* Define to 1 if you are on windows */
|
||||
#undef HAVE_WIN32
|
||||
|
||||
/* Have WINSOCK2_H */
|
||||
#undef HAVE_WINSOCK2_H
|
||||
|
||||
/* Have WINSOCK_H */
|
||||
#undef HAVE_WINSOCK_H
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
|
@ -257,6 +269,9 @@
|
|||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...) */
|
||||
#undef USE_TIMERFD_CREATE
|
||||
|
||||
/* Define to 1 if we can use timer_create(CLOCK_REALTIME,...) */
|
||||
#undef USE_TIMER_CREATE
|
||||
|
||||
|
|
0
libratbox/include/libratbox_config.h_vms
Executable file → Normal file
0
libratbox/include/libratbox_config.h_vms
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ratbox_lib.h 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: ratbox_lib.h 26052 2008-09-09 16:47:03Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -68,20 +68,19 @@ char *alloca();
|
|||
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 128
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef strerror
|
||||
#undef strerror
|
||||
#endif
|
||||
|
||||
#define strerror(x) wsock_strerror(x)
|
||||
const char *wsock_strerror(int error);
|
||||
#define strerror(x) rb_strerror(x)
|
||||
char *rb_strerror(int error);
|
||||
|
||||
|
||||
#define ENOBUFS WSAENOBUFS
|
||||
|
@ -96,18 +95,13 @@ const char *wsock_strerror(int error);
|
|||
#define pipe(x) _pipe(x, 1024, O_BINARY)
|
||||
#define ioctl(x,y,z) ioctlsocket(x,y, (u_long *)z)
|
||||
|
||||
int setenv(const char *, const char *, int);
|
||||
int kill(int pid, int sig);
|
||||
#define WNOHANG 1
|
||||
pid_t waitpid(pid_t pid, int *status, int options);
|
||||
pid_t getpid(void);
|
||||
unsigned int geteuid(void);
|
||||
|
||||
#ifndef SIGKILL
|
||||
#define SIGKILL SIGTERM
|
||||
#endif
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
|
@ -115,9 +109,8 @@ unsigned int geteuid(void);
|
|||
#define HOSTIPLEN 53
|
||||
#endif
|
||||
|
||||
#ifdef SOFT_ASSERT
|
||||
#ifdef __GNUC__
|
||||
#define lrb_assert(expr) do \
|
||||
#define slrb_assert(expr) do \
|
||||
if(rb_unlikely(!(expr))) { \
|
||||
rb_lib_log( \
|
||||
"file: %s line: %d (%s): Assertion failed: (%s)", \
|
||||
|
@ -125,7 +118,7 @@ unsigned int geteuid(void);
|
|||
} \
|
||||
while(0)
|
||||
#else
|
||||
#define lrb_assert(expr) do \
|
||||
#define slrb_assert(expr) do \
|
||||
if(rb_unlikely(!(expr))) { \
|
||||
rb_lib_log(L_MAIN, \
|
||||
"file: %s line: %d: Assertion failed: (%s)", \
|
||||
|
@ -133,16 +126,19 @@ unsigned int geteuid(void);
|
|||
} \
|
||||
while(0)
|
||||
#endif
|
||||
|
||||
#ifdef SOFT_ASSERT
|
||||
#define lrb_assert(expr) slrb_assert(expr)
|
||||
#else
|
||||
#define lrb_assert(expr) assert(expr)
|
||||
#define lrb_assert(expr) do { slrb_assert(expr); assert(expr); } while(0)
|
||||
#endif
|
||||
|
||||
#ifdef RB_SOCKADDR_HAS_SA_LEN
|
||||
#define ss_len sa_len
|
||||
#endif
|
||||
|
||||
#define GET_SS_FAMILY(x) (((struct sockaddr *)(x))->sa_family)
|
||||
|
||||
#define GET_SS_FAMILY(x) (((const struct sockaddr *)(x))->sa_family)
|
||||
#define SET_SS_FAMILY(x, y) ((((struct sockaddr *)(x))->sa_family) = y)
|
||||
#ifdef RB_SOCKADDR_HAS_SA_LEN
|
||||
#define SET_SS_LEN(x, y) do { \
|
||||
struct sockaddr *storage; \
|
||||
|
@ -201,8 +197,15 @@ char *rb_crypt(const char *, const char *);
|
|||
|
||||
unsigned char *rb_base64_encode(const unsigned char *str, int length);
|
||||
unsigned char *rb_base64_decode(const unsigned char *str, int length, int *ret);
|
||||
int rb_kill(pid_t, int);
|
||||
char *rb_strerror(int);
|
||||
|
||||
int rb_setenv(const char *, const char *, int);
|
||||
int rb_kill(int pid, int sig);
|
||||
|
||||
pid_t rb_waitpid(pid_t pid, int *status, int options);
|
||||
pid_t rb_getpid(void);
|
||||
//unsigned int rb_geteuid(void);
|
||||
|
||||
#include <rb_tools.h>
|
||||
#include <rb_memory.h>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_balloc.h 24324 2007-08-31 22:05:45Z androsyn $
|
||||
* $Id: rb_balloc.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -34,17 +34,18 @@
|
|||
|
||||
struct rb_bh;
|
||||
typedef struct rb_bh rb_bh;
|
||||
typedef void rb_bh_usage_cb(size_t bused, size_t bfree, size_t bmemusage, size_t heapalloc, const char *desc, void *data);
|
||||
typedef void rb_bh_usage_cb (size_t bused, size_t bfree, size_t bmemusage, size_t heapalloc,
|
||||
const char *desc, void *data);
|
||||
|
||||
|
||||
int rb_bh_free(rb_bh *, void *);
|
||||
void *rb_bh_alloc(rb_bh *);
|
||||
|
||||
rb_bh *rb_bh_create(size_t elemsize, int elemsperblock, const char *desc);
|
||||
int rb_bh_destroy(rb_bh * bh);
|
||||
int rb_bh_destroy(rb_bh *bh);
|
||||
int rb_bh_gc(rb_bh *bh);
|
||||
void rb_init_bh(void);
|
||||
void rb_bh_usage(rb_bh * bh, size_t * bused, size_t * bfree, size_t * bmemusage, const char **desc);
|
||||
void rb_bh_usage(rb_bh *bh, size_t *bused, size_t *bfree, size_t *bmemusage, const char **desc);
|
||||
void rb_bh_usage_all(rb_bh_usage_cb *cb, void *data);
|
||||
void rb_bh_total_usage(size_t *total_alloc, size_t *total_used);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_commio.h 25693 2008-07-10 18:27:23Z androsyn $
|
||||
* $Id: rb_commio.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -64,7 +64,7 @@ enum
|
|||
#define RB_FD_NONE 0x01
|
||||
#define RB_FD_FILE 0x02
|
||||
#define RB_FD_SOCKET 0x04
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#define RB_FD_PIPE 0x08
|
||||
#else
|
||||
#define RB_FD_PIPE RB_FD_SOCKET
|
||||
|
@ -88,7 +88,7 @@ struct rb_iovec
|
|||
|
||||
void rb_fdlist_init(int closeall, int maxfds, size_t heapsize);
|
||||
|
||||
rb_fde_t * rb_open(int, uint8_t, const char *);
|
||||
rb_fde_t *rb_open(int, uint8_t, const char *);
|
||||
void rb_close(rb_fde_t *);
|
||||
void rb_dump_fd(DUMPCB *, void *xdata);
|
||||
void rb_note(rb_fde_t *, const char *);
|
||||
|
@ -107,17 +107,16 @@ int rb_get_sockerr(rb_fde_t *);
|
|||
|
||||
void rb_settimeout(rb_fde_t *, time_t, PF *, void *);
|
||||
void rb_checktimeouts(void *);
|
||||
void rb_connect_tcp(rb_fde_t *, struct sockaddr *,
|
||||
struct sockaddr *, int, CNCB *, void *, int);
|
||||
void rb_connect_tcp_ssl(rb_fde_t *, struct sockaddr *,
|
||||
struct sockaddr *, int, CNCB *, void *, int);
|
||||
void rb_connect_tcp(rb_fde_t *, struct sockaddr *, struct sockaddr *, int, CNCB *, void *, int);
|
||||
void rb_connect_tcp_ssl(rb_fde_t *, struct sockaddr *, struct sockaddr *, int, CNCB *, void *, int);
|
||||
int rb_connect_sockaddr(rb_fde_t *, struct sockaddr *addr, int len);
|
||||
|
||||
const char *rb_errstr(int status);
|
||||
rb_fde_t *rb_socket(int family, int sock_type, int proto, const char *note);
|
||||
int rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2, const char *note);
|
||||
int rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2,
|
||||
const char *note);
|
||||
|
||||
void rb_accept_tcp(rb_fde_t *, ACPRE *precb, ACCB *callback, void *data);
|
||||
void rb_accept_tcp(rb_fde_t *, ACPRE * precb, ACCB * callback, void *data);
|
||||
ssize_t rb_write(rb_fde_t *, const void *buf, int count);
|
||||
ssize_t rb_writev(rb_fde_t *, struct rb_iovec *vector, int count);
|
||||
|
||||
|
@ -145,7 +144,7 @@ const char *rb_get_ssl_strerror(rb_fde_t *F);
|
|||
|
||||
rb_fde_t *rb_get_fde(int fd);
|
||||
|
||||
int rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize);
|
||||
int rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid);
|
||||
int rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int count);
|
||||
|
||||
void rb_set_type(rb_fde_t *F, uint8_t type);
|
||||
|
@ -153,10 +152,11 @@ uint8_t rb_get_type(rb_fde_t *F);
|
|||
|
||||
const char *rb_get_iotype(void);
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
RB_PRNG_EGD,
|
||||
RB_PRNG_FILE,
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
RB_PRNGWIN32,
|
||||
#endif
|
||||
RB_PRNG_DEFAULT,
|
||||
|
@ -165,11 +165,15 @@ typedef enum {
|
|||
int rb_init_prng(const char *path, prng_seed_t seed_type);
|
||||
int rb_get_random(void *buf, size_t len);
|
||||
int rb_get_pseudo_random(void *buf, size_t len);
|
||||
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout);
|
||||
void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout);
|
||||
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout);
|
||||
void rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout);
|
||||
int rb_supports_ssl(void);
|
||||
|
||||
unsigned int rb_ssl_handshake_count(rb_fde_t *F);
|
||||
void rb_ssl_clear_handshake_count(rb_fde_t *F);
|
||||
|
||||
|
||||
int rb_pass_fd_to_process(rb_fde_t *, pid_t, rb_fde_t *);
|
||||
rb_fde_t *rb_recv_fd(rb_fde_t *);
|
||||
|
||||
#endif /* INCLUDED_commio_h */
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_event.h 25151 2008-03-28 17:19:12Z androsyn $
|
||||
* $Id: rb_event.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -43,7 +43,7 @@ void rb_event_delete(struct ev_entry *);
|
|||
void rb_event_find_delete(EVH * func, void *);
|
||||
void rb_event_update(struct ev_entry *, time_t freq);
|
||||
void rb_set_back_events(time_t);
|
||||
void rb_dump_events(void (*func)(char *, void *), void *ptr);
|
||||
void rb_dump_events(void (*func) (char *, void *), void *ptr);
|
||||
void rb_run_event(struct ev_entry *);
|
||||
time_t rb_event_next(void);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_helper.h 24936 2008-01-14 20:43:23Z androsyn $
|
||||
* $Id: rb_helper.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -36,16 +36,20 @@ typedef void rb_helper_cb(rb_helper *);
|
|||
|
||||
|
||||
|
||||
rb_helper *rb_helper_start(const char *name, const char *fullpath, rb_helper_cb *read_cb, rb_helper_cb *error_cb);
|
||||
rb_helper *rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
|
||||
rb_helper_cb * error_cb);
|
||||
|
||||
rb_helper *rb_helper_child(rb_helper_cb *read_cb, rb_helper_cb *error_cb,
|
||||
log_cb *ilog, restart_cb *irestart, die_cb *idie,
|
||||
rb_helper *rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb,
|
||||
log_cb * ilog, restart_cb * irestart, die_cb * idie,
|
||||
int maxcon, size_t lb_heap_size, size_t dh_size, size_t fd_heap_size);
|
||||
|
||||
void rb_helper_restart(rb_helper *helper);
|
||||
#ifdef __GNUC__
|
||||
void rb_helper_write(rb_helper *helper, const char *format, ...) __attribute((format(printf, 2, 3)));
|
||||
void rb_helper_write_queue(rb_helper *helper, const char *format, ...) __attribute((format(printf, 2, 3)));
|
||||
void
|
||||
rb_helper_write(rb_helper *helper, const char *format, ...)
|
||||
__attribute((format(printf, 2, 3)));
|
||||
void rb_helper_write_queue(rb_helper *helper, const char *format, ...)
|
||||
__attribute((format(printf, 2, 3)));
|
||||
#else
|
||||
void rb_helper_write(rb_helper *helper, const char *format, ...);
|
||||
void rb_helper_write_queue(rb_helper *helper, const char *format, ...);
|
||||
|
@ -57,4 +61,3 @@ void rb_helper_close(rb_helper *helper);
|
|||
int rb_helper_read(rb_helper *helper, void *buf, size_t bufsize);
|
||||
void rb_helper_loop(rb_helper *helper, long delay);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_linebuf.h 25675 2008-07-06 04:13:05Z androsyn $
|
||||
* $Id: rb_linebuf.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -74,7 +74,7 @@ int rb_linebuf_parse(buf_head_t *, char *, int, int);
|
|||
int rb_linebuf_get(buf_head_t *, char *, int, int, int);
|
||||
void rb_linebuf_putmsg(buf_head_t *, const char *, va_list *, const char *, ...);
|
||||
void rb_linebuf_put(buf_head_t *, const char *, ...);
|
||||
void rb_linebuf_putbuf(buf_head_t *bufhead, const char *buffer);
|
||||
void rb_linebuf_putbuf(buf_head_t * bufhead, const char *buffer);
|
||||
void rb_linebuf_attach(buf_head_t *, buf_head_t *);
|
||||
void rb_count_rb_linebuf_memory(size_t *, size_t *);
|
||||
int rb_linebuf_flush(rb_fde_t *F, buf_head_t *);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_memory.h 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: rb_memory.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -62,7 +62,7 @@ rb_strndup(const char *x, size_t y)
|
|||
if(rb_unlikely(ret == NULL))
|
||||
rb_outofmemory();
|
||||
rb_strlcpy(ret, x, y);
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static inline char *
|
||||
|
@ -72,7 +72,7 @@ rb_strdup(const char *x)
|
|||
if(rb_unlikely(ret == NULL))
|
||||
rb_outofmemory();
|
||||
strcpy(ret, x);
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,4 +84,3 @@ rb_free(void *ptr)
|
|||
}
|
||||
|
||||
#endif /* _I_MEMORY_H */
|
||||
|
||||
|
|
|
@ -66,29 +66,30 @@ typedef struct _rb_patricia_tree_t
|
|||
rb_patricia_tree_t;
|
||||
|
||||
|
||||
rb_patricia_node_t *rb_match_ip(rb_patricia_tree_t * tree, struct sockaddr *ip);
|
||||
rb_patricia_node_t *rb_match_ip_exact(rb_patricia_tree_t * tree, struct sockaddr *ip, unsigned int len);
|
||||
rb_patricia_node_t *rb_match_string(rb_patricia_tree_t * tree, const char *string);
|
||||
rb_patricia_node_t *rb_match_exact_string(rb_patricia_tree_t * tree, const char *string);
|
||||
rb_patricia_node_t *rb_patricia_search_exact(rb_patricia_tree_t * patricia, rb_prefix_t * prefix);
|
||||
rb_patricia_node_t *rb_patricia_search_best(rb_patricia_tree_t * patricia, rb_prefix_t * prefix);
|
||||
rb_patricia_node_t *rb_patricia_search_best2(rb_patricia_tree_t * patricia,
|
||||
rb_prefix_t * prefix, int inclusive);
|
||||
rb_patricia_node_t *rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix);
|
||||
rb_patricia_node_t *rb_match_ip(rb_patricia_tree_t *tree, struct sockaddr *ip);
|
||||
rb_patricia_node_t *rb_match_ip_exact(rb_patricia_tree_t *tree, struct sockaddr *ip,
|
||||
unsigned int len);
|
||||
rb_patricia_node_t *rb_match_string(rb_patricia_tree_t *tree, const char *string);
|
||||
rb_patricia_node_t *rb_match_exact_string(rb_patricia_tree_t *tree, const char *string);
|
||||
rb_patricia_node_t *rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix);
|
||||
rb_patricia_node_t *rb_patricia_search_best(rb_patricia_tree_t *patricia, rb_prefix_t *prefix);
|
||||
rb_patricia_node_t *rb_patricia_search_best2(rb_patricia_tree_t *patricia,
|
||||
rb_prefix_t *prefix, int inclusive);
|
||||
rb_patricia_node_t *rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix);
|
||||
|
||||
void rb_patricia_remove(rb_patricia_tree_t * patricia, rb_patricia_node_t * node);
|
||||
void rb_patricia_remove(rb_patricia_tree_t *patricia, rb_patricia_node_t *node);
|
||||
rb_patricia_tree_t *rb_new_patricia(int maxbits);
|
||||
void rb_clear_patricia(rb_patricia_tree_t * patricia, void (*func)(void *));
|
||||
void rb_destroy_patricia(rb_patricia_tree_t * patricia, void (*func)(void *));
|
||||
void rb_patricia_process(rb_patricia_tree_t * patricia, void (*func)(rb_prefix_t *, void *));
|
||||
void rb_clear_patricia(rb_patricia_tree_t *patricia, void (*func) (void *));
|
||||
void rb_destroy_patricia(rb_patricia_tree_t *patricia, void (*func) (void *));
|
||||
void rb_patricia_process(rb_patricia_tree_t *patricia, void (*func) (rb_prefix_t *, void *));
|
||||
void rb_init_patricia(void);
|
||||
|
||||
|
||||
#if 0
|
||||
rb_prefix_t *ascii2prefix(int family, char *string);
|
||||
#endif
|
||||
rb_patricia_node_t *make_and_lookup(rb_patricia_tree_t * tree, const char *string);
|
||||
rb_patricia_node_t *make_and_lookup_ip(rb_patricia_tree_t * tree, struct sockaddr *, int bitlen);
|
||||
rb_patricia_node_t *make_and_lookup(rb_patricia_tree_t *tree, const char *string);
|
||||
rb_patricia_node_t *make_and_lookup_ip(rb_patricia_tree_t *tree, struct sockaddr *, int bitlen);
|
||||
|
||||
|
||||
#define RB_PATRICIA_MAXBITS 128
|
||||
|
|
|
@ -41,6 +41,6 @@ rawbuf_head_t *rb_new_rawbuffer(void);
|
|||
int rb_rawbuf_get(rawbuf_head_t *, void *data, int len);
|
||||
void rb_rawbuf_append(rawbuf_head_t *, void *data, int len);
|
||||
int rb_rawbuf_flush(rawbuf_head_t *, rb_fde_t *F);
|
||||
int rb_rawbuf_length(rawbuf_head_t *rb);
|
||||
int rb_rawbuf_length(rawbuf_head_t * rb);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_snprintf.h 24324 2007-08-31 22:05:45Z androsyn $
|
||||
* $Id: rb_snprintf.h 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -40,10 +40,14 @@
|
|||
* rb_sprintf - optimized sprintf
|
||||
*/
|
||||
#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)));
|
||||
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 *, ...);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_tools.h 25042 2008-01-23 16:14:08Z androsyn $
|
||||
* $Id: rb_tools.h 26170 2008-10-26 20:59:07Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef RB_LIB_H
|
||||
|
@ -34,6 +34,8 @@
|
|||
size_t rb_strlcpy(char *dst, const char *src, size_t siz);
|
||||
size_t rb_strlcat(char *dst, const char *src, size_t siz);
|
||||
size_t rb_strnlen(const char *s, size_t count);
|
||||
char *rb_basename(const char *);
|
||||
char *rb_dirname(const char *);
|
||||
|
||||
int rb_string_to_array(char *string, char **parv, int maxpara);
|
||||
|
||||
|
@ -59,7 +61,7 @@ struct _rb_dlink_list
|
|||
};
|
||||
|
||||
rb_dlink_node *rb_make_rb_dlink_node(void);
|
||||
void rb_free_rb_dlink_node(rb_dlink_node * lp);
|
||||
void rb_free_rb_dlink_node(rb_dlink_node *lp);
|
||||
void rb_init_rb_dlink_nodes(size_t dh_size);
|
||||
|
||||
/* This macros are basically swiped from the linux kernel
|
||||
|
@ -99,7 +101,7 @@ void rb_init_rb_dlink_nodes(size_t dh_size);
|
|||
*/
|
||||
|
||||
static inline void
|
||||
rb_dlinkMoveNode(rb_dlink_node * m, rb_dlink_list * oldlist, rb_dlink_list * newlist)
|
||||
rb_dlinkMoveNode(rb_dlink_node *m, rb_dlink_list *oldlist, rb_dlink_list *newlist)
|
||||
{
|
||||
/* Assumption: If m->next == NULL, then list->tail == m
|
||||
* and: If m->prev == NULL, then list->head == m
|
||||
|
@ -131,7 +133,7 @@ rb_dlinkMoveNode(rb_dlink_node * m, rb_dlink_list * oldlist, rb_dlink_list * new
|
|||
}
|
||||
|
||||
static inline void
|
||||
rb_dlinkAdd(void *data, rb_dlink_node * m, rb_dlink_list * list)
|
||||
rb_dlinkAdd(void *data, rb_dlink_node *m, rb_dlink_list *list)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(m != NULL);
|
||||
|
@ -152,7 +154,7 @@ rb_dlinkAdd(void *data, rb_dlink_node * m, rb_dlink_list * list)
|
|||
}
|
||||
|
||||
static inline void
|
||||
rb_dlinkAddBefore(rb_dlink_node * b, void *data, rb_dlink_node * m, rb_dlink_list * list)
|
||||
rb_dlinkAddBefore(rb_dlink_node *b, void *data, rb_dlink_node *m, rb_dlink_list *list)
|
||||
{
|
||||
assert(b != NULL);
|
||||
assert(data != NULL);
|
||||
|
@ -199,7 +201,7 @@ rb_dlinkMoveTail(rb_dlink_node *m, rb_dlink_list *list)
|
|||
}
|
||||
|
||||
static inline void
|
||||
rb_dlinkAddTail(void *data, rb_dlink_node * m, rb_dlink_list * list)
|
||||
rb_dlinkAddTail(void *data, rb_dlink_node *m, rb_dlink_list *list)
|
||||
{
|
||||
assert(m != NULL);
|
||||
assert(list != NULL);
|
||||
|
@ -223,7 +225,7 @@ rb_dlinkAddTail(void *data, rb_dlink_node * m, rb_dlink_list * list)
|
|||
* often of all non-spontaneous functions. So it had better be
|
||||
* efficient. */
|
||||
static inline void
|
||||
rb_dlinkDelete(rb_dlink_node * m, rb_dlink_list * list)
|
||||
rb_dlinkDelete(rb_dlink_node *m, rb_dlink_list *list)
|
||||
{
|
||||
assert(m != NULL);
|
||||
assert(list != NULL);
|
||||
|
@ -312,7 +314,7 @@ rb_dlinkFind(void *data, rb_dlink_list *list)
|
|||
}
|
||||
|
||||
static inline void
|
||||
rb_dlinkMoveList(rb_dlink_list * from, rb_dlink_list * to)
|
||||
rb_dlinkMoveList(rb_dlink_list *from, rb_dlink_list *to)
|
||||
{
|
||||
assert(from != NULL);
|
||||
assert(to != NULL);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# NOTE: Changing this file will not affect anything until you rerun configure.
|
||||
#
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
|
||||
# 2007 Free Software Foundation, Inc.
|
||||
# 2007, 2008 Free Software Foundation, Inc.
|
||||
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -43,8 +43,8 @@ EXIT_FAILURE=1
|
|||
|
||||
PROGRAM=ltmain.sh
|
||||
PACKAGE=libtool
|
||||
VERSION="1.5.24 Debian 1.5.24-1"
|
||||
TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)"
|
||||
VERSION="1.5.26 Debian 1.5.26-4"
|
||||
TIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
|
||||
|
||||
# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
|
||||
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
||||
|
@ -113,15 +113,21 @@ esac
|
|||
# These must not be set unconditionally because not all systems understand
|
||||
# e.g. LANG=C (notably SCO).
|
||||
# We save the old values to restore during execute mode.
|
||||
for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
|
||||
lt_env=
|
||||
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
|
||||
do
|
||||
eval "if test \"\${$lt_var+set}\" = set; then
|
||||
save_$lt_var=\$$lt_var
|
||||
lt_env=\"$lt_var=\$$lt_var \$lt_env\"
|
||||
$lt_var=C
|
||||
export $lt_var
|
||||
fi"
|
||||
done
|
||||
|
||||
if test -n "$lt_env"; then
|
||||
lt_env="env $lt_env"
|
||||
fi
|
||||
|
||||
# Make sure IFS has a sensible default
|
||||
lt_nl='
|
||||
'
|
||||
|
@ -485,7 +491,7 @@ do
|
|||
echo "\
|
||||
$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
exit $?
|
||||
|
@ -788,6 +794,7 @@ if test -z "$show_help"; then
|
|||
*.for) xform=for ;;
|
||||
*.java) xform=java ;;
|
||||
*.obj) xform=obj ;;
|
||||
*.sx) xform=sx ;;
|
||||
esac
|
||||
|
||||
libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
|
||||
|
@ -956,7 +963,7 @@ EOF
|
|||
$run $rm "$lobj" "$output_obj"
|
||||
|
||||
$show "$command"
|
||||
if $run eval "$command"; then :
|
||||
if $run eval $lt_env "$command"; then :
|
||||
else
|
||||
test -n "$output_obj" && $run $rm $removelist
|
||||
exit $EXIT_FAILURE
|
||||
|
@ -1028,7 +1035,7 @@ EOF
|
|||
command="$command$suppress_output"
|
||||
$run $rm "$obj" "$output_obj"
|
||||
$show "$command"
|
||||
if $run eval "$command"; then :
|
||||
if $run eval $lt_env "$command"; then :
|
||||
else
|
||||
$run $rm $removelist
|
||||
exit $EXIT_FAILURE
|
||||
|
@ -1161,6 +1168,7 @@ EOF
|
|||
thread_safe=no
|
||||
vinfo=
|
||||
vinfo_number=no
|
||||
single_module="${wl}-single_module"
|
||||
|
||||
func_infer_tag $base_compile
|
||||
|
||||
|
@ -1646,6 +1654,11 @@ EOF
|
|||
continue
|
||||
;;
|
||||
|
||||
-multi_module)
|
||||
single_module="${wl}-multi_module"
|
||||
continue
|
||||
;;
|
||||
|
||||
-module)
|
||||
module=yes
|
||||
continue
|
||||
|
@ -2152,7 +2165,12 @@ EOF
|
|||
continue
|
||||
fi
|
||||
name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
|
||||
for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
|
||||
if test "$linkmode" = lib; then
|
||||
searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
|
||||
else
|
||||
searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
|
||||
fi
|
||||
for searchdir in $searchdirs; do
|
||||
for search_ext in .la $std_shrext .so .a; do
|
||||
# Search the libtool library
|
||||
lib="$searchdir/lib${name}${search_ext}"
|
||||
|
@ -2948,12 +2966,18 @@ EOF
|
|||
# we do not want to link against static libs,
|
||||
# but need to link against shared
|
||||
eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
|
||||
eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
|
||||
if test -n "$deplibrary_names" ; then
|
||||
for tmp in $deplibrary_names ; do
|
||||
depdepl=$tmp
|
||||
done
|
||||
if test -f "$path/$depdepl" ; then
|
||||
if test -f "$deplibdir/$depdepl" ; then
|
||||
depdepl="$deplibdir/$depdepl"
|
||||
elif test -f "$path/$depdepl" ; then
|
||||
depdepl="$path/$depdepl"
|
||||
else
|
||||
# Can't find it, oh well...
|
||||
depdepl=
|
||||
fi
|
||||
# do not add paths which are already there
|
||||
case " $newlib_search_path " in
|
||||
|
@ -3101,9 +3125,10 @@ EOF
|
|||
|
||||
case $linkmode in
|
||||
oldlib)
|
||||
if test -n "$deplibs"; then
|
||||
$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
|
||||
fi
|
||||
case " $deplibs" in
|
||||
*\ -l* | *\ -L*)
|
||||
$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
|
||||
esac
|
||||
|
||||
if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
|
||||
$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
|
||||
|
@ -4245,9 +4270,10 @@ EOF
|
|||
;;
|
||||
|
||||
obj)
|
||||
if test -n "$deplibs"; then
|
||||
$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
|
||||
fi
|
||||
case " $deplibs" in
|
||||
*\ -l* | *\ -L*)
|
||||
$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
|
||||
esac
|
||||
|
||||
if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
|
||||
$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
|
||||
|
@ -6486,7 +6512,7 @@ relink_command=\"$relink_command\""
|
|||
fi
|
||||
|
||||
# Restore saved environment variables
|
||||
for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
|
||||
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
|
||||
do
|
||||
eval "if test \"\${save_$lt_var+set}\" = set; then
|
||||
$lt_var=\$save_$lt_var; export $lt_var
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $
|
||||
# $Id: Makefile.am 26046 2008-09-09 16:37:30Z androsyn $
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
INCLUDES = -I. -I../include @SSL_CFLAGS@ @GNUTLS_CFLAGS@
|
||||
|
||||
BUILT_SOURCES = version.c
|
||||
|
||||
version.c: version.c.SH ../CREDITS
|
||||
$(SHELL) ./version.c.SH
|
||||
$(CP) version.c version.c.last
|
||||
|
||||
version.lo: version.c ../include/serno.h
|
||||
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
libratbox_la_SOURCES = \
|
||||
unix.c \
|
||||
win32.c \
|
||||
|
@ -29,10 +38,11 @@ libratbox_la_SOURCES = \
|
|||
kqueue.c \
|
||||
rawbuf.c \
|
||||
patricia.c \
|
||||
arc4random.c
|
||||
arc4random.c \
|
||||
version.c
|
||||
|
||||
|
||||
libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt
|
||||
libratbox_la_LDFLAGS = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@ -avoid-version -no-undefined -export-symbols export-syms.txt
|
||||
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@
|
||||
lib_LTLIBRARIES = libratbox.la
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
@SET_MAKE@
|
||||
|
||||
# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $
|
||||
# $Id: Makefile.am 26046 2008-09-09 16:37:30Z androsyn $
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
|
@ -58,7 +58,7 @@ am_libratbox_la_OBJECTS = unix.lo win32.lo crypt.lo balloc.lo \
|
|||
commio.lo openssl.lo gnutls.lo nossl.lo event.lo ratbox_lib.lo \
|
||||
rb_memory.lo linebuf.lo snprintf.lo tools.lo helper.lo \
|
||||
devpoll.lo epoll.lo poll.lo ports.lo sigio.lo select.lo \
|
||||
kqueue.lo rawbuf.lo patricia.lo arc4random.lo
|
||||
kqueue.lo rawbuf.lo patricia.lo arc4random.lo version.lo
|
||||
libratbox_la_OBJECTS = $(am_libratbox_la_OBJECTS)
|
||||
libratbox_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
|
@ -120,7 +120,6 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
|
@ -202,13 +201,13 @@ psdir = @psdir@
|
|||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
INCLUDES = -I. -I../include @SSL_CFLAGS@ @GNUTLS_CFLAGS@
|
||||
BUILT_SOURCES = version.c
|
||||
libratbox_la_SOURCES = \
|
||||
unix.c \
|
||||
win32.c \
|
||||
|
@ -234,12 +233,14 @@ libratbox_la_SOURCES = \
|
|||
kqueue.c \
|
||||
rawbuf.c \
|
||||
patricia.c \
|
||||
arc4random.c
|
||||
arc4random.c \
|
||||
version.c
|
||||
|
||||
libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt
|
||||
libratbox_la_LDFLAGS = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@ -avoid-version -no-undefined -export-symbols export-syms.txt
|
||||
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@
|
||||
lib_LTLIBRARIES = libratbox.la
|
||||
all: all-am
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
|
@ -332,6 +333,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/win32.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
|
@ -435,13 +437,15 @@ distdir: $(DISTFILES)
|
|||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
@ -465,6 +469,7 @@ distclean-generic:
|
|||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
|
@ -540,6 +545,13 @@ uninstall-am: uninstall-libLTLIBRARIES
|
|||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-libLTLIBRARIES
|
||||
|
||||
|
||||
version.c: version.c.SH ../CREDITS
|
||||
$(SHELL) ./version.c.SH
|
||||
$(CP) version.c version.c.last
|
||||
|
||||
version.lo: version.c ../include/serno.h
|
||||
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: arc4random.c 25705 2008-07-11 18:21:57Z androsyn $ */
|
||||
/* $Id: arc4random.c 26092 2008-09-19 15:13:52Z androsyn $ */
|
||||
/* $$$: arc4random.c 2005/02/08 robert */
|
||||
/* $NetBSD: arc4random.c,v 1.5.2.1 2004/03/26 22:52:50 jmc Exp $ */
|
||||
/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
|
||||
|
@ -41,7 +41,8 @@
|
|||
|
||||
|
||||
|
||||
struct arc4_stream {
|
||||
struct arc4_stream
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t j;
|
||||
uint8_t s[256];
|
||||
|
@ -62,7 +63,7 @@ arc4_init(struct arc4_stream *as)
|
|||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 256; n++)
|
||||
for(n = 0; n < 256; n++)
|
||||
as->s[n] = n;
|
||||
as->i = 0;
|
||||
as->j = 0;
|
||||
|
@ -75,7 +76,8 @@ arc4_addrandom(struct arc4_stream *as, uint8_t *dat, int datlen)
|
|||
uint8_t si;
|
||||
|
||||
as->i--;
|
||||
for (n = 0; n < 256; n++) {
|
||||
for(n = 0; n < 256; n++)
|
||||
{
|
||||
as->i = (as->i + 1);
|
||||
si = as->s[as->i];
|
||||
as->j = (as->j + si + dat[n % datlen]);
|
||||
|
@ -107,29 +109,44 @@ arc4_stir(struct arc4_stream *as)
|
|||
struct rusage buf;
|
||||
getrusage(RUSAGE_SELF, &buf);
|
||||
arc4_addrandom(as, (void *)&buf, sizeof(buf));
|
||||
memset(&buf, 0, sizeof(buf))
|
||||
}
|
||||
memset(&buf, 0, sizeof(buf))}
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32)
|
||||
#if !defined(_WIN32)
|
||||
{
|
||||
uint8_t rnd[128];
|
||||
int fd;
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd != -1)
|
||||
if(fd != -1)
|
||||
{
|
||||
read(fd, rnd, sizeof(rnd));
|
||||
close(fd);
|
||||
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
|
||||
memset(&rnd, 0, sizeof(rnd));
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
{
|
||||
LARGE_INTEGER performanceCount;
|
||||
if (QueryPerformanceCounter (&performanceCount))
|
||||
if(QueryPerformanceCounter(&performanceCount))
|
||||
{
|
||||
arc4_addrandom(as, (void *)&performanceCount, sizeof(performanceCount));
|
||||
}
|
||||
HMODULE lib = LoadLibrary("ADVAPI32.DLL");
|
||||
if(lib)
|
||||
{
|
||||
uint8_t rnd[128];
|
||||
BOOLEAN(APIENTRY * pfn) (void *, ULONG) =
|
||||
(BOOLEAN(APIENTRY *) (void *, ULONG))GetProcAddress(lib,
|
||||
"SystemFunction036");
|
||||
if(pfn)
|
||||
{
|
||||
if(pfn(rnd, sizeof(rnd)) == TRUE)
|
||||
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
|
||||
memset(&rnd, 0, sizeof(rnd));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -141,7 +158,7 @@ arc4_stir(struct arc4_stream *as)
|
|||
* http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
|
||||
* N = 256 in our case.
|
||||
*/
|
||||
for (n = 0; n < 256 * 4; n++)
|
||||
for(n = 0; n < 256 * 4; n++)
|
||||
arc4_getbyte(as);
|
||||
}
|
||||
|
||||
|
@ -173,7 +190,8 @@ arc4_getword(struct arc4_stream *as)
|
|||
void
|
||||
arc4random_stir(void)
|
||||
{
|
||||
if (!rs_initialized) {
|
||||
if(!rs_initialized)
|
||||
{
|
||||
arc4_init(&rs);
|
||||
rs_initialized = 1;
|
||||
}
|
||||
|
@ -183,7 +201,7 @@ arc4random_stir(void)
|
|||
void
|
||||
arc4random_addrandom(uint8_t *dat, int datlen)
|
||||
{
|
||||
if (!rs_initialized)
|
||||
if(!rs_initialized)
|
||||
arc4random_stir();
|
||||
arc4_addrandom(&rs, dat, datlen);
|
||||
}
|
||||
|
@ -191,10 +209,9 @@ arc4random_addrandom(uint8_t *dat, int datlen)
|
|||
uint32_t
|
||||
arc4random(void)
|
||||
{
|
||||
if (!rs_initialized)
|
||||
if(!rs_initialized)
|
||||
arc4random_stir();
|
||||
return arc4_getword(&rs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: balloc.c 25861 2008-08-06 19:51:44Z androsyn $
|
||||
* $Id: balloc.c 26100 2008-09-20 01:27:19Z androsyn $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -59,6 +59,7 @@
|
|||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
||||
#ifndef NOBALLOC
|
||||
#ifdef HAVE_MMAP /* We've got mmap() that is good */
|
||||
#include <sys/mman.h>
|
||||
/* HP-UX sucks */
|
||||
|
@ -68,6 +69,7 @@
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static uintptr_t offset_pad;
|
||||
|
||||
|
@ -93,7 +95,7 @@ struct rb_bh
|
|||
};
|
||||
|
||||
#ifndef NOBALLOC
|
||||
static int newblock(rb_bh * bh);
|
||||
static int newblock(rb_bh *bh);
|
||||
static void rb_bh_gc_event(void *unused);
|
||||
#endif /* !NOBALLOC */
|
||||
static rb_dlink_list *heap_lists;
|
||||
|
@ -125,7 +127,7 @@ free_block(void *ptr, size_t size)
|
|||
#ifdef HAVE_MMAP
|
||||
munmap(ptr, size);
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
HeapFree(block_heap, 0, ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
|
@ -159,7 +161,7 @@ rb_init_bh(void)
|
|||
#endif
|
||||
|
||||
#ifndef NOBALLOC
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
block_heap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
|
||||
#endif
|
||||
rb_event_addish("rb_bh_gc_event", rb_bh_gc_event, NULL, 300);
|
||||
|
@ -192,13 +194,13 @@ get_block(size_t size)
|
|||
if(ptr == MAP_FAILED)
|
||||
ptr = NULL;
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
ptr = HeapAlloc(block_heap, 0, size);
|
||||
#else
|
||||
ptr = malloc(size);
|
||||
#endif
|
||||
#endif
|
||||
return(ptr);
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +226,7 @@ rb_bh_gc_event(void *unused)
|
|||
/* ************************************************************************ */
|
||||
|
||||
static int
|
||||
newblock(rb_bh * bh)
|
||||
newblock(rb_bh *bh)
|
||||
{
|
||||
rb_heap_block *b;
|
||||
unsigned long i;
|
||||
|
@ -242,7 +244,7 @@ newblock(rb_bh * bh)
|
|||
}
|
||||
offset = (uintptr_t)b->elems;
|
||||
/* Setup our blocks now */
|
||||
for (i = 0; i < bh->elemsPerBlock; i++, offset += bh->elemSize)
|
||||
for(i = 0; i < bh->elemsPerBlock; i++, offset += bh->elemSize)
|
||||
{
|
||||
*((void **)offset) = b;
|
||||
node = (void *)(offset + offset_pad);
|
||||
|
@ -334,11 +336,11 @@ rb_bh_create(size_t elemsize, int elemsperblock, const char *desc)
|
|||
/* ************************************************************************ */
|
||||
|
||||
void *
|
||||
rb_bh_alloc(rb_bh * bh)
|
||||
rb_bh_alloc(rb_bh *bh)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_dlink_node *new_node;
|
||||
rb_heap_block *block;
|
||||
rb_heap_block **block;
|
||||
void *ptr;
|
||||
#endif
|
||||
lrb_assert(bh != NULL);
|
||||
|
@ -348,7 +350,7 @@ rb_bh_alloc(rb_bh * bh)
|
|||
}
|
||||
|
||||
#ifdef NOBALLOC
|
||||
return(rb_malloc(bh->elemSize));
|
||||
return (rb_malloc(bh->elemSize));
|
||||
#else
|
||||
if(bh->free_list.head == NULL)
|
||||
{
|
||||
|
@ -368,11 +370,12 @@ rb_bh_alloc(rb_bh * bh)
|
|||
}
|
||||
|
||||
new_node = bh->free_list.head;
|
||||
block = new_node->data;
|
||||
ptr = new_node->data + offset_pad;
|
||||
block = (rb_heap_block **) new_node->data;
|
||||
ptr = (void *)((uintptr_t)new_node->data + (uintptr_t)offset_pad);
|
||||
rb_dlinkDelete(new_node, &bh->free_list);
|
||||
(*block)->free_count--;
|
||||
memset(ptr, 0, bh->elemSize - offset_pad);
|
||||
return(ptr);
|
||||
return (ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -389,7 +392,7 @@ rb_bh_alloc(rb_bh * bh)
|
|||
/* 0 if successful, 1 if element not contained within rb_bh. */
|
||||
/* ************************************************************************ */
|
||||
int
|
||||
rb_bh_free(rb_bh * bh, void *ptr)
|
||||
rb_bh_free(rb_bh *bh, void *ptr)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_heap_block *block;
|
||||
|
@ -413,14 +416,17 @@ rb_bh_free(rb_bh * bh, void *ptr)
|
|||
#ifdef NOBALLOC
|
||||
rb_free(ptr);
|
||||
#else
|
||||
data = (void *)(ptr - offset_pad);
|
||||
block = *(rb_heap_block **)data;
|
||||
data = (void *)((uintptr_t)ptr - (uintptr_t)offset_pad);
|
||||
block = *(rb_heap_block **) data;
|
||||
/* XXX */
|
||||
if(rb_unlikely(!((uintptr_t)ptr >= (uintptr_t)block->elems && (uintptr_t)ptr < (uintptr_t)block->elems + (uintptr_t)block->alloc_size)))
|
||||
if(rb_unlikely
|
||||
(!((uintptr_t)ptr >= (uintptr_t)block->elems
|
||||
&& (uintptr_t)ptr < (uintptr_t)block->elems + (uintptr_t)block->alloc_size)))
|
||||
{
|
||||
rb_bh_fail("rb_bh_free() bogus pointer");
|
||||
}
|
||||
block->free_count++;
|
||||
|
||||
rb_dlinkAdd(data, (rb_dlink_node *)ptr, &bh->free_list);
|
||||
#endif /* !NOBALLOC */
|
||||
return (0);
|
||||
|
@ -438,7 +444,7 @@ rb_bh_free(rb_bh * bh, void *ptr)
|
|||
/* 0 if successful, 1 if bh == NULL */
|
||||
/* ************************************************************************ */
|
||||
int
|
||||
rb_bh_destroy(rb_bh * bh)
|
||||
rb_bh_destroy(rb_bh *bh)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_dlink_node *ptr, *next;
|
||||
|
@ -464,8 +470,9 @@ rb_bh_destroy(rb_bh * bh)
|
|||
}
|
||||
|
||||
void
|
||||
rb_bh_usage(rb_bh * bh, size_t * bused, size_t * bfree, size_t * bmemusage, const char **desc)
|
||||
rb_bh_usage(rb_bh *bh, size_t *bused, size_t *bfree, size_t *bmemusage, const char **desc)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
size_t used, freem, memusage;
|
||||
|
||||
if(bh == NULL)
|
||||
|
@ -484,9 +491,17 @@ rb_bh_usage(rb_bh * bh, size_t * bused, size_t * bfree, size_t * bmemusage, cons
|
|||
*bmemusage = memusage;
|
||||
if(desc != NULL)
|
||||
*desc = bh->desc;
|
||||
#else
|
||||
static char *noballoc = "no blockheap";
|
||||
*bused = 0;
|
||||
*bfree = 0;
|
||||
*bmemusage = 0;
|
||||
*desc = noballoc;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rb_bh_usage_all(rb_bh_usage_cb *cb, void *data)
|
||||
void
|
||||
rb_bh_usage_all(rb_bh_usage_cb *cb, void *data)
|
||||
{
|
||||
rb_dlink_node *ptr;
|
||||
rb_bh *bh;
|
||||
|
@ -535,7 +550,7 @@ rb_bh_total_usage(size_t *total_alloc, size_t *total_used)
|
|||
|
||||
#ifndef NOBALLOC
|
||||
int
|
||||
rb_bh_gc(rb_bh * bh)
|
||||
rb_bh_gc(rb_bh *bh)
|
||||
{
|
||||
rb_heap_block *b;
|
||||
rb_dlink_node *ptr, *next;
|
||||
|
@ -548,7 +563,8 @@ rb_bh_gc(rb_bh * bh)
|
|||
return (1);
|
||||
}
|
||||
|
||||
if((rb_dlink_list_length(&bh->free_list) < bh->elemsPerBlock) || rb_dlink_list_length(&bh->block_list) == 1)
|
||||
if((rb_dlink_list_length(&bh->free_list) < bh->elemsPerBlock)
|
||||
|| rb_dlink_list_length(&bh->block_list) == 1)
|
||||
{
|
||||
/* There couldn't possibly be an entire free block. Return. */
|
||||
return (0);
|
||||
|
@ -565,9 +581,10 @@ rb_bh_gc(rb_bh * bh)
|
|||
/* i'm seriously going to hell for this.. */
|
||||
|
||||
offset = (uintptr_t)b->elems;
|
||||
for (i = 0; i < bh->elemsPerBlock; i++, offset += (uintptr_t)bh->elemSize)
|
||||
for(i = 0; i < bh->elemsPerBlock; i++, offset += (uintptr_t)bh->elemSize)
|
||||
{
|
||||
rb_dlinkDelete(((rb_dlink_node *)offset), &bh->free_list);
|
||||
rb_dlinkDelete((rb_dlink_node *)(offset + offset_pad),
|
||||
&bh->free_list);
|
||||
}
|
||||
rb_dlinkDelete(&b->node, &bh->block_list);
|
||||
free_block(b->elems, b->alloc_size);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: commio.c 25795 2008-07-29 15:26:55Z androsyn $
|
||||
* $Id: commio.c 26096 2008-09-20 01:05:42Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
@ -64,7 +64,7 @@ static const char *rb_err_str[] = { "Comm OK", "Error during bind()",
|
|||
|
||||
/* Highest FD and number of open FDs .. */
|
||||
static int number_fd = 0;
|
||||
static int rb_maxconnections = 0;
|
||||
int rb_maxconnections = 0;
|
||||
|
||||
static PF rb_connect_timeout;
|
||||
static PF rb_connect_tryconnect;
|
||||
|
@ -74,6 +74,7 @@ static void mangle_mapped_sockaddr(struct sockaddr *in);
|
|||
|
||||
#ifndef HAVE_SOCKETPAIR
|
||||
static int rb_inet_socketpair(int d, int type, int protocol, int sv[2]);
|
||||
static int rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2);
|
||||
#endif
|
||||
|
||||
static inline rb_fde_t *
|
||||
|
@ -88,7 +89,7 @@ add_fd(int fd)
|
|||
F = rb_bh_alloc(fd_heap);
|
||||
F->fd = fd;
|
||||
rb_dlinkAdd(F, &F->node, &rb_fd_table[rb_hash_fd(fd)]);
|
||||
return(F);
|
||||
return (F);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -142,28 +143,15 @@ rb_fd_hack(int *fd)
|
|||
static void
|
||||
rb_close_all(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
int i;
|
||||
#ifndef NDEBUG
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
/* XXX someone tell me why we care about 4 fd's ? */
|
||||
/* XXX btw, fd 3 is used for profiler ! */
|
||||
for (i = 4; i < rb_maxconnections; ++i)
|
||||
for(i = 3; i < rb_maxconnections; ++i)
|
||||
{
|
||||
close(i);
|
||||
}
|
||||
|
||||
/* XXX should his hack be done in all cases? */
|
||||
#ifndef NDEBUG
|
||||
/* fugly hack to reserve fd == 2 */
|
||||
(void) close(2);
|
||||
fd = open("stderr.log", O_WRONLY | O_CREAT | O_APPEND, 0644);
|
||||
if(fd >= 0)
|
||||
{
|
||||
dup2(fd, 2);
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -188,7 +176,8 @@ rb_get_sockerr(rb_fde_t *F)
|
|||
errtmp = errno;
|
||||
|
||||
#ifdef SO_ERROR
|
||||
if(F != NULL && !getsockopt(rb_get_fd(F), SOL_SOCKET, SO_ERROR, (char *) &err, (rb_socklen_t *) & len))
|
||||
if(F != NULL
|
||||
&& !getsockopt(rb_get_fd(F), SOL_SOCKET, SO_ERROR, (char *)&err, (rb_socklen_t *) & len))
|
||||
{
|
||||
if(err)
|
||||
errtmp = err;
|
||||
|
@ -204,7 +193,7 @@ rb_get_sockerr(rb_fde_t *F)
|
|||
int
|
||||
rb_getmaxconnect(void)
|
||||
{
|
||||
return(rb_maxconnections);
|
||||
return (rb_maxconnections);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -221,8 +210,8 @@ rb_set_buffers(rb_fde_t *F, int size)
|
|||
if(F == NULL)
|
||||
return 0;
|
||||
if(setsockopt
|
||||
(F->fd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size))
|
||||
|| setsockopt(F->fd, SOL_SOCKET, SO_SNDBUF, (char *) &size, sizeof(size)))
|
||||
(F->fd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size))
|
||||
|| setsockopt(F->fd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
@ -365,7 +354,9 @@ rb_accept_tryaccept(rb_fde_t *F, void *data)
|
|||
|
||||
if(new_F == NULL)
|
||||
{
|
||||
rb_lib_log("rb_accept: new_F == NULL on incoming connection. Closing new_fd == %d\n", new_fd);
|
||||
rb_lib_log
|
||||
("rb_accept: new_F == NULL on incoming connection. Closing new_fd == %d\n",
|
||||
new_fd);
|
||||
close(new_fd);
|
||||
continue;
|
||||
}
|
||||
|
@ -394,7 +385,8 @@ rb_accept_tryaccept(rb_fde_t *F, void *data)
|
|||
else
|
||||
#endif /* HAVE_SSL */
|
||||
{
|
||||
F->accept->callback(new_F, RB_OK, (struct sockaddr *)&st, addrlen, F->accept->data);
|
||||
F->accept->callback(new_F, RB_OK, (struct sockaddr *)&st, addrlen,
|
||||
F->accept->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +394,7 @@ rb_accept_tryaccept(rb_fde_t *F, void *data)
|
|||
|
||||
/* try to accept a TCP connection */
|
||||
void
|
||||
rb_accept_tcp(rb_fde_t *F, ACPRE *precb, ACCB *callback, void *data)
|
||||
rb_accept_tcp(rb_fde_t *F, ACPRE * precb, ACCB * callback, void *data)
|
||||
{
|
||||
if(F == NULL)
|
||||
return;
|
||||
|
@ -520,7 +512,8 @@ rb_connect_tryconnect(rb_fde_t *F, void *notused)
|
|||
return;
|
||||
/* Try the connect() */
|
||||
retval = connect(F->fd,
|
||||
(struct sockaddr *) &F->connect->hostaddr, GET_SS_LEN(&F->connect->hostaddr));
|
||||
(struct sockaddr *)&F->connect->hostaddr,
|
||||
GET_SS_LEN(&F->connect->hostaddr));
|
||||
/* Error? */
|
||||
if(retval < 0)
|
||||
{
|
||||
|
@ -534,8 +527,7 @@ rb_connect_tryconnect(rb_fde_t *F, void *notused)
|
|||
rb_connect_callback(F, RB_OK);
|
||||
else if(rb_ignore_errno(errno))
|
||||
/* Ignore error? Reschedule */
|
||||
rb_setselect(F, RB_SELECT_CONNECT,
|
||||
rb_connect_tryconnect, NULL);
|
||||
rb_setselect(F, RB_SELECT_CONNECT, rb_connect_tryconnect, NULL);
|
||||
else
|
||||
/* Error? Fail with RB_ERR_CONNECT */
|
||||
rb_connect_callback(F, RB_ERR_CONNECT);
|
||||
|
@ -578,10 +570,15 @@ rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#ifdef HAVE_SOCKETPAIR
|
||||
if(socketpair(family, sock_type, proto, nfd))
|
||||
#else
|
||||
if(rb_inet_socketpair(AF_INET, SOCK_STREAM, proto, nfd))
|
||||
if(sock_type == SOCK_DGRAM)
|
||||
{
|
||||
return rb_inet_socketpair_udp(F1, F2);
|
||||
}
|
||||
|
||||
if(rb_inet_socketpair(AF_INET, sock_type, proto, nfd))
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
|
@ -628,7 +625,7 @@ rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2
|
|||
int
|
||||
rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc)
|
||||
{
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
int fd[2];
|
||||
if(number_fd >= rb_maxconnections)
|
||||
{
|
||||
|
@ -718,7 +715,8 @@ rb_socket(int family, int sock_type, int proto, const char *note)
|
|||
F = rb_open(fd, RB_FD_SOCKET, note);
|
||||
if(F == NULL)
|
||||
{
|
||||
rb_lib_log("rb_socket: rb_open returns NULL on FD %d: %s, closing fd", fd, strerror(errno));
|
||||
rb_lib_log("rb_socket: rb_open returns NULL on FD %d: %s, closing fd", fd,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -741,7 +739,7 @@ rb_socket(int family, int sock_type, int proto, const char *note)
|
|||
static void
|
||||
mangle_mapped_sockaddr(struct sockaddr *in)
|
||||
{
|
||||
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) in;
|
||||
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)in;
|
||||
|
||||
if(in->sa_family == AF_INET)
|
||||
return;
|
||||
|
@ -752,7 +750,7 @@ mangle_mapped_sockaddr(struct sockaddr *in)
|
|||
memset(&in4, 0, sizeof(struct sockaddr_in));
|
||||
in4.sin_family = AF_INET;
|
||||
in4.sin_port = in6->sin6_port;
|
||||
in4.sin_addr.s_addr = ((uint32_t *) & in6->sin6_addr)[3];
|
||||
in4.sin_addr.s_addr = ((uint32_t *)&in6->sin6_addr)[3];
|
||||
memcpy(in, &in4, sizeof(struct sockaddr_in));
|
||||
}
|
||||
return;
|
||||
|
@ -765,7 +763,7 @@ mangle_mapped_sockaddr(struct sockaddr *in)
|
|||
int
|
||||
rb_listen(rb_fde_t *F, int backlog)
|
||||
{
|
||||
F->type = RB_FD_SOCKET|RB_FD_LISTEN;
|
||||
F->type = RB_FD_SOCKET | RB_FD_LISTEN;
|
||||
/* Currently just a simple wrapper for the sake of being complete */
|
||||
return listen(F->fd, backlog);
|
||||
}
|
||||
|
@ -774,7 +772,7 @@ void
|
|||
rb_fdlist_init(int closeall, int maxfds, size_t heapsize)
|
||||
{
|
||||
static int initialized = 0;
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
int vers = MAKEWORD(2, 0);
|
||||
|
@ -816,7 +814,7 @@ rb_open(int fd, uint8_t type, const char *desc)
|
|||
fdesc = F->desc;
|
||||
else
|
||||
fdesc = "NULL";
|
||||
rb_lib_log("Trying to rb_open an already open FD: %d desc: %d", fd, fdesc);
|
||||
rb_lib_log("Trying to rb_open an already open FD: %d desc: %s", fd, fdesc);
|
||||
return NULL;
|
||||
}
|
||||
F->fd = fd;
|
||||
|
@ -868,12 +866,13 @@ rb_close(rb_fde_t *F)
|
|||
|
||||
number_fd--;
|
||||
|
||||
#ifdef WIN32
|
||||
if(type & (RB_FD_SOCKET|RB_FD_PIPE))
|
||||
#ifdef _WIN32
|
||||
if(type & (RB_FD_SOCKET | RB_FD_PIPE))
|
||||
{
|
||||
closesocket(fd);
|
||||
return;
|
||||
} else
|
||||
}
|
||||
else
|
||||
#endif
|
||||
close(fd);
|
||||
}
|
||||
|
@ -954,7 +953,7 @@ rb_get_fd(rb_fde_t *F)
|
|||
{
|
||||
if(F == NULL)
|
||||
return -1;
|
||||
return(F->fd);
|
||||
return (F->fd);
|
||||
}
|
||||
|
||||
rb_fde_t *
|
||||
|
@ -1011,7 +1010,8 @@ rb_write(rb_fde_t *F, const void *buf, int count)
|
|||
if(F->type & RB_FD_SOCKET)
|
||||
{
|
||||
ret = send(F->fd, buf, count, MSG_NOSIGNAL);
|
||||
if(ret < 0) {
|
||||
if(ret < 0)
|
||||
{
|
||||
rb_get_errno();
|
||||
}
|
||||
return ret;
|
||||
|
@ -1026,11 +1026,11 @@ rb_fake_writev(rb_fde_t *F, const struct rb_iovec *vp, size_t vpcount)
|
|||
{
|
||||
ssize_t count = 0;
|
||||
|
||||
while (vpcount-- > 0)
|
||||
while(vpcount-- > 0)
|
||||
{
|
||||
ssize_t written = rb_write(F, vp->iov_base, vp->iov_len);
|
||||
|
||||
if (written <= 0)
|
||||
if(written <= 0)
|
||||
{
|
||||
if(count > 0)
|
||||
return count;
|
||||
|
@ -1046,16 +1046,17 @@ rb_fake_writev(rb_fde_t *F, const struct rb_iovec *vp, size_t vpcount)
|
|||
|
||||
#if defined(WIN32) || !defined(HAVE_WRITEV)
|
||||
ssize_t
|
||||
rb_writev(rb_fde_t *F, struct rb_iovec *vecount, int count)
|
||||
rb_writev(rb_fde_t *F, struct rb_iovec * vecount, int count)
|
||||
{
|
||||
return rb_fake_writev(F, vecount, count);
|
||||
}
|
||||
|
||||
#else
|
||||
ssize_t
|
||||
rb_writev(rb_fde_t *F, struct rb_iovec *vector, int count)
|
||||
rb_writev(rb_fde_t *F, struct rb_iovec * vector, int count)
|
||||
{
|
||||
if(F == NULL) {
|
||||
if(F == NULL)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1129,23 +1130,23 @@ inetntoa(const char *in)
|
|||
{
|
||||
static char buf[16];
|
||||
char *bufptr = buf;
|
||||
const unsigned char *a = (const unsigned char *) in;
|
||||
const unsigned char *a = (const unsigned char *)in;
|
||||
const char *n;
|
||||
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
while(*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
while(*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
while(*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a];
|
||||
while (*n)
|
||||
while(*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr = '\0';
|
||||
return buf;
|
||||
|
@ -1176,9 +1177,9 @@ inetntoa(const char *in)
|
|||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static const char *inet_ntop4(const unsigned char * src, char *dst, unsigned int size);
|
||||
static const char *inet_ntop4(const unsigned char *src, char *dst, unsigned int size);
|
||||
#ifdef RB_IPV6
|
||||
static const char *inet_ntop6(const unsigned char * src, char *dst, unsigned int size);
|
||||
static const char *inet_ntop6(const unsigned char *src, char *dst, unsigned int size);
|
||||
#endif
|
||||
|
||||
/* const char *
|
||||
|
@ -1197,7 +1198,7 @@ inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
|
|||
{
|
||||
if(size < 16)
|
||||
return NULL;
|
||||
return strcpy(dst, inetntoa((const char *) src));
|
||||
return strcpy(dst, inetntoa((const char *)src));
|
||||
}
|
||||
|
||||
/* const char *
|
||||
|
@ -1232,13 +1233,13 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
|
|||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof words);
|
||||
for (i = 0; i < IN6ADDRSZ; i += 2)
|
||||
for(i = 0; i < IN6ADDRSZ; i += 2)
|
||||
words[i / 2] = (src[i] << 8) | src[i + 1];
|
||||
best.base = -1;
|
||||
best.len = 0;
|
||||
cur.base = -1;
|
||||
cur.len = 0;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
{
|
||||
if(words[i] == 0)
|
||||
{
|
||||
|
@ -1269,7 +1270,7 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
|
|||
* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
{
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if(best.base != -1 && i >= best.base && i < (best.base + best.len))
|
||||
|
@ -1305,7 +1306,7 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
|
|||
* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
|
||||
if((unsigned int) (tp - tmp) > size)
|
||||
if((unsigned int)(tp - tmp) > size)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -1316,18 +1317,18 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
|
|||
int
|
||||
rb_inet_pton_sock(const char *src, struct sockaddr *dst)
|
||||
{
|
||||
if(rb_inet_pton(AF_INET, src, &((struct sockaddr_in *) dst)->sin_addr))
|
||||
if(rb_inet_pton(AF_INET, src, &((struct sockaddr_in *)dst)->sin_addr))
|
||||
{
|
||||
((struct sockaddr_in *) dst)->sin_port = 0;
|
||||
((struct sockaddr_in *) dst)->sin_family = AF_INET;
|
||||
((struct sockaddr_in *)dst)->sin_port = 0;
|
||||
((struct sockaddr_in *)dst)->sin_family = AF_INET;
|
||||
SET_SS_LEN(dst, sizeof(struct sockaddr_in));
|
||||
return 1;
|
||||
}
|
||||
#ifdef RB_IPV6
|
||||
else if(rb_inet_pton(AF_INET6, src, &((struct sockaddr_in6 *) dst)->sin6_addr))
|
||||
else if(rb_inet_pton(AF_INET6, src, &((struct sockaddr_in6 *)dst)->sin6_addr))
|
||||
{
|
||||
((struct sockaddr_in6 *) dst)->sin6_port = 0;
|
||||
((struct sockaddr_in6 *) dst)->sin6_family = AF_INET6;
|
||||
((struct sockaddr_in6 *)dst)->sin6_port = 0;
|
||||
((struct sockaddr_in6 *)dst)->sin6_family = AF_INET6;
|
||||
SET_SS_LEN(dst, sizeof(struct sockaddr_in6));
|
||||
return 1;
|
||||
}
|
||||
|
@ -1341,11 +1342,12 @@ rb_inet_ntop_sock(struct sockaddr *src, char *dst, unsigned int size)
|
|||
switch (src->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
return (rb_inet_ntop(AF_INET, &((struct sockaddr_in *) src)->sin_addr, dst, size));
|
||||
return (rb_inet_ntop(AF_INET, &((struct sockaddr_in *)src)->sin_addr, dst, size));
|
||||
break;
|
||||
#ifdef RB_IPV6
|
||||
case AF_INET6:
|
||||
return (rb_inet_ntop(AF_INET6, &((struct sockaddr_in6 *) src)->sin6_addr, dst, size));
|
||||
return (rb_inet_ntop
|
||||
(AF_INET6, &((struct sockaddr_in6 *)src)->sin6_addr, dst, size));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -1371,11 +1373,11 @@ rb_inet_ntop(int af, const void *src, char *dst, unsigned int size)
|
|||
return (inet_ntop4(src, dst, size));
|
||||
#ifdef RB_IPV6
|
||||
case AF_INET6:
|
||||
if(IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) src) ||
|
||||
IN6_IS_ADDR_V4COMPAT((const struct in6_addr *) src))
|
||||
if(IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)src) ||
|
||||
IN6_IS_ADDR_V4COMPAT((const struct in6_addr *)src))
|
||||
return (inet_ntop4
|
||||
((const unsigned char *)
|
||||
&((const struct in6_addr *) src)->s6_addr[12], dst, size));
|
||||
((const unsigned char *)&((const struct in6_addr *)src)->
|
||||
s6_addr[12], dst, size));
|
||||
else
|
||||
return (inet_ntop6(src, dst, size));
|
||||
|
||||
|
@ -1423,7 +1425,7 @@ inet_pton4(const char *src, unsigned char *dst)
|
|||
saw_digit = 0;
|
||||
octets = 0;
|
||||
*(tp = tmp) = 0;
|
||||
while ((ch = *src++) != '\0')
|
||||
while((ch = *src++) != '\0')
|
||||
{
|
||||
|
||||
if(ch >= '0' && ch <= '9')
|
||||
|
@ -1490,7 +1492,7 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||
curtok = src;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
while ((ch = tolower(*src++)) != '\0')
|
||||
while((ch = tolower(*src++)) != '\0')
|
||||
{
|
||||
const char *pch;
|
||||
|
||||
|
@ -1520,8 +1522,8 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||
}
|
||||
if(tp + INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
*tp++ = (unsigned char)(val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char)val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
|
@ -1543,8 +1545,8 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||
{
|
||||
if(tp + INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
*tp++ = (unsigned char)(val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char)val & 0xff;
|
||||
}
|
||||
if(colonp != NULL)
|
||||
{
|
||||
|
@ -1557,7 +1559,7 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||
|
||||
if(tp == endp)
|
||||
return (0);
|
||||
for (i = 1; i <= n; i++)
|
||||
for(i = 1; i <= n; i++)
|
||||
{
|
||||
endp[-i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
|
@ -1597,6 +1599,117 @@ rb_inet_pton(int af, const char *src, void *dst)
|
|||
|
||||
|
||||
#ifndef HAVE_SOCKETPAIR
|
||||
|
||||
/* mostly based on perl's emulation of socketpair udp */
|
||||
static int
|
||||
rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2)
|
||||
{
|
||||
struct sockaddr_in addr[2];
|
||||
rb_socklen_t size = sizeof(struct sockaddr_in);
|
||||
rb_fde_t *F[2];
|
||||
unsigned int fd[2];
|
||||
int i, got;
|
||||
unsigned short port;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
F[i] = rb_socket(AF_INET, SOCK_DGRAM, 0, "udp socketpair");
|
||||
if(F[i] == NULL)
|
||||
goto failed;
|
||||
addr[i].sin_family = AF_INET;
|
||||
addr[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr[i].sin_port = 0;
|
||||
if(bind(rb_get_fd(F[i]), (struct sockaddr *)&addr[i], sizeof(struct sockaddr_in)))
|
||||
goto failed;
|
||||
fd[i] = rb_get_fd(F[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
if(getsockname(fd[i], (struct sockaddr *)&addr[i], &size))
|
||||
goto failed;
|
||||
if(size != sizeof(struct sockaddr_in))
|
||||
goto failed;
|
||||
if(connect(fd[!i], (struct sockaddr *)&addr[i], sizeof(struct sockaddr_in)) == -1)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
port = addr[i].sin_port;
|
||||
got = rb_write(F[i], &port, sizeof(port));
|
||||
if(got != sizeof(port))
|
||||
{
|
||||
if(got == -1)
|
||||
goto failed;
|
||||
goto abort_failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct timeval wait = { 0, 100000 };
|
||||
|
||||
int max = fd[1] > fd[0] ? fd[1] : fd[0];
|
||||
fd_set rset;
|
||||
FD_ZERO(&rset);
|
||||
FD_SET(fd[0], &rset);
|
||||
FD_SET(fd[1], &rset);
|
||||
got = select(max + 1, &rset, NULL, NULL, &wait);
|
||||
if(got != 2 || !FD_ISSET(fd[0], &rset) || !FD_ISSET(fd[1], &rset))
|
||||
{
|
||||
if(got == -1)
|
||||
goto failed;
|
||||
goto abort_failed;
|
||||
}
|
||||
|
||||
struct sockaddr_in readfrom;
|
||||
unsigned short buf[2];
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
#ifdef MSG_DONTWAIT
|
||||
int flag = MSG_DONTWAIT
|
||||
#else
|
||||
int flag = 0;
|
||||
#endif
|
||||
got = recvfrom(rb_get_fd(F[i]), (char *)&buf, sizeof(buf), flag,
|
||||
(struct sockaddr *)&readfrom, &size);
|
||||
if(got == -1)
|
||||
goto failed;
|
||||
if(got != sizeof(port)
|
||||
|| size != sizeof(struct sockaddr_in)
|
||||
|| buf[0] != (unsigned short)addr[!i].sin_port
|
||||
|| readfrom.sin_family != addr[!i].sin_family
|
||||
|| readfrom.sin_addr.s_addr != addr[!i].sin_addr.s_addr
|
||||
|| readfrom.sin_port != addr[!i].sin_port)
|
||||
goto abort_failed;
|
||||
}
|
||||
|
||||
*newF1 = F[0];
|
||||
*newF2 = F[1];
|
||||
return 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ECONNABORTED WSAECONNABORTED
|
||||
#endif
|
||||
|
||||
abort_failed:
|
||||
rb_get_errno();
|
||||
errno = ECONNABORTED;
|
||||
failed:
|
||||
if(errno != ECONNABORTED)
|
||||
rb_get_errno();
|
||||
int o_errno = errno;
|
||||
if(F[0] != NULL)
|
||||
rb_close(F[0]);
|
||||
if(F[1] != NULL)
|
||||
rb_close(F[1]);
|
||||
errno = o_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rb_inet_socketpair(int family, int type, int protocol, int fd[2])
|
||||
{
|
||||
|
@ -1605,7 +1718,7 @@ rb_inet_socketpair(int family, int type, int protocol, int fd[2])
|
|||
int acceptor = -1;
|
||||
struct sockaddr_in listen_addr;
|
||||
struct sockaddr_in connect_addr;
|
||||
size_t size;
|
||||
rb_socklen_t size;
|
||||
|
||||
if(protocol || family != AF_INET)
|
||||
{
|
||||
|
@ -1625,7 +1738,7 @@ rb_inet_socketpair(int family, int type, int protocol, int fd[2])
|
|||
listen_addr.sin_family = AF_INET;
|
||||
listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
listen_addr.sin_port = 0; /* kernel choses port. */
|
||||
if(bind(listener, (struct sockaddr *) &listen_addr, sizeof(listen_addr)) == -1)
|
||||
if(bind(listener, (struct sockaddr *)&listen_addr, sizeof(listen_addr)) == -1)
|
||||
goto tidy_up_and_fail;
|
||||
if(listen(listener, 1) == -1)
|
||||
goto tidy_up_and_fail;
|
||||
|
@ -1635,15 +1748,15 @@ rb_inet_socketpair(int family, int type, int protocol, int fd[2])
|
|||
goto tidy_up_and_fail;
|
||||
/* We want to find out the port number to connect to. */
|
||||
size = sizeof(connect_addr);
|
||||
if(getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1)
|
||||
if(getsockname(listener, (struct sockaddr *)&connect_addr, &size) == -1)
|
||||
goto tidy_up_and_fail;
|
||||
if(size != sizeof(connect_addr))
|
||||
goto abort_tidy_up_and_fail;
|
||||
if(connect(connector, (struct sockaddr *) &connect_addr, sizeof(connect_addr)) == -1)
|
||||
if(connect(connector, (struct sockaddr *)&connect_addr, sizeof(connect_addr)) == -1)
|
||||
goto tidy_up_and_fail;
|
||||
|
||||
size = sizeof(listen_addr);
|
||||
acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size);
|
||||
acceptor = accept(listener, (struct sockaddr *)&listen_addr, &size);
|
||||
if(acceptor == -1)
|
||||
goto tidy_up_and_fail;
|
||||
if(size != sizeof(listen_addr))
|
||||
|
@ -1651,7 +1764,7 @@ rb_inet_socketpair(int family, int type, int protocol, int fd[2])
|
|||
close(listener);
|
||||
/* Now check we are talking to ourself by matching port and host on the
|
||||
two sockets. */
|
||||
if(getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1)
|
||||
if(getsockname(connector, (struct sockaddr *)&connect_addr, &size) == -1)
|
||||
goto tidy_up_and_fail;
|
||||
if(size != sizeof(connect_addr)
|
||||
|| listen_addr.sin_family != connect_addr.sin_family
|
||||
|
@ -1854,7 +1967,8 @@ try_select(void)
|
|||
int
|
||||
rb_io_sched_event(struct ev_entry *ev, int when)
|
||||
{
|
||||
if(ev == NULL || io_supports_event == NULL || io_sched_event == NULL || !io_supports_event())
|
||||
if(ev == NULL || io_supports_event == NULL || io_sched_event == NULL
|
||||
|| !io_supports_event())
|
||||
return 0;
|
||||
return io_sched_event(ev, when);
|
||||
}
|
||||
|
@ -1862,10 +1976,12 @@ rb_io_sched_event(struct ev_entry *ev, int when)
|
|||
void
|
||||
rb_io_unsched_event(struct ev_entry *ev)
|
||||
{
|
||||
if(ev == NULL || io_supports_event == NULL || io_unsched_event == NULL || !io_supports_event())
|
||||
if(ev == NULL || io_supports_event == NULL || io_unsched_event == NULL
|
||||
|| !io_supports_event())
|
||||
return;
|
||||
io_unsched_event(ev);
|
||||
}
|
||||
|
||||
int
|
||||
rb_io_supports_event(void)
|
||||
{
|
||||
|
@ -1894,42 +2010,42 @@ rb_init_netio(void)
|
|||
{
|
||||
if(!try_epoll())
|
||||
return;
|
||||
} else
|
||||
if(!strcmp("kqueue", ioenv))
|
||||
}
|
||||
else if(!strcmp("kqueue", ioenv))
|
||||
{
|
||||
if(!try_kqueue())
|
||||
return;
|
||||
} else
|
||||
if(!strcmp("ports", ioenv))
|
||||
}
|
||||
else if(!strcmp("ports", ioenv))
|
||||
{
|
||||
if(!try_ports())
|
||||
return;
|
||||
} else
|
||||
if(!strcmp("poll", ioenv))
|
||||
}
|
||||
else if(!strcmp("poll", ioenv))
|
||||
{
|
||||
if(!try_poll())
|
||||
return;
|
||||
} else
|
||||
if(!strcmp("devpoll", ioenv))
|
||||
}
|
||||
else if(!strcmp("devpoll", ioenv))
|
||||
{
|
||||
if(!try_devpoll())
|
||||
return;
|
||||
} else
|
||||
if(!strcmp("sigio", ioenv))
|
||||
}
|
||||
else if(!strcmp("sigio", ioenv))
|
||||
{
|
||||
if(!try_sigio())
|
||||
return;
|
||||
} else
|
||||
}
|
||||
else if(!strcmp("select", ioenv))
|
||||
{
|
||||
if(!try_select())
|
||||
return;
|
||||
}
|
||||
if(!strcmp("win32", ioenv))
|
||||
{
|
||||
if(!try_win32())
|
||||
return;
|
||||
}
|
||||
if(!strcmp("select", ioenv))
|
||||
{
|
||||
if(!try_select())
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1980,7 +2096,7 @@ rb_setup_fd(rb_fde_t *F)
|
|||
int
|
||||
rb_ignore_errno(int error)
|
||||
{
|
||||
switch(error)
|
||||
switch (error)
|
||||
{
|
||||
#ifdef EINPROGRESS
|
||||
case EINPROGRESS:
|
||||
|
@ -2008,6 +2124,7 @@ rb_ignore_errno(int error)
|
|||
}
|
||||
|
||||
|
||||
#if defined(HAVE_SENDMSG) && !defined(WIN32)
|
||||
int
|
||||
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
|
||||
{
|
||||
|
@ -2036,7 +2153,8 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds
|
|||
if((len = recvmsg(rb_get_fd(F), &msg, 0)) <= 0)
|
||||
return len;
|
||||
|
||||
if(msg.msg_controllen > 0 && msg.msg_control != NULL && (cmsg = CMSG_FIRSTHDR(&msg)) != NULL)
|
||||
if(msg.msg_controllen > 0 && msg.msg_control != NULL
|
||||
&& (cmsg = CMSG_FIRSTHDR(&msg)) != NULL)
|
||||
{
|
||||
rfds = (msg.msg_controllen - sizeof(struct cmsghdr)) / sizeof(int);
|
||||
|
||||
|
@ -2065,14 +2183,15 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds
|
|||
}
|
||||
xF[x] = rb_open(fd, stype, desc);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
*xF = NULL;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize)
|
||||
rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid)
|
||||
{
|
||||
int n;
|
||||
struct msghdr msg;
|
||||
|
@ -2086,7 +2205,9 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
|
|||
{
|
||||
iov[0].iov_base = ∅
|
||||
iov[0].iov_len = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
iov[0].iov_base = data;
|
||||
iov[0].iov_len = datasize;
|
||||
}
|
||||
|
@ -2120,4 +2241,20 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
|
|||
n = sendmsg(rb_get_fd(xF), &msg, MSG_NOSIGNAL);
|
||||
return n;
|
||||
}
|
||||
#else
|
||||
#ifndef _WIN32
|
||||
int
|
||||
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,7 +22,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: devpoll.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: devpoll.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
@ -68,7 +68,8 @@ devpoll_write_update(int fd, int events)
|
|||
/* Write the thing to our poll fd */
|
||||
retval = write(dpfd, &pollfds[0], sizeof(struct pollfd));
|
||||
if(retval != sizeof(struct pollfd))
|
||||
rb_lib_log("devpoll_write_update: dpfd write failed %d: %s", errno, strerror(errno));
|
||||
rb_lib_log("devpoll_write_update: dpfd write failed %d: %s", errno,
|
||||
strerror(errno));
|
||||
/* Done! */
|
||||
}
|
||||
|
||||
|
@ -162,8 +163,7 @@ rb_init_netio_devpoll(void)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_devpoll(rb_fde_t *F, unsigned int type, PF * handler,
|
||||
void *client_data)
|
||||
rb_setselect_devpoll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
lrb_assert(IsFDOpen(F));
|
||||
|
||||
|
@ -205,7 +205,7 @@ rb_select_devpoll(long delay)
|
|||
|
||||
do
|
||||
{
|
||||
for (;;)
|
||||
for(;;)
|
||||
{
|
||||
dopoll.dp_timeout = delay;
|
||||
dopoll.dp_nfds = maxfd;
|
||||
|
@ -223,13 +223,12 @@ rb_select_devpoll(long delay)
|
|||
if(num == 0)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
int fd = dopoll.dp_fds[i].fd;
|
||||
PF *hdl = NULL;
|
||||
rb_fde_t *F = rb_find_fd(fd);
|
||||
if((dopoll.dp_fds[i].
|
||||
revents & (POLLRDNORM | POLLIN | POLLHUP |
|
||||
if((dopoll.dp_fds[i].revents & (POLLRDNORM | POLLIN | POLLHUP |
|
||||
POLLERR))
|
||||
&& (dopoll.dp_fds[i].events & (POLLRDNORM | POLLIN)))
|
||||
{
|
||||
|
@ -243,15 +242,13 @@ rb_select_devpoll(long delay)
|
|||
* poll set *if* the handler changes state (active ->
|
||||
* NULL or vice versa.)
|
||||
*/
|
||||
devpoll_update_events(fd,
|
||||
RB_SELECT_READ, F->read_handler);
|
||||
devpoll_update_events(fd, RB_SELECT_READ, F->read_handler);
|
||||
}
|
||||
}
|
||||
|
||||
if(!IsFDOpen(F))
|
||||
continue; /* Read handler closed us..go on to do something more useful */
|
||||
if((dopoll.dp_fds[i].
|
||||
revents & (POLLWRNORM | POLLOUT | POLLHUP |
|
||||
if((dopoll.dp_fds[i].revents & (POLLWRNORM | POLLOUT | POLLHUP |
|
||||
POLLERR))
|
||||
&& (dopoll.dp_fds[i].events & (POLLWRNORM | POLLOUT)))
|
||||
{
|
||||
|
@ -268,7 +265,7 @@ rb_select_devpoll(long delay)
|
|||
}
|
||||
return RB_OK;
|
||||
}
|
||||
while (0);
|
||||
while(0);
|
||||
/* XXX Get here, we broke! */
|
||||
return 0;
|
||||
}
|
||||
|
@ -301,4 +298,3 @@ rb_setup_fd_devpoll(rb_fde_t *F)
|
|||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: epoll.c 25675 2008-07-06 04:13:05Z androsyn $
|
||||
* $Id: epoll.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
|||
#include <ratbox_lib.h>
|
||||
#include <commio-int.h>
|
||||
#include <event-int.h>
|
||||
|
||||
#if defined(HAVE_EPOLL_CTL) && (HAVE_SYS_EPOLL_H)
|
||||
#define USING_EPOLL
|
||||
#include <fcntl.h>
|
||||
|
@ -44,6 +43,10 @@
|
|||
#define EPOLL_SCHED_EVENT 1
|
||||
#endif
|
||||
|
||||
#if defined(USE_TIMERFD_CREATE)
|
||||
#include <sys/timerfd.h>
|
||||
#endif
|
||||
|
||||
#define RTSIGNAL SIGRTMIN
|
||||
struct epoll_info
|
||||
{
|
||||
|
@ -54,8 +57,7 @@ struct epoll_info
|
|||
|
||||
static struct epoll_info *ep_info;
|
||||
static int can_do_event;
|
||||
|
||||
//static void setup_signalfd(void);
|
||||
static int can_do_timerfd;
|
||||
|
||||
/*
|
||||
* rb_init_netio
|
||||
|
@ -81,7 +83,7 @@ rb_init_netio_epoll(void)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_epoll(rb_fde_t * F)
|
||||
rb_setup_fd_epoll(rb_fde_t *F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,7 +96,7 @@ rb_setup_fd_epoll(rb_fde_t * F)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_epoll(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_epoll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
struct epoll_event ep_event;
|
||||
int old_flags = F->pflags;
|
||||
|
@ -180,7 +182,7 @@ rb_select_epoll(long delay)
|
|||
if(num <= 0)
|
||||
return RB_OK;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
PF *hdl;
|
||||
rb_fde_t *F = ep_info->pfd[i].data.ptr;
|
||||
|
@ -259,6 +261,16 @@ rb_epoll_supports_event(void)
|
|||
if(can_do_event == -1)
|
||||
return 0;
|
||||
|
||||
#ifdef USE_TIMERFD_CREATE
|
||||
if((fd = timerfd_create(CLOCK_REALTIME, 0)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
can_do_event = 1;
|
||||
can_do_timerfd = 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ev.sigev_signo = SIGVTALRM;
|
||||
ev.sigev_notify = SIGEV_SIGNAL;
|
||||
if(timer_create(CLOCK_REALTIME, &ev, &timer) != 0)
|
||||
|
@ -281,7 +293,8 @@ rb_epoll_supports_event(void)
|
|||
|
||||
|
||||
/* bleh..work around a glibc header bug on 32bit systems */
|
||||
struct our_signalfd_siginfo {
|
||||
struct our_signalfd_siginfo
|
||||
{
|
||||
uint32_t signo;
|
||||
int32_t err;
|
||||
int32_t code;
|
||||
|
@ -332,9 +345,9 @@ signalfd_handler(rb_fde_t *F, void *data)
|
|||
rb_setselect(F, RB_SELECT_READ, signalfd_handler, NULL);
|
||||
return;
|
||||
}
|
||||
for(x = 0; x < ret / (int)sizeof(struct signalfd_siginfo); x++)
|
||||
for(x = 0; x < ret / (int)sizeof(struct our_signalfd_siginfo); x++)
|
||||
{
|
||||
ev = (struct ev_entry *)fdsig[x].svptr;
|
||||
ev = (struct ev_entry *)((uintptr_t)fdsig[x].svptr);
|
||||
if(ev == NULL)
|
||||
continue;
|
||||
rb_run_event(ev);
|
||||
|
@ -345,26 +358,32 @@ signalfd_handler(rb_fde_t *F, void *data)
|
|||
void
|
||||
rb_epoll_init_event(void)
|
||||
{
|
||||
|
||||
sigset_t ss;
|
||||
rb_fde_t *F;
|
||||
int sfd;
|
||||
rb_epoll_supports_event();
|
||||
if(!can_do_timerfd)
|
||||
{
|
||||
sigemptyset(&ss);
|
||||
sigaddset(&ss, RTSIGNAL);
|
||||
sigprocmask(SIG_BLOCK, &ss, 0);
|
||||
sigemptyset(&ss);
|
||||
sigaddset(&ss, RTSIGNAL);
|
||||
sfd = signalfd(-1, &ss, 0);
|
||||
if(sfd == -1) {
|
||||
if(sfd == -1)
|
||||
{
|
||||
can_do_event = -1;
|
||||
return;
|
||||
}
|
||||
F = rb_open(sfd, RB_FD_UNKNOWN, "signalfd");
|
||||
rb_set_nb(F);
|
||||
signalfd_handler(F, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_epoll_sched_event(struct ev_entry *event, int when)
|
||||
static int
|
||||
rb_epoll_sched_event_signalfd(struct ev_entry *event, int when)
|
||||
{
|
||||
timer_t *id;
|
||||
struct sigevent ev;
|
||||
|
@ -377,7 +396,7 @@ rb_epoll_sched_event(struct ev_entry *event, int when)
|
|||
ev.sigev_signo = RTSIGNAL;
|
||||
ev.sigev_value.sival_ptr = event;
|
||||
|
||||
if (timer_create(CLOCK_REALTIME, &ev, id) < 0)
|
||||
if(timer_create(CLOCK_REALTIME, &ev, id) < 0)
|
||||
{
|
||||
rb_lib_log("timer_create: %s\n", strerror(errno));
|
||||
return 0;
|
||||
|
@ -396,10 +415,94 @@ rb_epoll_sched_event(struct ev_entry *event, int when)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef USE_TIMERFD_CREATE
|
||||
static void
|
||||
rb_read_timerfd(rb_fde_t *F, void *data)
|
||||
{
|
||||
struct ev_entry *event = (struct ev_entry *)data;
|
||||
int retlen;
|
||||
uint64_t count;
|
||||
|
||||
if(event == NULL)
|
||||
{
|
||||
rb_close(F);
|
||||
return;
|
||||
}
|
||||
|
||||
retlen = rb_read(F, &count, sizeof(count));
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
|
||||
{
|
||||
rb_close(F);
|
||||
rb_lib_log("rb_read_timerfd: timerfd[%s] closed on error: %s", event->name,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
rb_setselect(F, RB_SELECT_READ, rb_read_timerfd, event);
|
||||
rb_run_event(event);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
rb_epoll_sched_event_timerfd(struct ev_entry *event, int when)
|
||||
{
|
||||
struct itimerspec ts;
|
||||
static char buf[FD_DESC_SZ + 8];
|
||||
int fd;
|
||||
rb_fde_t *F;
|
||||
|
||||
if((fd = timerfd_create(CLOCK_REALTIME, 0)) < 0)
|
||||
{
|
||||
rb_lib_log("timerfd_create: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&ts, 0, sizeof(ts));
|
||||
ts.it_value.tv_sec = when;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
if(event->frequency != 0)
|
||||
ts.it_interval = ts.it_value;
|
||||
|
||||
if(timerfd_settime(fd, 0, &ts, NULL) < 0)
|
||||
{
|
||||
rb_lib_log("timerfd_settime: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
rb_setselect(F, RB_SELECT_READ, rb_read_timerfd, event);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int
|
||||
rb_epoll_sched_event(struct ev_entry *event, int when)
|
||||
{
|
||||
#ifdef USE_TIMERFD_CREATE
|
||||
if(can_do_timerfd)
|
||||
{
|
||||
return rb_epoll_sched_event_timerfd(event, when);
|
||||
}
|
||||
#endif
|
||||
return rb_epoll_sched_event_signalfd(event, when);
|
||||
}
|
||||
|
||||
void
|
||||
rb_epoll_unsched_event(struct ev_entry *event)
|
||||
{
|
||||
timer_delete(*((timer_t *)event->comm_ptr));
|
||||
#ifdef USE_TIMERFD_CREATE
|
||||
if(can_do_timerfd)
|
||||
{
|
||||
rb_close((rb_fde_t *)event->comm_ptr);
|
||||
event->comm_ptr = NULL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
timer_delete(*((timer_t *) event->comm_ptr));
|
||||
rb_free(event->comm_ptr);
|
||||
event->comm_ptr = NULL;
|
||||
}
|
||||
|
@ -413,7 +516,7 @@ rb_init_netio_epoll(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_epoll(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_epoll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return;
|
||||
|
@ -427,7 +530,7 @@ rb_select_epoll(long delay)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_epoll(rb_fde_t * F)
|
||||
rb_setup_fd_epoll(rb_fde_t *F)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
@ -437,7 +540,8 @@ rb_setup_fd_epoll(rb_fde_t * F)
|
|||
#endif
|
||||
|
||||
#if !defined(USING_EPOLL) || !defined(EPOLL_SCHED_EVENT)
|
||||
void rb_epoll_init_event(void)
|
||||
void
|
||||
rb_epoll_init_event(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: event.c 25147 2008-03-28 17:15:47Z androsyn $
|
||||
* $Id: event.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -47,24 +47,11 @@
|
|||
#include <commio-int.h>
|
||||
#include <event-int.h>
|
||||
|
||||
static const char *last_event_ran = NULL;
|
||||
#define EV_NAME_LEN 33
|
||||
static char last_event_ran[EV_NAME_LEN];
|
||||
static rb_dlink_list event_list;
|
||||
|
||||
static time_t event_time_min = -1;
|
||||
/* The list of event processes */
|
||||
|
||||
#if 0
|
||||
struct ev_entry
|
||||
{
|
||||
rb_dlink_node node;
|
||||
EVH *func;
|
||||
void *arg;
|
||||
const char *name;
|
||||
time_t frequency;
|
||||
time_t when;
|
||||
void *data;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* struct ev_entry *
|
||||
|
@ -104,7 +91,7 @@ rb_event_add(const char *name, EVH * func, void *arg, time_t when)
|
|||
struct ev_entry *ev;
|
||||
ev = rb_malloc(sizeof(struct ev_entry));
|
||||
ev->func = func;
|
||||
ev->name = name;
|
||||
ev->name = rb_strndup(name, EV_NAME_LEN);
|
||||
ev->arg = arg;
|
||||
ev->when = rb_current_time() + when;
|
||||
ev->frequency = when;
|
||||
|
@ -117,13 +104,14 @@ rb_event_add(const char *name, EVH * func, void *arg, time_t when)
|
|||
rb_io_sched_event(ev, when);
|
||||
return ev;
|
||||
}
|
||||
|
||||
struct ev_entry *
|
||||
rb_event_addonce(const char *name, EVH * func, void *arg, time_t when)
|
||||
{
|
||||
struct ev_entry *ev;
|
||||
ev = rb_malloc(sizeof(struct ev_entry));
|
||||
ev->func = func;
|
||||
ev->name = name;
|
||||
ev->name = rb_strndup(name, EV_NAME_LEN);
|
||||
ev->arg = arg;
|
||||
ev->when = rb_current_time() + when;
|
||||
ev->frequency = 0;
|
||||
|
@ -151,6 +139,7 @@ rb_event_delete(struct ev_entry *ev)
|
|||
|
||||
rb_dlinkDelete(&ev->node, &event_list);
|
||||
rb_io_unsched_event(ev);
|
||||
rb_free(ev->name);
|
||||
rb_free(ev);
|
||||
}
|
||||
|
||||
|
@ -162,7 +151,7 @@ rb_event_delete(struct ev_entry *ev)
|
|||
* Side Effects: Removes the event from the event list
|
||||
*/
|
||||
void
|
||||
rb_event_find_delete(EVH *func, void *arg)
|
||||
rb_event_find_delete(EVH * func, void *arg)
|
||||
{
|
||||
rb_event_delete(rb_event_find(func, arg));
|
||||
}
|
||||
|
@ -196,7 +185,7 @@ rb_event_addish(const char *name, EVH * func, void *arg, time_t delta_ish)
|
|||
void
|
||||
rb_run_event(struct ev_entry *ev)
|
||||
{
|
||||
last_event_ran = ev->name;
|
||||
rb_strlcpy(last_event_ran, ev->name, sizeof(last_event_ran));
|
||||
ev->func(ev->arg);
|
||||
if(!ev->frequency)
|
||||
{
|
||||
|
@ -232,7 +221,7 @@ rb_event_run(void)
|
|||
ev = ptr->data;
|
||||
if(ev->when <= rb_current_time())
|
||||
{
|
||||
last_event_ran = ev->name;
|
||||
rb_strlcpy(last_event_ran, ev->name, sizeof(last_event_ran));
|
||||
ev->func(ev->arg);
|
||||
|
||||
/* event is scheduled more than once */
|
||||
|
@ -247,7 +236,9 @@ rb_event_run(void)
|
|||
rb_dlinkDelete(&ev->node, &event_list);
|
||||
rb_free(ev);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if((ev->when < event_time_min) || (event_time_min == -1))
|
||||
event_time_min = ev->when;
|
||||
}
|
||||
|
@ -270,6 +261,7 @@ rb_event_io_register_all(void)
|
|||
rb_io_sched_event(ev, when);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* void rb_event_init(void)
|
||||
*
|
||||
|
@ -280,7 +272,7 @@ rb_event_io_register_all(void)
|
|||
void
|
||||
rb_event_init(void)
|
||||
{
|
||||
last_event_ran = NULL;
|
||||
rb_strlcpy(last_event_ran, "NONE", sizeof(last_event_ran));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -291,11 +283,10 @@ rb_dump_events(void (*func) (char *, void *), void *ptr)
|
|||
rb_dlink_node *dptr;
|
||||
struct ev_entry *ev;
|
||||
len = sizeof(buf);
|
||||
if(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);
|
||||
func(buf, ptr);
|
||||
|
||||
|
@ -303,7 +294,7 @@ rb_dump_events(void (*func) (char *, void *), void *ptr)
|
|||
{
|
||||
ev = dptr->data;
|
||||
rb_snprintf(buf, len, "%-28s %-4ld seconds", ev->name,
|
||||
ev->when - (long) rb_current_time());
|
||||
ev->when - (long)rb_current_time());
|
||||
func(buf, ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,3 +146,10 @@ rb_supports_ssl
|
|||
rb_ssl_handshake_count
|
||||
rb_ssl_clear_handshake_count
|
||||
rb_get_pseudo_random
|
||||
rb_strerror
|
||||
rb_kill
|
||||
rb_setenv
|
||||
rb_getpid
|
||||
rb_waitpid
|
||||
rb_basename
|
||||
rb_dirname
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: gnutls.c 25793 2008-07-29 14:47:48Z androsyn $
|
||||
* $Id: gnutls.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -40,12 +40,12 @@ static gnutls_dh_params dh_params;
|
|||
#define SSL_P(x) *((gnutls_session_t *)F->ssl)
|
||||
|
||||
void
|
||||
rb_ssl_shutdown(rb_fde_t * F)
|
||||
rb_ssl_shutdown(rb_fde_t *F)
|
||||
{
|
||||
int i;
|
||||
if(F == NULL || F->ssl == NULL)
|
||||
return;
|
||||
for (i = 0; i < 4; i++)
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
if(gnutls_bye(SSL_P(F), GNUTLS_SHUT_RDWR) == GNUTLS_E_SUCCESS)
|
||||
break;
|
||||
|
@ -67,14 +67,15 @@ rb_ssl_clear_handshake_count(rb_fde_t *F)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_timeout(rb_fde_t * F, void *notused)
|
||||
rb_ssl_timeout(rb_fde_t *F, void *notused)
|
||||
{
|
||||
lrb_assert(F->accept != NULL);
|
||||
F->accept->callback(F, RB_ERR_TIMEOUT, NULL, 0, F->accept->data);
|
||||
}
|
||||
|
||||
|
||||
static int do_ssl_handshake(rb_fde_t *F, PF *callback)
|
||||
static int
|
||||
do_ssl_handshake(rb_fde_t *F, PF * callback)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
@ -98,7 +99,7 @@ static int do_ssl_handshake(rb_fde_t *F, PF *callback)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryaccept(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryaccept(rb_fde_t *F, void *data)
|
||||
{
|
||||
int ret;
|
||||
struct acceptdata *ad;
|
||||
|
@ -107,7 +108,7 @@ rb_ssl_tryaccept(rb_fde_t * F, void *data)
|
|||
|
||||
ret = do_ssl_handshake(F, rb_ssl_tryaccept);
|
||||
|
||||
switch(ret)
|
||||
switch (ret)
|
||||
{
|
||||
case -1:
|
||||
F->accept->callback(F, RB_ERROR_SSL, NULL, 0, F->accept->data);
|
||||
|
@ -125,14 +126,13 @@ rb_ssl_tryaccept(rb_fde_t * F, void *data)
|
|||
|
||||
ad = F->accept;
|
||||
F->accept = NULL;
|
||||
ad->callback(F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen,
|
||||
ad->data);
|
||||
ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data);
|
||||
rb_free(ad);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
|
||||
rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
|
||||
{
|
||||
gnutls_session_t *ssl;
|
||||
new_F->type |= RB_FD_SSL;
|
||||
|
@ -154,7 +154,7 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
|
|||
{
|
||||
struct acceptdata *ad = new_F->accept;
|
||||
new_F->accept = NULL;
|
||||
ad->callback(new_F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen, ad->data);
|
||||
ad->callback(new_F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data);
|
||||
rb_free(ad);
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
|
|||
|
||||
|
||||
void
|
||||
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
{
|
||||
new_F->type |= RB_FD_SSL;
|
||||
new_F->ssl = rb_malloc(sizeof(gnutls_session_t));
|
||||
|
@ -176,7 +176,7 @@ rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addr
|
|||
memcpy(&new_F->accept->S, st, addrlen);
|
||||
new_F->accept->addrlen = addrlen;
|
||||
|
||||
gnutls_init((gnutls_session_t *)new_F->ssl, GNUTLS_SERVER);
|
||||
gnutls_init((gnutls_session_t *) new_F->ssl, GNUTLS_SERVER);
|
||||
gnutls_set_default_priority(SSL_P(new_F));
|
||||
gnutls_credentials_set(SSL_P(new_F), GNUTLS_CRD_CERTIFICATE, x509);
|
||||
gnutls_dh_set_prime_bits(SSL_P(new_F), 1024);
|
||||
|
@ -185,7 +185,7 @@ rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addr
|
|||
{
|
||||
struct acceptdata *ad = F->accept;
|
||||
F->accept = NULL;
|
||||
ad->callback(F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen, ad->data);
|
||||
ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data);
|
||||
rb_free(ad);
|
||||
}
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addr
|
|||
|
||||
|
||||
static ssize_t
|
||||
rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, size_t count)
|
||||
rb_ssl_read_or_write(int r_or_w, rb_fde_t *F, void *rbuf, const void *wbuf, size_t count)
|
||||
{
|
||||
ssize_t ret;
|
||||
gnutls_session_t *ssl = F->ssl;
|
||||
|
@ -206,7 +206,7 @@ rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, siz
|
|||
|
||||
if(ret < 0)
|
||||
{
|
||||
switch(ret)
|
||||
switch (ret)
|
||||
{
|
||||
case GNUTLS_E_AGAIN:
|
||||
case GNUTLS_E_INTERRUPTED:
|
||||
|
@ -228,13 +228,13 @@ rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, siz
|
|||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
|
||||
rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
|
||||
{
|
||||
return rb_ssl_read_or_write(0, F, buf, NULL, count);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
|
||||
rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
|
||||
{
|
||||
return rb_ssl_read_or_write(1, F, NULL, buf, count);
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ rb_init_ssl(void)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_free_datum_t(gnutls_datum_t *d)
|
||||
rb_free_datum_t(gnutls_datum_t * d)
|
||||
{
|
||||
rb_free(d->data);
|
||||
rb_free(d);
|
||||
|
@ -314,9 +314,12 @@ rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
|
|||
}
|
||||
|
||||
|
||||
if((ret = gnutls_certificate_set_x509_key_mem(x509, d_cert, d_key, GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS)
|
||||
if((ret =
|
||||
gnutls_certificate_set_x509_key_mem(x509, d_cert, d_key,
|
||||
GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS)
|
||||
{
|
||||
rb_lib_log("rb_setup_ssl_server: Error loading certificate or key file: %s", gnutls_strerror(ret));
|
||||
rb_lib_log("rb_setup_ssl_server: Error loading certificate or key file: %s",
|
||||
gnutls_strerror(ret));
|
||||
return 0;
|
||||
}
|
||||
rb_free_datum_t(d_cert);
|
||||
|
@ -331,20 +334,24 @@ rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
|
|||
data = rb_load_file_into_datum_t(dhfile);
|
||||
if(data != NULL)
|
||||
{
|
||||
xret = gnutls_dh_params_import_pkcs3(dh_params, data, GNUTLS_X509_FMT_PEM);
|
||||
xret = gnutls_dh_params_import_pkcs3(dh_params, data,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
if(xret < 0)
|
||||
rb_lib_log("rb_setup_ssl_server: Error parsing DH file: %s\n", gnutls_strerror(xret));
|
||||
rb_lib_log
|
||||
("rb_setup_ssl_server: Error parsing DH file: %s\n",
|
||||
gnutls_strerror(xret));
|
||||
rb_free_datum_t(data);
|
||||
}
|
||||
gnutls_certificate_set_dh_params(x509, dh_params);
|
||||
} else
|
||||
}
|
||||
else
|
||||
rb_lib_log("rb_setup_ssl_server: Unable to setup DH parameters");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rb_ssl_listen(rb_fde_t * F, int backlog)
|
||||
rb_ssl_listen(rb_fde_t *F, int backlog)
|
||||
{
|
||||
F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL;
|
||||
return listen(F->fd, backlog);
|
||||
|
@ -358,7 +365,7 @@ struct ssl_connect
|
|||
};
|
||||
|
||||
static void
|
||||
rb_ssl_connect_realcb(rb_fde_t * F, int status, struct ssl_connect *sconn)
|
||||
rb_ssl_connect_realcb(rb_fde_t *F, int status, struct ssl_connect *sconn)
|
||||
{
|
||||
F->connect->callback = sconn->callback;
|
||||
F->connect->data = sconn->data;
|
||||
|
@ -367,20 +374,20 @@ rb_ssl_connect_realcb(rb_fde_t * F, int status, struct ssl_connect *sconn)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn_timeout_cb(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryconn_timeout_cb(rb_fde_t *F, void *data)
|
||||
{
|
||||
rb_ssl_connect_realcb(F, RB_ERR_TIMEOUT, data);
|
||||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn_cb(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryconn_cb(rb_fde_t *F, void *data)
|
||||
{
|
||||
struct ssl_connect *sconn = data;
|
||||
int ret;
|
||||
|
||||
ret = do_ssl_handshake(F, rb_ssl_tryconn_cb);
|
||||
|
||||
switch(ret)
|
||||
switch (ret)
|
||||
{
|
||||
case -1:
|
||||
rb_ssl_connect_realcb(F, RB_ERROR_SSL, sconn);
|
||||
|
@ -397,7 +404,7 @@ rb_ssl_tryconn_cb(rb_fde_t * F, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
|
||||
rb_ssl_tryconn(rb_fde_t *F, int status, void *data)
|
||||
{
|
||||
struct ssl_connect *sconn = data;
|
||||
if(status != RB_OK)
|
||||
|
@ -423,7 +430,7 @@ rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
|
|||
}
|
||||
|
||||
void
|
||||
rb_connect_tcp_ssl(rb_fde_t * F, struct sockaddr *dest,
|
||||
rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
|
||||
struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
struct ssl_connect *sconn;
|
||||
|
@ -439,7 +446,7 @@ rb_connect_tcp_ssl(rb_fde_t * F, struct sockaddr *dest,
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_connected(rb_fde_t * F, CNCB * callback, void *data, int timeout)
|
||||
rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
struct ssl_connect *sconn;
|
||||
if(F == NULL)
|
||||
|
@ -490,7 +497,7 @@ rb_get_pseudo_random(void *buf, size_t length)
|
|||
}
|
||||
|
||||
const char *
|
||||
rb_get_ssl_strerror(rb_fde_t * F)
|
||||
rb_get_ssl_strerror(rb_fde_t *F)
|
||||
{
|
||||
return gnutls_strerror(F->ssl_errno);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: helper.c 25245 2008-04-21 18:38:23Z androsyn $
|
||||
* $Id: helper.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
@ -41,8 +41,9 @@ struct _rb_helper
|
|||
|
||||
/* setup all the stuff a new child needs */
|
||||
rb_helper *
|
||||
rb_helper_child(rb_helper_cb *read_cb, rb_helper_cb *error_cb, log_cb *ilog, restart_cb *irestart, die_cb *idie,
|
||||
int maxcon, size_t lb_heap_size, size_t dh_size, size_t fd_heap_size)
|
||||
rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog,
|
||||
restart_cb * irestart, die_cb * idie, int maxcon, size_t lb_heap_size,
|
||||
size_t dh_size, size_t fd_heap_size)
|
||||
{
|
||||
rb_helper *helper;
|
||||
int maxfd, x = 0;
|
||||
|
@ -61,7 +62,7 @@ rb_helper_child(rb_helper_cb *read_cb, rb_helper_cb *error_cb, log_cb *ilog, res
|
|||
ofd = (int)strtol(tofd, NULL, 10);
|
||||
maxfd = (int)strtol(tmaxfd, NULL, 10);
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
for(x = 0; x < maxfd; x++)
|
||||
{
|
||||
if(x != ifd && x != ofd)
|
||||
|
@ -102,7 +103,8 @@ rb_helper_child(rb_helper_cb *read_cb, rb_helper_cb *error_cb, log_cb *ilog, res
|
|||
*/
|
||||
|
||||
rb_helper *
|
||||
rb_helper_start(const char *name, const char *fullpath, rb_helper_cb *read_cb, rb_helper_cb *error_cb)
|
||||
rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
|
||||
rb_helper_cb * error_cb)
|
||||
{
|
||||
rb_helper *helper;
|
||||
const char *parv[2];
|
||||
|
@ -138,17 +140,17 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb *read_cb, r
|
|||
rb_set_nb(out_f[0]);
|
||||
rb_set_nb(out_f[1]);
|
||||
|
||||
setenv("IFD", fy, 1);
|
||||
setenv("OFD", fx, 1);
|
||||
setenv("MAXFD", "256", 1);
|
||||
rb_setenv("IFD", fy, 1);
|
||||
rb_setenv("OFD", fx, 1);
|
||||
rb_setenv("MAXFD", "256", 1);
|
||||
|
||||
rb_snprintf(buf, sizeof(buf), "-ircd %s daemon", name);
|
||||
parv[0] = buf;
|
||||
parv[1] = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
SetHandleInformation((HANDLE)rb_get_fd(in_f[1]), HANDLE_FLAG_INHERIT, 1);
|
||||
SetHandleInformation((HANDLE)rb_get_fd(out_f[0]), HANDLE_FLAG_INHERIT, 1);
|
||||
#ifdef _WIN32
|
||||
SetHandleInformation((HANDLE) rb_get_fd(in_f[1]), HANDLE_FLAG_INHERIT, 1);
|
||||
SetHandleInformation((HANDLE) rb_get_fd(out_f[0]), HANDLE_FLAG_INHERIT, 1);
|
||||
#endif
|
||||
|
||||
pid = rb_spawn_process(fullpath, (const char **)parv);
|
||||
|
@ -197,7 +199,8 @@ rb_helper_write_sendq(rb_fde_t *F, void *helper_ptr)
|
|||
{
|
||||
while((retlen = rb_linebuf_flush(F, &helper->sendq)) > 0)
|
||||
;;
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) {
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
|
||||
{
|
||||
rb_helper_restart(helper);
|
||||
return;
|
||||
}
|
||||
|
@ -271,7 +274,7 @@ rb_helper_close(rb_helper *helper)
|
|||
{
|
||||
if(helper == NULL)
|
||||
return;
|
||||
kill(helper->pid, SIGKILL);
|
||||
rb_kill(helper->pid, SIGKILL);
|
||||
rb_close(helper->ifd);
|
||||
rb_close(helper->ofd);
|
||||
rb_free(helper);
|
||||
|
@ -292,4 +295,3 @@ rb_helper_loop(rb_helper *helper, long delay)
|
|||
rb_lib_loop(delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: kqueue.c 25364 2008-05-14 17:55:22Z jilles $
|
||||
* $Id: kqueue.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -63,13 +63,13 @@ static int kqoff; /* offset into the buffer */
|
|||
|
||||
|
||||
int
|
||||
rb_setup_fd_kqueue(rb_fde_t * F)
|
||||
rb_setup_fd_kqueue(rb_fde_t *F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
kq_update_events(rb_fde_t * F, short filter, PF * handler)
|
||||
kq_update_events(rb_fde_t *F, short filter, PF * handler)
|
||||
{
|
||||
PF *cur_handler;
|
||||
int kep_flags;
|
||||
|
@ -103,7 +103,7 @@ kq_update_events(rb_fde_t * F, short filter, PF * handler)
|
|||
kep_flags = EV_DELETE;
|
||||
}
|
||||
|
||||
EV_SET(kep, (uintptr_t) F->fd, filter, kep_flags, 0, 0, (void *) F);
|
||||
EV_SET(kep, (uintptr_t)F->fd, filter, kep_flags, 0, 0, (void *)F);
|
||||
|
||||
if(++kqoff == kqmax)
|
||||
{
|
||||
|
@ -117,13 +117,14 @@ kq_update_events(rb_fde_t * F, short filter, PF * handler)
|
|||
* because that would also return events we cannot
|
||||
* process at this point.
|
||||
*/
|
||||
for (i = 0; i < kqoff; i++)
|
||||
for(i = 0; i < kqoff; i++)
|
||||
{
|
||||
ret = kevent(kq, kqlst + i, 1, NULL, 0, &zero_timespec);
|
||||
/* jdc -- someone needs to do error checking... */
|
||||
/* EBADF is normal here -- jilles */
|
||||
if(ret == -1 && errno != EBADF)
|
||||
rb_lib_log("kq_update_events(): kevent(): %s", strerror(errno));
|
||||
rb_lib_log("kq_update_events(): kevent(): %s",
|
||||
strerror(errno));
|
||||
}
|
||||
kqoff = 0;
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ rb_init_netio_kqueue(void)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_kqueue(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_kqueue(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
lrb_assert(IsFDOpen(F));
|
||||
|
||||
|
@ -209,16 +210,18 @@ rb_select_kqueue(long delay)
|
|||
rb_fde_t *F;
|
||||
|
||||
|
||||
if(delay < 0) {
|
||||
if(delay < 0)
|
||||
{
|
||||
pt = NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
pt = &poll_time;
|
||||
poll_time.tv_sec = delay / 1000;
|
||||
poll_time.tv_nsec = (delay % 1000) * 1000000;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
for(;;)
|
||||
{
|
||||
num = kevent(kq, kqlst, kqoff, kqout, kqmax, pt);
|
||||
kqoff = 0;
|
||||
|
@ -241,7 +244,7 @@ rb_select_kqueue(long delay)
|
|||
if(num == 0)
|
||||
return RB_OK; /* No error.. */
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
PF *hdl = NULL;
|
||||
|
||||
|
@ -305,7 +308,7 @@ rb_kqueue_supports_event(void)
|
|||
ts.tv_nsec = 1000;
|
||||
|
||||
|
||||
EV_SET(&kv, (uintptr_t) 0x0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 1, 0);
|
||||
EV_SET(&kv, (uintptr_t)0x0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 1, 0);
|
||||
if(kevent(xkq, &kv, 1, NULL, 0, NULL) < 0)
|
||||
{
|
||||
can_do_event = -1;
|
||||
|
@ -326,7 +329,7 @@ rb_kqueue_sched_event(struct ev_entry *event, int when)
|
|||
kep_flags = EV_ADD;
|
||||
if(event->frequency == 0)
|
||||
kep_flags |= EV_ONESHOT;
|
||||
EV_SET(&kev, (uintptr_t) event, EVFILT_TIMER, kep_flags, 0, when * 1000, event);
|
||||
EV_SET(&kev, (uintptr_t)event, EVFILT_TIMER, kep_flags, 0, when * 1000, event);
|
||||
if(kevent(kq, &kev, 1, NULL, 0, NULL) < 0)
|
||||
return 0;
|
||||
return 1;
|
||||
|
@ -336,7 +339,7 @@ void
|
|||
rb_kqueue_unsched_event(struct ev_entry *event)
|
||||
{
|
||||
struct kevent kev;
|
||||
EV_SET(&kev, (uintptr_t) event, EVFILT_TIMER, EV_DELETE, 0, 0, event);
|
||||
EV_SET(&kev, (uintptr_t)event, EVFILT_TIMER, EV_DELETE, 0, 0, event);
|
||||
kevent(kq, &kev, 1, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
@ -356,7 +359,7 @@ rb_init_netio_kqueue(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_kqueue(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_kqueue(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return;
|
||||
|
@ -370,7 +373,7 @@ rb_select_kqueue(long delay)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_kqueue(rb_fde_t * F)
|
||||
rb_setup_fd_kqueue(rb_fde_t *F)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: linebuf.c 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: linebuf.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -47,20 +47,14 @@ static int bufline_count = 0;
|
|||
void
|
||||
rb_linebuf_init(size_t heap_size)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_linebuf_heap = rb_bh_create(sizeof(buf_line_t), heap_size, "librb_linebuf_heap");
|
||||
#endif
|
||||
}
|
||||
|
||||
static buf_line_t *
|
||||
rb_linebuf_allocate(void)
|
||||
{
|
||||
buf_line_t *t;
|
||||
#ifndef NOBALLOC
|
||||
t = rb_bh_alloc(rb_linebuf_heap);
|
||||
#else
|
||||
t = rb_malloc(sizeof(buf_line_t));
|
||||
#endif
|
||||
return (t);
|
||||
|
||||
}
|
||||
|
@ -68,11 +62,7 @@ rb_linebuf_allocate(void)
|
|||
static void
|
||||
rb_linebuf_free(buf_line_t * p)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_bh_free(rb_linebuf_heap, p);
|
||||
#else
|
||||
rb_free(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -113,7 +103,7 @@ rb_linebuf_new_line(buf_head_t * bufhead)
|
|||
* We've finished with the given line, so deallocate it
|
||||
*/
|
||||
static void
|
||||
rb_linebuf_done_line(buf_head_t * bufhead, buf_line_t * bufline, rb_dlink_node * node)
|
||||
rb_linebuf_done_line(buf_head_t * bufhead, buf_line_t * bufline, rb_dlink_node *node)
|
||||
{
|
||||
/* Remove it from the linked list */
|
||||
rb_dlinkDestroy(node, &bufhead->list);
|
||||
|
@ -188,7 +178,8 @@ rb_linebuf_donebuf(buf_head_t * bufhead)
|
|||
{
|
||||
while(bufhead->list.head != NULL)
|
||||
{
|
||||
rb_linebuf_done_line(bufhead, (buf_line_t *) bufhead->list.head->data, bufhead->list.head);
|
||||
rb_linebuf_done_line(bufhead, (buf_line_t *) bufhead->list.head->data,
|
||||
bufhead->list.head);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,7 +506,8 @@ rb_linebuf_attach(buf_head_t * bufhead, buf_head_t * new)
|
|||
* Then format/va_args is appended to the buffer.
|
||||
*/
|
||||
void
|
||||
rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args, const char *prefixfmt, ...)
|
||||
rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args,
|
||||
const char *prefixfmt, ...)
|
||||
{
|
||||
buf_line_t *bufline;
|
||||
int len = 0;
|
||||
|
@ -562,7 +554,8 @@ rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args, c
|
|||
else
|
||||
{
|
||||
/* Chop trailing CRLF's .. */
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n') || (bufline->buf[len] == '\0'))
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n')
|
||||
|| (bufline->buf[len] == '\0'))
|
||||
{
|
||||
len--;
|
||||
}
|
||||
|
@ -577,7 +570,7 @@ rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args, c
|
|||
}
|
||||
|
||||
void
|
||||
rb_linebuf_putbuf(buf_head_t *bufhead, const char *buffer)
|
||||
rb_linebuf_putbuf(buf_head_t * bufhead, const char *buffer)
|
||||
{
|
||||
buf_line_t *bufline;
|
||||
int len = 0;
|
||||
|
@ -614,7 +607,8 @@ rb_linebuf_putbuf(buf_head_t *bufhead, const char *buffer)
|
|||
else
|
||||
{
|
||||
/* Chop trailing CRLF's .. */
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n') || (bufline->buf[len] == '\0'))
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n')
|
||||
|| (bufline->buf[len] == '\0'))
|
||||
{
|
||||
len--;
|
||||
}
|
||||
|
@ -673,7 +667,8 @@ rb_linebuf_put(buf_head_t * bufhead, const char *format, ...)
|
|||
else
|
||||
{
|
||||
/* Chop trailing CRLF's .. */
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n') || (bufline->buf[len] == '\0'))
|
||||
while((bufline->buf[len] == '\r') || (bufline->buf[len] == '\n')
|
||||
|| (bufline->buf[len] == '\0'))
|
||||
{
|
||||
len--;
|
||||
}
|
||||
|
@ -755,7 +750,8 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
|
|||
vec[x].iov_len = bufline->len;
|
||||
ptr = ptr->next;
|
||||
|
||||
} while(++x < RB_UIO_MAXIOV);
|
||||
}
|
||||
while(++x < RB_UIO_MAXIOV);
|
||||
|
||||
if(x == 0)
|
||||
{
|
||||
|
@ -839,12 +835,7 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
|
|||
*/
|
||||
|
||||
void
|
||||
rb_count_rb_linebuf_memory(size_t * count, size_t * rb_linebuf_memory_used)
|
||||
rb_count_rb_linebuf_memory(size_t *count, size_t *rb_linebuf_memory_used)
|
||||
{
|
||||
#ifndef NOBALLOC
|
||||
rb_bh_usage(rb_linebuf_heap, count, NULL, rb_linebuf_memory_used, NULL);
|
||||
#else
|
||||
*count = 0;
|
||||
*rb_linebuf_memory_used = 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ rb_stir_arc4random(void *unused)
|
|||
}
|
||||
|
||||
|
||||
int rb_init_prng(const char *path, prng_seed_t seed_type)
|
||||
int
|
||||
rb_init_prng(const char *path, prng_seed_t seed_type)
|
||||
{
|
||||
/* xxx this ignores the parameters above */
|
||||
arc4random_stir();
|
||||
|
@ -75,7 +76,7 @@ rb_get_random(void *buf, size_t length)
|
|||
{
|
||||
uint32_t rnd = 0, i;
|
||||
uint8_t *xbuf = buf;
|
||||
for (i = 0; i < sizeof(length); i++)
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
if(i % 4 == 0)
|
||||
rnd = arc4random();
|
||||
|
@ -100,20 +101,20 @@ rb_get_ssl_strerror(rb_fde_t *F)
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout)
|
||||
rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout)
|
||||
rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
|
||||
struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout)
|
||||
struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -125,26 +126,26 @@ rb_supports_ssl(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_shutdown(rb_fde_t * F)
|
||||
rb_ssl_shutdown(rb_fde_t *F)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
|
||||
rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
|
||||
rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
@ -163,4 +164,3 @@ rb_ssl_clear_handshake_count(rb_fde_t *F)
|
|||
}
|
||||
|
||||
#endif /* !HAVE_OPENSSL */
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ static SSL_CTX *ssl_server_ctx;
|
|||
static SSL_CTX *ssl_client_ctx;
|
||||
static int libratbox_index = -1;
|
||||
|
||||
static unsigned long get_last_err(void)
|
||||
static unsigned long
|
||||
get_last_err(void)
|
||||
{
|
||||
unsigned long t_err, err = 0;
|
||||
err = ERR_get_error();
|
||||
|
@ -53,14 +54,14 @@ static unsigned long get_last_err(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_shutdown(rb_fde_t * F)
|
||||
rb_ssl_shutdown(rb_fde_t *F)
|
||||
{
|
||||
int i;
|
||||
if(F == NULL || F->ssl == NULL)
|
||||
return;
|
||||
SSL_set_shutdown((SSL *) F->ssl, SSL_RECEIVED_SHUTDOWN);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
if(SSL_shutdown((SSL *) F->ssl))
|
||||
break;
|
||||
|
@ -82,14 +83,15 @@ rb_ssl_clear_handshake_count(rb_fde_t *F)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_timeout(rb_fde_t * F, void *notused)
|
||||
rb_ssl_timeout(rb_fde_t *F, void *notused)
|
||||
{
|
||||
lrb_assert(F->accept != NULL);
|
||||
F->accept->callback(F, RB_ERR_TIMEOUT, NULL, 0, F->accept->data);
|
||||
}
|
||||
|
||||
|
||||
static void rb_ssl_info_callback(SSL *ssl, int where, int ret)
|
||||
static void
|
||||
rb_ssl_info_callback(SSL * ssl, int where, int ret)
|
||||
{
|
||||
if(where & SSL_CB_HANDSHAKE_START)
|
||||
{
|
||||
|
@ -104,11 +106,11 @@ static void
|
|||
rb_setup_ssl_cb(rb_fde_t *F)
|
||||
{
|
||||
SSL_set_ex_data(F->ssl, libratbox_index, (char *)F);
|
||||
SSL_set_info_callback((SSL *)F->ssl, (void *)rb_ssl_info_callback);
|
||||
SSL_set_info_callback((SSL *) F->ssl, (void (*)(const SSL *,int,int))rb_ssl_info_callback);
|
||||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryaccept(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryaccept(rb_fde_t *F, void *data)
|
||||
{
|
||||
int ssl_err;
|
||||
lrb_assert(F->accept != NULL);
|
||||
|
@ -146,8 +148,7 @@ rb_ssl_tryaccept(rb_fde_t * F, void *data)
|
|||
|
||||
ad = F->accept;
|
||||
F->accept = NULL;
|
||||
ad->callback(F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen,
|
||||
ad->data);
|
||||
ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data);
|
||||
rb_free(ad);
|
||||
|
||||
}
|
||||
|
@ -184,7 +185,7 @@ rb_ssl_accept_common(rb_fde_t *new_F)
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
|
||||
rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
|
||||
{
|
||||
new_F->type |= RB_FD_SSL;
|
||||
new_F->ssl = SSL_new(ssl_server_ctx);
|
||||
|
@ -204,7 +205,7 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
|
|||
|
||||
|
||||
void
|
||||
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
||||
{
|
||||
new_F->type |= RB_FD_SSL;
|
||||
new_F->ssl = SSL_new(ssl_server_ctx);
|
||||
|
@ -222,16 +223,16 @@ rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addr
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, size_t count)
|
||||
rb_ssl_read_or_write(int r_or_w, rb_fde_t *F, void *rbuf, const void *wbuf, size_t count)
|
||||
{
|
||||
ssize_t ret;
|
||||
unsigned long err;
|
||||
SSL *ssl = F->ssl;
|
||||
|
||||
if(r_or_w == 0)
|
||||
ret = (ssize_t)SSL_read(ssl, rbuf, (int) count);
|
||||
ret = (ssize_t) SSL_read(ssl, rbuf, (int)count);
|
||||
else
|
||||
ret = (ssize_t)SSL_write(ssl, wbuf, (int) count);
|
||||
ret = (ssize_t) SSL_write(ssl, wbuf, (int)count);
|
||||
|
||||
if(ret < 0)
|
||||
{
|
||||
|
@ -269,13 +270,13 @@ rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, siz
|
|||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
|
||||
rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
|
||||
{
|
||||
return rb_ssl_read_or_write(0, F, buf, NULL, count);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
|
||||
rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
|
||||
{
|
||||
return rb_ssl_read_or_write(1, F, NULL, buf, count);
|
||||
}
|
||||
|
@ -313,7 +314,6 @@ rb_init_ssl(void)
|
|||
int
|
||||
rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
|
||||
{
|
||||
FILE *param;
|
||||
DH *dh;
|
||||
unsigned long err;
|
||||
if(cert == NULL)
|
||||
|
@ -347,28 +347,34 @@ rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
|
|||
if(dhfile != NULL)
|
||||
{
|
||||
/* DH parameters aren't necessary, but they are nice..if they didn't pass one..that is their problem */
|
||||
param = fopen(dhfile, "r");
|
||||
if(param != NULL)
|
||||
BIO *bio = BIO_new_file(dhfile, "r");
|
||||
if(bio != NULL)
|
||||
{
|
||||
dh = PEM_read_DHparams(param, NULL, NULL, NULL);
|
||||
dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
|
||||
if(dh == NULL)
|
||||
{
|
||||
err = ERR_get_error();
|
||||
rb_lib_log
|
||||
("rb_setup_ssl_server: Error loading DH params file [%s]: %s",
|
||||
param, ERR_error_string(err, NULL));
|
||||
fclose(param);
|
||||
dhfile, ERR_error_string(err, NULL));
|
||||
BIO_free(bio);
|
||||
return 0;
|
||||
}
|
||||
BIO_free(bio);
|
||||
SSL_CTX_set_tmp_dh(ssl_server_ctx, dh);
|
||||
fclose(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = ERR_get_error();
|
||||
rb_lib_log("rb_setup_ssl_server: Error loading DH params file [%s]: %s",
|
||||
dhfile, ERR_error_string(err, NULL));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rb_ssl_listen(rb_fde_t * F, int backlog)
|
||||
rb_ssl_listen(rb_fde_t *F, int backlog)
|
||||
{
|
||||
F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL;
|
||||
return listen(F->fd, backlog);
|
||||
|
@ -382,7 +388,7 @@ struct ssl_connect
|
|||
};
|
||||
|
||||
static void
|
||||
rb_ssl_connect_realcb(rb_fde_t * F, int status, struct ssl_connect *sconn)
|
||||
rb_ssl_connect_realcb(rb_fde_t *F, int status, struct ssl_connect *sconn)
|
||||
{
|
||||
F->connect->callback = sconn->callback;
|
||||
F->connect->data = sconn->data;
|
||||
|
@ -391,13 +397,13 @@ rb_ssl_connect_realcb(rb_fde_t * F, int status, struct ssl_connect *sconn)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn_timeout_cb(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryconn_timeout_cb(rb_fde_t *F, void *data)
|
||||
{
|
||||
rb_ssl_connect_realcb(F, RB_ERR_TIMEOUT, data);
|
||||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn_cb(rb_fde_t * F, void *data)
|
||||
rb_ssl_tryconn_cb(rb_fde_t *F, void *data)
|
||||
{
|
||||
struct ssl_connect *sconn = data;
|
||||
int ssl_err;
|
||||
|
@ -431,7 +437,7 @@ rb_ssl_tryconn_cb(rb_fde_t * F, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
|
||||
rb_ssl_tryconn(rb_fde_t *F, int status, void *data)
|
||||
{
|
||||
struct ssl_connect *sconn = data;
|
||||
int ssl_err;
|
||||
|
@ -473,7 +479,7 @@ rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
|
|||
}
|
||||
|
||||
void
|
||||
rb_connect_tcp_ssl(rb_fde_t * F, struct sockaddr *dest,
|
||||
rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
|
||||
struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
struct ssl_connect *sconn;
|
||||
|
@ -489,7 +495,7 @@ rb_connect_tcp_ssl(rb_fde_t * F, struct sockaddr *dest,
|
|||
}
|
||||
|
||||
void
|
||||
rb_ssl_start_connected(rb_fde_t * F, CNCB * callback, void *data, int timeout)
|
||||
rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
|
||||
{
|
||||
struct ssl_connect *sconn;
|
||||
int ssl_err;
|
||||
|
@ -540,7 +546,7 @@ rb_init_prng(const char *path, prng_seed_t seed_type)
|
|||
{
|
||||
if(seed_type == RB_PRNG_DEFAULT)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
RAND_screen();
|
||||
#endif
|
||||
return RAND_status();
|
||||
|
@ -558,7 +564,7 @@ rb_init_prng(const char *path, prng_seed_t seed_type)
|
|||
if(RAND_load_file(path, -1) == -1)
|
||||
return -1;
|
||||
break;
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
case RB_PRNGWIN32:
|
||||
RAND_screen();
|
||||
break;
|
||||
|
@ -594,7 +600,7 @@ rb_get_pseudo_random(void *buf, size_t length)
|
|||
}
|
||||
|
||||
const char *
|
||||
rb_get_ssl_strerror(rb_fde_t * F)
|
||||
rb_get_ssl_strerror(rb_fde_t *F)
|
||||
{
|
||||
return ERR_error_string(F->ssl_errno, NULL);
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ rb_init_patricia(void)
|
|||
* convert prefix information to bytes
|
||||
*/
|
||||
static uint8_t *
|
||||
prefix_tochar(rb_prefix_t * prefix)
|
||||
prefix_tochar(rb_prefix_t *prefix)
|
||||
{
|
||||
if(prefix == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((uint8_t *) & prefix->add.sin);
|
||||
return ((uint8_t *)&prefix->add.sin);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -59,14 +59,15 @@ comp_with_mask(void *addr, void *dest, unsigned int mask)
|
|||
int n = mask / 8;
|
||||
int m = ((-1) << (8 - (mask % 8)));
|
||||
|
||||
if(mask % 8 == 0 || (((uint8_t *) addr)[n] & m) == (((uint8_t *) dest)[n] & m))
|
||||
if(mask % 8 == 0 || (((uint8_t *)addr)[n] & m) == (((uint8_t *)dest)[n] & m))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef NOTYET
|
||||
static char *
|
||||
prefix_toa2x(rb_prefix_t * prefix, char *buf, int buf_len, int with_len)
|
||||
prefix_toa2x(rb_prefix_t *prefix, char *buf, int buf_len, int with_len)
|
||||
{
|
||||
static char tmp[6];
|
||||
if(prefix == NULL)
|
||||
|
@ -88,12 +89,13 @@ prefix_toa2x(rb_prefix_t * prefix, char *buf, int buf_len, int with_len)
|
|||
*/
|
||||
|
||||
static char *
|
||||
prefix_toa2(rb_prefix_t * prefix, char *buff, int buf_len)
|
||||
prefix_toa2(rb_prefix_t *prefix, char *buff, int buf_len)
|
||||
{
|
||||
return (prefix_toa2x(prefix, buff, buf_len, 0));
|
||||
}
|
||||
|
||||
static char *
|
||||
prefix_toa(rb_prefix_t * prefix)
|
||||
prefix_toa(rb_prefix_t *prefix)
|
||||
{
|
||||
#ifdef RB_IPV6
|
||||
static char buf[INET6_ADDRSTRLEN + 6];
|
||||
|
@ -104,7 +106,7 @@ prefix_toa(rb_prefix_t * prefix)
|
|||
}
|
||||
#endif
|
||||
static rb_prefix_t *
|
||||
New_Prefix2(int family, void *dest, int bitlen, rb_prefix_t * prefix)
|
||||
New_Prefix2(int family, void *dest, int bitlen, rb_prefix_t *prefix)
|
||||
{
|
||||
int dynamic_allocated = 0;
|
||||
#ifdef RB_IPV6
|
||||
|
@ -229,7 +231,7 @@ ascii2prefix(int family, const char *string)
|
|||
}
|
||||
|
||||
static rb_prefix_t *
|
||||
Ref_Prefix(rb_prefix_t * prefix)
|
||||
Ref_Prefix(rb_prefix_t *prefix)
|
||||
{
|
||||
if(prefix == NULL)
|
||||
return (NULL);
|
||||
|
@ -243,7 +245,7 @@ Ref_Prefix(rb_prefix_t * prefix)
|
|||
}
|
||||
|
||||
static void
|
||||
Deref_Prefix(rb_prefix_t * prefix)
|
||||
Deref_Prefix(rb_prefix_t *prefix)
|
||||
{
|
||||
if(prefix == NULL)
|
||||
return;
|
||||
|
@ -287,7 +289,7 @@ rb_new_patricia(int maxbits)
|
|||
*/
|
||||
|
||||
void
|
||||
rb_clear_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
||||
rb_clear_patricia(rb_patricia_tree_t *patricia, void (*func) (void *))
|
||||
{
|
||||
assert(patricia);
|
||||
if(patricia->head)
|
||||
|
@ -297,7 +299,7 @@ rb_clear_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
|||
rb_patricia_node_t **Xsp = Xstack;
|
||||
rb_patricia_node_t *Xrn = patricia->head;
|
||||
|
||||
while (Xrn)
|
||||
while(Xrn)
|
||||
{
|
||||
rb_patricia_node_t *l = Xrn->l;
|
||||
rb_patricia_node_t *r = Xrn->r;
|
||||
|
@ -333,7 +335,7 @@ rb_clear_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
|||
}
|
||||
else
|
||||
{
|
||||
Xrn = (rb_patricia_node_t *) 0;
|
||||
Xrn = (rb_patricia_node_t *)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +345,7 @@ rb_clear_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
|||
|
||||
|
||||
void
|
||||
rb_destroy_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
||||
rb_destroy_patricia(rb_patricia_tree_t *patricia, void (*func) (void *))
|
||||
{
|
||||
rb_clear_patricia(patricia, func);
|
||||
num_active_patricia--;
|
||||
|
@ -355,7 +357,7 @@ rb_destroy_patricia(rb_patricia_tree_t * patricia, void (*func)(void *))
|
|||
*/
|
||||
|
||||
void
|
||||
rb_patricia_process(rb_patricia_tree_t * patricia, void (*func)(rb_prefix_t *, void *))
|
||||
rb_patricia_process(rb_patricia_tree_t *patricia, void (*func) (rb_prefix_t *, void *))
|
||||
{
|
||||
rb_patricia_node_t *node;
|
||||
assert(func);
|
||||
|
@ -368,7 +370,7 @@ rb_patricia_process(rb_patricia_tree_t * patricia, void (*func)(rb_prefix_t *, v
|
|||
}
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_patricia_search_exact(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
||||
rb_patricia_search_exact(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
|
||||
{
|
||||
rb_patricia_node_t *node;
|
||||
uint8_t *addr;
|
||||
|
@ -385,7 +387,7 @@ rb_patricia_search_exact(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
addr = rb_prefix_touchar(prefix);
|
||||
bitlen = prefix->bitlen;
|
||||
|
||||
while (node->bit < bitlen)
|
||||
while(node->bit < bitlen)
|
||||
{
|
||||
|
||||
if(BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07)))
|
||||
|
@ -443,7 +445,7 @@ rb_patricia_search_exact(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
|
||||
/* if inclusive != 0, "best" may be the given prefix itself */
|
||||
rb_patricia_node_t *
|
||||
rb_patricia_search_best2(rb_patricia_tree_t * patricia, rb_prefix_t * prefix, int inclusive)
|
||||
rb_patricia_search_best2(rb_patricia_tree_t *patricia, rb_prefix_t *prefix, int inclusive)
|
||||
{
|
||||
rb_patricia_node_t *node;
|
||||
rb_patricia_node_t *stack[RB_PATRICIA_MAXBITS + 1];
|
||||
|
@ -462,7 +464,7 @@ rb_patricia_search_best2(rb_patricia_tree_t * patricia, rb_prefix_t * prefix, in
|
|||
addr = rb_prefix_touchar(prefix);
|
||||
bitlen = prefix->bitlen;
|
||||
|
||||
while (node->bit < bitlen)
|
||||
while(node->bit < bitlen)
|
||||
{
|
||||
|
||||
if(node->prefix)
|
||||
|
@ -522,7 +524,7 @@ rb_patricia_search_best2(rb_patricia_tree_t * patricia, rb_prefix_t * prefix, in
|
|||
if(cnt <= 0)
|
||||
return (NULL);
|
||||
|
||||
while (--cnt >= 0)
|
||||
while(--cnt >= 0)
|
||||
{
|
||||
node = stack[cnt];
|
||||
#ifdef PATRICIA_DEBUG
|
||||
|
@ -545,14 +547,14 @@ rb_patricia_search_best2(rb_patricia_tree_t * patricia, rb_prefix_t * prefix, in
|
|||
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_patricia_search_best(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
||||
rb_patricia_search_best(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
|
||||
{
|
||||
return (rb_patricia_search_best2(patricia, prefix, 1));
|
||||
}
|
||||
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
||||
rb_patricia_lookup(rb_patricia_tree_t *patricia, rb_prefix_t *prefix)
|
||||
{
|
||||
rb_patricia_node_t *node, *new_node, *parent, *glue;
|
||||
uint8_t *addr, *test_addr;
|
||||
|
@ -585,7 +587,7 @@ rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
bitlen = prefix->bitlen;
|
||||
node = patricia->head;
|
||||
|
||||
while (node->bit < bitlen || node->prefix == NULL)
|
||||
while(node->bit < bitlen || node->prefix == NULL)
|
||||
{
|
||||
|
||||
if(node->bit < patricia->maxbits &&
|
||||
|
@ -631,7 +633,7 @@ rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
/* find the first bit different */
|
||||
check_bit = (node->bit < bitlen) ? node->bit : bitlen;
|
||||
differ_bit = 0;
|
||||
for (i = 0; i * 8 < check_bit; i++)
|
||||
for(i = 0; i * 8 < check_bit; i++)
|
||||
{
|
||||
if((r = (addr[i] ^ test_addr[i])) == 0)
|
||||
{
|
||||
|
@ -639,7 +641,7 @@ rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
continue;
|
||||
}
|
||||
/* I know the better way, but for now */
|
||||
for (j = 0; j < 8; j++)
|
||||
for(j = 0; j < 8; j++)
|
||||
{
|
||||
if(BIT_TEST(r, (0x80 >> j)))
|
||||
break;
|
||||
|
@ -656,7 +658,7 @@ rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
#endif /* PATRICIA_DEBUG */
|
||||
|
||||
parent = node->parent;
|
||||
while (parent && parent->bit >= differ_bit)
|
||||
while(parent && parent->bit >= differ_bit)
|
||||
{
|
||||
node = parent;
|
||||
parent = node->parent;
|
||||
|
@ -797,7 +799,7 @@ rb_patricia_lookup(rb_patricia_tree_t * patricia, rb_prefix_t * prefix)
|
|||
|
||||
|
||||
void
|
||||
rb_patricia_remove(rb_patricia_tree_t * patricia, rb_patricia_node_t * node)
|
||||
rb_patricia_remove(rb_patricia_tree_t *patricia, rb_patricia_node_t *node)
|
||||
{
|
||||
rb_patricia_node_t *parent, *child;
|
||||
|
||||
|
@ -914,7 +916,7 @@ rb_patricia_remove(rb_patricia_tree_t * patricia, rb_patricia_node_t * node)
|
|||
}
|
||||
|
||||
rb_patricia_node_t *
|
||||
make_and_lookup_ip(rb_patricia_tree_t * tree, struct sockaddr *in, int bitlen)
|
||||
make_and_lookup_ip(rb_patricia_tree_t *tree, struct sockaddr *in, int bitlen)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
@ -941,7 +943,7 @@ make_and_lookup_ip(rb_patricia_tree_t * tree, struct sockaddr *in, int bitlen)
|
|||
|
||||
|
||||
rb_patricia_node_t *
|
||||
make_and_lookup(rb_patricia_tree_t * tree, const char *string)
|
||||
make_and_lookup(rb_patricia_tree_t *tree, const char *string)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
@ -968,7 +970,7 @@ make_and_lookup(rb_patricia_tree_t * tree, const char *string)
|
|||
|
||||
#ifdef NOTYET
|
||||
static rb_patricia_node_t *
|
||||
try_search_exact(rb_patricia_tree_t * tree, char *string)
|
||||
try_search_exact(rb_patricia_tree_t *tree, char *string)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
@ -991,7 +993,7 @@ try_search_exact(rb_patricia_tree_t * tree, char *string)
|
|||
}
|
||||
|
||||
void
|
||||
lookup_then_remove(rb_patricia_tree_t * tree, char *string)
|
||||
lookup_then_remove(rb_patricia_tree_t *tree, char *string)
|
||||
{
|
||||
rb_patricia_node_t *node;
|
||||
|
||||
|
@ -1001,7 +1003,7 @@ lookup_then_remove(rb_patricia_tree_t * tree, char *string)
|
|||
#endif
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_match_ip(rb_patricia_tree_t * tree, struct sockaddr *ip)
|
||||
rb_match_ip(rb_patricia_tree_t *tree, struct sockaddr *ip)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
@ -1018,7 +1020,9 @@ rb_match_ip(rb_patricia_tree_t * tree, struct sockaddr *ip)
|
|||
len = 128;
|
||||
family = AF_INET6;
|
||||
ipptr = &((struct sockaddr_in6 *)ip)->sin6_addr;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
len = 32;
|
||||
family = AF_INET;
|
||||
ipptr = &((struct sockaddr_in *)ip)->sin_addr;
|
||||
|
@ -1035,7 +1039,7 @@ rb_match_ip(rb_patricia_tree_t * tree, struct sockaddr *ip)
|
|||
}
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_match_ip_exact(rb_patricia_tree_t * tree, struct sockaddr *ip, unsigned int len)
|
||||
rb_match_ip_exact(rb_patricia_tree_t *tree, struct sockaddr *ip, unsigned int len)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
@ -1054,7 +1058,9 @@ rb_match_ip_exact(rb_patricia_tree_t * tree, struct sockaddr *ip, unsigned int l
|
|||
len = 128;
|
||||
family = AF_INET6;
|
||||
ipptr = &((struct sockaddr_in6 *)ip)->sin6_addr;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(len > 32)
|
||||
len = 32;
|
||||
family = AF_INET;
|
||||
|
@ -1074,7 +1080,7 @@ rb_match_ip_exact(rb_patricia_tree_t * tree, struct sockaddr *ip, unsigned int l
|
|||
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_match_string(rb_patricia_tree_t * tree, const char *string)
|
||||
rb_match_string(rb_patricia_tree_t *tree, const char *string)
|
||||
{
|
||||
rb_patricia_node_t *node;
|
||||
rb_prefix_t *prefix;
|
||||
|
@ -1098,7 +1104,7 @@ rb_match_string(rb_patricia_tree_t * tree, const char *string)
|
|||
}
|
||||
|
||||
rb_patricia_node_t *
|
||||
rb_match_exact_string(rb_patricia_tree_t * tree, const char *string)
|
||||
rb_match_exact_string(rb_patricia_tree_t *tree, const char *string)
|
||||
{
|
||||
rb_prefix_t *prefix;
|
||||
rb_patricia_node_t *node;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: poll.c 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: poll.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
@ -52,7 +52,7 @@ typedef struct _pollfd_list pollfd_list_t;
|
|||
static pollfd_list_t pollfd_list;
|
||||
|
||||
int
|
||||
rb_setup_fd_poll(rb_fde_t * F)
|
||||
rb_setup_fd_poll(rb_fde_t *F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ rb_init_netio_poll(void)
|
|||
int fd;
|
||||
pollfd_list.pollfds = rb_malloc(rb_getmaxconnect() * (sizeof(struct pollfd)));
|
||||
pollfd_list.allocated = rb_getmaxconnect();
|
||||
for (fd = 0; fd < rb_getmaxconnect(); fd++)
|
||||
for(fd = 0; fd < rb_getmaxconnect(); fd++)
|
||||
{
|
||||
pollfd_list.pollfds[fd].fd = -1;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ resize_pollarray(int fd)
|
|||
rb_realloc(pollfd_list.pollfds,
|
||||
pollfd_list.allocated * (sizeof(struct pollfd)));
|
||||
memset(&pollfd_list.pollfds[old_value + 1], 0, sizeof(struct pollfd) * 1024);
|
||||
for (x = old_value + 1; x < pollfd_list.allocated; x++)
|
||||
for(x = old_value + 1; x < pollfd_list.allocated; x++)
|
||||
{
|
||||
pollfd_list.pollfds[x].fd = -1;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ resize_pollarray(int fd)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_poll(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_poll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
if(F == NULL)
|
||||
return;
|
||||
|
@ -134,7 +134,7 @@ rb_setselect_poll(rb_fde_t * F, unsigned int type, PF * handler, void *client_da
|
|||
pollfd_list.pollfds[F->fd].fd = -1;
|
||||
if(F->fd == pollfd_list.maxindex)
|
||||
{
|
||||
while (pollfd_list.maxindex >= 0
|
||||
while(pollfd_list.maxindex >= 0
|
||||
&& pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
|
||||
pollfd_list.maxindex--;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ rb_select_poll(long delay)
|
|||
return RB_OK;
|
||||
|
||||
/* XXX we *could* optimise by falling out after doing num fds ... */
|
||||
for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
|
||||
for(ci = 0; ci < pollfd_list.maxindex + 1; ci++)
|
||||
{
|
||||
rb_fde_t *F;
|
||||
pfd = &pollfd_list.pollfds[ci];
|
||||
|
@ -239,7 +239,7 @@ rb_init_netio_poll(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_poll(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_poll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return;
|
||||
|
@ -253,7 +253,7 @@ rb_select_poll(long delay)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_poll(rb_fde_t * F)
|
||||
rb_setup_fd_poll(rb_fde_t *F)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: ports.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: ports.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -45,25 +45,25 @@ static port_event_t *pelst; /* port buffer */
|
|||
static int pemax; /* max structs to buffer */
|
||||
|
||||
int
|
||||
rb_setup_fd_ports(rb_fde_t *F)
|
||||
rb_setup_fd_ports(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pe_update_events(rb_fde_t * F, short filter, PF * handler)
|
||||
pe_update_events(rb_fde_t *F, short filter, PF * handler)
|
||||
{
|
||||
PF *cur_handler = NULL;
|
||||
|
||||
if (filter == POLLRDNORM)
|
||||
if(filter == POLLRDNORM)
|
||||
cur_handler = F->read_handler;
|
||||
else if (filter == POLLWRNORM)
|
||||
else if(filter == POLLWRNORM)
|
||||
cur_handler = F->write_handler;
|
||||
|
||||
if (!cur_handler && handler)
|
||||
if(!cur_handler && handler)
|
||||
port_associate(pe, PORT_SOURCE_FD, F->fd, filter, F);
|
||||
else if (cur_handler && !handler)
|
||||
else if(cur_handler && !handler)
|
||||
port_dissociate(pe, PORT_SOURCE_FD, F->fd);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,8 @@ pe_update_events(rb_fde_t * F, short filter, PF * handler)
|
|||
int
|
||||
rb_init_netio_ports(void)
|
||||
{
|
||||
if((pe = port_create()) < 0) {
|
||||
if((pe = port_create()) < 0)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
pemax = getdtablesize();
|
||||
|
@ -96,18 +97,19 @@ rb_init_netio_ports(void)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_ports(rb_fde_t *F, unsigned int type, PF * handler,
|
||||
void *client_data)
|
||||
rb_setselect_ports(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
lrb_assert(IsFDOpen(F));
|
||||
|
||||
/* Update the list, even though we're not using it .. */
|
||||
if(type & RB_SELECT_READ) {
|
||||
if(type & RB_SELECT_READ)
|
||||
{
|
||||
pe_update_events(F, POLLRDNORM, handler);
|
||||
F->read_handler = handler;
|
||||
F->read_data = client_data;
|
||||
}
|
||||
if(type & RB_SELECT_WRITE) {
|
||||
if(type & RB_SELECT_WRITE)
|
||||
{
|
||||
pe_update_events(F, POLLWRNORM, handler);
|
||||
F->write_handler = handler;
|
||||
F->write_data = client_data;
|
||||
|
@ -128,8 +130,8 @@ rb_select_ports(long delay)
|
|||
{
|
||||
int i, fd;
|
||||
uint nget = 1;
|
||||
struct timespec poll_time;
|
||||
struct timer_data *tdata;
|
||||
struct timespec poll_time;
|
||||
struct timer_data *tdata;
|
||||
|
||||
poll_time.tv_sec = delay / 1000;
|
||||
poll_time.tv_nsec = (delay % 1000) * 1000000;
|
||||
|
@ -137,21 +139,25 @@ struct timer_data *tdata;
|
|||
i = port_getn(pe, pelst, pemax, &nget, &poll_time);
|
||||
rb_set_time();
|
||||
|
||||
if (i == -1)
|
||||
if(i == -1)
|
||||
return RB_OK;
|
||||
|
||||
for (i = 0; i < nget; i++) {
|
||||
switch(pelst[i].portev_source) {
|
||||
for(i = 0; i < nget; i++)
|
||||
{
|
||||
switch (pelst[i].portev_source)
|
||||
{
|
||||
case PORT_SOURCE_FD:
|
||||
fd = pelst[i].portev_object;
|
||||
PF *hdl = NULL;
|
||||
rb_fde_t *F = rb_find_fd(fd);
|
||||
|
||||
if ((pelst[i].portev_events & POLLRDNORM) && (hdl = F->read_handler)) {
|
||||
if((pelst[i].portev_events & POLLRDNORM) && (hdl = F->read_handler))
|
||||
{
|
||||
F->read_handler = NULL;
|
||||
hdl(F, F->read_data);
|
||||
}
|
||||
if ((pelst[i].portev_events & POLLWRNORM) && (hdl = F->write_handler)) {
|
||||
if((pelst[i].portev_events & POLLWRNORM) && (hdl = F->write_handler))
|
||||
{
|
||||
F->write_handler = NULL;
|
||||
hdl(F, F->write_data);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: ratbox_lib.c 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: ratbox_lib.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
|
@ -72,23 +72,24 @@ rb_ctime(const time_t t, char *buf, size_t len)
|
|||
if(rb_unlikely(tp == NULL))
|
||||
{
|
||||
strcpy(buf, "");
|
||||
return(buf);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
if(buf == NULL)
|
||||
{
|
||||
p = timex;
|
||||
tlen = sizeof(timex);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
p = buf;
|
||||
tlen = len;
|
||||
}
|
||||
|
||||
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);
|
||||
tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_year + 1900);
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,13 +108,13 @@ rb_date(const time_t t, char *buf, size_t len)
|
|||
if(rb_unlikely(gm == NULL))
|
||||
{
|
||||
rb_strlcpy(buf, "", len);
|
||||
return(buf);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
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);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
time_t
|
||||
|
@ -181,15 +182,17 @@ rb_set_time(void)
|
|||
memcpy(&rb_time, &newtime, sizeof(struct timeval));
|
||||
}
|
||||
|
||||
extern const char *libratbox_serno;
|
||||
|
||||
const char *
|
||||
rb_lib_version(void)
|
||||
{
|
||||
static const char *id = "$Rev: 25375 $";
|
||||
return id;
|
||||
return libratbox_serno;
|
||||
}
|
||||
|
||||
void
|
||||
rb_lib_init(log_cb *ilog, restart_cb *irestart, die_cb *idie, int closeall, int maxcon, size_t dh_size, size_t fd_heap_size)
|
||||
rb_lib_init(log_cb * ilog, restart_cb * irestart, die_cb * idie, int closeall, int maxcon,
|
||||
size_t dh_size, size_t fd_heap_size)
|
||||
{
|
||||
rb_set_time();
|
||||
rb_log = ilog;
|
||||
|
@ -236,7 +239,8 @@ rb_lib_loop(long delay)
|
|||
else
|
||||
next = -1;
|
||||
rb_select(next);
|
||||
} else
|
||||
}
|
||||
else
|
||||
rb_select(delay);
|
||||
rb_event_run();
|
||||
}
|
||||
|
@ -244,17 +248,17 @@ rb_lib_loop(long delay)
|
|||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
char *
|
||||
rb_strtok_r (char *s, const char *delim, char **save)
|
||||
rb_strtok_r(char *s, const char *delim, char **save)
|
||||
{
|
||||
char *token;
|
||||
|
||||
if (s == NULL)
|
||||
if(s == NULL)
|
||||
s = *save;
|
||||
|
||||
/* Scan leading delimiters. */
|
||||
s += strspn(s, delim);
|
||||
|
||||
if (*s == '\0')
|
||||
if(*s == '\0')
|
||||
{
|
||||
*save = s;
|
||||
return NULL;
|
||||
|
@ -263,7 +267,7 @@ rb_strtok_r (char *s, const char *delim, char **save)
|
|||
token = s;
|
||||
s = strpbrk(token, delim);
|
||||
|
||||
if (s == NULL)
|
||||
if(s == NULL)
|
||||
*save = (token + strlen(token));
|
||||
else
|
||||
{
|
||||
|
@ -273,8 +277,8 @@ rb_strtok_r (char *s, const char *delim, char **save)
|
|||
return token;
|
||||
}
|
||||
#else
|
||||
char
|
||||
*rb_strtok_r(char *s, const char *delim, char **save)
|
||||
char *
|
||||
rb_strtok_r(char *s, const char *delim, char **save)
|
||||
{
|
||||
return strtok_r(s, delim, save);
|
||||
}
|
||||
|
@ -287,7 +291,7 @@ static const char base64_table[] =
|
|||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
|
||||
};
|
||||
};
|
||||
|
||||
static const char base64_pad = '=';
|
||||
|
||||
|
@ -317,14 +321,15 @@ rb_base64_encode(const unsigned char *str, int length)
|
|||
unsigned char *p;
|
||||
unsigned char *result;
|
||||
|
||||
if ((length + 2) < 0 || ((length + 2) / 3) >= (1 << (sizeof(int) * 8 - 2))) {
|
||||
if((length + 2) < 0 || ((length + 2) / 3) >= (1 << (sizeof(int) * 8 - 2)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = rb_malloc(((length + 2) / 3) * 5);
|
||||
p = result;
|
||||
|
||||
while (length > 2)
|
||||
while(length > 2)
|
||||
{
|
||||
*p++ = base64_table[current[0] >> 2];
|
||||
*p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
|
@ -335,13 +340,17 @@ rb_base64_encode(const unsigned char *str, int length)
|
|||
length -= 3;
|
||||
}
|
||||
|
||||
if (length != 0) {
|
||||
if(length != 0)
|
||||
{
|
||||
*p++ = base64_table[current[0] >> 2];
|
||||
if (length > 1) {
|
||||
if(length > 1)
|
||||
{
|
||||
*p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
|
||||
*p++ = base64_table[(current[1] & 0x0f) << 2];
|
||||
*p++ = base64_pad;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = base64_table[(current[0] & 0x03) << 4];
|
||||
*p++ = base64_pad;
|
||||
*p++ = base64_pad;
|
||||
|
@ -360,13 +369,17 @@ rb_base64_decode(const unsigned char *str, int length, int *ret)
|
|||
|
||||
result = rb_malloc(length + 1);
|
||||
|
||||
while ((ch = *current++) != '\0' && length-- > 0) {
|
||||
if (ch == base64_pad) break;
|
||||
while((ch = *current++) != '\0' && length-- > 0)
|
||||
{
|
||||
if(ch == base64_pad)
|
||||
break;
|
||||
|
||||
ch = base64_reverse_table[ch];
|
||||
if (ch < 0) continue;
|
||||
if(ch < 0)
|
||||
continue;
|
||||
|
||||
switch(i % 4) {
|
||||
switch (i % 4)
|
||||
{
|
||||
case 0:
|
||||
result[j] = ch << 2;
|
||||
break;
|
||||
|
@ -375,7 +388,7 @@ rb_base64_decode(const unsigned char *str, int length, int *ret)
|
|||
result[j] = (ch & 0x0f) << 4;
|
||||
break;
|
||||
case 2:
|
||||
result[j++] |= ch >>2;
|
||||
result[j++] |= ch >> 2;
|
||||
result[j] = (ch & 0x03) << 6;
|
||||
break;
|
||||
case 3:
|
||||
|
@ -387,8 +400,10 @@ rb_base64_decode(const unsigned char *str, int length, int *ret)
|
|||
|
||||
k = j;
|
||||
|
||||
if (ch == base64_pad) {
|
||||
switch(i % 4) {
|
||||
if(ch == base64_pad)
|
||||
{
|
||||
switch (i % 4)
|
||||
{
|
||||
case 1:
|
||||
free(result);
|
||||
return NULL;
|
||||
|
@ -402,5 +417,3 @@ rb_base64_decode(const unsigned char *str, int length, int *ret)
|
|||
*ret = j;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ rb_rawbuf_append(rawbuf_head_t * rb, void *data, int len)
|
|||
{
|
||||
buf = (rawbuf_t *) rb->list.tail->data;
|
||||
clen = RAWBUF_SIZE - buf->len;
|
||||
ptr = (void *) (buf->data + buf->len);
|
||||
ptr = (void *)(buf->data + buf->len);
|
||||
if(len < clen)
|
||||
clen = len;
|
||||
|
||||
|
@ -211,7 +211,7 @@ rb_rawbuf_append(rawbuf_head_t * rb, void *data, int len)
|
|||
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
while(len > 0)
|
||||
{
|
||||
buf = rb_rawbuf_newbuf(rb);
|
||||
|
||||
|
@ -241,7 +241,7 @@ rb_rawbuf_get(rawbuf_head_t * rb, void *data, int len)
|
|||
buf = rb->list.head->data;
|
||||
|
||||
if(buf->flushing)
|
||||
ptr = (void *) (buf->data + rb->written);
|
||||
ptr = (void *)(buf->data + rb->written);
|
||||
else
|
||||
ptr = buf->data;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: rb_memory.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: rb_memory.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
@ -39,4 +39,3 @@ rb_outofmemory(void)
|
|||
rb_lib_log("Out of memory: restarting server...");
|
||||
rb_lib_restart("Out of Memory");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,22 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: select.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: select.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
#define FD_SETSIZE 65535
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
#include <commio-int.h>
|
||||
|
||||
#if defined(HAVE_SELECT)
|
||||
#if defined(HAVE_SELECT) || defined(_WIN32)
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_FD_SET(x, y) FD_SET((SOCKET)x, y)
|
||||
#define MY_FD_CLR(x, y) FD_CLR((SOCKET)x, y)
|
||||
#else
|
||||
#define MY_FD_SET(x, y) FD_SET(x, y)
|
||||
#define MY_FD_CLR(x, y) FD_CLR(x, y)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
|
@ -67,12 +76,12 @@ select_update_selectfds(rb_fde_t *F, short event, PF * handler)
|
|||
{
|
||||
if(handler)
|
||||
{
|
||||
FD_SET(F->fd, &select_readfds);
|
||||
MY_FD_SET(F->fd, &select_readfds);
|
||||
F->pflags |= RB_SELECT_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
FD_CLR(F->fd, &select_readfds);
|
||||
MY_FD_CLR(F->fd, &select_readfds);
|
||||
F->pflags &= ~RB_SELECT_READ;
|
||||
}
|
||||
}
|
||||
|
@ -81,17 +90,17 @@ select_update_selectfds(rb_fde_t *F, short event, PF * handler)
|
|||
{
|
||||
if(handler)
|
||||
{
|
||||
FD_SET(F->fd, &select_writefds);
|
||||
MY_FD_SET(F->fd, &select_writefds);
|
||||
F->pflags |= RB_SELECT_WRITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FD_CLR(F->fd, &select_writefds);
|
||||
MY_FD_CLR(F->fd, &select_writefds);
|
||||
F->pflags &= ~RB_SELECT_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
if(F->pflags & (RB_SELECT_READ|RB_SELECT_WRITE))
|
||||
if(F->pflags & (RB_SELECT_READ | RB_SELECT_WRITE))
|
||||
{
|
||||
if(F->fd > rb_maxfd)
|
||||
{
|
||||
|
@ -100,7 +109,8 @@ select_update_selectfds(rb_fde_t *F, short event, PF * handler)
|
|||
}
|
||||
else if(F->fd <= rb_maxfd)
|
||||
{
|
||||
while(rb_maxfd >= 0 && !FD_ISSET(rb_maxfd, &select_readfds) && !FD_ISSET(rb_maxfd, &select_writefds))
|
||||
while(rb_maxfd >= 0 && !FD_ISSET(rb_maxfd, &select_readfds)
|
||||
&& !FD_ISSET(rb_maxfd, &select_writefds))
|
||||
rb_maxfd--;
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +132,12 @@ rb_setup_fd_select(rb_fde_t *F)
|
|||
* This is a needed exported function which will be called to initialise
|
||||
* the network loop code.
|
||||
*/
|
||||
extern int rb_maxconnections;
|
||||
int
|
||||
rb_init_netio_select(void)
|
||||
{
|
||||
if(rb_maxconnections > FD_SETSIZE)
|
||||
rb_maxconnections = FD_SETSIZE; /* override this */
|
||||
FD_ZERO(&select_readfds);
|
||||
FD_ZERO(&select_writefds);
|
||||
return 0;
|
||||
|
@ -137,8 +150,7 @@ rb_init_netio_select(void)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_select(rb_fde_t *F, unsigned int type, PF * handler,
|
||||
void *client_data)
|
||||
rb_setselect_select(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
lrb_assert(IsFDOpen(F));
|
||||
|
||||
|
@ -181,7 +193,7 @@ rb_select_select(long delay)
|
|||
memcpy(&tmpreadfds, &select_readfds, sizeof(fd_set));
|
||||
memcpy(&tmpwritefds, &select_writefds, sizeof(fd_set));
|
||||
|
||||
for (;;)
|
||||
for(;;)
|
||||
{
|
||||
to.tv_sec = 0;
|
||||
to.tv_usec = delay * 1000;
|
||||
|
@ -201,7 +213,7 @@ rb_select_select(long delay)
|
|||
return 0;
|
||||
|
||||
/* XXX we *could* optimise by falling out after doing num fds ... */
|
||||
for (fd = 0; fd < rb_maxfd + 1; fd++)
|
||||
for(fd = 0; fd < rb_maxfd + 1; fd++)
|
||||
{
|
||||
F = rb_find_fd(fd);
|
||||
if(F == NULL)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: sigio.c 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: sigio.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -81,7 +81,7 @@ rb_init_netio_sigio(void)
|
|||
int fd;
|
||||
pollfd_list.pollfds = rb_malloc(rb_getmaxconnect() * (sizeof(struct pollfd)));
|
||||
pollfd_list.allocated = rb_getmaxconnect();
|
||||
for (fd = 0; fd < rb_getmaxconnect(); fd++)
|
||||
for(fd = 0; fd < rb_getmaxconnect(); fd++)
|
||||
{
|
||||
pollfd_list.pollfds[fd].fd = -1;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ resize_pollarray(int fd)
|
|||
rb_realloc(pollfd_list.pollfds,
|
||||
pollfd_list.allocated * (sizeof(struct pollfd)));
|
||||
memset(&pollfd_list.pollfds[old_value + 1], 0, sizeof(struct pollfd) * 1024);
|
||||
for (x = old_value + 1; x < pollfd_list.allocated; x++)
|
||||
for(x = old_value + 1; x < pollfd_list.allocated; x++)
|
||||
{
|
||||
pollfd_list.pollfds[x].fd = -1;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ resize_pollarray(int fd)
|
|||
*/
|
||||
|
||||
int
|
||||
rb_setup_fd_sigio(rb_fde_t * F)
|
||||
rb_setup_fd_sigio(rb_fde_t *F)
|
||||
{
|
||||
int flags = 0;
|
||||
int fd = F->fd;
|
||||
|
@ -162,7 +162,7 @@ rb_setup_fd_sigio(rb_fde_t * F)
|
|||
* and deregister interest in a pending IO state for a given FD.
|
||||
*/
|
||||
void
|
||||
rb_setselect_sigio(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_sigio(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
if(F == NULL)
|
||||
return;
|
||||
|
@ -194,7 +194,7 @@ rb_setselect_sigio(rb_fde_t * F, unsigned int type, PF * handler, void *client_d
|
|||
pollfd_list.pollfds[F->fd].fd = -1;
|
||||
if(F->fd == pollfd_list.maxindex)
|
||||
{
|
||||
while (pollfd_list.maxindex >= 0
|
||||
while(pollfd_list.maxindex >= 0
|
||||
&& pollfd_list.pollfds[pollfd_list.maxindex].fd == -1)
|
||||
pollfd_list.maxindex--;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ rb_select_sigio(long delay)
|
|||
timeout.tv_nsec = (delay % 1000) * 1000000;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
for(;;)
|
||||
{
|
||||
if(!sigio_is_screwed)
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ rb_select_sigio(long delay)
|
|||
#ifdef SIGIO_SCHED_EVENT
|
||||
if(sig == RTSIGTIM && can_do_event)
|
||||
{
|
||||
struct ev_entry *ev = (struct ev_entry *) si.si_ptr;
|
||||
struct ev_entry *ev = (struct ev_entry *)si.si_ptr;
|
||||
if(ev == NULL)
|
||||
continue;
|
||||
rb_run_event(ev);
|
||||
|
@ -335,7 +335,7 @@ rb_select_sigio(long delay)
|
|||
return RB_OK;
|
||||
|
||||
/* XXX we *could* optimise by falling out after doing num fds ... */
|
||||
for (ci = 0; ci < pollfd_list.maxindex + 1; ci++)
|
||||
for(ci = 0; ci < pollfd_list.maxindex + 1; ci++)
|
||||
{
|
||||
if(((revents = pollfd_list.pollfds[ci].revents) == 0)
|
||||
|| (pollfd_list.pollfds[ci].fd) == -1)
|
||||
|
@ -458,7 +458,7 @@ rb_init_netio_sigio(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_sigio(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_sigio(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return;
|
||||
|
@ -472,7 +472,7 @@ rb_select_sigio(long delay)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_sigio(rb_fde_t * F)
|
||||
rb_setup_fd_sigio(rb_fde_t *F)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* The original headers are below..
|
||||
* Note that this implementation does not process floating point numbers so
|
||||
* you will likely need to fall back to using sprintf yourself to do those...
|
||||
* $Id: snprintf.c 25375 2008-05-16 15:19:51Z androsyn $
|
||||
* $Id: snprintf.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -27,12 +27,13 @@
|
|||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
||||
static int skip_atoi(const char **s)
|
||||
static int
|
||||
skip_atoi(const char **s)
|
||||
{
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
while (isdigit(**s))
|
||||
i = i*10 + *((*s)++) - '0';
|
||||
while(isdigit(**s))
|
||||
i = i * 10 + *((*s)++) - '0';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -46,50 +47,56 @@ static int skip_atoi(const char **s)
|
|||
/* 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)
|
||||
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);
|
||||
d1 = (q >> 4) & 0xf;
|
||||
d2 = (q >> 8) & 0xf;
|
||||
d3 = (q >> 12);
|
||||
|
||||
d0 = 6*(d3 + d2 + d1) + (q & 0xf);
|
||||
d0 = 6 * (d3 + d2 + d1) + (q & 0xf);
|
||||
q = (d0 * 0xcd) >> 11;
|
||||
d0 = d0 - 10*q;
|
||||
d0 = d0 - 10 * q;
|
||||
*buf++ = d0 + '0'; /* least significant digit */
|
||||
d1 = q + 9*d3 + 5*d2 + d1;
|
||||
if (d1 != 0) {
|
||||
d1 = q + 9 * d3 + 5 * d2 + d1;
|
||||
if(d1 != 0)
|
||||
{
|
||||
q = (d1 * 0xcd) >> 11;
|
||||
d1 = d1 - 10*q;
|
||||
d1 = d1 - 10 * q;
|
||||
*buf++ = d1 + '0'; /* next digit */
|
||||
|
||||
d2 = q + 2*d2;
|
||||
if ((d2 != 0) || (d3 != 0)) {
|
||||
d2 = q + 2 * d2;
|
||||
if((d2 != 0) || (d3 != 0))
|
||||
{
|
||||
q = (d2 * 0xd) >> 7;
|
||||
d2 = d2 - 10*q;
|
||||
d2 = d2 - 10 * q;
|
||||
*buf++ = d2 + '0'; /* next digit */
|
||||
|
||||
d3 = q + 4*d3;
|
||||
if (d3 != 0) {
|
||||
d3 = q + 4 * d3;
|
||||
if(d3 != 0)
|
||||
{
|
||||
q = (d3 * 0xcd) >> 11;
|
||||
d3 = d3 - 10*q;
|
||||
d3 = d3 - 10 * q;
|
||||
*buf++ = d3 + '0'; /* next digit */
|
||||
if (q != 0)
|
||||
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)
|
||||
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);
|
||||
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 */
|
||||
|
@ -99,34 +106,36 @@ static char* put_dec_full(char *buf, unsigned q)
|
|||
// (x * 0x1a) >> 8: 11010 - same
|
||||
// (x * 0x0d) >> 7: 1101 - same, shortest code (on i386)
|
||||
|
||||
d0 = 6*(d3 + d2 + d1) + (q & 0xf);
|
||||
d0 = 6 * (d3 + d2 + d1) + (q & 0xf);
|
||||
q = (d0 * 0xcd) >> 11;
|
||||
d0 = d0 - 10*q;
|
||||
d0 = d0 - 10 * q;
|
||||
*buf++ = d0 + '0';
|
||||
d1 = q + 9*d3 + 5*d2 + d1;
|
||||
d1 = q + 9 * d3 + 5 * d2 + d1;
|
||||
q = (d1 * 0xcd) >> 11;
|
||||
d1 = d1 - 10*q;
|
||||
d1 = d1 - 10 * q;
|
||||
*buf++ = d1 + '0';
|
||||
|
||||
d2 = q + 2*d2;
|
||||
d2 = q + 2 * d2;
|
||||
q = (d2 * 0xd) >> 7;
|
||||
d2 = d2 - 10*q;
|
||||
d2 = d2 - 10 * q;
|
||||
*buf++ = d2 + '0';
|
||||
|
||||
d3 = q + 4*d3;
|
||||
d3 = q + 4 * d3;
|
||||
q = (d3 * 0xcd) >> 11; /* - shorter code */
|
||||
/* q = (d3 * 0x67) >> 10; - would also work */
|
||||
d3 = d3 - 10*q;
|
||||
d3 = d3 - 10 * q;
|
||||
*buf++ = d3 + '0';
|
||||
*buf++ = q + '0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char* put_dec(char *buf, unsigned long long int num)
|
||||
static char *
|
||||
put_dec(char *buf, unsigned long long int num)
|
||||
{
|
||||
while (1) {
|
||||
while(1)
|
||||
{
|
||||
unsigned rem;
|
||||
if (num < 100000)
|
||||
if(num < 100000)
|
||||
return put_dec_trunc(buf, num);
|
||||
rem = num % 100000;
|
||||
num = num / 100000;
|
||||
|
@ -142,9 +151,11 @@ static char* put_dec(char *buf, unsigned long long int num)
|
|||
#define SPECIAL 32 /* 0x */
|
||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
|
||||
static char *number(char *buf, char *end, unsigned long long int num, int base, int size, int precision, int type)
|
||||
static char *
|
||||
number(char *buf, char *end, unsigned long long int num, int base, int size, int precision,
|
||||
int type)
|
||||
{
|
||||
char sign,tmp[66];
|
||||
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"; */
|
||||
|
@ -153,104 +164,127 @@ static char *number(char *buf, char *end, unsigned long long int num, int base,
|
|||
int i;
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
if(type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
if(base < 2 || base > 36)
|
||||
return NULL;
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if ((signed long long int) num < 0) {
|
||||
if(type & SIGN)
|
||||
{
|
||||
if((signed long long int)num < 0)
|
||||
{
|
||||
sign = '-';
|
||||
num = - (signed long long int) num;
|
||||
num = -(signed long long int)num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
}
|
||||
else if(type & PLUS)
|
||||
{
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
}
|
||||
else if(type & SPACE)
|
||||
{
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
if (need_pfx) {
|
||||
if(need_pfx)
|
||||
{
|
||||
size--;
|
||||
if (base == 16)
|
||||
if(base == 16)
|
||||
size--;
|
||||
}
|
||||
|
||||
/* generate full string in tmp[], in reverse order */
|
||||
i = 0;
|
||||
if (num == 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 */
|
||||
else if(base != 10)
|
||||
{ /* 8 or 16 */
|
||||
int mask = base - 1;
|
||||
int shift = 3;
|
||||
if (base == 16) shift = 4;
|
||||
do {
|
||||
if(base == 16)
|
||||
shift = 4;
|
||||
do
|
||||
{
|
||||
tmp[i++] = digits[((unsigned char)num) & mask];
|
||||
num >>= shift;
|
||||
} while (num);
|
||||
} else { /* base 10 */
|
||||
}
|
||||
while(num);
|
||||
}
|
||||
else
|
||||
{ /* base 10 */
|
||||
i = put_dec(tmp, num) - tmp;
|
||||
}
|
||||
|
||||
/* printing 100 using %2d gives "100", not "00" */
|
||||
if (i > precision)
|
||||
if(i > precision)
|
||||
precision = i;
|
||||
/* leading space padding */
|
||||
size -= precision;
|
||||
if (!(type & (ZEROPAD+LEFT))) {
|
||||
while(--size >= 0) {
|
||||
if (buf < end)
|
||||
if(!(type & (ZEROPAD + LEFT)))
|
||||
{
|
||||
while(--size >= 0)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
/* sign */
|
||||
if (sign) {
|
||||
if (buf < end)
|
||||
if(sign)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
/* "0x" / "0" prefix */
|
||||
if (need_pfx) {
|
||||
if (buf < end)
|
||||
if(need_pfx)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
if (base == 16) {
|
||||
if (buf < end)
|
||||
if(base == 16)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = digits[16]; /* for arbitrary base: digits[33]; */
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
/* zero or space padding */
|
||||
if (!(type & LEFT)) {
|
||||
if(!(type & LEFT))
|
||||
{
|
||||
char c = (type & ZEROPAD) ? '0' : ' ';
|
||||
while (--size >= 0) {
|
||||
if (buf < end)
|
||||
while(--size >= 0)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
/* hmm even more zero padding? */
|
||||
while (i <= --precision) {
|
||||
if (buf < end)
|
||||
while(i <= --precision)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
}
|
||||
/* actual digits of result */
|
||||
while (--i >= 0) {
|
||||
if (buf < end)
|
||||
while(--i >= 0)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
/* trailing space padding */
|
||||
while (--size >= 0) {
|
||||
if (buf < end)
|
||||
while(--size >= 0)
|
||||
{
|
||||
if(buf < end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
|
@ -275,7 +309,8 @@ static char *number(char *buf, char *end, unsigned long long int num, int base,
|
|||
* 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
|
||||
rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
{
|
||||
int len;
|
||||
unsigned long long int num;
|
||||
|
@ -295,7 +330,8 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
|
||||
/* Reject out-of-range values early. Large positive sizes are
|
||||
used for unknown buffer sizes. */
|
||||
if (rb_unlikely((int) size < 0)) {
|
||||
if(rb_unlikely((int)size < 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -303,14 +339,17 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
end = buf + size;
|
||||
|
||||
/* Make sure end is always >= buf */
|
||||
if (end < buf) {
|
||||
if(end < buf)
|
||||
{
|
||||
end = ((void *)-1);
|
||||
size = end - buf;
|
||||
}
|
||||
|
||||
for (; *fmt ; ++fmt) {
|
||||
if (*fmt != '%') {
|
||||
if (str < end)
|
||||
for(; *fmt; ++fmt)
|
||||
{
|
||||
if(*fmt != '%')
|
||||
{
|
||||
if(str < end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
continue;
|
||||
|
@ -320,23 +359,36 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
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;
|
||||
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))
|
||||
if(isdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
else if(*fmt == '*')
|
||||
{
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
if(field_width < 0)
|
||||
{
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
|
@ -344,26 +396,30 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
|
||||
/* get the precision */
|
||||
precision = -1;
|
||||
if (*fmt == '.') {
|
||||
if(*fmt == '.')
|
||||
{
|
||||
++fmt;
|
||||
if (isdigit(*fmt))
|
||||
if(isdigit(*fmt))
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
else if(*fmt == '*')
|
||||
{
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
if(precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
/* get the conversion qualifier */
|
||||
qualifier = -1;
|
||||
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
|
||||
*fmt =='Z' || *fmt == 'z' || *fmt == 't') {
|
||||
if(*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
|
||||
*fmt == 'Z' || *fmt == 'z' || *fmt == 't')
|
||||
{
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
if (qualifier == 'l' && *fmt == 'l') {
|
||||
if(qualifier == 'l' && *fmt == 'l')
|
||||
{
|
||||
qualifier = 'L';
|
||||
++fmt;
|
||||
}
|
||||
|
@ -372,21 +428,25 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
/* default base */
|
||||
base = 10;
|
||||
|
||||
switch (*fmt) {
|
||||
switch (*fmt)
|
||||
{
|
||||
case 'c':
|
||||
if (!(flags & LEFT)) {
|
||||
while (--field_width > 0) {
|
||||
if (str < end)
|
||||
if(!(flags & LEFT))
|
||||
{
|
||||
while(--field_width > 0)
|
||||
{
|
||||
if(str < end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
}
|
||||
c = (unsigned char) va_arg(args, int);
|
||||
if (str < end)
|
||||
c = (unsigned char)va_arg(args, int);
|
||||
if(str < end)
|
||||
*str = c;
|
||||
++str;
|
||||
while (--field_width > 0) {
|
||||
if (str < end)
|
||||
while(--field_width > 0)
|
||||
{
|
||||
if(str < end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
|
@ -394,37 +454,44 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
|
||||
case 's':
|
||||
s = va_arg(args, char *);
|
||||
if (s == NULL) {
|
||||
if(s == NULL)
|
||||
{
|
||||
abort(); /* prefer blowing up vs corrupt data */
|
||||
}
|
||||
len = rb_strnlen(s, precision);
|
||||
|
||||
if (!(flags & LEFT)) {
|
||||
while (len < field_width--) {
|
||||
if (str < end)
|
||||
if(!(flags & LEFT))
|
||||
{
|
||||
while(len < field_width--)
|
||||
{
|
||||
if(str < end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (str < end)
|
||||
for(i = 0; i < len; ++i)
|
||||
{
|
||||
if(str < end)
|
||||
*str = *s;
|
||||
++str; ++s;
|
||||
++str;
|
||||
++s;
|
||||
}
|
||||
while (len < field_width--) {
|
||||
if (str < end)
|
||||
while(len < field_width--)
|
||||
{
|
||||
if(str < end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if (field_width == -1) {
|
||||
field_width = 2*sizeof(void *);
|
||||
if(field_width == -1)
|
||||
{
|
||||
field_width = 2 * sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str, end,
|
||||
(unsigned long) va_arg(args, void *),
|
||||
(unsigned long)va_arg(args, void *),
|
||||
16, field_width, precision, flags);
|
||||
continue;
|
||||
|
||||
|
@ -432,20 +499,25 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
case 'n':
|
||||
/* FIXME:
|
||||
* What does C99 say about the overflow case here? */
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
if(qualifier == 'l')
|
||||
{
|
||||
long *ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
} else if (qualifier == 'Z' || qualifier == 'z') {
|
||||
size_t * ip = va_arg(args, size_t *);
|
||||
}
|
||||
else if(qualifier == 'Z' || qualifier == 'z')
|
||||
{
|
||||
size_t *ip = va_arg(args, size_t *);
|
||||
*ip = (str - buf);
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
}
|
||||
else
|
||||
{
|
||||
int *ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
}
|
||||
continue;
|
||||
|
||||
case '%':
|
||||
if (str < end)
|
||||
if(str < end)
|
||||
*str = '%';
|
||||
++str;
|
||||
continue;
|
||||
|
@ -468,48 +540,60 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (str < end)
|
||||
if(str < end)
|
||||
*str = '%';
|
||||
++str;
|
||||
if (*fmt) {
|
||||
if (str < end)
|
||||
if(*fmt)
|
||||
{
|
||||
if(str < end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
--fmt;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (qualifier == 'L')
|
||||
if(qualifier == 'L')
|
||||
num = va_arg(args, long long int);
|
||||
else if (qualifier == 'l') {
|
||||
else if(qualifier == 'l')
|
||||
{
|
||||
num = va_arg(args, unsigned long);
|
||||
if (flags & SIGN)
|
||||
num = (signed long) num;
|
||||
} else if (qualifier == 'Z' || qualifier == 'z') {
|
||||
if(flags & SIGN)
|
||||
num = (signed long)num;
|
||||
}
|
||||
else if(qualifier == 'Z' || qualifier == 'z')
|
||||
{
|
||||
num = va_arg(args, size_t);
|
||||
} else if (qualifier == '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 {
|
||||
}
|
||||
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;
|
||||
if(flags & SIGN)
|
||||
num = (signed int)num;
|
||||
}
|
||||
str = number(str, end, num, base,
|
||||
field_width, precision, flags);
|
||||
str = number(str, end, num, base, field_width, precision, flags);
|
||||
}
|
||||
if (size > 0) {
|
||||
if (str < end)
|
||||
if(size > 0)
|
||||
{
|
||||
if(str < end)
|
||||
*str = '\0';
|
||||
else
|
||||
end[-1] = '\0';
|
||||
}
|
||||
/* the trailing null byte doesn't count towards the total */
|
||||
return str-buf;
|
||||
return str - buf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -524,13 +608,14 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
|||
* 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, ...)
|
||||
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);
|
||||
i = rb_vsnprintf(buf, size, fmt, args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
@ -548,7 +633,8 @@ int rb_snprintf(char * buf, size_t size, const char *fmt, ...)
|
|||
* 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)
|
||||
int
|
||||
rb_vsprintf(char *buf, const char *fmt, va_list args)
|
||||
{
|
||||
return rb_vsnprintf(buf, INT_MAX, fmt, args);
|
||||
}
|
||||
|
@ -563,13 +649,14 @@ int rb_vsprintf(char *buf, const char *fmt, va_list args)
|
|||
* into @buf. Use snprintf() or scnprintf() in order to avoid
|
||||
* buffer overflows.
|
||||
*/
|
||||
int rb_sprintf(char * buf, const char *fmt, ...)
|
||||
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);
|
||||
i = rb_vsnprintf(buf, INT_MAX, fmt, args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
@ -583,7 +670,7 @@ 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);
|
||||
return (rb_vsprintf(str + x, format, ap) + x);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -598,7 +685,7 @@ rb_sprintf_append(char *str, const char *format, ...)
|
|||
va_start(ap, format);
|
||||
x = rb_vsprintf_append(str, format, ap);
|
||||
va_end(ap);
|
||||
return(x);
|
||||
return (x);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -610,8 +697,17 @@ rb_sprintf_append(char *str, const char *format, ...)
|
|||
int
|
||||
rb_vsnprintf_append(char *str, size_t len, const char *format, va_list ap)
|
||||
{
|
||||
size_t x = strlen(str);
|
||||
return(rb_vsnprintf(str+x, len - x, format, ap) + x);
|
||||
size_t x;
|
||||
if(len == 0)
|
||||
return 0;
|
||||
x = strlen(str);
|
||||
|
||||
if(len < x)
|
||||
{
|
||||
str[len - 1] = '\0';
|
||||
return len - 1;
|
||||
}
|
||||
return (rb_vsnprintf(str + x, len - x, format, ap) + x);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -628,6 +724,5 @@ rb_snprintf_append(char *str, size_t len, const char *format, ...)
|
|||
va_start(ap, format);
|
||||
x = rb_vsnprintf_append(str, len, format, ap);
|
||||
va_end(ap);
|
||||
return(x);
|
||||
return (x);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: tools.c 25040 2008-01-23 16:11:34Z androsyn $
|
||||
* $Id: tools.c 26170 2008-10-26 20:59:07Z androsyn $
|
||||
*
|
||||
* Here is the original header:
|
||||
*
|
||||
|
@ -62,7 +62,7 @@ rb_init_rb_dlink_nodes(size_t dh_size)
|
|||
rb_dlink_node *
|
||||
rb_make_rb_dlink_node(void)
|
||||
{
|
||||
return(rb_bh_alloc(dnode_heap));
|
||||
return (rb_bh_alloc(dnode_heap));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,7 +73,7 @@ rb_make_rb_dlink_node(void)
|
|||
* side effects - free given rb_dlink_node
|
||||
*/
|
||||
void
|
||||
rb_free_rb_dlink_node(rb_dlink_node * ptr)
|
||||
rb_free_rb_dlink_node(rb_dlink_node *ptr)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
rb_bh_free(dnode_heap, ptr);
|
||||
|
@ -97,7 +97,7 @@ rb_string_to_array(char *string, char **parv, int maxpara)
|
|||
if(string == NULL || string[0] == '\0')
|
||||
return x;
|
||||
|
||||
while (*xbuf == ' ') /* skip leading spaces */
|
||||
while(*xbuf == ' ') /* skip leading spaces */
|
||||
xbuf++;
|
||||
if(*xbuf == '\0') /* ignore all-space args */
|
||||
return x;
|
||||
|
@ -123,12 +123,12 @@ rb_string_to_array(char *string, char **parv, int maxpara)
|
|||
else
|
||||
return x;
|
||||
}
|
||||
while (*xbuf == ' ')
|
||||
while(*xbuf == ' ')
|
||||
xbuf++;
|
||||
if(*xbuf == '\0')
|
||||
return x;
|
||||
}
|
||||
while (x < maxpara - 1);
|
||||
while(x < maxpara - 1);
|
||||
|
||||
if(*p == ':')
|
||||
p++;
|
||||
|
@ -148,8 +148,8 @@ rb_strlcat(char *dest, const char *src, size_t count)
|
|||
|
||||
dest += dsize;
|
||||
count -= dsize;
|
||||
if (len >= count)
|
||||
len = count-1;
|
||||
if(len >= count)
|
||||
len = count - 1;
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = 0;
|
||||
return res;
|
||||
|
@ -168,8 +168,9 @@ rb_strlcpy(char *dest, const char *src, size_t size)
|
|||
{
|
||||
size_t ret = strlen(src);
|
||||
|
||||
if (size) {
|
||||
size_t len = (ret >= size) ? size-1 : ret;
|
||||
if(size)
|
||||
{
|
||||
size_t len = (ret >= size) ? size - 1 : ret;
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
|
@ -189,7 +190,7 @@ size_t
|
|||
rb_strnlen(const char *s, size_t count)
|
||||
{
|
||||
const char *sc;
|
||||
for (sc = s; count-- && *sc != '\0'; ++sc)
|
||||
for(sc = s; count-- && *sc != '\0'; ++sc)
|
||||
;;
|
||||
return sc - s;
|
||||
}
|
||||
|
@ -201,3 +202,42 @@ rb_strnlen(const char *s, size_t count)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* rb_basename
|
||||
*
|
||||
* input -
|
||||
* output -
|
||||
* side effects -
|
||||
*/
|
||||
char *
|
||||
rb_basename(const char *path)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if(!(s = strrchr(path, '/')))
|
||||
s = path;
|
||||
else
|
||||
s++;
|
||||
return rb_strdup(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* rb_dirname
|
||||
*/
|
||||
|
||||
char *
|
||||
rb_dirname (const char *path)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = strrchr(path, '/');
|
||||
if(s == NULL)
|
||||
{
|
||||
return rb_strdup(".");
|
||||
}
|
||||
|
||||
/* remove extra slashes */
|
||||
while(s > path && *s == '/')
|
||||
--s;
|
||||
|
||||
return rb_strndup(path, ((uintptr_t)s - (uintptr_t)path) + 2);
|
||||
}
|
||||
|
|
|
@ -21,26 +21,44 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: unix.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: unix.c 26180 2008-11-11 00:00:12Z androsyn $
|
||||
*/
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
|
||||
#ifndef WINDOWS
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
|
||||
#if defined(HAVE_SPAWN_H) && defined(HAVE_POSIX_SPAWN)
|
||||
#include <spawn.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <crt_externs.h>
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
extern char **environ;
|
||||
#endif
|
||||
pid_t
|
||||
rb_spawn_process(const char *path, const char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
const void *arghack = argv;
|
||||
char **myenviron;
|
||||
posix_spawnattr_t spattr;
|
||||
posix_spawnattr_init(&spattr);
|
||||
#ifdef POSIX_SPAWN_USEVFORK
|
||||
posix_spawnattr_setflags(&spattr, POSIX_SPAWN_USEVFORK);
|
||||
#endif
|
||||
if(posix_spawn(&pid, path, NULL, &spattr, arghack, environ))
|
||||
#ifdef __APPLE__
|
||||
myenviron = *_NSGetEnviron(); /* apple needs to go fuck themselves for this */
|
||||
#else
|
||||
myenviron = environ;
|
||||
#endif
|
||||
if(posix_spawn(&pid, path, NULL, &spattr, arghack, myenviron))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -56,7 +74,7 @@ rb_spawn_process(const char *path, const char **argv)
|
|||
execv(path, (const void *)argv); /* make gcc shut up */
|
||||
_exit(1); /* if we're still here, we're screwed */
|
||||
}
|
||||
return(pid);
|
||||
return (pid);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -78,7 +96,7 @@ rb_gettimeofday(struct timeval *tv, void *tz)
|
|||
int
|
||||
rb_gettimeofday(struct timeval *tv, void *tz)
|
||||
{
|
||||
return(gettimeofday(tv, tz));
|
||||
return (gettimeofday(tv, tz));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -97,6 +115,37 @@ rb_sleep(unsigned int seconds, unsigned int useconds)
|
|||
select(0, NULL, NULL, NULL, &tv);
|
||||
#endif
|
||||
}
|
||||
#endif /* !WINDOWS */
|
||||
|
||||
/* this is to keep some linkers from bitching about exporting a non-existant symbol..bleh */
|
||||
char *
|
||||
rb_strerror(int error)
|
||||
{
|
||||
return strerror(error);
|
||||
}
|
||||
|
||||
int
|
||||
rb_kill(pid_t pid, int sig)
|
||||
{
|
||||
return kill(pid, sig);
|
||||
}
|
||||
|
||||
int
|
||||
rb_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
return setenv(name, value, overwrite);
|
||||
}
|
||||
|
||||
pid_t
|
||||
rb_waitpid(pid_t pid, int *status, int options)
|
||||
{
|
||||
return waitpid(pid, status, options);
|
||||
}
|
||||
|
||||
pid_t
|
||||
rb_getpid(void)
|
||||
{
|
||||
return getpid();
|
||||
}
|
||||
|
||||
|
||||
#endif /* !WIN32 */
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: win32.c 25038 2008-01-23 16:03:08Z androsyn $
|
||||
* $Id: win32.c 26092 2008-09-19 15:13:52Z androsyn $
|
||||
*/
|
||||
|
||||
#include <libratbox_config.h>
|
||||
#include <ratbox_lib.h>
|
||||
#include <commio-int.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
static HWND hwnd;
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef union
|
|||
#define EPOCH_BIAS Const64(116444736000000000)
|
||||
|
||||
pid_t
|
||||
getpid()
|
||||
rb_getpid()
|
||||
{
|
||||
return GetCurrentProcessId();
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ rb_gettimeofday(struct timeval *tp, void *not_used)
|
|||
GetSystemTimeAsFileTime(&ft.ft_val);
|
||||
|
||||
/* seconds since epoch */
|
||||
tp->tv_sec = (long) ((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
|
||||
tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
|
||||
|
||||
/* microseconds remaining */
|
||||
tp->tv_usec = (long) ((ft.ft_i64 / Const64(10)) % Const64(1000000));
|
||||
tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ rb_spawn_process(const char *path, const char **argv)
|
|||
}
|
||||
|
||||
pid_t
|
||||
waitpid(int pid, int *status, int flags)
|
||||
rb_waitpid(int pid, int *status, int flags)
|
||||
{
|
||||
DWORD timeout = (flags & WNOHANG) ? 0 : INFINITE;
|
||||
HANDLE hProcess;
|
||||
|
@ -113,7 +113,7 @@ waitpid(int pid, int *status, int flags)
|
|||
{
|
||||
if(GetExitCodeProcess(hProcess, &waitcode))
|
||||
{
|
||||
*status = (int) ((waitcode & 0xff) << 8);
|
||||
*status = (int)((waitcode & 0xff) << 8);
|
||||
CloseHandle(hProcess);
|
||||
return pid;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ waitpid(int pid, int *status, int flags)
|
|||
}
|
||||
|
||||
int
|
||||
setenv(const char *name, const char *value, int overwrite)
|
||||
rb_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
char *buf;
|
||||
int len;
|
||||
|
@ -152,7 +152,7 @@ setenv(const char *name, const char *value, int overwrite)
|
|||
}
|
||||
|
||||
int
|
||||
kill(int pid, int sig)
|
||||
rb_kill(int pid, int sig)
|
||||
{
|
||||
HANDLE hProcess;
|
||||
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
|
||||
|
@ -180,15 +180,134 @@ kill(int pid, int sig)
|
|||
|
||||
}
|
||||
|
||||
int
|
||||
rb_pass_fd_to_process(int fd, pid_t process, rb_fde_t *F)
|
||||
/*
|
||||
* packet format is
|
||||
uint32_t magic
|
||||
uint8_t protocol count
|
||||
WSAPROTOCOL_INFO * count
|
||||
size_t datasize
|
||||
data
|
||||
|
||||
*/
|
||||
|
||||
static int
|
||||
make_wsaprotocol_info(pid_t process, rb_fde_t *F, WSAPROTOCOL_INFO * inf)
|
||||
{
|
||||
WSAPROTOCOL_INFO info;
|
||||
WSADuplicateSocket((SOCKET)fd, process, &info);
|
||||
rb_write(F, &info, sizeof(info));
|
||||
if(!WSADuplicateSocket((SOCKET) rb_get_fd(F), process, &info))
|
||||
{
|
||||
memcpy(inf, &info, sizeof(WSAPROTOCOL_INFO));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rb_fde_t *
|
||||
make_fde_from_wsaprotocol_info(void *data)
|
||||
{
|
||||
WSAPROTOCOL_INFO *info = data;
|
||||
SOCKET t;
|
||||
t = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, info, 0, 0);
|
||||
if(t == INVALID_SOCKET)
|
||||
{
|
||||
rb_get_errno();
|
||||
return NULL;
|
||||
}
|
||||
return rb_open(t, RB_FD_SOCKET, "remote_socket");
|
||||
}
|
||||
|
||||
static uint8_t fd_buf[16384];
|
||||
#define MAGIC_CONTROL 0xFF0ACAFE
|
||||
|
||||
int
|
||||
rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid)
|
||||
{
|
||||
size_t bufsize =
|
||||
sizeof(uint32_t) + sizeof(uint8_t) + (sizeof(WSAPROTOCOL_INFO) * (size_t)count) +
|
||||
sizeof(size_t) + datasize;
|
||||
int i;
|
||||
uint32_t magic = MAGIC_CONTROL;
|
||||
void *ptr;
|
||||
if(count > 4)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(bufsize > sizeof(fd_buf))
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
memset(fd_buf, 0, sizeof(fd_buf));
|
||||
|
||||
ptr = fd_buf;
|
||||
memcpy(ptr, &magic, sizeof(magic));
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(magic));
|
||||
*((uint8_t *)ptr) = count;
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint8_t));
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
make_wsaprotocol_info(pid, F[i], (WSAPROTOCOL_INFO *) ptr);
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(WSAPROTOCOL_INFO));
|
||||
}
|
||||
memcpy(ptr, &datasize, sizeof(size_t));
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(size_t));
|
||||
memcpy(ptr, data, datasize);
|
||||
return rb_write(xF, fd_buf, bufsize);
|
||||
}
|
||||
|
||||
#ifdef MYMIN
|
||||
#undef MYMIN
|
||||
#endif
|
||||
#define MYMIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
int
|
||||
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
|
||||
{
|
||||
size_t minsize = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(size_t);
|
||||
size_t datalen;
|
||||
ssize_t retlen;
|
||||
uint32_t magic;
|
||||
uint8_t count;
|
||||
unsigned int i;
|
||||
void *ptr;
|
||||
ssize_t ret;
|
||||
memset(fd_buf, 0, sizeof(fd_buf)); /* some paranoia here... */
|
||||
ret = rb_read(F, fd_buf, sizeof(fd_buf));
|
||||
if(ret <= 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
if(ret < (ssize_t) minsize)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
ptr = fd_buf;
|
||||
memcpy(&magic, ptr, sizeof(uint32_t));
|
||||
if(magic != MAGIC_CONTROL)
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint32_t));
|
||||
memcpy(&count, ptr, sizeof(uint8_t));
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint8_t));
|
||||
for(i = 0; i < count && i < (unsigned int)nfds; i++)
|
||||
{
|
||||
rb_fde_t *tF = make_fde_from_wsaprotocol_info(ptr);
|
||||
if(tF == NULL)
|
||||
return -1;
|
||||
xF[i] = tF;
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(WSAPROTOCOL_INFO));
|
||||
}
|
||||
memcpy(&datalen, ptr, sizeof(size_t));
|
||||
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(size_t));
|
||||
retlen = MYMIN(datalen, datasize);
|
||||
memcpy(data, ptr, datalen);
|
||||
return retlen;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK
|
||||
rb_process_events(HWND nhwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
|
||||
|
@ -280,14 +399,12 @@ rb_init_netio_win32(void)
|
|||
void
|
||||
rb_sleep(unsigned int seconds, unsigned int useconds)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = seconds;
|
||||
tv.tv_usec = useconds;
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
DWORD msec = seconds * 1000;;
|
||||
Sleep(msec);
|
||||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_win32(rb_fde_t * F)
|
||||
rb_setup_fd_win32(rb_fde_t *F)
|
||||
{
|
||||
if(F == NULL)
|
||||
return 0;
|
||||
|
@ -312,7 +429,7 @@ rb_setup_fd_win32(rb_fde_t * F)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_win32(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_win32(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
int old_flags = F->pflags;
|
||||
|
||||
|
@ -379,8 +496,8 @@ rb_select_win32(long delay)
|
|||
#undef strerror
|
||||
#endif
|
||||
|
||||
const char *
|
||||
wsock_strerror(int error)
|
||||
static const char *
|
||||
_rb_strerror(int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
|
@ -488,6 +605,14 @@ wsock_strerror(int error)
|
|||
return strerror(error);
|
||||
}
|
||||
};
|
||||
|
||||
char *
|
||||
rb_strerror(int error)
|
||||
{
|
||||
static char buf[128];
|
||||
rb_strlcpy(buf, _rb_strerror(error), sizeof(buf));
|
||||
return buf;
|
||||
}
|
||||
#else /* win32 not supported */
|
||||
int
|
||||
rb_init_netio_win32(void)
|
||||
|
@ -497,7 +622,7 @@ rb_init_netio_win32(void)
|
|||
}
|
||||
|
||||
void
|
||||
rb_setselect_win32(rb_fde_t * F, unsigned int type, PF * handler, void *client_data)
|
||||
rb_setselect_win32(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return;
|
||||
|
@ -511,9 +636,9 @@ rb_select_win32(long delay)
|
|||
}
|
||||
|
||||
int
|
||||
rb_setup_fd_win32(rb_fde_t * F)
|
||||
rb_setup_fd_win32(rb_fde_t *F)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* _WIN32 */
|
||||
|
|
152
src/sslproc.c
152
src/sslproc.c
|
@ -18,11 +18,13 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: sslproc.c 25677 2008-07-06 04:21:42Z androsyn $
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <ratbox_lib.h>
|
||||
#include "stdinc.h"
|
||||
|
||||
|
||||
#include "s_conf.h"
|
||||
#include "logger.h"
|
||||
#include "listener.h"
|
||||
|
@ -37,7 +39,7 @@
|
|||
#define ZIPSTATS_TIME 60
|
||||
|
||||
static void collect_zipstats(void *unused);
|
||||
static void ssl_read_ctl(rb_fde_t *F, void *data);
|
||||
static void ssl_read_ctl(rb_fde_t * F, void *data);
|
||||
static int ssld_count;
|
||||
|
||||
static char tmpbuf[READBUF_SIZE];
|
||||
|
@ -67,34 +69,39 @@ struct _ssl_ctl
|
|||
uint8_t dead;
|
||||
};
|
||||
|
||||
static void send_new_ssl_certs_one(ssl_ctl_t *ctl, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params);
|
||||
static void send_init_prng(ssl_ctl_t *ctl, prng_seed_t seedtype, const char *path);
|
||||
static void send_new_ssl_certs_one(ssl_ctl_t * ctl, const char *ssl_cert,
|
||||
const char *ssl_private_key, const char *ssl_dh_params);
|
||||
static void send_init_prng(ssl_ctl_t * ctl, prng_seed_t seedtype, const char *path);
|
||||
|
||||
|
||||
static rb_dlink_list ssl_daemons;
|
||||
|
||||
static inline int32_t buf_to_int32(char *buf)
|
||||
static inline int32_t
|
||||
buf_to_int32(char *buf)
|
||||
{
|
||||
int32_t x;
|
||||
memcpy(&x, buf, sizeof(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void int32_to_buf(char *buf, int32_t x)
|
||||
static inline void
|
||||
int32_to_buf(char *buf, int32_t x)
|
||||
{
|
||||
memcpy(buf, &x, sizeof(x));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline uint16_t buf_to_uint16(char *buf)
|
||||
static inline uint16_t
|
||||
buf_to_uint16(char *buf)
|
||||
{
|
||||
uint16_t x;
|
||||
memcpy(&x, buf, sizeof(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void uint16_to_buf(char *buf, uint16_t x)
|
||||
static inline void
|
||||
uint16_to_buf(char *buf, uint16_t x)
|
||||
{
|
||||
memcpy(buf, &x, sizeof(x));
|
||||
return;
|
||||
|
@ -102,7 +109,7 @@ static inline void uint16_to_buf(char *buf, uint16_t x)
|
|||
|
||||
|
||||
static ssl_ctl_t *
|
||||
allocate_ssl_daemon(rb_fde_t *F, rb_fde_t *P, int pid)
|
||||
allocate_ssl_daemon(rb_fde_t * F, rb_fde_t * P, int pid)
|
||||
{
|
||||
ssl_ctl_t *ctl;
|
||||
|
||||
|
@ -118,7 +125,7 @@ allocate_ssl_daemon(rb_fde_t *F, rb_fde_t *P, int pid)
|
|||
}
|
||||
|
||||
static void
|
||||
free_ssl_daemon(ssl_ctl_t *ctl)
|
||||
free_ssl_daemon(ssl_ctl_t * ctl)
|
||||
{
|
||||
rb_dlink_node *ptr;
|
||||
ssl_ctl_buf_t *ctl_buf;
|
||||
|
@ -170,26 +177,26 @@ ssl_killall(void)
|
|||
continue;
|
||||
ctl->dead = 1;
|
||||
ssld_count--;
|
||||
kill(ctl->pid, SIGKILL);
|
||||
rb_kill(ctl->pid, SIGKILL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_dead(ssl_ctl_t *ctl)
|
||||
ssl_dead(ssl_ctl_t * ctl)
|
||||
{
|
||||
if(ctl->dead)
|
||||
return;
|
||||
|
||||
ctl->dead = 1;
|
||||
ssld_count--;
|
||||
kill(ctl->pid, SIGKILL); /* make sure the process is really gone */
|
||||
rb_kill(ctl->pid, SIGKILL); /* make sure the process is really gone */
|
||||
ilog(L_MAIN, "ssld helper died - attempting to restart");
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld helper died - attempting to restart");
|
||||
start_ssldaemon(1, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params);
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_do_pipe(rb_fde_t *F, void *data)
|
||||
ssl_do_pipe(rb_fde_t * F, void *data)
|
||||
{
|
||||
int retlen;
|
||||
ssl_ctl_t *ctl = data;
|
||||
|
@ -222,10 +229,17 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
|
|||
{
|
||||
rb_fde_t *F1, *F2;
|
||||
rb_fde_t *P1, *P2;
|
||||
#ifdef _WIN32
|
||||
const char *suffix = ".exe";
|
||||
#else
|
||||
const char *suffix = "";
|
||||
#endif
|
||||
|
||||
char fullpath[PATH_MAX + 1];
|
||||
char fdarg[6];
|
||||
const char *parv[2];
|
||||
char buf[128];
|
||||
char s_pid[10];
|
||||
pid_t pid;
|
||||
int started = 0, i;
|
||||
|
||||
|
@ -235,7 +249,8 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
|
|||
if(ssld_spin_count > 20 && (rb_current_time() - last_spin < 5))
|
||||
{
|
||||
ilog(L_MAIN, "ssld helper is spinning - will attempt to restart in 1 minute");
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld helper is spinning - will attempt to restart in 1 minute");
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"ssld helper is spinning - will attempt to restart in 1 minute");
|
||||
rb_event_add("restart_ssld_event", restart_ssld_event, NULL, 60);
|
||||
ssld_wait = 1;
|
||||
return 0;
|
||||
|
@ -243,22 +258,25 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
|
|||
|
||||
ssld_spin_count++;
|
||||
last_spin = rb_current_time();
|
||||
|
||||
if(ssld_path == NULL)
|
||||
{
|
||||
rb_snprintf(fullpath, sizeof(fullpath), "%s/ssld", BINPATH);
|
||||
rb_snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", BINPATH, suffix);
|
||||
|
||||
if(access(fullpath, X_OK) == -1)
|
||||
{
|
||||
rb_snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld", ConfigFileEntry.dpath);
|
||||
rb_snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld%s",
|
||||
ConfigFileEntry.dpath, suffix);
|
||||
if(access(fullpath, X_OK) == -1)
|
||||
{
|
||||
ilog(L_MAIN, "Unable to execute ssld in %s/bin or %s", ConfigFileEntry.dpath, BINPATH);
|
||||
return 0 ;
|
||||
ilog(L_MAIN,
|
||||
"Unable to execute ssld%s in %s/bin or %s",
|
||||
ConfigFileEntry.dpath, suffix, BINPATH);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ssld_path = rb_strdup(fullpath);
|
||||
}
|
||||
|
||||
rb_strlcpy(buf, "-ircd ssld daemon helper", sizeof(buf));
|
||||
parv[0] = buf;
|
||||
parv[1] = NULL;
|
||||
|
@ -270,12 +288,18 @@ 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);
|
||||
rb_snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(F2));
|
||||
setenv("CTL_FD", fdarg, 1);
|
||||
rb_setenv("CTL_FD", fdarg, 1);
|
||||
rb_pipe(&P1, &P2, "SSL/TLS pipe");
|
||||
rb_snprintf(fdarg, sizeof(fdarg), "%d", rb_get_fd(P1));
|
||||
setenv("CTL_PIPE", fdarg, 1);
|
||||
rb_setenv("CTL_PIPE", fdarg, 1);
|
||||
rb_snprintf(s_pid, sizeof(s_pid), "%d", getpid());
|
||||
rb_setenv("CTL_PPID", s_pid, 1);
|
||||
#ifdef _WIN32
|
||||
SetHandleInformation((HANDLE) rb_get_fd(F2), HANDLE_FLAG_INHERIT, 1);
|
||||
SetHandleInformation((HANDLE) rb_get_fd(P1), HANDLE_FLAG_INHERIT, 1);
|
||||
#endif
|
||||
|
||||
pid = rb_spawn_process(ssld_path, (const char **)parv);
|
||||
pid = rb_spawn_process(ssld_path, (const char **) parv);
|
||||
if(pid == -1)
|
||||
{
|
||||
ilog(L_MAIN, "Unable to create ssld: %s\n", strerror(errno));
|
||||
|
@ -297,15 +321,17 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co
|
|||
send_init_prng(ctl, RB_PRNG_DEFAULT, NULL);
|
||||
}
|
||||
if(ssl_ok && ssl_cert != NULL && ssl_private_key != NULL)
|
||||
send_new_ssl_certs_one(ctl, ssl_cert, ssl_private_key, ssl_dh_params != NULL ? ssl_dh_params : "");
|
||||
send_new_ssl_certs_one(ctl, ssl_cert, ssl_private_key,
|
||||
ssl_dh_params != NULL ? ssl_dh_params : "");
|
||||
ssl_read_ctl(ctl->F, ctl);
|
||||
ssl_do_pipe(P2, ctl);
|
||||
|
||||
}
|
||||
return started;
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_process_zipstats(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
||||
ssl_process_zipstats(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
||||
{
|
||||
struct Client *server;
|
||||
struct ZipStats *zips;
|
||||
|
@ -326,18 +352,18 @@ ssl_process_zipstats(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
|||
zips->out_wire += strtoull(parv[5], NULL, 10);
|
||||
|
||||
if(zips->in > 0)
|
||||
zips->in_ratio = ((double)(zips->in - zips->in_wire) / (double) zips->in) * 100.00;
|
||||
zips->in_ratio = ((double) (zips->in - zips->in_wire) / (double) zips->in) * 100.00;
|
||||
else
|
||||
zips->in_ratio = 0;
|
||||
|
||||
if(zips->out > 0)
|
||||
zips->out_ratio = ((double)(zips->out - zips->out_wire) / (double) zips->out) * 100.00;
|
||||
zips->out_ratio = ((double) (zips->out - zips->out_wire) / (double) zips->out) * 100.00;
|
||||
else
|
||||
zips->out_ratio = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_process_dead_fd(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
||||
ssl_process_dead_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
||||
{
|
||||
struct Client *client_p;
|
||||
char reason[256];
|
||||
|
@ -353,7 +379,7 @@ ssl_process_dead_fd(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
|||
return;
|
||||
if(IsAnyServer(client_p))
|
||||
{
|
||||
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL, "ssld error for %s: %s", client_p->name, reason);
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld error for %s: %s", client_p->name, reason);
|
||||
ilog(L_SERVER, "ssld error for %s: %s", log_client_name(client_p, SHOW_IP), reason);
|
||||
}
|
||||
exit_client(client_p, client_p, &me, reason);
|
||||
|
@ -361,7 +387,7 @@ ssl_process_dead_fd(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
|||
|
||||
|
||||
static void
|
||||
ssl_process_zip_ready(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
||||
ssl_process_zip_ready(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
||||
{
|
||||
struct Client *client_p;
|
||||
int32_t fd;
|
||||
|
@ -383,7 +409,7 @@ ssl_process_zip_ready(ssl_ctl_t *ctl, ssl_ctl_buf_t *ctl_buf)
|
|||
|
||||
|
||||
static void
|
||||
ssl_process_cmd_recv(ssl_ctl_t *ctl)
|
||||
ssl_process_cmd_recv(ssl_ctl_t * ctl)
|
||||
{
|
||||
static const char *cannot_setup_ssl = "ssld cannot setup ssl, check your certificates and private key";
|
||||
static const char *no_ssl_or_zlib = "ssld has neither SSL/TLS or zlib support killing all sslds";
|
||||
|
@ -394,7 +420,7 @@ ssl_process_cmd_recv(ssl_ctl_t *ctl)
|
|||
RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head)
|
||||
{
|
||||
ctl_buf = ptr->data;
|
||||
switch(*ctl_buf->buf)
|
||||
switch (*ctl_buf->buf)
|
||||
{
|
||||
case 'N':
|
||||
ssl_ok = 0; /* ssld says it can't do ssl/tls */
|
||||
|
@ -436,7 +462,7 @@ ssl_process_cmd_recv(ssl_ctl_t *ctl)
|
|||
|
||||
|
||||
static void
|
||||
ssl_read_ctl(rb_fde_t *F, void *data)
|
||||
ssl_read_ctl(rb_fde_t * F, void *data)
|
||||
{
|
||||
ssl_ctl_buf_t *ctl_buf;
|
||||
ssl_ctl_t *ctl = data;
|
||||
|
@ -450,13 +476,15 @@ ssl_read_ctl(rb_fde_t *F, void *data)
|
|||
ctl_buf->buf = rb_malloc(READSIZE);
|
||||
retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, READSIZE, ctl_buf->F, 4);
|
||||
ctl_buf->buflen = retlen;
|
||||
if(retlen <= 0) {
|
||||
if(retlen <= 0)
|
||||
{
|
||||
rb_free(ctl_buf->buf);
|
||||
rb_free(ctl_buf);
|
||||
}
|
||||
else
|
||||
rb_dlinkAddTail(ctl_buf, &ctl_buf->node, &ctl->readq);
|
||||
} while(retlen > 0);
|
||||
}
|
||||
while(retlen > 0);
|
||||
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
|
||||
{
|
||||
|
@ -478,18 +506,19 @@ which_ssld(void)
|
|||
ctl = ptr->data;
|
||||
if(ctl->dead)
|
||||
continue;
|
||||
if(lowest == NULL) {
|
||||
if(lowest == NULL)
|
||||
{
|
||||
lowest = ctl;
|
||||
continue;
|
||||
}
|
||||
if(ctl->cli_count < lowest->cli_count)
|
||||
lowest = ctl;
|
||||
}
|
||||
return(lowest);
|
||||
return (lowest);
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_write_ctl(rb_fde_t *F, void *data)
|
||||
ssl_write_ctl(rb_fde_t * F, void *data)
|
||||
{
|
||||
ssl_ctl_t *ctl = data;
|
||||
ssl_ctl_buf_t *ctl_buf;
|
||||
|
@ -503,7 +532,7 @@ ssl_write_ctl(rb_fde_t *F, void *data)
|
|||
{
|
||||
ctl_buf = ptr->data;
|
||||
/* in theory unix sock_dgram shouldn't ever short write this.. */
|
||||
retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen);
|
||||
retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen, ctl->pid);
|
||||
if(retlen > 0)
|
||||
{
|
||||
rb_dlinkDelete(ptr, &ctl->writeq);
|
||||
|
@ -517,14 +546,16 @@ ssl_write_ctl(rb_fde_t *F, void *data)
|
|||
{
|
||||
ssl_dead(ctl);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
rb_setselect(ctl->F, RB_SELECT_WRITE, ssl_write_ctl, ctl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ssl_cmd_write_queue(ssl_ctl_t *ctl, rb_fde_t **F, int count, const void *buf, size_t buflen)
|
||||
ssl_cmd_write_queue(ssl_ctl_t * ctl, rb_fde_t ** F, int count, const void *buf, size_t buflen)
|
||||
{
|
||||
ssl_ctl_buf_t *ctl_buf;
|
||||
int x;
|
||||
|
@ -549,7 +580,7 @@ ssl_cmd_write_queue(ssl_ctl_t *ctl, rb_fde_t **F, int count, const void *buf, si
|
|||
|
||||
|
||||
static void
|
||||
send_new_ssl_certs_one(ssl_ctl_t *ctl, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params)
|
||||
send_new_ssl_certs_one(ssl_ctl_t * ctl, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
|
@ -559,16 +590,18 @@ send_new_ssl_certs_one(ssl_ctl_t *ctl, const char *ssl_cert, const char *ssl_pri
|
|||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"Parameters for send_new_ssl_certs_one too long (%zu > %zu) to pass to ssld, not sending...",
|
||||
len, sizeof(tmpbuf));
|
||||
ilog(L_MAIN, "Parameters for send_new_ssl_certs_one too long (%zu > %zu) to pass to ssld, not sending...",
|
||||
ilog(L_MAIN,
|
||||
"Parameters for send_new_ssl_certs_one too long (%zu > %zu) to pass to ssld, not sending...",
|
||||
len, sizeof(tmpbuf));
|
||||
return;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
send_init_prng(ssl_ctl_t *ctl, prng_seed_t seedtype, const char *path)
|
||||
send_init_prng(ssl_ctl_t * ctl, prng_seed_t seedtype, const char *path)
|
||||
{
|
||||
size_t len;
|
||||
const char *s;
|
||||
|
@ -585,7 +618,8 @@ send_init_prng(ssl_ctl_t *ctl, prng_seed_t seedtype, const char *path)
|
|||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"Parameters for send_init_prng too long (%zd > %zd) to pass to ssld, not sending...",
|
||||
len, sizeof(tmpbuf));
|
||||
ilog(L_MAIN, "Parameters for send_init_prng too long (%zd > %zd) to pass to ssld, not sending...",
|
||||
ilog(L_MAIN,
|
||||
"Parameters for send_init_prng too long (%zd > %zd) to pass to ssld, not sending...",
|
||||
len, sizeof(tmpbuf));
|
||||
return;
|
||||
|
||||
|
@ -612,7 +646,7 @@ send_new_ssl_certs(const char *ssl_cert, const char *ssl_private_key, const char
|
|||
|
||||
|
||||
ssl_ctl_t *
|
||||
start_ssld_accept(rb_fde_t *sslF, rb_fde_t *plainF, int32_t id)
|
||||
start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
|
||||
{
|
||||
rb_fde_t *F[2];
|
||||
ssl_ctl_t *ctl;
|
||||
|
@ -629,7 +663,7 @@ start_ssld_accept(rb_fde_t *sslF, rb_fde_t *plainF, int32_t id)
|
|||
}
|
||||
|
||||
ssl_ctl_t *
|
||||
start_ssld_connect(rb_fde_t *sslF, rb_fde_t *plainF, int32_t id)
|
||||
start_ssld_connect(rb_fde_t * sslF, rb_fde_t * plainF, int32_t id)
|
||||
{
|
||||
rb_fde_t *F[2];
|
||||
ssl_ctl_t *ctl;
|
||||
|
@ -647,7 +681,7 @@ start_ssld_connect(rb_fde_t *sslF, rb_fde_t *plainF, int32_t id)
|
|||
}
|
||||
|
||||
void
|
||||
ssld_decrement_clicount(ssl_ctl_t *ctl)
|
||||
ssld_decrement_clicount(ssl_ctl_t * ctl)
|
||||
{
|
||||
if(ctl == NULL)
|
||||
return;
|
||||
|
@ -671,7 +705,7 @@ ssld_decrement_clicount(ssl_ctl_t *ctl)
|
|||
void
|
||||
start_zlib_session(void *data)
|
||||
{
|
||||
struct Client *server = (struct Client *)data;
|
||||
struct Client *server = (struct Client *) data;
|
||||
uint16_t recvqlen;
|
||||
uint8_t level;
|
||||
void *xbuf;
|
||||
|
@ -693,8 +727,9 @@ start_zlib_session(void *data)
|
|||
|
||||
if(len > READBUF_SIZE)
|
||||
{
|
||||
rb_free(buf);
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld - attempted to pass message of %zd len, max len %d, giving up", len, READBUF_SIZE);
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"ssld - attempted to pass message of %zd len, max len %d, giving up",
|
||||
len, READBUF_SIZE);
|
||||
ilog(L_MAIN, "ssld - attempted to pass message of %zd len, max len %d, giving up", len, READBUF_SIZE);
|
||||
exit_client(server, server, server, "ssld readbuf exceeded");
|
||||
return;
|
||||
|
@ -704,7 +739,7 @@ start_zlib_session(void *data)
|
|||
level = ConfigFileEntry.compression_level;
|
||||
|
||||
int32_to_buf(&buf[1], rb_get_fd(server->localClient->F));
|
||||
buf[5] = (char)level;
|
||||
buf[5] = (char) level;
|
||||
|
||||
recvq_start = &buf[6];
|
||||
server->localClient->zipstats = rb_malloc(sizeof(struct ZipStats));
|
||||
|
@ -716,8 +751,9 @@ start_zlib_session(void *data)
|
|||
{
|
||||
cpylen = rb_linebuf_get(&server->localClient->buf_recvq, xbuf, left, LINEBUF_PARTIAL, LINEBUF_RAW);
|
||||
left -= cpylen;
|
||||
xbuf += cpylen;
|
||||
} while(cpylen > 0);
|
||||
xbuf = (void *) (((uintptr_t) xbuf) + cpylen);
|
||||
}
|
||||
while(cpylen > 0);
|
||||
|
||||
/* Pass the socket to ssld. */
|
||||
*buf = 'Z';
|
||||
|
@ -758,7 +794,7 @@ collect_zipstats(void *unused)
|
|||
|
||||
id = rb_get_fd(target_p->localClient->F);
|
||||
int32_to_buf(&buf[1], rb_get_fd(target_p->localClient->F));
|
||||
rb_strlcpy(odata, target_p->name, (sizeof(buf)-len));
|
||||
rb_strlcpy(odata, target_p->name, (sizeof(buf) - len));
|
||||
len += strlen(odata) + 1; /* Get the \0 as well */
|
||||
ssl_cmd_write_queue(target_p->localClient->ssl_ctl, NULL, 0, buf, len);
|
||||
}
|
||||
|
@ -786,9 +822,9 @@ get_ssld_count(void)
|
|||
return ssld_count;
|
||||
}
|
||||
|
||||
void init_ssld(void)
|
||||
void
|
||||
init_ssld(void)
|
||||
{
|
||||
rb_event_addish("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME);
|
||||
rb_event_addish("cleanup_dead_ssld", cleanup_dead_ssl, NULL, 1200);
|
||||
}
|
||||
|
||||
|
|
142
ssld/ssld.c
142
ssld/ssld.c
|
@ -18,7 +18,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA
|
||||
*
|
||||
* $Id: ssld.c 25677 2008-07-06 04:21:42Z androsyn $
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
@ -34,28 +34,33 @@
|
|||
#endif
|
||||
|
||||
static void setup_signals(void);
|
||||
static pid_t ppid;
|
||||
|
||||
static inline int32_t buf_to_int32(char *buf)
|
||||
static inline int32_t
|
||||
buf_to_int32(char *buf)
|
||||
{
|
||||
int32_t x;
|
||||
memcpy(&x, buf, sizeof(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void int32_to_buf(char *buf, int32_t x)
|
||||
static inline void
|
||||
int32_to_buf(char *buf, int32_t x)
|
||||
{
|
||||
memcpy(buf, &x, sizeof(x));
|
||||
return;
|
||||
}
|
||||
|
||||
static inline uint16_t buf_to_uint16(char *buf)
|
||||
static inline uint16_t
|
||||
buf_to_uint16(char *buf)
|
||||
{
|
||||
uint16_t x;
|
||||
memcpy(&x, buf, sizeof(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void uint16_to_buf(char *buf, uint16_t x)
|
||||
static inline void
|
||||
uint16_to_buf(char *buf, uint16_t x)
|
||||
{
|
||||
memcpy(buf, &x, sizeof(x));
|
||||
return;
|
||||
|
@ -157,12 +162,12 @@ typedef struct _conn
|
|||
static rb_dlink_list connid_hash_table[CONN_HASH_SIZE];
|
||||
static rb_dlink_list dead_list;
|
||||
|
||||
static void conn_mod_read_cb(rb_fde_t * fd, void *data);
|
||||
static void conn_mod_read_cb(rb_fde_t *fd, void *data);
|
||||
static void conn_mod_write_sendq(rb_fde_t *, void *data);
|
||||
static void conn_plain_write_sendq(rb_fde_t *, void *data);
|
||||
static void mod_write_ctl(rb_fde_t *, void *data);
|
||||
static void conn_plain_read_cb(rb_fde_t * fd, void *data);
|
||||
static void mod_cmd_write_queue(mod_ctl_t *ctl, const void *data, size_t len);
|
||||
static void conn_plain_read_cb(rb_fde_t *fd, void *data);
|
||||
static void mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len);
|
||||
static const char *remote_closed = "Remote host closed the connection";
|
||||
static int ssl_ok;
|
||||
#ifdef HAVE_LIBZ
|
||||
|
@ -262,7 +267,7 @@ close_conn(conn_t * conn, int wait_plain, const char *fmt, ...)
|
|||
rb_dlinkAdd(conn, &conn->node, &dead_list);
|
||||
return;
|
||||
}
|
||||
rb_setselect(conn->plain_fd, RB_SELECT_WRITE|RB_SELECT_READ, NULL, NULL);
|
||||
rb_setselect(conn->plain_fd, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL);
|
||||
va_start(ap, fmt);
|
||||
rb_vsnprintf(reason, sizeof(reason), fmt, ap);
|
||||
va_end(ap);
|
||||
|
@ -275,7 +280,7 @@ close_conn(conn_t * conn, int wait_plain, const char *fmt, ...)
|
|||
}
|
||||
|
||||
static conn_t *
|
||||
make_conn(mod_ctl_t *ctl, rb_fde_t * mod_fd, rb_fde_t * plain_fd)
|
||||
make_conn(mod_ctl_t * ctl, rb_fde_t *mod_fd, rb_fde_t *plain_fd)
|
||||
{
|
||||
conn_t *conn = rb_malloc(sizeof(conn_t));
|
||||
conn->ctl = ctl;
|
||||
|
@ -310,12 +315,10 @@ check_handshake_flood(void *unused)
|
|||
else
|
||||
rb_ssl_clear_handshake_count(conn->mod_fd);
|
||||
}
|
||||
HASH_WALK_END
|
||||
|
||||
}
|
||||
HASH_WALK_END}
|
||||
|
||||
static void
|
||||
conn_mod_write_sendq(rb_fde_t * fd, void *data)
|
||||
conn_mod_write_sendq(rb_fde_t *fd, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
const char *err;
|
||||
|
@ -331,7 +334,7 @@ conn_mod_write_sendq(rb_fde_t * fd, void *data)
|
|||
return;
|
||||
}
|
||||
|
||||
while ((retlen = rb_rawbuf_flush(conn->modbuf_out, fd)) > 0)
|
||||
while((retlen = rb_rawbuf_flush(conn->modbuf_out, fd)) > 0)
|
||||
conn->mod_out += retlen;
|
||||
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
|
||||
|
@ -401,7 +404,7 @@ static void
|
|||
common_zlib_deflate(conn_t * conn, void *buf, size_t len)
|
||||
{
|
||||
int ret, have;
|
||||
z_stream *outstream = &((zlib_stream_t *)conn->stream)->outstream;
|
||||
z_stream *outstream = &((zlib_stream_t *) conn->stream)->outstream;
|
||||
outstream->next_in = buf;
|
||||
outstream->avail_in = len;
|
||||
outstream->next_out = (Bytef *) outbuf;
|
||||
|
@ -422,7 +425,7 @@ common_zlib_deflate(conn_t * conn, void *buf, size_t len)
|
|||
}
|
||||
if(outstream->avail_in != 0)
|
||||
{
|
||||
/* avail_in isn't empty...*/
|
||||
/* avail_in isn't empty... */
|
||||
close_conn(conn, WAIT_PLAIN, "error compressing data, avail_in != 0");
|
||||
return;
|
||||
}
|
||||
|
@ -433,15 +436,15 @@ common_zlib_deflate(conn_t * conn, void *buf, size_t len)
|
|||
static void
|
||||
common_zlib_inflate(conn_t * conn, void *buf, size_t len)
|
||||
{
|
||||
int ret, have;
|
||||
((zlib_stream_t *)conn->stream)->instream.next_in = buf;
|
||||
((zlib_stream_t *)conn->stream)->instream.avail_in = len;
|
||||
((zlib_stream_t *)conn->stream)->instream.next_out = (Bytef *) outbuf;
|
||||
((zlib_stream_t *)conn->stream)->instream.avail_out = sizeof(outbuf);
|
||||
int ret, have = 0;
|
||||
((zlib_stream_t *) conn->stream)->instream.next_in = buf;
|
||||
((zlib_stream_t *) conn->stream)->instream.avail_in = len;
|
||||
((zlib_stream_t *) conn->stream)->instream.next_out = (Bytef *) outbuf;
|
||||
((zlib_stream_t *) conn->stream)->instream.avail_out = sizeof(outbuf);
|
||||
|
||||
while (((zlib_stream_t *)conn->stream)->instream.avail_in)
|
||||
while(((zlib_stream_t *) conn->stream)->instream.avail_in)
|
||||
{
|
||||
ret = inflate(&((zlib_stream_t *)conn->stream)->instream, Z_NO_FLUSH);
|
||||
ret = inflate(&((zlib_stream_t *) conn->stream)->instream, Z_NO_FLUSH);
|
||||
if(ret != Z_OK)
|
||||
{
|
||||
if(!strncmp("ERROR ", buf, 6))
|
||||
|
@ -452,14 +455,14 @@ common_zlib_inflate(conn_t * conn, void *buf, size_t len)
|
|||
close_conn(conn, WAIT_PLAIN, "Inflate failed: %s", zError(ret));
|
||||
return;
|
||||
}
|
||||
have = sizeof(outbuf) - ((zlib_stream_t *)conn->stream)->instream.avail_out;
|
||||
have = sizeof(outbuf) - ((zlib_stream_t *) conn->stream)->instream.avail_out;
|
||||
|
||||
if(((zlib_stream_t *)conn->stream)->instream.avail_in)
|
||||
if(((zlib_stream_t *) conn->stream)->instream.avail_in)
|
||||
{
|
||||
conn_plain_write(conn, outbuf, have);
|
||||
have = 0;
|
||||
((zlib_stream_t *)conn->stream)->instream.next_out = (Bytef *) outbuf;
|
||||
((zlib_stream_t *)conn->stream)->instream.avail_out = sizeof(outbuf);
|
||||
((zlib_stream_t *) conn->stream)->instream.next_out = (Bytef *) outbuf;
|
||||
((zlib_stream_t *) conn->stream)->instream.avail_out = sizeof(outbuf);
|
||||
}
|
||||
}
|
||||
if(have == 0)
|
||||
|
@ -487,7 +490,7 @@ plain_check_cork(conn_t * conn)
|
|||
|
||||
|
||||
static void
|
||||
conn_plain_read_cb(rb_fde_t * fd, void *data)
|
||||
conn_plain_read_cb(rb_fde_t *fd, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
int length = 0;
|
||||
|
@ -500,7 +503,7 @@ conn_plain_read_cb(rb_fde_t * fd, void *data)
|
|||
if(plain_check_cork(conn))
|
||||
return;
|
||||
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
if(IsDead(conn))
|
||||
return;
|
||||
|
@ -535,7 +538,7 @@ conn_plain_read_cb(rb_fde_t * fd, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
conn_mod_read_cb(rb_fde_t * fd, void *data)
|
||||
conn_mod_read_cb(rb_fde_t *fd, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
const char *err = remote_closed;
|
||||
|
@ -553,7 +556,7 @@ conn_mod_read_cb(rb_fde_t * fd, void *data)
|
|||
return;
|
||||
}
|
||||
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
if(IsDead(conn))
|
||||
return;
|
||||
|
@ -562,7 +565,8 @@ conn_mod_read_cb(rb_fde_t * fd, void *data)
|
|||
|
||||
if(length == 0 || (length < 0 && !rb_ignore_errno(errno)))
|
||||
{
|
||||
if(length == 0) {
|
||||
if(length == 0)
|
||||
{
|
||||
close_conn(conn, WAIT_PLAIN, "%s", remote_closed);
|
||||
return;
|
||||
}
|
||||
|
@ -598,7 +602,7 @@ conn_mod_read_cb(rb_fde_t * fd, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
conn_plain_write_sendq(rb_fde_t * fd, void *data)
|
||||
conn_plain_write_sendq(rb_fde_t *fd, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
int retlen;
|
||||
|
@ -606,7 +610,7 @@ conn_plain_write_sendq(rb_fde_t * fd, void *data)
|
|||
if(IsDead(conn))
|
||||
return;
|
||||
|
||||
while ((retlen = rb_rawbuf_flush(conn->plainbuf_out, fd)) > 0)
|
||||
while((retlen = rb_rawbuf_flush(conn->plainbuf_out, fd)) > 0)
|
||||
{
|
||||
conn->plain_out += retlen;
|
||||
}
|
||||
|
@ -638,7 +642,7 @@ maxconn(void)
|
|||
}
|
||||
|
||||
static void
|
||||
ssl_process_accept_cb(rb_fde_t * F, int status, struct sockaddr *addr, rb_socklen_t len, void *data)
|
||||
ssl_process_accept_cb(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t len, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
if(status == RB_OK)
|
||||
|
@ -653,7 +657,7 @@ ssl_process_accept_cb(rb_fde_t * F, int status, struct sockaddr *addr, rb_sockle
|
|||
}
|
||||
|
||||
static void
|
||||
ssl_process_connect_cb(rb_fde_t * F, int status, void *data)
|
||||
ssl_process_connect_cb(rb_fde_t *F, int status, void *data)
|
||||
{
|
||||
conn_t *conn = data;
|
||||
if(status == RB_OK)
|
||||
|
@ -748,7 +752,7 @@ process_stats(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
|
|||
|
||||
#ifdef HAVE_LIBZ
|
||||
static void
|
||||
zlib_send_zip_ready(mod_ctl_t *ctl, conn_t *conn)
|
||||
zlib_send_zip_ready(mod_ctl_t * ctl, conn_t * conn)
|
||||
{
|
||||
char buf[5];
|
||||
|
||||
|
@ -778,22 +782,22 @@ zlib_process(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
|
|||
id = buf_to_int32(&ctlb->buf[1]);
|
||||
conn_add_id_hash(conn, id);
|
||||
|
||||
level = (uint8_t) ctlb->buf[5];
|
||||
level = (uint8_t)ctlb->buf[5];
|
||||
|
||||
recvqlen = ctlb->buflen - hdr;
|
||||
recvq_start = &ctlb->buf[6];
|
||||
|
||||
SetZip(conn);
|
||||
conn->stream = rb_malloc(sizeof(zlib_stream_t));
|
||||
instream = &((zlib_stream_t *)conn->stream)->instream;
|
||||
outstream = &((zlib_stream_t *)conn->stream)->outstream;
|
||||
instream = &((zlib_stream_t *) conn->stream)->instream;
|
||||
outstream = &((zlib_stream_t *) conn->stream)->outstream;
|
||||
|
||||
instream->total_in = 0;
|
||||
instream->total_out = 0;
|
||||
instream->zalloc = (alloc_func) ssld_alloc;
|
||||
instream->zfree = (free_func) ssld_free;
|
||||
instream->data_type = Z_ASCII;
|
||||
inflateInit(&((zlib_stream_t *)conn->stream)->instream);
|
||||
inflateInit(&((zlib_stream_t *) conn->stream)->instream);
|
||||
|
||||
outstream->total_in = 0;
|
||||
outstream->total_out = 0;
|
||||
|
@ -804,7 +808,7 @@ zlib_process(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
|
|||
if(level > 9)
|
||||
level = Z_DEFAULT_COMPRESSION;
|
||||
|
||||
deflateInit(&((zlib_stream_t *)conn->stream)->outstream, level);
|
||||
deflateInit(&((zlib_stream_t *) conn->stream)->outstream, level);
|
||||
if(recvqlen > 0)
|
||||
common_zlib_inflate(conn, recvq_start, recvqlen);
|
||||
zlib_send_zip_ready(ctl, conn);
|
||||
|
@ -821,7 +825,7 @@ init_prng(mod_ctl_t * ctl, mod_ctl_buf_t * ctl_buf)
|
|||
char *path;
|
||||
prng_seed_t seed_type;
|
||||
|
||||
seed_type = (prng_seed_t)ctl_buf->buf[1];
|
||||
seed_type = (prng_seed_t) ctl_buf->buf[1];
|
||||
path = &ctl_buf->buf[2];
|
||||
rb_init_prng(path, seed_type);
|
||||
}
|
||||
|
@ -851,7 +855,7 @@ ssl_new_keys(mod_ctl_t * ctl, mod_ctl_buf_t * ctl_buf)
|
|||
}
|
||||
|
||||
static void
|
||||
send_nossl_support(mod_ctl_t *ctl, mod_ctl_buf_t *ctlb)
|
||||
send_nossl_support(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
|
||||
{
|
||||
static const char *nossl_cmd = "N";
|
||||
conn_t *conn;
|
||||
|
@ -870,14 +874,14 @@ send_nossl_support(mod_ctl_t *ctl, mod_ctl_buf_t *ctlb)
|
|||
}
|
||||
|
||||
static void
|
||||
send_i_am_useless(mod_ctl_t *ctl)
|
||||
send_i_am_useless(mod_ctl_t * ctl)
|
||||
{
|
||||
static const char *useless = "U";
|
||||
mod_cmd_write_queue(ctl, useless, strlen(useless));
|
||||
}
|
||||
|
||||
static void
|
||||
send_nozlib_support(mod_ctl_t *ctl, mod_ctl_buf_t *ctlb)
|
||||
send_nozlib_support(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb)
|
||||
{
|
||||
static const char *nozlib_cmd = "z";
|
||||
conn_t *conn;
|
||||
|
@ -973,7 +977,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl)
|
|||
|
||||
|
||||
static void
|
||||
mod_read_ctl(rb_fde_t * F, void *data)
|
||||
mod_read_ctl(rb_fde_t *F, void *data)
|
||||
{
|
||||
mod_ctl_buf_t *ctl_buf;
|
||||
mod_ctl_t *ctl = data;
|
||||
|
@ -997,7 +1001,7 @@ mod_read_ctl(rb_fde_t * F, void *data)
|
|||
rb_dlinkAddTail(ctl_buf, &ctl_buf->node, &ctl->readq);
|
||||
}
|
||||
}
|
||||
while (retlen > 0);
|
||||
while(retlen > 0);
|
||||
|
||||
if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
|
||||
exit(0);
|
||||
|
@ -1007,7 +1011,7 @@ mod_read_ctl(rb_fde_t * F, void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
mod_write_ctl(rb_fde_t * F, void *data)
|
||||
mod_write_ctl(rb_fde_t *F, void *data)
|
||||
{
|
||||
mod_ctl_t *ctl = data;
|
||||
mod_ctl_buf_t *ctl_buf;
|
||||
|
@ -1018,11 +1022,11 @@ mod_write_ctl(rb_fde_t * F, void *data)
|
|||
{
|
||||
ctl_buf = ptr->data;
|
||||
retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf,
|
||||
ctl_buf->buflen);
|
||||
ctl_buf->buflen, ppid);
|
||||
if(retlen > 0)
|
||||
{
|
||||
rb_dlinkDelete(ptr, &ctl->writeq);
|
||||
for (x = 0; x < ctl_buf->nfds; x++)
|
||||
for(x = 0; x < ctl_buf->nfds; x++)
|
||||
rb_close(ctl_buf->F[x]);
|
||||
rb_free(ctl_buf->buf);
|
||||
rb_free(ctl_buf);
|
||||
|
@ -1037,10 +1041,10 @@ mod_write_ctl(rb_fde_t * F, void *data)
|
|||
|
||||
|
||||
static void
|
||||
read_pipe_ctl(rb_fde_t * F, void *data)
|
||||
read_pipe_ctl(rb_fde_t *F, void *data)
|
||||
{
|
||||
int retlen;
|
||||
while ((retlen = rb_read(F, inbuf, sizeof(inbuf))) > 0)
|
||||
while((retlen = rb_read(F, inbuf, sizeof(inbuf))) > 0)
|
||||
{
|
||||
;; /* we don't do anything with the pipe really, just care if the other process dies.. */
|
||||
}
|
||||
|
@ -1053,29 +1057,34 @@ read_pipe_ctl(rb_fde_t * F, void *data)
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *s_ctlfd, *s_pipe;
|
||||
const char *s_ctlfd, *s_pipe, *s_pid;
|
||||
int ctlfd, pipefd, x, maxfd;
|
||||
maxfd = maxconn();
|
||||
|
||||
s_ctlfd = getenv("CTL_FD");
|
||||
s_pipe = getenv("CTL_PIPE");
|
||||
s_pid = getenv("CTL_PPID");
|
||||
|
||||
if(s_ctlfd == NULL || s_pipe == NULL)
|
||||
if(s_ctlfd == NULL || s_pipe == NULL || s_pid == NULL)
|
||||
{
|
||||
fprintf(stderr, "This is ircd-ratbox ssld. You know you aren't supposed to run me directly?\n");
|
||||
fprintf(stderr, "You get an Id tag for this: $Id: ssld.c 25677 2008-07-06 04:21:42Z androsyn $\n");
|
||||
fprintf(stderr,
|
||||
"This is ircd-ratbox ssld. You know you aren't supposed to run me directly?\n");
|
||||
fprintf(stderr,
|
||||
"You get an Id tag for this: $Id$\n");
|
||||
fprintf(stderr, "Have a nice life\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ctlfd = atoi(s_ctlfd);
|
||||
pipefd = atoi(s_pipe);
|
||||
|
||||
for (x = 0; x < maxfd; x++)
|
||||
ppid = atoi(s_pid);
|
||||
x = 0;
|
||||
#ifndef _WIN32
|
||||
for(x = 0; x < maxfd; x++)
|
||||
{
|
||||
if(x != ctlfd && x != pipefd && x > 2)
|
||||
close(x);
|
||||
}
|
||||
|
||||
x = open("/dev/null", O_RDWR);
|
||||
if(x >= 0)
|
||||
{
|
||||
|
@ -1088,12 +1097,11 @@ main(int argc, char **argv)
|
|||
if(x > 2)
|
||||
close(x);
|
||||
}
|
||||
|
||||
#endif
|
||||
setup_signals();
|
||||
rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
|
||||
rb_init_rawbuffers(1024);
|
||||
ssl_ok = rb_supports_ssl();
|
||||
|
||||
mod_ctl = rb_malloc(sizeof(mod_ctl_t));
|
||||
mod_ctl->F = rb_open(ctlfd, RB_FD_SOCKET, "ircd control socket");
|
||||
mod_ctl->F_pipe = rb_open(pipefd, RB_FD_PIPE, "ircd pipe");
|
||||
|
@ -1108,7 +1116,7 @@ main(int argc, char **argv)
|
|||
/* this is really useless... */
|
||||
send_i_am_useless(mod_ctl);
|
||||
/* sleep until the ircd kills us */
|
||||
rb_sleep(2<<30, 0);
|
||||
rb_sleep(2 << 30, 0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1121,16 +1129,18 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
static void
|
||||
dummy_handler(int sig)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
setup_signals()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct sigaction act;
|
||||
|
||||
act.sa_flags = 0;
|
||||
|
@ -1153,5 +1163,5 @@ setup_signals()
|
|||
|
||||
act.sa_handler = dummy_handler;
|
||||
sigaction(SIGALRM, &act, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue