diff --git a/.appveyor-build.sh b/.appveyor-build.sh new file mode 100644 index 00000000..8ea6283e --- /dev/null +++ b/.appveyor-build.sh @@ -0,0 +1,9 @@ +set -v + +export MSYSTEM=MINGW64 +export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl + +sh ./autogen.sh +./configure --prefix=c:/projects/charybdis/build --enable-openssl=/mingw64 +make -j2 +make install diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..6b401717 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,15 @@ +version: 3.6-dev_{build} +clone_depth: 10 +install: + - c:\msys64\usr\bin\sh.exe -lc "pacman -Sy --noconfirm git" + - c:\msys64\usr\bin\sh.exe -lc "uname -a" + - c:\msys64\usr\bin\sh.exe -lc "cat /proc/cpuinfo" + - c:\msys64\usr\bin\sh.exe -lc "cat /proc/meminfo" + - c:\msys64\usr\bin\sh.exe -lc "cygcheck -s -v > $APPVEYOR_BUILD_FOLDER/cygcheck.log 2>&1" + - ps: Push-AppveyorArtifact cygcheck.log +build_script: + - c:\msys64\usr\bin\sh.exe -lc "cd $APPVEYOR_BUILD_FOLDER; sh .appveyor-build.sh" +# - c:\msys64\usr\bin\sh.exe -lc "cd $APPVEYOR_BUILD_FOLDER/build/bin; ./charybdis -version" +on_failure: + - ps: Push-AppveyorArtifact config.log + - ps: Push-AppveyorArtifact librb\include\librb-config.h diff --git a/.gitignore b/.gitignore index d212eb4b..5166a02e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,31 +12,48 @@ Makefile .dirstamp .libs authd/authd -autom4te.cache bandb/bandb bandb/bantool +autom4te.cache +aclocal.m4 +compile +config.guess +config.sub +depcomp +ltmain.sh +missing config.log config.status configure stamp-h1 -include/setup.h libltdl/ librb/configure -librb/include/libratbox_config.h +librb/compile +librb/depcomp +librb/aclocal.m4 +librb/include/librb_config.h +librb/include/librb_config.h.in librb/include/librb-config.h +librb/include/serno.h +librb/librb.pc +librb/ltmain.sh +librb/missing librb/libratbox.pc librb/libtool librb/src/version.c librb/src/version.c.last scripts/*.tar.bz2 scripts/*.tar.gz +include/setup.h +include/setup.h.in ircd/charybdis -ircd/lex.yy.c +ircd/ircd_parser.c +ircd/ircd_parser.h +ircd/ircd_lexer.c ircd/version.c ircd/version.c.last -ircd/y.tab.h -ircd/y.tab.c ssld/ssld +wsockd/wsockd tools/charybdis-mkpasswd tools/genssl tools/mkpasswd @@ -47,6 +64,7 @@ ircd/version.c ircd/version.c.last /libtool Makefile.in +m4/argz.m4 m4/libtool.m4 m4/ltargz.m4 m4/ltdl.m4 diff --git a/.mailmap b/.mailmap index ea4a5128..0c7637e7 100644 --- a/.mailmap +++ b/.mailmap @@ -17,5 +17,5 @@ Valeriy Yatsko Valeriy Yatsko William Pitcock William Pitcock nenolod -Sam Dodrill -Sam Dodrill +Christine Dodrill +Christine Dodrill diff --git a/.travis.yml b/.travis.yml index ad8efb37..68dba8a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,9 +44,6 @@ matrix: compiler: clang env: COMPILER=clang LIBTOOLIZE=glibtoolize -branches: - except: - - authd-framework osx_image: xcode7.3 diff --git a/CREDITS b/CREDITS index 745deb9a..af2df0be 100644 --- a/CREDITS +++ b/CREDITS @@ -9,9 +9,9 @@ jilles, Jilles Tjoelker mr_flea, Keith Buck kaniini, William Pitcock spb, Stephen Bennett - + The following people are also project members: - + amdj, Aaron Jones Elizafox, Elizabeth Myers grawity, Mantas Mikulėnas @@ -19,23 +19,24 @@ jdhore, JD Horelick lp0, Simon Arlott mniip viatsko, Valerii Iatsko - + The following people have made contributions to the Charybdis releases, in nick-alphabetical order: AndroSyn, Aaron Sethman anfl, Lee Hardy beu, Elfyn McBratney +BlindSight, Matt Ullman Entrope, Michael Poole gxti, Michael Tharp Taros, Brett Greenham ThaPrince, Jon Christopherson twincest, River Tarnell w00t, Robin Burchell - -For a list of contributors to ircd-ratbox, ircd-hyrbid, and ircd2.8 (the + +For a list of contributors to ircd-ratbox, ircd-hybrid, and ircd2.8 (the predecessors to Charybdis), see the doc/credits-past.txt file in the Charybdis distribution. - + Visit the Charybdis website at: http://www.charybdis.io Visit us on IRC at: irc.freenode.net #charybdis diff --git a/Makefile.am b/Makefile.am index 34e15287..85513d2c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,7 @@ endif SUBDIRS += ircd \ ssld \ + wsockd \ authd \ bandb \ tools \ @@ -37,3 +38,14 @@ include/serno.h: install-data-hook: test -d ${DESTDIR}${logdir} || mkdir -p ${DESTDIR}${logdir} + +install-exec-hook: + rm -f ${DESTDIR}${moduledir}/*.la + rm -f ${DESTDIR}${moduledir}/autoload/*.la + rm -f ${DESTDIR}${moduledir}/extensions/*.la + rm -f ${DESTDIR}${moduledir}/*.dll.a + rm -f ${DESTDIR}${moduledir}/autoload/*.dll.a + rm -f ${DESTDIR}${moduledir}/extensions/*.dll.a + +clean-local: + rm -f include/serno.h diff --git a/NEWS.md b/NEWS.md index 71e3c663..9666a6f2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -42,6 +42,11 @@ See LICENSE for licensing details (GPL v2). stuff has been renamed and shuffled around to be more consistent. ### code +- irc_dictionary and irc_radixtree stuff is now in librb, prefixed accordingly. + Typedefs have been added for consistency reasons. For example, now you would + write `rb_dictionary *foo` and `RB_DICTIONARY_FOREACH`. +- C99 bools have been added. Don't use ints as simple true/false flags anymore. + Accordingly, the `YES`/`NO` and `TRUE`/`FALSE` macros have been removed. - libratbox has been renamed to librb, as we have diverged from upstream long ago. - Almost all 2.8-style hashtable structures have been moved to dictionaries or diff --git a/README.md b/README.md index f12bfff4..38463a03 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# charybdis [![Build Status](https://travis-ci.org/charybdis-ircd/charybdis.svg?branch=master)](https://travis-ci.org/charybdis-ircd/charybdis) +# charybdis [![POSIX Build Status](https://travis-ci.org/charybdis-ircd/charybdis.svg?branch=master)](https://travis-ci.org/charybdis-ircd/charybdis) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/is0obsml8xyq2qk7/branch/master?svg=true)](https://ci.appveyor.com/project/kaniini/charybdis/branch/master) Charybdis is an IRCv3 server designed to be highly scalable. It implements IRCv3.1 and some parts of IRCv3.2. @@ -10,8 +10,52 @@ It is meant to be used with an IRCv3-capable services implementation such as [At # necessary requirements * A supported platform - * A working dynamic load library. - * A working lex. Solaris /usr/ccs/bin/lex appears to be broken, on this system flex should be used. + * A working dynamic library system + * A working lex and yacc - flex and bison should work + +# platforms + +Charybdis is designed with portability in mind, but does not target older systems nor those of solely academic +interest. + +Do note that operating systems are only supported if they are supported by their vendor. + +## Tier 1 + +These platforms are the best supported, and should always work. They are actively tested. If you encounter +problems, please file a bug. + +* FreeBSD 10.x and above (i386 and amd64) +* Linux 2.6.x and above with glibc or musl (i386, x86_64, and ARM) +* Mac OS X 10.7 and above +* Windows Vista/Server 2008 and above (x86 or x64) + +## Tier 2 + +These platforms are supported and occasionally tested, and most features should work, but this is not +guaranteed. If you find any problems, file a bug, but as these are not regularly tested platforms, a timely +resolution may not be possible. + +* DragonflyBSD 4.4 and above (i386) +* Linux with uClibc (i386 or x86_64) +* NetBSD 6.1.x and above (i386, amd64) +* OpenBSD 5.6 and above (i386, amd64) +* Solaris 10 and above (i386) + +## Tier 3 + +Anything else that hasn't been tested. Charybdis may or may not work on it; patches welcome if they don't. + +# platform specific errata + +These are known issues and workarounds for supported platforms. + + * **FreeBSD**: if you are compiling with ipv6 you may experience + problems with ipv4 due to the way the socket code is written. To + fix this you must: "sysctl net.inet6.ip6.v6only=0" + + * **Solaris**: you may have to set your PATH to include /usr/gnu/bin and /usr/gnu/sbin before /usr/bin + and /usr/sbin. Solaris's default tools don't seem to play nicely with the configure script. # building from git @@ -31,9 +75,8 @@ You will need to run `autogen.sh` to build the autotools files prior to building (Using CHALLENGE is not recommended for new deployments, so if you want to use a different TLS library, feel free.) - * For ECDHE, OpenSSL 1.0.0 or newer is required. RHEL/Fedora and derivatives like CentOS - will need to compile OpenSSL from source, as ECC/ECDHE-functionality is removed from - the OpenSSL package in these distributions. + * For ECDHE, OpenSSL 1.0.0 or newer is required. Solaris; and RHEL/Fedora and its derivatives such as CentOS + have removed support for ECC/ECDHE. You will need to compile your own OpenSSL on these systems. # tips @@ -41,31 +84,10 @@ You will need to run `autogen.sh` to build the autotools files prior to building * Please read doc/index.txt to get an overview of the current documentation. + * Read the NEWS file for what's new in this release. + * The files, /etc/services, /etc/protocols, and /etc/resolv.conf, SHOULD be readable by the user running the server in order for ircd to start with the correct settings. If these files are wrong, charybdis will try to use 127.0.0.1 for a resolver as a last-ditch effort. - * FREEBSD USERS: if you are compiling with ipv6 you may experience - problems with ipv4 due to the way the socket code is written. To - fix this you must: "sysctl net.inet6.ip6.v6only=0" - - * SOLARIS USERS: this code appears to tickle a bug in older gcc and - egcs ONLY on 64-bit Solaris7. gcc-2.95 and SunPro C on 64bit should - work fine, and any gcc or SunPro compiled on 32bit. - - * SUPPORTED PLATFORMS: this code should compile without any warnings on: - - * FreeBSD 10 - * Gentoo & Gentoo Hardened ~x86/~amd64/~fbsd - * RHEL 6 / 7 - * Debian Jessie - * OpenSuSE 11/12 - * OpenSolaris 2008.x? - * Solaris 10 sparc. - - Please let us know if you find otherwise. It may work on other platforms, but this is not guaranteed. - - * Please read NEWS for information about what is in this release. - - * Other files recommended for reading: BUGS, INSTALL diff --git a/aclocal.m4 b/aclocal.m4 deleted file mode 100644 index 9ba68755..00000000 --- a/aclocal.m4 +++ /dev/null @@ -1,1221 +0,0 @@ -# generated automatically by aclocal 1.15 -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. - -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) - -# Copyright (C) 2002-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# Copyright (C) 2011-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_AR([ACT-IF-FAIL]) -# ------------------------- -# Try to determine the archiver interface, and trigger the ar-lib wrapper -# if it is needed. If the detection of archiver interface fails, run -# ACT-IF-FAIL (default is to abort configure with a proper error message). -AC_DEFUN([AM_PROG_AR], -[AC_BEFORE([$0], [LT_INIT])dnl -AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([ar-lib])dnl -AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) -: ${AR=ar} - -AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], - [AC_LANG_PUSH([C]) - am_cv_ar_interface=ar - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], - [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([am_ar_try]) - if test "$ac_status" -eq 0; then - am_cv_ar_interface=ar - else - am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([am_ar_try]) - if test "$ac_status" -eq 0; then - am_cv_ar_interface=lib - else - am_cv_ar_interface=unknown - fi - fi - rm -f conftest.lib libconftest.a - ]) - AC_LANG_POP([C])]) - -case $am_cv_ar_interface in -ar) - ;; -lib) - # Microsoft lib, so override with the ar-lib wrapper script. - # FIXME: It is wrong to rewrite AR. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__AR in this case, - # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something - # similar. - AR="$am_aux_dir/ar-lib $AR" - ;; -unknown) - m4_default([$1], - [AC_MSG_ERROR([could not determine $AR interface])]) - ;; -esac -AC_SUBST([AR])dnl -]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Older Autoconf quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl -]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi -dnl The trailing newline in this macro's definition is deliberate, for -dnl backward compatibility and to allow trailing 'dnl'-style comments -dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. -]) - -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST([install_sh])]) - -# Copyright (C) 2003-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) -fi -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# -------------------- -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) - -# _AM_SET_OPTIONS(OPTIONS) -# ------------------------ -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Copyright (C) 1999-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor 'install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -# -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done - rm -rf conftest.dir - - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([m4/charybdis.m4]) -m4_include([m4/libtool.m4]) -m4_include([m4/ltargz.m4]) -m4_include([m4/ltdl.m4]) -m4_include([m4/ltoptions.m4]) -m4_include([m4/ltsugar.m4]) -m4_include([m4/ltversion.m4]) -m4_include([m4/lt~obsolete.m4]) -m4_include([m4/pkg.m4]) diff --git a/authd/Makefile.am b/authd/Makefile.am index cc15db5a..ef2c44a4 100644 --- a/authd/Makefile.am +++ b/authd/Makefile.am @@ -2,13 +2,18 @@ pkglibexec_PROGRAMS = authd AM_CFLAGS=$(WARNFLAGS) AM_CPPFLAGS = -I../include -I../librb/include - -authd_SOURCES = provider.c \ - authd.c \ - res.c \ - reslib.c \ - dns.c \ - providers/rdns.c \ - providers/ident.c +authd_SOURCES = \ + authd.c \ + dns.c \ + getaddrinfo.c \ + getnameinfo.c \ + notice.c \ + provider.c \ + res.c \ + reslib.c \ + reslist.c \ + providers/blacklist.c \ + providers/ident.c \ + providers/rdns.c authd_LDADD = ../librb/src/librb.la diff --git a/authd/authd.c b/authd/authd.c index bb01be82..6f500a9d 100644 --- a/authd/authd.c +++ b/authd/authd.c @@ -21,17 +21,21 @@ #include "authd.h" #include "dns.h" #include "provider.h" +#include "notice.h" #define MAXPARA 10 static void handle_reload(int parc, char *parv[]); static void handle_stat(int parc, char *parv[]); +static void handle_options(int parc, char *parv[]); rb_helper *authd_helper = NULL; authd_cmd_handler authd_cmd_handlers[256] = { ['C'] = handle_new_connection, - ['D'] = resolve_dns, - ['H'] = handle_reload, + ['D'] = handle_resolve_dns, + ['E'] = handle_cancel_connection, + ['O'] = handle_options, + ['R'] = handle_reload, ['S'] = handle_stat, }; @@ -43,31 +47,69 @@ authd_reload_handler authd_reload_handlers[256] = { ['D'] = reload_nameservers, }; +rb_dictionary *authd_option_handlers; + static void handle_stat(int parc, char *parv[]) { authd_stat_handler handler; if(parc < 3) - /* XXX Should log this somehow */ + { + warn_opers(L_CRIT, "BUG: handle_stat received too few parameters (at least 3 expected, got %d)", parc); return; + } - if (!(handler = authd_stat_handlers[parv[2][0]])) + if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]])) return; handler(parv[1], parv[2][0]); } +static void +handle_options(int parc, char *parv[]) +{ + struct auth_opts_handler *handler; + + if(parc < 4) + { + warn_opers(L_CRIT, "BUG: handle_options received too few parameters (at least 4 expected, got %d)", parc); + return; + } + + if((handler = rb_dictionary_retrieve(authd_option_handlers, parv[1])) == NULL) + { + warn_opers(L_CRIT, "BUG: handle_options got a bad option type %s", parv[1]); + return; + } + + if((parc - 2) < handler->min_parc) + { + warn_opers(L_CRIT, "BUG: handle_options received too few parameters (at least %d expected, got %d)", handler->min_parc, parc); + return; + } + + handler->handler(parv[1], parc - 2, (const char **)&parv[2]); +} + static void handle_reload(int parc, char *parv[]) { authd_reload_handler handler; if(parc < 2) - /* XXX Should log this somehow */ - return; + { + /* Reload all handlers */ + for(size_t i = 0; i < 256; i++) + { + if ((handler = authd_reload_handlers[(unsigned char) i]) != NULL) + handler(parv[1][0]); + } - if (!(handler = authd_reload_handlers[parv[1][0]])) + return; + } + + if (!(handler = authd_reload_handlers[(unsigned char)parv[1][0]])) return; handler(parv[1][0]); @@ -89,7 +131,7 @@ parse_request(rb_helper *helper) if(parc < 1) continue; - handler = authd_cmd_handlers[parv[0][0]]; + handler = authd_cmd_handlers[(unsigned char)parv[0][0]]; if (handler != NULL) handler(parc, parv); } @@ -101,7 +143,7 @@ error_cb(rb_helper *helper) exit(1); } -#ifndef WINDOWS +#ifndef _WIN32 static void dummy_handler(int sig) { @@ -112,7 +154,7 @@ dummy_handler(int sig) static void setup_signals(void) { -#ifndef WINDOWS +#ifndef _WIN32 struct sigaction act; act.sa_flags = 0; @@ -152,11 +194,16 @@ main(int argc, char *argv[]) rb_set_time(); setup_signals(); + + authd_option_handlers = rb_dictionary_create("authd options handlers", strcasecmp); + init_resolver(); init_providers(); rb_init_prng(NULL, RB_PRNG_DEFAULT); rb_helper_loop(authd_helper, 0); + destroy_providers(); + return 0; } diff --git a/authd/authd.h b/authd/authd.h index 771f797a..07c746ca 100644 --- a/authd/authd.h +++ b/authd/authd.h @@ -21,11 +21,21 @@ #ifndef _AUTHD_H #define _AUTHD_H -#include -#include +#include "stdinc.h" +#include "rb_lib.h" +#include "rb_dictionary.h" #include "setup.h" -#include "common.h" +#include "ircd_defs.h" + +typedef void (*provider_opts_handler_t)(const char *, int, const char **); + +struct auth_opts_handler +{ + const char *option; + int min_parc; + provider_opts_handler_t handler; +}; extern rb_helper *authd_helper; @@ -37,4 +47,6 @@ extern authd_cmd_handler authd_cmd_handlers[256]; extern authd_stat_handler authd_stat_handlers[256]; extern authd_reload_handler authd_reload_handlers[256]; +extern rb_dictionary *authd_option_handlers; + #endif diff --git a/authd/dns.c b/authd/dns.c index 41b6fc79..19b3efcb 100644 --- a/authd/dns.c +++ b/authd/dns.c @@ -1,4 +1,4 @@ -/* authd/dns.h - header for authd DNS functions +/* authd/dns.c - authd DNS functions * Copyright (c) 2016 William Pitcock * * Permission to use, copy, modify, and/or distribute this software for any @@ -22,140 +22,238 @@ #include "dns.h" #include "res.h" -void -format_address(struct rb_sockaddr_storage *addr, char *buffer, size_t length) +static void handle_lookup_ip_reply(void *data, struct DNSReply *reply); +static void handle_lookup_hostname_reply(void *data, struct DNSReply *reply); + +uint64_t query_count = 0; + +/* A bit different from ircd... you just get a dns_query object. + * + * It gets freed whenever the res code gets back to us. + */ +struct dns_query * +lookup_ip(const char *host, int aftype, DNSCB callback, void *data) { - if(GET_SS_FAMILY(addr) == AF_INET) + struct dns_query *query = rb_malloc(sizeof(struct dns_query)); + int g_type; + + if(aftype == AF_INET) { - rb_inet_ntop_sock((struct sockaddr *)addr, buffer, length); + query->type = QUERY_A; + g_type = T_A; } #ifdef RB_IPV6 - else if(GET_SS_FAMILY(addr) == AF_INET6) + else if(aftype == AF_INET6) { - char tmpbuf[length]; - - rb_inet_ntop_sock((struct sockaddr *)addr, tmpbuf, length); - - if(*tmpbuf == ':') - { - rb_strlcpy(buffer, "0", length); - rb_strlcat(buffer, tmpbuf, length); - } - else - rb_strlcpy(buffer, tmpbuf, length); + query->type = QUERY_AAAA; + g_type = T_AAAA; } #endif + else + { + rb_free(query); + return NULL; + } + + query->id = query_count++; + query->callback = callback; + query->data = data; + + query->query.ptr = query; + query->query.callback = handle_lookup_ip_reply; + + gethost_byname_type(host, &query->query, g_type); + + return query; } -bool -sockcmp(struct rb_sockaddr_storage *addr, struct rb_sockaddr_storage *addr2, int family) +/* See lookup_ip's comment */ +struct dns_query * +lookup_hostname(const char *ip, DNSCB callback, void *data) { - if(family == AF_INET) - { - struct sockaddr_in *ip, *ip2; - ip = (struct sockaddr_in *)addr; - ip2 = (struct sockaddr_in *)addr2; + struct dns_query *query = rb_malloc(sizeof(struct dns_query)); + int aftype; - return ip->sin_addr.s_addr == ip2->sin_addr.s_addr; + if(!rb_inet_pton_sock(ip, (struct sockaddr *)&query->addr)) + { + rb_free(query); + return NULL; + } + + aftype = GET_SS_FAMILY(&query->addr); + + if(aftype == AF_INET) + query->type = QUERY_PTR_A; +#ifdef RB_IPV6 + else if(aftype == AF_INET6) + query->type = QUERY_PTR_AAAA; +#endif + else + { + rb_free(query); + return NULL; + } + + query->id = query_count++; + query->callback = callback; + query->data = data; + + query->query.ptr = query; + query->query.callback = handle_lookup_hostname_reply; + + gethost_byaddr(&query->addr, &query->query); + + return query; +} + +/* Cancel a pending query */ +void +cancel_query(struct dns_query *query) +{ + query->callback = query->data = NULL; +} + +/* Callback from gethost_byname_type */ +static void +handle_lookup_ip_reply(void *data, struct DNSReply *reply) +{ + struct dns_query *query = data; + char ip[64] = "*"; + + if(query == NULL) + /* Shouldn't happen */ + exit(2); + + if(reply == NULL) + goto end; + + switch(query->type) + { + case QUERY_A: + if(GET_SS_FAMILY(&reply->addr) == AF_INET) + rb_inet_ntop_sock((struct sockaddr *)&reply->addr, ip, sizeof(ip)); + break; +#ifdef RB_IPV6 + case QUERY_AAAA: + if(GET_SS_FAMILY(&reply->addr) == AF_INET6) + { + rb_inet_ntop_sock((struct sockaddr *)&reply->addr, ip, sizeof(ip)); + if(ip[0] == ':') + { + memmove(&ip[1], ip, strlen(ip)); + ip[0] = '0'; + } + } + break; +#endif + default: + exit(3); + } + +end: + if(query->callback) + query->callback(ip, ip[0] != '*', query->type, query->data); + + rb_free(query); +} + +/* Callback from gethost_byaddr */ +static void +handle_lookup_hostname_reply(void *data, struct DNSReply *reply) +{ + struct dns_query *query = data; + char *hostname = NULL; + + if(query == NULL) + /* Shouldn't happen */ + exit(4); + + if(reply == NULL) + goto end; + + if(query->type == QUERY_PTR_A) + { + struct sockaddr_in *ip, *ip_fwd; + ip = (struct sockaddr_in *) &query->addr; + ip_fwd = (struct sockaddr_in *) &reply->addr; + + if(ip->sin_addr.s_addr == ip_fwd->sin_addr.s_addr) + hostname = reply->h_name; } #ifdef RB_IPV6 - else if(family == AF_INET6) + else if(query->type == QUERY_PTR_AAAA) { - struct sockaddr_in6 *ip, *ip2; - ip = (struct sockaddr_in6 *) addr; - ip2 = (struct sockaddr_in6 *) addr2; + struct sockaddr_in6 *ip, *ip_fwd; + ip = (struct sockaddr_in6 *) &query->addr; + ip_fwd = (struct sockaddr_in6 *) &reply->addr; - return(memcmp(&ip->sin6_addr, &ip2->sin6_addr, sizeof(struct in6_addr)) == 0); + if(memcmp(&ip->sin6_addr, &ip_fwd->sin6_addr, sizeof(struct in6_addr)) == 0) + hostname = reply->h_name; } #endif + else + /* Shouldn't happen */ + exit(5); +end: + if(query->callback) + query->callback(hostname, hostname != NULL, query->type, query->data); - return false; + rb_free(query); } static void -submit_dns_answer(void *userdata, struct DNSReply *reply) +submit_dns_answer(const char *reply, bool status, query_type type, void *data) { - struct dns_request *req = userdata; - char response[64] = "*"; - char status = 'E'; - int family = AF_INET; + char *id = data; - if (reply == NULL) + if(!id || type == QUERY_INVALID) + exit(6); + + if(reply == NULL || status == false) { - rb_helper_write(authd_helper, "E %s E %c *", req->reqid, req->type); - goto cleanup; + rb_helper_write(authd_helper, "E %s E %c *", id, type); + rb_free(id); + return; } - switch (req->type) + rb_helper_write(authd_helper, "E %s O %c %s", id, type, reply); + rb_free(id); +} + +void +handle_resolve_dns(int parc, char *parv[]) +{ + char *id = rb_strdup(parv[1]); + char qtype = *parv[2]; + char *record = parv[3]; + int aftype = AF_INET; + + switch(qtype) { - case '4': #ifdef RB_IPV6 case '6': - format_address(&reply->addr, response, sizeof(response)); - break; + aftype = AF_INET6; #endif + case '4': + if(!lookup_ip(record, aftype, submit_dns_answer, id)) + submit_dns_answer(NULL, false, qtype, NULL); + break; #ifdef RB_IPV6 case 'S': - family = AF_INET6; #endif case 'R': - if(sockcmp(&req->addr, &reply->addr, family) && strlen(reply->h_name) < 63) - { - rb_strlcpy(response, reply->h_name, sizeof(response)); - status = 'O'; - } + if(!lookup_hostname(record, submit_dns_answer, id)) + submit_dns_answer(NULL, false, qtype, NULL); break; default: exit(7); } - - rb_helper_write(authd_helper, "E %s %c %c %s", req->reqid, status, req->type, response); -cleanup: - rb_free(req); -} - -void -resolve_dns(int parc, char *parv[]) -{ - struct dns_request *req; - char *requestid = parv[1]; - char *qtype = parv[2]; - char *rec = parv[3]; - int type; - - req = rb_malloc(sizeof(*req)); - rb_strlcpy(req->reqid, requestid, sizeof(req->reqid)); - req->type = *qtype; - - switch (req->type) - { - case '4': - type = T_A; - break; - case '6': - type = T_AAAA; - break; - case 'R': - case 'S': - if(!rb_inet_pton_sock(rec, (struct sockaddr *) &req->addr)) - exit(6); - type = T_PTR; - break; - } - - req->query.ptr = req; - req->query.callback = submit_dns_answer; - - if (type != T_PTR) - gethost_byname_type(rec, &req->query, type); - else - gethost_byaddr(&req->addr, &req->query); } void enumerate_nameservers(const char *rid, const char letter) { - char buf[40 * IRCD_MAXNS]; /* Plenty */ + char buf[(HOSTIPLEN + 1) * IRCD_MAXNS]; char *c = buf; int i; @@ -168,8 +266,7 @@ enumerate_nameservers(const char *rid, const char letter) for(i = 0; i < irc_nscount; i++) { - char addr[40]; - int ret; + char addr[HOSTIPLEN]; rb_inet_ntop_sock((struct sockaddr *)&irc_nsaddr_list[i], addr, sizeof(addr)); @@ -180,8 +277,8 @@ enumerate_nameservers(const char *rid, const char letter) return; } - ret = snprintf(c, 40, "%s ", addr); - c += (size_t)ret; + (void)snprintf(c, HOSTIPLEN + 1, "%s ", addr); + c += strlen(addr) + 1; } *(--c) = '\0'; diff --git a/authd/dns.h b/authd/dns.h index a173f252..b4eae8c6 100644 --- a/authd/dns.h +++ b/authd/dns.h @@ -27,17 +27,34 @@ #include "res.h" #include "reslib.h" -struct dns_request +typedef enum +{ + QUERY_INVALID = 0, + QUERY_A = '4', + QUERY_AAAA = '6', + QUERY_PTR_A = 'R', + QUERY_PTR_AAAA = 'S', +} query_type; + +/* Similar to that in ircd */ +typedef void (*DNSCB)(const char *res, bool status, query_type type, void *data); + +struct dns_query { struct DNSQuery query; - char reqid[DNS_REQ_IDLEN]; + query_type type; struct rb_sockaddr_storage addr; - char type; + uint64_t id; + + DNSCB callback; + void *data; }; -extern void format_address(struct rb_sockaddr_storage *addr, char *buffer, size_t length); -extern bool sockcmp(struct rb_sockaddr_storage *addr, struct rb_sockaddr_storage *addr2, int family); -extern void resolve_dns(int parc, char *parv[]); +extern struct dns_query *lookup_hostname(const char *ip, DNSCB callback, void *data); +extern struct dns_query *lookup_ip(const char *host, int aftype, DNSCB callback, void *data); +extern void cancel_query(struct dns_query *query); + +extern void handle_resolve_dns(int parc, char *parv[]); extern void enumerate_nameservers(const char *rid, const char letter); extern void reload_nameservers(const char letter); diff --git a/authd/getaddrinfo.c b/authd/getaddrinfo.c new file mode 100644 index 00000000..43384c42 --- /dev/null +++ b/authd/getaddrinfo.c @@ -0,0 +1,617 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef _WIN32 +#include +#include "getaddrinfo.h" +#include "stdinc.h" + +static const char in_addrany[] = { 0, 0, 0, 0 }; +static const char in_loopback[] = { 127, 0, 0, 1 }; +static const char in6_addrany[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +static const char in6_loopback[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 +}; + +static const struct afd { + int a_af; + int a_addrlen; + int a_socklen; + int a_off; + const char *a_addrany; + const char *a_loopback; + int a_scoped; +} afdl [] = { +#define N_INET6 0 +#ifdef IPV6 + {PF_INET6, sizeof(struct in6_addr), + sizeof(struct sockaddr_in6), + offsetof(struct sockaddr_in6, sin6_addr), + in6_addrany, in6_loopback, 1}, +#endif +#define N_INET 1 + {PF_INET, sizeof(struct in_addr), + sizeof(struct sockaddr_in), + offsetof(struct sockaddr_in, sin_addr), + in_addrany, in_loopback, 0}, + {0, 0, 0, 0, NULL, NULL, 0}, +}; + +struct explore { + int e_af; + int e_socktype; + int e_protocol; + const char *e_protostr; + int e_wild; +#define WILD_AF(ex) ((ex)->e_wild & 0x01) +#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) +#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) +}; + +static const struct explore explore[] = { +#ifdef IPV6 + { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, + { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, + { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, +#endif + { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, + { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, + { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, + { PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, + { PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, + { PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 }, + { -1, 0, 0, NULL, 0 }, +}; + +#define PTON_MAX 16 + +static bool str_isnumber(const char *); +static int explore_null(const struct rb_addrinfo *, + const char *, struct rb_addrinfo **); +static int explore_numeric(const struct rb_addrinfo *, const char *, + const char *, struct rb_addrinfo **); +static struct rb_addrinfo *get_ai(const struct rb_addrinfo *, + const struct afd *, const char *); +static int get_portmatch(const struct rb_addrinfo *, const char *); +static int get_port(struct rb_addrinfo *, const char *, int); +static const struct afd *find_afd(int); +#if 0 +/* We will need this should we ever want gai_strerror() */ +static char *ai_errlist[] = { + "Success", + "Address family for hostname not supported", /* EAI_ADDRFAMILY */ + "Temporary failure in name resolution", /* EAI_AGAIN */ + "Invalid value for ai_flags", /* EAI_BADFLAGS */ + "Non-recoverable failure in name resolution", /* EAI_FAIL */ + "ai_family not supported", /* EAI_FAMILY */ + "Memory allocation failure", /* EAI_MEMORY */ + "No address associated with hostname", /* EAI_NODATA */ + "hostname nor servname provided, or not known", /* EAI_NONAME */ + "servname not supported for ai_socktype", /* EAI_SERVICE */ + "ai_socktype not supported", /* EAI_SOCKTYPE */ + "System error returned in errno", /* EAI_SYSTEM */ + "Invalid value for hints", /* EAI_BADHINTS */ + "Resolved protocol is unknown", /* EAI_PROTOCOL */ + "Unknown error", /* EAI_MAX */ +}; +#endif +/* XXX macros that make external reference is BAD. */ + +#define GET_AI(ai, afd, addr) \ +do { \ + /* external reference: pai, error, and label free */ \ + (ai) = get_ai(pai, (afd), (addr)); \ + if ((ai) == NULL) { \ + error = EAI_MEMORY; \ + goto free; \ + } \ +} while (/*CONSTCOND*/0) + +#define GET_PORT(ai, serv) \ +do { \ + /* external reference: error and label free */ \ + error = get_port((ai), (serv), 0); \ + if (error != 0) \ + goto free; \ +} while (/*CONSTCOND*/0) + +#define ERR(err) \ +do { \ + /* external reference: error, and label bad */ \ + error = (err); \ + goto bad; \ + /*NOTREACHED*/ \ +} while (/*CONSTCOND*/0) + +#define MATCH_FAMILY(x, y, w) \ + ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC))) +#define MATCH(x, y, w) \ + ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) + +#if 0 +/* We will need this should we ever want gai_strerror() */ +char * +gai_strerror(int ecode) +{ + if (ecode < 0 || ecode > EAI_MAX) + ecode = EAI_MAX; + return ai_errlist[ecode]; +} +#endif + +void +rb_freeaddrinfo(struct rb_addrinfo *ai) +{ + struct rb_addrinfo *next; + + do { + next = ai->ai_next; + if (ai->ai_canonname) + rb_free(ai->ai_canonname); + /* no need to free(ai->ai_addr) */ + rb_free(ai); + ai = next; + } while (ai); +} + +static bool +str_isnumber(const char *p) +{ + char *ep; + + if (*p == '\0') + return false; + + ep = NULL; + errno = 0; + (void)strtoul(p, &ep, 10); + if (errno == 0 && ep && *ep == '\0') + return true; + else + return false; +} + +int +rb_getaddrinfo(const char *hostname, const char *servname, + const struct rb_addrinfo *hints, struct rb_addrinfo **res) +{ + struct rb_addrinfo sentinel; + struct rb_addrinfo *cur; + int error = 0; + struct rb_addrinfo ai; + struct rb_addrinfo ai0; + struct rb_addrinfo *pai; + const struct explore *ex; + + memset(&sentinel, 0, sizeof(sentinel)); + cur = &sentinel; + pai = &ai; + pai->ai_flags = 0; + pai->ai_family = PF_UNSPEC; + pai->ai_socktype = ANY; + pai->ai_protocol = ANY; + pai->ai_addrlen = 0; + pai->ai_canonname = NULL; + pai->ai_addr = NULL; + pai->ai_next = NULL; + + if (hostname == NULL && servname == NULL) + return EAI_NONAME; + if (hints) { + /* error check for hints */ + if (hints->ai_addrlen || hints->ai_canonname || + hints->ai_addr || hints->ai_next) + ERR(EAI_BADHINTS); /* xxx */ + if (hints->ai_flags & ~AI_MASK) + ERR(EAI_BADFLAGS); + switch (hints->ai_family) { + case PF_UNSPEC: + case PF_INET: +#ifdef IPV6 + case PF_INET6: +#endif + break; + default: + ERR(EAI_FAMILY); + } + memcpy(pai, hints, sizeof(*pai)); + + /* + * if both socktype/protocol are specified, check if they + * are meaningful combination. + */ + if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) { + for (ex = explore; ex->e_af >= 0; ex++) { + if (pai->ai_family != ex->e_af) + continue; + if (ex->e_socktype == ANY) + continue; + if (ex->e_protocol == ANY) + continue; + if (pai->ai_socktype == ex->e_socktype && + pai->ai_protocol != ex->e_protocol) { + ERR(EAI_BADHINTS); + } + } + } + } + + /* + * check for special cases. (1) numeric servname is disallowed if + * socktype/protocol are left unspecified. (2) servname is disallowed + * for raw and other inet{,6} sockets. + */ + if (MATCH_FAMILY(pai->ai_family, PF_INET, 1) +#ifdef IPV6 + || MATCH_FAMILY(pai->ai_family, PF_INET6, 1) +#endif + ) { + ai0 = *pai; /* backup *pai */ + + if (pai->ai_family == PF_UNSPEC) { +#ifdef IPV6 + pai->ai_family = PF_INET6; +#else + pai->ai_family = PF_INET; +#endif + } + error = get_portmatch(pai, servname); + if (error) + ERR(error); + + *pai = ai0; + } + + ai0 = *pai; + + /* NULL hostname, or numeric hostname */ + for (ex = explore; ex->e_af >= 0; ex++) { + *pai = ai0; + + /* PF_UNSPEC entries are prepared for DNS queries only */ + if (ex->e_af == PF_UNSPEC) + continue; + + if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) + continue; + if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) + continue; + if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) + continue; + + if (pai->ai_family == PF_UNSPEC) + pai->ai_family = ex->e_af; + if (pai->ai_socktype == ANY && ex->e_socktype != ANY) + pai->ai_socktype = ex->e_socktype; + if (pai->ai_protocol == ANY && ex->e_protocol != ANY) + pai->ai_protocol = ex->e_protocol; + + if (hostname == NULL) + error = explore_null(pai, servname, &cur->ai_next); + else + error = explore_numeric(pai, hostname, servname, &cur->ai_next); + + if (error) + goto free; + + while (cur && cur->ai_next) + cur = cur->ai_next; + } + + /* + * XXX + * If numreic representation of AF1 can be interpreted as FQDN + * representation of AF2, we need to think again about the code below. + */ + if (sentinel.ai_next) + goto good; + + if (pai->ai_flags & AI_NUMERICHOST) + ERR(EAI_NONAME); + if (hostname == NULL) + ERR(EAI_NODATA); + + /* XXX */ + if (sentinel.ai_next) + error = 0; + + if (error) + goto free; + if (error == 0) { + if (sentinel.ai_next) { + good: + *res = sentinel.ai_next; + return SUCCESS; + } else + error = EAI_FAIL; + } + free: + bad: + if (sentinel.ai_next) + rb_freeaddrinfo(sentinel.ai_next); + *res = NULL; + return error; +} + +/* + * hostname == NULL. + * passive socket -> anyaddr (0.0.0.0 or ::) + * non-passive socket -> localhost (127.0.0.1 or ::1) + */ +static int +explore_null(const struct rb_addrinfo *pai, const char *servname, struct rb_addrinfo **res) +{ + int s; + const struct afd *afd; + struct rb_addrinfo *cur; + struct rb_addrinfo sentinel; + int error; + + *res = NULL; + sentinel.ai_next = NULL; + cur = &sentinel; + + /* + * filter out AFs that are not supported by the kernel + * XXX errno? + */ + s = socket(pai->ai_family, SOCK_DGRAM, 0); + if (s < 0) { +#ifdef _WIN32 + errno = WSAGetLastError(); +#endif + if (errno != EMFILE) + return 0; + } else +#ifdef _WIN32 + closesocket(s); +#else + close(s); +#endif + + /* + * if the servname does not match socktype/protocol, ignore it. + */ + if (get_portmatch(pai, servname) != 0) + return 0; + + afd = find_afd(pai->ai_family); + if (afd == NULL) + return 0; + + if (pai->ai_flags & AI_PASSIVE) { + GET_AI(cur->ai_next, afd, afd->a_addrany); + GET_PORT(cur->ai_next, servname); + } else { + GET_AI(cur->ai_next, afd, afd->a_loopback); + GET_PORT(cur->ai_next, servname); + } + cur = cur->ai_next; + + *res = sentinel.ai_next; + return 0; + +free: + if (sentinel.ai_next) + rb_freeaddrinfo(sentinel.ai_next); + return error; +} + +/* + * numeric hostname + */ +static int +explore_numeric(const struct rb_addrinfo *pai, const char *hostname, + const char *servname, struct rb_addrinfo **res) +{ + const struct afd *afd; + struct rb_addrinfo *cur; + struct rb_addrinfo sentinel; + int error; + char pton[PTON_MAX]; + + *res = NULL; + sentinel.ai_next = NULL; + cur = &sentinel; + + /* + * if the servname does not match socktype/protocol, ignore it. + */ + if (get_portmatch(pai, servname) != 0) + return 0; + + afd = find_afd(pai->ai_family); + if (afd == NULL) + return 0; + + switch (afd->a_af) { +#if 0 /*X/Open spec*/ + case AF_INET: + if (rb_inet_pton + if (inet_aton(hostname, (struct in_addr *)pton) == 1) { + if (pai->ai_family == afd->a_af || + pai->ai_family == PF_UNSPEC /*?*/) { + GET_AI(cur->ai_next, afd, pton); + GET_PORT(cur->ai_next, servname); + while (cur && cur->ai_next) + cur = cur->ai_next; + } else + ERR(EAI_FAMILY); /*xxx*/ + } + break; +#endif + default: + if (rb_inet_pton(afd->a_af, hostname, pton) == 1) { + if (pai->ai_family == afd->a_af || + pai->ai_family == PF_UNSPEC /*?*/) { + GET_AI(cur->ai_next, afd, pton); + GET_PORT(cur->ai_next, servname); + while (cur && cur->ai_next) + cur = cur->ai_next; + } else + ERR(EAI_FAMILY); /* XXX */ + } + break; + } + + *res = sentinel.ai_next; + return 0; + +free: +bad: + if (sentinel.ai_next) + rb_freeaddrinfo(sentinel.ai_next); + return error; +} + +static struct rb_addrinfo * +get_ai(const struct rb_addrinfo *pai, const struct afd *afd, const char *addr) +{ + char *p; + struct rb_addrinfo *ai; + + ai = (struct rb_addrinfo *)rb_malloc(sizeof(struct rb_addrinfo) + + (afd->a_socklen)); + if (ai == NULL) + return NULL; + + memcpy(ai, pai, sizeof(struct rb_addrinfo)); + ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); + memset(ai->ai_addr, 0, (size_t)afd->a_socklen); + ai->ai_addrlen = afd->a_socklen; + ai->ai_addr->sa_family = ai->ai_family = afd->a_af; + p = (char *)(void *)(ai->ai_addr); + memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); + return ai; +} + +static int +get_portmatch(const struct rb_addrinfo *ai, const char *servname) +{ + struct rb_addrinfo xai; + memcpy(&xai, ai, sizeof(struct rb_addrinfo)); + return(get_port(&xai, servname, 1)); +} + +static int +get_port(struct rb_addrinfo *ai, const char *servname, int matchonly) +{ + const char *proto; + struct servent *sp; + int port; + int allownumeric; + + if (servname == NULL) + return 0; + switch (ai->ai_family) { + case AF_INET: +#ifdef AF_INET6 + case AF_INET6: +#endif + break; + default: + return 0; + } + + switch (ai->ai_socktype) { + case SOCK_RAW: + return EAI_SERVICE; + case SOCK_DGRAM: + case SOCK_STREAM: + allownumeric = 1; + break; + case ANY: + allownumeric = 0; + break; + default: + return EAI_SOCKTYPE; + } + + if (str_isnumber(servname)) { + if (!allownumeric) + return EAI_SERVICE; + port = atoi(servname); + if (port < 0 || port > 65535) + return EAI_SERVICE; + port = htons(port); + } else { + switch (ai->ai_socktype) { + case SOCK_DGRAM: + proto = "udp"; + break; + case SOCK_STREAM: + proto = "tcp"; + break; + default: + proto = NULL; + break; + } + + if ((sp = getservbyname(servname, proto)) == NULL) + return EAI_SERVICE; + port = sp->s_port; + } + + if (!matchonly) { + switch (ai->ai_family) { + case AF_INET: + ((struct sockaddr_in *)(void *) + ai->ai_addr)->sin_port = port; + break; +#ifdef IPV6 + case AF_INET6: + ((struct sockaddr_in6 *)(void *) + ai->ai_addr)->sin6_port = port; + break; +#endif + } + } + + return 0; +} + +static const struct afd * +find_afd(int af) +{ + const struct afd *afd; + + if (af == PF_UNSPEC) + return(NULL); + + for (afd = afdl; afd->a_af; afd++) + { + if (afd->a_af == af) + return(afd); + } + + return(NULL); +} +#endif diff --git a/authd/getaddrinfo.h b/authd/getaddrinfo.h new file mode 100644 index 00000000..9916629b --- /dev/null +++ b/authd/getaddrinfo.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +struct rb_addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + char *ai_canonname; + struct sockaddr *ai_addr; + struct rb_addrinfo *ai_next; +}; + +#ifndef AI_PASSIVE +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#endif /* AI_PASSIVE */ + +#ifndef AI_NUMERICHOST +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +#endif /* AI_NUMERICHOST */ + +#ifndef EAI_FAIL +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#endif /* EAI_FAIL */ + +#ifndef EAI_FAMILY +#define EAI_FAMILY 5 /* ai_family not supported */ +#endif /* EAI_FAMILY */ + +#ifndef EAI_MEMORY +#define EAI_MEMORY 6 /* memory allocation failure */ +#endif /* EAI_MEMORY */ + +#ifndef EAI_NONAME +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#endif /* EAI_NONAME */ + +#ifndef EAI_SYSTEM +#define EAI_SYSTEM 11 /* system error returned in errno */ +#endif /* EAI_SYSTEM */ + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 0x00000002 +#endif /* NI_NUMERICHOST */ + +#ifndef NI_NAMEREQD +#define NI_NAMEREQD 0x00000004 +#endif /* NI_NAMEREQD */ + +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 0x00000008 +#endif /* NI_NUMERICSERV */ + +#ifndef NI_DGRAM +#define NI_DGRAM 0x00000010 +#endif /* NI_DGRAM */ + +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned int) 0xffffffff) +#endif /* INADDR_NONE */ + +int rb_getaddrinfo(const char *hostname, const char *servname, + const struct rb_addrinfo *hints, struct rb_addrinfo **res); +void rb_freeaddrinfo(struct rb_addrinfo *ai); + +#define SUCCESS 0 +#define ANY 0 + +#undef EAI_ADDRFAMILY +#undef EAI_AGAIN +#undef EAI_BADFLAGS +#undef EAI_FAIL +#undef EAI_FAMILY +#undef EAI_MEMORY +#undef EAI_NODATA +#undef EAI_NONAME +#undef EAI_SERVICE +#undef EAI_SOCKTYPE +#undef EAI_SYSTEM +#undef EAI_BADHINTS +#undef EAI_PROTOCOL +#undef EAI_MAX +#undef AI_MASK + +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 +#define AI_MASK (AI_PASSIVE | AI_NUMERICHOST) diff --git a/authd/getnameinfo.c b/authd/getnameinfo.c new file mode 100644 index 00000000..39e296af --- /dev/null +++ b/authd/getnameinfo.c @@ -0,0 +1,240 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Issues to be discussed: + * - Thread safe-ness must be checked + * - RFC2553 says that we should raise error on short buffer. X/Open says + * we need to truncate the result. We obey RFC2553 (and X/Open should be + * modified). ipngwg rough consensus seems to follow RFC2553. + * - What is "local" in NI_FQDN? + * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other. + * - (KAME extension) always attach textual scopeid (fe80::1%lo0), if + * sin6_scope_id is filled - standardization status? + * XXX breaks backward compat for code that expects no scopeid. + * beware on merge. + */ + +#ifdef _WIN32 +#include +#include "getaddrinfo.h" +#include "getnameinfo.h" + +static const struct afd { + int a_af; + int a_addrlen; + rb_socklen_t a_socklen; + int a_off; +} afdl [] = { +#ifdef IPV6 + {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), + offsetof(struct sockaddr_in6, sin6_addr)}, +#endif + {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), + offsetof(struct sockaddr_in, sin_addr)}, + {0, 0, 0, 0}, +}; + +struct sockinet +{ + unsigned char si_len; + unsigned char si_family; + unsigned short si_port; +}; + +#ifdef IPV6 +static int ip6_parsenumeric(const struct sockaddr *, const char *, char *, + size_t, int); +#endif + +int +rb_getnameinfo(const struct sockaddr *sa, rb_socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) +{ + const struct afd *afd; + struct servent *sp; + unsigned short port; + int family, i; + const char *addr; + uint32_t v4a; + char numserv[512]; + char numaddr[512]; + + if (sa == NULL) + return EAI_FAIL; + +/* if (sa->sa_len != salen) + return EAI_FAIL; +*/ + family = sa->sa_family; + for (i = 0; afdl[i].a_af; i++) + if (afdl[i].a_af == family) { + afd = &afdl[i]; + goto found; + } + return EAI_FAMILY; + + found: + if (salen != afd->a_socklen) + return EAI_FAIL; + + /* network byte order */ + port = ((const struct sockinet *)sa)->si_port; + addr = (const char *)sa + afd->a_off; + + if (serv == NULL || servlen == 0) { + /* + * do nothing in this case. + * in case you are wondering if "&&" is more correct than + * "||" here: rfc2553bis-03 says that serv == NULL OR + * servlen == 0 means that the caller does not want the result. + */ + } else { + if (flags & NI_NUMERICSERV) + sp = NULL; + else { + sp = getservbyport(port, + (flags & NI_DGRAM) ? "udp" : "tcp"); + } + if (sp) { + if (strlen(sp->s_name) + 1 > servlen) + return EAI_MEMORY; + rb_strlcpy(serv, sp->s_name, servlen); + } else { + snprintf(numserv, sizeof(numserv), "%u", ntohs(port)); + if (strlen(numserv) + 1 > servlen) + return EAI_MEMORY; + rb_strlcpy(serv, numserv, servlen); + } + } + + switch (sa->sa_family) { + case AF_INET: + v4a = (uint32_t) + ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); + if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) + flags |= NI_NUMERICHOST; + v4a >>= IN_CLASSA_NSHIFT; + if (v4a == 0) + flags |= NI_NUMERICHOST; + break; +#ifdef IPV6 + case AF_INET6: + { + const struct sockaddr_in6 *sin6; + sin6 = (const struct sockaddr_in6 *)sa; + switch (sin6->sin6_addr.s6_addr[0]) { + case 0x00: + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + ; + else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) + ; + else + flags |= NI_NUMERICHOST; + break; + default: + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + flags |= NI_NUMERICHOST; + } + else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) + flags |= NI_NUMERICHOST; + break; + } + } + break; +#endif + } + if (host == NULL || hostlen == 0) { + /* + * do nothing in this case. + * in case you are wondering if "&&" is more correct than + * "||" here: rfc2553bis-03 says that host == NULL or + * hostlen == 0 means that the caller does not want the result. + */ + } else if (flags & NI_NUMERICHOST) { + size_t numaddrlen; + + /* NUMERICHOST and NAMEREQD conflicts with each other */ + if (flags & NI_NAMEREQD) + return EAI_NONAME; + + switch(afd->a_af) { +#ifdef IPV6 + case AF_INET6: + { + int error; + + if ((error = ip6_parsenumeric(sa, addr, host, + hostlen, flags)) != 0) + return(error); + break; + } +#endif + default: + if (rb_inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + == NULL) + return EAI_SYSTEM; + numaddrlen = strlen(numaddr); + if (numaddrlen + 1 > hostlen) /* don't forget terminator */ + return EAI_MEMORY; + rb_strlcpy(host, numaddr, hostlen); + break; + } + } + return(0); +} + +#ifdef IPV6 +static int +ip6_parsenumeric(const struct sockaddr *sa, const char *addr, + char *host, size_t hostlen, int flags) +{ + size_t numaddrlen; + char numaddr[512]; + + if (rb_inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) + return(EAI_SYSTEM); + + numaddrlen = strlen(numaddr); + + if (numaddrlen + 1 > hostlen) /* don't forget terminator */ + return(EAI_MEMORY); + + if (*numaddr == ':') + { + *host = '0'; + rb_strlcpy(host+1, numaddr, hostlen-1); + } + else + rb_strlcpy(host, numaddr, hostlen); + + return(0); +} +#endif +#endif diff --git a/authd/getnameinfo.h b/authd/getnameinfo.h new file mode 100644 index 00000000..d7a919a4 --- /dev/null +++ b/authd/getnameinfo.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +int rb_getnameinfo(const struct sockaddr *sa, rb_socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags); + +#ifndef IN_MULTICAST +#define IN_MULTICAST(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) +#endif + +#ifndef IN_EXPERIMENTAL +#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000) +#endif diff --git a/authd/notice.c b/authd/notice.c new file mode 100644 index 00000000..3e1d3f8a --- /dev/null +++ b/authd/notice.c @@ -0,0 +1,48 @@ +/* authd/notice.c - send notices back to the ircd and to clients + * Copyright (c) 2016 Elizabeth Myers + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "authd.h" +#include "notice.h" + +/* Send a notice to a client */ +void notice_client(uint32_t cid, const char *fmt, ...) +{ + char buf[BUFSIZE]; + va_list args; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + + rb_helper_write(authd_helper, "N %x :%s", cid, buf); +} + +/* Send a warning to the IRC daemon for logging, etc. */ +void warn_opers(notice_level_t level, const char *fmt, ...) +{ + char buf[BUFSIZE]; + va_list args; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + + rb_helper_write(authd_helper, "W %c :%s", level, buf); +} diff --git a/authd/notice.h b/authd/notice.h new file mode 100644 index 00000000..1e48bccf --- /dev/null +++ b/authd/notice.h @@ -0,0 +1,35 @@ +/* authd/notice.h - send notices back to the ircd and to clients + * Copyright (c) 2016 Elizabeth Myers + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CHARYBDIS_AUTHD_NOTICE_H__ +#define __CHARYBDIS_AUTHD_NOTICE_H__ + +typedef enum +{ + L_DEBUG = 'D', + L_INFO = 'I', + L_WARN = 'W', + L_CRIT ='C', +} notice_level_t; + +void notice_client(uint32_t cid, const char *fmt, ...); +void warn_opers(notice_level_t level, const char *fmt, ...); + +#endif /* __CHARYBDIS_AUTHD_NOTICE_H__ */ diff --git a/authd/provider.c b/authd/provider.c index bd46f53c..fcd9490a 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -18,16 +18,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* So the basic design here is to have "authentication providers" that do - * things like query ident and blacklists and even open proxies. +/* The basic design here is to have "authentication providers" that do things + * like query ident and blacklists and even open proxies. * - * Providers are registered statically in the struct auth_providers array. You will - * probably want to add an item to the provider_t enum also. + * Providers are registered in the auth_providers linked list. It is planned to + * use a bitmap to store provider ID's later. * - * Providers can either return failure immediately, immediate acceptance, or - * do work in the background (calling set_provider to signal this). + * Providers can either return failure immediately, immediate acceptance, or do + * work in the background (calling set_provider to signal this). * - * It is up to providers to keep their own state on clients if they need to. + * Provider-specific data for each client can be kept in an index of the data + * struct member (using the provider's ID). * * All providers must implement at a minimum a perform_provider function. You * don't have to implement the others if you don't need them. @@ -39,53 +40,82 @@ * should call provider_done. Do NOT call this if you have accepted or rejected * the client. * + * Eventually, stuff like *:line handling will be moved here, but that means we + * have to talk to bandb directly first. + * * --Elizafox, 9 March 2016 */ +#include "rb_dictionary.h" #include "authd.h" #include "provider.h" +#include "notice.h" rb_dlink_list auth_providers; /* Clients waiting */ -struct auth_client auth_clients[MAX_CLIENTS]; +rb_dictionary *auth_clients; /* Load a provider */ -void load_provider(struct auth_provider *provider) +void +load_provider(struct auth_provider *provider) { + if(rb_dlink_list_length(&auth_providers) >= MAX_PROVIDERS) + { + warn_opers(L_CRIT, "Exceeded maximum level of authd providers (%d max)", MAX_PROVIDERS); + return; + } + + if(provider->opt_handlers != NULL) + { + struct auth_opts_handler *handler; + + for(handler = provider->opt_handlers; handler->option != NULL; handler++) + rb_dictionary_add(authd_option_handlers, handler->option, handler); + } + provider->init(); rb_dlinkAdd(provider, &provider->node, &auth_providers); } -void unload_provider(struct auth_provider *provider) +void +unload_provider(struct auth_provider *provider) { + if(provider->opt_handlers != NULL) + { + struct auth_opts_handler *handler; + + for(handler = provider->opt_handlers; handler->option != NULL; handler++) + rb_dictionary_delete(authd_option_handlers, handler->option); + } provider->destroy(); rb_dlinkDelete(&provider->node, &auth_providers); } /* Initalise all providers */ -void init_providers(void) +void +init_providers(void) { + auth_clients = rb_dictionary_create("pending auth clients", rb_uint32cmp); load_provider(&rdns_provider); load_provider(&ident_provider); + load_provider(&blacklist_provider); } /* Terminate all providers */ -void destroy_providers(void) +void +destroy_providers(void) { rb_dlink_node *ptr; + rb_dictionary_iter iter; + struct auth_client *auth; struct auth_provider *provider; /* Cancel outstanding connections */ - for (size_t i = 0; i < MAX_CLIENTS; i++) + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) { - if(auth_clients[i].cid) - { - /* TBD - is this the right thing? - * (NOTE - this error message is designed for morons) */ - reject_client(&auth_clients[i], 0, true, - "IRC server reloading... try reconnecting in a few seconds"); - } + /* TBD - is this the right thing? */ + reject_client(auth, 0, "Authentication system is down... try reconnecting in a few seconds"); } RB_DLINK_FOREACH(ptr, auth_providers.head) @@ -98,7 +128,8 @@ void destroy_providers(void) } /* Cancel outstanding providers for a client */ -void cancel_providers(struct auth_client *auth) +void +cancel_providers(struct auth_client *auth) { rb_dlink_node *ptr; struct auth_provider *provider; @@ -107,24 +138,30 @@ void cancel_providers(struct auth_client *auth) { provider = ptr->data; - if(provider->cancel && is_provider(auth, provider->id)) + if(provider->cancel && is_provider_on(auth, provider->id)) /* Cancel if required */ provider->cancel(auth); } + + rb_dictionary_delete(auth_clients, RB_UINT_TO_POINTER(auth->cid)); + rb_free(auth); } -/* Provider is done */ -void provider_done(struct auth_client *auth, provider_t id) +/* Provider is done - WARNING: do not use auth instance after calling! */ +void +provider_done(struct auth_client *auth, provider_t id) { rb_dlink_node *ptr; struct auth_provider *provider; - unset_provider(auth, id); + set_provider_off(auth, id); + set_provider_done(auth, id); if(!auth->providers) { - /* No more providers, done */ - accept_client(auth, 0); + if(!auth->providers_starting) + /* Only do this when there are no providers left */ + accept_client(auth, 0); return; } @@ -132,16 +169,16 @@ void provider_done(struct auth_client *auth, provider_t id) { provider = ptr->data; - if(provider->completed && is_provider(auth, provider->id)) + if(provider->completed && is_provider_on(auth, provider->id)) /* Notify pending clients who asked for it */ provider->completed(auth, id); } } -/* Reject a client, cancel outstanding providers if any if hard set to true */ -void reject_client(struct auth_client *auth, provider_t id, bool hard, const char *reason) +/* Reject a client - WARNING: do not use auth instance after calling! */ +void +reject_client(struct auth_client *auth, provider_t id, const char *reason) { - uint16_t cid = auth->cid; char reject; switch(id) @@ -155,83 +192,87 @@ void reject_client(struct auth_client *auth, provider_t id, bool hard, const cha case PROVIDER_BLACKLIST: reject = 'B'; break; - case PROVIDER_NULL: default: reject = 'N'; break; } - rb_helper_write(authd_helper, "R %x %c :%s", auth->cid, reject, reason); + /* We send back username and hostname in case ircd wants to overrule our decision. + * In the future this may not be the case. + * --Elizafox + */ + rb_helper_write(authd_helper, "R %x %c %s %s :%s", auth->cid, reject, auth->username, auth->hostname, reason); - unset_provider(auth, id); - - if(hard && auth->providers) - { - cancel_providers(auth); - memset(&auth_clients[cid], 0, sizeof(struct auth_client)); - } + set_provider_off(auth, id); + cancel_providers(auth); } -/* Accept a client, cancel outstanding providers if any */ -void accept_client(struct auth_client *auth, provider_t id) +/* Accept a client, cancel outstanding providers if any - WARNING: do nto use auth instance after calling! */ +void +accept_client(struct auth_client *auth, provider_t id) { - uint16_t cid = auth->cid; + uint32_t cid = auth->cid; rb_helper_write(authd_helper, "A %x %s %s", auth->cid, auth->username, auth->hostname); - unset_provider(auth, id); - - if(auth->providers) - cancel_providers(auth); - - memset(&auth_clients[cid], 0, sizeof(struct auth_client)); -} - -/* Send a notice to a client */ -void notice_client(struct auth_client *auth, const char *notice) -{ - rb_helper_write(authd_helper, "N %x :%s", auth->cid, notice); + set_provider_off(auth, id); + cancel_providers(auth); } /* Begin authenticating user */ -static void start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ip, const char *c_port) +static void +start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ip, const char *c_port) { - rb_dlink_node *ptr; struct auth_provider *provider; - struct auth_client *auth; + struct auth_client *auth = rb_malloc(sizeof(struct auth_client)); long lcid = strtol(cid, NULL, 16); + rb_dlink_node *ptr; - if(lcid >= MAX_CLIENTS) + if(lcid >= UINT32_MAX) return; - auth = &auth_clients[lcid]; - if(auth->cid != 0) - /* Shouldn't get here */ + auth->cid = (uint32_t)lcid; + + if(rb_dictionary_find(auth_clients, RB_UINT_TO_POINTER(auth->cid)) == NULL) + rb_dictionary_add(auth_clients, RB_UINT_TO_POINTER(auth->cid), auth); + else + { + warn_opers(L_CRIT, "BUG: duplicate client added via start_auth: %x", auth->cid); + rb_free(auth); return; + } - auth->cid = (uint16_t)lcid; + rb_strlcpy(auth->l_ip, l_ip, sizeof(auth->l_ip)); + auth->l_port = (uint16_t)atoi(l_port); /* should be safe */ + (void) rb_inet_pton_sock(l_ip, (struct sockaddr *)&auth->l_addr); + + rb_strlcpy(auth->c_ip, c_ip, sizeof(auth->c_ip)); + auth->c_port = (uint16_t)atoi(c_port); + (void) rb_inet_pton_sock(c_ip, (struct sockaddr *)&auth->c_addr); - (void)rb_inet_pton_sock(l_ip, (struct sockaddr *)&auth->l_addr); #ifdef RB_IPV6 if(GET_SS_FAMILY(&auth->l_addr) == AF_INET6) - ((struct sockaddr_in6 *)&auth->l_addr)->sin6_port = htons(atoi(l_ip)); + ((struct sockaddr_in6 *)&auth->l_addr)->sin6_port = htons(auth->l_port); else #endif - ((struct sockaddr_in *)&auth->l_addr)->sin_port = htons(atoi(l_ip)); + ((struct sockaddr_in *)&auth->l_addr)->sin_port = htons(auth->l_port); - (void)rb_inet_pton_sock(c_ip, (struct sockaddr *)&auth->c_addr); #ifdef RB_IPV6 if(GET_SS_FAMILY(&auth->c_addr) == AF_INET6) - ((struct sockaddr_in6 *)&auth->c_addr)->sin6_port = htons(atoi(c_ip)); + ((struct sockaddr_in6 *)&auth->c_addr)->sin6_port = htons(auth->c_port); else #endif - ((struct sockaddr_in *)&auth->c_addr)->sin_port = htons(atoi(c_ip)); + ((struct sockaddr_in *)&auth->c_addr)->sin_port = htons(auth->c_port); + memset(auth->data, 0, sizeof(auth->data)); + auth->providers_starting = true; RB_DLINK_FOREACH(ptr, auth_providers.head) { provider = ptr->data; + lrb_assert(provider->start != NULL); + /* Execute providers */ if(!provider->start(auth)) { @@ -240,6 +281,7 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co return; } } + auth->providers_starting = false; /* If no providers are running, accept the client */ if(!auth->providers) @@ -247,10 +289,41 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co } /* Callback for the initiation */ -void handle_new_connection(int parc, char *parv[]) +void +handle_new_connection(int parc, char *parv[]) { - if(parc < 7) + if(parc < 6) + { + warn_opers(L_CRIT, "BUG: received too few params for new connection (6 expected, got %d)", parc); return; + } start_auth(parv[1], parv[2], parv[3], parv[4], parv[5]); } + +void +handle_cancel_connection(int parc, char *parv[]) +{ + struct auth_client *auth; + long lcid; + + if(parc < 2) + { + warn_opers(L_CRIT, "BUG: received too few params for new connection (2 expected, got %d)", parc); + return; + } + + if((lcid = strtol(parv[1], NULL, 16)) > UINT32_MAX) + { + warn_opers(L_CRIT, "BUG: got a request to cancel a connection that can't exist: %lx", lcid); + return; + } + + if((auth = rb_dictionary_retrieve(auth_clients, RB_UINT_TO_POINTER((uint32_t)lcid))) == NULL) + { + warn_opers(L_CRIT, "BUG: tried to cancel nonexistent connection %lx", lcid); + return; + } + + cancel_providers(auth); +} diff --git a/authd/provider.h b/authd/provider.h index 4f3c57a9..a9e99e2c 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -22,39 +22,49 @@ #define __CHARYBDIS_AUTHD_PROVIDER_H__ #include "stdinc.h" +#include "authd.h" +#include "rb_dictionary.h" -/* Arbitrary limit */ -#define MAX_CLIENTS 4096 +#define MAX_PROVIDERS 32 /* This should be enough */ /* Registered providers */ typedef enum { - PROVIDER_NULL = 0x0, /* Dummy value */ - PROVIDER_RDNS = 0x1, - PROVIDER_IDENT = 0x2, - PROVIDER_BLACKLIST = 0x4, + PROVIDER_RDNS, + PROVIDER_IDENT, + PROVIDER_BLACKLIST, } provider_t; struct auth_client { uint16_t cid; /* Client ID */ - struct rb_sockaddr_storage l_addr; /* Listener IP address */ - struct rb_sockaddr_storage c_addr; /* Client IP address */ + char l_ip[HOSTIPLEN + 1]; /* Listener IP address */ + uint16_t l_port; /* Listener port */ + struct rb_sockaddr_storage l_addr; /* Listener address/port */ + + char c_ip[HOSTIPLEN + 1]; /* Client IP address */ + uint16_t c_port; /* Client port */ + struct rb_sockaddr_storage c_addr; /* Client address/port */ char hostname[HOSTLEN + 1]; /* Used for DNS lookup */ char username[USERLEN + 1]; /* Used for ident lookup */ - unsigned int providers; /* Providers at work, + uint32_t providers; /* Providers at work, * none left when set to 0 */ + uint32_t providers_done; /* Providers completed */ + bool providers_starting; /* Providers are still warming up */ + + void *data[MAX_PROVIDERS]; /* Provider-specific data slots */ }; typedef bool (*provider_init_t)(void); -typedef bool (*provider_perform_t)(struct auth_client *); -typedef void (*provider_complete_t)(struct auth_client *, provider_t provider); -typedef void (*provider_cancel_t)(struct auth_client *); typedef void (*provider_destroy_t)(void); +typedef bool (*provider_start_t)(struct auth_client *); +typedef void (*provider_cancel_t)(struct auth_client *); +typedef void (*provider_complete_t)(struct auth_client *, provider_t); + struct auth_provider { rb_dlink_node node; @@ -64,16 +74,19 @@ struct auth_provider provider_init_t init; /* Initalise the provider */ provider_destroy_t destroy; /* Terminate the provider */ - provider_perform_t start; /* Perform authentication */ + provider_start_t start; /* Perform authentication */ provider_cancel_t cancel; /* Authentication cancelled */ provider_complete_t completed; /* Callback for when other performers complete (think dependency chains) */ + + struct auth_opts_handler *opt_handlers; }; extern rb_dlink_list auth_providers; +extern rb_dictionary *auth_clients; + extern struct auth_provider rdns_provider; extern struct auth_provider ident_provider; - -extern struct auth_client auth_clients[MAX_CLIENTS]; +extern struct auth_provider blacklist_provider; void load_provider(struct auth_provider *provider); void unload_provider(struct auth_provider *provider); @@ -84,28 +97,43 @@ void cancel_providers(struct auth_client *auth); void provider_done(struct auth_client *auth, provider_t id); void accept_client(struct auth_client *auth, provider_t id); -void reject_client(struct auth_client *auth, provider_t id, bool hard, const char *reason); - -void notice_client(struct auth_client *auth, const char *notice); +void reject_client(struct auth_client *auth, provider_t id, const char *reason); void handle_new_connection(int parc, char *parv[]); +void handle_cancel_connection(int parc, char *parv[]); /* Provider is operating on this auth_client (set this if you have async work to do) */ -static inline void set_provider(struct auth_client *auth, provider_t provider) +static inline void +set_provider_on(struct auth_client *auth, provider_t provider) { - auth->providers |= provider; + auth->providers |= (1 << provider); } /* Provider is no longer operating on this auth client (you should use provider_done) */ -static inline void unset_provider(struct auth_client *auth, provider_t provider) +static inline void +set_provider_off(struct auth_client *auth, provider_t provider) { - auth->providers &= ~provider; + auth->providers &= ~(1 << provider); +} + +/* Set the provider to done (you should use provider_done) */ +static inline void +set_provider_done(struct auth_client *auth, provider_t provider) +{ + auth->providers_done |= (1 << provider); } /* Check if provider is operating on this auth client */ -static inline bool is_provider(struct auth_client *auth, provider_t provider) +static inline bool +is_provider_on(struct auth_client *auth, provider_t provider) { - return auth->providers & provider; + return auth->providers & (1 << provider); +} + +static inline bool +is_provider_done(struct auth_client *auth, provider_t provider) +{ + return auth->providers_done & (1 << provider); } #endif /* __CHARYBDIS_AUTHD_PROVIDER_H__ */ diff --git a/authd/providers/blacklist.c b/authd/providers/blacklist.c new file mode 100644 index 00000000..c05cb630 --- /dev/null +++ b/authd/providers/blacklist.c @@ -0,0 +1,565 @@ +/* + * charybdis: A slightly useful ircd. + * blacklist.c: Manages DNS blacklist entries and lookups + * + * Copyright (C) 2006-2011 charybdis development team + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Originally written for charybdis circa 2006 (by nenolod?). + * Tweaked for authd. Some functions and structs renamed. Public/private + * interfaces have been shifted around. Some code has been cleaned up too. + * -- Elizafox 24 March 2016 + */ + +#include "authd.h" +#include "provider.h" +#include "notice.h" +#include "stdinc.h" +#include "dns.h" + +typedef enum filter_t +{ + FILTER_ALL = 1, + FILTER_LAST = 2, +} filter_t; + +/* Blacklist accepted IP types */ +#define IPTYPE_IPV4 1 +#define IPTYPE_IPV6 2 + +/* A configured DNSBL */ +struct blacklist +{ + char host[IRCD_RES_HOSTLEN + 1]; + char reason[BUFSIZE]; /* Reason template (ircd fills in the blanks) */ + unsigned char iptype; /* IP types supported */ + rb_dlink_list filters; /* Filters for queries */ + + bool delete; /* If true delete when no clients */ + int refcount; /* When 0 and delete is set, remove this blacklist */ + + time_t lastwarning; /* Last warning about garbage replies sent */ +}; + +/* A lookup in progress for a particular DNSBL for a particular client */ +struct blacklist_lookup +{ + struct blacklist *bl; /* Blacklist we're checking */ + struct auth_client *auth; /* Client */ + struct dns_query *query; /* DNS query pointer */ + + rb_dlink_node node; +}; + +/* A blacklist filter */ +struct blacklist_filter +{ + filter_t type; /* Type of filter */ + char filter[HOSTIPLEN]; /* The filter itself */ + + rb_dlink_node node; +}; + +/* Blacklist user data attached to auth_client instance */ +struct blacklist_user +{ + rb_dlink_list queries; /* Blacklist queries in flight */ + time_t timeout; /* When this times out */ +}; + +/* public interfaces */ +static bool blacklists_init(void); +static void blacklists_destroy(void); + +static bool blacklists_start(struct auth_client *); +static void blacklists_cancel(struct auth_client *); + +/* private interfaces */ +static void unref_blacklist(struct blacklist *); +static struct blacklist *new_blacklist(const char *, const char *, unsigned char, rb_dlink_list *); +static struct blacklist *find_blacklist(const char *); +static bool blacklist_check_reply(struct blacklist_lookup *, const char *); +static void blacklist_dns_callback(const char *, bool, query_type, void *); +static void initiate_blacklist_dnsquery(struct blacklist *, struct auth_client *); +static void timeout_blacklist_queries_event(void *); + +/* Variables */ +static rb_dlink_list blacklist_list = { NULL, NULL, 0 }; +static struct ev_entry *timeout_ev; +static int blacklist_timeout = 15; + +/* private interfaces */ + +static void +unref_blacklist(struct blacklist *bl) +{ + rb_dlink_node *ptr, *nptr; + + bl->refcount--; + if (bl->delete && bl->refcount <= 0) + { + RB_DLINK_FOREACH_SAFE(ptr, nptr, bl->filters.head) + { + rb_dlinkDelete(ptr, &bl->filters); + rb_free(ptr); + } + + rb_dlinkFindDestroy(bl, &blacklist_list); + rb_free(bl); + } +} + +static struct blacklist * +new_blacklist(const char *name, const char *reason, unsigned char iptype, rb_dlink_list *filters) +{ + struct blacklist *bl; + + if (name == NULL || reason == NULL || iptype == 0) + return NULL; + + if((bl = find_blacklist(name)) == NULL) + { + bl = rb_malloc(sizeof(struct blacklist)); + rb_dlinkAddAlloc(bl, &blacklist_list); + } + else + bl->delete = false; + + rb_strlcpy(bl->host, name, IRCD_RES_HOSTLEN + 1); + rb_strlcpy(bl->reason, reason, BUFSIZE); + bl->iptype = iptype; + + rb_dlinkMoveList(filters, &bl->filters); + + bl->lastwarning = 0; + + return bl; +} + +static struct blacklist * +find_blacklist(const char *name) +{ + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, blacklist_list.head) + { + struct blacklist *bl = (struct blacklist *)ptr->data; + + if (!strcasecmp(bl->host, name)) + return bl; + } + + return NULL; +} + +static inline bool +blacklist_check_reply(struct blacklist_lookup *bllookup, const char *ipaddr) +{ + struct blacklist *bl = bllookup->bl; + const char *lastoctet; + rb_dlink_node *ptr; + + /* No filters and entry found - thus positive match */ + if (!rb_dlink_list_length(&bl->filters)) + return true; + + /* Below will prolly have to change if IPv6 address replies are sent back */ + if ((lastoctet = strrchr(ipaddr, '.')) == NULL || *(++lastoctet) == '\0') + goto blwarn; + + RB_DLINK_FOREACH(ptr, bl->filters.head) + { + struct blacklist_filter *filter = ptr->data; + const char *cmpstr; + + if (filter->type == FILTER_ALL) + cmpstr = ipaddr; + else if (filter->type == FILTER_LAST) + cmpstr = lastoctet; + else + { + warn_opers(L_CRIT, "BUG: Unknown blacklist filter type on blacklist %s: %d", + bl->host, filter->type); + continue; + } + + if (strcmp(cmpstr, filter->filter) == 0) + /* Match! */ + return true; + } + + return false; +blwarn: + if (bl->lastwarning + 3600 < rb_current_time()) + { + warn_opers(L_WARN, "Garbage/undecipherable reply received from blacklist %s (reply %s)", + bl->host, ipaddr); + bl->lastwarning = rb_current_time(); + } + return false; +} + +static void +blacklist_dns_callback(const char *result, bool status, query_type type, void *data) +{ + struct blacklist_lookup *bllookup = (struct blacklist_lookup *)data; + struct blacklist_user *bluser; + struct blacklist *bl; + struct auth_client *auth; + + if (bllookup == NULL || bllookup->auth == NULL) + return; + + bl = bllookup->bl; + auth = bllookup->auth; + bluser = auth->data[PROVIDER_BLACKLIST]; + if(bluser == NULL) + return; + + if (result != NULL && status && blacklist_check_reply(bllookup, result)) + { + /* Match found, so proceed no further */ + blacklists_cancel(auth); + reject_client(auth, PROVIDER_BLACKLIST, bl->reason); + return; + } + + unref_blacklist(bl); + cancel_query(bllookup->query); /* Ignore future responses */ + rb_dlinkDelete(&bllookup->node, &bluser->queries); + rb_free(bllookup); + + if(!rb_dlink_list_length(&bluser->queries)) + { + /* Done here */ + rb_free(bluser); + auth->data[PROVIDER_BLACKLIST] = NULL; + provider_done(auth, PROVIDER_BLACKLIST); + } +} + +static void +initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth) +{ + struct blacklist_lookup *bllookup = rb_malloc(sizeof(struct blacklist_lookup)); + struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST]; + char buf[IRCD_RES_HOSTLEN + 1]; + int aftype; + + bllookup->bl = bl; + bllookup->auth = auth; + + aftype = GET_SS_FAMILY(&auth->c_addr); + if((aftype == AF_INET && (bl->iptype & IPTYPE_IPV4) == 0) || + (aftype == AF_INET6 && (bl->iptype & IPTYPE_IPV6) == 0)) + /* Incorrect blacklist type for this IP... */ + return; + + build_rdns(buf, sizeof(buf), &auth->c_addr, bl->host); + + bllookup->query = lookup_ip(buf, AF_INET, blacklist_dns_callback, bllookup); + + rb_dlinkAdd(bllookup, &bllookup->node, &bluser->queries); + bl->refcount++; +} + +/* Timeout outstanding queries */ +static void +timeout_blacklist_queries_event(void *notused) +{ + struct auth_client *auth; + rb_dictionary_iter iter; + + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + { + struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST]; + + if(bluser != NULL && bluser->timeout < rb_current_time()) + { + blacklists_cancel(auth); + provider_done(auth, PROVIDER_BLACKLIST); + } + } +} + +static inline void +lookup_all_blacklists(struct auth_client *auth) +{ + struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST]; + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, blacklist_list.head) + { + struct blacklist *bl = (struct blacklist *)ptr->data; + + if (!bl->delete) + initiate_blacklist_dnsquery(bl, auth); + } + + bluser->timeout = rb_current_time() + blacklist_timeout; +} + +static inline void +delete_blacklist(struct blacklist *bl) +{ + if (bl->refcount > 0) + bl->delete = true; + else + { + rb_dlinkFindDestroy(bl, &blacklist_list); + rb_free(bl); + } +} + +static void +delete_all_blacklists(void) +{ + rb_dlink_node *ptr, *nptr; + + RB_DLINK_FOREACH_SAFE(ptr, nptr, blacklist_list.head) + { + delete_blacklist(ptr->data); + } +} + +/* public interfaces */ +static bool +blacklists_start(struct auth_client *auth) +{ + if(auth->data[PROVIDER_BLACKLIST] != NULL) + return true; + + if(!rb_dlink_list_length(&blacklist_list)) + /* Nothing to do... */ + return true; + + auth->data[PROVIDER_BLACKLIST] = rb_malloc(sizeof(struct blacklist_user)); + + if(is_provider_done(auth, PROVIDER_RDNS) && is_provider_done(auth, PROVIDER_IDENT)) + /* This probably can't happen but let's handle this case anyway */ + lookup_all_blacklists(auth); + + set_provider_on(auth, PROVIDER_BLACKLIST); + return true; +} + +/* This is called every time a provider is completed as long as we are marked not done */ +static void +blacklists_initiate(struct auth_client *auth, provider_t provider) +{ + struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST]; + + lrb_assert(provider != PROVIDER_BLACKLIST); + lrb_assert(!is_provider_done(auth, PROVIDER_BLACKLIST)); + lrb_assert(rb_dlink_list_length(&blacklist_list) > 0); + + if(bluser == NULL || rb_dlink_list_length(&bluser->queries)) + /* Nothing to do */ + return; + else if(!(is_provider_done(auth, PROVIDER_RDNS) && is_provider_done(auth, PROVIDER_IDENT))) + /* Don't start until we've completed these */ + return; + else + lookup_all_blacklists(auth); +} + +static void +blacklists_cancel(struct auth_client *auth) +{ + rb_dlink_node *ptr, *nptr; + struct blacklist_user *bluser = auth->data[PROVIDER_BLACKLIST]; + + if(bluser == NULL) + return; + + RB_DLINK_FOREACH_SAFE(ptr, nptr, bluser->queries.head) + { + struct blacklist_lookup *bllookup = ptr->data; + + cancel_query(bllookup->query); + unref_blacklist(bllookup->bl); + + rb_dlinkDelete(&bllookup->node, &bluser->queries); + rb_free(bllookup); + } + + rb_free(bluser); + auth->data[PROVIDER_BLACKLIST] = NULL; +} + +static bool +blacklists_init(void) +{ + timeout_ev = rb_event_addish("timeout_blacklist_queries_event", timeout_blacklist_queries_event, NULL, 1); + return (timeout_ev != NULL); +} + +static void +blacklists_destroy(void) +{ + rb_dlink_node *ptr, *nptr; + rb_dictionary_iter iter; + struct blacklist *bl; + struct auth_client *auth; + + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + { + blacklists_cancel(auth); + } + + delete_all_blacklists(); + rb_event_delete(timeout_ev); +} + +static void +add_conf_blacklist(const char *key, int parc, const char **parv) +{ + rb_dlink_list filters = { NULL, NULL, 0 }; + char *tmp, *elemlist = rb_strdup(parv[2]); + unsigned char iptype; + + if(*elemlist == '*') + goto end; + + for(char *elem = rb_strtok_r(elemlist, ",", &tmp); elem; elem = rb_strtok_r(NULL, ",", &tmp)) + { + struct blacklist_filter *filter = rb_malloc(sizeof(struct blacklist_filter)); + int dot_c = 0; + filter_t type = FILTER_LAST; + bool valid = true; + + /* Check blacklist filter type and for validity */ + for(char *c = elem; *c != '\0'; c++) + { + if(*c == '.') + { + if(++dot_c > 3) + { + warn_opers(L_CRIT, "addr_conf_blacklist got a bad filter (too many octets)"); + valid = false; + break; + } + + type = FILTER_ALL; + } + else if(!isdigit(*c)) + { + warn_opers(L_CRIT, "addr_conf_blacklist got a bad filter (invalid character in blacklist filter: %c)", *c); + valid = false; + break; + } + } + + if(valid && dot_c > 0 && dot_c < 3) + { + warn_opers(L_CRIT, "addr_conf_blacklist got a bad filter (insufficient octets)"); + valid = false; + } + + if(!valid) + { + rb_free(filter); + continue; + } + + filter->type = type; + rb_strlcpy(filter->filter, elem, sizeof(filter->filter)); + rb_dlinkAdd(filter, &filter->node, &filters); + } + +end: + rb_free(elemlist); + + iptype = atoi(parv[1]) & 0x3; + if(new_blacklist(parv[0], parv[3], iptype, &filters) == NULL) + { + rb_dlink_node *ptr, *nptr; + + warn_opers(L_CRIT, "addr_conf_blacklist got a malformed blacklist"); + + RB_DLINK_FOREACH_SAFE(ptr, nptr, filters.head) + { + rb_free(ptr->data); + rb_dlinkDelete(ptr, &filters); + } + } +} + +static void +del_conf_blacklist(const char *key, int parc, const char **parv) +{ + struct blacklist *bl = find_blacklist(parv[0]); + if(bl == NULL) + { + warn_opers(L_CRIT, "BUG: tried to remove nonexistent blacklist %s", parv[0]); + return; + } + + delete_blacklist(bl); +} + +static void +del_conf_blacklist_all(const char *key, int parc, const char **parv) +{ + delete_all_blacklists(); +} + +static void +add_conf_blacklist_timeout(const char *key, int parc, const char **parv) +{ + int timeout = atoi(parv[0]); + + if(timeout < 0) + { + warn_opers(L_CRIT, "BUG: blacklist timeout < 0 (value: %d)", timeout); + return; + } + + blacklist_timeout = timeout; +} + +struct auth_opts_handler blacklist_options[] = +{ + { "rbl", 4, add_conf_blacklist }, + { "rbl_del", 1, del_conf_blacklist }, + { "rbl_del_all", 0, del_conf_blacklist_all }, + { "rbl_timeout", 1, add_conf_blacklist_timeout }, + { NULL, 0, NULL }, +}; + +struct auth_provider blacklist_provider = +{ + .id = PROVIDER_BLACKLIST, + .init = blacklists_init, + .destroy = blacklists_destroy, + .start = blacklists_start, + .cancel = blacklists_cancel, + .completed = blacklists_initiate, + .opt_handlers = blacklist_options, +}; diff --git a/authd/providers/ident.c b/authd/providers/ident.c index 0b943b48..e14fac43 100644 --- a/authd/providers/ident.c +++ b/authd/providers/ident.c @@ -18,9 +18,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* Largely adapted from old s_auth.c, but reworked for authd. rDNS code + * moved to its own provider. + * + * --Elizafox 13 March 2016 + */ + #include "stdinc.h" #include "match.h" #include "authd.h" +#include "notice.h" #include "provider.h" #include "res.h" @@ -28,19 +35,17 @@ struct ident_query { - rb_dlink_node node; - - struct auth_client *auth; /* Our client */ - time_t timeout; /* Timeout interval */ - rb_fde_t *F; /* Our FD */ + time_t timeout; /* Timeout interval */ + rb_fde_t *F; /* Our FD */ }; /* Goinked from old s_auth.c --Elizafox */ static const char *messages[] = { - ":*** Checking Ident", - ":*** Got Ident response", - ":*** No Ident response", + "*** Checking Ident", + "*** Got Ident response", + "*** No Ident response", + "*** Cannot verify ident validity, ignoring ident", }; typedef enum @@ -48,134 +53,34 @@ typedef enum REPORT_LOOKUP, REPORT_FOUND, REPORT_FAIL, + REPORT_INVALID, } ident_message; static EVH timeout_ident_queries_event; static CNCB ident_connected; static PF read_ident_reply; -static void client_fail(struct ident_query *query, ident_message message); -static void client_success(struct ident_query *query); -static void cleanup_query(struct ident_query *query); +static void client_fail(struct auth_client *auth, ident_message message); +static void client_success(struct auth_client *auth); static char * get_valid_ident(char *buf); -static rb_dlink_list queries; static struct ev_entry *timeout_ev; static int ident_timeout = 5; -bool ident_init(void) -{ - timeout_ev = rb_event_addish("timeout_ident_queries_event", timeout_ident_queries_event, NULL, 1); - return (timeout_ev != NULL); -} - -void ident_destroy(void) -{ - rb_dlink_node *ptr, *nptr; - - /* Nuke all ident queries */ - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) - { - struct ident_query *query = ptr->data; - - notice_client(query->auth, messages[REPORT_FAIL]); - - rb_close(query->F); - rb_free(query); - rb_dlinkDelete(ptr, &queries); - } -} - -bool ident_start(struct auth_client *auth) -{ - struct ident_query *query = rb_malloc(sizeof(struct ident_query)); - struct rb_sockaddr_storage localaddr, clientaddr; - int family; - rb_fde_t *F; - - query->auth = auth; - query->timeout = rb_current_time() + ident_timeout; - - if((F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL) - { - client_fail(query, REPORT_FAIL); - return true; /* Not a fatal error */ - } - - query->F = F; - - /* Build sockaddr_storages for rb_connect_tcp below */ - memcpy(&localaddr, &auth->l_addr, sizeof(struct rb_sockaddr_storage)); - memcpy(&clientaddr, &auth->c_addr, sizeof(struct rb_sockaddr_storage)); - - /* Set the ports correctly */ -#ifdef RB_IPV6 - if(GET_SS_FAMILY(&localaddr) == AF_INET6) - ((struct sockaddr_in6 *)&localaddr)->sin6_port = 0; - else -#endif - ((struct sockaddr_in *)&localaddr)->sin_port = 0; - -#ifdef RB_IPV6 - if(GET_SS_FAMILY(&clientaddr) == AF_INET6) - ((struct sockaddr_in6 *)&clientaddr)->sin6_port = htons(113); - else -#endif - ((struct sockaddr_in *)&clientaddr)->sin_port = htons(113); - - rb_connect_tcp(F, (struct sockaddr *)&auth->c_addr, - (struct sockaddr *)&auth->l_addr, - GET_SS_LEN(&auth->l_addr), ident_connected, - query, ident_timeout); - - set_provider(auth, PROVIDER_IDENT); - - rb_dlinkAdd(query, &query->node, &queries); - - notice_client(auth, messages[REPORT_LOOKUP]); - - return true; -} - -void ident_cancel(struct auth_client *auth) -{ - rb_dlink_node *ptr, *nptr; - - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) - { - struct ident_query *query = ptr->data; - - if(query->auth == auth) - { - client_fail(query, REPORT_FAIL); - - rb_close(query->F); - rb_free(query); - rb_dlinkDelete(ptr, &queries); - - return; - } - } -} - /* Timeout outstanding queries */ -static void timeout_ident_queries_event(void *notused) +static void +timeout_ident_queries_event(void *notused __unused) { - rb_dlink_node *ptr, *nptr; + struct auth_client *auth; + rb_dictionary_iter iter; - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) { - struct ident_query *query = ptr->data; + struct ident_query *query = auth->data[PROVIDER_IDENT]; - if(query->timeout < rb_current_time()) - { - client_fail(query, REPORT_FAIL); - - rb_close(query->F); - rb_free(query); - rb_dlinkDelete(ptr, &queries); - } + if(query != NULL && query->timeout < rb_current_time()) + client_fail(auth, REPORT_FAIL); } } @@ -190,74 +95,73 @@ static void timeout_ident_queries_event(void *notused) * a write buffer far greater than this message to store it in should * problems arise. -avalon */ -static void ident_connected(rb_fde_t *F, int error, void *data) +static void +ident_connected(rb_fde_t *F __unused, int error, void *data) { - struct ident_query *query = data; - struct auth_client *auth = query->auth; - uint16_t c_port, l_port; + struct auth_client *auth = data; + struct ident_query *query; char authbuf[32]; int authlen; + if(auth == NULL) + return; + + query = auth->data[PROVIDER_IDENT]; + + if(query == NULL) + return; + /* Check the error */ if(error != RB_OK) { /* We had an error during connection :( */ - client_fail(query, REPORT_FAIL); - cleanup_query(query); + client_fail(auth, REPORT_FAIL); return; } -#ifdef RB_IPV6 - if(GET_SS_FAMILY(&auth->c_addr) == AF_INET6) - c_port = ntohs(((struct sockaddr_in6 *)&auth->c_addr)->sin6_port); - else -#endif - c_port = ntohs(((struct sockaddr_in *)&auth->c_addr)->sin_port); - -#ifdef RB_IPV6 - if(GET_SS_FAMILY(&auth->l_addr) == AF_INET6) - l_port = ntohs(((struct sockaddr_in6 *)&auth->l_addr)->sin6_port); - else -#endif - l_port = ntohs(((struct sockaddr_in *)&auth->l_addr)->sin_port); - - snprintf(authbuf, sizeof(authbuf), "%u , %u\r\n", - c_port, l_port); + auth->c_port, auth->l_port); authlen = strlen(authbuf); if(rb_write(query->F, authbuf, authlen) != authlen) { - client_fail(query, REPORT_FAIL); + client_fail(auth, REPORT_FAIL); return; } - read_ident_reply(query->F, query); + read_ident_reply(query->F, auth); } static void read_ident_reply(rb_fde_t *F, void *data) { - struct ident_query *query = data; - struct auth_client *auth = query->auth; + struct auth_client *auth = data; + struct ident_query *query; + char buf[IDENT_BUFSIZE + 1]; /* buffer to read auth reply into */ + ident_message message = REPORT_FAIL; char *s = NULL; char *t = NULL; - int len; + ssize_t len; int count; - char buf[IDENT_BUFSIZE + 1]; /* buffer to read auth reply into */ + + if(auth == NULL) + return; + + query = auth->data[PROVIDER_IDENT]; + + if(query == NULL) + return; len = rb_read(F, buf, IDENT_BUFSIZE); if(len < 0 && rb_ignore_errno(errno)) { - rb_setselect(F, RB_SELECT_READ, read_ident_reply, query); + rb_setselect(F, RB_SELECT_READ, read_ident_reply, auth); return; } if(len > 0) { - buf[len] = '\0'; - - if((s = get_valid_ident(buf))) + if((s = get_valid_ident(buf)) != NULL) { t = auth->username; @@ -266,10 +170,9 @@ read_ident_reply(rb_fde_t *F, void *data) for (count = USERLEN; *s && count; s++) { - if(*s == '@') - { + if(*s == '@' || *s == '\r' || *s == '\n') break; - } + if(*s != ' ' && *s != ':' && *s != '[') { *t++ = *s; @@ -278,61 +181,58 @@ read_ident_reply(rb_fde_t *F, void *data) } *t = '\0'; } + else + message = REPORT_INVALID; } if(s == NULL) - client_fail(query, REPORT_FAIL); + client_fail(auth, message); else - client_success(query); - - cleanup_query(query); + client_success(auth); } -static void client_fail(struct ident_query *query, ident_message report) +static void +client_fail(struct auth_client *auth, ident_message report) { - struct auth_client *auth = query->auth; + struct ident_query *query = auth->data[PROVIDER_IDENT]; - if(auth) - { - rb_strlcpy(auth->username, "*", sizeof(auth->username)); - notice_client(auth, messages[report]); - provider_done(auth, PROVIDER_IDENT); - } + if(query == NULL) + return; + + rb_strlcpy(auth->username, "*", sizeof(auth->username)); + + if(query->F != NULL) + rb_close(query->F); + + rb_free(query); + auth->data[PROVIDER_IDENT] = NULL; + + notice_client(auth->cid, messages[report]); + provider_done(auth, PROVIDER_IDENT); } -static void client_success(struct ident_query *query) +static void +client_success(struct auth_client *auth) { - struct auth_client *auth = query->auth; + struct ident_query *query = auth->data[PROVIDER_IDENT]; - if(auth) - { - notice_client(auth, messages[REPORT_FOUND]); - provider_done(auth, PROVIDER_IDENT); - } -} + if(query == NULL) + return; -static void cleanup_query(struct ident_query *query) -{ - rb_dlink_node *ptr, *nptr; + if(query->F != NULL) + rb_close(query->F); - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) - { - struct ident_query *query_l = ptr->data; + rb_free(query); + auth->data[PROVIDER_IDENT] = NULL; - if(query_l == query) - { - rb_close(query->F); - rb_free(query); - rb_dlinkDelete(ptr, &queries); - } - } + notice_client(auth->cid, messages[REPORT_FOUND]); + provider_done(auth, PROVIDER_IDENT); } /* get_valid_ident * parse ident query reply from identd server * - * Torn out of old s_auth.c because there was nothing wrong with it - * --Elizafox + * Taken from old s_auth.c --Elizafox * * Inputs - pointer to ident buf * Outputs - NULL if no valid ident found, otherwise pointer to name @@ -354,45 +254,145 @@ get_valid_ident(char *buf) colon1Ptr = strchr(remotePortString, ':'); if(!colon1Ptr) - return 0; + return NULL; *colon1Ptr = '\0'; colon1Ptr++; colon2Ptr = strchr(colon1Ptr, ':'); if(!colon2Ptr) - return 0; + return NULL; *colon2Ptr = '\0'; colon2Ptr++; commaPtr = strchr(remotePortString, ','); if(!commaPtr) - return 0; + return NULL; *commaPtr = '\0'; commaPtr++; remp = atoi(remotePortString); if(!remp) - return 0; + return NULL; locp = atoi(commaPtr); if(!locp) - return 0; + return NULL; /* look for USERID bordered by first pair of colons */ if(!strstr(colon1Ptr, "USERID")) - return 0; + return NULL; colon3Ptr = strchr(colon2Ptr, ':'); if(!colon3Ptr) - return 0; + return NULL; *colon3Ptr = '\0'; colon3Ptr++; return (colon3Ptr); } +static bool +ident_init(void) +{ + timeout_ev = rb_event_addish("timeout_ident_queries_event", timeout_ident_queries_event, NULL, 1); + return (timeout_ev != NULL); +} + +static void +ident_destroy(void) +{ + struct auth_client *auth; + rb_dictionary_iter iter; + + /* Nuke all ident queries */ + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + { + if(auth->data[PROVIDER_IDENT] != NULL) + client_fail(auth, REPORT_FAIL); + } +} + +static bool ident_start(struct auth_client *auth) +{ + struct ident_query *query = rb_malloc(sizeof(struct ident_query)); + struct rb_sockaddr_storage l_addr, c_addr; + int family = GET_SS_FAMILY(&auth->c_addr); + + if(auth->data[PROVIDER_IDENT] != NULL) + return true; + + notice_client(auth->cid, messages[REPORT_LOOKUP]); + + auth->data[PROVIDER_IDENT] = query; + query->timeout = rb_current_time() + ident_timeout; + + if((query->F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL) + { + warn_opers(L_DEBUG, "Could not create ident socket: %s", strerror(errno)); + client_fail(auth, REPORT_FAIL); + return true; /* Not a fatal error */ + } + + /* Build sockaddr_storages for rb_connect_tcp below */ + memcpy(&l_addr, &auth->l_addr, sizeof(l_addr)); + memcpy(&c_addr, &auth->c_addr, sizeof(c_addr)); + + /* Set the ports correctly */ +#ifdef RB_IPV6 + if(GET_SS_FAMILY(&l_addr) == AF_INET6) + ((struct sockaddr_in6 *)&l_addr)->sin6_port = 0; + else +#endif + ((struct sockaddr_in *)&l_addr)->sin_port = 0; + +#ifdef RB_IPV6 + if(GET_SS_FAMILY(&c_addr) == AF_INET6) + ((struct sockaddr_in6 *)&c_addr)->sin6_port = htons(113); + else +#endif + ((struct sockaddr_in *)&c_addr)->sin_port = htons(113); + + rb_connect_tcp(query->F, (struct sockaddr *)&c_addr, + (struct sockaddr *)&l_addr, + GET_SS_LEN(&l_addr), ident_connected, + auth, ident_timeout); + + set_provider_on(auth, PROVIDER_IDENT); + + return true; +} + +static void +ident_cancel(struct auth_client *auth) +{ + struct ident_query *query = auth->data[PROVIDER_IDENT]; + + if(query != NULL) + client_fail(auth, REPORT_FAIL); +} + +static void +add_conf_ident_timeout(const char *key __unused, int parc __unused, const char **parv) +{ + int timeout = atoi(parv[0]); + + if(timeout < 0) + { + warn_opers(L_CRIT, "BUG: ident timeout < 0 (value: %d)", timeout); + return; + } + + ident_timeout = timeout; +} + +struct auth_opts_handler ident_options[] = +{ + { "ident_timeout", 1, add_conf_ident_timeout }, + { NULL, 0, NULL }, +}; + struct auth_provider ident_provider = { @@ -402,4 +402,5 @@ struct auth_provider ident_provider = .start = ident_start, .cancel = ident_cancel, .completed = NULL, + .opt_handlers = ident_options, }; diff --git a/authd/providers/rdns.c b/authd/providers/rdns.c index f06bbf0a..e5e1f6dd 100644 --- a/authd/providers/rdns.c +++ b/authd/providers/rdns.c @@ -22,15 +22,13 @@ #include "rb_commio.h" #include "authd.h" #include "provider.h" +#include "notice.h" #include "res.h" #include "dns.h" -struct dns_query +struct user_query { - rb_dlink_node node; - - struct auth_client *auth; /* Our client */ - struct DNSQuery query; /* DNS query */ + struct dns_query *query; /* Pending DNS query */ time_t timeout; /* When the request times out */ }; @@ -51,176 +49,157 @@ typedef enum REPORT_TOOLONG, } dns_message; -static EVH timeout_dns_queries_event; -static void client_fail(struct dns_query *query, dns_message message); -static void client_success(struct dns_query *query); -static void get_dns_answer(void *userdata, struct DNSReply *reply); +static void client_fail(struct auth_client *auth, dns_message message); +static void client_success(struct auth_client *auth); +static void dns_answer_callback(const char *res, bool status, query_type type, void *data); -static rb_dlink_list queries; static struct ev_entry *timeout_ev; -static int rdns_timeout = 30; +static EVH timeout_dns_queries_event; +static int rdns_timeout = 15; - -bool client_dns_init(void) +static void +dns_answer_callback(const char *res, bool status, query_type type, void *data) { - timeout_ev = rb_event_addish("timeout_dns_queries_event", timeout_dns_queries_event, NULL, 5); - return (timeout_ev != NULL); -} + struct auth_client *auth = data; + struct user_query *query = auth->data[PROVIDER_RDNS]; -void client_dns_destroy(void) -{ - rb_dlink_node *ptr, *nptr; - struct dns_query *query; - - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) + if(query == NULL || res == NULL || status == false) + client_fail(auth, REPORT_FAIL); + else if(strlen(res) > HOSTLEN) + client_fail(auth, REPORT_TOOLONG); + else { - client_fail(ptr->data, REPORT_FAIL); - rb_dlinkDelete(ptr, &queries); - rb_free(ptr); + rb_strlcpy(auth->hostname, res, HOSTLEN + 1); + client_success(auth); } - - rb_event_delete(timeout_ev); } -bool client_dns_start(struct auth_client *auth) +/* Timeout outstanding queries */ +static void +timeout_dns_queries_event(void *notused) { - struct dns_query *query = rb_malloc(sizeof(struct dns_query)); + struct auth_client *auth; + rb_dictionary_iter iter; - query->auth = auth; - query->timeout = rb_current_time() + rdns_timeout; - - query->query.ptr = query; - query->query.callback = get_dns_answer; - - gethost_byaddr(&auth->c_addr, &query->query); - notice_client(auth, messages[REPORT_LOOKUP]); - set_provider(auth, PROVIDER_RDNS); - return true; -} - -void client_dns_cancel(struct auth_client *auth) -{ - rb_dlink_node *ptr; - - /* Bah, the stupid DNS resolver code doesn't have a cancellation - * func... */ - RB_DLINK_FOREACH(ptr, queries.head) + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) { - struct dns_query *query = ptr->data; + struct user_query *query = auth->data[PROVIDER_RDNS]; - if(query->auth == auth) + if(query != NULL && query->timeout < rb_current_time()) { - /* This will get cleaned up later by the DNS stuff */ - client_fail(query, REPORT_FAIL); + client_fail(auth, REPORT_FAIL); return; } } } static void -get_dns_answer(void *userdata, struct DNSReply *reply) +client_fail(struct auth_client *auth, dns_message report) { - struct dns_query *query = userdata; - struct auth_client *auth = query->auth; - rb_dlink_node *ptr, *nptr; - bool fail = false; - dns_message response; + struct user_query *query = auth->data[PROVIDER_RDNS]; - if(reply == NULL || auth == NULL) - { - response = REPORT_FAIL; - fail = true; - goto cleanup; - } + if(query == NULL) + return; - if(!sockcmp(&auth->c_addr, &reply->addr, GET_SS_FAMILY(&auth->c_addr))) - { - response = REPORT_FAIL; - fail = true; - goto cleanup; - } + rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname)); - if(strlen(reply->h_name) > HOSTLEN) - { - /* Ah well. */ - response = REPORT_TOOLONG; - fail = true; - goto cleanup; - } + notice_client(auth->cid, messages[report]); + cancel_query(query->query); - rb_strlcpy(auth->hostname, reply->h_name, HOSTLEN + 1); + rb_free(query); + auth->data[PROVIDER_RDNS] = NULL; -cleanup: - /* Clean us up off the pending queries list */ - RB_DLINK_FOREACH_SAFE(ptr, nptr, queries.head) - { - struct dns_query *query_l = ptr->data; - - if(query == query_l) - { - /* Found */ - if(fail) - client_fail(query, response); - else - client_success(query); - - rb_dlinkDelete(ptr, &queries); - rb_free(query); - return; - } - } + provider_done(auth, PROVIDER_RDNS); } -/* Timeout outstanding queries */ -static void timeout_dns_queries_event(void *notused) +static void +client_success(struct auth_client *auth) { - rb_dlink_node *ptr; + struct user_query *query = auth->data[PROVIDER_RDNS]; - /* NOTE - we do not delete queries from the list from a timeout, when - * the query times out later it will be deleted. - */ - RB_DLINK_FOREACH(ptr, queries.head) - { - struct dns_query *query = ptr->data; + notice_client(auth->cid, messages[REPORT_FOUND]); + cancel_query(query->query); - if(query->auth && query->timeout < rb_current_time()) - { - client_fail(query, REPORT_FAIL); - } - } + rb_free(query); + auth->data[PROVIDER_RDNS] = NULL; + + provider_done(auth, PROVIDER_RDNS); } -static void client_fail(struct dns_query *query, dns_message report) +static bool +rdns_init(void) { - struct auth_client *auth = query->auth; - - if(auth) - { - rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname)); - notice_client(auth, messages[report]); - provider_done(auth, PROVIDER_RDNS); - query->auth = NULL; - } + timeout_ev = rb_event_addish("timeout_dns_queries_event", timeout_dns_queries_event, NULL, 1); + return (timeout_ev != NULL); } -static void client_success(struct dns_query *query) +static void +rdns_destroy(void) { - struct auth_client *auth = query->auth; + struct auth_client *auth; + rb_dictionary_iter iter; - if(auth) + RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) { - notice_client(auth, messages[REPORT_FOUND]); - provider_done(auth, PROVIDER_RDNS); - query->auth = NULL; + if(auth->data[PROVIDER_RDNS] != NULL) + client_fail(auth, REPORT_FAIL); } + + rb_event_delete(timeout_ev); } +static bool +rdns_start(struct auth_client *auth) +{ + struct user_query *query = rb_malloc(sizeof(struct user_query)); + + query->timeout = rb_current_time() + rdns_timeout; + + auth->data[PROVIDER_RDNS] = query; + + query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth); + + notice_client(auth->cid, messages[REPORT_LOOKUP]); + set_provider_on(auth, PROVIDER_RDNS); + return true; +} + +static void +rdns_cancel(struct auth_client *auth) +{ + struct user_query *query = auth->data[PROVIDER_RDNS]; + + if(query != NULL) + client_fail(auth, REPORT_FAIL); +} + +static void +add_conf_dns_timeout(const char *key, int parc, const char **parv) +{ + int timeout = atoi(parv[0]); + + if(timeout < 0) + { + warn_opers(L_CRIT, "BUG: DNS timeout < 0 (value: %d)", timeout); + return; + } + + rdns_timeout = timeout; +} + +struct auth_opts_handler rdns_options[] = +{ + { "dns_timeout", 1, add_conf_dns_timeout }, + { NULL, 0, NULL }, +}; + struct auth_provider rdns_provider = { .id = PROVIDER_RDNS, - .init = client_dns_init, - .destroy = client_dns_destroy, - .start = client_dns_start, - .cancel = client_dns_cancel, + .init = rdns_init, + .destroy = rdns_destroy, + .start = rdns_start, + .cancel = rdns_cancel, .completed = NULL, + .opt_handlers = rdns_options, }; diff --git a/authd/res.c b/authd/res.c index 4deafb5f..d68e402a 100644 --- a/authd/res.c +++ b/authd/res.c @@ -98,7 +98,6 @@ static int check_question(struct reslist *request, HEADER * header, char *buf, c static int proc_answer(struct reslist *request, HEADER * header, char *, char *); static struct reslist *find_id(int id); static struct DNSReply *make_dnsreply(struct reslist *request); -static int generate_random_port(void); static uint16_t generate_random_id(void); #ifdef RES_MIN @@ -107,55 +106,6 @@ static uint16_t generate_random_id(void); #define RES_MIN(a, b) ((a) < (b) ? (a) : (b)) -static rb_fde_t * -random_socket(int family) -{ - rb_fde_t *F; - int nport; - int i; - rb_socklen_t len; - struct rb_sockaddr_storage sockaddr; - F = rb_socket(family, SOCK_DGRAM, 0, "UDP resolver socket"); - if(F == NULL) - return NULL; - - memset(&sockaddr, 0, sizeof(sockaddr)); - - SET_SS_FAMILY(&sockaddr, family); - -#ifdef RB_IPV6 - if(family == AF_INET6) - { - struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&sockaddr; - memcpy(&in6->sin6_addr, &ipv6_addr, sizeof(struct in6_addr)); - len = (rb_socklen_t) sizeof(struct sockaddr_in6); - } - else -#endif - { - struct sockaddr_in *in = (struct sockaddr_in *)&sockaddr; - in->sin_addr.s_addr = ipv4_addr.s_addr; - len = (rb_socklen_t) sizeof(struct sockaddr_in); - } - - for(i = 0; i < 10; i++) - { - nport = htons(generate_random_port()); - - if(family == AF_INET) - ((struct sockaddr_in *)&sockaddr)->sin_port = nport; -#ifdef RB_IPV6 - else - ((struct sockaddr_in6 *)&sockaddr)->sin6_port = nport; - -#endif - if(bind(rb_get_fd(F), (struct sockaddr *)&sockaddr, len) == 0) - return F; - } - rb_close(F); - return NULL; -} - /* * int * res_ourserver(inp) @@ -167,7 +117,8 @@ random_socket(int family) * revised for ircd, cryogen(stu) may03 * slightly modified for charybdis, mr_flea oct12 */ -static int res_ourserver(const struct rb_sockaddr_storage *inp) +static int +res_ourserver(const struct rb_sockaddr_storage *inp) { #ifdef RB_IPV6 const struct sockaddr_in6 *v6; @@ -177,49 +128,43 @@ static int res_ourserver(const struct rb_sockaddr_storage *inp) const struct sockaddr_in *v4in = (const struct sockaddr_in *)inp; int ns; - for (ns = 0; ns < irc_nscount; ns++) + for(ns = 0; ns < irc_nscount; ns++) { const struct rb_sockaddr_storage *srv = &irc_nsaddr_list[ns]; - - if (srv->ss_family != inp->ss_family) - continue; - #ifdef RB_IPV6 v6 = (const struct sockaddr_in6 *)srv; #endif v4 = (const struct sockaddr_in *)srv; /* could probably just memcmp(srv, inp, srv.ss_len) here - * but we'll err on the side of caution - stu + * but we'll air on the side of caution - stu */ - switch (srv->ss_family) + switch (GET_SS_FAMILY(srv)) { #ifdef RB_IPV6 - case AF_INET6: - if (v6->sin6_port == v6in->sin6_port) - if ((memcmp(&v6->sin6_addr.s6_addr, &v6in->sin6_addr.s6_addr, - sizeof(struct in6_addr)) == 0) || - (memcmp(&v6->sin6_addr.s6_addr, &in6addr_any, - sizeof(struct in6_addr)) == 0)) - { - return ns; - } - break; + case AF_INET6: + if(GET_SS_FAMILY(srv) == GET_SS_FAMILY(inp)) + if(v6->sin6_port == v6in->sin6_port) + if((memcmp(&v6->sin6_addr.s6_addr, &v6in->sin6_addr.s6_addr, + sizeof(struct in6_addr)) == 0) || + (memcmp(&v6->sin6_addr.s6_addr, &in6addr_any, + sizeof(struct in6_addr)) == 0)) + return 1; + break; #endif - case AF_INET: - if (v4->sin_port == v4in->sin_port) - if ((v4->sin_addr.s_addr == INADDR_ANY) - || (v4->sin_addr.s_addr == v4in->sin_addr.s_addr)) - { - return ns; - } - break; - default: - break; + case AF_INET: + if(GET_SS_FAMILY(srv) == GET_SS_FAMILY(inp)) + if(v4->sin_port == v4in->sin_port) + if((v4->sin_addr.s_addr == INADDR_ANY) + || (v4->sin_addr.s_addr == v4in->sin_addr.s_addr)) + return 1; + break; + default: + break; } } - return -1; + return 0; } /* @@ -280,7 +225,7 @@ static void start_resolver(void) if (res_fd == NULL) { - if ((res_fd = rb_socket(irc_nsaddr_list[0].ss_family, SOCK_DGRAM, 0, + if ((res_fd = rb_socket(GET_SS_FAMILY(&irc_nsaddr_list[0]), SOCK_DGRAM, 0, "UDP resolver socket")) == NULL) return; @@ -472,20 +417,6 @@ generate_random_id(void) return id; } -static int -generate_random_port(void) -{ - uint16_t port; - - while(1) - { - rb_get_random(&port, sizeof(port)); - if(port > 1024) - break; - } - return (int)port; -} - /* * gethost_byname_type - get host address from name, adding domain if needed */ @@ -534,6 +465,52 @@ static void do_query_name(struct DNSQuery *query, const char *name, struct resli query_name(request); } +/* Build an rDNS style query - if suffix is NULL, use the appropriate .arpa zone */ +void build_rdns(char *buf, size_t size, const struct rb_sockaddr_storage *addr, const char *suffix) +{ + const unsigned char *cp; + + if (GET_SS_FAMILY(addr) == AF_INET) + { + const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr; + cp = (const unsigned char *)&v4->sin_addr.s_addr; + + (void) snprintf(buf, size, "%u.%u.%u.%u.%s", + (unsigned int)(cp[3]), + (unsigned int)(cp[2]), + (unsigned int)(cp[1]), + (unsigned int)(cp[0]), + suffix == NULL ? "in-addr.arpa" : suffix); + } +#ifdef RB_IPV6 + else if (GET_SS_FAMILY(addr) == AF_INET6) + { + const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr; + cp = (const unsigned char *)&v6->sin6_addr.s6_addr; + + (void) snprintf(buf, size, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%s", + (unsigned int)(cp[15] & 0xf), (unsigned int)(cp[15] >> 4), + (unsigned int)(cp[14] & 0xf), (unsigned int)(cp[14] >> 4), + (unsigned int)(cp[13] & 0xf), (unsigned int)(cp[13] >> 4), + (unsigned int)(cp[12] & 0xf), (unsigned int)(cp[12] >> 4), + (unsigned int)(cp[11] & 0xf), (unsigned int)(cp[11] >> 4), + (unsigned int)(cp[10] & 0xf), (unsigned int)(cp[10] >> 4), + (unsigned int)(cp[9] & 0xf), (unsigned int)(cp[9] >> 4), + (unsigned int)(cp[8] & 0xf), (unsigned int)(cp[8] >> 4), + (unsigned int)(cp[7] & 0xf), (unsigned int)(cp[7] >> 4), + (unsigned int)(cp[6] & 0xf), (unsigned int)(cp[6] >> 4), + (unsigned int)(cp[5] & 0xf), (unsigned int)(cp[5] >> 4), + (unsigned int)(cp[4] & 0xf), (unsigned int)(cp[4] >> 4), + (unsigned int)(cp[3] & 0xf), (unsigned int)(cp[3] >> 4), + (unsigned int)(cp[2] & 0xf), (unsigned int)(cp[2] >> 4), + (unsigned int)(cp[1] & 0xf), (unsigned int)(cp[1] >> 4), + (unsigned int)(cp[0] & 0xf), (unsigned int)(cp[0] >> 4), + suffix == NULL ? "ip6.arpa" : suffix); + } +#endif +} + /* * do_query_number - Use this to do reverse IP# lookups. */ @@ -549,40 +526,7 @@ static void do_query_number(struct DNSQuery *query, const struct rb_sockaddr_sto request->name = (char *)rb_malloc(IRCD_RES_HOSTLEN + 1); } - if (addr->ss_family == AF_INET) - { - const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr; - cp = (const unsigned char *)&v4->sin_addr.s_addr; - - sprintf(request->queryname, "%u.%u.%u.%u.in-addr.arpa", (unsigned int)(cp[3]), - (unsigned int)(cp[2]), (unsigned int)(cp[1]), (unsigned int)(cp[0])); - } -#ifdef RB_IPV6 - else if (addr->ss_family == AF_INET6) - { - const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr; - cp = (const unsigned char *)&v6->sin6_addr.s6_addr; - - (void)sprintf(request->queryname, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." - "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa", - (unsigned int)(cp[15] & 0xf), (unsigned int)(cp[15] >> 4), - (unsigned int)(cp[14] & 0xf), (unsigned int)(cp[14] >> 4), - (unsigned int)(cp[13] & 0xf), (unsigned int)(cp[13] >> 4), - (unsigned int)(cp[12] & 0xf), (unsigned int)(cp[12] >> 4), - (unsigned int)(cp[11] & 0xf), (unsigned int)(cp[11] >> 4), - (unsigned int)(cp[10] & 0xf), (unsigned int)(cp[10] >> 4), - (unsigned int)(cp[9] & 0xf), (unsigned int)(cp[9] >> 4), - (unsigned int)(cp[8] & 0xf), (unsigned int)(cp[8] >> 4), - (unsigned int)(cp[7] & 0xf), (unsigned int)(cp[7] >> 4), - (unsigned int)(cp[6] & 0xf), (unsigned int)(cp[6] >> 4), - (unsigned int)(cp[5] & 0xf), (unsigned int)(cp[5] >> 4), - (unsigned int)(cp[4] & 0xf), (unsigned int)(cp[4] >> 4), - (unsigned int)(cp[3] & 0xf), (unsigned int)(cp[3] >> 4), - (unsigned int)(cp[2] & 0xf), (unsigned int)(cp[2] >> 4), - (unsigned int)(cp[1] & 0xf), (unsigned int)(cp[1] >> 4), - (unsigned int)(cp[0] & 0xf), (unsigned int)(cp[0] >> 4)); - } -#endif + build_rdns(request->queryname, IRCD_RES_HOSTLEN + 1, addr, NULL); request->type = T_PTR; query_name(request); @@ -918,7 +862,7 @@ static int res_read_single_reply(rb_fde_t *F, void *data) * ip#. */ #ifdef RB_IPV6 - if (request->addr.ss_family == AF_INET6) + if (GET_SS_FAMILY(&request->addr) == AF_INET6) gethost_byname_type_fqdn(request->name, request->query, T_AAAA); else #endif diff --git a/authd/res.h b/authd/res.h index 5a177257..1fabe0b2 100644 --- a/authd/res.h +++ b/authd/res.h @@ -32,5 +32,6 @@ extern void init_resolver(void); extern void restart_resolver(void); extern void gethost_byname_type(const char *, struct DNSQuery *, int); extern void gethost_byaddr(const struct rb_sockaddr_storage *, struct DNSQuery *); +extern void build_rdns(char *, size_t, const struct rb_sockaddr_storage *, const char *); #endif diff --git a/authd/reslib.c b/authd/reslib.c index 6f0180db..b3b43726 100644 --- a/authd/reslib.c +++ b/authd/reslib.c @@ -76,9 +76,27 @@ * - Dianora */ +#include + +#ifndef _WIN32 + +#include + +typedef struct addrinfo rb_addrinfo; + +#else +#include "getaddrinfo.h" +#include "getnameinfo.h" +#define getaddrinfo rb_getaddrinfo +#define getnameinfo rb_getnameinfo +#define freeaddrinfo rb_freeaddrinfo + +extern const char * get_windows_nameservers(void); +typedef struct rb_addrinfo rb_addrinfo; +#endif + #include "stdinc.h" #include "ircd_defs.h" -#include "common.h" #include "ircd.h" #include "res.h" #include "reslib.h" @@ -112,7 +130,12 @@ static const char digitvalue[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/ }; +#ifndef _WIN32 static int parse_resvconf(void); +#else +static void parse_windows_resolvers(void); +#endif + static void add_nameserver(const char *); static const char digits[] = "0123456789"; @@ -139,12 +162,31 @@ int irc_res_init(void) { irc_nscount = 0; +#ifndef _WIN32 parse_resvconf(); +#else + parse_windows_resolvers(); +#endif if (irc_nscount == 0) add_nameserver("127.0.0.1"); return 0; } +#ifdef _WIN32 +static void +parse_windows_resolvers(void) +{ + const char *ns = get_windows_nameservers(); + char *server; + char *p; + char *buf = rb_strdup(ns); + for(server = rb_strtok_r(buf, " ", &p); server != NULL;server = rb_strtok_r(NULL, " ", &p)) + { + add_nameserver(server); + } + rb_free(buf); +} +#else /* parse_resvconf() * * inputs - NONE @@ -210,6 +252,7 @@ parse_resvconf(void) fclose(file); return 0; } +#endif /* add_nameserver() * @@ -221,7 +264,7 @@ parse_resvconf(void) static void add_nameserver(const char *arg) { - struct addrinfo hints, *res; + rb_addrinfo hints, *res; /* Done max number of nameservers? */ if (irc_nscount >= IRCD_MAXNS) diff --git a/authd/reslib.h b/authd/reslib.h index 38f7b8f3..e8917130 100644 --- a/authd/reslib.h +++ b/authd/reslib.h @@ -78,24 +78,24 @@ typedef struct */ #define IRC_NS_GET16(s, cp) { \ const unsigned char *t_cp = (const unsigned char *)(cp); \ - (s) = ((u_int16_t)t_cp[0] << 8) \ - | ((u_int16_t)t_cp[1]) \ + (s) = ((uint16_t)t_cp[0] << 8) \ + | ((uint16_t)t_cp[1]) \ ; \ (cp) += NS_INT16SZ; \ } #define IRC_NS_GET32(l, cp) { \ const unsigned char *t_cp = (const unsigned char *)(cp); \ - (l) = ((u_int32_t)t_cp[0] << 24) \ - | ((u_int32_t)t_cp[1] << 16) \ - | ((u_int32_t)t_cp[2] << 8) \ - | ((u_int32_t)t_cp[3]) \ + (l) = ((uint32_t)t_cp[0] << 24) \ + | ((uint32_t)t_cp[1] << 16) \ + | ((uint32_t)t_cp[2] << 8) \ + | ((uint32_t)t_cp[3]) \ ; \ (cp) += NS_INT32SZ; \ } #define IRC_NS_PUT16(s, cp) { \ - u_int16_t t_s = (u_int16_t)(s); \ + uint16_t t_s = (uint16_t)(s); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ @@ -103,7 +103,7 @@ typedef struct } #define IRC_NS_PUT32(l, cp) { \ - u_int32_t t_l = (u_int32_t)(l); \ + uint32_t t_l = (uint32_t)(l); \ unsigned char *t_cp = (unsigned char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ diff --git a/authd/reslist.c b/authd/reslist.c new file mode 100644 index 00000000..7fb97f5e --- /dev/null +++ b/authd/reslist.c @@ -0,0 +1,276 @@ +/* + * reslist.c - get nameservers from windows * + * + * ircd-ratbox related changes are as follows + * + * Copyright (C) 2008 Aaron Sethman + * Copyright (C) 2008-2012 ircd-ratbox development team + * + * pretty much all of this was yanked from c-ares ares_init.c here is the original + * header from there -- + * + * Id: ares_init.c,v 1.72 2008-05-15 00:00:19 yangtse Exp $ + * Copyright 1998 by the Massachusetts Institute of Technology. + * Copyright (C) 2007-2008 by Daniel Stenberg + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * + */ + +#ifdef _WIN32 +#include + +#include +#include + +const char *get_windows_nameservers(void); + + +#define IS_NT() ((int)GetVersion() > 0) +#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP" +#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters" +#define NAMESERVER "NameServer" +#define DHCPNAMESERVER "DhcpNameServer" +#define DATABASEPATH "DatabasePath" +#define WIN_PATH_HOSTS "\\hosts" + +static int +get_iphlpapi_dns_info(char *ret_buf, size_t ret_size) +{ + FIXED_INFO *fi = alloca(sizeof(*fi)); + DWORD size = sizeof(*fi); + typedef DWORD(WINAPI * get_net_param_func) (FIXED_INFO *, DWORD *); + get_net_param_func xxGetNetworkParams; /* available only on Win-98/2000+ */ + HMODULE handle; + IP_ADDR_STRING *ipAddr; + int i, count = 0; + int debug = 0; + size_t ip_size = sizeof("255.255.255.255,") - 1; + size_t left = ret_size; + char *ret = ret_buf; + HRESULT res; + + if(!fi) + return (0); + + handle = LoadLibrary("iphlpapi.dll"); + if(!handle) + return (0); + + xxGetNetworkParams = (get_net_param_func) GetProcAddress(handle, "GetNetworkParams"); + if(!xxGetNetworkParams) + goto quit; + + res = (*xxGetNetworkParams) (fi, &size); + if((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) + goto quit; + + fi = alloca(size); + if(!fi || (*xxGetNetworkParams) (fi, &size) != ERROR_SUCCESS) + goto quit; + + if(debug) + { + printf("Host Name: %s\n", fi->HostName); + printf("Domain Name: %s\n", fi->DomainName); + printf("DNS Servers:\n" " %s (primary)\n", fi->DnsServerList.IpAddress.String); + } + if(strlen(fi->DnsServerList.IpAddress.String) > 0 && + inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE && left > ip_size) + { + ret += sprintf(ret, "%s,", fi->DnsServerList.IpAddress.String); + left -= ret - ret_buf; + count++; + } + + for(i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ip_size; + ipAddr = ipAddr->Next, i++) + { + if(inet_addr(ipAddr->IpAddress.String) != INADDR_NONE) + { + ret += sprintf(ret, "%s,", ipAddr->IpAddress.String); + left -= ret - ret_buf; + count++; + } + if(debug) + printf(" %s (secondary %d)\n", ipAddr->IpAddress.String, i + 1); + } + + quit: + if(handle) + FreeLibrary(handle); + + if(debug && left <= ip_size) + printf("Too many nameservers. Truncating to %d addressess", count); + if(ret > ret_buf) + ret[-1] = '\0'; + return (count); +} + +/* + * Warning: returns a dynamically allocated buffer, the user MUST + * use free() / rb_free() if the function returns 1 + */ +static int +get_res_nt(HKEY hKey, const char *subkey, char **obuf) +{ + /* Test for the size we need */ + DWORD size = 0; + int result; + + result = RegQueryValueEx(hKey, subkey, 0, NULL, NULL, &size); + if((result != ERROR_SUCCESS && result != ERROR_MORE_DATA) || !size) + return 0; + *obuf = rb_malloc(size + 1); + if(!*obuf) + return 0; + + if(RegQueryValueEx(hKey, subkey, 0, NULL, (LPBYTE) * obuf, &size) != ERROR_SUCCESS) + { + rb_free(*obuf); + return 0; + } + if(size == 1) + { + rb_free(*obuf); + return 0; + } + return 1; +} + +static int +get_res_interfaces_nt(HKEY hKey, const char *subkey, char **obuf) +{ + char enumbuf[39]; /* GUIDs are 38 chars + 1 for NULL */ + DWORD enum_size = 39; + int idx = 0; + HKEY hVal; + + while(RegEnumKeyEx(hKey, idx++, enumbuf, &enum_size, 0, + NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS) + { + int rc; + + enum_size = 39; + if(RegOpenKeyEx(hKey, enumbuf, 0, KEY_QUERY_VALUE, &hVal) != ERROR_SUCCESS) + continue; + rc = get_res_nt(hVal, subkey, obuf); + RegCloseKey(hVal); + if(rc) + return 1; + } + return 0; +} + +const char * +get_windows_nameservers(void) +{ + /* + NameServer info via IPHLPAPI (IP helper API): + GetNetworkParams() should be the trusted source for this. + Available in Win-98/2000 and later. If that fail, fall-back to + registry information. + + NameServer Registry: + + On Windows 9X, the DNS server can be found in: + HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP\NameServer + + On Windows NT/2000/XP/2003: + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NameServer + or + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DhcpNameServer + or + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\ + NameServer + or + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\ + DhcpNameServer + */ + static char namelist[512]; + HKEY mykey; + HKEY subkey; + DWORD data_type; + DWORD bytes; + DWORD result; + char *line = NULL; + memset(&namelist, 0, sizeof(namelist)); + if(get_iphlpapi_dns_info(namelist, sizeof(namelist)) > 0) + { + return namelist; + } + + if(IS_NT()) + { + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, + KEY_READ, &mykey) == ERROR_SUCCESS) + { + RegOpenKeyEx(mykey, "Interfaces", 0, + KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &subkey); + if(get_res_nt(mykey, NAMESERVER, &line)) + { + rb_strlcpy(namelist, line, sizeof(namelist)); + return namelist; + } + else if(get_res_nt(mykey, DHCPNAMESERVER, &line)) + { + rb_strlcpy(namelist, line, sizeof(namelist)); + rb_free(line); + } + /* Try the interfaces */ + else if(get_res_interfaces_nt(subkey, NAMESERVER, &line)) + { + rb_strlcpy(namelist, line, sizeof(namelist)); + rb_free(line); + } + else if(get_res_interfaces_nt(subkey, DHCPNAMESERVER, &line)) + { + rb_strlcpy(namelist, line, sizeof(namelist)); + rb_free(line); + } + RegCloseKey(subkey); + RegCloseKey(mykey); + } + } + else + { + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, + KEY_READ, &mykey) == ERROR_SUCCESS) + { + if((result = RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type, + NULL, &bytes)) == ERROR_SUCCESS || + result == ERROR_MORE_DATA) + { + if(bytes) + { + line = (char *)rb_malloc(bytes + 1); + if(RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type, + (unsigned char *)line, &bytes) == + ERROR_SUCCESS) + { + rb_strlcpy(namelist, line, sizeof(namelist)); + } + free(line); + } + } + } + RegCloseKey(mykey); + } + if(strlen(namelist) > 0) + return namelist; + return NULL; +} + + +#endif diff --git a/autogen.sh b/autogen.sh index 175e0ff5..fd14128a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -81,7 +81,7 @@ parse_options "$@" echo "Building librb autotools files." cd "$TOP_DIR"/librb -bash autogen.sh +sh autogen.sh echo "Building main autotools files." diff --git a/bandb/bandb.c b/bandb/bandb.c index 1936b416..71a425d7 100644 --- a/bandb/bandb.c +++ b/bandb/bandb.c @@ -31,7 +31,7 @@ #include #include #include "rsdb.h" -#include "common.h" +#include "ircd_defs.h" #define MAXPARA 10 @@ -255,7 +255,7 @@ dummy_handler(int sig) static void setup_signals(void) { -#ifndef WINDOWS +#ifndef _WIN32 struct sigaction act; act.sa_flags = 0; diff --git a/bandb/bantool.c b/bandb/bantool.c index 4cd53bd7..e89fa5b9 100644 --- a/bandb/bantool.c +++ b/bandb/bantool.c @@ -40,7 +40,6 @@ #include #include "stdinc.h" -#include "common.h" #include "rsdb.h" #define EmptyString(x) ((x == NULL) || (*(x) == '\0')) @@ -93,16 +92,16 @@ struct counter /* flags set by command line options */ struct flags { - int none; - int export; - int import; - int verify; - int vacuum; - int pretend; - int verbose; - int wipe; - int dupes_ok; -} flag = {YES, NO, NO, NO, NO, NO, NO, NO, NO}; + bool none; + bool export; + bool import; + bool verify; + bool vacuum; + bool pretend; + bool verbose; + bool wipe; + bool dupes_ok; +} flag = {true, false, false, false, false, false, false, false, false}; /* *INDENT-ON* */ static int table_has_rows(const char *table); @@ -145,32 +144,32 @@ main(int argc, char *argv[]) print_help(EXIT_SUCCESS); break; case 'i': - flag.none = NO; - flag.import = YES; + flag.none = false; + flag.import = true; break; case 'e': - flag.none = NO; - flag.export = YES; + flag.none = false; + flag.export = true; break; case 'u': - flag.none = NO; - flag.verify = YES; + flag.none = false; + flag.verify = true; break; case 's': - flag.none = NO; - flag.vacuum = YES; + flag.none = false; + flag.vacuum = true; break; case 'p': - flag.pretend = YES; + flag.pretend = true; break; case 'v': - flag.verbose = YES; + flag.verbose = true; break; case 'w': - flag.wipe = YES; + flag.wipe = true; break; case 'd': - flag.dupes_ok = YES; + flag.dupes_ok = true; break; default: /* '?' */ print_help(EXIT_FAILURE); @@ -200,7 +199,7 @@ main(int argc, char *argv[]) fprintf(stdout, "* charybdis bantool v.%s\n", BT_VERSION); - if(flag.pretend == NO) + if(flag.pretend == false) { if(rsdb_init(db_error_cb) == -1) { @@ -214,7 +213,7 @@ main(int argc, char *argv[]) if(flag.import && flag.wipe) { - flag.dupes_ok = YES; /* dont check for dupes if we are wiping the db clean */ + flag.dupes_ok = true; /* dont check for dupes if we are wiping the db clean */ for(i = 0; i < 3; i++) fprintf(stdout, "* WARNING: YOU ARE ABOUT TO WIPE YOUR DATABASE!\n"); @@ -226,7 +225,7 @@ main(int argc, char *argv[]) wipe_schema(); } } - if(flag.verbose && flag.dupes_ok == YES) + if(flag.verbose && flag.dupes_ok == true) fprintf(stdout, "* Allowing duplicate bans...\n"); /* checking for our files to import or export */ @@ -235,7 +234,7 @@ main(int argc, char *argv[]) snprintf(conf, sizeof(conf), "%s/%s.conf%s", etc, bandb_table[i], bandb_suffix[i]); - if(flag.import && flag.pretend == NO) + if(flag.import && flag.pretend == false) rsdb_transaction(RSDB_TRANS_START); if(flag.import) @@ -244,7 +243,7 @@ main(int argc, char *argv[]) if(flag.export) export_config(conf, i); - if(flag.import && flag.pretend == NO) + if(flag.import && flag.pretend == false) rsdb_transaction(RSDB_TRANS_END); } @@ -497,9 +496,9 @@ import_config(const char *conf, int id) else snprintf(newreason, sizeof(newreason), "%s", f_reason); - if(flag.pretend == NO) + if(flag.pretend == false) { - if(flag.dupes_ok == NO) + if(flag.dupes_ok == false) drop_dupes(f_mask1, f_mask2, bandb_table[id]); rsdb_exec(NULL, diff --git a/bandb/sqlite3.c b/bandb/sqlite3.c index 60cbc77f..8716889c 100644 --- a/bandb/sqlite3.c +++ b/bandb/sqlite3.c @@ -25168,7 +25168,7 @@ winFullPathname(sqlite3_vfs * pVfs, /* Pointer to vfs object */ { #if defined(__CYGWIN__) - cygwin_conv_to_full_win32_path(zRelative, zFull); + cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull); return SQLITE_OK; #endif diff --git a/configure.ac b/configure.ac index e17ef34f..956ad882 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ fi AC_PREFIX_DEFAULT($HOME/ircd) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADER(include/setup.h) + AC_CONFIG_SUBDIRS([librb]) AC_CONFIG_AUX_DIR([libltdl/config]) @@ -33,6 +34,24 @@ LTDL_INIT build_ltdl=$with_included_ltdl AM_CONDITIONAL([BUILD_LTDL], [test x"$build_ltdl" = x"yes"]) +case "$host_os" in +*cygwin*) + AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system]) + AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) + ;; +*mingw* | *msys*) + AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) + AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) + AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])]) + LIBS="$LIBS -lws2_32 -liphlpapi" + is_mingw="yes" + ;; +*) + ;; +esac + +AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"]) + if test "$ac_cv_c_compiler_gnu" = yes; then IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall" fi @@ -102,7 +121,8 @@ AS_IF([test "x$enable_fhs_paths" = "xyes"], pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}' rundir=${rundir-'${prefix}/run'} pkgrundir='${rundir}/${PACKAGE_TARNAME}' - pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'], + pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}' + AC_DEFINE([ENABLE_FHS_PATHS], [1], [Uncomment if FHS pathnames are enabled])], [libexecdir='${bindir}' pkglibexecdir='${libexecdir}' rundir='${sysconfdir}' @@ -141,19 +161,13 @@ AC_CHECK_SIZEOF(long long) dnl Networking Functions dnl ==================== -AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])]) +AC_SEARCH_LIBS(socket, [socket ws2_32], , [AC_MSG_ERROR([You have no socket()! Aborting.])]) dnl SunOS/Solaris required libnsl for inet_ntoa() if test x"$SUN" = xyes; then AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])]) fi -AC_CHECK_TYPE(socklen_t, , -[AC_DEFINE([socklen_t], [unsigned int], -[If we don't have a real socklen_t, unsigned int is good enough.])], -[#include -#include ]) - AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no]) @@ -175,34 +189,8 @@ dnl Check for stdarg.h - if we can't find it, halt configure AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])]) AC_CHECK_FUNCS([strlcat strlcpy]) -AC_CHECK_TYPE([u_int32_t], [], -[ - AC_CHECK_TYPE([uint32_t], - [ - AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.]) - ], - [ - AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int]) - AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.]) - ]) -]) - -AC_CHECK_TYPE([u_int16_t], [], -[ - AC_CHECK_TYPE([uint16_t], - [ - AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute]) - ], - [ - AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int]) - AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.]) - ]) -]) - -AC_CHECK_TYPE([in_port_t], [], -[AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])], -[[#include -#include ]]) +AC_TYPE_INT16_T +AC_TYPE_INT32_T AC_CHECK_TYPE([sa_family_t], [], [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])], @@ -497,6 +485,18 @@ if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.]) fi +dnl ********************************************************************** +dnl Enable oper chghost +dnl ********************************************************************** + +AC_ARG_ENABLE(oper-chghost, +AC_HELP_STRING([--enable-oper-chghost],[Enable opers to use the CHGHOST command]), +[operchghost=$enableval],[operchghost=no]) + +if test "$operchghost" = yes; then + AC_DEFINE(ENABLE_OPER_CHGHOST, 1, [Define this to enable opers to use the CHGHOST command.]) +fi + dnl Debug-related options dnl ===================== @@ -607,7 +607,7 @@ CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual) CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings) CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration) CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes) -CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis) +CHARYBDIS_C_GCC_TRY_FLAGS([-Wparentheses], charybdis_cv_c_gcc_parentheses) CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w) CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra) CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow) @@ -656,6 +656,7 @@ AC_CONFIG_FILES( \ authd/Makefile \ bandb/Makefile \ ssld/Makefile \ + wsockd/Makefile \ extensions/Makefile \ ircd/Makefile \ modules/Makefile \ diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index 49951a5e..d7525a7a 100644 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -8,33 +8,33 @@ */ /* Extensions */ -#loadmodule "extensions/chm_operonly_compat.la"; -#loadmodule "extensions/chm_quietunreg_compat.la"; -#loadmodule "extensions/chm_sslonly_compat.la"; -#loadmodule "extensions/chm_operpeace.la"; -#loadmodule "extensions/createauthonly.la"; -#loadmodule "extensions/extb_account.la"; -#loadmodule "extensions/extb_canjoin.la"; -#loadmodule "extensions/extb_channel.la"; -#loadmodule "extensions/extb_combi.la"; -#loadmodule "extensions/extb_extgecos.la"; -#loadmodule "extensions/extb_hostmask.la"; -#loadmodule "extensions/extb_oper.la"; -#loadmodule "extensions/extb_realname.la"; -#loadmodule "extensions/extb_server.la"; -#loadmodule "extensions/extb_ssl.la"; -#loadmodule "extensions/hurt.la"; -#loadmodule "extensions/m_extendchans.la"; -#loadmodule "extensions/m_findforwards.la"; -#loadmodule "extensions/m_identify.la"; -#loadmodule "extensions/no_oper_invis.la"; -#loadmodule "extensions/sno_farconnect.la"; -#loadmodule "extensions/sno_globalkline.la"; -#loadmodule "extensions/sno_globalnickchange.la"; -#loadmodule "extensions/sno_globaloper.la"; -#loadmodule "extensions/sno_whois.la"; -#loadmodule "extensions/override.la"; -#loadmodule "extensions/no_kill_services.la"; +#loadmodule "extensions/chm_operonly_compat"; +#loadmodule "extensions/chm_quietunreg_compat"; +#loadmodule "extensions/chm_sslonly_compat"; +#loadmodule "extensions/chm_operpeace"; +#loadmodule "extensions/createauthonly"; +#loadmodule "extensions/extb_account"; +#loadmodule "extensions/extb_canjoin"; +#loadmodule "extensions/extb_channel"; +#loadmodule "extensions/extb_combi"; +#loadmodule "extensions/extb_extgecos"; +#loadmodule "extensions/extb_hostmask"; +#loadmodule "extensions/extb_oper"; +#loadmodule "extensions/extb_realname"; +#loadmodule "extensions/extb_server"; +#loadmodule "extensions/extb_ssl"; +#loadmodule "extensions/hurt"; +#loadmodule "extensions/m_extendchans"; +#loadmodule "extensions/m_findforwards"; +#loadmodule "extensions/m_identify"; +#loadmodule "extensions/no_oper_invis"; +#loadmodule "extensions/sno_farconnect"; +#loadmodule "extensions/sno_globalkline"; +#loadmodule "extensions/sno_globalnickchange"; +#loadmodule "extensions/sno_globaloper"; +#loadmodule "extensions/sno_whois"; +#loadmodule "extensions/override"; +#loadmodule "extensions/no_kill_services"; /* * IP cloaking extensions: use ip_cloaking_4.0 @@ -43,15 +43,14 @@ * releases. */ -#loadmodule "extensions/ip_cloaking_4.0.la"; -#loadmodule "extensions/ip_cloaking.la"; +#loadmodule "extensions/ip_cloaking_4.0"; +#loadmodule "extensions/ip_cloaking"; serverinfo { name = "hades.arpa"; sid = "42X"; description = "charybdis test server"; network_name = "StaticBox"; - hub = yes; /* On multi-homed hosts you may need the following. These define * the addresses we connect from to other servers. */ diff --git a/doc/reference.conf b/doc/reference.conf index 19e337c5..5c9bd0b5 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -43,73 +43,73 @@ * Charybdis contains several extensions that are not enabled by default. * To use them, uncomment the lines below. * - * Channel mode +-A (admin only) -- chm_adminonly.la - * Channel mode +-O (oper only) -- chm_operonly.la - * Channel mode +-S (ssl only) -- chm_sslonly.la - * Emulates channel mode +-O (oper only) (+-iI $o) -- chm_operonly_compat.la - * Emulates channel mode +-R (quiet unreg) (+-q $~a) -- chm_quietunreg_compat.la - * Emulates channel mode +-S (ssl only) (+-b $~z) -- chm_sslonly_compat.la - * Channel mode +-M (disallow KICK on IRC ops) -- chm_operpeace.la - * Restrict channel creation to logged in users -- createauthonly.la - * Account bans (+b $a[:mask]) -- extb_account.la - * Banned from another channel (+b $j:mask) -- extb_canjoin.la - * Other-channel bans (+b $c:mask) -- extb_channel.la - * Combination extbans -- extb_combi.la - * Extended ban (+b $x:mask) -- extb_extgecos.la - * Hostmask bans (for combination extbans) -- extb_hostmask.la - * Oper bans (+b $o) -- extb_oper.la - * Realname (gecos) bans (+b $r:mask) -- extb_realname.la - * Server bans (+b $s:mask) -- extb_server.la - * SSL bans (+b $z) -- extb_ssl.la - * Helpops system (umode +H) -- helpops.la - * HURT system -- hurt.la - * New host mangling (umode +x) -- ip_cloaking_4.0.la - * Old host mangling (umode +h) -- ip_cloaking.la - * Dynamically extend channel limits -- m_extendchans.la - * Find channel forwards -- m_findforwards.la - * /identify support -- m_identify.la - * Opers cannot be invisible (umode +i) -- no_oper_invis.la - * Far connection notices (snomask +F) -- sno_farconnect.la - * Remote k/d/x line active notices -- sno_globalkline.la - * Remote oper up notices -- sno_globaloper.la - * Global nick-change notices -- sno_globalnickchange.la - * /whois notifications (snomask +W) -- sno_whois.la - * Oper-override (modehacking only) -- override.la - * Stop services kills -- no_kill_services.la + * Channel mode +-A (admin only) -- chm_adminonly + * Channel mode +-O (oper only) -- chm_operonly + * Channel mode +-S (ssl only) -- chm_sslonly + * Emulates channel mode +-O (oper only) (+-iI $o) -- chm_operonly_compat + * Emulates channel mode +-R (quiet unreg) (+-q $~a) -- chm_quietunreg_compat + * Emulates channel mode +-S (ssl only) (+-b $~z) -- chm_sslonly_compat + * Channel mode +-M (disallow KICK on IRC ops) -- chm_operpeace + * Restrict channel creation to logged in users -- createauthonly + * Account bans (+b $a[:mask]) -- extb_account + * Banned from another channel (+b $j:mask) -- extb_canjoin + * Other-channel bans (+b $c:mask) -- extb_channel + * Combination extbans -- extb_combi + * Extended ban (+b $x:mask) -- extb_extgecos + * Hostmask bans (for combination extbans) -- extb_hostmask + * Oper bans (+b $o) -- extb_oper + * Realname (gecos) bans (+b $r:mask) -- extb_realname + * Server bans (+b $s:mask) -- extb_server + * SSL bans (+b $z) -- extb_ssl + * Helpops system (umode +H) -- helpops + * HURT system -- hurt + * New host mangling (umode +x) -- ip_cloaking_4.0 + * Old host mangling (umode +h) -- ip_cloaking + * Dynamically extend channel limits -- m_extendchans + * Find channel forwards -- m_findforwards + * /identify support -- m_identify + * Opers cannot be invisible (umode +i) -- no_oper_invis + * Far connection notices (snomask +F) -- sno_farconnect + * Remote k/d/x line active notices -- sno_globalkline + * Remote oper up notices -- sno_globaloper + * Global nick-change notices -- sno_globalnickchange + * /whois notifications (snomask +W) -- sno_whois + * Oper-override (modehacking only) -- override + * Stop services kills -- no_kill_services */ -#loadmodule "extensions/chm_adminonly.la"; -#loadmodule "extensions/chm_operonly.la"; -#loadmodule "extensions/chm_sslonly.la"; -#loadmodule "extensions/chm_operonly_compat.la"; -#loadmodule "extensions/chm_quietunreg_compat.la"; -#loadmodule "extensions/chm_sslonly_compat.la"; -#loadmodule "extensions/chm_operpeace.la"; -#loadmodule "extensions/createauthonly.la"; -#loadmodule "extensions/extb_account.la"; -#loadmodule "extensions/extb_canjoin.la"; -#loadmodule "extensions/extb_channel.la"; -#loadmodule "extensions/extb_combi.la"; -#loadmodule "extensions/extb_extgecos.la"; -#loadmodule "extensions/extb_hostmask.la"; -#loadmodule "extensions/extb_oper.la"; -#loadmodule "extensions/extb_realname.la"; -#loadmodule "extensions/extb_server.la"; -#loadmodule "extensions/extb_ssl.la"; -#loadmodule "extensions/helpops.la"; -#loadmodule "extensions/hurt.la"; -#loadmodule "extensions/ip_cloaking_4.0.la"; -#loadmodule "extensions/ip_cloaking.la"; -#loadmodule "extensions/m_extendchans.la"; -#loadmodule "extensions/m_findforwards.la"; -#loadmodule "extensions/m_identify.la"; -#loadmodule "extensions/no_oper_invis.la"; -#loadmodule "extensions/sno_farconnect.la"; -#loadmodule "extensions/sno_globalkline.la"; -#loadmodule "extensions/sno_globalnickchange.la"; -#loadmodule "extensions/sno_globaloper.la"; -#loadmodule "extensions/sno_whois.la"; -#loadmodule "extensions/override.la"; -#loadmodule "extensions/no_kill_services.la"; +#loadmodule "extensions/chm_adminonly"; +#loadmodule "extensions/chm_operonly"; +#loadmodule "extensions/chm_sslonly"; +#loadmodule "extensions/chm_operonly_compat"; +#loadmodule "extensions/chm_quietunreg_compat"; +#loadmodule "extensions/chm_sslonly_compat"; +#loadmodule "extensions/chm_operpeace"; +#loadmodule "extensions/createauthonly"; +#loadmodule "extensions/extb_account"; +#loadmodule "extensions/extb_canjoin"; +#loadmodule "extensions/extb_channel"; +#loadmodule "extensions/extb_combi"; +#loadmodule "extensions/extb_extgecos"; +#loadmodule "extensions/extb_hostmask"; +#loadmodule "extensions/extb_oper"; +#loadmodule "extensions/extb_realname"; +#loadmodule "extensions/extb_server"; +#loadmodule "extensions/extb_ssl"; +#loadmodule "extensions/helpops"; +#loadmodule "extensions/hurt"; +#loadmodule "extensions/ip_cloaking_4.0"; +#loadmodule "extensions/ip_cloaking"; +#loadmodule "extensions/m_extendchans"; +#loadmodule "extensions/m_findforwards"; +#loadmodule "extensions/m_identify"; +#loadmodule "extensions/no_oper_invis"; +#loadmodule "extensions/sno_farconnect"; +#loadmodule "extensions/sno_globalkline"; +#loadmodule "extensions/sno_globalnickchange"; +#loadmodule "extensions/sno_globaloper"; +#loadmodule "extensions/sno_whois"; +#loadmodule "extensions/override"; +#loadmodule "extensions/no_kill_services"; /* serverinfo {}: Contains information about the server. (OLD M:) */ serverinfo { @@ -134,11 +134,6 @@ serverinfo { */ network_name = "MyNet"; - /* hub: allow this server to act as a hub and have multiple servers - * connected to it. - */ - hub = no; - /* vhost: the IP to bind to when we connect outward to ipv4 servers. * This should be an ipv4 IP only. */ @@ -1349,5 +1344,5 @@ modules { path = "/usr/local/ircd/modules/autoload"; /* module: the name of a module to load on startup/rehash */ - #module = "some_module.la"; + #module = "some_module"; }; diff --git a/doc/server-version-info.txt b/doc/server-version-info.txt index 6019ee73..194c6b35 100644 --- a/doc/server-version-info.txt +++ b/doc/server-version-info.txt @@ -17,8 +17,6 @@ +----------------------------+ | 'e' | USE_EXCEPT | |------+---------------------| - | 'H' | HUB | - |------+---------------------| | 'I' | USE_INVEX | |------+---------------------| | 'K' | USE_KNOCK | @@ -29,8 +27,6 @@ |------+---------------------| | 'S' | OPERS_SEE_ALL_USERS | |------+---------------------| - | 'T' | IGNORE_BOGUS_TS | - |------+---------------------| | 'Z' | ZIPLINKS | |------+---------------------| | '6' | IPv6 | diff --git a/doc/technical/ts6-protocol.txt b/doc/technical/ts6-protocol.txt index bf52130d..36d63cd3 100644 --- a/doc/technical/ts6-protocol.txt +++ b/doc/technical/ts6-protocol.txt @@ -1198,8 +1198,6 @@ CAP CHALLENGE CHANTRACE CLOSE -CNOTICE -CPRIVMSG DIE GET HELP diff --git a/extensions/Makefile.am b/extensions/Makefile.am index f3a5ecbb..443c6557 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/librb/include $(LTDLINCL) AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared AM_LDFLAGS += -export-symbols-regex _mheader -LIBS += $(top_srcdir)/librb/src/librb.la $(top_srcdir)/ircd/libircd.la +LIBS += $(top_srcdir)/ircd/libircd.la extensiondir=@moduledir@/extensions diff --git a/extensions/extb_combi.c b/extensions/extb_combi.c index 6b06fdb9..c9f35642 100644 --- a/extensions/extb_combi.c +++ b/extensions/extb_combi.c @@ -52,7 +52,7 @@ static int _modinit(void); static void _moddeinit(void); static int eb_or(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); static int eb_and(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); -static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, int is_and); +static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, bool is_and); static int recursion_depth = 0; DECLARE_MODULE_AV2(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc); @@ -76,20 +76,20 @@ _moddeinit(void) static int eb_or(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type) { - return eb_combi(data, client_p, chptr, mode_type, FALSE); + return eb_combi(data, client_p, chptr, mode_type, false); } static int eb_and(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type) { - return eb_combi(data, client_p, chptr, mode_type, TRUE); + return eb_combi(data, client_p, chptr, mode_type, true); } static int eb_combi(const char *data, struct Client *client_p, - struct Channel *chptr, long mode_type, int is_and) + struct Channel *chptr, long mode_type, bool is_and) { const char *p, *banend; - int have_result = FALSE; + bool have_result = false; int allowed_nodes = 11; size_t datalen; @@ -143,12 +143,12 @@ static int eb_combi(const char *data, struct Client *client_p, recursion_depth++; while (--allowed_nodes) { - int invert = FALSE; + bool invert = false; char *child_data, child_data_buf[BANLEN]; ExtbanFunc f; if (*p == '~') { - invert = TRUE; + invert = true; p++; if (p == banend) { MOD_DEBUG("combo invalid: no data after ~"); @@ -164,7 +164,7 @@ static int eb_combi(const char *data, struct Client *client_p, if (*p == ':') { unsigned int parencount = 0; - int escaped = FALSE, done = FALSE; + bool escaped = false, done = false; char *o; p++; @@ -173,7 +173,7 @@ static int eb_combi(const char *data, struct Client *client_p, * we already have_result. */ o = child_data = child_data_buf; - while (TRUE) { + while (true) { if (p == banend) { if (parencount) { MOD_DEBUG("combo invalid: EOD while in parens"); @@ -186,11 +186,11 @@ static int eb_combi(const char *data, struct Client *client_p, if (*p != '(' && *p != ')' && *p != '\\' && *p != ',') *o++ = '\\'; *o++ = *p++; - escaped = FALSE; + escaped = false; } else { switch (*p) { case '\\': - escaped = TRUE; + escaped = true; break; case '(': parencount++; @@ -208,7 +208,7 @@ static int eb_combi(const char *data, struct Client *client_p, if (parencount) *o++ = *p; else - done = TRUE; + done = true; break; default: *o++ = *p; @@ -239,7 +239,7 @@ static int eb_combi(const char *data, struct Client *client_p, child_result = child_result == EXTBAN_MATCH; if (is_and ? !child_result : child_result) - have_result = TRUE; + have_result = true; } if (p == banend) diff --git a/extensions/extb_hostmask.c b/extensions/extb_hostmask.c index fcdee731..9bffe26b 100644 --- a/extensions/extb_hostmask.c +++ b/extensions/extb_hostmask.c @@ -56,7 +56,7 @@ eb_hostmask(const char *banstr, struct Client *client_p, struct Channel *chptr, #ifdef RB_IPV6 /* handle Teredo if necessary */ - if (client_p->localClient->ip.ss_family == AF_INET6 && ipv4_from_ipv6((const struct sockaddr_in6 *) &client_p->localClient->ip, &ip4)) + if (GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6 && ipv4_from_ipv6((const struct sockaddr_in6 *) &client_p->localClient->ip, &ip4)) { sprintf(src_ip4host, "%s!%s@", client_p->name, client_p->username); s4 = src_ip4host + strlen(src_ip4host); diff --git a/extensions/m_echotags.c b/extensions/m_echotags.c index 858f7f90..bbf78aed 100644 --- a/extensions/m_echotags.c +++ b/extensions/m_echotags.c @@ -20,18 +20,16 @@ DECLARE_MODULE_AV2(echotags, NULL, NULL, echotags_clist, NULL, NULL, NULL, NULL, static void m_echotags(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { - int i; - sendto_one_notice(source_p, ":*** You sent %zu tags.", msgbuf_p->n_tags); - for (i = 0; i < msgbuf_p->n_tags; i++) + for (size_t i = 0; i < msgbuf_p->n_tags; i++) { struct MsgTag *tag = &msgbuf_p->tags[i]; if (tag->value) - sendto_one_notice(source_p, ":*** %d: %s => %s", i, tag->key, tag->value); + sendto_one_notice(source_p, ":*** %zu: %s => %s", i, tag->key, tag->value); else - sendto_one_notice(source_p, ":*** %d: %s", i, tag->key); + sendto_one_notice(source_p, ":*** %zu: %s", i, tag->key); } } diff --git a/extensions/m_identify.c b/extensions/m_identify.c index 156e6a9d..aebcd361 100644 --- a/extensions/m_identify.c +++ b/extensions/m_identify.c @@ -31,7 +31,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "match.h" #include "numeric.h" diff --git a/extensions/m_sendbans.c b/extensions/m_sendbans.c index a3a1ea27..a6e15512 100644 --- a/extensions/m_sendbans.c +++ b/extensions/m_sendbans.c @@ -31,7 +31,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "match.h" #include "numeric.h" @@ -91,7 +90,7 @@ mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou { struct ConfItem *aconf; rb_dlink_node *ptr; - int i, count; + int count; const char *target, *mask2; struct Client *server_p; struct rb_radixtree_iteration_state state; diff --git a/extensions/m_webirc.c b/extensions/m_webirc.c index cf849efe..99f66b5b 100644 --- a/extensions/m_webirc.c +++ b/extensions/m_webirc.c @@ -92,7 +92,7 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc IsGotId(client_p) ? client_p->username : "webirc", IsGotId(client_p) ? client_p->username : "webirc", (struct sockaddr *) &client_p->localClient->ip, - client_p->localClient->ip.ss_family, NULL); + GET_SS_FAMILY(&client_p->localClient->ip), NULL); if (aconf == NULL || !(aconf->status & CONF_CLIENT)) return; if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc.")) @@ -145,7 +145,7 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc /* Check dlines now, klines will be checked on registration */ if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip, - source_p->localClient->ip.ss_family))) + GET_SS_FAMILY(&source_p->localClient->ip)))) { if(!(aconf->status & CONF_EXEMPTDLINE)) { diff --git a/help/Makefile.am b/help/Makefile.am index fae3a746..9d2efdd0 100644 --- a/help/Makefile.am +++ b/help/Makefile.am @@ -13,7 +13,7 @@ SYMLINKS= topic accept cmode admin names links away whowas \ version kick who invite quit join list nick oper part \ time credits motd userhost users whois ison lusers \ user help pass error challenge knock ping pong \ - cprivmsg cnotice map trace chantrace extban monitor + map trace chantrace extban monitor all: build: diff --git a/help/opers/cnotice b/help/opers/cnotice deleted file mode 100644 index 338b643f..00000000 --- a/help/opers/cnotice +++ /dev/null @@ -1,5 +0,0 @@ -CNOTICE : - -Providing you are opped (+o) or voiced (+v) in , and -is a member of , CNOTICE generates a NOTICE towards -. CNOTICE bypasses any anti-spam measures in place. diff --git a/help/opers/cprivmsg b/help/opers/cprivmsg deleted file mode 100644 index fd9f0c1e..00000000 --- a/help/opers/cprivmsg +++ /dev/null @@ -1,5 +0,0 @@ -CPRIVMSG : - -Providing you are opped (+o) or voiced (+v) in , and -is a member of , CPRIVMSG generates a PRIVMSG towards -. CPRIVMSG bypasses any anti-spam measures in place. diff --git a/help/opers/index b/help/opers/index index b33fa210..3dd19664 100644 --- a/help/opers/index +++ b/help/opers/index @@ -2,23 +2,23 @@ Help topics available to opers: ACCEPT ADMIN AWAY CAPAB CHALLENGE CHANTRACE CLOSE CMODE -CNOTICE CONNECT CPRIVMSG CREDITS -DIE DLINE ERROR ETRACE -EXTBAN HELP INDEX INFO -INVITE ISON JOIN KICK -KILL KLINE KNOCK LINKS -LIST LOCOPS LUSERS MAP -MASKTRACE MODLIST MODLOAD MODRELOAD -MODRESTART MODUNLOAD MONITOR MOTD -NAMES NICK NOTICE OPER -OPERSPY OPERWALL PART PASS -PING PONG POST PRIVMSG -PRIVS QUIT REHASH RESTART -RESV SCAN SERVER SET -SJOIN SNOMASK SQUIT STATS -SVINFO TESTGECOS TESTLINE TESTMASK -TIME TOPIC TRACE UHELP -UMODE UNDLINE UNKLINE UNREJECT -UNRESV UNXLINE USER USERHOST -USERS VERSION WALLOPS WHO -WHOIS WHOWAS XLINE +CONNECT CREDITS DIE DLINE +ERROR ETRACE EXTBAN HELP +INDEX INFO INVITE ISON +JOIN KICK KILL KLINE +KNOCK LINKS LIST LOCOPS +LUSERS MAP MASKTRACE MODLIST +MODLOAD MODRELOAD MODRESTART MODUNLOAD +MONITOR MOTD NAMES NICK +NOTICE OPER OPERSPY OPERWALL +PART PASS PING PONG +POST PRIVMSG PRIVS QUIT +REHASH RESTART RESV SCAN +SERVER SET SJOIN SNOMASK +SQUIT STATS SVINFO TESTGECOS +TESTLINE TESTMASK TIME TOPIC +TRACE UHELP UMODE UNDLINE +UNKLINE UNREJECT UNRESV UNXLINE +USER USERHOST USERS VERSION +WALLOPS WHO WHOIS WHOWAS +XLINE diff --git a/help/users/index b/help/users/index index 06de37bd..80522d6b 100644 --- a/help/users/index +++ b/help/users/index @@ -1,14 +1,14 @@ Help topics available to users: ACCEPT ADMIN AWAY CHALLENGE -CHANTRACE CMODE CNOTICE CPRIVMSG -CREDITS ERROR EXTBAN HELP -INDEX INFO INVITE ISON -JOIN KICK KNOCK LINKS -LIST LUSERS MAP MONITOR -MOTD NAMES NICK NOTICE -OPER PART PASS PING -PONG PRIVMSG QUIT STATS -TIME TOPIC TRACE UMODE -USER USERHOST USERS VERSION -WHO WHOIS WHOWAS +CHANTRACE CMODE CREDITS ERROR +EXTBAN HELP INDEX INFO +INVITE ISON JOIN KICK +KNOCK LINKS LIST LUSERS +MAP MONITOR MOTD NAMES +NICK NOTICE OPER PART +PASS PING PONG PRIVMSG +QUIT STATS TIME TOPIC +TRACE UMODE USER USERHOST +USERS VERSION WHO WHOIS +WHOWAS diff --git a/include/blacklist.h b/include/blacklist.h index 652f12b4..7c8fc23e 100644 --- a/include/blacklist.h +++ b/include/blacklist.h @@ -36,7 +36,7 @@ struct Blacklist { int ipv6; /* Does this blacklist support IPv6 lookups? */ char host[IRCD_RES_HOSTLEN + 1]; rb_dlink_list filters; /* Filters for queries */ - char reject_reason[IRCD_BUFSIZE]; + char reject_reason[BUFSIZE]; unsigned int hits; time_t lastwarning; }; diff --git a/include/cache.h b/include/cache.h index 33c75bbc..095354d8 100644 --- a/include/cache.h +++ b/include/cache.h @@ -1,6 +1,8 @@ #ifndef INCLUDED_CACHE_H #define INCLUDED_CACHE_H +#include "rb_dictionary.h" + #define HELP_MAX 100 #define CACHEFILELEN 30 @@ -43,8 +45,7 @@ void send_user_motd(struct Client *); void send_oper_motd(struct Client *); void cache_user_motd(void); -struct Dictionary; -extern struct Dictionary *help_dict_oper; -extern struct Dictionary *help_dict_user; +extern rb_dictionary *help_dict_oper; +extern rb_dictionary *help_dict_user; #endif diff --git a/include/capability.h b/include/capability.h index 0030b7e4..76e58c97 100644 --- a/include/capability.h +++ b/include/capability.h @@ -21,9 +21,12 @@ #ifndef __CAPABILITY_H__ #define __CAPABILITY_H__ +#include "stdinc.h" +#include "rb_dictionary.h" + struct CapabilityIndex { const char *name; - struct Dictionary *cap_dict; + rb_dictionary *cap_dict; unsigned int highest_bit; rb_dlink_node node; }; diff --git a/include/channel.h b/include/channel.h index 44323b0e..ddbb951d 100644 --- a/include/channel.h +++ b/include/channel.h @@ -73,7 +73,7 @@ struct Channel unsigned int join_count; /* joins within delta */ unsigned int join_delta; /* last ts of join */ - unsigned long bants; + time_t bants; time_t channelts; char *chname; @@ -93,7 +93,7 @@ struct membership struct Client *client_p; unsigned int flags; - unsigned long bants; + time_t bants; }; #define BANLEN 195 @@ -213,7 +213,7 @@ extern void destroy_channel(struct Channel *); extern int can_send(struct Channel *chptr, struct Client *who, struct membership *); -extern int flood_attack_channel(int p_or_n, struct Client *source_p, +extern bool flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname); extern int is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr, const char *, const char *, const char **); @@ -231,7 +231,7 @@ extern void invalidate_bancache_user(struct Client *); extern void free_channel_list(rb_dlink_list *); -extern int check_channel_name(const char *name); +extern bool check_channel_name(const char *name); extern void channel_member_names(struct Channel *chptr, struct Client *, int show_eon); @@ -264,7 +264,7 @@ extern void set_channel_mlock(struct Client *client_p, struct Client *source_p, extern struct ChannelMode chmode_table[256]; -extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid, +extern bool add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward, rb_dlink_list * list, long mode_type); extern struct Ban * del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, diff --git a/include/client.h b/include/client.h index b8ca0501..b9a612bf 100644 --- a/include/client.h +++ b/include/client.h @@ -26,11 +26,7 @@ #ifndef INCLUDED_client_h #define INCLUDED_client_h -#include "config.h" - -#if !defined(CONFIG_CHARYBDIS_LEVEL_1) -#error Incorrect config.h for this revision of ircd. -#endif +#include "defaults.h" #include "ircd_defs.h" #include "channel.h" @@ -170,7 +166,9 @@ struct Client struct LocalUser { - rb_dlink_node tnode; /* This is the node for the local list type the client is on*/ + rb_dlink_node tnode; /* This is the node for the local list type the client is on */ + rb_dlink_list connids; /* This is the list of connids to free */ + /* * The following fields are allocated only for local clients * (directly connected to *this* server with a socket. @@ -237,7 +235,6 @@ struct LocalUser time_t next_away; /* Don't allow next away before... */ time_t last; - uint32_t connid; /* clients allowed to talk through +g */ rb_dlink_list allow_list; @@ -276,7 +273,6 @@ struct LocalUser struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */ struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */ - uint32_t zconnid; uint32_t localflags; struct ZipStats *zipstats; /* zipstats */ uint16_t cork_count; /* used for corking/uncorking connections */ @@ -609,4 +605,8 @@ extern char *generate_uid(void); void allocate_away(struct Client *); void free_away(struct Client *); +uint32_t connid_get(struct Client *client_p); +void connid_put(uint32_t id); +void client_release_connids(struct Client *client_p); + #endif /* INCLUDED_client_h */ diff --git a/include/common.h b/include/common.h deleted file mode 100644 index e674e100..00000000 --- a/include/common.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ircd-ratbox: A slightly useful ircd. - * common.h: An ircd header common to most code. - * - * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center - * Copyright (C) 1996-2002 Hybrid Development Team - * Copyright (C) 2002-2004 ircd-ratbox development team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef INCLUDED_common_h -#define INCLUDED_common_h - - -#ifndef NULL -#define NULL 0 -#endif - - -/* Blah. I use these a lot. -Dianora */ -#ifdef YES -#undef YES -#endif - -#define YES 1 - -#ifdef NO -#undef NO -#endif - -#define NO 0 - -/* Just blindly define our own MIN/MAX macro */ - -#define IRCD_MAX(a, b) ((a) > (b) ? (a) : (b)) -#define IRCD_MIN(a, b) ((a) < (b) ? (a) : (b)) - -/* Right out of the RFC */ -#define IRCD_BUFSIZE 512 - -/* readbuf size */ -#define READBUF_SIZE 16384 - -#endif /* INCLUDED_common_h */ diff --git a/include/config.h b/include/config.h deleted file mode 100644 index 6ba69963..00000000 --- a/include/config.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * ircd-ratbox: A slightly useful ircd. - * config.h: The ircd compile-time-configurable header. - * - * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center - * Copyright (C) 1996-2002 Hybrid Development Team - * Copyright (C) 2002-2004 ircd-ratbox development team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef INCLUDED_config_h -#define INCLUDED_config_h - -#include "setup.h" - -/* - * Directory paths and filenames for UNIX systems. - * IRCD_PREFIX is set using ./configure --prefix, see INSTALL. - * The other defaults should be fine. - * - * NOTE: CHANGING THESE WILL NOT ALTER THE DIRECTORY THAT FILES WILL - * BE INSTALLED TO. IF YOU CHANGE THESE, DO NOT USE MAKE INSTALL, - * BUT COPY THE FILES MANUALLY TO WHERE YOU WANT THEM. - * - * IRCD_PREFIX = prefix for all directories, - * DPATH = root directory of installation, - * BINPATH = directory for binary files, - * ETCPATH = directory for configuration files, - * LOGPATH = directory for logfiles, - * MODPATH = directory for modules, - * AUTOMODPATH = directory for autoloaded modules - */ - -/* dirs */ -#define DPATH IRCD_PREFIX -#define BINPATH IRCD_PREFIX "/bin/" -#define MODPATH MODULE_DIR -#define AUTOMODPATH MODULE_DIR "/autoload/" -#define ETCPATH ETC_DIR -#define LOGPATH LOG_DIR -#define UHPATH HELP_DIR "/users" -#define HPATH HELP_DIR "/opers" - -/* files */ -#define SPATH BINPATH "/" PROGRAM_PREFIX "charybdis" /* ircd executable */ -#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ -#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ -#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ -#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ -#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ -#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ - -/* IGNORE_BOGUS_TS - * Ignore bogus timestamps from other servers. Yes this will desync - * the network, but it will allow chanops to resync with a valid non TS 0 - * - * This should be enabled network wide, or not at all. - */ -#undef IGNORE_BOGUS_TS - -/* HANGONGOODLINK and HANGONRETRYDELAY - * Often net breaks for a short time and it's useful to try to - * establishing the same connection again faster than CONNECTFREQUENCY - * would allow. But, to keep trying on bad connection, we require - * that connection has been open for certain minimum time - * (HANGONGOODLINK) and we give the net few seconds to steady - * (HANGONRETRYDELAY). This latter has to be long enough that the - * other end of the connection has time to notice it broke too. - * 1997/09/18 recommended values by ThemBones for modern EFnet - */ -#define HANGONRETRYDELAY 60 /* Recommended value: 30-60 seconds */ -#define HANGONGOODLINK 3600 /* Recommended value: 30-60 minutes */ - -/* KILLCHASETIMELIMIT - - * Max time from the nickname change that still causes KILL - * automatically to switch for the current nick of that user. (seconds) - */ -#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ - -/* CHARYBDIS_SOMAXCONN - * Use SOMAXCONN if OS has it, otherwise use this value for the - * listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs. - */ -#define CHARYBDIS_SOMAXCONN 25 - -/* MAX_BUFFER - * The amount of fds to reserve for clients exempt from limits - * and dns lookups. - */ -#define MAX_BUFFER 60 - -/* ---------------------------------------------------------------- - * STOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOP - * ---------------------------------------------------------------- - * The options below this line should NOT be modified. - * ---------------------------------------------------------------- - */ - -#define CONFIG_CHARYBDIS_LEVEL_2 - -#include "defaults.h" -#endif /* INCLUDED_config_h */ diff --git a/include/config.h.dist b/include/config.h.dist deleted file mode 100644 index f143506e..00000000 --- a/include/config.h.dist +++ /dev/null @@ -1,116 +0,0 @@ -/* - * ircd-ratbox: A slightly useful ircd. - * config.h: The ircd compile-time-configurable header. - * - * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center - * Copyright (C) 1996-2002 Hybrid Development Team - * Copyright (C) 2002-2004 ircd-ratbox development team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef INCLUDED_config_h -#define INCLUDED_config_h - -#include "setup.h" - -/* - * Directory paths and filenames for UNIX systems. - * IRCD_PREFIX is set using ./configure --prefix, see INSTALL. - * The other defaults should be fine. - * - * NOTE: CHANGING THESE WILL NOT ALTER THE DIRECTORY THAT FILES WILL - * BE INSTALLED TO. IF YOU CHANGE THESE, DO NOT USE MAKE INSTALL, - * BUT COPY THE FILES MANUALLY TO WHERE YOU WANT THEM. - * - * IRCD_PREFIX = prefix for all directories, - * DPATH = root directory of installation, - * BINPATH = directory for binary files, - * ETCPATH = directory for configuration files, - * LOGPATH = directory for logfiles, - * MODPATH = directory for modules, - * AUTOMODPATH = directory for autoloaded modules - */ - -/* dirs */ -#define DPATH IRCD_PREFIX -#define BINPATH IRCD_PREFIX "/bin/" -#define MODPATH MODULE_DIR -#define AUTOMODPATH MODULE_DIR "/autoload/" -#define ETCPATH ETC_DIR -#define LOGPATH LOG_DIR -#define UHPATH HELP_DIR "/users" -#define HPATH HELP_DIR "/opers" - -/* files */ -#define SPATH BINPATH "/" PROGRAM_PREFIX "charybdis" /* ircd executable */ -#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ -#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ -#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ -#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ -#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ -#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ - -/* IGNORE_BOGUS_TS - * Ignore bogus timestamps from other servers. Yes this will desync - * the network, but it will allow chanops to resync with a valid non TS 0 - * - * This should be enabled network wide, or not at all. - */ -#undef IGNORE_BOGUS_TS - -/* HANGONGOODLINK and HANGONRETRYDELAY - * Often net breaks for a short time and it's useful to try to - * establishing the same connection again faster than CONNECTFREQUENCY - * would allow. But, to keep trying on bad connection, we require - * that connection has been open for certain minimum time - * (HANGONGOODLINK) and we give the net few seconds to steady - * (HANGONRETRYDELAY). This latter has to be long enough that the - * other end of the connection has time to notice it broke too. - * 1997/09/18 recommended values by ThemBones for modern EFnet - */ -#define HANGONRETRYDELAY 60 /* Recommended value: 30-60 seconds */ -#define HANGONGOODLINK 3600 /* Recommended value: 30-60 minutes */ - -/* KILLCHASETIMELIMIT - - * Max time from the nickname change that still causes KILL - * automatically to switch for the current nick of that user. (seconds) - */ -#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ - -/* CHARYBDIS_SOMAXCONN - * Use SOMAXCONN if OS has it, otherwise use this value for the - * listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs. - */ -#define CHARYBDIS_SOMAXCONN 25 - -/* MAX_BUFFER - * The amount of fds to reserve for clients exempt from limits - * and dns lookups. - */ -#define MAX_BUFFER 60 - -/* ---------------------------------------------------------------- - * STOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOPSTOP - * ---------------------------------------------------------------- - * The options below this line should NOT be modified. - * ---------------------------------------------------------------- - */ - -#define CONFIG_CHARYBDIS_LEVEL_2 - -#include "defaults.h" -#endif /* INCLUDED_config_h */ diff --git a/include/defaults.h b/include/defaults.h index a7f1dc90..599b2611 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -25,14 +25,38 @@ #ifndef INCLUDED_defaults_h #define INCLUDED_defaults_h -/* this file is included (only) at the end of config.h, to supply default - * values for things which are now configurable at runtime. +/* /!\ DANGER WILL ROBINSON! DANGER! /!\ + * + * Do not mess with these values unless you know what you are doing! */ +#include "setup.h" + /* * First, set other fd limits based on values from user */ +typedef enum { + IRCD_PATH_PREFIX, + IRCD_PATH_MODULES, + IRCD_PATH_AUTOLOAD_MODULES, + IRCD_PATH_ETC, + IRCD_PATH_LOG, + IRCD_PATH_USERHELP, + IRCD_PATH_OPERHELP, + IRCD_PATH_IRCD_EXEC, + IRCD_PATH_IRCD_CONF, + IRCD_PATH_IRCD_MOTD, + IRCD_PATH_IRCD_LOG, + IRCD_PATH_IRCD_PID, + IRCD_PATH_IRCD_OMOTD, + IRCD_PATH_BANDB, + IRCD_PATH_BIN, + IRCD_PATH_LIBEXEC, + IRCD_PATH_COUNT +} ircd_path_t; + +extern const char *ircd_paths[IRCD_PATH_COUNT]; #define MAXCONNECTIONS 65535 /* default max connections if getrlimit doesn't work */ /* class {} default values */ @@ -59,5 +83,64 @@ #define JOIN_LEAVE_COUNT_EXPIRE_TIME 120 #define MIN_SPAM_NUM 5 #define MIN_SPAM_TIME 60 -#define CONFIG_CHARYBDIS_LEVEL_1 + +/* + * Directory paths and filenames for UNIX systems. + * IRCD_PREFIX is set using ./configure --prefix, see INSTALL. + * + * IRCD_PREFIX = prefix for all directories, + * DPATH = root directory of installation, + * BINPATH = directory for binary files, + * ETCPATH = directory for configuration files, + * LOGPATH = directory for logfiles, + * MODPATH = directory for modules, + * AUTOMODPATH = directory for autoloaded modules + */ + +#define DPATH IRCD_PREFIX +#define BINPATH IRCD_PREFIX "/bin/" +#define MODPATH MODULE_DIR +#define AUTOMODPATH MODULE_DIR "/autoload/" +#define ETCPATH ETC_DIR +#define LOGPATH LOG_DIR +#define UHPATH HELP_DIR "/users" +#define HPATH HELP_DIR "/opers" +#define SPATH BINPATH "/" PROGRAM_PREFIX "charybdis" /* ircd executable */ +#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */ +#define MPATH ETCPATH "/ircd.motd" /* MOTD file */ +#define LPATH LOGPATH "/ircd.log" /* ircd logfile */ +#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */ +#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */ +#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */ + +/* HANGONGOODLINK and HANGONRETRYDELAY + * Often net breaks for a short time and it's useful to try to + * establishing the same connection again faster than CONNECTFREQUENCY + * would allow. But, to keep trying on bad connection, we require + * that connection has been open for certain minimum time + * (HANGONGOODLINK) and we give the net few seconds to steady + * (HANGONRETRYDELAY). This latter has to be long enough that the + * other end of the connection has time to notice it broke too. + */ +#define HANGONRETRYDELAY 60 /* Recommended value: 30-60 seconds */ +#define HANGONGOODLINK 3600 /* Recommended value: 30-60 minutes */ + +/* KILLCHASETIMELIMIT - + * Max time from the nickname change that still causes KILL + * automatically to switch for the current nick of that user. (seconds) + */ +#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ + +/* MAX_BUFFER + * The amount of fds to reserve for clients exempt from limits + * and dns lookups. + */ +#define MAX_BUFFER 60 + +/* CHARYBDIS_SOMAXCONN + * Use SOMAXCONN if OS has it, otherwise use this value for the + * listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs. + */ +#define CHARYBDIS_SOMAXCONN 25 + #endif /* INCLUDED_defaults_h */ diff --git a/include/dns.h b/include/dns.h index 155bb843..742b5d7c 100644 --- a/include/dns.h +++ b/include/dns.h @@ -34,12 +34,15 @@ extern rb_dlink_list nameservers; typedef void (*DNSCB)(const char *res, int status, int aftype, void *data); typedef void (*DNSLISTCB)(int resc, const char *resv[], int status, void *data); -uint16_t lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data); -uint16_t lookup_ip(const char *hostname, int aftype, DNSCB callback, void *data); -void cancel_lookup(uint16_t xid); +uint32_t lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data); +uint32_t lookup_ip(const char *hostname, int aftype, DNSCB callback, void *data); +void cancel_lookup(uint32_t xid); +void cancel_dns_stats(uint32_t xid); + void dns_results_callback(const char *callid, const char *status, const char *aftype, const char *results); void dns_stats_results_callback(const char *callid, const char *status, int resc, const char *resv[]); -void init_nameserver_cache(void); -bool reload_nameservers(void); + +void init_dns(void); +void reload_nameservers(void); #endif diff --git a/include/hash.h b/include/hash.h index 1a5a66ba..aa0ef79e 100644 --- a/include/hash.h +++ b/include/hash.h @@ -25,12 +25,12 @@ #ifndef INCLUDED_hash_h #define INCLUDED_hash_h -struct Dictionary; -struct rb_radixtree; +#include "rb_dictionary.h" +#include "rb_radixtree.h" -extern struct Dictionary *nd_dict; -extern struct rb_radixtree *resv_tree; -extern struct rb_radixtree *channel_tree; +extern rb_dictionary *nd_dict; +extern rb_radixtree *resv_tree; +extern rb_radixtree *channel_tree; /* Magic value for FNV hash functions */ #define FNV1_32_INIT 0x811c9dc5UL @@ -65,10 +65,10 @@ struct ConfItem; struct cachefile; struct nd_entry; -extern u_int32_t fnv_hash_upper(const unsigned char *s, int bits); -extern u_int32_t fnv_hash(const unsigned char *s, int bits); -extern u_int32_t fnv_hash_len(const unsigned char *s, int bits, int len); -extern u_int32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len); +extern uint32_t fnv_hash_upper(const unsigned char *s, int bits); +extern uint32_t fnv_hash(const unsigned char *s, int bits); +extern uint32_t fnv_hash_len(const unsigned char *s, int bits, int len); +extern uint32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len); extern void init_hash(void); @@ -95,11 +95,8 @@ extern void del_from_resv_hash(const char *name, struct ConfItem *aconf); extern struct ConfItem *hash_find_resv(const char *name); extern void clear_resv_hash(void); -void add_to_cli_connid_hash(struct Client *client_p); -void del_from_cli_connid_hash(struct Client *client_p); +void add_to_cli_connid_hash(struct Client *client_p, uint32_t id); +void del_from_cli_connid_hash(uint32_t id); struct Client *find_cli_connid_hash(uint32_t connid); -void add_to_zconnid_hash(struct Client *client_p); -void del_from_zconnid_hash(struct Client *client_p); - #endif /* INCLUDED_hash_h */ diff --git a/include/hostmask.h b/include/hostmask.h index 43dadc0a..8e97cf74 100644 --- a/include/hostmask.h +++ b/include/hostmask.h @@ -54,7 +54,7 @@ struct ConfItem *find_dline(struct sockaddr *, int); #define find_kline(x) (find_conf_by_address((x)->host, (x)->sockhost, \ (x)->orighost, \ (struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\ - (x)->localClient->ip.ss_family, (x)->username, NULL)) + GET_SS_FAMILY(&(x)->localClient->ip), (x)->username, NULL)) void report_auth(struct Client *); #ifdef RB_IPV6 diff --git a/include/ircd.h b/include/ircd.h index 48e901eb..d268efe6 100644 --- a/include/ircd.h +++ b/include/ircd.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_ircd_h #define INCLUDED_ircd_h -#include "config.h" +#include "defaults.h" struct Client; struct rb_dlink_list; @@ -99,8 +99,8 @@ extern int testing_conf; extern struct ev_entry *check_splitmode_ev; -extern bool ssl_ok; -extern bool zlib_ok; +extern bool ircd_ssl_ok; +extern bool ircd_zlib_ok; extern int maxconnections; void ircd_shutdown(const char *reason); diff --git a/include/ircd_defs.h b/include/ircd_defs.h index 0822a37e..40db5383 100644 --- a/include/ircd_defs.h +++ b/include/ircd_defs.h @@ -35,7 +35,7 @@ #ifndef INCLUDED_ircd_defs_h #define INCLUDED_ircd_defs_h -#include "config.h" +#include "defaults.h" /* For those unfamiliar with GNU format attributes, a is the 1 based * argument number of the format string, and b is the 1 based argument @@ -56,8 +56,12 @@ #define IRC_DEPRECATED #endif -#if !defined(CONFIG_CHARYBDIS_LEVEL_1) -# error Incorrect config.h for this revision of ircd. +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #define HOSTLEN 63 /* Length of hostname. Updated to */ @@ -119,4 +123,7 @@ #define PATRICIA_BITS 32 #endif +/* Read buffer size */ +#define READBUF_SIZE 16384 + #endif /* INCLUDED_ircd_defs_h */ diff --git a/include/m_info.h b/include/m_info.h index 00eb0ab3..d0ff6417 100644 --- a/include/m_info.h +++ b/include/m_info.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_m_info_h #define INCLUDED_m_info_h -#include "config.h" +#include "defaults.h" typedef struct Information { diff --git a/include/match.h b/include/match.h index c49e12e9..151ad4bf 100644 --- a/include/match.h +++ b/include/match.h @@ -46,8 +46,8 @@ extern int match_ips(const char *mask, const char *name); /* * comp_with_mask - compares to IP address */ -int comp_with_mask(void *addr, void *dest, u_int mask); -int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask); +int comp_with_mask(void *addr, void *dest, unsigned int mask); +int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, unsigned int mask); /* * collapse - collapse a string in place, converts multiple adjacent *'s diff --git a/include/modules.h b/include/modules.h index b2ff535b..0b83bd60 100644 --- a/include/modules.h +++ b/include/modules.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_modules_h #define INCLUDED_modules_h #include "serno.h" -#include "config.h" +#include "defaults.h" #include "setup.h" #include "parse.h" diff --git a/include/msg.h b/include/msg.h index 0adc9a84..3709163a 100644 --- a/include/msg.h +++ b/include/msg.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_msg_h #define INCLUDED_msg_h -#include "config.h" +#include "defaults.h" #include "msgbuf.h" struct Client; @@ -54,7 +54,7 @@ typedef void (*MessageHandler) (struct MsgBuf *, struct Client *, struct Client struct MessageEntry { MessageHandler handler; - int min_para; + size_t min_para; }; /* Message table structure */ diff --git a/include/newconf.h b/include/newconf.h index fda64c64..d6c73557 100644 --- a/include/newconf.h +++ b/include/newconf.h @@ -1,5 +1,4 @@ /* This code is in the public domain. - * $Nightmare: nightmare/include/config.h,v 1.32.2.2.2.2 2002/07/02 03:41:28 ejb Exp $ */ #ifndef _NEWCONF_H_INCLUDED diff --git a/include/numeric.h b/include/numeric.h index 465cee15..154ba98e 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_numeric_h #define INCLUDED_numeric_h -#include "config.h" +#include "defaults.h" #include "messages.h" /* diff --git a/include/parse.h b/include/parse.h index a61754f1..a60068dd 100644 --- a/include/parse.h +++ b/include/parse.h @@ -39,7 +39,7 @@ extern void mod_add_cmd(struct Message *msg); extern void mod_del_cmd(struct Message *msg); extern char *reconstruct_parv(int parc, const char *parv[]); -extern struct Dictionary *alias_dict; -extern struct Dictionary *cmd_dict; +extern rb_dictionary *alias_dict; +extern rb_dictionary *cmd_dict; #endif /* INCLUDED_parse_h_h */ diff --git a/include/s_assert.h b/include/s_assert.h index 60ea28cd..74a48198 100644 --- a/include/s_assert.h +++ b/include/s_assert.h @@ -26,7 +26,7 @@ #ifndef INCLUDED_s_assert_h #define INCLUDED_s_assert_h -#include "config.h" +#include "defaults.h" #ifdef SOFT_ASSERT diff --git a/include/s_conf.h b/include/s_conf.h index 4f78fbdd..9a0f5532 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -33,7 +33,6 @@ #include "ircd_defs.h" #include "class.h" #include "client.h" -#include "common.h" struct Client; struct DNSReply; @@ -373,8 +372,8 @@ extern void add_temp_dline(struct ConfItem *); extern void report_temp_klines(struct Client *); extern void show_temp_klines(struct Client *, rb_dlink_list *); -extern int rehash(int); -extern void rehash_bans(int); +extern bool rehash(bool); +extern void rehash_bans(void); extern int conf_add_server(struct ConfItem *, int); extern void conf_add_class_to_conf(struct ConfItem *); @@ -389,11 +388,11 @@ extern int yylex(void); extern unsigned long cidr_to_bitmask[]; -extern char conffilebuf[IRCD_BUFSIZE + 1]; +extern char conffilebuf[BUFSIZE + 1]; extern int lineno; #define NOT_AUTHORISED (-1) -#define SOCKET_ERROR (-2) +#define I_SOCKET_ERROR (-2) #define I_LINE_FULL (-3) #define BANNED_CLIENT (-4) #define TOO_MANY_LOCAL (-6) diff --git a/include/s_newconf.h b/include/s_newconf.h index 55b3ec36..b23c6364 100644 --- a/include/s_newconf.h +++ b/include/s_newconf.h @@ -131,7 +131,7 @@ struct oper_conf extern struct remote_conf *make_remote_conf(void); extern void free_remote_conf(struct remote_conf *); -extern int find_shared_conf(const char *username, const char *host, +extern bool find_shared_conf(const char *username, const char *host, const char *server, int flags); extern void propagate_generic(struct Client *source_p, const char *command, const char *target, int cap, const char *format, ...); diff --git a/include/s_serv.h b/include/s_serv.h index 5c323320..6808c37e 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_serv_h #define INCLUDED_serv_h -#include "config.h" +#include "defaults.h" #include "capability.h" /* diff --git a/include/s_user.h b/include/s_user.h index d50c44d1..e0f41aa3 100644 --- a/include/s_user.h +++ b/include/s_user.h @@ -25,7 +25,7 @@ #ifndef INCLUDED_s_user_h #define INCLUDED_s_user_h -#include "config.h" +#include "defaults.h" struct Client; struct User; diff --git a/include/send.h b/include/send.h index 6cb5df7b..695ec563 100644 --- a/include/send.h +++ b/include/send.h @@ -27,7 +27,6 @@ #include "rb_lib.h" #include "ircd_defs.h" -#include "config.h" /* HAVE_STDARG_H */ struct Client; struct Channel; diff --git a/include/setup.h.in b/include/setup.h.in deleted file mode 100644 index a66efc10..00000000 --- a/include/setup.h.in +++ /dev/null @@ -1,473 +0,0 @@ -/* include/setup.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Size of away heap. */ -#undef AWAY_HEAP_SIZE - -/* Size of the ban heap. */ -#undef BAN_HEAP_SIZE - -/* Custom branding name. */ -#undef BRANDING_NAME - -/* Custom branding name. */ -#undef BRANDING_VERSION - -/* Size of the channel heap. */ -#undef CHANNEL_HEAP_SIZE - -/* Define this if you are profiling. */ -#undef CHARYBDIS_PROFILE - -/* Size of the client heap. */ -#undef CLIENT_HEAP_SIZE - -/* Size of the confitem heap. */ -#undef CONFITEM_HEAP_SIZE - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define if custom branding is enabled. */ -#undef CUSTOM_BRANDING - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - -/* Size of the dlink_node heap. */ -#undef DNODE_HEAP_SIZE - -/* Prefix where config files are installed. */ -#undef ETC_DIR - -/* Size of fd heap. */ -#undef FD_HEAP_SIZE - -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - -/* Define to 1 if you have the `argz_add' function. */ -#undef HAVE_ARGZ_ADD - -/* Define to 1 if you have the `argz_append' function. */ -#undef HAVE_ARGZ_APPEND - -/* Define to 1 if you have the `argz_count' function. */ -#undef HAVE_ARGZ_COUNT - -/* Define to 1 if you have the `argz_create_sep' function. */ -#undef HAVE_ARGZ_CREATE_SEP - -/* Define to 1 if you have the header file. */ -#undef HAVE_ARGZ_H - -/* Define to 1 if you have the `argz_insert' function. */ -#undef HAVE_ARGZ_INSERT - -/* Define to 1 if you have the `argz_next' function. */ -#undef HAVE_ARGZ_NEXT - -/* Define to 1 if you have the `argz_stringify' function. */ -#undef HAVE_ARGZ_STRINGIFY - -/* Define to 1 if you have the `closedir' function. */ -#undef HAVE_CLOSEDIR - -/* Define to 1 if you have the header file. */ -#undef HAVE_CRYPT_H - -/* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if - you don't. */ -#undef HAVE_DECL_CYGWIN_CONV_PATH - -/* Define to 1 if you have the header file. */ -#undef HAVE_DIRENT_H - -/* Define if you have the GNU dld library. */ -#undef HAVE_DLD - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLD_H - -/* Define to 1 if you have the `dlerror' function. */ -#undef HAVE_DLERROR - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DL_H - -/* Define if you have the _dyld_func_lookup function. */ -#undef HAVE_DYLD - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define to 1 if the system has the type `error_t'. */ -#undef HAVE_ERROR_T - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `crypto' library (-lcrypto). */ -#undef HAVE_LIBCRYPTO - -/* Define if you have the libdl library or equivalent. */ -#undef HAVE_LIBDL - -/* Define if libdlloader will be built on this platform */ -#undef HAVE_LIBDLLOADER - -/* Define to 1 if zlib (-lz) is available. */ -#undef HAVE_LIBZ - -/* Define this if a modern libltdl is already installed */ -#undef HAVE_LTDL - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACHINE_ENDIAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACH_O_DYLD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mmap' function. */ -#undef HAVE_MMAP - -/* Define if nanosleep exists */ -#undef HAVE_NANOSLEEP - -/* Define to 1 if you have the `opendir' function. */ -#undef HAVE_OPENDIR - -/* Define if libtool can extract symbol lists from object files. */ -#undef HAVE_PRELOADED_SYMBOLS - -/* Define to 1 if you have the `readdir' function. */ -#undef HAVE_READDIR - -/* Define if you have the shl_load function. */ -#undef HAVE_SHL_LOAD - -/* Define to 1 if you have the `snprintf' function. */ -#undef HAVE_SNPRINTF - -/* Define to 1 if you have the `socketpair' function. */ -#undef HAVE_SOCKETPAIR - -/* Define to 1 if stdbool.h conforms to C99. */ -#undef HAVE_STDBOOL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDDEF_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strlcat' function. */ -#undef HAVE_STRLCAT - -/* Define to 1 if you have the `strlcpy' function. */ -#undef HAVE_STRLCPY - -/* Define to 1 if you have the `strndup' function. */ -#undef HAVE_STRNDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_DL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_EPOLL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_RESOURCE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SYSLOG_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_WAIT_H - -/* Define to 1 if the system has the type `uintptr_t'. */ -#undef HAVE_UINTPTR_T - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - -/* Define to 1 if you have the header file. */ -#undef HAVE_WAIT_H - -/* This value is set to 1 to indicate that the system argz facility works */ -#undef HAVE_WORKING_ARGZ - -/* Define to 1 if the system has the type `_Bool'. */ -#undef HAVE__BOOL - -/* Prefix where help files are installed. */ -#undef HELP_DIR - -/* Prefix where the ircd is installed. */ -#undef IRCD_PREFIX - -/* Size of the local client heap. */ -#undef LCLIENT_HEAP_SIZE - -/* Size of the linebuf heap. */ -#undef LINEBUF_HEAP_SIZE - -/* Prefix where to write logfiles. */ -#undef LOG_DIR - -/* Define if the OS needs help to load dependent libraries for dlopen(). */ -#undef LTDL_DLOPEN_DEPLIBS - -/* Define to the system default library search path. */ -#undef LT_DLSEARCH_PATH - -/* The archive extension */ -#undef LT_LIBEXT - -/* The archive prefix */ -#undef LT_LIBPREFIX - -/* Define to the extension used for runtime loadable modules, say, ".so". */ -#undef LT_MODULE_EXT - -/* Define to the name of the environment variable that determines the run-time - module search path. */ -#undef LT_MODULE_PATH_VAR - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - -/* Define to the shared library suffix, say, ".dylib". */ -#undef LT_SHARED_EXT - -/* Define to the shared archive member specification, say "(shr.o)". */ -#undef LT_SHARED_LIB_MEMBER - -/* Sizeof member heap. */ -#undef MEMBER_HEAP_SIZE - -/* Prefix where modules are installed. */ -#undef MODULE_DIR - -/* Size of the monitor heap. */ -#undef MONITOR_HEAP_SIZE - -/* Define this to disable debugging support. */ -#undef NDEBUG - -/* Size of the nick delay heap. */ -#undef ND_HEAP_SIZE - -/* Define if dlsym() requires a leading underscore in symbol names. */ -#undef NEED_USCORE - -/* Nickname length */ -#undef NICKLEN - -/* Size of the WHOWAS array. */ -#undef NICKNAMEHISTORYLENGTH - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Path to /dev/null */ -#undef PATH_DEVNULL - -/* Size of the pre-client heap. */ -#undef PCLIENT_HEAP_SIZE - -/* Directory where binaries the IRCd itself spawns live */ -#undef PKGLIBEXECDIR - -/* Directory in which to store state, such as ban database */ -#undef PKGLOCALSTATEDIR - -/* Directory to store pidfile in. */ -#undef PKGRUNDIR - -/* String with which all programs intended to be in PATH are prefixed. */ -#undef PROGRAM_PREFIX - -/* The size of `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* The size of `short', as computed by sizeof. */ -#undef SIZEOF_SHORT - -/* Define this to enable soft asserts. */ -#undef SOFT_ASSERT - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Maximum topic length (<=390) */ -#undef TOPICLEN - -/* Size of the topic heap. */ -#undef TOPIC_HEAP_SIZE - -/* Size of the user heap. */ -#undef USER_HEAP_SIZE - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Version number of package */ -#undef VERSION - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#undef YYTEXT_POINTER - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -/* Define so that glibc/gnulib argp.h does not typedef error_t. */ -#undef __error_t_defined - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to a type to use for 'error_t' if it is not otherwise available. */ -#undef error_t - -/* If system does not define in_port_t, define it to what it should be. */ -#undef in_port_t - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to `int' if does not define. */ -#undef pid_t - -/* If system does not define sa_family_t, define it here. */ -#undef sa_family_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* If we don't have a real socklen_t, unsigned int is good enough. */ -#undef socklen_t - -/* If system does not define u_int16_t, define a usable substitute. */ -#undef u_int16_t - -/* If system does not define u_int32_t, define to unsigned long int here. */ -#undef u_int32_t diff --git a/include/stdinc.h b/include/stdinc.h index 9a32e5ce..d620f779 100644 --- a/include/stdinc.h +++ b/include/stdinc.h @@ -22,7 +22,6 @@ */ #include "rb_lib.h" -#include "config.h" /* Gotta pull in the autoconf stuff */ #include "ircd_defs.h" /* Needed for some reasons here -- dwr */ /* AIX requires this to be the first thing in the file. */ @@ -93,7 +92,6 @@ typedef bool _Bool; #include #include #include -#include #include #include #include @@ -113,16 +111,11 @@ typedef bool _Bool; #endif -#include #include -#include #ifdef HAVE_SYS_PARAM_H #include #endif -#include -#include -#include #ifdef HAVE_ERRNO_H #include diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/ircd/Makefile.am b/ircd/Makefile.am index a1e6c7e2..20370488 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -14,6 +14,10 @@ version.c: version.c.SH ../CREDITS ../include/patchlevel.h ../include/serno.h $(CP) version.c version.c.last touch version.c.SH +if MINGW +EXTRA_FLAGS = -Wl,--enable-runtime-pseudo-reloc -export-symbols-regex '*' +endif + libircd_la_SOURCES = \ authd.c \ bandbi.c \ @@ -63,7 +67,7 @@ libircd_la_SOURCES = \ tgchange.c \ version.c \ whowas.c -libircd_la_LDFLAGS = $(EXTRA_FLAGS) -avoid-version +libircd_la_LDFLAGS = $(EXTRA_FLAGS) -avoid-version -no-undefined libircd_la_LIBADD = @LIBLTDL@ -L$(top_srcdir)/librb/src -lrb libircd_LTLIBRARIES = libircd.la diff --git a/ircd/authd.c b/ircd/authd.c index 491d0237..8b453393 100644 --- a/ircd/authd.c +++ b/ircd/authd.c @@ -55,20 +55,20 @@ start_authd(void) #endif if(authd_path == NULL) { - snprintf(fullpath, sizeof(fullpath), "%s/authd%s", PKGLIBEXECDIR, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cauthd%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { - snprintf(fullpath, sizeof(fullpath), "%s/libexec/charybdis/authd%s", - ConfigFileEntry.dpath, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cbin%cauthd%s", + ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, - "Unable to execute authd in %s or %s/libexec/charybdis", - PKGLIBEXECDIR, ConfigFileEntry.dpath); + "Unable to execute authd in %s or %s/bin", + ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); sendto_realops_snomask(SNO_GENERAL, L_ALL, - "Unable to execute authd in %s or %s/libexec/charybdis", - PKGLIBEXECDIR, ConfigFileEntry.dpath); + "Unable to execute authd in %s or %s/bin", + ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); return 1; } @@ -114,6 +114,39 @@ parse_authd_reply(rb_helper * helper) } dns_results_callback(parv[1], parv[2], parv[3], parv[4]); break; + case 'W': + if(parc != 3) + { + ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc); + restart_authd(); + return; + } + + switch(*parv[2]) + { + case 'D': /* debug */ + sendto_realops_snomask(SNO_DEBUG, L_ALL, "authd debug: %s", parv[3]); + break; + case 'I': /* Info */ + sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd info: %s", parv[3]); + inotice("authd info: %s", parv[3]); + break; + case 'W': /* Warning */ + sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd WARNING: %s", parv[3]); + iwarn("authd warning: %s", parv[3]); + break; + case 'C': /* Critical (error) */ + sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd CRITICAL: %s", parv[3]); + ierror("authd critical: %s", parv[3]); + break; + default: /* idk */ + sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd sent us an unknown oper notice type (%s): %s", parv[2], parv[3]); + ilog(L_MAIN, "authd unknown oper notice type (%s): %s", parv[2], parv[3]); + break; + } + + /* NOTREACHED */ + break; case 'X': case 'Y': case 'Z': diff --git a/ircd/bandbi.c b/ircd/bandbi.c index aa9410d2..15171b64 100644 --- a/ircd/bandbi.c +++ b/ircd/bandbi.c @@ -80,21 +80,21 @@ start_bandb(void) const char *suffix = ""; #endif - rb_setenv("BANDB_DBPATH", PKGLOCALSTATEDIR "/ban.db", 1); + rb_setenv("BANDB_DBPATH", ircd_paths[IRCD_PATH_BANDB], 1); if(bandb_path == NULL) { - snprintf(fullpath, sizeof(fullpath), "%s/bandb%s", PKGLIBEXECDIR, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cbandb%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { - snprintf(fullpath, sizeof(fullpath), "%s/bin/bandb%s", - ConfigFileEntry.dpath, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cbin%cbandb%s", + ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, "Unable to execute bandb%s in %s or %s/bin", - suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath); + suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); return 0; } } diff --git a/ircd/blacklist.c b/ircd/blacklist.c index dca1c2ed..47438438 100644 --- a/ircd/blacklist.c +++ b/ircd/blacklist.c @@ -156,7 +156,7 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client * blcptr->client_p = client_p; /* IPv4 */ - if ((client_p->localClient->ip.ss_family == AF_INET) && blptr->ipv4) + if ((GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET) && blptr->ipv4) { ip = (uint8_t *)&((struct sockaddr_in *)&client_p->localClient->ip)->sin_addr.s_addr; @@ -168,8 +168,9 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client * (unsigned int) ip[0], blptr->host); } +#ifdef RB_IPV6 /* IPv6 */ - else if ((client_p->localClient->ip.ss_family == AF_INET6) && blptr->ipv6) + else if ((GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6) && blptr->ipv6) { /* Split up for rDNS lookup * ex: ip[0] = 0x00, ip[1] = 0x00... ip[16] = 0x01 for localhost @@ -197,6 +198,7 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client * /* Tack host on */ strcpy(bufptr, blptr->host); } +#endif /* This shouldn't happen... */ else return; @@ -225,7 +227,7 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason, int ipv4, int i blptr->status &= ~CONF_ILLEGAL; rb_strlcpy(blptr->host, name, IRCD_RES_HOSTLEN + 1); - rb_strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); + rb_strlcpy(blptr->reject_reason, reject_reason, BUFSIZE); blptr->ipv4 = ipv4; blptr->ipv6 = ipv6; diff --git a/ircd/cache.c b/ircd/cache.c index 58a9044c..b5581f52 100644 --- a/ircd/cache.c +++ b/ircd/cache.c @@ -32,7 +32,6 @@ #include "stdinc.h" #include "ircd_defs.h" -#include "common.h" #include "s_conf.h" #include "client.h" #include "hash.h" @@ -47,8 +46,8 @@ struct cacheline *emptyline = NULL; rb_dlink_list links_cache_list; char user_motd_changed[MAX_DATE_STRING]; -struct Dictionary *help_dict_oper = NULL; -struct Dictionary *help_dict_user = NULL; +rb_dictionary *help_dict_oper = NULL; +rb_dictionary *help_dict_user = NULL; /* init_cache() * @@ -65,8 +64,8 @@ init_cache(void) user_motd_changed[0] = '\0'; - user_motd = cache_file(MPATH, "ircd.motd", 0); - oper_motd = cache_file(OPATH, "opers.motd", 0); + user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0); + oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0); memset(&links_cache_list, 0, sizeof(links_cache_list)); help_dict_oper = rb_dictionary_create("oper help", strcasecmp); @@ -237,24 +236,24 @@ load_help(void) struct dirent *ldirent= NULL; char filename[PATH_MAX]; struct cachefile *cacheptr; - struct DictionaryIter iter; + rb_dictionary_iter iter; #if defined(S_ISLNK) && defined(HAVE_LSTAT) struct stat sb; #endif - DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper) + RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper) { rb_dictionary_delete(help_dict_oper, cacheptr->name); free_cachefile(cacheptr); } - DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user) + RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user) { rb_dictionary_delete(help_dict_user, cacheptr->name); free_cachefile(cacheptr); } - helpfile_dir = opendir(HPATH); + helpfile_dir = opendir(ircd_paths[IRCD_PATH_OPERHELP]); if(helpfile_dir == NULL) return; @@ -263,13 +262,13 @@ load_help(void) { if(ldirent->d_name[0] == '.') continue; - snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name); + snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_OPERHELP], RB_PATH_SEPARATOR, ldirent->d_name); cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER); rb_dictionary_add(help_dict_oper, cacheptr->name, cacheptr); } closedir(helpfile_dir); - helpfile_dir = opendir(UHPATH); + helpfile_dir = opendir(ircd_paths[IRCD_PATH_USERHELP]); if(helpfile_dir == NULL) return; @@ -278,7 +277,7 @@ load_help(void) { if(ldirent->d_name[0] == '.') continue; - snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name); + snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_USERHELP], RB_PATH_SEPARATOR, ldirent->d_name); #if defined(S_ISLNK) && defined(HAVE_LSTAT) if(lstat(filename, &sb) < 0) @@ -342,7 +341,7 @@ cache_user_motd(void) struct stat sb; struct tm *local_tm; - if(stat(MPATH, &sb) == 0) + if(stat(ircd_paths[IRCD_PATH_IRCD_MOTD], &sb) == 0) { local_tm = localtime(&sb.st_mtime); @@ -356,7 +355,7 @@ cache_user_motd(void) } } free_cachefile(user_motd); - user_motd = cache_file(MPATH, "ircd.motd", 0); + user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0); } diff --git a/ircd/capability.c b/ircd/capability.c index 38a6c5a5..2eb5c60e 100644 --- a/ircd/capability.c +++ b/ircd/capability.c @@ -129,7 +129,7 @@ capability_require(struct CapabilityIndex *idx, const char *cap) } static void -capability_destroy(struct DictionaryElement *delem, void *privdata) +capability_destroy(rb_dictionary_element *delem, void *privdata) { s_assert(delem != NULL); @@ -165,7 +165,7 @@ capability_index_destroy(struct CapabilityIndex *idx) const char * capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask) { - struct DictionaryIter iter; + rb_dictionary_iter iter; struct CapabilityEntry *entry; static char buf[BUFSIZE]; char *t = buf; @@ -175,7 +175,7 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask) *t = '\0'; - DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) { if ((1 << entry->value) & cap_mask) { @@ -193,13 +193,13 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask) unsigned int capability_index_mask(struct CapabilityIndex *idx) { - struct DictionaryIter iter; + rb_dictionary_iter iter; struct CapabilityEntry *entry; unsigned int mask = 0; s_assert(idx != NULL); - DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) { if (!(entry->flags & CAP_ORPHANED)) mask |= (1 << entry->value); @@ -211,13 +211,13 @@ capability_index_mask(struct CapabilityIndex *idx) unsigned int capability_index_get_required(struct CapabilityIndex *idx) { - struct DictionaryIter iter; + rb_dictionary_iter iter; struct CapabilityEntry *entry; unsigned int mask = 0; s_assert(idx != NULL); - DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) { if (!(entry->flags & CAP_ORPHANED) && (entry->flags & CAP_REQUIRED)) mask |= (1 << entry->value); @@ -235,13 +235,13 @@ capability_index_stats(void (*cb)(const char *line, void *privdata), void *privd RB_DLINK_FOREACH(node, capability_indexes.head) { struct CapabilityIndex *idx = node->data; - struct DictionaryIter iter; + rb_dictionary_iter iter; struct CapabilityEntry *entry; snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1)); cb(buf, privdata); - DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) { snprintf(buf, sizeof buf, "bit %d: '%s'", entry->value, entry->cap); cb(buf, privdata); diff --git a/ircd/channel.c b/ircd/channel.c index 35a9afb6..4609325a 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -26,7 +26,6 @@ #include "channel.h" #include "chmode.h" #include "client.h" -#include "common.h" #include "hash.h" #include "hook.h" #include "match.h" @@ -337,23 +336,23 @@ invalidate_bancache_user(struct Client *client_p) /* check_channel_name() * * input - channel name - * output - 1 if valid channel name, else 0 + * output - true if valid channel name, else false * side effects - */ -int +bool check_channel_name(const char *name) { s_assert(name != NULL); if(name == NULL) - return 0; + return false; for (; *name; ++name) { if(!IsChanChar(*name)) - return 0; + return false; } - return 1; + return true; } /* free_channel_list() @@ -581,7 +580,7 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list, } } #ifdef RB_IPV6 - if(who->localClient->ip.ss_family == AF_INET6 && + if(GET_SS_FAMILY(&who->localClient->ip) == AF_INET6 && ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4)) { sprintf(src_ip4host, "%s!%s@", who->name, who->username); @@ -902,11 +901,11 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC * says NOTICE must not auto reply * - pointer to source Client - * - pointer to target channel - * output - 1 if target is under flood attack + * - pointer to target channel + * output - true if target is under flood attack * side effects - check for flood attack on target chptr */ -int +bool flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname) { int delta; @@ -944,13 +943,13 @@ flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, sendto_one(source_p, ":%s NOTICE %s :*** Message to %s throttled due to flooding", me.name, source_p->name, chptr->chname); - return 1; + return true; } else chptr->received_number_of_privmsgs++; } - return 0; + return false; } /* find_bannickchange_channel() diff --git a/ircd/chmode.c b/ircd/chmode.c index 5616fc7c..c3182d1f 100644 --- a/ircd/chmode.c +++ b/ircd/chmode.c @@ -26,7 +26,6 @@ #include "stdinc.h" #include "channel.h" #include "client.h" -#include "common.h" #include "hash.h" #include "hook.h" #include "match.h" @@ -203,10 +202,10 @@ get_channel_access(struct Client *source_p, struct Channel *chptr, struct member * Checks if mlock and chanops permit a mode change. * * inputs - client, channel, access level, errors pointer, mode char - * outputs - 0 on failure, 1 on success + * outputs - false on failure, true on success * side effects - error message sent on failure */ -static int +static bool allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel, int *errors, char c) { @@ -221,7 +220,7 @@ allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel, c, chptr->mode_lock); *errors |= SM_ERR_MLOCK; - return 0; + return false; } if(alevel < CHFL_CHANOP) { @@ -229,18 +228,18 @@ allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel, sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, chptr->chname); *errors |= SM_ERR_NOOPS; - return 0; + return false; } - return 1; + return true; } /* add_id() * * inputs - client, channel, id to add, type, forward - * outputs - 0 on failure, 1 on success + * outputs - false on failure, true on success * side effects - given id is added to the appropriate list */ -int +bool add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward, rb_dlink_list * list, long mode_type) { @@ -258,14 +257,14 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const { sendto_one(source_p, form_str(ERR_BANLISTFULL), me.name, source_p->name, chptr->chname, realban); - return 0; + return false; } RB_DLINK_FOREACH(ptr, list->head) { actualBan = ptr->data; if(mask_match(actualBan->banstr, realban)) - return 0; + return false; } } /* dont let remotes set duplicates */ @@ -275,7 +274,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const { actualBan = ptr->data; if(!irccmp(actualBan->banstr, realban)) - return 0; + return false; } } @@ -294,7 +293,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION) chptr->bants++; - return 1; + return true; } /* del_id() @@ -487,7 +486,7 @@ pretty_mask(const char *idmask) * output - true if forwarding should be allowed * side effects - numeric sent if not allowed */ -static int +static bool check_forward(struct Client *source_p, struct Channel *chptr, const char *forward) { @@ -498,20 +497,20 @@ check_forward(struct Client *source_p, struct Channel *chptr, (MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward)))) { sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward); - return 0; + return false; } /* don't forward to inconsistent target -- jilles */ if(chptr->chname[0] == '#' && forward[0] == '&') { sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward); - return 0; + return false; } if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL) { sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), forward); - return 0; + return false; } if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET)) { @@ -520,10 +519,10 @@ check_forward(struct Client *source_p, struct Channel *chptr, { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, targptr->chname); - return 0; + return false; } } - return 1; + return true; } /* fix_key() @@ -536,9 +535,9 @@ check_forward(struct Client *source_p, struct Channel *chptr, static char * fix_key(char *arg) { - u_char *s, *t, c; + unsigned char *s, *t, c; - for(s = t = (u_char *) arg; (c = *s); s++) + for(s = t = (unsigned char *) arg; (c = *s); s++) { c &= 0x7f; if(c != ':' && c != ',' && c > ' ') @@ -559,9 +558,9 @@ fix_key(char *arg) static char * fix_key_remote(char *arg) { - u_char *s, *t, c; + unsigned char *s, *t, c; - for(s = t = (u_char *) arg; (c = *s); s++) + for(s = t = (unsigned char *) arg; (c = *s); s++) { c &= 0x7f; if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' ')) @@ -889,7 +888,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr, * also make sure it will always fit on a line with channel * name etc. */ - if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5)) + if(strlen(mask) > MIN(BANLEN, MODEBUFLEN - 5)) { sendto_one_numeric(source_p, ERR_INVALIDBAN, form_str(ERR_INVALIDBAN), diff --git a/ircd/class.c b/ircd/class.c index 580b9fc3..75db28d0 100644 --- a/ircd/class.c +++ b/ircd/class.c @@ -23,11 +23,10 @@ */ #include "stdinc.h" -#include "config.h" +#include "defaults.h" #include "class.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "numeric.h" #include "s_conf.h" diff --git a/ircd/client.c b/ircd/client.c index bd6982d0..268f61b2 100644 --- a/ircd/client.c +++ b/ircd/client.c @@ -23,11 +23,10 @@ * USA */ #include "stdinc.h" -#include "config.h" +#include "defaults.h" #include "client.h" #include "class.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -77,9 +76,9 @@ static rb_bh *pclient_heap = NULL; static rb_bh *user_heap = NULL; static rb_bh *away_heap = NULL; static char current_uid[IDLEN]; -static int32_t current_connid = 0; +static uint32_t current_connid = 0; -struct Dictionary *nd_dict = NULL; +rb_dictionary *nd_dict = NULL; enum { @@ -130,6 +129,78 @@ init_client(void) nd_dict = rb_dictionary_create("nickdelay", irccmp); } +/* + * connid_get - allocate a connid + * + * inputs - none + * outputs - a connid token which is used to represent a logical circuit + * side effects - current_connid is incremented, possibly multiple times. + * the association of the connid to it's client is committed. + */ +uint32_t +connid_get(struct Client *client_p) +{ + s_assert(MyClient(client_p)); + if (!MyClient(client_p)) + return 0; + + /* find a connid that is available */ + while (find_cli_connid_hash(++current_connid) != NULL) + { + /* handle wraparound, current_connid must NEVER be 0 */ + if (current_connid == 0) + ++current_connid; + } + + add_to_cli_connid_hash(client_p, current_connid); + rb_dlinkAddAlloc(RB_UINT_TO_POINTER(current_connid), &client_p->localClient->connids); + + return current_connid; +} + +/* + * connid_put - free a connid + * + * inputs - connid to free + * outputs - nothing + * side effects - connid bookkeeping structures are freed + */ +void +connid_put(uint32_t id) +{ + struct Client *client_p; + + s_assert(id != 0); + if (id == 0) + return; + + client_p = find_cli_connid_hash(id); + if (client_p == NULL) + return; + + del_from_cli_connid_hash(id); + rb_dlinkFindDestroy(RB_UINT_TO_POINTER(id), &client_p->localClient->connids); +} + +/* + * client_release_connids - release any connids still attached to a client + * + * inputs - client to garbage collect + * outputs - none + * side effects - client's connids are garbage collected + */ +void +client_release_connids(struct Client *client_p) +{ + rb_dlink_node *ptr, *ptr2; + + s_assert(MyClient(client_p)); + if (!MyClient(client_p)) + return; + + RB_DLINK_FOREACH_SAFE(ptr, ptr2, client_p->localClient->connids.head) + connid_put(RB_POINTER_TO_UINT(ptr->data)); +} /* * make_client - create a new Client struct and set it to initial state. @@ -161,17 +232,6 @@ make_client(struct Client *from) client_p->localClient->F = NULL; - if(current_connid+1 == 0) - current_connid++; - - client_p->localClient->connid = ++current_connid; - - if(current_connid+1 == 0) - current_connid++; - - client_p->localClient->zconnid = ++current_connid; - add_to_cli_connid_hash(client_p); - client_p->preClient = rb_bh_alloc(pclient_heap); /* as good a place as any... */ @@ -230,7 +290,7 @@ free_local_client(struct Client *client_p) client_p->localClient->listener = 0; } - del_from_cli_connid_hash(client_p); + client_release_connids(client_p); if(client_p->localClient->F != NULL) { rb_close(client_p->localClient->F); @@ -542,7 +602,7 @@ check_dlines(void) if(IsMe(client_p)) continue; - if((aconf = find_dline((struct sockaddr *)&client_p->localClient->ip,client_p->localClient->ip.ss_family)) != NULL) + if((aconf = find_dline((struct sockaddr *)&client_p->localClient->ip, GET_SS_FAMILY(&client_p->localClient->ip))) != NULL) { if(aconf->status & CONF_EXEMPTDLINE) continue; @@ -561,7 +621,7 @@ check_dlines(void) { client_p = ptr->data; - if((aconf = find_dline((struct sockaddr *)&client_p->localClient->ip,client_p->localClient->ip.ss_family)) != NULL) + if((aconf = find_dline((struct sockaddr *)&client_p->localClient->ip, GET_SS_FAMILY(&client_p->localClient->ip))) != NULL) { if(aconf->status & CONF_EXEMPTDLINE) continue; @@ -1802,15 +1862,15 @@ free_user(struct User *user, struct Client *client_p) if(user->refcnt < 0 || user->invited.head || user->channel.head) { sendto_realops_snomask(SNO_GENERAL, L_ALL, - "* %#lx user (%s!%s@%s) %#lx %#lx %#lx %lu %d *", - (unsigned long) client_p, + "* %p user (%s!%s@%s) %p %p %p %lu %d *", + client_p, client_p ? client_p-> name : "", client_p->username, client_p->host, - (unsigned long) user, - (unsigned long) user->invited.head, - (unsigned long) user->channel.head, + user, + user->invited.head, + user->channel.head, rb_dlink_list_length(&user->channel), user->refcnt); s_assert(!user->refcnt); @@ -1950,7 +2010,7 @@ close_connection(struct Client *client_p) else ServerStats.is_ni++; - del_from_cli_connid_hash(client_p); + client_release_connids(client_p); if(client_p->localClient->F != NULL) { diff --git a/ircd/dns.c b/ircd/dns.c index 055c6b33..a3a8077e 100644 --- a/ircd/dns.c +++ b/ircd/dns.c @@ -37,16 +37,13 @@ #include "msg.h" #include "hash.h" -#define DNS_IDTABLE_SIZE 0x2000 -#define DNS_STATTABLE_SIZE 0x10 - #define DNS_HOST_IPV4 ((char)'4') #define DNS_HOST_IPV6 ((char)'6') #define DNS_REVERSE_IPV4 ((char)'R') #define DNS_REVERSE_IPV6 ((char)'S') -static void submit_dns(uint16_t uid, char type, const char *addr); -static void submit_dns_stat(uint16_t uid); +static void submit_dns(uint32_t uid, char type, const char *addr); +static void submit_dns_stat(uint32_t uid); struct dnsreq { @@ -60,55 +57,24 @@ struct dnsstatreq void *data; }; -static struct dnsreq querytable[DNS_IDTABLE_SIZE]; -static struct dnsstatreq stattable[DNS_STATTABLE_SIZE]; +/* These serve as a form of sparse array */ +static rb_dictionary *query_dict; +static rb_dictionary *stat_dict; + rb_dlink_list nameservers; +static uint32_t query_id = 0; +static uint32_t stat_id = 0; -static uint16_t -assign_dns_id(void) -{ - static uint16_t id = 1; - int loopcnt = 0; - while(1) - { - if(++loopcnt > DNS_IDTABLE_SIZE) - return 0; - if(id < DNS_IDTABLE_SIZE - 1 || id == 0) - id++; - else - id = 1; - if(querytable[id].callback == NULL) - break; - } - return (id); -} +#define ASSIGN_ID(id) (id++) -static uint8_t -assign_dns_stat_id(void) -{ - static uint8_t id = 1; - int loopcnt = 0; - while(1) - { - if(++loopcnt > DNS_STATTABLE_SIZE) - return 0; - if(id < DNS_STATTABLE_SIZE - 1 || id == 0) - id++; - else - id = 1; - if(stattable[id].callback == NULL) - break; - } - return (id); -} static void -handle_dns_failure(uint16_t xid) +handle_dns_failure(uint32_t xid) { - struct dnsreq *req; + struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); + s_assert(req); - req = &querytable[xid]; if(req->callback == NULL) return; @@ -118,47 +84,49 @@ handle_dns_failure(uint16_t xid) } static void -handle_dns_stat_failure(uint8_t xid) +handle_dns_stat_failure(uint32_t xid) { - struct dnsstatreq *req; - const char *err[] = { "Unknown failure" }; + struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); + s_assert(req); - req = &stattable[xid]; if(req->callback == NULL) return; - req->callback(1, err, 2, req->data); + req->callback(1, NULL, 2, req->data); + req->callback = NULL; + req->data = NULL; +} + +void +cancel_lookup(uint32_t xid) +{ + struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); + s_assert(req); req->callback = NULL; req->data = NULL; } void -cancel_lookup(uint16_t xid) +cancel_dns_stats(uint32_t xid) { - querytable[xid].callback = NULL; - querytable[xid].data = NULL; + struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); + s_assert(req); + req->callback = NULL; + req->data = NULL; } -void -cancel_dns_stats(uint16_t xid) -{ - stattable[xid].callback = NULL; - stattable[xid].data = NULL; -} -uint16_t +uint32_t lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data) { - struct dnsreq *req; + struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); int aft; - uint16_t nid; - check_authd(); - nid = assign_dns_id(); - if((nid = assign_dns_id()) == 0) - return 0; + uint32_t rid = ASSIGN_ID(query_id); - req = &querytable[nid]; + check_authd(); + + rb_dictionary_add(query_dict, RB_UINT_TO_POINTER(rid), req); req->callback = callback; req->data = data; @@ -170,22 +138,20 @@ lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data) #endif aft = 4; - submit_dns(nid, aft == 4 ? DNS_HOST_IPV4 : DNS_HOST_IPV6, hostname); - return (nid); + submit_dns(rid, aft == 4 ? DNS_HOST_IPV4 : DNS_HOST_IPV6, hostname); + return (rid); } -uint16_t +uint32_t lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) { - struct dnsreq *req; + struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); int aft; - uint16_t nid; + uint32_t rid = ASSIGN_ID(query_id); + check_authd(); - if((nid = assign_dns_id()) == 0) - return 0; - - req = &querytable[nid]; + rb_dictionary_add(query_dict, RB_UINT_TO_POINTER(rid), req); req->callback = callback; req->data = data; @@ -197,41 +163,45 @@ lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) #endif aft = 4; - submit_dns(nid, aft == 4 ? DNS_REVERSE_IPV4 : DNS_REVERSE_IPV6, addr); - return (nid); + submit_dns(rid, aft == 4 ? DNS_REVERSE_IPV4 : DNS_REVERSE_IPV6, addr); + return (rid); } -uint8_t +uint32_t get_nameservers(DNSLISTCB callback, void *data) { - struct dnsstatreq *req; - uint8_t nid; + struct dnsstatreq *req = rb_malloc(sizeof(struct dnsstatreq)); + uint32_t qid = ASSIGN_ID(stat_id); + check_authd(); - if((nid = assign_dns_stat_id()) == 0) - return 0; + rb_dictionary_add(stat_dict, RB_UINT_TO_POINTER(qid), req); - req = &stattable[nid]; req->callback = callback; req->data = data; - submit_dns_stat(nid); - return (nid); + submit_dns_stat(qid); + return (qid); } + void dns_results_callback(const char *callid, const char *status, const char *type, const char *results) { struct dnsreq *req; - uint16_t nid; + uint32_t rid; int st; int aft; - long lnid = strtol(callid, NULL, 16); + long lrid = strtol(callid, NULL, 16); - if(lnid > DNS_IDTABLE_SIZE || lnid == 0) + if(lrid > UINT32_MAX) return; - nid = (uint16_t)lnid; - req = &querytable[nid]; + + rid = (uint32_t)lrid; + req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(rid)); + if(req == NULL) + return; + st = (*status == 'O'); aft = *type == '6' || *type == 'S' ? 6 : 4; if(req->callback == NULL) @@ -248,22 +218,26 @@ dns_results_callback(const char *callid, const char *status, const char *type, c aft = AF_INET; req->callback(results, st, aft, req->data); - req->callback = NULL; - req->data = NULL; + + rb_free(req); + rb_dictionary_delete(query_dict, RB_UINT_TO_POINTER(rid)); } void dns_stats_results_callback(const char *callid, const char *status, int resc, const char *resv[]) { struct dnsstatreq *req; - uint8_t nid; - int st, i; - long lnid = strtol(callid, NULL, 16); + uint32_t qid; + int st; + long lqid = strtol(callid, NULL, 16); - if(lnid > DNS_STATTABLE_SIZE || lnid == 0) + if(lqid > UINT32_MAX) return; - nid = (uint8_t)lnid; - req = &stattable[nid]; + + qid = (uint32_t)lqid; + req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(qid)); + + s_assert(req); if(req->callback == NULL) { @@ -286,14 +260,14 @@ dns_stats_results_callback(const char *callid, const char *status, int resc, con } /* Query complete */ - req->callback(resc, resv, st, stattable[nid].data); + req->callback(resc, resv, st, req->data); - req->data = NULL; - req->callback = NULL; + rb_free(req); + rb_dictionary_delete(stat_dict, RB_UINT_TO_POINTER(qid)); } static void -get_nameservers_cb(int resc, const char *resv[], int status, void *data) +stats_results_callback(int resc, const char *resv[], int status, void *data) { if(status == 0) { @@ -316,28 +290,26 @@ get_nameservers_cb(int resc, const char *resv[], int status, void *data) } } + void -init_nameserver_cache(void) +init_dns(void) { - (void)get_nameservers(get_nameservers_cb, NULL); + query_dict = rb_dictionary_create("dns queries", rb_uint32cmp); + stat_dict = rb_dictionary_create("dns stat queries", rb_uint32cmp); + (void)get_nameservers(stats_results_callback, NULL); } -bool +void reload_nameservers(void) { - if(authd_helper == NULL) - { - /* Shit */ - return false; - } - rb_helper_write(authd_helper, "H D"); - init_nameserver_cache(); - return true; + check_authd(); + rb_helper_write(authd_helper, "R D"); + (void)get_nameservers(stats_results_callback, NULL); } static void -submit_dns(uint16_t nid, char type, const char *addr) +submit_dns(uint32_t nid, char type, const char *addr) { if(authd_helper == NULL) { @@ -348,7 +320,7 @@ submit_dns(uint16_t nid, char type, const char *addr) } static void -submit_dns_stat(uint16_t nid) +submit_dns_stat(uint32_t nid) { if(authd_helper == NULL) { diff --git a/ircd/extban.c b/ircd/extban.c index 037dfdb5..69603f14 100644 --- a/ircd/extban.c +++ b/ircd/extban.c @@ -23,7 +23,6 @@ #include "stdinc.h" #include "channel.h" #include "client.h" -#include "common.h" ExtbanFunc extban_table[256] = { NULL }; diff --git a/ircd/hash.c b/ircd/hash.c index 894fe325..0d3fb128 100644 --- a/ircd/hash.c +++ b/ircd/hash.c @@ -27,7 +27,6 @@ #include "s_conf.h" #include "channel.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -40,14 +39,13 @@ #include "rb_dictionary.h" #include "rb_radixtree.h" -struct Dictionary *client_connid_tree = NULL; -struct Dictionary *client_zconnid_tree = NULL; -struct rb_radixtree *client_id_tree = NULL; -struct rb_radixtree *client_name_tree = NULL; +rb_dictionary *client_connid_tree = NULL; +rb_radixtree *client_id_tree = NULL; +rb_radixtree *client_name_tree = NULL; -struct rb_radixtree *channel_tree = NULL; -struct rb_radixtree *resv_tree = NULL; -struct rb_radixtree *hostname_tree = NULL; +rb_radixtree *channel_tree = NULL; +rb_radixtree *resv_tree = NULL; +rb_radixtree *hostname_tree = NULL; /* * look in whowas.c for the missing ...[WW_MAX]; entry @@ -61,7 +59,6 @@ void init_hash(void) { client_connid_tree = rb_dictionary_create("client connid", rb_uint32cmp); - client_zconnid_tree = rb_dictionary_create("client zconnid", rb_uint32cmp); client_id_tree = rb_radixtree_create("client id", NULL); client_name_tree = rb_radixtree_create("client name", irccasecanon); @@ -71,10 +68,10 @@ init_hash(void) hostname_tree = rb_radixtree_create("hostname", irccasecanon); } -u_int32_t +uint32_t fnv_hash_upper(const unsigned char *s, int bits) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; while (*s) { @@ -86,10 +83,10 @@ fnv_hash_upper(const unsigned char *s, int bits) return h; } -u_int32_t +uint32_t fnv_hash(const unsigned char *s, int bits) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; while (*s) { @@ -101,10 +98,10 @@ fnv_hash(const unsigned char *s, int bits) return h; } -u_int32_t +uint32_t fnv_hash_len(const unsigned char *s, int bits, int len) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; const unsigned char *x = s + len; while (*s && s < x) { @@ -116,10 +113,10 @@ fnv_hash_len(const unsigned char *s, int bits, int len) return h; } -u_int32_t +uint32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len) { - u_int32_t h = FNV1_32_INIT; + uint32_t h = FNV1_32_INIT; const unsigned char *x = s + len; while (*s && s < x) { @@ -480,7 +477,7 @@ void clear_resv_hash(void) { struct ConfItem *aconf; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; RB_RADIXTREE_FOREACH(aconf, &iter, resv_tree) { @@ -494,41 +491,19 @@ clear_resv_hash(void) } void -add_to_zconnid_hash(struct Client *client_p) +add_to_cli_connid_hash(struct Client *client_p, uint32_t id) { - rb_dictionary_add(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid), client_p); + rb_dictionary_add(client_connid_tree, RB_UINT_TO_POINTER(id), client_p); } void -del_from_zconnid_hash(struct Client *client_p) +del_from_cli_connid_hash(uint32_t id) { - rb_dictionary_delete(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid)); -} - -void -add_to_cli_connid_hash(struct Client *client_p) -{ - rb_dictionary_add(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid), client_p); -} - -void -del_from_cli_connid_hash(struct Client *client_p) -{ - rb_dictionary_delete(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid)); + rb_dictionary_delete(client_connid_tree, RB_UINT_TO_POINTER(id)); } struct Client * find_cli_connid_hash(uint32_t connid) { - struct Client *target_p; - - target_p = rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid)); - if (target_p != NULL) - return target_p; - - target_p = rb_dictionary_retrieve(client_zconnid_tree, RB_UINT_TO_POINTER(connid)); - if (target_p != NULL) - return target_p; - - return NULL; + return rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid)); } diff --git a/ircd/ircd.c b/ircd/ircd.c index c96edb32..8a16ffa4 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -26,12 +26,11 @@ #include "rb_lib.h" #include "stdinc.h" #include "setup.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd_signal.h" @@ -95,9 +94,6 @@ rb_dlink_list global_serv_list; /* global servers on the network */ rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */ rb_dlink_list oper_list; /* network opers */ -const char *logFileName = LPATH; -const char *pidFileName = PPATH; - char **myargv; bool dorehash = false; bool dorehashbans = false; @@ -105,8 +101,8 @@ bool doremotd = false; bool kline_queued = false; bool server_state_foreground = false; bool opers_see_all_users = false; -bool ssl_ok = false; -bool zlib_ok = true; +bool ircd_ssl_ok = false; +bool ircd_zlib_ok = true; int testing_conf = 0; time_t startup_time; @@ -119,6 +115,28 @@ int split_users; int split_servers; int eob_count; +const char *ircd_paths[IRCD_PATH_COUNT] = { + [IRCD_PATH_PREFIX] = DPATH, + [IRCD_PATH_MODULES] = MODPATH, + [IRCD_PATH_AUTOLOAD_MODULES] = AUTOMODPATH, + [IRCD_PATH_ETC] = ETCPATH, + [IRCD_PATH_LOG] = LOGPATH, + [IRCD_PATH_USERHELP] = UHPATH, + [IRCD_PATH_OPERHELP] = HPATH, + [IRCD_PATH_IRCD_EXEC] = SPATH, + [IRCD_PATH_IRCD_CONF] = CPATH, + [IRCD_PATH_IRCD_MOTD] = MPATH, + [IRCD_PATH_IRCD_LOG] = LPATH, + [IRCD_PATH_IRCD_PID] = PPATH, + [IRCD_PATH_IRCD_OMOTD] = OPATH, + [IRCD_PATH_BANDB] = DBPATH, + [IRCD_PATH_BIN] = BINPATH, + [IRCD_PATH_LIBEXEC] = PKGLIBEXECDIR, +}; + +const char *logFileName = NULL; +const char *pidFileName = NULL; + void ircd_shutdown(const char *reason) { @@ -156,6 +174,7 @@ print_startup(int pid) { int fd; +#ifndef _WIN32 close(1); fd = open("/dev/null", O_RDWR); if (fd == -1) { @@ -166,19 +185,30 @@ print_startup(int pid) fd = dup(fd); if (fd != 1) abort(); - +#endif + inotice("runtime path: %s", rb_path_to_self()); inotice("now running in %s mode from %s as pid %d ...", !server_state_foreground ? "background" : "foreground", ConfigFileEntry.dpath, pid); +#ifndef _WIN32 /* let the parent process know the initialization was successful * -- jilles */ if (!server_state_foreground) - write(0, ".", 1); + { + /* GCC complains on Linux if we don't check the value of write pedantically. + * Technically you're supposed to check the value, yes, but it probably can't fail. + * No, casting to void is of no use to shut the warning up. You HAVE to use the value. + * --Elizfaox + */ + if(write(0, ".", 1) < 1) + abort(); + } if (dup2(1, 0) == -1) abort(); if (dup2(1, 2) == -1) abort(); +#endif } /* @@ -191,7 +221,7 @@ print_startup(int pid) static void init_sys(void) { -#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H) +#if !defined(_WIN32) && defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H) struct rlimit limit; if(!getrlimit(RLIMIT_NOFILE, &limit)) @@ -212,6 +242,7 @@ init_sys(void) static int make_daemon(void) { +#ifndef _WIN32 int pid; int pip[2]; char c; @@ -246,7 +277,7 @@ make_daemon(void) /* fclose(stdin); fclose(stdout); fclose(stderr); */ - +#endif return 0; } @@ -277,13 +308,13 @@ check_rehash(void *unused) */ if(dorehash) { - rehash(1); + rehash(true); dorehash = false; } if(dorehashbans) { - rehash_bans(1); + rehash_bans(); dorehashbans = false; } @@ -358,6 +389,85 @@ initialize_server_capabs(void) default_server_capabs &= ~CAP_ZIP; } +/* + * relocate_paths + * + * inputs - none + * output - none + * side effects - items in ircd_paths[] array are relocated + */ +#ifdef _WIN32 +static void +relocate_paths(void) +{ + char prefix[PATH_MAX], workbuf[PATH_MAX]; + char *p; + + rb_strlcpy(prefix, rb_path_to_self(), sizeof prefix); + + ircd_paths[IRCD_PATH_IRCD_EXEC] = rb_strdup(prefix); + + /* if we're running from inside the source tree, we probably do not want to relocate any other paths */ + if (strstr(prefix, ".libs") != NULL) + return; + + /* prefix = /home/kaniini/ircd/bin/ircd */ + p = strrchr(prefix, RB_PATH_SEPARATOR); + if (rb_unlikely(p == NULL)) + return; + *p = 0; + + /* prefix = /home/kaniini/ircd/bin */ + p = strrchr(prefix, RB_PATH_SEPARATOR); + if (rb_unlikely(p == NULL)) + return; + *p = 0; + + /* prefix = /home/kaniini/ircd */ + ircd_paths[IRCD_PATH_PREFIX] = rb_strdup(prefix); + + /* now that we have our prefix, we can relocate the other paths... */ + snprintf(workbuf, sizeof workbuf, "%s%cmodules", prefix, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_MODULES] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cmodules%cautoload", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_AUTOLOAD_MODULES] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc", prefix, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_ETC] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%clog", prefix, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_LOG] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%chelp%cusers", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_USERHELP] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%chelp%copers", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_OPERHELP] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.conf", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_IRCD_CONF] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.motd", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_IRCD_MOTD] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc%copers.motd", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_IRCD_OMOTD] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc%cban.db", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_BANDB] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.pid", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_IRCD_PID] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%clogs%circd.log", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_IRCD_LOG] = rb_strdup(workbuf); + + snprintf(workbuf, sizeof workbuf, "%s%cbin", prefix, RB_PATH_SEPARATOR); + ircd_paths[IRCD_PATH_BIN] = rb_strdup(workbuf); + ircd_paths[IRCD_PATH_LIBEXEC] = rb_strdup(workbuf); +} +#endif /* * write_pidfile @@ -412,7 +522,7 @@ check_pidfile(const char *filename) if(fgets(buff, 20, fb) != NULL) { pidfromfile = atoi(buff); - if(!kill(pidfromfile, 0)) + if(!rb_kill(pidfromfile, 0)) { printf("ircd: daemon is already running\n"); exit(-1); @@ -539,19 +649,28 @@ charybdis_main(int argc, char *argv[]) { int fd; +#ifndef _WIN32 /* Check to see if the user is running us as root, which is a nono */ if(geteuid() == 0) { fprintf(stderr, "Don't run ircd as root!!!\n"); return -1; } +#endif + +#ifdef _WIN32 + relocate_paths(); +#endif + + logFileName = ircd_paths[IRCD_PATH_IRCD_LOG]; + pidFileName = ircd_paths[IRCD_PATH_IRCD_PID]; + + ConfigFileEntry.dpath = ircd_paths[IRCD_PATH_PREFIX]; + ConfigFileEntry.configfile = ircd_paths[IRCD_PATH_IRCD_CONF]; /* Server configuration file */ + ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ init_sys(); - ConfigFileEntry.dpath = DPATH; - ConfigFileEntry.configfile = CPATH; /* Server configuration file */ - ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ - umask(077); /* better safe than sorry --SRB */ myargv = argv; @@ -607,6 +726,7 @@ charybdis_main(int argc, char *argv[]) if (testing_conf) server_state_foreground = true; +#ifndef _WIN32 /* Make sure fd 0, 1 and 2 are in use -- jilles */ do { @@ -616,6 +736,7 @@ charybdis_main(int argc, char *argv[]) close(fd); else if (fd == -1) exit(1); +#endif /* Check if there is pidfile and daemon already running */ if(!testing_conf) @@ -663,7 +784,7 @@ charybdis_main(int argc, char *argv[]) init_auth(); /* Initialise the auth code */ init_authd(); /* Start up authd. */ - init_nameserver_cache(); /* Get our nameserver cache for STATS a/A */ + init_dns(); /* Start up DNS query system */ privilegeset_set_new("default", "", 0); @@ -679,7 +800,7 @@ charybdis_main(int argc, char *argv[]) init_bandb(); init_ssld(); - rehash_bans(0); + rehash_bans(); initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); @@ -713,10 +834,10 @@ charybdis_main(int argc, char *argv[]) if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list)) { ilog(L_MAIN, "WARNING: Unable to setup SSL."); - ssl_ok = false; + ircd_ssl_ok = false; } else - ssl_ok = true; + ircd_ssl_ok = true; } if (testing_conf) diff --git a/ircd/ircd_lexer.c b/ircd/ircd_lexer.c deleted file mode 100644 index 23a8c135..00000000 --- a/ircd/ircd_lexer.c +++ /dev/null @@ -1,2022 +0,0 @@ - -#line 3 "ircd_lexer.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -typedef uint64_t flex_uint64_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - (yytext_ptr) -= (yy_more_len); \ - yyleng = (yy_size_t) (yy_cp - (yytext_ptr)); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 12 -#define YY_END_OF_BUFFER 13 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[47] = - { 0, - 4, 4, 13, 11, 4, 3, 11, 5, 11, 11, - 6, 9, 9, 4, 3, 0, 7, 5, 10, 0, - 2, 6, 9, 9, 0, 9, 0, 9, 0, 9, - 0, 9, 0, 9, 0, 9, 0, 0, 0, 9, - 0, 1, 0, 1, 8, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 1, 1, - 1, 6, 1, 1, 1, 7, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 10, 1, 11, - 1, 12, 1, 1, 13, 10, 14, 15, 16, 10, - 10, 10, 17, 10, 10, 18, 19, 20, 21, 10, - 10, 10, 10, 10, 22, 10, 10, 10, 10, 10, - 1, 1, 1, 1, 10, 1, 23, 10, 24, 25, - - 26, 10, 10, 10, 27, 10, 10, 28, 29, 30, - 31, 10, 10, 10, 10, 10, 32, 10, 10, 10, - 10, 10, 1, 1, 1, 33, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[34] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 3, 3, - 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1 - } ; - -static yyconst flex_int16_t yy_base[54] = - { 0, - 0, 28, 81, 104, 78, 0, 10, 0, 31, 64, - 56, 0, 20, 24, 0, 12, 104, 0, 104, 22, - 104, 16, 0, 4, 29, 29, 27, 28, 27, 29, - 46, 47, 47, 42, 64, 49, 74, 20, 11, 53, - 18, 17, 8, 7, 0, 104, 85, 88, 91, 94, - 7, 97, 100 - } ; - -static yyconst flex_int16_t yy_def[54] = - { 0, - 47, 47, 46, 46, 46, 48, 49, 50, 46, 46, - 46, 51, 51, 46, 48, 49, 46, 50, 46, 46, - 46, 46, 51, 51, 46, 51, 46, 51, 46, 51, - 46, 51, 46, 51, 46, 51, 46, 52, 53, 51, - 52, 52, 53, 53, 51, 0, 46, 46, 46, 46, - 46, 46, 46 - } ; - -static yyconst flex_int16_t yy_nxt[138] = - { 0, - 4, 5, 6, 7, 8, 4, 9, 10, 11, 23, - 4, 4, 17, 17, 17, 17, 26, 13, 44, 44, - 42, 42, 44, 42, 22, 14, 26, 13, 4, 5, - 6, 7, 8, 4, 9, 10, 11, 19, 4, 4, - 24, 25, 27, 28, 29, 13, 30, 20, 31, 32, - 24, 25, 27, 28, 29, 13, 30, 20, 31, 32, - 33, 34, 35, 36, 22, 37, 40, 38, 45, 21, - 33, 34, 35, 36, 39, 37, 40, 38, 45, 14, - 46, 46, 46, 46, 39, 12, 12, 12, 15, 46, - 15, 16, 16, 16, 18, 46, 18, 41, 46, 41, - - 43, 46, 43, 3, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46 - } ; - -static yyconst flex_int16_t yy_chk[138] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 51, - 1, 1, 7, 7, 16, 16, 24, 1, 44, 43, - 42, 41, 39, 38, 22, 14, 24, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, - 13, 20, 25, 26, 27, 2, 28, 9, 29, 30, - 13, 20, 25, 26, 27, 2, 28, 9, 29, 30, - 31, 32, 33, 34, 11, 35, 36, 35, 40, 10, - 31, 32, 33, 34, 35, 37, 36, 37, 40, 5, - 3, 0, 0, 0, 37, 47, 47, 47, 48, 0, - 48, 49, 49, 49, 50, 0, 50, 52, 0, 52, - - 53, 0, 53, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -static int yy_more_flag = 0; -static int yy_more_len = 0; -#define yymore() ((yy_more_flag) = 1) -#define YY_MORE_ADJ (yy_more_len) -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "ircd_lexer.l" -/* src/ircd_lexer.l - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ -#line 26 "ircd_lexer.l" -#include -#include - -#include - -#include -#include -#include - -#define WE_ARE_MEMORY_C - -#include "stdinc.h" -#include "ircd_defs.h" -#include "common.h" -#include "config.h" -#include "logger.h" -#include "s_conf.h" -#include "newconf.h" - -#include "ircd_parser.h" - -int yylex(void); - -#define MAX_INCLUDE_DEPTH 10 - -YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; -int include_stack_ptr=0; -int lineno = 1; -void ccomment(void); -void cinclude(void); -void hashcomment(void); -int ieof(void); -int lineno_stack[MAX_INCLUDE_DEPTH]; -char conffile_stack[MAX_INCLUDE_DEPTH][IRCD_BUFSIZE]; -char conffilebuf[IRCD_BUFSIZE+1]; -char *current_file = conffilebuf; - -FILE *inc_fbfile_in[MAX_INCLUDE_DEPTH]; - -char linebuf[512]; - -#undef YY_INPUT - -#define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg) - -#define YY_INPUT(buf,result,max_size) \ - if (!(result = conf_fgets(buf, max_size, conf_fbfile_in))) \ - YY_FATAL_ERROR("input in flex scanner failed"); -#line 569 "ircd_lexer.c" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (void ); - -int yyget_debug (void ); - -void yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE yyget_extra (void ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in (void ); - -void yyset_in (FILE * in_str ); - -FILE *yyget_out (void ); - -void yyset_out (FILE * out_str ); - -yy_size_t yyget_leng (void ); - -char *yyget_text (void ); - -int yyget_lineno (void ); - -void yyset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - yy_size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 83 "ircd_lexer.l" - -#line 751 "ircd_lexer.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - (yy_more_len) = 0; - if ( (yy_more_flag) ) - { - (yy_more_len) = (yy_c_buf_p) - (yytext_ptr); - (yy_more_flag) = 0; - } - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 47 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 104 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 84 "ircd_lexer.l" -{ cinclude(); } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 85 "ircd_lexer.l" -{ ccomment(); } - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 86 "ircd_lexer.l" -{ strcpy(linebuf, yytext+1); lineno++; yyless(1); } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 88 "ircd_lexer.l" -; - YY_BREAK -case 5: -YY_RULE_SETUP -#line 89 "ircd_lexer.l" -{ hashcomment(); } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 91 "ircd_lexer.l" -{ yylval.number = atoi(yytext); return NUMBER; } - YY_BREAK -case 7: -/* rule 7 can match eol */ -YY_RULE_SETUP -#line 93 "ircd_lexer.l" -{ - if(yytext[yyleng-2] == '\\') - { - yyless(yyleng-1); /* return last quote */ - yymore(); /* append next string */ - } - else - { - strcpy(yylval.string, yytext + 1); - if(yylval.string[yyleng-2] != '"') - ilog(L_MAIN, "Unterminated character string"); - else - { - int i,j; - yylval.string[yyleng-2] = '\0'; /* remove close - * quote - */ - - for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) - { - if (yylval.string[i] != '\\') - { - yylval.string[j] = yylval.string[i]; - } - else - { - i++; - if (yylval.string[i] == '\0') /* XXX - * should not - * happen - */ - { - ilog(L_MAIN, - "Unterminated character string"); - break; - } - yylval.string[j] = yylval.string[i]; - } - } - yylval.string[j] = '\0'; - return QSTRING; - } - } - } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 139 "ircd_lexer.l" -{ return LOADMODULE; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 140 "ircd_lexer.l" -{ - strcpy(yylval.string, yytext); - yylval.string[yyleng] = '\0'; - return STRING; - } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 146 "ircd_lexer.l" -{ return TWODOTS; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 147 "ircd_lexer.l" -{ return yytext[0]; } - YY_BREAK -case YY_STATE_EOF(INITIAL): -#line 148 "ircd_lexer.l" -{ if (ieof()) yyterminate(); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 149 "ircd_lexer.l" -ECHO; - YY_BREAK -#line 953 "ircd_lexer.c" - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 47 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 47 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 46); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return 0; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n, i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -yy_size_t yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 149 "ircd_lexer.l" - - - -/* C-comment ignoring routine -kre*/ -void ccomment() -{ - int c; - - /* log(L_NOTICE, "got comment"); */ - while (1) - { - while ((c = input()) != '*' && c != EOF) - if (c == '\n') ++lineno; - if (c == '*') - { - while ((c = input()) == '*'); - if (c == '/') - break; - if (c == '\n') ++lineno; - } - if (c == EOF) - { - YY_FATAL_ERROR("EOF in comment"); - /* XXX hack alert this disables - * the stupid unused function warning - * gcc generates - */ - yy_fatal_error("EOF in comment"); - break; - } - } -} - -void cinclude(void) -{ - char *c; - if ((c = strchr(yytext, '<')) == NULL) - *strchr(c = strchr(yytext, '"') + 1, '"') = 0; - else - *strchr(++c, '>') = 0; - - /* do stacking and co. */ - if (include_stack_ptr >= MAX_INCLUDE_DEPTH) - conf_report_error("Includes nested too deep (max is %d)", MAX_INCLUDE_DEPTH); - else - { - FILE *tmp_fbfile_in; - - tmp_fbfile_in = fopen(c, "r"); - - if (tmp_fbfile_in == NULL) - { - /* if its not found in PREFIX, look in ETCPATH */ - char fnamebuf[IRCD_BUFSIZE]; - - snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ETCPATH, c); - tmp_fbfile_in = fopen(fnamebuf, "r"); - - /* wasnt found there either.. error. */ - if(tmp_fbfile_in == NULL) - { - conf_report_error("Include %s: %s.", c, strerror(errno)); - return; - } - } - lineno_stack[include_stack_ptr] = lineno; - lineno = 1; - inc_fbfile_in[include_stack_ptr] = conf_fbfile_in; - strcpy(conffile_stack[include_stack_ptr], c); - current_file = conffile_stack[include_stack_ptr]; - include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; - conf_fbfile_in = tmp_fbfile_in; - yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE)); - } -} - -int ieof(void) -{ - if (include_stack_ptr) - fclose(conf_fbfile_in); - if (--include_stack_ptr < 0) - { - /* We will now exit the lexer - restore init values if we get /rehash - * later and reenter lexer -kre */ - include_stack_ptr = 0; - lineno = 1; - return 1; - } - /* switch buffer */ - yy_delete_buffer(YY_CURRENT_BUFFER); - lineno = lineno_stack[include_stack_ptr]; - conf_fbfile_in = inc_fbfile_in[include_stack_ptr]; - - if(include_stack_ptr) - current_file = conffile_stack[include_stack_ptr]; - else - current_file = conffilebuf; - - yy_switch_to_buffer(include_stack[include_stack_ptr]); - return 0; -} - -/* #-comment style, look for #include */ -#define INCLUDE "#include" - -void hashcomment(void) -{ - if (strlen(yytext) < sizeof(INCLUDE) - 1) - return; - - if (!strncasecmp(yytext, INCLUDE, sizeof(INCLUDE) - 1)) - yyerror("You probably meant '.include', skipping"); -} - diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 43b79f68..ccaf2e99 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -25,8 +25,6 @@ #include #include -#include - #include #include #include @@ -35,8 +33,7 @@ #include "stdinc.h" #include "ircd_defs.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "logger.h" #include "s_conf.h" #include "newconf.h" @@ -55,8 +52,8 @@ void cinclude(void); void hashcomment(void); int ieof(void); int lineno_stack[MAX_INCLUDE_DEPTH]; -char conffile_stack[MAX_INCLUDE_DEPTH][IRCD_BUFSIZE]; -char conffilebuf[IRCD_BUFSIZE+1]; +char conffile_stack[MAX_INCLUDE_DEPTH][BUFSIZE]; +char conffilebuf[BUFSIZE+1]; char *current_file = conffilebuf; FILE *inc_fbfile_in[MAX_INCLUDE_DEPTH]; @@ -69,7 +66,7 @@ char linebuf[512]; #define YY_INPUT(buf,result,max_size) \ if (!(result = conf_fgets(buf, max_size, conf_fbfile_in))) \ - YY_FATAL_ERROR("input in flex scanner failed"); + YY_FATAL_ERROR("input in flex scanner failed"); %} ws [ \t]* @@ -104,9 +101,9 @@ include \.include{ws}(\<.*\>|\".*\") { int i,j; yylval.string[yyleng-2] = '\0'; /* remove close - * quote + * quote */ - + for (j=i=0 ;yylval.string[i] != '\0'; i++,j++) { if (yylval.string[i] != '\\') @@ -116,7 +113,7 @@ include \.include{ws}(\<.*\>|\".*\") else { i++; - if (yylval.string[i] == '\0') /* XXX + if (yylval.string[i] == '\0') /* XXX * should not * happen */ @@ -136,7 +133,7 @@ include \.include{ws}(\<.*\>|\".*\") loadmodule { return LOADMODULE; } -{string} { +{string} { strcpy(yylval.string, yytext); yylval.string[yyleng] = '\0'; return STRING; @@ -151,7 +148,7 @@ loadmodule { return LOADMODULE; } void ccomment() { int c; - + /* log(L_NOTICE, "got comment"); */ while (1) { @@ -160,7 +157,7 @@ void ccomment() if (c == '*') { while ((c = input()) == '*'); - if (c == '/') + if (c == '/') break; if (c == '\n') ++lineno; } @@ -185,21 +182,21 @@ void cinclude(void) else *strchr(++c, '>') = 0; - /* do stacking and co. */ + /* do stacking and co. */ if (include_stack_ptr >= MAX_INCLUDE_DEPTH) conf_report_error("Includes nested too deep (max is %d)", MAX_INCLUDE_DEPTH); else { FILE *tmp_fbfile_in; - + tmp_fbfile_in = fopen(c, "r"); - + if (tmp_fbfile_in == NULL) { - /* if its not found in PREFIX, look in ETCPATH */ - char fnamebuf[IRCD_BUFSIZE]; + /* if its not found in PREFIX, look in IRCD_PATH_ETC */ + char fnamebuf[BUFSIZE]; - snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ETCPATH, c); + snprintf(fnamebuf, sizeof(fnamebuf), "%s%c%s", IRCD_PATH_ETC, RB_PATH_SEPARATOR, c); tmp_fbfile_in = fopen(fnamebuf, "r"); /* wasnt found there either.. error. */ diff --git a/ircd/ircd_parser.c b/ircd/ircd_parser.c deleted file mode 100644 index a20c2eaf..00000000 --- a/ircd/ircd_parser.c +++ /dev/null @@ -1,1817 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "3.0.4" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - - - - -/* Copy the first part of user declarations. */ -#line 5 "ircd_parser.y" /* yacc.c:339 */ - -#include -#include - -#include - -#include -#include -#include -#include -#define WE_ARE_MEMORY_C -#include "stdinc.h" -#include "setup.h" -#include "common.h" -#include "ircd_defs.h" -#include "config.h" -#include "client.h" -#include "modules.h" -#include "newconf.h" - -#define YY_NO_UNPUT - -int yyparse(void); -void yyerror(const char *); -int yylex(void); - -static time_t conf_find_time(char*); - -static struct { - const char * name; - const char * plural; - time_t val; -} ircd_times[] = { - {"second", "seconds", 1}, - {"minute", "minutes", 60}, - {"hour", "hours", 60 * 60}, - {"day", "days", 60 * 60 * 24}, - {"week", "weeks", 60 * 60 * 24 * 7}, - {"fortnight", "fortnights", 60 * 60 * 24 * 14}, - {"month", "months", 60 * 60 * 24 * 7 * 4}, - {"year", "years", 60 * 60 * 24 * 365}, - /* ok-- we now do sizes here too. they aren't times, but - it's close enough */ - {"byte", "bytes", 1}, - {"kb", NULL, 1024}, - {"kbyte", "kbytes", 1024}, - {"kilobyte", "kilebytes", 1024}, - {"mb", NULL, 1024 * 1024}, - {"mbyte", "mbytes", 1024 * 1024}, - {"megabyte", "megabytes", 1024 * 1024}, - {NULL, NULL, 0}, -}; - -time_t conf_find_time(char *name) -{ - int i; - - for (i = 0; ircd_times[i].name; i++) - { - if (strcasecmp(ircd_times[i].name, name) == 0 || - (ircd_times[i].plural && strcasecmp(ircd_times[i].plural, name) == 0)) - return ircd_times[i].val; - } - - return 0; -} - -static struct -{ - const char *word; - int yesno; -} yesno[] = { - {"yes", 1}, - {"no", 0}, - {"true", 1}, - {"false", 0}, - {"on", 1}, - {"off", 0}, - {NULL, 0} -}; - -static int conf_get_yesno_value(char *str) -{ - int i; - - for (i = 0; yesno[i].word; i++) - { - if (strcasecmp(str, yesno[i].word) == 0) - { - return yesno[i].yesno; - } - } - - return -1; -} - -static void free_cur_list(conf_parm_t* list) -{ - if (list->type == CF_STRING || list->type == CF_QSTRING) { - rb_free(list->v.string); - } else if (list->type == CF_FLIST) { - /* Even though CF_FLIST is a flag, comparing with == is valid - * because conf_parm_t.type must be either a type or one flag. - */ - free_cur_list(list->v.list); - } - - if (list->next) { - free_cur_list(list->next); - } - - rb_free(list); -} - - -conf_parm_t * cur_list = NULL; - -static void add_cur_list_cpt(conf_parm_t *new) -{ - if (cur_list == NULL) - { - cur_list = rb_malloc(sizeof(conf_parm_t)); - cur_list->type = CF_FLIST; - cur_list->v.list = new; - } - else - { - new->next = cur_list->v.list; - cur_list->v.list = new; - } -} - -static void add_cur_list(int type, char *str, int number) -{ - conf_parm_t *new; - - new = rb_malloc(sizeof(conf_parm_t)); - new->next = NULL; - new->type = type; - - switch(type) - { - case CF_INT: - case CF_TIME: - case CF_YESNO: - new->v.number = number; - break; - case CF_STRING: - case CF_QSTRING: - new->v.string = rb_strdup(str); - break; - } - - add_cur_list_cpt(new); -} - - - -#line 225 "ircd_parser.c" /* yacc.c:339 */ - -# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "y.tab.h". */ -#ifndef YY_YY_IRCD_PARSER_H_INCLUDED -# define YY_YY_IRCD_PARSER_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - LOADMODULE = 258, - TWODOTS = 259, - QSTRING = 260, - STRING = 261, - NUMBER = 262 - }; -#endif -/* Tokens. */ -#define LOADMODULE 258 -#define TWODOTS 259 -#define QSTRING 260 -#define STRING 261 -#define NUMBER 262 - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE -{ -#line 164 "ircd_parser.y" /* yacc.c:355 */ - - int number; - char string[IRCD_BUFSIZE + 1]; - conf_parm_t * conf_parm; - -#line 285 "ircd_parser.c" /* yacc.c:355 */ -}; - -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_IRCD_PARSER_H_INCLUDED */ - -/* Copy the second part of user declarations. */ - -#line 302 "ircd_parser.c" /* yacc.c:358 */ - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#else -typedef signed char yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) -# endif -# endif -# ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) -#else -# define YYUSE(E) /* empty */ -#endif - -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS -# include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (0) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 42 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 13 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 17 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 29 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 45 - -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 262 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 12, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, - 2, 11, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 8, 2, 9, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7 -}; - -#if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 183, 183, 184, 185, 188, 189, 193, 192, 202, - 201, 212, 213, 216, 224, 225, 228, 232, 252, 258, - 264, 270, 293, 292, 307, 308, 309, 311, 323, 327 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || 0 -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "LOADMODULE", "TWODOTS", "QSTRING", - "STRING", "NUMBER", "'{'", "'}'", "';'", "'='", "','", "$accept", "conf", - "conf_item", "block", "$@1", "$@2", "block_items", "block_item", - "itemlist", "single", "oneitem", "loadmodule", "$@3", "qstring", - "string", "number", "timespec", YY_NULLPTR -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 123, 125, - 59, 61, 44 -}; -# endif - -#define YYPACT_NINF -33 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-33))) - -#define YYTABLE_NINF -3 - -#define yytable_value_is_error(Yytable_value) \ - 0 - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int8 yypact[] = -{ - 11, -33, 13, -33, 2, -33, -33, -33, -33, 16, - -33, -33, 18, -33, 19, 22, 24, -33, 9, -33, - 23, 22, 20, -33, -1, 14, -33, -33, 15, -33, - 29, -33, -33, 22, 17, 27, -33, -1, -1, -33, - 22, 17, -33, -33, -33 -}; - - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 4, 0, 1, 0, 25, 3, 5, 6, 7, - 22, 24, 0, 9, 0, 0, 0, 23, 0, 12, - 0, 0, 0, 11, 0, 0, 8, 26, 0, 15, - 16, 18, 21, 20, 19, 0, 13, 0, 0, 27, - 29, 28, 10, 14, 17 -}; - - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -33, -33, -33, -33, -33, -33, 21, -17, -33, 3, - 1, -33, -33, 32, -2, -32, -31 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 2, 6, 7, 12, 16, 18, 19, 28, 29, - 30, 8, 14, 31, 20, 33, 34 -}; - - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int8 yytable[] = -{ - 9, 23, 40, 41, 11, 5, 27, 10, 23, 40, - 41, -2, 1, 3, -2, 5, 4, -2, 22, 5, - 5, 11, 32, 35, 27, 36, 15, 37, 5, 17, - 26, 39, 21, 38, 24, 32, 32, 42, 39, 44, - 43, 13, 25 -}; - -static const yytype_uint8 yycheck[] = -{ - 2, 18, 34, 34, 5, 6, 7, 5, 25, 41, - 41, 0, 1, 0, 3, 6, 3, 6, 9, 6, - 6, 5, 24, 9, 7, 10, 8, 12, 6, 10, - 10, 33, 8, 4, 11, 37, 38, 10, 40, 38, - 37, 9, 21 -}; - - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 1, 14, 0, 3, 6, 15, 16, 24, 27, - 5, 5, 17, 26, 25, 8, 18, 10, 19, 20, - 27, 8, 9, 20, 11, 19, 10, 7, 21, 22, - 23, 26, 27, 28, 29, 9, 10, 12, 4, 27, - 28, 29, 10, 22, 23 -}; - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 13, 14, 14, 14, 15, 15, 17, 16, 18, - 16, 19, 19, 20, 21, 21, 22, 22, 23, 23, - 23, 23, 25, 24, 26, 27, 28, 29, 29, 29 -}; - - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 0, 2, 1, 1, 1, 0, 6, 0, - 7, 2, 1, 4, 3, 1, 1, 3, 1, 1, - 1, 1, 0, 4, 1, 1, 1, 2, 2, 2 -}; - - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - - - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - - -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ - -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -{ - FILE *yyo = yyoutput; - YYUSE (yyo); - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - YYUSE (yytype); -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -{ - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) -{ - unsigned long int yylno = yyrline[yyrule]; - int yynrhs = yyr2[yyrule]; - int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -{ - YYUSE (yyvaluep); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - -/*----------. -| yyparse. | -`----------*/ - -int -yyparse (void) -{ - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (); - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 7: -#line 193 "ircd_parser.y" /* yacc.c:1646 */ - { - conf_start_block((yyvsp[0].string), NULL); - } -#line 1402 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 8: -#line 197 "ircd_parser.y" /* yacc.c:1646 */ - { - if (conf_cur_block) - conf_end_block(conf_cur_block); - } -#line 1411 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 9: -#line 202 "ircd_parser.y" /* yacc.c:1646 */ - { - conf_start_block((yyvsp[-1].string), (yyvsp[0].string)); - } -#line 1419 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 10: -#line 206 "ircd_parser.y" /* yacc.c:1646 */ - { - if (conf_cur_block) - conf_end_block(conf_cur_block); - } -#line 1428 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 13: -#line 217 "ircd_parser.y" /* yacc.c:1646 */ - { - conf_call_set(conf_cur_block, (yyvsp[-3].string), cur_list); - free_cur_list(cur_list); - cur_list = NULL; - } -#line 1438 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 16: -#line 229 "ircd_parser.y" /* yacc.c:1646 */ - { - add_cur_list_cpt((yyvsp[0].conf_parm)); - } -#line 1446 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 17: -#line 233 "ircd_parser.y" /* yacc.c:1646 */ - { - /* "1 .. 5" meaning 1,2,3,4,5 - only valid for integers */ - if ((yyvsp[-2].conf_parm)->type != CF_INT || (yyvsp[0].conf_parm)->type != CF_INT) - { - conf_report_error("Both arguments in '..' notation must be integers."); - break; - } - else - { - int i; - - for (i = (yyvsp[-2].conf_parm)->v.number; i <= (yyvsp[0].conf_parm)->v.number; i++) - { - add_cur_list(CF_INT, 0, i); - } - } - } -#line 1468 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 18: -#line 253 "ircd_parser.y" /* yacc.c:1646 */ - { - (yyval.conf_parm) = rb_malloc(sizeof(conf_parm_t)); - (yyval.conf_parm)->type = CF_QSTRING; - (yyval.conf_parm)->v.string = rb_strdup((yyvsp[0].string)); - } -#line 1478 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 19: -#line 259 "ircd_parser.y" /* yacc.c:1646 */ - { - (yyval.conf_parm) = rb_malloc(sizeof(conf_parm_t)); - (yyval.conf_parm)->type = CF_TIME; - (yyval.conf_parm)->v.number = (yyvsp[0].number); - } -#line 1488 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 20: -#line 265 "ircd_parser.y" /* yacc.c:1646 */ - { - (yyval.conf_parm) = rb_malloc(sizeof(conf_parm_t)); - (yyval.conf_parm)->type = CF_INT; - (yyval.conf_parm)->v.number = (yyvsp[0].number); - } -#line 1498 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 21: -#line 271 "ircd_parser.y" /* yacc.c:1646 */ - { - /* a 'string' could also be a yes/no value .. - so pass it as that, if so */ - int val = conf_get_yesno_value((yyvsp[0].string)); - - (yyval.conf_parm) = rb_malloc(sizeof(conf_parm_t)); - - if (val != -1) - { - (yyval.conf_parm)->type = CF_YESNO; - (yyval.conf_parm)->v.number = val; - } - else - { - (yyval.conf_parm)->type = CF_STRING; - (yyval.conf_parm)->v.string = rb_strdup((yyvsp[0].string)); - } - } -#line 1521 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 22: -#line 293 "ircd_parser.y" /* yacc.c:1646 */ - { - char *m_bn; - m_bn = rb_basename((char *) (yyvsp[0].string)); - - if (findmodule_byname(m_bn) == -1) - { - load_one_module((yyvsp[0].string), MAPI_ORIGIN_EXTENSION, 0); - } - - rb_free(m_bn); - } -#line 1537 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 24: -#line 307 "ircd_parser.y" /* yacc.c:1646 */ - { strcpy((yyval.string), (yyvsp[0].string)); } -#line 1543 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 25: -#line 308 "ircd_parser.y" /* yacc.c:1646 */ - { strcpy((yyval.string), (yyvsp[0].string)); } -#line 1549 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 26: -#line 309 "ircd_parser.y" /* yacc.c:1646 */ - { (yyval.number) = (yyvsp[0].number); } -#line 1555 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 27: -#line 312 "ircd_parser.y" /* yacc.c:1646 */ - { - time_t t; - - if ((t = conf_find_time((yyvsp[0].string))) == 0) - { - conf_report_error("Unrecognised time type/size '%s'", (yyvsp[0].string)); - t = 1; - } - - (yyval.number) = (yyvsp[-1].number) * t; - } -#line 1571 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 28: -#line 324 "ircd_parser.y" /* yacc.c:1646 */ - { - (yyval.number) = (yyvsp[-1].number) + (yyvsp[0].number); - } -#line 1579 "ircd_parser.c" /* yacc.c:1646 */ - break; - - case 29: -#line 328 "ircd_parser.y" /* yacc.c:1646 */ - { - (yyval.number) = (yyvsp[-1].number) + (yyvsp[0].number); - } -#line 1587 "ircd_parser.c" /* yacc.c:1646 */ - break; - - -#line 1591 "ircd_parser.c" /* yacc.c:1646 */ - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* Now 'shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - return yyresult; -} diff --git a/ircd/ircd_parser.h b/ircd/ircd_parser.h deleted file mode 100644 index 5247dfc5..00000000 --- a/ircd/ircd_parser.h +++ /dev/null @@ -1,86 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef YY_YY_IRCD_PARSER_H_INCLUDED -# define YY_YY_IRCD_PARSER_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - LOADMODULE = 258, - TWODOTS = 259, - QSTRING = 260, - STRING = 261, - NUMBER = 262 - }; -#endif -/* Tokens. */ -#define LOADMODULE 258 -#define TWODOTS 259 -#define QSTRING 260 -#define STRING 261 -#define NUMBER 262 - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE -{ -#line 164 "ircd_parser.y" /* yacc.c:1909 */ - - int number; - char string[IRCD_BUFSIZE + 1]; - conf_parm_t * conf_parm; - -#line 74 "ircd_parser.h" /* yacc.c:1909 */ -}; - -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_IRCD_PARSER_H_INCLUDED */ diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index ca76d9d9..900f5ea5 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -6,8 +6,6 @@ #include #include -#include - #include #include #include @@ -15,9 +13,8 @@ #define WE_ARE_MEMORY_C #include "stdinc.h" #include "setup.h" -#include "common.h" #include "ircd_defs.h" -#include "config.h" +#include "defaults.h" #include "client.h" #include "modules.h" #include "newconf.h" @@ -163,7 +160,7 @@ static void add_cur_list(int type, char *str, int number) %union { int number; - char string[IRCD_BUFSIZE + 1]; + char string[BUFSIZE + 1]; conf_parm_t * conf_parm; } diff --git a/ircd/ircd_signal.c b/ircd/ircd_signal.c index b6017295..0b3ffdb6 100644 --- a/ircd/ircd_signal.c +++ b/ircd/ircd_signal.c @@ -27,6 +27,11 @@ #include "client.h" #include "send.h" +#ifndef _WIN32 + +#include +#include + /* * dummy_handler - don't know if this is really needed but if alarm is still * being used we probably will @@ -171,3 +176,17 @@ setup_signals() sigprocmask(SIG_UNBLOCK, &sigs, NULL); } + +#else +void +setup_signals() +{ +/* this is a stub for mingw32 */ +} + +void +setup_reboot_signals() +{ +/* this is a stub for mingw32 */ +} +#endif diff --git a/ircd/listener.c b/ircd/listener.c index b191333f..aeff94e9 100644 --- a/ircd/listener.c +++ b/ircd/listener.c @@ -106,7 +106,7 @@ static uint16_t get_listener_port(const struct Listener *listener) { #ifdef RB_IPV6 - if(listener->addr.ss_family == AF_INET6) + if(GET_SS_FAMILY(&listener->addr) == AF_INET6) return ntohs(((const struct sockaddr_in6 *)&listener->addr)->sin6_port); else #endif @@ -180,7 +180,7 @@ inetport(struct Listener *listener) F = rb_socket(GET_SS_FAMILY(&listener->addr), SOCK_STREAM, 0, "Listener socket"); #ifdef RB_IPV6 - if(listener->addr.ss_family == AF_INET6) + if(GET_SS_FAMILY(&listener->addr) == AF_INET6) { struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&listener->addr; if(!IN6_ARE_ADDR_EQUAL(&in6->sin6_addr, &in6addr_any)) @@ -279,10 +279,10 @@ find_listener(struct rb_sockaddr_storage *addr) for (listener = ListenerPollList; listener; listener = listener->next) { - if(addr->ss_family != listener->addr.ss_family) + if(GET_SS_FAMILY(addr) != GET_SS_FAMILY(&listener->addr)) continue; - switch(addr->ss_family) + switch(GET_SS_FAMILY(addr)) { case AF_INET: { @@ -342,7 +342,7 @@ add_listener(int port, const char *vhost_ip, int family, int ssl, int defer_acce if(port == 0) return; memset(&vaddr, 0, sizeof(vaddr)); - vaddr.ss_family = family; + SET_SS_FAMILY(&vaddr, family); if(vhost_ip != NULL) { @@ -481,7 +481,7 @@ add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, str free_client(new_client); return; } - new_client->localClient->ssl_ctl = start_ssld_accept(F, xF[1], new_client->localClient->connid); /* this will close F for us */ + new_client->localClient->ssl_ctl = start_ssld_accept(F, xF[1], connid_get(new_client)); /* this will close F for us */ if(new_client->localClient->ssl_ctl == NULL) { free_client(new_client); @@ -523,7 +523,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi static time_t last_oper_notice = 0; int len; - if(listener->ssl && (!ssl_ok || !get_ssld_count())) + if(listener->ssl && (!ircd_ssl_ok || !get_ssld_count())) { rb_close(F); return 0; diff --git a/ircd/match.c b/ircd/match.c index dc4d0f88..66ffe236 100644 --- a/ircd/match.c +++ b/ircd/match.c @@ -18,7 +18,7 @@ * */ #include "stdinc.h" -#include "config.h" +#include "defaults.h" #include "client.h" #include "ircd.h" #include "match.h" @@ -308,13 +308,13 @@ match_esc(const char *mask, const char *name) return 0; } -int comp_with_mask(void *addr, void *dest, u_int mask) +int comp_with_mask(void *addr, void *dest, unsigned int mask) { if (memcmp(addr, dest, mask / 8) == 0) { int n = mask / 8; int m = ((-1) << (8 - (mask % 8))); - if (mask % 8 == 0 || (((u_char *) addr)[n] & m) == (((u_char *) dest)[n] & m)) + if (mask % 8 == 0 || (((unsigned char *) addr)[n] & m) == (((unsigned char *) dest)[n] & m)) { return (1); } @@ -322,7 +322,7 @@ int comp_with_mask(void *addr, void *dest, u_int mask) return (0); } -int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask) +int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, unsigned int mask) { void *iaddr = NULL; void *idest = NULL; diff --git a/ircd/modules.c b/ircd/modules.c index 8175c624..2173dd69 100644 --- a/ircd/modules.c +++ b/ircd/modules.c @@ -39,6 +39,10 @@ #include +#ifndef LT_MODULE_EXT +# error "Charybdis requires loadable module support." +#endif + struct module **modlist = NULL; static const char *core_module_table[] = { @@ -125,8 +129,8 @@ modules_init(void) mod_add_cmd(&modrestart_msgtab); /* Add the default paths we look in to the module system --nenolod */ - mod_add_path(MODPATH); - mod_add_path(AUTOMODPATH); + mod_add_path(ircd_paths[IRCD_PATH_MODULES]); + mod_add_path(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]); } /* mod_find_path() @@ -202,12 +206,20 @@ int findmodule_byname(const char *name) { int i; + char name_ext[PATH_MAX + 1]; + + rb_strlcpy(name_ext, name, sizeof name_ext); + rb_strlcat(name_ext, LT_MODULE_EXT, sizeof name_ext); for (i = 0; i < num_mods; i++) { if(!irccmp(modlist[i]->name, name)) return i; + + if(!irccmp(modlist[i]->name, name_ext)) + return i; } + return -1; } @@ -223,7 +235,7 @@ load_all_modules(int warn) DIR *system_module_dir = NULL; struct dirent *ldirent = NULL; char module_fq_name[PATH_MAX + 1]; - int len; + size_t module_ext_len = strlen(LT_MODULE_EXT); modules_init(); @@ -231,20 +243,22 @@ load_all_modules(int warn) max_mods = MODS_INCREMENT; - system_module_dir = opendir(AUTOMODPATH); + system_module_dir = opendir(ircd_paths[IRCD_PATH_AUTOLOAD_MODULES]); if(system_module_dir == NULL) { - ilog(L_MAIN, "Could not load modules from %s: %s", AUTOMODPATH, strerror(errno)); + ilog(L_MAIN, "Could not load modules from %s: %s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], strerror(errno)); return; } while ((ldirent = readdir(system_module_dir)) != NULL) { + size_t len; + len = strlen(ldirent->d_name); - if((len > 3) && !strcmp(ldirent->d_name+len-3, ".la")) + if(len > module_ext_len && !strcasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT)) { - (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name); + (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name); (void) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, 0); } @@ -267,14 +281,14 @@ load_core_modules(int warn) for (i = 0; core_module_table[i]; i++) { - snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH, - core_module_table[i], ".la"); + snprintf(module_name, sizeof(module_name), "%s%c%s%s", ircd_paths[IRCD_PATH_MODULES], RB_PATH_SEPARATOR, + core_module_table[i], LT_MODULE_EXT); if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, 1) == -1) { ilog(L_MAIN, - "Error loading core module %s%s: terminating ircd", - core_module_table[i], ".la"); + "Error loading core module %s: terminating ircd", + core_module_table[i]); exit(0); } } @@ -292,7 +306,6 @@ load_one_module(const char *path, int origin, int coremodule) char modpath[PATH_MAX]; rb_dlink_node *pathst; const char *mpath; - struct stat statbuf; if (server_state_foreground) @@ -308,7 +321,7 @@ load_one_module(const char *path, int origin, int coremodule) { mpath = pathst->data; - snprintf(modpath, sizeof(modpath), "%s/%s", mpath, path); + snprintf(modpath, sizeof(modpath), "%s/%s%s", mpath, path, LT_MODULE_EXT); if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL)) { if(stat(modpath, &statbuf) == 0) @@ -809,7 +822,7 @@ load_a_module(const char *path, int warn, int origin, int core) mod_basename = rb_basename(path); - tmpptr = lt_dlopen(path); + tmpptr = lt_dlopenext(path); if(tmpptr == NULL) { @@ -822,7 +835,6 @@ load_a_module(const char *path, int warn, int origin, int core) return -1; } - /* * _mheader is actually a struct mapi_mheader_*, but mapi_version * is always the first member of this structure, so we treate it @@ -1027,11 +1039,11 @@ load_a_module(const char *path, int warn, int origin, int core) } sendto_realops_snomask(SNO_GENERAL, L_ALL, - "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx", + "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at %p", mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, - (unsigned long) tmpptr); - ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at 0x%lx", - mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, (unsigned long) tmpptr); + (void *) tmpptr); + ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d; origin: %s; description: \"%s\"] loaded at %p", + mod_basename, ver, MAPI_VERSION(*mapi_version), o, description, (void *) tmpptr); } rb_free(mod_basename); return 0; diff --git a/ircd/monitor.c b/ircd/monitor.c index 2a9bd3e6..ff15bcd4 100644 --- a/ircd/monitor.c +++ b/ircd/monitor.c @@ -37,7 +37,7 @@ #include "send.h" #include "rb_radixtree.h" -static struct rb_radixtree *monitor_tree; +static rb_radixtree *monitor_tree; void init_monitor(void) diff --git a/ircd/msgbuf.c b/ircd/msgbuf.c index 3aae2157..50538d27 100644 --- a/ircd/msgbuf.c +++ b/ircd/msgbuf.c @@ -35,7 +35,6 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) char *ch; char *parv[MAXPARA]; size_t n_para; - int i; /* skip any leading spaces */ for (ch = line; *ch && *ch == ' '; ch++) @@ -108,7 +107,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) return 1; msgbuf->cmd = parv[0]; - for (i = 0; i < n_para; i++) + for (size_t i = 0; i < n_para; i++) msgbuf_append_para(msgbuf, parv[i]); return 0; @@ -117,9 +116,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line) static int msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - - for (i = 0; i < msgbuf->n_tags; i++) + for (size_t i = 0; i < msgbuf->n_tags; i++) { if ((msgbuf->tags[i].capmask & capmask) != 0) return 1; @@ -131,14 +128,12 @@ msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask) static void msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - if (!msgbuf_has_matching_tags(msgbuf, capmask)) return; *buf = '@'; - for (i = 0; i < msgbuf->n_tags; i++) + for (size_t i = 0; i < msgbuf->n_tags; i++) { if ((msgbuf->tags[i].capmask & capmask) == 0) continue; @@ -162,8 +157,6 @@ msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned in void msgbuf_unparse_prefix(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - memset(buf, 0, buflen); if (msgbuf->n_tags > 0) @@ -187,11 +180,9 @@ msgbuf_unparse_prefix(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int msgbuf_unparse(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask) { - int i; - msgbuf_unparse_prefix(buf, buflen, msgbuf, capmask); - for (i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++) + for (size_t i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++) { if (i == (msgbuf->n_para - 1)) { diff --git a/ircd/newconf.c b/ircd/newconf.c index ccc7afc0..7a726db3 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -10,7 +10,6 @@ #include "newconf.h" #include "ircd_defs.h" -#include "common.h" #include "logger.h" #include "s_conf.h" #include "s_user.h" @@ -239,7 +238,7 @@ conf_set_serverinfo_vhost(void *data) { if(rb_inet_pton(AF_INET, (char *) data, &ServerInfo.ip.sin_addr) <= 0) { - conf_report_error("Invalid netmask for server IPv4 vhost (%s)", (char *) data); + conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data); return; } ServerInfo.ip.sin_family = AF_INET; @@ -252,7 +251,7 @@ conf_set_serverinfo_vhost6(void *data) #ifdef RB_IPV6 if(rb_inet_pton(AF_INET6, (char *) data, &ServerInfo.ip6.sin6_addr) <= 0) { - conf_report_error("Invalid netmask for server IPv6 vhost (%s)", (char *) data); + conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data); return; } @@ -1325,7 +1324,7 @@ conf_set_connect_vhost(void *data) { if(rb_inet_pton_sock(data, (struct sockaddr *)&yy_server->my_ipnum) <= 0) { - conf_report_error("Invalid netmask for server vhost (%s)", + conf_report_error("Invalid IP address for server connect vhost (%s)", (char *) data); return; } @@ -2030,10 +2029,10 @@ void conf_report_error(const char *fmt, ...) { va_list ap; - char msg[IRCD_BUFSIZE + 1] = { 0 }; + char msg[BUFSIZE + 1] = { 0 }; va_start(ap, fmt); - vsnprintf(msg, IRCD_BUFSIZE, fmt, ap); + vsnprintf(msg, BUFSIZE, fmt, ap); va_end(ap); if (testing_conf) @@ -2050,10 +2049,10 @@ void conf_report_warning(const char *fmt, ...) { va_list ap; - char msg[IRCD_BUFSIZE + 1] = { 0 }; + char msg[BUFSIZE + 1] = { 0 }; va_start(ap, fmt); - vsnprintf(msg, IRCD_BUFSIZE, fmt, ap); + vsnprintf(msg, BUFSIZE, fmt, ap); va_end(ap); if (testing_conf) @@ -2265,7 +2264,6 @@ remove_conf_item(const char *topconf, const char *name) static struct ConfEntry conf_serverinfo_table[] = { { "description", CF_QSTRING, NULL, 0, &ServerInfo.description }, - { "hub", CF_YESNO, NULL, 0, &ServerInfo.hub }, { "network_name", CF_QSTRING, conf_set_serverinfo_network_name, 0, NULL }, { "name", CF_QSTRING, conf_set_serverinfo_name, 0, NULL }, diff --git a/ircd/operhash.c b/ircd/operhash.c index d627bbf1..a8348cb2 100644 --- a/ircd/operhash.c +++ b/ircd/operhash.c @@ -37,7 +37,7 @@ #include "operhash.h" #include "rb_radixtree.h" -static struct rb_radixtree *operhash_tree = NULL; +static rb_radixtree *operhash_tree = NULL; struct operhash_entry { diff --git a/ircd/packet.c b/ircd/packet.c index 2e838453..ef8de04d 100644 --- a/ircd/packet.c +++ b/ircd/packet.c @@ -25,7 +25,6 @@ #include "s_conf.h" #include "s_serv.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "parse.h" #include "packet.h" diff --git a/ircd/parse.c b/ircd/parse.c index b1e57bff..74c5fddb 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -27,7 +27,6 @@ #include "parse.h" #include "client.h" #include "channel.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -42,11 +41,8 @@ #include "packet.h" #include "s_assert.h" -struct Dictionary *cmd_dict = NULL; -struct Dictionary *alias_dict = NULL; - -/* parv[0] is not used, and parv[LAST] == NULL */ -static char *para[MAXPARA + 2]; +rb_dictionary *cmd_dict = NULL; +rb_dictionary *alias_dict = NULL; static void cancel_clients(struct Client *, struct Client *); static void remove_unknown(struct Client *, const char *, char *); @@ -82,7 +78,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) { struct Client *from = client_p; char *end; - int i = 1, res; + int res; int numeric = 0; struct Message *mptr; struct MsgBuf msgbuf; @@ -107,7 +103,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) return; } - if (msgbuf.origin != NULL) + if (msgbuf.origin != NULL && IsServer(client_p)) { from = find_client(msgbuf.origin); @@ -146,6 +142,15 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) struct alias_entry *aptr = rb_dictionary_retrieve(alias_dict, msgbuf.cmd); if (aptr != NULL) { + if (msgbuf.n_para < 2) + { + sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), + me.name, + EmptyString(client_p->name) ? "*" : client_p->name, + msgbuf.cmd); + return; + } + do_alias(aptr, client_p, reconstruct_parv(msgbuf.n_para - 1, msgbuf.para + 1)); return; } @@ -177,7 +182,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) /* Its expected this nasty code can be removed * or rewritten later if still needed. */ - if((unsigned long) (p + 8) > (unsigned long) end) + if((p + 8) > end) { for (; p <= end; p++) { @@ -240,13 +245,13 @@ handle_command(struct Message *mptr, struct MsgBuf *msgbuf_p, struct Client *cli sendto_realops_snomask(SNO_GENERAL, L_ALL, "Dropping server %s due to (invalid) command '%s'" - " with only %zu arguments (expecting %d).", + " with only %zu arguments (expecting %zu).", client_p->name, mptr->cmd, msgbuf_p->n_para, ehandler.min_para); ilog(L_SERVER, - "Insufficient parameters (%zu < %d) for command '%s' from %s.", + "Insufficient parameters (%zu < %zu) for command '%s' from %s.", msgbuf_p->n_para, ehandler.min_para, mptr->cmd, client_p->name); snprintf(squitreason, sizeof squitreason, - "Insufficient parameters (%zu < %d) for command '%s'", + "Insufficient parameters (%zu < %zu) for command '%s'", msgbuf_p->n_para, ehandler.min_para, mptr->cmd); exit_client(client_p, client_p, client_p, squitreason); return (-1); @@ -272,7 +277,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so ehandler = mptr->handlers[ENCAP_HANDLER]; handler = ehandler.handler; - if(parc < ehandler.min_para || + if((size_t)parc < ehandler.min_para || (ehandler.min_para && EmptyString(parv[ehandler.min_para - 1]))) return; diff --git a/ircd/restart.c b/ircd/restart.c index 499b291d..f91f9293 100644 --- a/ircd/restart.c +++ b/ircd/restart.c @@ -37,11 +37,11 @@ extern char **myargv; void restart(const char *mesg) { - static int was_here = NO; /* redundant due to restarting flag below */ + static bool was_here = false; /* redundant due to restarting flag below */ if(was_here) abort(); - was_here = YES; + was_here = true; ilog(L_MAIN, "Restarting Server because: %s", mesg); @@ -72,10 +72,10 @@ server_reboot(void) close(i); unlink(pidFileName); - execv(SPATH, (void *)myargv); + execv(ircd_paths[IRCD_PATH_IRCD_EXEC], (void *)myargv); /* use this if execv of SPATH fails */ - snprintf(path, sizeof(path), "%s/bin/ircd", ConfigFileEntry.dpath); + snprintf(path, sizeof(path), "%s%cbin%circd", ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); execv(path, (void *)myargv); exit(-1); diff --git a/ircd/s_auth.c b/ircd/s_auth.c index 86ce272f..c30b9e14 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -34,11 +34,10 @@ * --Bleep Thomas Helvey */ #include "stdinc.h" -#include "config.h" +#include "defaults.h" #include "s_auth.h" #include "s_conf.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" @@ -269,7 +268,7 @@ start_auth_query(struct AuthRequest *auth) if(IsAnyDead(auth->client)) return 0; - family = auth->client->localClient->ip.ss_family; + family = GET_SS_FAMILY(&auth->client->localClient->ip); if((F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL) { ilog_error("creating auth stream socket"); @@ -302,7 +301,7 @@ start_auth_query(struct AuthRequest *auth) /* XXX mangle_mapped_sockaddr((struct sockaddr *)&localaddr); */ #ifdef RB_IPV6 - if(localaddr.ss_family == AF_INET6) + if(GET_SS_FAMILY(&localaddr) == AF_INET6) { auth->lport = ntohs(((struct sockaddr_in6 *)&localaddr)->sin6_port); ((struct sockaddr_in6 *)&localaddr)->sin6_port = 0; @@ -316,7 +315,7 @@ start_auth_query(struct AuthRequest *auth) destaddr = auth->client->localClient->ip; #ifdef RB_IPV6 - if(localaddr.ss_family == AF_INET6) + if(GET_SS_FAMILY(&localaddr) == AF_INET6) { auth->rport = ntohs(((struct sockaddr_in6 *)&destaddr)->sin6_port); ((struct sockaddr_in6 *)&destaddr)->sin6_port = htons(113); diff --git a/ircd/s_conf.c b/ircd/s_conf.c index aaa9f867..87520538 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -32,7 +32,6 @@ #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -169,7 +168,7 @@ free_conf(struct ConfItem *aconf) * inputs - pointer to client * output - 0 = Success * NOT_AUTHORISED (-1) = Access denied (no I line match) - * SOCKET_ERROR (-2) = Bad socket. + * I_SOCKET_ERROR (-2) = Bad socket. * I_LINE_FULL (-3) = I-line is full * TOO_MANY (-4) = Too many connections from hostname * BANNED_CLIENT (-5) = K-lined @@ -190,7 +189,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern switch (i) { - case SOCKET_ERROR: + case I_SOCKET_ERROR: exit_client(client_p, source_p, &me, "Socket Error"); break; @@ -261,7 +260,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern { int port = -1; #ifdef RB_IPV6 - if(source_p->localClient->ip.ss_family == AF_INET6) + if(GET_SS_FAMILY(&source_p->localClient->ip) == AF_INET6) port = ntohs(((struct sockaddr_in6 *)&source_p->localClient->listener->addr)->sin6_port); else #endif @@ -394,7 +393,7 @@ find_address_conf_by_client(struct Client *client_p, const char *username) aconf = find_address_conf(client_p->host, client_p->sockhost, client_p->username, client_p->username, (struct sockaddr *) &client_p->localClient->ip, - client_p->localClient->ip.ss_family, + GET_SS_FAMILY(&client_p->localClient->ip), client_p->localClient->auth_user); } else @@ -404,7 +403,7 @@ find_address_conf_by_client(struct Client *client_p, const char *username) aconf = find_address_conf(client_p->host, client_p->sockhost, non_ident, client_p->username, (struct sockaddr *) &client_p->localClient->ip, - client_p->localClient->ip.ss_family, + GET_SS_FAMILY(&client_p->localClient->ip), client_p->localClient->auth_user); } return aconf; @@ -636,10 +635,10 @@ attach_conf(struct Client *client_p, struct ConfItem *aconf) * as a result of an operator issuing this command, else assume it has been * called as a result of the server receiving a HUP signal. */ -int -rehash(int sig) +bool +rehash(bool sig) { - if(sig != 0) + if(sig) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "Got signal SIGHUP, reloading ircd conf. file"); @@ -647,7 +646,7 @@ rehash(int sig) rehash_authd(); /* don't close listeners until we know we can go ahead with the rehash */ - read_conf_files(NO); + read_conf_files(false); if(ServerInfo.description != NULL) rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info)); @@ -655,11 +654,11 @@ rehash(int sig) rb_strlcpy(me.info, "unknown", sizeof(me.info)); open_logfiles(); - return (0); + return false; } void -rehash_bans(int sig) +rehash_bans(void) { bandb_rehash_bans(); } @@ -690,8 +689,6 @@ set_default_conf(void) ServerInfo.specific_ipv6_vhost = 0; #endif - /* Don't reset hub, as that will break lazylinks */ - /* ServerInfo.hub = false; */ AdminInfo.name = NULL; AdminInfo.email = NULL; AdminInfo.description = NULL; @@ -868,9 +865,9 @@ validate_conf(void) if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list)) { ilog(L_MAIN, "WARNING: Unable to setup SSL."); - ssl_ok = false; + ircd_ssl_ok = false; } else { - ssl_ok = true; + ircd_ssl_ok = true; send_new_ssl_certs(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list); } @@ -1419,7 +1416,7 @@ read_conf_files(bool cold) * free an alias{} entry. */ static void -free_alias_cb(struct DictionaryElement *ptr, void *unused) +free_alias_cb(rb_dictionary_element *ptr, void *unused) { struct alias_entry *aptr = ptr->data; diff --git a/ircd/s_newconf.c b/ircd/s_newconf.c index d5e5a9d2..3815f839 100644 --- a/ircd/s_newconf.c +++ b/ircd/s_newconf.c @@ -32,7 +32,6 @@ #include "stdinc.h" #include "ircd_defs.h" -#include "common.h" #include "s_conf.h" #include "s_newconf.h" #include "client.h" @@ -174,7 +173,7 @@ free_remote_conf(struct remote_conf *remote_p) rb_free(remote_p); } -int +bool find_shared_conf(const char *username, const char *host, const char *server, int flags) { @@ -190,13 +189,13 @@ find_shared_conf(const char *username, const char *host, match(shared_p->server, server)) { if(shared_p->flags & flags) - return YES; + return true; else - return NO; + return false; } } - return NO; + return false; } void @@ -305,7 +304,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const if(parse_netmask(addr, &ip, &bits) != HM_HOST) { - if(ip.ss_family == cip.ss_family && + if(GET_SS_FAMILY(&ip) == GET_SS_FAMILY(&cip) && comp_with_mask_sock((struct sockaddr *)&ip, (struct sockaddr *)&cip, bits)) return oper_p; } @@ -685,8 +684,7 @@ expire_temp_rxlines(void *unused) struct ConfItem *aconf; rb_dlink_node *ptr; rb_dlink_node *next_ptr; - int i; - struct rb_radixtree_iteration_state state; + rb_radixtree_iteration_state state; RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) { diff --git a/ircd/s_serv.c b/ircd/s_serv.c index a479999e..79a0a487 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -31,7 +31,6 @@ #include "s_serv.h" #include "class.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -273,7 +272,7 @@ try_connections(void *unused) continue; /* don't allow ssl connections if ssl isn't setup */ - if(ServerConfSSL(tmp_p) && (!ssl_ok || !get_ssld_count())) + if(ServerConfSSL(tmp_p) && (!ircd_ssl_ok || !get_ssld_count())) continue; cltmp = tmp_p->class; @@ -797,19 +796,6 @@ server_estab(struct Client *client_p) /* Its got identd , since its a server */ SetGotId(client_p); - /* If there is something in the serv_list, it might be this - * connecting server.. - */ - if(!ServerInfo.hub && serv_list.head) - { - if(client_p != serv_list.head->data || serv_list.head->next) - { - ServerStats.is_ref++; - sendto_one(client_p, "ERROR :I'm a leaf not a hub"); - return exit_client(client_p, client_p, client_p, "I'm a leaf"); - } - } - if(IsUnknown(client_p)) { /* the server may be linking based on certificate fingerprint now. --nenolod */ @@ -1171,7 +1157,7 @@ serv_connect_ssl_callback(rb_fde_t *F, int status, void *data) } client_p->localClient->F = xF[0]; - client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0])); + client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], connid_get(client_p)); if(!client_p->localClient->ssl_ctl) { serv_connect_callback(client_p->localClient->F, RB_ERROR, data); diff --git a/ircd/s_user.c b/ircd/s_user.c index f1fc52a4..86a8c7cd 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -27,7 +27,6 @@ #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -219,7 +218,7 @@ register_local_user(struct Client *client_p, struct Client *source_p) { struct ConfItem *aconf, *xconf; struct User *user = source_p->user; - char tmpstr2[IRCD_BUFSIZE]; + char tmpstr2[BUFSIZE]; char ipaddr[HOSTIPLEN]; char myusername[USERLEN+1]; int status; @@ -1464,10 +1463,8 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use target_p->info); if(*mode) - sendto_channel_local_butone(target_p, ALL_MEMBERS, chptr, - ":%s MODE %s +%s %s", - target_p->servptr->name, - chptr->chname, mode, modeval); + sendto_channel_local_with_capability_butone(target_p, ALL_MEMBERS, NOCAPS, CLICAP_CHGHOST, chptr, + ":%s MODE %s +%s %s", target_p->servptr->name, chptr->chname, mode, modeval); *modeval = '\0'; } diff --git a/ircd/scache.c b/ircd/scache.c index 6c57522a..93f5acdc 100644 --- a/ircd/scache.c +++ b/ircd/scache.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" @@ -62,7 +61,7 @@ struct scache_entry time_t last_split; }; -static struct rb_radixtree *scache_tree = NULL; +static rb_radixtree *scache_tree = NULL; void clear_scache_hash_table(void) @@ -134,7 +133,7 @@ void scache_send_flattened_links(struct Client *source_p) { struct scache_entry *scache_ptr; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; int show; RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree) @@ -170,7 +169,7 @@ void scache_send_missing(struct Client *source_p) { struct scache_entry *scache_ptr; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree) { @@ -191,7 +190,7 @@ void count_scache(size_t * number_servers_cached, size_t * mem_servers_cached) { struct scache_entry *scache_ptr; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; *number_servers_cached = 0; *mem_servers_cached = 0; diff --git a/ircd/send.c b/ircd/send.c index 6eec553a..a8782112 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -27,7 +27,6 @@ #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" @@ -218,12 +217,12 @@ send_queued_write(rb_fde_t *F, void *data) static void linebuf_put_msgvbuf(struct MsgBuf *msgbuf, buf_head_t *linebuf, unsigned int capmask, const char *pattern, va_list *va) { - char buf[IRCD_BUFSIZE]; + char buf[BUFSIZE]; rb_linebuf_newbuf(linebuf); msgbuf_unparse_prefix(buf, sizeof buf, msgbuf, capmask); rb_linebuf_putprefix(linebuf, pattern, va, buf); -} +} /* linebuf_put_msgbuf * @@ -497,7 +496,7 @@ void sendto_channel_flags(struct Client *one, int type, struct Client *source_p, struct Channel *chptr, const char *pattern, ...) { - char buf[IRCD_BUFSIZE]; + char buf[BUFSIZE]; va_list args; buf_head_t rb_linebuf_local; buf_head_t rb_linebuf_id; @@ -505,7 +504,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, struct membership *msptr; rb_dlink_node *ptr; rb_dlink_node *next_ptr; - unsigned int current_capmask = 0; + int current_capmask = 0; struct MsgBuf msgbuf; rb_linebuf_newbuf(&rb_linebuf_local); diff --git a/ircd/sslproc.c b/ircd/sslproc.c index 9f01f229..55c7ba6d 100644 --- a/ircd/sslproc.c +++ b/ircd/sslproc.c @@ -278,17 +278,17 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co if(ssld_path == NULL) { - snprintf(fullpath, sizeof(fullpath), "%s/ssld%s", PKGLIBEXECDIR, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cssld%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { - snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld%s", - ConfigFileEntry.dpath, suffix); + snprintf(fullpath, sizeof(fullpath), "%s%cbin%cssld%s", + ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, "Unable to execute ssld%s in %s or %s/bin", - suffix, PKGLIBEXECDIR, ConfigFileEntry.dpath); + suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); return 0; } } @@ -339,7 +339,7 @@ start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, co rb_close(F2); rb_close(P1); ctl = allocate_ssl_daemon(F1, P2, pid); - if(ssl_ok) + if(ircd_ssl_ok) { send_init_prng(ctl, RB_PRNG_DEFAULT, NULL); send_certfp_method(ctl, ConfigFileEntry.certfp_method); @@ -452,7 +452,6 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) uint32_t len; uint8_t *certfp; char *certfp_string; - int i; if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN) return; /* bogus message..drop it.. XXX should warn here */ @@ -465,7 +464,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) return; rb_free(client_p->certfp); certfp_string = rb_malloc(len * 2 + 1); - for(i = 0; i < len; i++) + for(uint32_t i = 0; i < len; i++) snprintf(certfp_string + 2 * i, 3, "%02x", certfp[i]); client_p->certfp = certfp_string; @@ -478,7 +477,7 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) static const char *no_ssl_or_zlib = "ssld has neither SSL/TLS or zlib support killing all sslds"; rb_dlink_node *ptr, *next; ssl_ctl_buf_t *ctl_buf; - int len; + unsigned long len; if(ctl->dead) return; @@ -489,7 +488,7 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) switch (*ctl_buf->buf) { case 'N': - ssl_ok = false; /* ssld says it can't do ssl/tls */ + ircd_ssl_ok = false; /* ssld says it can't do ssl/tls */ break; case 'D': ssl_process_dead_fd(ctl, ctl_buf); @@ -504,24 +503,24 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) ssl_process_zipstats(ctl, ctl_buf); break; case 'I': - ssl_ok = false; + ircd_ssl_ok = false; ilog(L_MAIN, "%s", cannot_setup_ssl); sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", cannot_setup_ssl); break; case 'U': - zlib_ok = 0; - ssl_ok = false; + ircd_zlib_ok = 0; + ircd_ssl_ok = false; ilog(L_MAIN, "%s", no_ssl_or_zlib); sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", no_ssl_or_zlib); ssl_killall(); - break; + return; case 'V': len = ctl_buf->buflen - 1; if (len > sizeof(ctl->version) - 1) len = sizeof(ctl->version) - 1; strncpy(ctl->version, &ctl_buf->buf[1], len); case 'z': - zlib_ok = 0; + ircd_zlib_ok = 0; break; default: ilog(L_MAIN, "Received invalid command from ssld: %s", ctl_buf->buf); @@ -722,7 +721,7 @@ send_new_ssl_certs(const char *ssl_cert, const char *ssl_private_key, const char rb_dlink_node *ptr; if(ssl_cert == NULL || ssl_private_key == NULL || ssl_dh_params == NULL) { - ssl_ok = false; + ircd_ssl_ok = false; return; } RB_DLINK_FOREACH(ptr, ssl_daemons.head) @@ -810,7 +809,6 @@ start_zlib_session(void *data) rb_fde_t *F[2]; rb_fde_t *xF1, *xF2; char *buf; - char buf2[9]; void *recvq_start; size_t hdr = (sizeof(uint8_t) * 2) + sizeof(uint32_t); @@ -864,23 +862,11 @@ start_zlib_session(void *data) return; } - if(IsSSL(server)) - { - /* tell ssld the new connid for the ssl part*/ - buf2[0] = 'Y'; - uint32_to_buf(&buf2[1], rb_get_fd(server->localClient->F)); - uint32_to_buf(&buf2[5], rb_get_fd(xF2)); - ssl_cmd_write_queue(server->localClient->ssl_ctl, NULL, 0, buf2, sizeof(buf2)); - } - - F[0] = server->localClient->F; F[1] = xF1; - del_from_zconnid_hash(server); server->localClient->F = xF2; /* need to redo as what we did before isn't valid now */ - uint32_to_buf(&buf[1], server->localClient->zconnid); - add_to_zconnid_hash(server); + uint32_to_buf(&buf[1], connid_get(server)); server->localClient->z_ctl = which_ssld(); if(!server->localClient->z_ctl) diff --git a/ircd/supported.c b/ircd/supported.c index 94ebf3a2..c28ed9d0 100644 --- a/ircd/supported.c +++ b/ircd/supported.c @@ -72,7 +72,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "numeric.h" #include "ircd.h" #include "s_conf.h" diff --git a/ircd/version.c.SH b/ircd/version.c.SH index c02158a3..ff055ffa 100644 --- a/ircd/version.c.SH +++ b/ircd/version.c.SH @@ -7,7 +7,7 @@ echo "Extracting $package/src/version.c..." if test -r version.c.last then - generation=`sed -n 's/^char \*generation = \"\(.*\)\";/\1/p' < version.c.last` + generation=`sed -n 's/^const char \*generation = \"\(.*\)\";/\1/p' < version.c.last` if test ! "$generation" ; then generation=0; fi else generation=0 @@ -63,7 +63,7 @@ const char *infotext[] = "$package --", "Based on the original code written by Jarkko Oikarinen", "Copyright 1988, 1989, 1990, 1991 University of Oulu, Computing Center", - "Copyright (c) 1996-2001 Hybrid Development Team", + "Copyright (c) 1996-2001 Hybrid Development Team", "Copyright (c) 2002-2009 ircd-ratbox Development Team", "Copyright (c) 2005-2016 charybdis development team", " ", diff --git a/ircd/whowas.c b/ircd/whowas.c index ea9c838b..62419535 100644 --- a/ircd/whowas.c +++ b/ircd/whowas.c @@ -46,7 +46,7 @@ struct whowas_top rb_dlink_list wwlist; }; -static struct rb_radixtree *whowas_tree = NULL; +static rb_radixtree *whowas_tree = NULL; static rb_dlink_list whowas_list = {NULL, NULL, 0}; static unsigned int whowas_list_length = NICKNAMEHISTORYLENGTH; static void whowas_trim(void *unused); diff --git a/librb/INSTALL b/librb/INSTALL deleted file mode 100644 index b42a17ac..00000000 --- a/librb/INSTALL +++ /dev/null @@ -1,182 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/librb/Makefile.am b/librb/Makefile.am index a21a3026..cfddf5d7 100644 --- a/librb/Makefile.am +++ b/librb/Makefile.am @@ -16,3 +16,5 @@ include/serno.h: echo '#define DATECODE 0UL' >>include/serno.h; \ fi +clean-local: + rm -f include/serno.h diff --git a/librb/acinclude.m4 b/librb/acinclude.m4 index 8325a7d0..eaa270e0 100644 --- a/librb/acinclude.m4 +++ b/librb/acinclude.m4 @@ -1,4 +1,3 @@ -# $Id: acinclude.m4 23020 2006-09-01 18:20:19Z androsyn $ - aclocal.m4 - Autoconf fun... AC_DEFUN([AC_DEFINE_DIR], [ test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' @@ -34,12 +33,17 @@ AC_DEFUN([AC_SUBST_DIR], [ dnl IPv6 support macros..pretty much swiped from wget dnl RB_PROTO_INET6 - + AC_DEFUN([RB_PROTO_INET6],[ AC_CACHE_CHECK([for INET6 protocol support], [rb_cv_proto_inet6],[ AC_TRY_CPP([ +#ifndef _WIN32 #include #include +#else +#include +#include +#endif #ifndef PF_INET6 #error Missing PF_INET6 @@ -52,14 +56,14 @@ AC_DEFUN([RB_PROTO_INET6],[ ],[ rb_cv_proto_inet6=no ]) - ]) + ]) if test "X$rb_cv_proto_inet6" = "Xyes"; then : $1 else : - $2 - fi -]) + $2 + fi +]) AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[ @@ -69,9 +73,14 @@ AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[ ],[ rb_have_sockaddr_in6=no ],[ +#ifndef _WIN32 #include #include #include +#else +#include +#include +#endif ]) if test "X$rb_have_sockaddr_in6" = "Xyes"; then : @@ -83,7 +92,7 @@ AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[ AC_DEFUN([RB_CHECK_TIMER_CREATE], - [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], + [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], [rb__cv_timer_create_works], [AC_TRY_RUN([ #ifdef HAVE_TIME_H @@ -116,7 +125,7 @@ int main(int argc, char *argv[]) [rb__cv_timer_create_works=no]) ]) case $rb__cv_timer_create_works in - yes) AC_DEFINE([USE_TIMER_CREATE], 1, + yes) AC_DEFINE([USE_TIMER_CREATE], 1, [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);; esac ]) @@ -124,7 +133,7 @@ esac AC_DEFUN([RB_CHECK_TIMERFD_CREATE], - [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)], + [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)], [rb__cv_timerfd_create_works], [AC_TRY_RUN([ #ifdef HAVE_TIME_H @@ -156,7 +165,7 @@ int main(int argc, char *argv[]) [rb__cv_timerfd_create_works=no]) ]) case $rb__cv_timerfd_create_works in - yes) AC_DEFINE([USE_TIMERFD_CREATE], 1, + yes) AC_DEFINE([USE_TIMERFD_CREATE], 1, [Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);; esac ]) diff --git a/librb/autogen.sh b/librb/autogen.sh index 3eaa78b6..03a67ed2 100755 --- a/librb/autogen.sh +++ b/librb/autogen.sh @@ -80,7 +80,7 @@ parse_options "$@" cd $TOP_DIR -run_or_die $ACLOCAL +run_or_die $ACLOCAL -I ../m4 run_or_die $LIBTOOLIZE --force --copy run_or_die $AUTOHEADER run_or_die $AUTOCONF diff --git a/librb/config.guess b/librb/config.guess deleted file mode 100755 index dbfb9786..00000000 --- a/librb/config.guess +++ /dev/null @@ -1,1421 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. - -timestamp='2015-01-01' - -# 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 -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches to . - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2015 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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - 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 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - 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 - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - 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-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/librb/config.sub b/librb/config.sub deleted file mode 100755 index 6d2e94c8..00000000 --- a/librb/config.sub +++ /dev/null @@ -1,1807 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. - -timestamp='2015-01-01' - -# 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 -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2015 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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # 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) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - 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 - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/librb/configure.ac b/librb/configure.ac index 52f0a230..f2e5acbc 100644 --- a/librb/configure.ac +++ b/librb/configure.ac @@ -62,7 +62,7 @@ case "$host_os" in AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system]) AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system]) ;; -*mingw*) +*mingw* | *msys*) AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system]) 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.])]) @@ -144,6 +144,7 @@ AC_CHECK_TYPE([socklen_t], rb_cv_socklen_t=socklen_t,[ #endif #ifdef HAVE_WINSOCK2_H #include +#include #endif int getpeername (int, $arg2 *, $t *); ],[ @@ -210,8 +211,9 @@ AC_CHECK_TYPE([sa_family_t], [], dnl check for various functions... -AC_CHECK_FUNCS([snprintf vsnprintf 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_CHECK_FUNCS([snprintf vsnprintf socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn getexecname strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage timerfd_create]) +AC_SEARCH_LIBS(dlinfo, dl, AC_DEFINE(HAVE_DLINFO, 1, [Define if you have dlinfo])) 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 @@ -496,6 +498,7 @@ if test "x$rb_windows_h" = "xyes"; then echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile echo '#include ' >> $outfile echo '#include ' >> $outfile + echo '#include ' >> $outfile echo '#include ' >> $outfile fi diff --git a/librb/include/commio-int.h b/librb/include/commio-int.h index 90cdf2fb..da2833a4 100644 --- a/librb/include/commio-int.h +++ b/librb/include/commio-int.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio.h 24059 2007-07-24 17:25:41Z androsyn $ */ #ifndef _COMMIO_INT_H @@ -33,13 +32,6 @@ #define FD_DESC_SZ 128 /* hostlen + comment */ - -#ifdef _WIN32 -#define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0) -#else -#define rb_get_errno() -#endif - #define rb_hash_fd(x) ((x ^ (x >> RB_FD_HASH_BITS) ^ (x >> (RB_FD_HASH_BITS * 2))) & RB_FD_HASH_MASK) #ifdef HAVE_WRITEV @@ -104,7 +96,7 @@ struct _fde * filedescriptor. Think though: when do you think we'll need more? */ rb_dlink_node node; - int fd; /* So we can use the rb_fde_t as a callback ptr */ + rb_platform_fd_t fd; /* So we can use the rb_fde_t as a callback ptr */ uint8_t flags; uint8_t type; int pflags; @@ -136,7 +128,7 @@ typedef struct timer_data extern rb_dlink_list *rb_fd_table; static inline rb_fde_t * -rb_find_fd(int fd) +rb_find_fd(rb_platform_fd_t fd) { rb_dlink_list *hlist; rb_dlink_node *ptr; diff --git a/librb/include/commio-ssl.h b/librb/include/commio-ssl.h index 6e2bd69f..adcce1ae 100644 --- a/librb/include/commio-ssl.h +++ b/librb/include/commio-ssl.h @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio-ssl.h 26280 2008-12-10 20:25:29Z androsyn $ */ #ifndef _COMMIO_SSL_H diff --git a/librb/include/event-int.h b/librb/include/event-int.h index 993a78d0..4cabd316 100644 --- a/librb/include/event-int.h +++ b/librb/include/event-int.h @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: event-int.h 26272 2008-12-10 05:55:10Z androsyn $ */ struct ev_entry diff --git a/librb/include/librb_config.h.in b/librb/include/librb_config.h.in deleted file mode 100644 index 95d88994..00000000 --- a/librb/include/librb_config.h.in +++ /dev/null @@ -1,377 +0,0 @@ -/* include/librb_config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* This is a Cygwin system */ -#undef CYGWIN - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - -/* Define to 1 if you have the `arc4random' function. */ -#undef HAVE_ARC4RANDOM - -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_INET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_CRYPT_H - -/* Define to 1 if you have devpoll */ -#undef HAVE_DEVPOLL - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the `epoll_ctl' function. */ -#undef HAVE_EPOLL_CTL - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define to 1 if you have the `fork' function. */ -#undef HAVE_FORK - -/* Define to 1 if you have the `fstat' function. */ -#undef HAVE_FSTAT - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the `getrusage' function. */ -#undef HAVE_GETRUSAGE - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if you have the `gmtime_r' function. */ -#undef HAVE_GMTIME_R - -/* Has GnuTLS */ -#undef HAVE_GNUTLS - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `kevent' function. */ -#undef HAVE_KEVENT - -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_TCP_H - -/* Has mbedTLS */ -#undef HAVE_MBEDTLS - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have nanosleep */ -#undef HAVE_NANOSLEEP - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - -/* Has OpenSSL */ -#undef HAVE_OPENSSL - -/* Define to 1 if you have the `poll' function. */ -#undef HAVE_POLL - -/* Define to 1 if you have the `port_create' function. */ -#undef HAVE_PORT_CREATE - -/* Define to 1 if you have the header file. */ -#undef HAVE_PORT_H - -/* Define to 1 if you have the `posix_spawn' function. */ -#undef HAVE_POSIX_SPAWN - -/* Define to 1 if you have the `select' function. */ -#undef HAVE_SELECT - -/* Define to 1 if you have the `sendmsg' function. */ -#undef HAVE_SENDMSG - -/* Define to 1 if you have the `signalfd' function. */ -#undef HAVE_SIGNALFD - -/* Define to 1 if you have the header file. */ -#undef HAVE_SIGNAL_H - -/* Define to 1 if you have the `snprintf' function. */ -#undef HAVE_SNPRINTF - -/* Define to 1 if you have the `socketpair' function. */ -#undef HAVE_SOCKETPAIR - -/* Define to 1 if you have the header file. */ -#undef HAVE_SPAWN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strlcat' function. */ -#undef HAVE_STRLCAT - -/* Define to 1 if you have the `strlcpy' function. */ -#undef HAVE_STRLCPY - -/* Define to 1 if you have the `strnlen' function. */ -#undef HAVE_STRNLEN - -/* Define to 1 if you have the `strtok_r' function. */ -#undef HAVE_STRTOK_R - -/* Define to 1 if the system has the type `struct sockaddr_in6'. */ -#undef HAVE_STRUCT_SOCKADDR_IN6 - -/* Define to 1 if the system has the type `struct sockaddr_storage'. */ -#undef HAVE_STRUCT_SOCKADDR_STORAGE - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_DEVPOLL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_EPOLL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_EVENT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_POLL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SELECT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SIGNALFD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIMERFD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the 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 - -/* Define to 1 if you have the header file. */ -#undef HAVE_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `usleep' function. */ -#undef HAVE_USLEEP - -/* Define to 1 if you have the `vfork' function. */ -#undef HAVE_VFORK - -/* Define to 1 if you have the header file. */ -#undef HAVE_VFORK_H - -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - -/* 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 - -/* Define to 1 if `vfork' works. */ -#undef HAVE_WORKING_VFORK - -/* Define to 1 if you have the `writev' function. */ -#undef HAVE_WRITEV - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - -/* This is a MinGW system */ -#undef MINGW - -/* Define this to disable debugging support. */ -#undef NDEBUG - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Prefix where librb is installed. */ -#undef RB_PREFIX - -/* Defined to mark profiling is enabled */ -#undef RB_PROFILE - -/* Define to 1 if sockaddr has a 'sa_len' member. */ -#undef SOCKADDR_IN_HAS_LEN - -/* Define this to enable soft asserts. */ -#undef SOFT_ASSERT - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* 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 - -/* Version number of package */ -#undef VERSION - -/* This is a Windows system */ -#undef WINDOWS - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `int' if doesn't define. */ -#undef gid_t - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to `int' if does not define. */ -#undef pid_t - -/* If system does not define sa_family_t, define it here. */ -#undef sa_family_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* Define to `int' if does not define. */ -#undef ssize_t - -/* Define to `int' if doesn't define. */ -#undef uid_t - -/* Define as `fork' if `vfork' does not work. */ -#undef vfork diff --git a/librb/include/rb_balloc.h b/librb/include/rb_balloc.h index 7ca7857d..ff665200 100644 --- a/librb/include/rb_balloc.h +++ b/librb/include/rb_balloc.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_balloc.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_commio.h b/librb/include/rb_commio.h index 92e75950..f51e04b1 100644 --- a/librb/include/rb_commio.h +++ b/librb/include/rb_commio.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_commio.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H @@ -88,7 +87,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(rb_platform_fd_t, 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 *); @@ -150,11 +149,11 @@ void rb_setselect(rb_fde_t *, unsigned int type, PF * handler, void *client_data void rb_init_netio(void); int rb_select(unsigned long); int rb_fd_ssl(rb_fde_t *F); -int rb_get_fd(rb_fde_t *F); +rb_platform_fd_t rb_get_fd(rb_fde_t *F); const char *rb_get_ssl_strerror(rb_fde_t *F); int rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method); -rb_fde_t *rb_get_fde(int fd); +rb_fde_t *rb_get_fde(rb_platform_fd_t fd); 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); diff --git a/librb/include/rb_dictionary.h b/librb/include/rb_dictionary.h index 2ae5b725..2baf027d 100644 --- a/librb/include/rb_dictionary.h +++ b/librb/include/rb_dictionary.h @@ -25,59 +25,65 @@ #ifndef __RB_DICTIONARY_H__ #define __RB_DICTIONARY_H__ -struct Dictionary; /* defined in src/dictionary.c */ +#include "librb-config.h" + +typedef struct rb_dictionary rb_dictionary; +typedef struct rb_dictionary_element rb_dictionary_element; +typedef struct rb_dictionary_iter rb_dictionary_iter; + +struct rb_dictionary; typedef int (*DCF)(/* const void *a, const void *b */); -struct DictionaryElement +struct rb_dictionary_element { - struct DictionaryElement *left, *right, *prev, *next; + rb_dictionary_element *left, *right, *prev, *next; void *data; const void *key; int position; }; -struct DictionaryIter +struct rb_dictionary_iter { - struct DictionaryElement *cur, *next; + rb_dictionary_element *cur, *next; }; /* * this is a convenience macro for inlining iteration of dictionaries. */ -#define DICTIONARY_FOREACH(element, state, dict) for (rb_dictionary_foreach_start((dict), (state)); (element = rb_dictionary_foreach_cur((dict), (state))); rb_dictionary_foreach_next((dict), (state))) +#define RB_DICTIONARY_FOREACH(element, state, dict) for (rb_dictionary_foreach_start((dict), (state)); (element = rb_dictionary_foreach_cur((dict), (state))); rb_dictionary_foreach_next((dict), (state))) /* * rb_dictionary_create_named() creates a new dictionary tree which has a name. * name is the name, compare_cb is the comparator. */ -extern struct Dictionary *rb_dictionary_create(const char *name, DCF compare_cb); +extern rb_dictionary *rb_dictionary_create(const char *name, DCF compare_cb); /* * rb_dictionary_set_comparator_func() resets the comparator used for lookups and * insertions in the DTree structure. */ -extern void rb_dictionary_set_comparator_func(struct Dictionary *dict, +extern void rb_dictionary_set_comparator_func(rb_dictionary *dict, DCF compare_cb); /* * rb_dictionary_get_comparator_func() returns the comparator used for lookups and * insertions in the DTree structure. */ -extern DCF rb_dictionary_get_comparator_func(struct Dictionary *dict); +extern DCF rb_dictionary_get_comparator_func(rb_dictionary *dict); /* * rb_dictionary_get_linear_index() returns the linear index of an object in the * DTree structure. */ -extern int rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key); +extern int rb_dictionary_get_linear_index(rb_dictionary *dict, const void *key); /* * rb_dictionary_destroy() destroys all entries in a dtree, and also optionally calls * a defined callback function to destroy any data attached to it. */ -extern void rb_dictionary_destroy(struct Dictionary *dtree, - void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), +extern void rb_dictionary_destroy(rb_dictionary *dtree, + void (*destroy_cb)(rb_dictionary_element *delem, void *privdata), void *privdata); /* @@ -86,8 +92,8 @@ extern void rb_dictionary_destroy(struct Dictionary *dtree, * * To shortcircuit iteration, return non-zero from the callback function. */ -extern void rb_dictionary_foreach(struct Dictionary *dtree, - int (*foreach_cb)(struct DictionaryElement *delem, void *privdata), +extern void rb_dictionary_foreach(rb_dictionary *dtree, + int (*foreach_cb)(rb_dictionary_element *delem, void *privdata), void *privdata); /* @@ -97,8 +103,8 @@ extern void rb_dictionary_foreach(struct Dictionary *dtree, * When the object is found, a non-NULL is returned from the callback, which results * in that object being returned to the user. */ -extern void *rb_dictionary_search(struct Dictionary *dtree, - void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata), +extern void *rb_dictionary_search(rb_dictionary *dtree, + void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata), void *privdata); /* @@ -107,56 +113,68 @@ extern void *rb_dictionary_search(struct Dictionary *dtree, * in progress at a time, it is permitted to remove the current element * of the iteration (but not any other element). */ -extern void rb_dictionary_foreach_start(struct Dictionary *dtree, - struct DictionaryIter *state); +extern void rb_dictionary_foreach_start(rb_dictionary *dtree, + rb_dictionary_iter *state); /* * rb_dictionary_foreach_cur() returns the current element of the iteration, * or NULL if there are no more elements. */ -extern void *rb_dictionary_foreach_cur(struct Dictionary *dtree, - struct DictionaryIter *state); +extern void *rb_dictionary_foreach_cur(rb_dictionary *dtree, + rb_dictionary_iter *state); /* * rb_dictionary_foreach_next() moves to the next element. */ -extern void rb_dictionary_foreach_next(struct Dictionary *dtree, - struct DictionaryIter *state); +extern void rb_dictionary_foreach_next(rb_dictionary *dtree, + rb_dictionary_iter *state); /* * rb_dictionary_add() adds a key->value entry to the dictionary tree. */ -extern struct DictionaryElement *rb_dictionary_add(struct Dictionary *dtree, const void *key, void *data); +extern rb_dictionary_element *rb_dictionary_add(rb_dictionary *dtree, const void *key, void *data); /* - * rb_dictionary_find() returns a struct DictionaryElement container from a dtree for key 'key'. + * rb_dictionary_find() returns a rb_dictionary_element container from a dtree for key 'key'. */ -extern struct DictionaryElement *rb_dictionary_find(struct Dictionary *dtree, const void *key); +extern rb_dictionary_element *rb_dictionary_find(rb_dictionary *dtree, const void *key); /* * rb_dictionary_find() returns data from a dtree for key 'key'. */ -extern void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key); +extern void *rb_dictionary_retrieve(rb_dictionary *dtree, const void *key); /* * rb_dictionary_delete() deletes a key->value entry from the dictionary tree. */ -extern void *rb_dictionary_delete(struct Dictionary *dtree, const void *key); +extern void *rb_dictionary_delete(rb_dictionary *dtree, const void *key); /* * rb_dictionary_size() returns the number of elements in a dictionary tree. */ -extern unsigned int rb_dictionary_size(struct Dictionary *dtree); +extern unsigned int rb_dictionary_size(rb_dictionary *dtree); -void rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata); +void rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata); void rb_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata); +#ifndef _WIN32 + #define RB_POINTER_TO_INT(x) ((int32_t) (long) (x)) #define RB_INT_TO_POINTER(x) ((void *) (long) (int32_t) (x)) #define RB_POINTER_TO_UINT(x) ((uint32_t) (unsigned long) (x)) #define RB_UINT_TO_POINTER(x) ((void *) (unsigned long) (uint32_t) (x)) +#else + +#define RB_POINTER_TO_INT(x) ((int32_t) (unsigned long long) (x)) +#define RB_INT_TO_POINTER(x) ((void *) (unsigned long long) (int32_t) (x)) + +#define RB_POINTER_TO_UINT(x) ((uint32_t) (unsigned long long) (x)) +#define RB_UINT_TO_POINTER(x) ((void *) (unsigned long long) (uint32_t) (x)) + +#endif + static inline int rb_int32cmp(const void *a, const void *b) { return RB_POINTER_TO_INT(b) - RB_POINTER_TO_INT(a); diff --git a/librb/include/rb_event.h b/librb/include/rb_event.h index 61b6efae..84d9d172 100644 --- a/librb/include/rb_event.h +++ b/librb/include/rb_event.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_event.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_helper.h b/librb/include/rb_helper.h index 3287e8d9..0b4a9086 100644 --- a/librb/include/rb_helper.h +++ b/librb/include/rb_helper.h @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_helper.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_lib.h b/librb/include/rb_lib.h index c7ad3e29..4003a832 100644 --- a/librb/include/rb_lib.h +++ b/librb/include/rb_lib.h @@ -66,7 +66,15 @@ char *alloca(); #define rb_unlikely(x) (x) #endif - +#ifdef _WIN32 +#define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0) +typedef SOCKET rb_platform_fd_t; +#define RB_PATH_SEPARATOR '\\' +#else +#define rb_get_errno() +typedef int rb_platform_fd_t; +#define RB_PATH_SEPARATOR '/' +#endif #ifdef _WIN32 #include @@ -82,18 +90,32 @@ char *alloca(); #define strerror(x) rb_strerror(x) char *rb_strerror(int error); - +#undef ENOBUFS #define ENOBUFS WSAENOBUFS + +#undef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS + +#undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK + +#undef EMSGSIZE #define EMSGSIZE WSAEMSGSIZE + +#undef EALREADY #define EALREADY WSAEALREADY + +#undef EISCONN #define EISCONN WSAEISCONN + +#undef EADDRINUSE #define EADDRINUSE WSAEADDRINUSE + +#undef EAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT #define pipe(x) _pipe(x, 1024, O_BINARY) -#define ioctl(x,y,z) ioctlsocket(x,y, (u_long *)z) +#define ioctl(x,y,z) ioctlsocket(x,y, (unsigned long *)z) #define WNOHANG 1 diff --git a/librb/include/rb_linebuf.h b/librb/include/rb_linebuf.h index b1d8c847..d0e0b988 100644 --- a/librb/include/rb_linebuf.h +++ b/librb/include/rb_linebuf.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_linebuf.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_memory.h b/librb/include/rb_memory.h index d4dd6f0c..1bc7af09 100644 --- a/librb/include/rb_memory.h +++ b/librb/include/rb_memory.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_memory.h 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_patricia.h b/librb/include/rb_patricia.h index 6ea803a9..79b9fecb 100644 --- a/librb/include/rb_patricia.h +++ b/librb/include/rb_patricia.h @@ -1,5 +1,4 @@ /* - * $Id: patricia.h 23020 2006-09-01 18:20:19Z androsyn $ * Dave Plonka * * This product includes software developed by the University of Michigan, @@ -25,7 +24,6 @@ #define INET6_ADDRSTRLEN 46 #endif -/* typedef unsigned int u_int; */ #define rb_prefix_touchar(prefix) ((unsigned char *)&(prefix)->add.sin) #define MAXLINE 1024 #define BIT_TEST(f, b) ((f) & (b)) diff --git a/librb/include/rb_radixtree.h b/librb/include/rb_radixtree.h index f647de17..0b5d1bcc 100644 --- a/librb/include/rb_radixtree.h +++ b/librb/include/rb_radixtree.h @@ -39,12 +39,16 @@ struct rb_radixtree; /* defined in src/rb_radixtree.c */ struct rb_radixtree_leaf; /* defined in src/rb_radixtree.c */ +typedef struct rb_radixtree rb_radixtree; +typedef struct rb_radixtree_leaf rb_radixtree_leaf; +typedef struct rb_radixtree_iteration_state rb_radixtree_iteration_state; + /* * struct rb_radixtree_iteration_state, private. */ struct rb_radixtree_iteration_state { - struct rb_radixtree_leaf *cur, *next; + rb_radixtree_leaf *cur, *next; void *pspare[4]; int ispare[4]; }; @@ -63,7 +67,7 @@ struct rb_radixtree_iteration_state * compare_cb is the canonizing function. */ -extern struct rb_radixtree *rb_radixtree_create(const char *name, void (*canonize_cb)(char *key)); +extern rb_radixtree *rb_radixtree_create(const char *name, void (*canonize_cb)(char *key)); /* * rb_radixtree_shutdown() deallocates all heaps used in patricia trees. This is @@ -76,7 +80,7 @@ extern void rb_radixtree_shutdown(void); * rb_radixtree_destroy() destroys all entries in a dtree, and also optionally calls * a defined callback function to destroy any data attached to it. */ -extern void rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata); +extern void rb_radixtree_destroy(rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata); /* * rb_radixtree_foreach() iterates all entries in a dtree, and also optionally calls @@ -84,7 +88,7 @@ extern void rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)( * * To shortcircuit iteration, return non-zero from the callback function. */ -extern void rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata); +extern void rb_radixtree_foreach(rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata); /* * rb_radixtree_search() iterates all entries in a dtree, and also optionally calls @@ -93,7 +97,7 @@ extern void rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(c * When the object is found, a non-NULL is returned from the callback, which results * in that object being returned to the user. */ -extern void *rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata); +extern void *rb_radixtree_search(rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata); /* * rb_radixtree_foreach_start() begins an iteration over all items @@ -101,7 +105,7 @@ extern void *rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb) * in progress at a time, it is permitted to remove the current element * of the iteration (but not any other element). */ -extern void rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state); +extern void rb_radixtree_foreach_start(rb_radixtree *dtree, rb_radixtree_iteration_state *state); /* * rb_radixtree_foreach_start_from() begins an iteration over all items, @@ -110,44 +114,44 @@ extern void rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_rad * of the iteration (but not any other element). * Use NULL as a key to have it start at the beginning. */ -extern void rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key); +extern void rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key); /* * rb_radixtree_foreach_cur() returns the current element of the iteration, * or NULL if there are no more elements. */ -extern void *rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state); +extern void *rb_radixtree_foreach_cur(rb_radixtree *dtree, rb_radixtree_iteration_state *state); /* * rb_radixtree_foreach_next() moves to the next element. */ -extern void rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state); +extern void rb_radixtree_foreach_next(rb_radixtree *dtree, rb_radixtree_iteration_state *state); /* * rb_radixtree_add() adds a key->value entry to the patricia tree. */ -extern int rb_radixtree_add(struct rb_radixtree *dtree, const char *key, void *data); +extern int rb_radixtree_add(rb_radixtree *dtree, const char *key, void *data); /* * rb_radixtree_find() returns data from a dtree for key 'key'. */ -extern void *rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key); +extern void *rb_radixtree_retrieve(rb_radixtree *dtree, const char *key); /* * rb_radixtree_delete() deletes a key->value entry from the patricia tree. */ -extern void *rb_radixtree_delete(struct rb_radixtree *dtree, const char *key); +extern void *rb_radixtree_delete(rb_radixtree *dtree, const char *key); /* Low-level functions */ -struct rb_radixtree_leaf *rb_radixtree_elem_add(struct rb_radixtree *dtree, const char *key, void *data); -struct rb_radixtree_leaf *rb_radixtree_elem_find(struct rb_radixtree *dtree, const char *key, int fuzzy); -void rb_radixtree_elem_delete(struct rb_radixtree *dtree, struct rb_radixtree_leaf *elem); -const char *rb_radixtree_elem_get_key(struct rb_radixtree_leaf *elem); -void rb_radixtree_elem_set_data(struct rb_radixtree_leaf *elem, void *data); -void *rb_radixtree_elem_get_data(struct rb_radixtree_leaf *elem); +rb_radixtree_leaf *rb_radixtree_elem_add(rb_radixtree *dtree, const char *key, void *data); +rb_radixtree_leaf *rb_radixtree_elem_find(rb_radixtree *dtree, const char *key, int fuzzy); +void rb_radixtree_elem_delete(rb_radixtree *dtree, rb_radixtree_leaf *elem); +const char *rb_radixtree_elem_get_key(rb_radixtree_leaf *elem); +void rb_radixtree_elem_set_data(rb_radixtree_leaf *elem, void *data); +void *rb_radixtree_elem_get_data(rb_radixtree_leaf *elem); -unsigned int rb_radixtree_size(struct rb_radixtree *dict); -void rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata); +unsigned int rb_radixtree_size(rb_radixtree *dict); +void rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata); void rb_radixtree_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata); #endif diff --git a/librb/include/rb_rawbuf.h b/librb/include/rb_rawbuf.h index 523a17b1..91242e82 100644 --- a/librb/include/rb_rawbuf.h +++ b/librb/include/rb_rawbuf.h @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id$ */ #ifndef RB_LIB_H diff --git a/librb/include/rb_tools.h b/librb/include/rb_tools.h index 9a2e2949..c60a483c 100644 --- a/librb/include/rb_tools.h +++ b/librb/include/rb_tools.h @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_tools.h 26170 2008-10-26 20:59:07Z androsyn $ */ #ifndef RB_LIB_H @@ -371,5 +370,6 @@ void rb_zstring_append_from_c(rb_zstring_t *zs, const char *buf, size_t len); char *rb_zstring_to_c(rb_zstring_t *zs, char *buf, size_t len); char *rb_zstring_to_c_alloc(rb_zstring_t *zs); size_t rb_zstring_to_ptr(rb_zstring_t *zs, void **ptr); +const char *rb_path_to_self(void); #endif /* __TOOLS_H__ */ diff --git a/librb/include/serno.h b/librb/include/serno.h deleted file mode 100644 index 7ab97950..00000000 --- a/librb/include/serno.h +++ /dev/null @@ -1,2 +0,0 @@ -#define SERNO "20160307-81204be" -#define DATECODE 1457395822UL diff --git a/librb/src/Makefile.am b/librb/src/Makefile.am index 7e1acd69..cd13ff69 100644 --- a/librb/src/Makefile.am +++ b/librb/src/Makefile.am @@ -1,4 +1,3 @@ -# $Id: Makefile.am 26046 2008-09-09 16:37:30Z androsyn $ AUTOMAKE_OPTIONS = foreign diff --git a/librb/src/arc4random.c b/librb/src/arc4random.c index f65bab1b..f6f53c76 100644 --- a/librb/src/arc4random.c +++ b/librb/src/arc4random.c @@ -1,4 +1,3 @@ -/* $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 $ */ diff --git a/librb/src/balloc.c b/librb/src/balloc.c index b7b03644..71b36cab 100644 --- a/librb/src/balloc.c +++ b/librb/src/balloc.c @@ -28,7 +28,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: balloc.c 26100 2008-09-20 01:27:19Z androsyn $ */ /* diff --git a/librb/src/commio.c b/librb/src/commio.c index b3f1c182..9fe8689c 100644 --- a/librb/src/commio.c +++ b/librb/src/commio.c @@ -21,8 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio.c 26254 2008-12-10 04:04:38Z androsyn $ */ + #include #include #include @@ -74,12 +74,12 @@ static void mangle_mapped_sockaddr(struct sockaddr *in); #endif #ifndef HAVE_SOCKETPAIR -static int rb_inet_socketpair(int d, int type, int protocol, int sv[2]); +static int rb_inet_socketpair(int d, int type, int protocol, rb_platform_fd_t sv[2]); static int rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2); #endif static inline rb_fde_t * -add_fd(int fd) +add_fd(rb_platform_fd_t fd) { rb_fde_t *F = rb_find_fd(fd); @@ -230,7 +230,7 @@ rb_set_nb(rb_fde_t *F) { int nonb = 0; int res; - int fd; + rb_platform_fd_t fd; if(F == NULL) return 0; fd = F->fd; @@ -409,7 +409,7 @@ rb_accept_tcp(rb_fde_t *F, ACPRE * precb, ACCB * callback, void *data) } /* - * void rb_connect_tcp(int fd, struct sockaddr *dest, + * void rb_connect_tcp(rb_platform_fd_t fd, struct sockaddr *dest, * struct sockaddr *clocal, int socklen, * CNCB *callback, void *data, int timeout) * Input: An fd to connect with, a host and port to connect to, @@ -496,7 +496,7 @@ rb_connect_timeout(rb_fde_t *F, void *notused) rb_connect_callback(F, RB_ERR_TIMEOUT); } -/* static void rb_connect_tryconnect(int fd, void *notused) +/* static void rb_connect_tryconnect(rb_platform_fd_t fd, void *notused) * Input: The fd, the handler data(unused). * Output: None. * Side-effects: Try and connect with pending connect data for the FD. If @@ -564,7 +564,7 @@ rb_errstr(int error) int rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2, const char *note) { - int nfd[2]; + rb_platform_fd_t nfd[2]; if(number_fd >= rb_maxconnections) { errno = ENFILE; @@ -627,7 +627,7 @@ int rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc) { #ifndef _WIN32 - int fd[2]; + rb_platform_fd_t fd[2]; if(number_fd >= rb_maxconnections) { errno = ENFILE; @@ -677,7 +677,7 @@ rb_fde_t * rb_socket(int family, int sock_type, int proto, const char *note) { rb_fde_t *F; - int fd; + rb_platform_fd_t fd; /* First, make sure we aren't going to run out of file descriptors */ if(rb_unlikely(number_fd >= rb_maxconnections)) { @@ -703,7 +703,7 @@ rb_socket(int family, int sock_type, int proto, const char *note) if(family == AF_INET6) { int off = 1; - if(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(off)) == -1) + if(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &off, sizeof(off)) == -1) { rb_lib_log("rb_socket: Could not set IPV6_V6ONLY option to 1 on FD %d: %s", fd, strerror(errno)); @@ -821,7 +821,7 @@ rb_fdlist_init(int closeall, int maxfds, size_t heapsize) /* Called to open a given filedescriptor */ rb_fde_t * -rb_open(int fd, uint8_t type, const char *desc) +rb_open(rb_platform_fd_t fd, uint8_t type, const char *desc) { rb_fde_t *F; lrb_assert(fd >= 0); @@ -970,7 +970,7 @@ rb_fd_ssl(rb_fde_t *F) return 0; } -int +rb_platform_fd_t rb_get_fd(rb_fde_t *F) { if(F == NULL) @@ -979,7 +979,7 @@ rb_get_fd(rb_fde_t *F) } rb_fde_t * -rb_get_fde(int fd) +rb_get_fde(rb_platform_fd_t fd) { return rb_find_fd(fd); } @@ -1609,7 +1609,7 @@ 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]; + rb_platform_fd_t fd[2]; int i, got; unsigned short port; struct timeval wait = { 0, 100000 }; @@ -1693,7 +1693,9 @@ rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2) return 0; #ifdef _WIN32 +#ifndef ECONNABORTED #define ECONNABORTED WSAECONNABORTED +#endif #endif abort_failed: @@ -1713,7 +1715,7 @@ rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2) int -rb_inet_socketpair(int family, int type, int protocol, int fd[2]) +rb_inet_socketpair(int family, int type, int protocol, rb_platform_fd_t fd[2]) { int listener = -1; int connector = -1; @@ -2136,7 +2138,7 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds struct stat st; uint8_t stype = RB_FD_UNKNOWN; const char *desc; - int fd, len, x, rfds; + rb_platform_fd_t fd, len, x, rfds; int control_len = CMSG_SPACE(sizeof(int) * nfds); @@ -2221,6 +2223,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz if(count > 0) { + size_t ucount = (size_t)count; int len = CMSG_SPACE(sizeof(int) * count); char buf[len]; @@ -2231,7 +2234,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(int) * count); - for(unsigned int i = 0; i < count; i++) + for(size_t i = 0; i < ucount; i++) { ((int *)CMSG_DATA(cmsg))[i] = rb_get_fd(F[i]); } diff --git a/librb/src/crypt.c b/librb/src/crypt.c index 15c40a0b..9344e988 100644 --- a/librb/src/crypt.c +++ b/librb/src/crypt.c @@ -754,7 +754,7 @@ rb_des_crypt(const char *key, const char *setting) #define MD5_SIZE 16 static void -_crypt_to64(char *s, u_long v, int n) +_crypt_to64(char *s, unsigned long v, int n) { while (--n >= 0) { *s++ = ascii64[v&0x3f]; @@ -1072,8 +1072,8 @@ rb_md5_crypt(const char *pw, const char *salt) MD5_CTX ctx,ctx1; unsigned long l; int sl, pl; - u_int i; - u_char final[MD5_SIZE]; + unsigned int i; + unsigned char final[MD5_SIZE]; static const char *sp, *ep; static char passwd[120], *p; static const char *magic = "$1$"; @@ -1095,23 +1095,23 @@ rb_md5_crypt(const char *pw, const char *salt) MD5Init(&ctx); /* The password first, since that is what is most unknown */ - MD5Update(&ctx, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx, (const unsigned char *)pw, strlen(pw)); /* Then our magic string */ - MD5Update(&ctx, (const u_char *)magic, strlen(magic)); + MD5Update(&ctx, (const unsigned char *)magic, strlen(magic)); /* Then the raw salt */ - MD5Update(&ctx, (const u_char *)sp, (u_int)sl); + MD5Update(&ctx, (const unsigned char *)sp, (unsigned int)sl); /* Then just as many characters of the MD5(pw,salt,pw) */ MD5Init(&ctx1); - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); - MD5Update(&ctx1, (const u_char *)sp, (u_int)sl); - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)sp, (unsigned int)sl); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); MD5Final(final, &ctx1); for(pl = (int)strlen(pw); pl > 0; pl -= MD5_SIZE) - MD5Update(&ctx, (const u_char *)final, - (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl)); + MD5Update(&ctx, (const unsigned char *)final, + (unsigned int)(pl > MD5_SIZE ? MD5_SIZE : pl)); /* Don't leave anything around in vm they could use. */ memset(final, 0, sizeof(final)); @@ -1119,13 +1119,13 @@ rb_md5_crypt(const char *pw, const char *salt) /* Then something really weird... */ for (i = strlen(pw); i; i >>= 1) if(i & 1) - MD5Update(&ctx, (const u_char *)final, 1); + MD5Update(&ctx, (const unsigned char *)final, 1); else - MD5Update(&ctx, (const u_char *)pw, 1); + MD5Update(&ctx, (const unsigned char *)pw, 1); /* Now make the output string */ rb_strlcpy(passwd, magic, sizeof(passwd)); - strncat(passwd, sp, (u_int)sl); + strncat(passwd, sp, (unsigned int)sl); rb_strlcat(passwd, "$", sizeof(passwd)); MD5Final(final, &ctx); @@ -1138,20 +1138,20 @@ rb_md5_crypt(const char *pw, const char *salt) for(i = 0; i < 1000; i++) { MD5Init(&ctx1); if(i & 1) - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); else - MD5Update(&ctx1, (const u_char *)final, MD5_SIZE); + MD5Update(&ctx1, (const unsigned char *)final, MD5_SIZE); if(i % 3) - MD5Update(&ctx1, (const u_char *)sp, (u_int)sl); + MD5Update(&ctx1, (const unsigned char *)sp, (unsigned int)sl); if(i % 7) - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); if(i & 1) - MD5Update(&ctx1, (const u_char *)final, MD5_SIZE); + MD5Update(&ctx1, (const unsigned char *)final, MD5_SIZE); else - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); MD5Final(final, &ctx1); } @@ -1350,7 +1350,7 @@ static void rb_sha256_init_ctx(struct sha256_ctx *ctx) static void *rb_sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ - uint32_t bytes = ctx->buflen; + uint32_t bytes = ctx->buflen, *ptr; size_t pad; unsigned int i; @@ -1363,9 +1363,11 @@ static void *rb_sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) memcpy(&ctx->buffer[bytes], SHA256_fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(uint32_t *) & ctx->buffer[bytes + pad + 4] = SHA256_SWAP(ctx->total[0] << 3); - *(uint32_t *) & ctx->buffer[bytes + pad] = SHA256_SWAP((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + ptr = (uint32_t *)&ctx->buffer[bytes + pad + 4]; /* Avoid warnings about strict aliasing */ + *ptr = SHA256_SWAP(ctx->total[0] << 3); + + ptr = (uint32_t *)&ctx->buffer[bytes + pad]; + *ptr = SHA256_SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ rb_sha256_process_block(ctx->buffer, bytes + pad + 8, ctx); @@ -1924,7 +1926,7 @@ static void rb_sha512_init_ctx(struct sha512_ctx *ctx) static void *rb_sha512_finish_ctx(struct sha512_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ - uint64_t bytes = ctx->buflen; + uint64_t bytes = ctx->buflen, *ptr; size_t pad; unsigned int i; @@ -1937,9 +1939,11 @@ static void *rb_sha512_finish_ctx(struct sha512_ctx *ctx, void *resbuf) memcpy(&ctx->buffer[bytes], SHA512_fillbuf, pad); /* Put the 128-bit file length in *bits* at the end of the buffer. */ - *(uint64_t *) & ctx->buffer[bytes + pad + 8] = SHA512_SWAP(ctx->total[0] << 3); - *(uint64_t *) & ctx->buffer[bytes + pad] = SHA512_SWAP((ctx->total[1] << 3) | - (ctx->total[0] >> 61)); + ptr = (uint64_t *)&ctx->buffer[bytes + pad + 8]; /* Avoid warnings about strict aliasing */ + *ptr = SHA512_SWAP(ctx->total[0] << 3); + + ptr = (uint64_t *)&ctx->buffer[bytes + pad]; + *ptr = SHA512_SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 61)); /* Process last bytes. */ rb_sha512_process_block(ctx->buffer, bytes + pad + 16, ctx); diff --git a/librb/src/devpoll.c b/librb/src/devpoll.c index 2e99c092..06d34ec0 100644 --- a/librb/src/devpoll.c +++ b/librb/src/devpoll.c @@ -22,8 +22,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: devpoll.c 26254 2008-12-10 04:04:38Z androsyn $ */ + #include #include #include diff --git a/librb/src/dictionary.c b/librb/src/dictionary.c index 5bc285da..eeac439f 100644 --- a/librb/src/dictionary.c +++ b/librb/src/dictionary.c @@ -26,10 +26,10 @@ #include #include -struct Dictionary +struct rb_dictionary { DCF compare_cb; - struct DictionaryElement *root, *head, *tail; + rb_dictionary_element *root, *head, *tail; unsigned int count; char *id; unsigned int dirty:1; @@ -55,10 +55,10 @@ static rb_dlink_list dictionary_list = {NULL, NULL, 0}; * - if services runs out of memory and cannot allocate the object, * the program will abort. */ -struct Dictionary *rb_dictionary_create(const char *name, +rb_dictionary *rb_dictionary_create(const char *name, DCF compare_cb) { - struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary)); + rb_dictionary *dtree = (rb_dictionary *) rb_malloc(sizeof(rb_dictionary)); dtree->compare_cb = compare_cb; dtree->id = rb_strdup(name); @@ -69,7 +69,7 @@ struct Dictionary *rb_dictionary_create(const char *name, } /* - * rb_dictionary_set_comparator_func(struct Dictionary *dict, + * rb_dictionary_set_comparator_func(rb_dictionary *dict, * DCF compare_cb) * * Resets the comparator function used by the dictionary code for @@ -85,7 +85,7 @@ struct Dictionary *rb_dictionary_create(const char *name, * Side Effects: * - the dictionary comparator function is reset. */ -void rb_dictionary_set_comparator_func(struct Dictionary *dict, +void rb_dictionary_set_comparator_func(rb_dictionary *dict, DCF compare_cb) { lrb_assert(dict != NULL); @@ -95,7 +95,7 @@ void rb_dictionary_set_comparator_func(struct Dictionary *dict, } /* - * rb_dictionary_get_comparator_func(struct Dictionary *dict) + * rb_dictionary_get_comparator_func(rb_dictionary *dict) * * Returns the current comparator function used by the dictionary. * @@ -109,7 +109,7 @@ void rb_dictionary_set_comparator_func(struct Dictionary *dict, * - none */ DCF -rb_dictionary_get_comparator_func(struct Dictionary *dict) +rb_dictionary_get_comparator_func(rb_dictionary *dict) { lrb_assert(dict != NULL); @@ -117,7 +117,7 @@ rb_dictionary_get_comparator_func(struct Dictionary *dict) } /* - * rb_dictionary_get_linear_index(struct Dictionary *dict, + * rb_dictionary_get_linear_index(rb_dictionary *dict, * const void *key) * * Gets a linear index number for key. @@ -133,9 +133,9 @@ rb_dictionary_get_comparator_func(struct Dictionary *dict) * - rebuilds the linear index if the tree is marked as dirty. */ int -rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key) +rb_dictionary_get_linear_index(rb_dictionary *dict, const void *key) { - struct DictionaryElement *elem; + rb_dictionary_element *elem; lrb_assert(dict != NULL); lrb_assert(key != NULL); @@ -148,7 +148,7 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key) return elem->position; else { - struct DictionaryElement *delem; + rb_dictionary_element *delem; int i; for (delem = dict->head, i = 0; delem != NULL; delem = delem->next, i++) @@ -161,7 +161,7 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key) } /* - * rb_dictionary_retune(struct Dictionary *dict, const void *key) + * rb_dictionary_retune(rb_dictionary *dict, const void *key) * * Retunes the tree, self-optimizing for the element which belongs to key. * @@ -175,9 +175,9 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key) * - a new root node is nominated. */ static void -rb_dictionary_retune(struct Dictionary *dict, const void *key) +rb_dictionary_retune(rb_dictionary *dict, const void *key) { - struct DictionaryElement n, *tn, *left, *right, *node; + rb_dictionary_element n, *tn, *left, *right, *node; int ret; lrb_assert(dict != NULL); @@ -253,8 +253,8 @@ rb_dictionary_retune(struct Dictionary *dict, const void *key) } /* - * rb_dictionary_link(struct Dictionary *dict, - * struct DictionaryElement *delem) + * rb_dictionary_link(rb_dictionary *dict, + * rb_dictionary_element *delem) * * Links a dictionary tree element to the dictionary. * @@ -274,8 +274,8 @@ rb_dictionary_retune(struct Dictionary *dict, const void *key) * - a node is linked to the dictionary tree */ static void -rb_dictionary_link(struct Dictionary *dict, - struct DictionaryElement *delem) +rb_dictionary_link(rb_dictionary *dict, + rb_dictionary_element *delem) { lrb_assert(dict != NULL); lrb_assert(delem != NULL); @@ -340,7 +340,7 @@ rb_dictionary_link(struct Dictionary *dict, } /* - * rb_dictionary_unlink_root(struct Dictionary *dict) + * rb_dictionary_unlink_root(rb_dictionary *dict) * * Unlinks the root dictionary tree element from the dictionary. * @@ -354,9 +354,9 @@ rb_dictionary_link(struct Dictionary *dict, * - the root node is unlinked from the dictionary tree */ static void -rb_dictionary_unlink_root(struct Dictionary *dict) +rb_dictionary_unlink_root(rb_dictionary *dict) { - struct DictionaryElement *delem, *nextnode, *parentofnext; + rb_dictionary_element *delem, *nextnode, *parentofnext; dict->dirty = TRUE; @@ -409,7 +409,7 @@ rb_dictionary_unlink_root(struct Dictionary *dict) } /* - * rb_dictionary_destroy(struct Dictionary *dtree, + * rb_dictionary_destroy(rb_dictionary *dtree, * void (*destroy_cb)(dictionary_elem_t *delem, void *privdata), * void *privdata); * @@ -430,11 +430,11 @@ rb_dictionary_unlink_root(struct Dictionary *dict) * - if this is called without a callback, the objects bound to the * DTree will not be destroyed. */ -void rb_dictionary_destroy(struct Dictionary *dtree, - void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), +void rb_dictionary_destroy(rb_dictionary *dtree, + void (*destroy_cb)(rb_dictionary_element *delem, void *privdata), void *privdata) { - struct DictionaryElement *n, *tn; + rb_dictionary_element *n, *tn; lrb_assert(dtree != NULL); @@ -452,7 +452,7 @@ void rb_dictionary_destroy(struct Dictionary *dtree, } /* - * rb_dictionary_foreach(struct Dictionary *dtree, + * rb_dictionary_foreach(rb_dictionary *dtree, * void (*destroy_cb)(dictionary_elem_t *delem, void *privdata), * void *privdata); * @@ -469,18 +469,18 @@ void rb_dictionary_destroy(struct Dictionary *dtree, * Side Effects: * - on success, a dtree is iterated */ -void rb_dictionary_foreach(struct Dictionary *dtree, - int (*foreach_cb)(struct DictionaryElement *delem, void *privdata), +void rb_dictionary_foreach(rb_dictionary *dtree, + int (*foreach_cb)(rb_dictionary_element *delem, void *privdata), void *privdata) { - struct DictionaryElement *n, *tn; + rb_dictionary_element *n, *tn; lrb_assert(dtree != NULL); RB_DLINK_FOREACH_SAFE(n, tn, dtree->head) { /* delem_t is a subclass of node_t. */ - struct DictionaryElement *delem = (struct DictionaryElement *) n; + rb_dictionary_element *delem = (rb_dictionary_element *) n; if (foreach_cb != NULL) (*foreach_cb)(delem, privdata); @@ -488,8 +488,8 @@ void rb_dictionary_foreach(struct Dictionary *dtree, } /* - * rb_dictionary_search(struct Dictionary *dtree, - * void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), + * rb_dictionary_search(rb_dictionary *dtree, + * void (*destroy_cb)(rb_dictionary_element *delem, void *privdata), * void *privdata); * * Searches all entries in a DTree using a custom callback. @@ -506,11 +506,11 @@ void rb_dictionary_foreach(struct Dictionary *dtree, * Side Effects: * - a dtree is iterated until the requested conditions are met */ -void *rb_dictionary_search(struct Dictionary *dtree, - void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata), +void *rb_dictionary_search(rb_dictionary *dtree, + void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata), void *privdata) { - struct DictionaryElement *n, *tn; + rb_dictionary_element *n, *tn; void *ret = NULL; lrb_assert(dtree != NULL); @@ -518,7 +518,7 @@ void *rb_dictionary_search(struct Dictionary *dtree, RB_DLINK_FOREACH_SAFE(n, tn, dtree->head) { /* delem_t is a subclass of node_t. */ - struct DictionaryElement *delem = (struct DictionaryElement *) n; + rb_dictionary_element *delem = (rb_dictionary_element *) n; if (foreach_cb != NULL) ret = (*foreach_cb)(delem, privdata); @@ -531,8 +531,8 @@ void *rb_dictionary_search(struct Dictionary *dtree, } /* - * rb_dictionary_foreach_start(struct Dictionary *dtree, - * struct DictionaryIter *state); + * rb_dictionary_foreach_start(rb_dictionary *dtree, + * rb_dictionary_iter *state); * * Initializes a static DTree iterator. * @@ -546,8 +546,8 @@ void *rb_dictionary_search(struct Dictionary *dtree, * Side Effects: * - the static iterator, &state, is initialized. */ -void rb_dictionary_foreach_start(struct Dictionary *dtree, - struct DictionaryIter *state) +void rb_dictionary_foreach_start(rb_dictionary *dtree, + rb_dictionary_iter *state) { lrb_assert(dtree != NULL); lrb_assert(state != NULL); @@ -568,8 +568,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree, } /* - * rb_dictionary_foreach_cur(struct Dictionary *dtree, - * struct DictionaryIter *state); + * rb_dictionary_foreach_cur(rb_dictionary *dtree, + * rb_dictionary_iter *state); * * Returns the data from the current node being iterated by the * static iterator. @@ -584,8 +584,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree, * Side Effects: * - none */ -void *rb_dictionary_foreach_cur(struct Dictionary *dtree, - struct DictionaryIter *state) +void *rb_dictionary_foreach_cur(rb_dictionary *dtree, + rb_dictionary_iter *state) { lrb_assert(dtree != NULL); lrb_assert(state != NULL); @@ -594,8 +594,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree, } /* - * rb_dictionary_foreach_next(struct Dictionary *dtree, - * struct DictionaryIter *state); + * rb_dictionary_foreach_next(rb_dictionary *dtree, + * rb_dictionary_iter *state); * * Advances a static DTree iterator. * @@ -609,8 +609,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree, * Side Effects: * - the static iterator, &state, is advanced to a new DTree node. */ -void rb_dictionary_foreach_next(struct Dictionary *dtree, - struct DictionaryIter *state) +void rb_dictionary_foreach_next(rb_dictionary *dtree, + rb_dictionary_iter *state) { lrb_assert(dtree != NULL); lrb_assert(state != NULL); @@ -630,7 +630,7 @@ void rb_dictionary_foreach_next(struct Dictionary *dtree, } /* - * rb_dictionary_find(struct Dictionary *dtree, const void *key) + * rb_dictionary_find(rb_dictionary *dtree, const void *key) * * Looks up a DTree node by name. * @@ -645,7 +645,7 @@ void rb_dictionary_foreach_next(struct Dictionary *dtree, * Side Effects: * - none */ -struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void *key) +rb_dictionary_element *rb_dictionary_find(rb_dictionary *dict, const void *key) { lrb_assert(dict != NULL); lrb_assert(key != NULL); @@ -660,7 +660,7 @@ struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void } /* - * rb_dictionary_add(struct Dictionary *dtree, const void *key, void *data) + * rb_dictionary_add(rb_dictionary *dtree, const void *key, void *data) * * Creates a new DTree node and binds data to it. * @@ -676,9 +676,9 @@ struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void * Side Effects: * - data is inserted into the DTree. */ -struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void *key, void *data) +rb_dictionary_element *rb_dictionary_add(rb_dictionary *dict, const void *key, void *data) { - struct DictionaryElement *delem; + rb_dictionary_element *delem; lrb_assert(dict != NULL); lrb_assert(key != NULL); @@ -695,7 +695,7 @@ struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void } /* - * rb_dictionary_delete(struct Dictionary *dtree, const void *key) + * rb_dictionary_delete(rb_dictionary *dtree, const void *key) * * Deletes data from a dictionary tree. * @@ -713,9 +713,9 @@ struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void * Notes: * - the returned data needs to be mowgli_freed/released manually! */ -void *rb_dictionary_delete(struct Dictionary *dtree, const void *key) +void *rb_dictionary_delete(rb_dictionary *dtree, const void *key) { - struct DictionaryElement *delem = rb_dictionary_find(dtree, key); + rb_dictionary_element *delem = rb_dictionary_find(dtree, key); void *data; if (delem == NULL) @@ -730,7 +730,7 @@ void *rb_dictionary_delete(struct Dictionary *dtree, const void *key) } /* - * rb_dictionary_retrieve(struct Dictionary *dtree, const void *key) + * rb_dictionary_retrieve(rb_dictionary *dtree, const void *key) * * Retrieves data from a dictionary. * @@ -745,9 +745,9 @@ void *rb_dictionary_delete(struct Dictionary *dtree, const void *key) * Side Effects: * - none */ -void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key) +void *rb_dictionary_retrieve(rb_dictionary *dtree, const void *key) { - struct DictionaryElement *delem = rb_dictionary_find(dtree, key); + rb_dictionary_element *delem = rb_dictionary_find(dtree, key); if (delem != NULL) return delem->data; @@ -756,7 +756,7 @@ void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key) } /* - * rb_dictionary_size(struct Dictionary *dict) + * rb_dictionary_size(rb_dictionary *dict) * * Returns the size of a dictionary. * @@ -769,7 +769,7 @@ void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key) * Side Effects: * - none */ -unsigned int rb_dictionary_size(struct Dictionary *dict) +unsigned int rb_dictionary_size(rb_dictionary *dict) { lrb_assert(dict != NULL); @@ -778,7 +778,7 @@ unsigned int rb_dictionary_size(struct Dictionary *dict) /* returns the sum of the depths of the subtree rooted in delem at depth depth */ static int -stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth) +stats_recurse(rb_dictionary_element *delem, int depth, int *pmaxdepth) { int result; @@ -793,7 +793,7 @@ stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth) } /* - * rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata) + * rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata) * * Returns the size of a dictionary. * @@ -808,7 +808,7 @@ stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth) * Side Effects: * - callback called with stats text */ -void rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata) +void rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata) { char str[256]; int sum, maxdepth; diff --git a/librb/src/epoll.c b/librb/src/epoll.c index ac7c6be5..1d4d6272 100644 --- a/librb/src/epoll.c +++ b/librb/src/epoll.c @@ -23,8 +23,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: epoll.c 26294 2008-12-13 03:01:19Z androsyn $ */ + #define _GNU_SOURCE 1 #include diff --git a/librb/src/event.c b/librb/src/event.c index 1e124830..cdf41474 100644 --- a/librb/src/event.c +++ b/librb/src/event.c @@ -39,7 +39,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: event.c 26272 2008-12-10 05:55:10Z androsyn $ */ #include diff --git a/librb/src/export-syms.txt b/librb/src/export-syms.txt index ecf64e40..7a1b0cc5 100644 --- a/librb/src/export-syms.txt +++ b/librb/src/export-syms.txt @@ -188,3 +188,4 @@ rb_zstring_serialized rb_zstring_to_c rb_zstring_to_c_alloc rb_zstring_to_ptr +rb_path_to_self diff --git a/librb/src/gnutls.c b/librb/src/gnutls.c index 3bd65f80..4038dc3d 100644 --- a/librb/src/gnutls.c +++ b/librb/src/gnutls.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: gnutls.c 26296 2008-12-13 03:36:00Z androsyn $ */ #include diff --git a/librb/src/helper.c b/librb/src/helper.c index a41fa879..a8dabf3d 100644 --- a/librb/src/helper.c +++ b/librb/src/helper.c @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: helper.c 26092 2008-09-19 15:13:52Z androsyn $ */ + #include #include #include @@ -78,7 +78,7 @@ rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog, if(x > 2) /* don't undo what we just did */ close(x); #else - x = 0; /* shut gcc up */ + (void) x; /* shut gcc up */ #endif rb_lib_init(ilog, irestart, idie, 0, maxfd, dh_size, fd_heap_size); diff --git a/librb/src/kqueue.c b/librb/src/kqueue.c index 7ab9cd72..98e286b7 100644 --- a/librb/src/kqueue.c +++ b/librb/src/kqueue.c @@ -22,7 +22,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: kqueue.c 26092 2008-09-19 15:13:52Z androsyn $ */ #include diff --git a/librb/src/linebuf.c b/librb/src/linebuf.c index 51c97cd9..f14d4a98 100644 --- a/librb/src/linebuf.c +++ b/librb/src/linebuf.c @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: linebuf.c 26092 2008-09-19 15:13:52Z androsyn $ */ #include diff --git a/librb/src/mbedtls.c b/librb/src/mbedtls.c index a31b12e8..0cf4330e 100644 --- a/librb/src/mbedtls.c +++ b/librb/src/mbedtls.c @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id$ */ #include diff --git a/librb/src/nossl.c b/librb/src/nossl.c index 4cc9a06e..e97843b9 100644 --- a/librb/src/nossl.c +++ b/librb/src/nossl.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio.c 24808 2008-01-02 08:17:05Z androsyn $ */ diff --git a/librb/src/openssl.c b/librb/src/openssl.c index 9898bf80..a8d998c4 100644 --- a/librb/src/openssl.c +++ b/librb/src/openssl.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: commio.c 24808 2008-01-02 08:17:05Z androsyn $ */ #include @@ -359,9 +358,10 @@ rb_init_ssl(void) SSL_CTX_set_session_cache_mode(ssl_server_ctx, SSL_SESS_CACHE_OFF); SSL_CTX_set_cipher_list(ssl_server_ctx, librb_ciphers); - /* Set ECDHE on OpenSSL 1.00+, but make sure it's actually available because redhat are dicks - and bastardise their OpenSSL for stupid reasons... */ - #if (OPENSSL_VERSION_NUMBER >= 0x10000000L) && defined(NID_secp384r1) + /* Set ECDHE on OpenSSL 1.00+, but make sure it's actually available + * (it's not by default on Solaris or Red Hat... fuck Red Hat and Oracle) + */ + #if (OPENSSL_VERSION_NUMBER >= 0x10000000L) && !defined(OPENSSL_NO_ECDH) EC_KEY *key = EC_KEY_new_by_curve_name(NID_secp384r1); if (key) { SSL_CTX_set_tmp_ecdh(ssl_server_ctx, key); diff --git a/librb/src/patricia.c b/librb/src/patricia.c index 88f22077..9db07138 100644 --- a/librb/src/patricia.c +++ b/librb/src/patricia.c @@ -4,7 +4,6 @@ * This was then yanked out of the ratbox/devel/src tree and stuffed into * librb and had function names changed, but otherwise not really altered. * - * $Id: patricia.c 24244 2007-08-22 19:04:55Z androsyn $ * Dave Plonka * * This product includes software developed by the University of Michigan, diff --git a/librb/src/poll.c b/librb/src/poll.c index f53851b5..0356776c 100644 --- a/librb/src/poll.c +++ b/librb/src/poll.c @@ -22,7 +22,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: poll.c 26092 2008-09-19 15:13:52Z androsyn $ */ #include #include diff --git a/librb/src/ports.c b/librb/src/ports.c index af025718..1527a915 100644 --- a/librb/src/ports.c +++ b/librb/src/ports.c @@ -23,7 +23,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: ports.c 26286 2008-12-10 23:28:53Z androsyn $ */ #include @@ -123,7 +122,7 @@ rb_setselect_ports(rb_fde_t *F, unsigned int type, PF * handler, void *client_da int rb_select_ports(long delay) { - int i, fd; + int i, fd = -1; unsigned int nget = 1; struct timespec poll_time; struct timespec *p = NULL; diff --git a/librb/src/radixtree.c b/librb/src/radixtree.c index 70740b51..abc153fa 100644 --- a/librb/src/radixtree.c +++ b/librb/src/radixtree.c @@ -53,11 +53,15 @@ rb_dlink_list radixtree_list = {NULL, NULL, 0}; */ union rb_radixtree_elem; +typedef union rb_radixtree_elem rb_radixtree_elem; + +/* Other typedefs are in rb_radixtree.h */ +typedef struct rb_radixtree_node rb_radixtree_node; struct rb_radixtree { void (*canonize_cb)(char *key); - union rb_radixtree_elem *root; + rb_radixtree_elem *root; unsigned int count; char *id; @@ -74,8 +78,8 @@ struct rb_radixtree_node int nibnum; /* branches of the tree */ - union rb_radixtree_elem *down[POINTERS_PER_NODE]; - union rb_radixtree_elem *parent; + rb_radixtree_elem *down[POINTERS_PER_NODE]; + rb_radixtree_elem *parent; char parent_val; }; @@ -90,7 +94,7 @@ struct rb_radixtree_leaf /* key (canonized copy) */ char *key; - union rb_radixtree_elem *parent; + rb_radixtree_elem *parent; char parent_val; }; @@ -98,9 +102,9 @@ struct rb_radixtree_leaf union rb_radixtree_elem { int nibnum; - struct rb_radixtree_node node; + rb_radixtree_node node; - struct rb_radixtree_leaf leaf; + rb_radixtree_leaf leaf; }; #define IS_LEAF(elem) ((elem)->nibnum == -1) @@ -123,8 +127,8 @@ union rb_radixtree_elem * Side Effects: * - none */ -static union rb_radixtree_elem * -first_leaf(union rb_radixtree_elem *delem) +static rb_radixtree_elem * +first_leaf(rb_radixtree_elem *delem) { int val; @@ -160,10 +164,10 @@ first_leaf(union rb_radixtree_elem *delem) * - if services runs out of memory and cannot allocate the object, * the program will abort. */ -struct rb_radixtree * +rb_radixtree * rb_radixtree_create(const char *name, void (*canonize_cb)(char *key)) { - struct rb_radixtree *dtree = (struct rb_radixtree *) rb_malloc(sizeof(struct rb_radixtree)); + rb_radixtree *dtree = (rb_radixtree *) rb_malloc(sizeof(rb_radixtree)); dtree->canonize_cb = canonize_cb; dtree->id = rb_strdup(name); @@ -175,7 +179,7 @@ rb_radixtree_create(const char *name, void (*canonize_cb)(char *key)) } /* - * rb_radixtree_destroy(struct rb_radixtree *dtree, + * rb_radixtree_destroy(rb_radixtree *dtree, * void (*destroy_cb)(const char *key, void *data, void *privdata), * void *privdata); * @@ -197,10 +201,10 @@ rb_radixtree_create(const char *name, void (*canonize_cb)(char *key)) * DTree will not be destroyed. */ void -rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata) +rb_radixtree_destroy(rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata) { - struct rb_radixtree_iteration_state state; - union rb_radixtree_elem *delem; + rb_radixtree_iteration_state state; + rb_radixtree_elem *delem; void *entry; @@ -223,7 +227,7 @@ rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char * } /* - * rb_radixtree_foreach(struct rb_radixtree *dtree, + * rb_radixtree_foreach(rb_radixtree *dtree, * int (*foreach_cb)(const char *key, void *data, void *privdata), * void *privdata); * @@ -241,9 +245,9 @@ rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char * * - on success, a dtree is iterated */ void -rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata) +rb_radixtree_foreach(rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata) { - union rb_radixtree_elem *delem, *next; + rb_radixtree_elem *delem, *next; int val; @@ -299,7 +303,7 @@ rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *k } /* - * rb_radixtree_search(struct rb_radixtree *dtree, + * rb_radixtree_search(rb_radixtree *dtree, * void *(*foreach_cb)(const char *key, void *data, void *privdata), * void *privdata); * @@ -318,9 +322,9 @@ rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *k * - a dtree is iterated until the requested conditions are met */ void * -rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata) +rb_radixtree_search(rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata) { - union rb_radixtree_elem *delem, *next; + rb_radixtree_elem *delem, *next; int val; void *ret = NULL; @@ -382,8 +386,8 @@ rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char * } /* - * rb_radixtree_foreach_start(struct rb_radixtree *dtree, - * struct rb_radixtree_iteration_state *state); + * rb_radixtree_foreach_start(rb_radixtree *dtree, + * rb_radixtree_iteration_state *state); * * Initializes a static DTree iterator. * @@ -398,7 +402,7 @@ rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char * * - the static iterator, &state, is initialized. */ void -rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state) +rb_radixtree_foreach_start(rb_radixtree *dtree, rb_radixtree_iteration_state *state) { if (dtree == NULL) return; @@ -421,8 +425,8 @@ rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_itera } /* - * rb_radixtree_foreach_cur(struct rb_radixtree *dtree, - * struct rb_radixtree_iteration_state *state); + * rb_radixtree_foreach_cur(rb_radixtree *dtree, + * rb_radixtree_iteration_state *state); * * Returns the data from the current node being iterated by the * static iterator. @@ -438,7 +442,7 @@ rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_itera * - none */ void * -rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state) +rb_radixtree_foreach_cur(rb_radixtree *dtree, rb_radixtree_iteration_state *state) { if (dtree == NULL) return NULL; @@ -446,12 +450,12 @@ rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iterati lrb_assert(state != NULL); return STATE_CUR(state) != NULL ? - ((struct rb_radixtree_leaf *) STATE_CUR(state))->data : NULL; + ((rb_radixtree_leaf *) STATE_CUR(state))->data : NULL; } /* - * rb_radixtree_foreach_next(struct rb_radixtree *dtree, - * struct rb_radixtree_iteration_state *state); + * rb_radixtree_foreach_next(rb_radixtree *dtree, + * rb_radixtree_iteration_state *state); * * Advances a static DTree iterator. * @@ -466,11 +470,11 @@ rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iterati * - the static iterator, &state, is advanced to a new DTree node. */ void -rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state) +rb_radixtree_foreach_next(rb_radixtree *dtree, rb_radixtree_iteration_state *state) { - struct rb_radixtree_leaf *leaf; + rb_radixtree_leaf *leaf; - union rb_radixtree_elem *delem, *next; + rb_radixtree_elem *delem, *next; int val; @@ -537,7 +541,7 @@ rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iterat } /* - * rb_radixtree_elem_find(struct rb_radixtree *dtree, const char *key) + * rb_radixtree_elem_find(rb_radixtree *dtree, const char *key) * * Looks up a DTree node by name. * @@ -553,14 +557,14 @@ rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iterat * Side Effects: * - none */ -struct rb_radixtree_leaf * -rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy) +rb_radixtree_leaf * +rb_radixtree_elem_find(rb_radixtree *dict, const char *key, int fuzzy) { char ckey_store[256]; char *ckey_buf = NULL; const char *ckey; - union rb_radixtree_elem *delem; + rb_radixtree_elem *delem; int val, keylen; @@ -612,7 +616,7 @@ rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy) } /* - * rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key) + * rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key) * * Starts iteration from a specified key, by wrapping rb_radixtree_elem_find(). * @@ -628,7 +632,7 @@ rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy) * - the iterator's state is initialized at a specific point */ void -rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key) +rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key) { lrb_assert(dtree != NULL); lrb_assert(state != NULL); @@ -647,7 +651,7 @@ rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_ } /* - * rb_radixtree_add(struct rb_radixtree *dtree, const char *key, void *data) + * rb_radixtree_add(rb_radixtree *dtree, const char *key, void *data) * * Creates a new DTree node and binds data to it. * @@ -663,14 +667,14 @@ rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_ * Side Effects: * - data is inserted into the DTree. */ -struct rb_radixtree_leaf * -rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data) +rb_radixtree_leaf * +rb_radixtree_elem_add(rb_radixtree *dict, const char *key, void *data) { char *ckey; - union rb_radixtree_elem *delem, *prev, *newnode; + rb_radixtree_elem *delem, *prev, *newnode; - union rb_radixtree_elem **place1; + rb_radixtree_elem **place1; int val, keylen; int i, j; @@ -720,7 +724,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data) lrb_assert(prev == NULL); lrb_assert(dict->count == 0); place1 = &dict->root; - *place1 = rb_malloc(sizeof(struct rb_radixtree_leaf)); + *place1 = rb_malloc(sizeof(rb_radixtree_leaf)); lrb_assert(*place1 != NULL); (*place1)->nibnum = -1; (*place1)->leaf.data = data; @@ -745,7 +749,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data) if ((prev == NULL) || (prev->nibnum < i)) { /* Insert new node below prev */ - newnode = rb_malloc(sizeof(struct rb_radixtree_node)); + newnode = rb_malloc(sizeof(rb_radixtree_node)); lrb_assert(newnode != NULL); newnode->nibnum = i; newnode->node.parent = prev; @@ -800,7 +804,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data) val = NIBBLE_VAL(ckey, i); place1 = &newnode->node.down[val]; lrb_assert(*place1 == NULL); - *place1 = rb_malloc(sizeof(struct rb_radixtree_leaf)); + *place1 = rb_malloc(sizeof(rb_radixtree_leaf)); lrb_assert(*place1 != NULL); (*place1)->nibnum = -1; (*place1)->leaf.data = data; @@ -812,13 +816,13 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data) } int -rb_radixtree_add(struct rb_radixtree *dict, const char *key, void *data) +rb_radixtree_add(rb_radixtree *dict, const char *key, void *data) { return (rb_radixtree_elem_add(dict, key, data) != NULL); } /* - * rb_radixtree_delete(struct rb_radixtree *dtree, const char *key) + * rb_radixtree_delete(rb_radixtree *dtree, const char *key) * * Deletes data from a patricia tree. * @@ -837,10 +841,10 @@ rb_radixtree_add(struct rb_radixtree *dict, const char *key, void *data) * - the returned data needs to be rb_freed/released manually! */ void * -rb_radixtree_delete(struct rb_radixtree *dict, const char *key) +rb_radixtree_delete(rb_radixtree *dict, const char *key) { void *data; - struct rb_radixtree_leaf *leaf; + rb_radixtree_leaf *leaf; leaf = rb_radixtree_elem_find(dict, key, 0); @@ -853,16 +857,16 @@ rb_radixtree_delete(struct rb_radixtree *dict, const char *key) } void -rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *leaf) +rb_radixtree_elem_delete(rb_radixtree *dict, rb_radixtree_leaf *leaf) { - union rb_radixtree_elem *delem, *prev, *next; + rb_radixtree_elem *delem, *prev, *next; int val, i, used; lrb_assert(dict != NULL); lrb_assert(leaf != NULL); - delem = (union rb_radixtree_elem *) leaf; + delem = (rb_radixtree_elem *) leaf; val = delem->leaf.parent_val; prev = delem->leaf.parent; @@ -924,7 +928,7 @@ rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *le } /* - * rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key) + * rb_radixtree_retrieve(rb_radixtree *dtree, const char *key) * * Retrieves data from a patricia. * @@ -940,9 +944,9 @@ rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *le * - none */ void * -rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key) +rb_radixtree_retrieve(rb_radixtree *dtree, const char *key) { - struct rb_radixtree_leaf *delem = rb_radixtree_elem_find(dtree, key, 0); + rb_radixtree_leaf *delem = rb_radixtree_elem_find(dtree, key, 0); if (delem != NULL) return delem->data; @@ -951,7 +955,7 @@ rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key) } const char * -rb_radixtree_elem_get_key(struct rb_radixtree_leaf *leaf) +rb_radixtree_elem_get_key(rb_radixtree_leaf *leaf) { lrb_assert(leaf != NULL); @@ -959,7 +963,7 @@ rb_radixtree_elem_get_key(struct rb_radixtree_leaf *leaf) } void -rb_radixtree_elem_set_data(struct rb_radixtree_leaf *leaf, void *data) +rb_radixtree_elem_set_data(rb_radixtree_leaf *leaf, void *data) { lrb_assert(leaf != NULL); @@ -967,7 +971,7 @@ rb_radixtree_elem_set_data(struct rb_radixtree_leaf *leaf, void *data) } void * -rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf) +rb_radixtree_elem_get_data(rb_radixtree_leaf *leaf) { lrb_assert(leaf != NULL); @@ -975,7 +979,7 @@ rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf) } /* - * rb_radixtree_size(struct rb_radixtree *dict) + * rb_radixtree_size(rb_radixtree *dict) * * Returns the size of a patricia. * @@ -989,7 +993,7 @@ rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf) * - none */ unsigned int -rb_radixtree_size(struct rb_radixtree *dict) +rb_radixtree_size(rb_radixtree *dict) { lrb_assert(dict != NULL); @@ -999,11 +1003,11 @@ rb_radixtree_size(struct rb_radixtree *dict) /* returns the sum of the depths of the subtree rooted in delem at depth depth */ /* there is no need for this to be recursive, but it is easier... */ static int -stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth) +stats_recurse(rb_radixtree_elem *delem, int depth, int *pmaxdepth) { int result = 0; int val; - union rb_radixtree_elem *next; + rb_radixtree_elem *next; if (depth > *pmaxdepth) *pmaxdepth = depth; @@ -1046,7 +1050,7 @@ stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth) } /* - * rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata) + * rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata) * * Returns the size of a patricia. * @@ -1062,7 +1066,7 @@ stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth) * - callback called with stats text */ void -rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata) +rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata) { char str[256]; int sum, maxdepth; diff --git a/librb/src/rawbuf.c b/librb/src/rawbuf.c index 29b06fbf..4e83270b 100644 --- a/librb/src/rawbuf.c +++ b/librb/src/rawbuf.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id$ */ #include #include diff --git a/librb/src/rb_lib.c b/librb/src/rb_lib.c index 54fe3bf5..041200f9 100644 --- a/librb/src/rb_lib.c +++ b/librb/src/rb_lib.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_lib.c 26282 2008-12-10 20:33:21Z androsyn $ */ #include diff --git a/librb/src/rb_memory.c b/librb/src/rb_memory.c index 3caa06ca..32b2689a 100644 --- a/librb/src/rb_memory.c +++ b/librb/src/rb_memory.c @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: rb_memory.c 26092 2008-09-19 15:13:52Z androsyn $ */ #include #include diff --git a/librb/src/select.c b/librb/src/select.c index 6425e49d..61d464a4 100644 --- a/librb/src/select.c +++ b/librb/src/select.c @@ -22,8 +22,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: select.c 26092 2008-09-19 15:13:52Z androsyn $ */ + #define FD_SETSIZE 65535 #include #include diff --git a/librb/src/sigio.c b/librb/src/sigio.c index b847d0b0..d5faa171 100644 --- a/librb/src/sigio.c +++ b/librb/src/sigio.c @@ -23,7 +23,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: sigio.c 26092 2008-09-19 15:13:52Z androsyn $ */ #ifndef _GNU_SOURCE diff --git a/librb/src/tools.c b/librb/src/tools.c index 0f4b68c1..b42fdbaa 100644 --- a/librb/src/tools.c +++ b/librb/src/tools.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: tools.c 26170 2008-10-26 20:59:07Z androsyn $ * * Here is the original header: * @@ -32,6 +31,7 @@ * defined, tools.h will build inlined versions of the functions * on supported compilers */ + #define _GNU_SOURCE 1 #include #include @@ -210,12 +210,10 @@ rb_strnlen(const char *s, size_t count) int rb_snprintf_append(char *str, size_t len, const char *format, ...) { - int x; - if(len == 0) return 0; - x = strlen(str); + size_t x = strlen(str); if(len < x) { @@ -225,10 +223,10 @@ rb_snprintf_append(char *str, size_t len, const char *format, ...) va_list ap; va_start(ap, format); - x = (vsnprintf(str + x, len - x, format, ap) + (int)x); + int y = (vsnprintf(str + x, len - x, format, ap) + (int)x); va_end(ap); - return (x); + return (y); } /* rb_basename diff --git a/librb/src/unix.c b/librb/src/unix.c index 31ecac35..521f5329 100644 --- a/librb/src/unix.c +++ b/librb/src/unix.c @@ -21,24 +21,28 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA * - * $Id: unix.c 26180 2008-11-11 00:00:12Z androsyn $ */ + #include #include - #ifndef _WIN32 #include +#ifdef HAVE_DLINFO +# include +# include +#endif + +#ifdef __APPLE__ +#include +#include +#endif #if defined(HAVE_SPAWN_H) && defined(HAVE_POSIX_SPAWN) #include -#ifdef __APPLE__ -#include -#endif - #ifndef __APPLE__ extern char **environ; #endif @@ -151,5 +155,36 @@ rb_getpid(void) return getpid(); } +const char * +rb_path_to_self(void) +{ + static char path_buf[4096]; +#if defined(HAVE_GETEXECNAME) + char *s = getexecname(); + if (s == NULL) + return NULL; + realpath(s, path_buf); + return path_buf; +#elif defined(__linux__) + if (readlink("/proc/self/exe", path_buf, sizeof path_buf) != -1) + return path_buf; + return NULL; +#elif defined(HAVE_DLINFO) + struct link_map *map = NULL; + dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); + if (map == NULL) + return NULL; + realpath(map->l_name, path_buf); +#elif defined(__APPLE__) + char tmp_path[4096]; + uint32_t pathlen = 4096; + + if (_NSGetExecutablePath(tmp_path, &pathlen) < 0) + return NULL; + + realpath(tmp_path, path_buf); + return path_buf; +#endif +} #endif /* !WIN32 */ diff --git a/librb/src/version.c.SH b/librb/src/version.c.SH index 6d0bf442..22cb63f2 100644 --- a/librb/src/version.c.SH +++ b/librb/src/version.c.SH @@ -1,6 +1,5 @@ #!/bin/sh -# $Id: version.c.SH 24870 2008-01-10 16:51:01Z androsyn $ spitshell=cat package=librb @@ -21,7 +20,7 @@ $spitshell >version.c < @@ -94,7 +93,7 @@ rb_spawn_process(const char *path, const char **argv) } pid_t -rb_waitpid(int pid, int *status, int flags) +rb_waitpid(pid_t pid, int *status, int flags) { DWORD timeout = (flags & WNOHANG) ? 0 : INFINITE; HANDLE hProcess; @@ -152,7 +151,7 @@ rb_setenv(const char *name, const char *value, int overwrite) } int -rb_kill(int pid, int sig) +rb_kill(pid_t pid, int sig) { HANDLE hProcess; int ret = -1; @@ -415,7 +414,7 @@ rb_setup_fd_win32(rb_fde_t *F) { case RB_FD_SOCKET: { - u_long nonb = 1; + unsigned long nonb = 1; if(ioctlsocket((SOCKET) F->fd, FIONBIO, &nonb) == -1) { rb_get_errno(); @@ -614,6 +613,15 @@ rb_strerror(int error) rb_strlcpy(buf, _rb_strerror(error), sizeof(buf)); return buf; } + +const char * +rb_path_to_self(void) +{ + static char path_buf[MAX_PATH]; + GetModuleFileName(NULL, path_buf, MAX_PATH); + return path_buf; +} + #else /* win32 not supported */ int rb_init_netio_win32(void) diff --git a/modules/Makefile.am b/modules/Makefile.am index 539f94d7..8c2fb9df 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/librb/include $(LTDLINCL) AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared AM_LDFLAGS += -export-symbols-regex _mheader -LIBS += $(top_srcdir)/librb/src/librb.la $(top_srcdir)/ircd/libircd.la +LIBS += $(top_srcdir)/ircd/libircd.la auto_load_moddir=@moduledir@/autoload @@ -21,7 +21,6 @@ auto_load_mod_LTLIBRARIES = \ m_challenge.la \ m_chghost.la \ m_close.la \ - m_cmessage.la \ m_connect.la \ m_dline.la \ m_encap.la \ diff --git a/modules/cap_server_time.c b/modules/cap_server_time.c index 3119319f..73fce017 100644 --- a/modules/cap_server_time.c +++ b/modules/cap_server_time.c @@ -52,7 +52,7 @@ mapi_cap_list_av2 cap_server_time_cap_list[] = { static void cap_server_time_process(hook_data *data) { - static char buf[IRCD_BUFSIZE]; + static char buf[BUFSIZE]; time_t ts = rb_current_time(); struct MsgBuf *msgbuf = data->arg1; diff --git a/modules/core/m_ban.c b/modules/core/m_ban.c index b46e830b..94c18f2d 100644 --- a/modules/core/m_ban.c +++ b/modules/core/m_ban.c @@ -31,8 +31,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "match.h" #include "s_conf.h" diff --git a/modules/core/m_error.c b/modules/core/m_error.c index 078dcbc4..d8a93148 100644 --- a/modules/core/m_error.c +++ b/modules/core/m_error.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "numeric.h" #include "send.h" diff --git a/modules/core/m_join.c b/modules/core/m_join.c index a2e78917..4018ff82 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "channel.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -427,15 +426,6 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ newts = atol(parv[1]); oldts = chptr->channelts; -#ifdef IGNORE_BOGUS_TS - if(newts < 800000000) - { - sendto_realops_snomask(SNO_DEBUG, L_ALL, - "*** Bogus TS %ld on %s ignored from %s", - (long) newts, chptr->chname, client_p->name); - newts = (oldts == 0) ? oldts : 800000000; - } -#else /* making a channel TS0 */ if(!isnew && !newts && oldts) { @@ -446,7 +436,6 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ "Server %s changing TS on %s from %ld to 0", source_p->name, chptr->chname, (long) oldts); } -#endif if(isnew) chptr->channelts = newts; @@ -614,16 +603,6 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source oldts = chptr->channelts; oldmode = &chptr->mode; -#ifdef IGNORE_BOGUS_TS - if(newts < 800000000) - { - sendto_realops_snomask(SNO_DEBUG, L_ALL, - "*** Bogus TS %ld on %s ignored from %s", - (long) newts, chptr->chname, client_p->name); - - newts = (oldts == 0) ? oldts : 800000000; - } -#else if(!isnew && !newts && oldts) { sendto_channel_local(ALL_MEMBERS, chptr, @@ -634,7 +613,6 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source "Server %s changing TS on %s from %ld to 0", source_p->name, chptr->chname, (long) oldts); } -#endif if(isnew) chptr->channelts = newts; diff --git a/modules/core/m_message.c b/modules/core/m_message.c index d1b2da6e..afc8e04f 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -26,7 +26,6 @@ #include "client.h" #include "ircd.h" #include "numeric.h" -#include "common.h" #include "s_conf.h" #include "s_serv.h" #include "msg.h" diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index cd9dc9c0..7930ddea 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -40,7 +40,6 @@ #include "msg.h" #include "parse.h" #include "modules.h" -#include "common.h" #include "packet.h" #include "scache.h" #include "s_newconf.h" diff --git a/modules/core/m_part.c b/modules/core/m_part.c index 15357c00..094f39f1 100644 --- a/modules/core/m_part.c +++ b/modules/core/m_part.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "channel.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/core/m_server.c b/modules/core/m_server.c index 992ede46..3f16888a 100644 --- a/modules/core/m_server.c +++ b/modules/core/m_server.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" /* client struct */ -#include "common.h" #include "hash.h" /* add_to_client_hash */ #include "match.h" #include "ircd.h" /* me */ diff --git a/modules/core/m_squit.c b/modules/core/m_squit.c index fb2ce5cc..ad2dc965 100644 --- a/modules/core/m_squit.c +++ b/modules/core/m_squit.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" diff --git a/modules/m_cap.c b/modules/m_cap.c index 726fbe4a..a1dd5b29 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -146,19 +146,18 @@ clicap_find(const char *data, int *negate, int *finished) * Generates a list of capabilities. * * Inputs: client to send to, subcmd to send, - * flags to match against: 0 to do none, -1 if client has no flags, - * int to whether we are doing CAP CLEAR + * flags to match against: 0 to do none, -1 if client has no flags * Outputs: None */ static void -clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clear) +clicap_generate(struct Client *source_p, const char *subcmd, int flags) { char buf[BUFSIZE] = { 0 }; char capbuf[BUFSIZE] = { 0 }; int buflen = 0; - int curlen, mlen; + int mlen; struct CapabilityEntry *entry; - struct DictionaryIter iter; + rb_dictionary_iter iter; mlen = snprintf(buf, sizeof buf, ":%s CAP %s %s", me.name, @@ -172,20 +171,14 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea return; } - DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict) + RB_DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict) { size_t caplen = 0; struct ClientCapability *clicap = entry->ownerdata; const char *data = NULL; - if(flags) - { - if(!IsCapableEntry(source_p, entry)) - continue; - /* they are capable of this, check sticky */ - else if(clear && HasCapabilityFlag(entry, CLICAP_FLAGS_STICKY)) - continue; - } + if(flags && !IsCapableEntry(source_p, entry)) + continue; if (!clicap_visible(source_p, entry)) continue; @@ -211,8 +204,8 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea memset(capbuf, 0, sizeof capbuf); } - buflen = rb_snprintf_append(capbuf, sizeof capbuf, "%s%s%s%s ", - clear ? "-" : "", entry->cap, data != NULL ? "=" : "", data != NULL ? data : ""); + buflen = rb_snprintf_append(capbuf, sizeof capbuf, "%s%s%s ", + entry->cap, data != NULL ? "=" : "", data != NULL ? data : ""); } /* remove trailing space */ @@ -254,15 +247,6 @@ cap_ack(struct Client *source_p, const char *arg) source_p->localClient->caps &= ~capdel; } -static void -cap_clear(struct Client *source_p, const char *arg) -{ - clicap_generate(source_p, "ACK", - source_p->localClient->caps ? source_p->localClient->caps : -1, 1); - - source_p->localClient->caps = 0; -} - static void cap_end(struct Client *source_p, const char *arg) { @@ -282,7 +266,7 @@ cap_list(struct Client *source_p, const char *arg) { /* list of what theyre currently using */ clicap_generate(source_p, "LIST", - source_p->localClient->caps ? source_p->localClient->caps : -1, 0); + source_p->localClient->caps ? source_p->localClient->caps : -1); } static void @@ -298,7 +282,7 @@ cap_ls(struct Client *source_p, const char *arg) } /* list of what we support */ - clicap_generate(source_p, "LS", 0, 0); + clicap_generate(source_p, "LS", 0); } static void @@ -404,7 +388,6 @@ static struct clicap_cmd } clicap_cmdlist[] = { /* This list *MUST* be in alphabetical order */ { "ACK", cap_ack }, - { "CLEAR", cap_clear }, { "END", cap_end }, { "LIST", cap_list }, { "LS", cap_ls }, diff --git a/modules/m_certfp.c b/modules/m_certfp.c index d5c1c558..f6dc003a 100644 --- a/modules/m_certfp.c +++ b/modules/m_certfp.c @@ -29,7 +29,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "hash.h" #include "ircd.h" diff --git a/modules/m_chghost.c b/modules/m_chghost.c index e8b235e0..b6711f76 100644 --- a/modules/m_chghost.c +++ b/modules/m_chghost.c @@ -13,8 +13,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "numeric.h" #include "s_conf.h" diff --git a/modules/m_cmessage.c b/modules/m_cmessage.c deleted file mode 100644 index f0684867..00000000 --- a/modules/m_cmessage.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd). - * m_cmessage.c: Handles CPRIVMSG/CNOTICE, target change limitation free - * PRIVMSG/NOTICE implementations. - * - * Copyright (C) 2005 Lee Hardy - * Copyright (C) 2005 ircd-ratbox development team - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1.Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2.Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3.The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "stdinc.h" -#include "client.h" -#include "channel.h" -#include "numeric.h" -#include "msg.h" -#include "modules.h" -#include "hash.h" -#include "send.h" -#include "s_conf.h" -#include "packet.h" -#include "supported.h" - -static const char cmessage_desc[] = - "Provides the CPRIVMSG and CNOTICE facilities for bypassing anti-spam measures"; - -static void m_cmessage(int, const char *, struct MsgBuf *, struct Client *, struct Client *, int, const char **); -static void m_cprivmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **); -static void m_cnotice(struct MsgBuf *, struct Client *, struct Client *, int, const char **); - -static int -_modinit(void) -{ - add_isupport("CPRIVMSG", isupport_string, ""); - add_isupport("CNOTICE", isupport_string, ""); - - return 0; -} - -static void -_moddeinit(void) -{ - delete_isupport("CPRIVMSG"); - delete_isupport("CNOTICE"); -} - -struct Message cprivmsg_msgtab = { - "CPRIVMSG", 0, 0, 0, 0, - {mg_ignore, {m_cprivmsg, 4}, mg_ignore, mg_ignore, mg_ignore, {m_cprivmsg, 4}} -}; -struct Message cnotice_msgtab = { - "CNOTICE", 0, 0, 0, 0, - {mg_ignore, {m_cnotice, 4}, mg_ignore, mg_ignore, mg_ignore, {m_cnotice, 4}} -}; - -mapi_clist_av1 cmessage_clist[] = { &cprivmsg_msgtab, &cnotice_msgtab, NULL }; - -DECLARE_MODULE_AV2(cmessage, _modinit, _moddeinit, cmessage_clist, NULL, NULL, NULL, NULL, cmessage_desc); - -#define PRIVMSG 0 -#define NOTICE 1 - -static void -m_cprivmsg(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) -{ - m_cmessage(PRIVMSG, "PRIVMSG", msgbuf_p, client_p, source_p, parc, parv); -} - -static void -m_cnotice(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) -{ - m_cmessage(NOTICE, "NOTICE", msgbuf_p, client_p, source_p, parc, parv); -} - -static void -m_cmessage(int p_or_n, const char *command, struct MsgBuf *msgbuf_p, - struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) -{ - struct Client *target_p; - struct Channel *chptr; - struct membership *msptr; - - if(!IsFloodDone(source_p)) - flood_endgrace(source_p); - - if((target_p = find_named_person(parv[1])) == NULL) - { - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_NOSUCHNICK, - form_str(ERR_NOSUCHNICK), parv[1]); - return; - } - - if((chptr = find_channel(parv[2])) == NULL) - { - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, - form_str(ERR_NOSUCHCHANNEL), parv[2]); - return; - } - - if((msptr = find_channel_membership(chptr, source_p)) == NULL) - { - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_NOTONCHANNEL, - form_str(ERR_NOTONCHANNEL), - chptr->chname); - return; - } - - if(!is_chanop_voiced(msptr)) - { - if(p_or_n != NOTICE) - sendto_one(source_p, form_str(ERR_VOICENEEDED), - me.name, source_p->name, chptr->chname); - return; - } - - if(!IsMember(target_p, chptr)) - { - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, - form_str(ERR_USERNOTINCHANNEL), - target_p->name, chptr->chname); - return; - } - - if(MyClient(target_p) && (IsSetCallerId(target_p) || (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])) && - !accept_message(source_p, target_p) && !IsOper(source_p)) - { - if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0]) - { - if (p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_NONONREG, - form_str(ERR_NONONREG), - target_p->name); - return; - } - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, ERR_TARGUMODEG, - form_str(ERR_TARGUMODEG), target_p->name); - - if((target_p->localClient->last_caller_id_time + - ConfigFileEntry.caller_id_wait) < rb_current_time()) - { - if(p_or_n != NOTICE) - sendto_one_numeric(source_p, RPL_TARGNOTIFY, - form_str(RPL_TARGNOTIFY), - target_p->name); - - sendto_one(target_p, form_str(RPL_UMODEGMSG), - me.name, target_p->name, source_p->name, - source_p->username, source_p->host); - - target_p->localClient->last_caller_id_time = rb_current_time(); - } - - return; - } - - if(p_or_n != NOTICE) - source_p->localClient->last = rb_current_time(); - - sendto_anywhere(target_p, source_p, command, ":%s", parv[3]); -} diff --git a/modules/m_connect.c b/modules/m_connect.c index d3e4a598..3f1db4dd 100644 --- a/modules/m_connect.c +++ b/modules/m_connect.c @@ -99,7 +99,7 @@ mo_connect(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour return; } - if(ServerConfSSL(server_p) && (!ssl_ok || !get_ssld_count())) + if(ServerConfSSL(server_p) && (!ircd_ssl_ok || !get_ssld_count())) { sendto_one_notice(source_p, ":Connect: Server %s is set to use SSL/TLS but SSL/TLS is not configured.", @@ -192,7 +192,7 @@ ms_connect(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour return; } - if(ServerConfSSL(server_p) && (!ssl_ok || !get_ssld_count())) + if(ServerConfSSL(server_p) && (!ircd_ssl_ok || !get_ssld_count())) { sendto_one_notice(source_p, ":Connect: Server %s is set to use SSL/TLS but SSL/TLS is not configured.", diff --git a/modules/m_dline.c b/modules/m_dline.c index 9c3a3988..9a056d05 100644 --- a/modules/m_dline.c +++ b/modules/m_dline.c @@ -26,7 +26,6 @@ #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "hostmask.h" diff --git a/modules/m_encap.c b/modules/m_encap.c index 9ba07d1e..f87ed655 100644 --- a/modules/m_encap.c +++ b/modules/m_encap.c @@ -31,8 +31,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "numeric.h" #include "s_serv.h" diff --git a/modules/m_etrace.c b/modules/m_etrace.c index 3a0f5e18..064206ae 100644 --- a/modules/m_etrace.c +++ b/modules/m_etrace.c @@ -35,7 +35,6 @@ #include "hook.h" #include "client.h" #include "hash.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" @@ -165,8 +164,8 @@ do_etrace(struct Client *source_p, int ipv4, int ipv6) target_p = ptr->data; #ifdef RB_IPV6 - if((!ipv4 && target_p->localClient->ip.ss_family == AF_INET) || - (!ipv6 && target_p->localClient->ip.ss_family == AF_INET6)) + if((!ipv4 && GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET) || + (!ipv6 && GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET6)) continue; #endif diff --git a/modules/m_info.c b/modules/m_info.c index b5cc9c61..81d69a96 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -26,7 +26,6 @@ #include "m_info.h" #include "channel.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "hook.h" @@ -285,12 +284,6 @@ static struct InfoStruct info_table[] = { &ConfigFileEntry.hide_spoof_ips, "Hide IPs of spoofed users" }, - { - "hub", - OUTPUT_BOOLEAN_YN, - &ServerInfo.hub, - "Server is a hub" - }, { "kline_delay", OUTPUT_DECIMAL, @@ -779,7 +772,7 @@ send_conf_options(struct Client *source_p) /* * Now send them a list of all our configuration options - * (mostly from config.h) + * (mostly from defaults.h) */ for (infoptr = MyInformation; infoptr->name; infoptr++) { diff --git a/modules/m_invite.c b/modules/m_invite.c index 3572c0e4..bd9aeefb 100644 --- a/modules/m_invite.c +++ b/modules/m_invite.c @@ -23,7 +23,6 @@ */ #include "stdinc.h" -#include "common.h" #include "channel.h" #include "client.h" #include "hash.h" diff --git a/modules/m_kline.c b/modules/m_kline.c index c1861ec3..7c55fc55 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -26,7 +26,6 @@ #include "channel.h" #include "class.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "hostmask.h" diff --git a/modules/m_list.c b/modules/m_list.c index 500d0f87..e8947cf8 100644 --- a/modules/m_list.c +++ b/modules/m_list.c @@ -471,7 +471,7 @@ static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, static void safelist_iterate_client(struct Client *source_p) { struct Channel *chptr; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; RB_RADIXTREE_FOREACH_FROM(chptr, &iter, channel_tree, source_p->localClient->safelist_data->chname) { diff --git a/modules/m_map.c b/modules/m_map.c index 8675fed8..6ba05e1f 100644 --- a/modules/m_map.c +++ b/modules/m_map.c @@ -157,7 +157,7 @@ flattened_map(struct Client *client_p) rb_dlink_node *ptr; struct Client *target_p; int i, len; - int cnt = 0; + unsigned long cnt = 0; /* First display me as the root */ rb_strlcpy(buf, me.name, BUFSIZE); diff --git a/modules/m_names.c b/modules/m_names.c index c7e142eb..026dfd2d 100644 --- a/modules/m_names.c +++ b/modules/m_names.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "channel.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/m_oper.c b/modules/m_oper.c index a6d5eca9..926af3fd 100644 --- a/modules/m_oper.c +++ b/modules/m_oper.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" diff --git a/modules/m_operspy.c b/modules/m_operspy.c index 9ad565fe..32a1a96d 100644 --- a/modules/m_operspy.c +++ b/modules/m_operspy.c @@ -31,8 +31,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "numeric.h" #include "s_serv.h" diff --git a/modules/m_privs.c b/modules/m_privs.c index 402a4e01..d8a32ebb 100644 --- a/modules/m_privs.c +++ b/modules/m_privs.c @@ -31,7 +31,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "numeric.h" #include "send.h" #include "msg.h" diff --git a/modules/m_rehash.c b/modules/m_rehash.c index f0380230..3151abfa 100644 --- a/modules/m_rehash.c +++ b/modules/m_rehash.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "client.h" #include "channel.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "s_serv.h" @@ -73,7 +72,7 @@ rehash_bans_loc(struct Client *source_p) if (!MyConnect(source_p)) remote_rehash_oper_p = source_p; - rehash_bans(0); + rehash_bans(); } static void @@ -118,7 +117,7 @@ rehash_omotd(struct Client *source_p) remote_rehash_oper_p = source_p; free_cachefile(oper_motd); - oper_motd = cache_file(OPATH, "opers.motd", 0); + oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0); } static void @@ -197,10 +196,9 @@ static void rehash_tresvs(struct Client *source_p) { struct ConfItem *aconf; - struct rb_radixtree_iteration_state iter; + rb_radixtree_iteration_state iter; rb_dlink_node *ptr; rb_dlink_node *next_ptr; - int i; sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s is clearing temp resvs", get_oper_name(source_p)); diff --git a/modules/m_restart.c b/modules/m_restart.c index 42041186..3910e299 100644 --- a/modules/m_restart.c +++ b/modules/m_restart.c @@ -24,7 +24,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" @@ -59,10 +58,6 @@ DECLARE_MODULE_AV2(restart, NULL, NULL, restart_clist, NULL, NULL, NULL, NULL, r static void mo_restart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { - char buf[BUFSIZE]; - rb_dlink_node *ptr; - struct Client *target_p; - if(!IsOperDie(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), diff --git a/modules/m_scan.c b/modules/m_scan.c index b144a06d..55071716 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.c @@ -34,7 +34,6 @@ #include "hook.h" #include "client.h" #include "hash.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/m_services.c b/modules/m_services.c index 558722f3..b8a1f363 100644 --- a/modules/m_services.c +++ b/modules/m_services.c @@ -32,8 +32,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "numeric.h" #include "s_conf.h" diff --git a/modules/m_set.c b/modules/m_set.c index 3ee08aec..e28b7002 100644 --- a/modules/m_set.c +++ b/modules/m_set.c @@ -31,7 +31,6 @@ #include "numeric.h" #include "s_serv.h" #include "send.h" -#include "common.h" #include "channel.h" #include "s_conf.h" #include "s_newconf.h" diff --git a/modules/m_signon.c b/modules/m_signon.c index 59f757cf..9175c357 100644 --- a/modules/m_signon.c +++ b/modules/m_signon.c @@ -32,8 +32,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "numeric.h" #include "s_conf.h" diff --git a/modules/m_snote.c b/modules/m_snote.c index af23287d..b79afbd9 100644 --- a/modules/m_snote.c +++ b/modules/m_snote.c @@ -34,7 +34,6 @@ #include "hook.h" #include "client.h" #include "hash.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/m_starttls.c b/modules/m_starttls.c index fba20e7d..62b7feb6 100644 --- a/modules/m_starttls.c +++ b/modules/m_starttls.c @@ -20,7 +20,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "hash.h" #include "ircd.h" @@ -75,7 +74,7 @@ mr_starttls(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou return; } - if (!ssl_ok || !get_ssld_count()) + if (!ircd_ssl_ok || !get_ssld_count()) { sendto_one_numeric(client_p, ERR_STARTTLS, form_str(ERR_STARTTLS), "TLS is not configured"); return; @@ -96,7 +95,7 @@ mr_starttls(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou sendto_one_numeric(client_p, RPL_STARTTLS, form_str(RPL_STARTTLS)); send_queued(client_p); - ctl = start_ssld_accept(client_p->localClient->F, F[1], rb_get_fd(F[0])); + ctl = start_ssld_accept(client_p->localClient->F, F[1], connid_get(client_p)); if (ctl != NULL) { client_p->localClient->F = F[0]; diff --git a/modules/m_stats.c b/modules/m_stats.c index 2c381223..40082039 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "class.h" /* report_classes */ #include "client.h" /* Client */ -#include "common.h" #include "match.h" #include "ircd.h" /* me */ #include "listener.h" /* show_ports */ @@ -142,53 +141,53 @@ static void stats_capability(struct Client *); */ static struct stats_cmd stats_cmd_table[256] = { /* letter handler/handler_parv parv oper admin */ - ['a'] = { stats_dns_servers, false, true, true, }, - ['A'] = { stats_dns_servers, false, true, true, }, - ['b'] = { stats_delay, false, true, true, }, - ['B'] = { stats_hash, false, true, true, }, - ['c'] = { stats_connect, false, false, false, }, - ['C'] = { stats_capability, false, true, false, }, - ['d'] = { stats_tdeny, false, true, false, }, - ['D'] = { stats_deny, false, true, false, }, - ['e'] = { stats_exempt, false, true, false, }, - ['E'] = { stats_events, false, true, true, }, - ['f'] = { stats_comm, false, true, true, }, - ['F'] = { stats_comm, false, true, true, }, - ['g'] = { stats_prop_klines, false, true, false, }, - ['h'] = { stats_hubleaf, false, false, false, }, - ['H'] = { stats_hubleaf, false, false, false, }, - ['i'] = { stats_auth, false, false, false, }, - ['I'] = { stats_auth, false, false, false, }, - ['k'] = { stats_tklines, false, false, false, }, - ['K'] = { stats_klines, false, false, false, }, - ['l'] = { .handler_parv = stats_ltrace, true, false, false, }, - ['L'] = { .handler_parv = stats_ltrace, true, false, false, }, - ['m'] = { stats_messages, false, false, false, }, - ['M'] = { stats_messages, false, false, false, }, - ['n'] = { stats_dnsbl, false, false, false, }, - ['o'] = { stats_oper, false, false, false, }, - ['O'] = { stats_privset, false, true, false, }, - ['p'] = { stats_operedup, false, false, false, }, - ['P'] = { stats_ports, false, false, false, }, - ['q'] = { stats_tresv, false, true, false, }, - ['Q'] = { stats_resv, false, true, false, }, - ['r'] = { stats_usage, false, true, false, }, - ['R'] = { stats_usage, false, true, false, }, - ['s'] = { stats_ssld, false, true, true, }, - ['S'] = { stats_ssld, false, true, true, }, - ['t'] = { stats_tstats, false, true, false, }, - ['T'] = { stats_tstats, false, true, false, }, - ['u'] = { stats_uptime, false, false, false, }, - ['U'] = { stats_shared, false, true, false, }, - ['v'] = { stats_servers, false, false, false, }, - ['V'] = { stats_servers, false, false, false, }, - ['x'] = { stats_tgecos, false, true, false, }, - ['X'] = { stats_gecos, false, true, false, }, - ['y'] = { stats_class, false, false, false, }, - ['Y'] = { stats_class, false, false, false, }, - ['z'] = { stats_memory, false, true, false, }, - ['Z'] = { stats_ziplinks, false, true, false, }, - ['?'] = { stats_servlinks, false, false, false, }, + ['a'] = { { stats_dns_servers }, false, true, true, }, + ['A'] = { { stats_dns_servers }, false, true, true, }, + ['b'] = { { stats_delay }, false, true, true, }, + ['B'] = { { stats_hash }, false, true, true, }, + ['c'] = { { stats_connect }, false, false, false, }, + ['C'] = { { stats_capability }, false, true, false, }, + ['d'] = { { stats_tdeny }, false, true, false, }, + ['D'] = { { stats_deny }, false, true, false, }, + ['e'] = { { stats_exempt }, false, true, false, }, + ['E'] = { { stats_events }, false, true, true, }, + ['f'] = { { stats_comm }, false, true, true, }, + ['F'] = { { stats_comm }, false, true, true, }, + ['g'] = { { stats_prop_klines }, false, true, false, }, + ['h'] = { { stats_hubleaf }, false, false, false, }, + ['H'] = { { stats_hubleaf }, false, false, false, }, + ['i'] = { { stats_auth }, false, false, false, }, + ['I'] = { { stats_auth }, false, false, false, }, + ['k'] = { { stats_tklines }, false, false, false, }, + ['K'] = { { stats_klines }, false, false, false, }, + ['l'] = { { .handler_parv = stats_ltrace }, true, false, false, }, + ['L'] = { { .handler_parv = stats_ltrace }, true, false, false, }, + ['m'] = { { stats_messages }, false, false, false, }, + ['M'] = { { stats_messages }, false, false, false, }, + ['n'] = { { stats_dnsbl }, false, false, false, }, + ['o'] = { { stats_oper }, false, false, false, }, + ['O'] = { { stats_privset }, false, true, false, }, + ['p'] = { { stats_operedup }, false, false, false, }, + ['P'] = { { stats_ports }, false, false, false, }, + ['q'] = { { stats_tresv }, false, true, false, }, + ['Q'] = { { stats_resv }, false, true, false, }, + ['r'] = { { stats_usage }, false, true, false, }, + ['R'] = { { stats_usage }, false, true, false, }, + ['s'] = { { stats_ssld }, false, true, true, }, + ['S'] = { { stats_ssld }, false, true, true, }, + ['t'] = { { stats_tstats }, false, true, false, }, + ['T'] = { { stats_tstats }, false, true, false, }, + ['u'] = { { stats_uptime }, false, false, false, }, + ['U'] = { { stats_shared }, false, true, false, }, + ['v'] = { { stats_servers }, false, false, false, }, + ['V'] = { { stats_servers }, false, false, false, }, + ['x'] = { { stats_tgecos }, false, true, false, }, + ['X'] = { { stats_gecos }, false, true, false, }, + ['y'] = { { stats_class }, false, false, false, }, + ['Y'] = { { stats_class }, false, false, false, }, + ['z'] = { { stats_memory }, false, true, false, }, + ['Z'] = { { stats_ziplinks }, false, true, false, }, + ['?'] = { { stats_servlinks }, false, false, false, }, }; /* @@ -204,9 +203,8 @@ static void m_stats(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { static time_t last_used = 0; - int i; struct stats_cmd *cmd; - char statchar; + unsigned char statchar; int did_stats = 0; statchar = parv[1][0]; @@ -286,9 +284,9 @@ static void stats_delay(struct Client *source_p) { struct nd_entry *nd; - struct DictionaryIter iter; + rb_dictionary_iter iter; - DICTIONARY_FOREACH(nd, &iter, nd_dict) + RB_DICTIONARY_FOREACH(nd, &iter, nd_dict) { sendto_one_notice(source_p, ":Delaying: %s for %ld", nd->name, (long) nd->expire); @@ -566,7 +564,7 @@ stats_auth (struct Client *source_p) aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, (struct sockaddr *)&source_p->localClient->ip, CONF_CLIENT, - source_p->localClient->ip.ss_family, + GET_SS_FAMILY(&source_p->localClient->ip), source_p->username, NULL); else aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_CLIENT, @@ -608,7 +606,7 @@ stats_tklines(struct Client *source_p) aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, (struct sockaddr *)&source_p->localClient->ip, CONF_KILL, - source_p->localClient->ip.ss_family, + GET_SS_FAMILY(&source_p->localClient->ip), source_p->username, NULL); else aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL, @@ -711,7 +709,7 @@ stats_klines(struct Client *source_p) aconf = find_conf_by_address (source_p->host, source_p->sockhost, NULL, (struct sockaddr *)&source_p->localClient->ip, CONF_KILL, - source_p->localClient->ip.ss_family, + GET_SS_FAMILY(&source_p->localClient->ip), source_p->username, NULL); else aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL, @@ -735,11 +733,11 @@ stats_klines(struct Client *source_p) static void stats_messages(struct Client *source_p) { - struct DictionaryIter iter; + rb_dictionary_iter iter; struct Message *msg; struct alias_entry *amsg; - DICTIONARY_FOREACH(msg, &iter, cmd_dict) + RB_DICTIONARY_FOREACH(msg, &iter, cmd_dict) { s_assert(msg->cmd != NULL); sendto_one_numeric(source_p, RPL_STATSCOMMANDS, @@ -748,7 +746,7 @@ stats_messages(struct Client *source_p) msg->bytes, msg->rcount); } - DICTIONARY_FOREACH(amsg, &iter, alias_dict) + RB_DICTIONARY_FOREACH(amsg, &iter, alias_dict) { s_assert(amsg->name != NULL); sendto_one_numeric(source_p, RPL_STATSCOMMANDS, @@ -871,9 +869,8 @@ static void stats_tresv(struct Client *source_p) { struct ConfItem *aconf; - struct rb_radixtree_iteration_state state; + rb_radixtree_iteration_state state; rb_dlink_node *ptr; - int i; RB_DLINK_FOREACH(ptr, resv_conf_list.head) { @@ -898,9 +895,8 @@ static void stats_resv(struct Client *source_p) { struct ConfItem *aconf; - struct rb_radixtree_iteration_state state; + rb_radixtree_iteration_state state; rb_dlink_node *ptr; - int i; RB_DLINK_FOREACH(ptr, resv_conf_list.head) { @@ -942,6 +938,7 @@ stats_ssld(struct Client *source_p) static void stats_usage (struct Client *source_p) { +#ifndef _WIN32 struct rusage rus; time_t secs; time_t rup; @@ -993,6 +990,7 @@ stats_usage (struct Client *source_p) "R :Signals %d Context Vol. %d Invol %d", (int) rus.ru_nsignals, (int) rus.ru_nvcsw, (int) rus.ru_nivcsw); +#endif } static void diff --git a/modules/m_svinfo.c b/modules/m_svinfo.c index 9faadc42..c6042fe1 100644 --- a/modules/m_svinfo.c +++ b/modules/m_svinfo.c @@ -23,7 +23,6 @@ */ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "ircd.h" #include "numeric.h" diff --git a/modules/m_tb.c b/modules/m_tb.c index 2b6e7098..4dce456c 100644 --- a/modules/m_tb.c +++ b/modules/m_tb.c @@ -32,8 +32,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "ircd.h" #include "match.h" #include "s_conf.h" diff --git a/modules/m_testmask.c b/modules/m_testmask.c index 4537d648..46b431f8 100644 --- a/modules/m_testmask.c +++ b/modules/m_testmask.c @@ -34,7 +34,6 @@ /* List of ircd includes from ../include/ */ #include "stdinc.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "match.h" #include "numeric.h" diff --git a/modules/m_tginfo.c b/modules/m_tginfo.c index dd9050a1..c30d6501 100644 --- a/modules/m_tginfo.c +++ b/modules/m_tginfo.c @@ -29,7 +29,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "match.h" #include "hash.h" #include "ircd.h" diff --git a/modules/m_trace.c b/modules/m_trace.c index fb0fdb92..38550667 100644 --- a/modules/m_trace.c +++ b/modules/m_trace.c @@ -27,7 +27,6 @@ #include "hook.h" #include "client.h" #include "hash.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/m_version.c b/modules/m_version.c index 597249a8..02cc6369 100644 --- a/modules/m_version.c +++ b/modules/m_version.c @@ -124,10 +124,6 @@ confopts(void) if(ConfigChannel.use_except) *p++ = 'e'; - /* might wanna hide this :P */ - if(ServerInfo.hub) - *p++ = 'H'; - if(ConfigChannel.use_invex) *p++ = 'I'; @@ -139,9 +135,6 @@ confopts(void) if(opers_see_all_users || ConfigFileEntry.operspy_dont_care_user_info) *p++ = 'S'; -#ifdef IGNORE_BOGUS_TS - *p++ = 'T'; -#endif #ifdef HAVE_LIBZ *p++ = 'Z'; diff --git a/modules/m_who.c b/modules/m_who.c index f0260830..aa674582 100644 --- a/modules/m_who.c +++ b/modules/m_who.c @@ -22,7 +22,6 @@ * USA */ #include "stdinc.h" -#include "common.h" #include "client.h" #include "channel.h" #include "hash.h" diff --git a/modules/m_whois.c b/modules/m_whois.c index 39b04814..5f7b42d1 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -23,7 +23,6 @@ */ #include "stdinc.h" -#include "common.h" #include "client.h" #include "hash.h" #include "channel.h" @@ -367,7 +366,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) target_p->name, target_p->sockhost); #ifdef RB_IPV6 - if (target_p->localClient->ip.ss_family == AF_INET6 && + if (GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET6 && (show_ip(source_p, target_p) || (source_p == target_p && !IsIPSpoof(target_p))) && ipv4_from_ipv6((struct sockaddr_in6 *)&target_p->localClient->ip, &ip4)) diff --git a/modules/m_whowas.c b/modules/m_whowas.c index 7f6e0926..a5038cce 100644 --- a/modules/m_whowas.c +++ b/modules/m_whowas.c @@ -25,7 +25,6 @@ #include "stdinc.h" #include "whowas.h" #include "client.h" -#include "common.h" #include "hash.h" #include "match.h" #include "ircd.h" diff --git a/modules/m_xline.c b/modules/m_xline.c index 02c162af..8f557b49 100644 --- a/modules/m_xline.c +++ b/modules/m_xline.c @@ -32,8 +32,7 @@ #include "send.h" #include "channel.h" #include "client.h" -#include "common.h" -#include "config.h" +#include "defaults.h" #include "class.h" #include "ircd.h" #include "numeric.h" diff --git a/scripts/application.sh b/scripts/application.sh index ff82db9e..a04ec371 100755 --- a/scripts/application.sh +++ b/scripts/application.sh @@ -24,10 +24,13 @@ if [ "x$TIP" = "x" ]; then exit fi -# Charybdis wants the hg tip to be in include/serno.h, in its own format. -MYTIP=`git log -1 --date=short --pretty=format:%cd_%h 2>/dev/null | sed -e s/-//g -e s/_/-/` +# Charybdis wants the git head to be in include/serno.h, in its own format. +SERNO=`git log -1 --date=format:%Y%m%d --pretty=format:%cd-%h` +DATECODE=`git log -1 --pretty=format:%ct` + echo "[charybdis] Generating include/serno.h for tip $MYTIP." cat << _EOF_ > include/serno.h /* Generated automatically by makepackage. Any changes made here will be lost. */ -#define SERNO "$MYTIP" +#define SERNO "$SERNO" +#define DATECODE "$DATECODE" _EOF_ diff --git a/scripts/makerelease.sh b/scripts/makerelease.sh index 106dd883..2a34e9ef 100755 --- a/scripts/makerelease.sh +++ b/scripts/makerelease.sh @@ -20,16 +20,12 @@ # if [ "x$1" = "x" ]; then - echo "usage: $0 releasename [--automatic]" + echo "usage: $0 releasename" exit else RELEASENAME="$1" fi -if [ "x$2" = "x--automatic" ]; then - AUTOMATIC="yes" -fi - TIP=`git log -1 --pretty=oneline | cut -d" " -f1` WRKDIR=`pwd` @@ -66,41 +62,6 @@ echo "Building $RELEASENAME.tbz2 from $RELEASENAME/" tar jcf $RELEASENAME.tar.bz2 $RELEASENAME/ rm $RELEASENAME-working.tar.gz +rm -rf $RELEASENAME -PUBLISH="yes" - -ok="0" -if [ "x$AUTOMATIC" != "xyes" ]; then - echo - echo "Would you like to publish these releases now?" - while [ $ok -eq 0 ]; do - echo -n "[$PUBLISH] " - - read INPUT - case $INPUT in - [Yy]*) - PUBLISH="yes" - ok=1 - ;; - [Nn]*) - PUBLISH="no" - ok=1 - ;; - esac - done -fi - -if [ "x$PUBLISH" = "xyes" ]; then - scp $RELEASENAME.tgz hg.atheme.org:/srv/distfiles - scp $RELEASENAME.tbz2 hg.atheme.org:/srv/distfiles - - echo - echo "The releases have been published, and will be available to the entire" - echo "distribution network within 15 minutes." -fi - -echo -echo "Done. If you have any bugs to report, report them against" -echo "the distfiles.atheme.org component at http://jira.atheme.org" -echo "Thanks!" -echo +echo "Done. $RELEASENAME.tar.gz and $RELEASENAME.tar.bz2 built." diff --git a/ssld/ssld.c b/ssld/ssld.c index 6446a656..6eb942c2 100644 --- a/ssld/ssld.c +++ b/ssld/ssld.c @@ -151,7 +151,7 @@ static void conn_plain_read_cb(rb_fde_t *fd, void *data); static void conn_plain_read_shutdown_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 bool ssl_ok; +static bool ssld_ssl_ok; static int certfp_method = RB_SSL_CERTFP_METH_SHA1; #ifdef HAVE_LIBZ static bool zlib_ok = true; @@ -459,7 +459,7 @@ common_zlib_inflate(conn_t * conn, void *buf, size_t len) } #endif -static int +static bool plain_check_cork(conn_t * conn) { if(rb_rawbuf_length(conn->modbuf_out) >= 4096) @@ -470,9 +470,9 @@ plain_check_cork(conn_t * conn) rb_setselect(conn->plain_fd, RB_SELECT_READ, NULL, NULL); /* try to write */ conn_mod_write_sendq(conn->mod_fd, conn); - return 1; + return true; } - return 0; + return false; } @@ -1015,7 +1015,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl) break; } - if(!ssl_ok) + if(!ssld_ssl_ok) { send_nossl_support(ctl, ctl_buf); break; @@ -1031,7 +1031,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl) break; } - if(!ssl_ok) + if(!ssld_ssl_ok) { send_nossl_support(ctl, ctl_buf); break; @@ -1051,7 +1051,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl) } case 'K': { - if(!ssl_ok) + if(!ssld_ssl_ok) { send_nossl_support(ctl, ctl_buf); break; @@ -1067,11 +1067,6 @@ mod_process_cmd_recv(mod_ctl_t * ctl) process_stats(ctl, ctl_buf); break; } - case 'Y': - { - change_connid(ctl, ctl_buf); - break; - } #ifdef HAVE_LIBZ case 'Z': @@ -1237,7 +1232,7 @@ main(int argc, char **argv) setup_signals(); rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096); rb_init_rawbuffers(1024); - ssl_ok = rb_supports_ssl(); + ssld_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"); @@ -1248,7 +1243,7 @@ main(int argc, char **argv) read_pipe_ctl(mod_ctl->F_pipe, NULL); mod_read_ctl(mod_ctl->F, mod_ctl); send_version(mod_ctl); - if(!zlib_ok && !ssl_ok) + if(!zlib_ok && !ssld_ssl_ok) { /* this is really useless... */ send_i_am_useless(mod_ctl); @@ -1259,7 +1254,7 @@ main(int argc, char **argv) if(!zlib_ok) send_nozlib_support(mod_ctl, NULL); - if(!ssl_ok) + if(!ssld_ssl_ok) send_nossl_support(mod_ctl, NULL); rb_lib_loop(0); return 0; diff --git a/tools/README.mkpasswd b/tools/README.mkpasswd index a07ae54d..2bae860c 100644 --- a/tools/README.mkpasswd +++ b/tools/README.mkpasswd @@ -3,56 +3,36 @@ mkpasswd.c documentation This is documentation for the updated mkpasswd.c included with a number of ircd, irc services, and non-IRC related programs -This version of mkpasswd can create DES, Extended DES, Blowfish, and MD5 +This version of mkpasswd can create Blowfish, MD5, SHA256, and SHA512 crypted passwords, with either randomly generated or user provided salts. Options: +-x Generate a SHA256 password +-y Generate a SHA512 password -m Generate an MD5 password --d Generate a DES password -b Generate a Blowfish password --e Generate an Extended (BSDi) DES password -l Specify a length for a random MD5 or Blowfish salt --r Specify a number of rounds for a Blowfish or Extended DES password - Blowfish: no more than 6 recommended, no less than 4 accepted - Extended DES: default of 25 --s Specify a salt, 2 alphanumeric characters for DES, up to 16 for MD5, - up to 22 for Blowfish, 2 for Extended DES +-r Specify a number of rounds for a Blowfish password + Default 4, no more than 6 recommended +-s Specify a salt, up to 16 for MD5, SHA256, and SHA512 + up to 22 for Blowfish -p Specify a plaintext password to use -? Get brief help -h Get extended help -Without the presence of any parameters, it'll behave like the old mkpasswd, -creating a DES password with a randomly generated salt and prompting for -the password (without echo). +Without the presence of any parameters, it'll generate a SHA512 hash with a +randomly generated salt and prompting for the password (without echo). -A DES salt is a pair of alphanumeric characters ('.' and '/' are permitted -as well), such as 'a4' or 'Td'. - -An MD5 salt consists of up to 16 (though most implementations limit you to -8) alphanumeric characters (plus '.' and '/'), -such as 'tGd' or 'J6d4dfG'. +An MD5, SHA256, and SHA512 salt consists of up to 16 alphanumeric characters +(plus '.' and '/'), such as 'tGd' or 'J6d4dfG'. A Blowfish salt consists of up to 22 alphanumeric characters (plus '.' and '/'). Blowfish also specifies a number of rounds*, by default 4. -Known bugs: -The encryption algorithms supported depend on your system's crypt() - implementation. -The maximum length of an MD5 salt is limited to your systems crypt() - implementation, typically 8. +Blowfish may not always be available, but MD5, SHA256, and SHA512 are +guaranteed to be. -Supported Platforms (Known and tested): -Linux glibc (DES and MD5) -FreeBSD 3.x (DES (MD5 maybe)) -FreeBSD 4.x (DES, MD5, Blowfish, Extended DES) -Solaris 2.5-2.6 (DES only) -Cygwin 1.1.4 (DES only) -Prior Cygwin with the MD5 libcrypt (MD5 only) -OpenBSD 2.7 (don't link with -lcrypt) (DES, MD5, Blowfish) -Mac OS-X (Darwin) (don't link with -lcrypt) (DES only) +This program should work anywhere Charybdis does; if you find otherwise, file +a bug. -An MMK build script is included, as well as an MD5 crypt() implementation - -Other systems probably work, but they haven't been amply tested. - -* Blowfish's rounds parameter is a logarithm, not an integer value + * Blowfish's rounds parameter is a logarithm, not an integer value diff --git a/tools/mkpasswd.c b/tools/mkpasswd.c index de1ccc1b..689f912e 100644 --- a/tools/mkpasswd.c +++ b/tools/mkpasswd.c @@ -1,15 +1,14 @@ /* simple password generator by Nelson Minar (minar@reed.edu) -** copyright 1991, all rights reserved. -** You can use this code as long as my name stays with it. -** -** md5 patch by W. Campbell -** Modernization, getopt, etc for the Hybrid IRCD team -** by W. Campbell -** -** /dev/random for salt generation added by -** Aaron Sethman -** -*/ + * copyright 1991, all rights reserved. + * You can use this code as long as my name stays with it. + * + * md5 patch by W. Campbell + * Modernization, getopt, etc for the Hybrid IRCD team + * by W. Campbell + * + * /dev/random for salt generation added by + * Aaron Sethman + */ #include #include #include @@ -22,20 +21,15 @@ #endif #define FLAG_MD5 0x00000001 -#define FLAG_DES 0x00000002 -#define FLAG_SALT 0x00000004 -#define FLAG_PASS 0x00000008 -#define FLAG_LENGTH 0x00000010 -#define FLAG_BLOWFISH 0x00000020 -#define FLAG_ROUNDS 0x00000040 -#define FLAG_EXT 0x00000080 -#define FLAG_SHA256 0x00000100 -#define FLAG_SHA512 0x00000200 +#define FLAG_SALT 0x00000002 +#define FLAG_PASS 0x00000004 +#define FLAG_LENGTH 0x00000008 +#define FLAG_BLOWFISH 0x00000010 +#define FLAG_ROUNDS 0x00000020 +#define FLAG_SHA256 0x00000040 +#define FLAG_SHA512 0x00000080 -static char *make_des_salt(void); -static char *make_ext_salt(int); -static char *make_ext_salt_para(int, char *); static char *make_md5_salt(int); static char *make_md5_salt_para(char *); static char *make_sha256_salt(int); @@ -44,7 +38,6 @@ static char *make_sha512_salt(int); static char *make_sha512_salt_para(char *); static char *make_bf_salt(int, int); static char *make_bf_salt_para(int, char *); -static char *int_to_base64(int); static char *generate_random_salt(char *, int); static char *generate_poor_salt(char *, int); @@ -100,30 +93,22 @@ main(int argc, char *argv[]) char *hashed; int flag = 0; int length = 0; /* Not Set */ - int rounds = 0; /* Not set, since extended DES needs 25 and blowfish needs - ** 4 by default, a side effect of this being the encryption - ** type parameter must be specified before the rounds - ** parameter. + int rounds = 0; /* Not set, since blowfish needs 4 by default, a side effect + * of this being the encryption type parameter must be + * specified before the rounds parameter. */ - while((c = getopt(argc, argv, "xymdber:h?l:s:p:")) != -1) + while((c = getopt(argc, argv, "xymbr:h?l:s:p:")) != -1) { switch (c) { case 'm': flag |= FLAG_MD5; break; - case 'd': - flag |= FLAG_DES; - break; case 'b': flag |= FLAG_BLOWFISH; rounds = 4; break; - case 'e': - flag |= FLAG_EXT; - rounds = 25; - break; case 'l': flag |= FLAG_LENGTH; length = atoi(optarg); @@ -187,45 +172,6 @@ main(int argc, char *argv[]) else salt = make_sha256_salt(length); } - else if(flag & FLAG_EXT) - { - /* XXX - rounds needs to be done */ - if(flag & FLAG_SALT) - { - if((strlen(saltpara) == 4)) - { - salt = make_ext_salt_para(rounds, saltpara); - } - else - { - printf("Invalid salt, please enter 4 alphanumeric characters\n"); - exit(1); - } - } - else - { - salt = make_ext_salt(rounds); - } - } - else if (flag & FLAG_DES) - { - if(flag & FLAG_SALT) - { - if((strlen(saltpara) == 2)) - { - salt = saltpara; - } - else - { - printf("Invalid salt, please enter 2 alphanumeric characters\n"); - exit(1); - } - } - else - { - salt = make_des_salt(); - } - } else { if(length == 0) @@ -262,53 +208,6 @@ main(int argc, char *argv[]) return 0; } -static char * -make_des_salt() -{ - static char salt[3]; - generate_random_salt(salt, 2); - salt[2] = '\0'; - return salt; -} - -char * -int_to_base64(int value) -{ - static char buf[5]; - int i; - - for(i = 0; i < 4; i++) - { - buf[i] = saltChars[value & 63]; - value >>= 6; /* Right shifting 6 places is the same as dividing by 64 */ - } - - buf[i] = '\0'; /* not REALLY needed as it's static, and thus initialized - ** to \0. - */ - return buf; -} - -char * -make_ext_salt(int rounds) -{ - static char salt[10]; - - sprintf(salt, "_%s", int_to_base64(rounds)); - generate_random_salt(&salt[5], 4); - salt[9] = '\0'; - return salt; -} - -char * -make_ext_salt_para(int rounds, char *saltpara) -{ - static char salt[10]; - - sprintf(salt, "_%s%s", int_to_base64(rounds), saltpara); - return salt; -} - char * make_md5_salt_para(char *saltpara) { @@ -499,19 +398,16 @@ generate_random_salt(char *salt, int length) void full_usage() { - printf("mkpasswd [-m|-d|-b|-e] [-l saltlength] [-r rounds] [-s salt] [-p plaintext]\n"); + printf("mkpasswd [-m|-b|-x|-y] [-l saltlength] [-r rounds] [-s salt] [-p plaintext]\n"); printf("-x Generate a SHA256 password\n"); printf("-y Generate a SHA512 password\n"); printf("-m Generate an MD5 password\n"); - printf("-d Generate a DES password\n"); printf("-b Generate a Blowfish password\n"); - printf("-e Generate an Extended DES password\n"); printf("-l Specify a length for a random MD5 or Blowfish salt\n"); - printf("-r Specify a number of rounds for a Blowfish or Extended DES password\n"); - printf(" Blowfish: default 4, no more than 6 recommended\n"); - printf(" Extended DES: default 25\n"); - printf("-s Specify a salt, 2 alphanumeric characters for DES, up to 16 for MD5,\n"); - printf(" up to 22 for Blowfish, and 4 for Extended DES\n"); + printf("-r Specify a number of rounds for a Blowfish password\n"); + printf(" Default 4, no more than 6 recommended\n"); + printf("-s Specify a salt, up to 16 for MD5, SHA256, and SHA512\n"); + printf(" up to 22 for Blowfish\n"); printf("-p Specify a plaintext password to use\n"); printf("Example: mkpasswd -m -s 3dr -p test\n"); exit(0); @@ -521,11 +417,11 @@ void brief_usage() { printf("mkpasswd - password hash generator\n"); - printf("Standard DES: mkpasswd [-d] [-s salt] [-p plaintext]\n"); - printf("Extended DES: mkpasswd -e [-r rounds] [-s salt] [-p plaintext]\n"); - printf(" MD5: mkpasswd -m [-l saltlength] [-s salt] [-p plaintext]\n"); - printf(" Blowfish: mkpasswd -b [-r rounds] [-l saltlength] [-s salt]\n"); - printf(" [-p plaintext]\n"); + printf(" SHA512: mkpasswd [-y] [-l saltlength] [-s salt] [-p plaintext]\n"); + printf(" SHA256: mkpasswd -x [-l saltlength] [-s salt] [-p plaintext]\n"); + printf(" MD5: mkpasswd -m [-l saltlength] [-s salt] [-p plaintext]\n"); + printf("Blowfish: mkpasswd -b [-r rounds] [-l saltlength] [-s salt]\n"); + printf(" [-p plaintext]\n"); printf("Use -h for full usage\n"); exit(0); } diff --git a/wsockd/Makefile.am b/wsockd/Makefile.am new file mode 100644 index 00000000..d4524698 --- /dev/null +++ b/wsockd/Makefile.am @@ -0,0 +1,7 @@ +pkglibexec_PROGRAMS = wsockd +AM_CFLAGS=$(WARNFLAGS) +AM_CPPFLAGS = -I../include -I../librb/include + + +wsockd_SOURCES = wsockd.c +wsockd_LDADD = ../librb/src/librb.la diff --git a/wsockd/wsockd.c b/wsockd/wsockd.c new file mode 100644 index 00000000..7c6bbab2 --- /dev/null +++ b/wsockd/wsockd.c @@ -0,0 +1,548 @@ +/* + * wsockd.c: charybdis websockets helper + * Copyright (C) 2007 Aaron Sethman + * Copyright (C) 2007 ircd-ratbox development team + * Copyright (C) 2016 William Pitcock + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#include "stdinc.h" + +#define MAXPASSFD 4 +#ifndef READBUF_SIZE +#define READBUF_SIZE 16384 +#endif + +static void setup_signals(void); +static pid_t ppid; + +static inline uint32_t +buf_to_uint32(uint8_t *buf) +{ + uint32_t x; + memcpy(&x, buf, sizeof(x)); + return x; +} + +static inline void +uint32_to_buf(uint8_t *buf, uint32_t x) +{ + memcpy(buf, &x, sizeof(x)); + return; +} + +typedef struct _mod_ctl_buf +{ + rb_dlink_node node; + uint8_t *buf; + size_t buflen; + rb_fde_t *F[MAXPASSFD]; + int nfds; +} mod_ctl_buf_t; + +typedef struct _mod_ctl +{ + rb_dlink_node node; + int cli_count; + rb_fde_t *F; + rb_fde_t *F_pipe; + rb_dlink_list readq; + rb_dlink_list writeq; +} mod_ctl_t; + +static mod_ctl_t *mod_ctl; + +typedef struct _conn +{ + rb_dlink_node node; + mod_ctl_t *ctl; + rawbuf_head_t *modbuf_out; + rawbuf_head_t *plainbuf_out; + + uint32_t id; + + rb_fde_t *mod_fd; + rb_fde_t *plain_fd; + uint64_t mod_out; + uint64_t mod_in; + uint64_t plain_in; + uint64_t plain_out; + uint8_t flags; +} conn_t; + +#define FLAG_CORK 0x01 +#define FLAG_DEAD 0x02 +#define FLAG_WSOCK 0x04 + +#define IsCork(x) ((x)->flags & FLAG_CORK) +#define IsDead(x) ((x)->flags & FLAG_DEAD) +#define IsWS(x) ((x)->flags & FLAG_WSOCK) + +#define SetCork(x) ((x)->flags |= FLAG_CORK) +#define SetDead(x) ((x)->flags |= FLAG_DEAD) +#define SetWS(x) ((x)->flags |= FLAG_WSOCK) + +#define ClearCork(x) ((x)->flags &= ~FLAG_CORK) +#define ClearDead(x) ((x)->flags &= ~FLAG_DEAD) +#define ClearWS(x) ((x)->flags &= ~FLAG_WSOCK) + +#define NO_WAIT 0x0 +#define WAIT_PLAIN 0x1 + +#define HASH_WALK_SAFE(i, max, ptr, next, table) for(i = 0; i < max; i++) { RB_DLINK_FOREACH_SAFE(ptr, next, table[i].head) +#define HASH_WALK_END } +#define CONN_HASH_SIZE 2000 +#define connid_hash(x) (&connid_hash_table[(x % CONN_HASH_SIZE)]) + +static rb_dlink_list connid_hash_table[CONN_HASH_SIZE]; +static rb_dlink_list dead_list; + +static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data); + +#ifndef _WIN32 +static void +dummy_handler(int sig) +{ + return; +} +#endif + +static void +setup_signals() +{ +#ifndef _WIN32 + struct sigaction act; + + act.sa_flags = 0; + act.sa_handler = SIG_IGN; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, SIGPIPE); + sigaddset(&act.sa_mask, SIGALRM); +#ifdef SIGTRAP + sigaddset(&act.sa_mask, SIGTRAP); +#endif + +#ifdef SIGWINCH + sigaddset(&act.sa_mask, SIGWINCH); + sigaction(SIGWINCH, &act, 0); +#endif + sigaction(SIGPIPE, &act, 0); +#ifdef SIGTRAP + sigaction(SIGTRAP, &act, 0); +#endif + + act.sa_handler = dummy_handler; + sigaction(SIGALRM, &act, 0); +#endif +} + +static int +maxconn(void) +{ +#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H) + struct rlimit limit; + + if(!getrlimit(RLIMIT_NOFILE, &limit)) + { + return limit.rlim_cur; + } +#endif /* RLIMIT_FD_MAX */ + return MAXCONNECTIONS; +} + +static conn_t * +conn_find_by_id(uint32_t id) +{ + rb_dlink_node *ptr; + conn_t *conn; + + RB_DLINK_FOREACH(ptr, (connid_hash(id))->head) + { + conn = ptr->data; + if(conn->id == id && !IsDead(conn)) + return conn; + } + return NULL; +} + +static void +conn_add_id_hash(conn_t * conn, uint32_t id) +{ + conn->id = id; + rb_dlinkAdd(conn, &conn->node, connid_hash(id)); +} + +static void +free_conn(conn_t * conn) +{ + rb_free_rawbuffer(conn->modbuf_out); + rb_free_rawbuffer(conn->plainbuf_out); + rb_free(conn); +} + +static void +clean_dead_conns(void *unused) +{ + conn_t *conn; + rb_dlink_node *ptr, *next; + + RB_DLINK_FOREACH_SAFE(ptr, next, dead_list.head) + { + conn = ptr->data; + free_conn(conn); + } + + dead_list.tail = dead_list.head = NULL; +} + +static void +mod_write_ctl(rb_fde_t *F, void *data) +{ + mod_ctl_t *ctl = data; + mod_ctl_buf_t *ctl_buf; + rb_dlink_node *ptr, *next; + int retlen, x; + + RB_DLINK_FOREACH_SAFE(ptr, next, ctl->writeq.head) + { + ctl_buf = ptr->data; + retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, + ctl_buf->buflen, ppid); + if(retlen > 0) + { + rb_dlinkDelete(ptr, &ctl->writeq); + for(x = 0; x < ctl_buf->nfds; x++) + rb_close(ctl_buf->F[x]); + rb_free(ctl_buf->buf); + rb_free(ctl_buf); + + } + if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) + exit(0); + + } + if(rb_dlink_list_length(&ctl->writeq) > 0) + rb_setselect(ctl->F, RB_SELECT_WRITE, mod_write_ctl, ctl); +} + +static void +mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len) +{ + mod_ctl_buf_t *ctl_buf; + ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = rb_malloc(len); + ctl_buf->buflen = len; + memcpy(ctl_buf->buf, data, len); + ctl_buf->nfds = 0; + rb_dlinkAddTail(ctl_buf, &ctl_buf->node, &ctl->writeq); + mod_write_ctl(ctl->F, ctl); +} + +static void +close_conn(conn_t * conn, int wait_plain, const char *fmt, ...) +{ + va_list ap; + char reason[128]; /* must always be under 250 bytes */ + uint8_t buf[256]; + int len; + if(IsDead(conn)) + return; + + rb_rawbuf_flush(conn->modbuf_out, conn->mod_fd); + rb_rawbuf_flush(conn->plainbuf_out, conn->plain_fd); + rb_close(conn->mod_fd); + SetDead(conn); + + rb_dlinkDelete(&conn->node, connid_hash(conn->id)); + + if(!wait_plain || fmt == NULL) + { + rb_close(conn->plain_fd); + rb_dlinkAdd(conn, &conn->node, &dead_list); + return; + } + + rb_setselect(conn->plain_fd, RB_SELECT_READ, conn_plain_read_shutdown_cb, conn); + rb_setselect(conn->plain_fd, RB_SELECT_WRITE, NULL, NULL); + + va_start(ap, fmt); + vsnprintf(reason, sizeof(reason), fmt, ap); + va_end(ap); + + buf[0] = 'D'; + uint32_to_buf(&buf[1], conn->id); + rb_strlcpy((char *) &buf[5], reason, sizeof(buf) - 5); + len = (strlen(reason) + 1) + 5; + mod_cmd_write_queue(conn->ctl, buf, len); +} + +static conn_t * +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; + conn->modbuf_out = rb_new_rawbuffer(); + conn->plainbuf_out = rb_new_rawbuffer(); + conn->mod_fd = mod_fd; + conn->plain_fd = plain_fd; + conn->id = -1; + rb_set_nb(mod_fd); + rb_set_nb(plain_fd); + return conn; +} + +static void +cleanup_bad_message(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb) +{ + int i; + + /* XXX should log this somehow */ + for (i = 0; i < ctlb->nfds; i++) + rb_close(ctlb->F[i]); +} + +static void +conn_mod_handshake_cb(rb_fde_t *fd, void *data) +{ + char inbuf[READBUF_SIZE]; + conn_t *conn = data; + int length = 0; + if (conn == NULL) + return; + + if (IsDead(conn)) + return; + + while (1) + { + if (IsDead(conn)) + return; + + length = rb_read(conn->plain_fd, inbuf, sizeof(inbuf)); + if (length == 0 || (length < 0 && !rb_ignore_errno(errno))) + { + close_conn(conn, NO_WAIT, "Connection closed"); + return; + } + } +} + +static void +conn_mod_read_cb(rb_fde_t *fd, void *data) +{ +} + +static void +conn_plain_read_cb(rb_fde_t *fd, void *data) +{ +} + +static void +conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data) +{ + char inbuf[READBUF_SIZE]; + conn_t *conn = data; + int length = 0; + + if(conn == NULL) + return; + + while(1) + { + length = rb_read(conn->plain_fd, inbuf, sizeof(inbuf)); + + if(length == 0 || (length < 0 && !rb_ignore_errno(errno))) + { + rb_close(conn->plain_fd); + rb_dlinkAdd(conn, &conn->node, &dead_list); + return; + } + + if(length < 0) + { + rb_setselect(conn->plain_fd, RB_SELECT_READ, conn_plain_read_shutdown_cb, conn); + return; + } + } +} + +static void +wsock_process(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb) +{ + conn_t *conn; + uint32_t id; + + conn = make_conn(ctl, ctlb->F[0], ctlb->F[1]); + + id = buf_to_uint32(&ctlb->buf[1]); + conn_add_id_hash(conn, id); + SetWS(conn); + + if(rb_get_type(conn->mod_fd) & RB_FD_UNKNOWN) + rb_set_type(conn->mod_fd, RB_FD_SOCKET); + + if(rb_get_type(conn->plain_fd) == RB_FD_UNKNOWN) + rb_set_type(conn->plain_fd, RB_FD_SOCKET); + + conn_mod_handshake_cb(conn->mod_fd, conn); +} + +static void +mod_process_cmd_recv(mod_ctl_t * ctl) +{ + rb_dlink_node *ptr, *next; + mod_ctl_buf_t *ctl_buf; + + RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head) + { + ctl_buf = ptr->data; + + switch (*ctl_buf->buf) + { + case 'A': + { + if (ctl_buf->nfds != 2 || ctl_buf->buflen != 5) + { + cleanup_bad_message(ctl, ctl_buf); + break; + } + wsock_process(ctl, ctl_buf); + break; + } + default: + break; + /* Log unknown commands */ + } + rb_dlinkDelete(ptr, &ctl->readq); + rb_free(ctl_buf->buf); + rb_free(ctl_buf); + } + +} + +static void +mod_read_ctl(rb_fde_t *F, void *data) +{ + mod_ctl_buf_t *ctl_buf; + mod_ctl_t *ctl = data; + int retlen; + int i; + + do + { + ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = rb_malloc(READBUF_SIZE); + ctl_buf->buflen = READBUF_SIZE; + retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, ctl_buf->buflen, ctl_buf->F, + MAXPASSFD); + if(retlen <= 0) + { + rb_free(ctl_buf->buf); + rb_free(ctl_buf); + } + else + { + ctl_buf->buflen = retlen; + rb_dlinkAddTail(ctl_buf, &ctl_buf->node, &ctl->readq); + for (i = 0; i < MAXPASSFD && ctl_buf->F[i] != NULL; i++) + ; + ctl_buf->nfds = i; + } + } + while(retlen > 0); + + if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) + exit(0); + + mod_process_cmd_recv(ctl); + rb_setselect(ctl->F, RB_SELECT_READ, mod_read_ctl, ctl); +} + +static void +read_pipe_ctl(rb_fde_t *F, void *data) +{ + char inbuf[READBUF_SIZE]; + int retlen; + 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.. */ + } + if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) + exit(0); + rb_setselect(F, RB_SELECT_READ, read_pipe_ctl, NULL); +} + +int +main(int argc, char **argv) +{ + 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 || s_pid == NULL) + { + fprintf(stderr, + "This is the charybdis wsockd for internal ircd use.\n"); + fprintf(stderr, + "You aren't supposed to run me directly. Exiting.\n"); + exit(1); + } + + ctlfd = atoi(s_ctlfd); + pipefd = atoi(s_pipe); + 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) + { + if(ctlfd != 0 && pipefd != 0) + dup2(x, 0); + if(ctlfd != 1 && pipefd != 1) + dup2(x, 1); + if(ctlfd != 2 && pipefd != 2) + dup2(x, 2); + if(x > 2) + close(x); + } +#endif + setup_signals(); + rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096); + rb_init_rawbuffers(1024); + + 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"); + rb_set_nb(mod_ctl->F); + rb_set_nb(mod_ctl->F_pipe); + rb_event_addish("clean_dead_conns", clean_dead_conns, NULL, 10); + read_pipe_ctl(mod_ctl->F_pipe, NULL); + mod_read_ctl(mod_ctl->F, mod_ctl); + + rb_lib_loop(0); + return 0; +}