Initial import

This commit is contained in:
nohar 2005-04-28 08:26:44 +00:00
commit 665d2ec5af
70 changed files with 26772 additions and 0 deletions

6
AUTHORS Normal file
View File

@ -0,0 +1,6 @@
Arnaud 'nohar' Cornet
Loïc 'Kyoshiro' Gomez
Thanks to jj, YS and lafounie, for hanging around while we were coding.
Crypto shamelessly taken from Christophe 'sexy' Devine.

340
COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

4
ChangeLog Normal file
View File

@ -0,0 +1,4 @@
2005-04-21 Arnaud Cornet <nohar@t1r.net>
* src: Now use autoconf/automake
bip is now public :)

14
IDEAS Normal file
View File

@ -0,0 +1,14 @@
- parser limité aux join part mode kick kill privmsg notices quit nick names
- parser client : join, part, quit, nick, privmsg/notice
- gestion des chans avec liste des nicks et statut
- backlog avec timestamp à la reconnexion
- logs au format irssi + timestamp complet
- parser de conf (lex) du style var = value
- backlog dans un dir, plusieurs fichiers (un par chan + le reste dans un autre)
- [secondaire] rotate logs
- connection.c: conn, read/write polls, waitevent, ssl transparent et anti flood
- irc.c: gestion des chans, des spécificités d'un client IRC (ping)
- log.c: log et backlog
- client.c: gestion des clients (auth, etc...)
- config.c: lecture et enregistrement de la conf

182
INSTALL Normal file
View File

@ -0,0 +1,182 @@
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.

1
Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = src samples

357
Makefile.in Normal file
View File

@ -0,0 +1,357 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in 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.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
CC = @CC@
HAVE_LIB = @HAVE_LIB@
LEX = @LEX@
LIB = @LIB@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
YACC = @YACC@
SUBDIRS = src samples
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ./src/config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS TODO aclocal.m4 config.guess config.sub configure \
configure.in install-sh missing mkinstalldirs src/config.h.in \
src/stamp-h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
src/config.h: src/stamp-h
@if test ! -f $@; then \
rm -f src/stamp-h; \
$(MAKE) src/stamp-h; \
else :; fi
src/stamp-h: $(srcdir)/src/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=src/config.h \
$(SHELL) ./config.status
@echo timestamp > src/stamp-h 2> /dev/null
$(srcdir)/src/config.h.in: $(srcdir)/src/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/src/stamp-h.in; \
$(MAKE) $(srcdir)/src/stamp-h.in; \
else :; fi
$(srcdir)/src/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/src/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f src/config.h
maintainer-clean-hdr:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
@SET_MAKE@
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am:
uninstall: uninstall-recursive
all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-recursive
-rm -f config.status
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
install-data-recursive uninstall-data-recursive install-exec-recursive \
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
all-recursive check-recursive installcheck-recursive info-recursive \
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

0
NEWS Normal file
View File

2
README Normal file
View File

@ -0,0 +1,2 @@
log encryption support
salt this md5

9
TODO Normal file
View File

@ -0,0 +1,9 @@
- SSL certificate verification
- allowed IP filtering
- multi user (user/pass to identify user + realname to id. network)
- keep invites when detached
- DCC proxying ?
- /bip command, for admin (rehash, jump, ...)
- crypt logs
tidy up irc_server/server structures

987
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,987 @@
dnl aclocal.m4 generated automatically by aclocal 1.4-p6
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# lib-prefix.m4 serial 3 (gettext-0.13)
dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
dnl require excessive bracketing.
ifdef([AC_HELP_STRING],
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])
# lib-link.m4 serial 4 (gettext-0.12)
dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible.
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
undefine([Name])
undefine([NAME])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. If found, it
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
define([Name],[translit([$1],[./-], [___])])
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LIB[]NAME"
AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
undefine([Name])
undefine([NAME])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
dnl hardcode_direct, hardcode_minus_L.
AC_DEFUN([AC_LIB_RPATH],
[
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
libext="$acl_cv_libext"
shlibext="$acl_cv_shlibext"
hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
hardcode_direct="$acl_cv_hardcode_direct"
hardcode_minus_L="$acl_cv_hardcode_minus_L"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE(rpath,
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib$1-prefix],
[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
--without-lib$1-prefix don't search for lib$1 in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/lib"
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
if test $use_additional = yes; then
if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
else
if test -f "$additional_libdir/lib$name.$libext"; then
found_dir="$additional_libdir"
found_a="$additional_libdir/lib$name.$libext"
if test -f "$additional_libdir/lib$name.la"; then
found_la="$additional_libdir/lib$name.la"
fi
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
else
if test -f "$dir/lib$name.$libext"; then
found_dir="$dir"
found_a="$dir/lib$name.$libext"
if test -f "$dir/lib$name.la"; then
found_la="$dir/lib$name.la"
fi
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/lib | */lib/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/lib"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/lib"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
done
dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])
# lib-ld.m4 serial 3 (gettext-0.13)
dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl Subroutines of libtool.m4,
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
dnl with libtool.m4.
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
case `$LD -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
acl_cv_prog_gnu_ld=yes ;;
*)
acl_cv_prog_gnu_ld=no ;;
esac])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-1.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
# Prepare PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]* | [A-Za-z]:[\\/]*)]
[re_direlt='/[^/][^/]*/\.\./']
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(acl_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
*GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break ;;
*)
test "$with_gnu_ld" != yes && break ;;
esac
fi
done
IFS="$ac_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN([AM_CONFIG_HEADER],
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# Do all the work for Automake. 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.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
# Copyright 2002 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 2, 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
# 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.
AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.4-p6])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# 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 (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $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
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN([AM_MISSING_PROG],
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
dnl AM_PROG_LEX
dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT
AC_DEFUN([AM_PROG_LEX],
[missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1)
AC_CHECK_PROGS(LEX, flex lex, $missing_dir/missing flex)
AC_PROG_LEX
AC_DECL_YYTEXT])

4256
autom4te.cache/output.0 Normal file

File diff suppressed because it is too large Load Diff

116
autom4te.cache/requests Normal file
View File

@ -0,0 +1,116 @@
# This file was generated by Autom4te Thu Apr 14 05:08:07 UTC 2005.
# It contains the lists of macros which have been traced.
# It can be safely removed.
@request = (
bless( [
'0',
1,
[
'/usr/share/autoconf'
],
[
'/usr/share/autoconf/autoconf/autoconf.m4f',
'aclocal.m4',
'configure.in'
],
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_STRUCT_TM' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRNLEN' => 1,
'm4_sinclude' => 1,
'AC_PROG_CXX' => 1,
'AC_PATH_X' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_PROG_AWK' => 1,
'_m4_warn' => 1,
'AC_HEADER_STDC' => 1,
'AC_HEADER_MAJOR' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_LIBSOURCE' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_YACC' => 1,
'AC_INIT' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_SUBST' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_PROG_RANLIB' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AC_FUNC_MMAP' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_CHECK_TYPES' => 1,
'AC_CHECK_MEMBERS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_PROG_CPP' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_LEX' => 1,
'AC_C_CONST' => 1,
'AC_TYPE_PID_T' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_MEMCMP' => 1,
'm4_include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
}
], 'Autom4te::Request' )
);

135
autom4te.cache/traces.0 Normal file
View File

@ -0,0 +1,135 @@
m4trace:configure.in:1: -1- AC_INIT([src/bip.c])
m4trace:configure.in:1: -1- m4_pattern_forbid([^_?A[CHUM]_])
m4trace:configure.in:1: -1- m4_pattern_forbid([_AC_])
m4trace:configure.in:1: -1- m4_pattern_forbid([^LIBOBJS$], [do not use LIBOBJS directly, use AC_LIBOBJ (see section `AC_LIBOBJ vs LIBOBJS'])
m4trace:configure.in:1: -1- m4_pattern_allow([^AS_FLAGS$])
m4trace:configure.in:1: -1- m4_pattern_forbid([^_?m4_])
m4trace:configure.in:1: -1- m4_pattern_forbid([^dnl$])
m4trace:configure.in:1: -1- m4_pattern_forbid([^_?AS_])
m4trace:configure.in:1: -1- AC_SUBST([SHELL], [${CONFIG_SHELL-/bin/sh}])
m4trace:configure.in:1: -1- AC_SUBST([PATH_SEPARATOR])
m4trace:configure.in:1: -1- AC_SUBST([PACKAGE_NAME], [m4_ifdef([AC_PACKAGE_NAME], ['AC_PACKAGE_NAME'])])
m4trace:configure.in:1: -1- AC_SUBST([PACKAGE_TARNAME], [m4_ifdef([AC_PACKAGE_TARNAME], ['AC_PACKAGE_TARNAME'])])
m4trace:configure.in:1: -1- AC_SUBST([PACKAGE_VERSION], [m4_ifdef([AC_PACKAGE_VERSION], ['AC_PACKAGE_VERSION'])])
m4trace:configure.in:1: -1- AC_SUBST([PACKAGE_STRING], [m4_ifdef([AC_PACKAGE_STRING], ['AC_PACKAGE_STRING'])])
m4trace:configure.in:1: -1- AC_SUBST([PACKAGE_BUGREPORT], [m4_ifdef([AC_PACKAGE_BUGREPORT], ['AC_PACKAGE_BUGREPORT'])])
m4trace:configure.in:1: -1- AC_SUBST([exec_prefix], [NONE])
m4trace:configure.in:1: -1- AC_SUBST([prefix], [NONE])
m4trace:configure.in:1: -1- AC_SUBST([program_transform_name], [s,x,x,])
m4trace:configure.in:1: -1- AC_SUBST([bindir], ['${exec_prefix}/bin'])
m4trace:configure.in:1: -1- AC_SUBST([sbindir], ['${exec_prefix}/sbin'])
m4trace:configure.in:1: -1- AC_SUBST([libexecdir], ['${exec_prefix}/libexec'])
m4trace:configure.in:1: -1- AC_SUBST([datadir], ['${prefix}/share'])
m4trace:configure.in:1: -1- AC_SUBST([sysconfdir], ['${prefix}/etc'])
m4trace:configure.in:1: -1- AC_SUBST([sharedstatedir], ['${prefix}/com'])
m4trace:configure.in:1: -1- AC_SUBST([localstatedir], ['${prefix}/var'])
m4trace:configure.in:1: -1- AC_SUBST([libdir], ['${exec_prefix}/lib'])
m4trace:configure.in:1: -1- AC_SUBST([includedir], ['${prefix}/include'])
m4trace:configure.in:1: -1- AC_SUBST([oldincludedir], ['/usr/include'])
m4trace:configure.in:1: -1- AC_SUBST([infodir], ['${prefix}/info'])
m4trace:configure.in:1: -1- AC_SUBST([mandir], ['${prefix}/man'])
m4trace:configure.in:1: -1- AC_DEFINE_TRACE_LITERAL([PACKAGE_NAME])
m4trace:configure.in:1: -1- AH_OUTPUT([PACKAGE_NAME], [/* Define to the full name of this package. */
#undef PACKAGE_NAME])
m4trace:configure.in:1: -1- AC_DEFINE_TRACE_LITERAL([PACKAGE_TARNAME])
m4trace:configure.in:1: -1- AH_OUTPUT([PACKAGE_TARNAME], [/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME])
m4trace:configure.in:1: -1- AC_DEFINE_TRACE_LITERAL([PACKAGE_VERSION])
m4trace:configure.in:1: -1- AH_OUTPUT([PACKAGE_VERSION], [/* Define to the version of this package. */
#undef PACKAGE_VERSION])
m4trace:configure.in:1: -1- AC_DEFINE_TRACE_LITERAL([PACKAGE_STRING])
m4trace:configure.in:1: -1- AH_OUTPUT([PACKAGE_STRING], [/* Define to the full name and version of this package. */
#undef PACKAGE_STRING])
m4trace:configure.in:1: -1- AC_DEFINE_TRACE_LITERAL([PACKAGE_BUGREPORT])
m4trace:configure.in:1: -1- AH_OUTPUT([PACKAGE_BUGREPORT], [/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT])
m4trace:configure.in:1: -1- AC_SUBST([build_alias])
m4trace:configure.in:1: -1- AC_SUBST([host_alias])
m4trace:configure.in:1: -1- AC_SUBST([target_alias])
m4trace:configure.in:1: -1- AC_SUBST([DEFS])
m4trace:configure.in:1: -1- AC_SUBST([ECHO_C])
m4trace:configure.in:1: -1- AC_SUBST([ECHO_N])
m4trace:configure.in:1: -1- AC_SUBST([ECHO_T])
m4trace:configure.in:1: -1- AC_SUBST([LIBS])
m4trace:configure.in:2: -1- AC_CONFIG_HEADERS([src/config.h])
m4trace:configure.in:2: -1- _m4_warn([obsolete], [The macro `AC_OUTPUT_COMMANDS' is obsolete.
You should run autoupdate.], [autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
aclocal.m4:855: AM_CONFIG_HEADER is expanded from...
configure.in:2: the top level])
m4trace:configure.in:2: -3- _m4_warn([obsolete], [The macro `_AC_OUTPUT_COMMANDS_CNT' is obsolete.
You should run autoupdate.], [autoconf/status.m4:321: _AC_OUTPUT_COMMANDS_CNT is expanded from...
autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from...
aclocal.m4:855: AM_CONFIG_HEADER is expanded from...
configure.in:2: the top level])
m4trace:configure.in:3: -1- AM_INIT_AUTOMAKE([bip], [0.0])
m4trace:configure.in:3: -1- AM_AUTOMAKE_VERSION([1.4-p6])
m4trace:configure.in:3: -1- AC_PROG_INSTALL
m4trace:configure.in:3: -1- AC_SUBST([INSTALL_PROGRAM])
m4trace:configure.in:3: -1- AC_SUBST([INSTALL_SCRIPT])
m4trace:configure.in:3: -1- AC_SUBST([INSTALL_DATA])
m4trace:configure.in:3: -1- AC_SUBST([PACKAGE])
m4trace:configure.in:3: -1- AC_SUBST([VERSION])
m4trace:configure.in:3: -2- AC_DEFINE_TRACE_LITERAL([PACKAGE])
m4trace:configure.in:3: -2- AH_OUTPUT([PACKAGE], [/* Name of package */
#undef PACKAGE])
m4trace:configure.in:3: -2- AC_DEFINE_TRACE_LITERAL([VERSION])
m4trace:configure.in:3: -2- AH_OUTPUT([VERSION], [/* Version number of package */
#undef VERSION])
m4trace:configure.in:3: -1- AC_SUBST([ACLOCAL])
m4trace:configure.in:3: -1- AC_SUBST([AUTOCONF])
m4trace:configure.in:3: -1- AC_SUBST([AUTOMAKE])
m4trace:configure.in:3: -1- AC_SUBST([AUTOHEADER])
m4trace:configure.in:3: -1- AC_SUBST([MAKEINFO])
m4trace:configure.in:3: -1- AC_PROG_MAKE_SET
m4trace:configure.in:3: -1- AC_SUBST([SET_MAKE])
m4trace:configure.in:4: -1- AC_PROG_CC
m4trace:configure.in:4: -1- AC_SUBST([CC])
m4trace:configure.in:4: -1- AC_SUBST([CFLAGS])
m4trace:configure.in:4: -1- AC_SUBST([LDFLAGS])
m4trace:configure.in:4: -1- AC_SUBST([CPPFLAGS])
m4trace:configure.in:4: -1- AC_SUBST([CC])
m4trace:configure.in:4: -1- AC_SUBST([ac_ct_CC])
m4trace:configure.in:4: -1- AC_SUBST([CC])
m4trace:configure.in:4: -1- AC_SUBST([ac_ct_CC])
m4trace:configure.in:4: -1- AC_SUBST([CC])
m4trace:configure.in:4: -1- AC_SUBST([CC])
m4trace:configure.in:4: -1- AC_SUBST([ac_ct_CC])
m4trace:configure.in:4: -1- AC_SUBST([EXEEXT], [$ac_cv_exeext])
m4trace:configure.in:4: -1- AC_SUBST([OBJEXT], [$ac_cv_objext])
m4trace:configure.in:5: -1- AC_PROG_INSTALL
m4trace:configure.in:5: -1- AC_SUBST([INSTALL_PROGRAM])
m4trace:configure.in:5: -1- AC_SUBST([INSTALL_SCRIPT])
m4trace:configure.in:5: -1- AC_SUBST([INSTALL_DATA])
m4trace:configure.in:6: -1- AC_PROG_YACC
m4trace:configure.in:6: -1- AC_SUBST([YACC])
m4trace:configure.in:7: -1- AC_SUBST([LEX])
m4trace:configure.in:7: -1- AC_PROG_LEX
m4trace:configure.in:7: -1- AC_SUBST([LEX])
m4trace:configure.in:7: -1- AC_CHECK_LIB([fl], [yywrap], [LEXLIB="-lfl"], [AC_CHECK_LIB(l, yywrap, LEXLIB="-ll")])
m4trace:configure.in:7: -1- AC_CHECK_LIB([l], [yywrap], [LEXLIB="-ll"])
m4trace:configure.in:7: -1- AC_SUBST([LEXLIB])
m4trace:configure.in:7: -1- AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])
m4trace:configure.in:7: -1- AC_DEFINE_TRACE_LITERAL([YYTEXT_POINTER])
m4trace:configure.in:7: -1- AH_OUTPUT([YYTEXT_POINTER], [/* Define to 1 if `lex\' declares `yytext\' as a `char *\' by default, not a
`char[]\'. */
#undef YYTEXT_POINTER])
m4trace:configure.in:7: -1- _m4_warn([obsolete], [The macro `AC_DECL_YYTEXT' is obsolete.
You should run autoupdate.], [autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from...
aclocal.m4:986: AM_PROG_LEX is expanded from...
configure.in:7: the top level])
m4trace:configure.in:7: -1- AC_PROG_LEX
m4trace:configure.in:7: -1- _m4_warn([syntax], [AC_PROG_LEX invoked multiple times], [autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from...
aclocal.m4:986: AM_PROG_LEX is expanded from...
configure.in:7: the top level])
m4trace:configure.in:17: -1- AC_CHECK_LIB([ssl], [SSL_read], [], [
echo "Error! You need to have libssl around."
exit -1
])
m4trace:configure.in:17: -1- AH_OUTPUT([HAVE_LIBSSL], [/* Define to 1 if you have the `ssl\' library (-lssl). */
#undef HAVE_LIBSSL])
m4trace:configure.in:17: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBSSL])
m4trace:configure.in:19: -1- AC_CONFIG_FILES([Makefile src/Makefile samples/Makefile])
m4trace:configure.in:19: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments.
You should run autoupdate.], [])
m4trace:configure.in:19: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:19: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])

1465
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1569
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

4256
configure vendored Executable file

File diff suppressed because it is too large Load Diff

19
configure.in Normal file
View File

@ -0,0 +1,19 @@
AC_INIT(src/bip.c)
AM_CONFIG_HEADER(src/config.h)
AM_INIT_AUTOMAKE(bip,0.0)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_YACC
AM_PROG_LEX
requires_libssl=yes
AC_ARG_ENABLE(ssl,
[ --disable-ssl Drop OpenSSL support],
[requires_libssl=no])
if test "x$requires_libssl" = "xyes" ; then
AC_CHECK_LIB(ssl, SSL_read, [], [
echo "Error! You need to have libssl around."
exit -1
])
fi
AC_OUTPUT(Makefile src/Makefile samples/Makefile)

1
debian/bip.substvars vendored Normal file
View File

@ -0,0 +1 @@
shlibs:Depends=libc6 (>= 2.3.4-1)

14
debian/bip/DEBIAN/control vendored Normal file
View File

@ -0,0 +1,14 @@
Package: bip
Version: 0.0-1
Section: net
Priority: optional
Architecture: i386
Depends: libc6 (>= 2.3.4-1)
Installed-Size: 172
Maintainer: Arnaud Cornet <nohar@t1r.net>
Description: multiuser irc proxy with ssl, conversation replay and more
Bip is a IRC proxy that supports as replaying logged conversation when a client
connects, multiple clients on one irc server connection, SSL support (on both
ends) and has a handy logging directory structure. It is multiuser, and has a
flexible configuration. Some of it's configuration can be changed at runtime
with special irc commands.

9
debian/bip/DEBIAN/md5sums vendored Normal file
View File

@ -0,0 +1,9 @@
2fcb2e23f48dd8e205b6e434bb0a1e49 usr/bin/bip
df1d3b30f4ccb839963d39b67fcc83e3 usr/bin/genpwent
816e04d8e35370693904cc3a06107e56 usr/share/bip/bip.conf
48f6c5372dbef10c96f251f313a4c83b usr/share/bip/bip.vim
b35795a23db4c45c95fc897375954a49 usr/share/doc/bip/README
08e6785d9f0333a1f0009c71655a8e6a usr/share/doc/bip/TODO
c9367cfeedf1700a01107616effd5c8e usr/share/doc/bip/AUTHORS
75e57f35e3a9155f3cd215d43dd31380 usr/share/doc/bip/changelog.gz
9416df600764b0209c175026fd2f7702 usr/share/doc/bip/changelog.Debian.gz

BIN
debian/bip/usr/bin/bip vendored Executable file

Binary file not shown.

BIN
debian/bip/usr/bin/genpwent vendored Executable file

Binary file not shown.

122
debian/bip/usr/share/bip/bip.conf vendored Normal file
View File

@ -0,0 +1,122 @@
# bip default config file.
# Thou shoult change thy password
ip = "0.0.0.0";
# To connect a client to bip, try the port below, and
# be sure to set the username and password to the values
# specified in the network you want to connect to.
port = 7778;
# If you set this to true, you'll only be able to connect to bip
# with a SSL capable IRC client. Be sure to generate a certificate
# for bip with 'make cert'
client_side_ssl = false;
log_level = 3;
# This is where logs go. Channel and private messages will use that
# configuration value as a prefix, and then log_format to determine
# full log filename.
#log_root = "/var/proxy/logs";
# Log format allows you to make log filenames depend on the log line's
# attributes. Here's a list :
# %u -> user name
# %n -> network name
# %Y -> 4 digit year
# %m -> 2 digit month
# %d -> 2 digit day
# %c -> destination (#chan, privates, ...)
#log_format = "%n/%Y-%m/%c.%d.log";
# Sets the frequency (in seconds) of log syncing (real write to kernel)
#log_sync_interval = 5;
# Makes bip send the log of each channel and privates while
# you were not connected to the proxy upon connection.
#no_backlog = false; # disable backlog
backlog_lines = 10; # number of lines in backlog, 0 means no limit
always_backlog = true; # backlog even lines already backlogged
# Network definition, a name and server info
network {
name = "iiens";
server { host = "irc.iiens.net"; port = 6667; };
};
network {
name = "freenode";
server { host = "irc.freenode.org"; port = 6667; };
server { host = "brown.freenode.net"; port = 6667; };
server { host = "thunder.stealer.net"; port = 6667; };
};
# Configuration example with one user who connects to two irc networks
# To use the multi-server feature:
# - define the connections
# - chose and setup a different login for each connection
# on your irc client:
# - Use the multi server feature of your client, the server beeing each time
# the server where bip is running. In your client setup realname or username
# to the value of login in the corresponding connection.
# User structure is grouping information for a given user
user {
# The name in bip of the user
# This is used by bip only
name = "nohar";
# this user's password
password = "233a8d53b55a268d4a84a3acdd5ed57d"; # (md5(md5("tata")))
# A user can have mutiple connections to irc networks.
# define a connection:
connection {
name = "iiens"; # used by bip only
network = "iiens"; # which ircnet to connect to
login = "bipbip"; # used to auth user and to diffenciate
# among multiple connections of a user.
# in your irc client setup username or
# realname to this login value.
# Information sent to the irc server:
nick = "bip`luser";
user = "bipbip";
realname = "coyote";
#password = "serverpassword";
# Some options:
#away_nick = "bip`away";
#follow_nick = true;
#ignore_first_nick = true;
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
# Autojoined channels:
channel { name = "#bip"; };
};
connection {
name = "freenode"; # used by bip only
network = "freenode"; # which ircnet to connect to
login = "bipfnode"; # used to auth user and to diffenciate
# among multiple connections of a user.
# in your irc client setup username or
# realname to this login value.
# Information sent to the irc server:
nick = "bip`luser";
user = "bipbip";
realname = "coyote";
#password = "serverpassword";
# Some options:
#away_nick = "bip`away";
#follow_nick = true;
#ignore_first_nick = true;
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
# Autojoined channels:
channel { name = "#bip"; };
};
};

135
debian/bip/usr/share/bip/bip.vim vendored Normal file
View File

@ -0,0 +1,135 @@
" Vim syntax file
" Language: Bip configuration file
" Copyright: Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
" License: This file is part of the bip project. See the file 'COPYING' for
" the exact licensing terms.
"
"
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
" Global elements
syn match bipComment contained %\s*#.*$%
syn match bipEndError contained /\(#.*\)\@<![^;{]$/
" Possible values types.
syn region bipString contained start=+"+ end=+"+
syn keyword bipBool contained true false
syn match bipNumeric contained /\d\d*/
syn region bipIP contained start=+"+ end=+"+ contains=bipAddrTk,bipDot
syn region bipNetmask contained start=+"+ end=+"+ contains=bipAddrTk,bipDot,bipSlash,bipMask
syn match bipAddrTk contained #\d\{1,3}#
syn match bipDot contained #\.#
syn match bipSlash contained #/#
syn match bipMask contained #\d\{1,2}#
syn match bipWhite contained +#\@!\s*+
" wrong
" syn match bipWhite contained +^\s*\ze[^#]*+
" Values syntax
syn region bipStringV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipString
syn region bipBoolV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipBool
syn region bipNumericV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipNumeric
syn region bipIPV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipIP
syn region bipNetmaskV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipNetmask
syn region bipMain start=/\%^/ end=/\%$/ contains=bipKeyword,bipNetwork,bipUser,bipComment,bipEndError
" Top level elements
syn keyword bipKeyword contained nextgroup=bipBoolV client_side_ssl no_backlog always_backlog
syn keyword bipKeyword contained nextgroup=bipStringV log_root log_format pid_file
syn keyword bipKeyword contained nextgroup=bipNumericV port log_level backlog_lines log_sync_interval
syn keyword bipKeyword contained nextgroup=bipIPV ip
" Network block (level 1)
syn region bipNetwork contained matchgroup=Macro start=/network\s*{\s*/ end=/};/
\ contains=bipNKeyword,bipServer,bipComment,bipEndError,bipWhite
syn keyword bipNKeyword contained nextgroup=bipStringV name
syn keyword bipNKeyword contained nextgroup=bipBoolV ssl
" User block (level 1)
syn region bipUser contained matchgroup=Macro start=/user\s*{\s*/ end=/};/
\ contains=bipUKeyword,bipConnection,bipComment,bipEndError,bipWhite
syn keyword bipUKeyword contained nextgroup=bipStringV nick user realname password username name
" Connection block (level 2)
syn region bipConnection contained matchgroup=Macro start=/connection\s*{\s*/ end=/};/
\ contains=bipCoKeyword,bipChannel,bipComment,bipEndError,bipWhite
syn keyword bipCoKeyword contained nextgroup=bipBoolV ssl follow_nick ignore_first_nick
syn keyword bipCoKeyword contained nextgroup=bipStringV name user network password vhost away_nick on_connect_send
syn keyword bipCoKeyword contained nextgroup=bipNumericV source_port
" Channel elements (lvl 2)
syn region bipChannel contained matchgroup=Macro start=/channel\s*{\s*/ end=/};/
\ contains=bipCKeyword,bipComment,bipEndError,bipWhite
syn keyword bipCKeyword contained nextgroup=bipStringV name key
" Server elements (lvl 2)
syn region bipServer contained matchgroup=Macro start=/server\s*{\s*/ end=/};/
\ contains=bipSKeyword,bipComment,bipEndError,bipWhite
syn keyword bipSKeyword contained nextgroup=bipStringV host
syn keyword bipSKeyword contained nextgroup=bipNumericV port
" Client elements (lvl 2)
syn region bipClient contained matchgroup=Macro start=/client\s*{\s*/ end=/};/
\ contains=bipCLKeyword,bipComment,bipEndError,bipWhite
syn keyword bipCLKeyword contained nextgroup=bipStringV user password
" Synchronization
syn sync match bipSyncNet grouphere bipNetwork /\_.\s*\(network\s*{\)\@=+/
syn sync match bipSyncUser grouphere bipUser /\_.\s*\(user\s*{\)\@=+/
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version < 508
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink bipMain Error
HiLink bipNetwork Error
HiLink bipChannel Error
HiLink bipServer Error
HiLink bipUser Error
" We do not HiLink bipWhite, siec we only want to ignore it.
HiLink bipKeyword Keyword
HiLink bipNKeyword Keyword
HiLink bipUKeyword Keyword
HiLink bipCKeyword Keyword
HiLink bipSKeyword Keyword
HiLink bipCoKeyword Keyword
HiLink bipComment Comment
HiLink bipMatch Include
HiLink bipStringV Error
HiLink bipBoolV Error
HiLink bipNumericV Error
HiLink bipIPV Error
HiLink bipEndError Error
HiLink bipString String
HiLink bipBool Boolean
HiLink bipNumeric Number
HiLink bipIP String
HiLink bipAddrTk String
HiLink bipDot Delimiter
HiLink bipSlash Delimiter
HiLink bipMask Number
delcommand HiLink
let b:current_syntax = "bip"
" vim: ts=8

6
debian/bip/usr/share/doc/bip/AUTHORS vendored Normal file
View File

@ -0,0 +1,6 @@
Arnaud 'nohar' Cornet
Loïc 'Kyoshiro' Gomez
Thanks to jj, YS and lafounie, for hanging around while we were coding.
Crypto shamelessly taken from Christophe 'sexy' Devine.

2
debian/bip/usr/share/doc/bip/README vendored Normal file
View File

@ -0,0 +1,2 @@
log encryption support
salt this md5

9
debian/bip/usr/share/doc/bip/TODO vendored Normal file
View File

@ -0,0 +1,9 @@
- SSL certificate verification
- allowed IP filtering
- multi user (user/pass to identify user + realname to id. network)
- keep invites when detached
- DCC proxying ?
- /bip command, for admin (rehash, jump, ...)
- crypt logs
tidy up irc_server/server structures

Binary file not shown.

Binary file not shown.

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
bip (0.0-1) unstable; urgency=low
* debian/rules: Initial package
-- Arnaud Cornet <nohar@t1r.net> Thu, 20 Apr 2005 22:00:45 -0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
4

16
debian/control vendored Normal file
View File

@ -0,0 +1,16 @@
Source: bip
Section: net
Priority: optional
Maintainer: Arnaud Cornet <nohar@t1r.net>
Standards-Version: 3.6.1.1
Build-Depends: cdbs, libssl-dev, bison, flex
Package: bip
Architecture: any
Depends: ${shlibs:Depends}
Description: multiuser irc proxy with ssl, conversation replay and more
Bip is a IRC proxy that supports as replaying logged conversation when a client
connects, multiple clients on one irc server connection, SSL support (on both
ends) and has a handy logging directory structure. It is multiuser, and has a
flexible configuration. Some of it's configuration can be changed at runtime
with special irc commands.

1
debian/files vendored Normal file
View File

@ -0,0 +1 @@
bip_0.0-1_i386.deb net optional

4
debian/rules vendored Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

0
debian/stamp-autotools-files vendored Normal file
View File

0
debian/stamp-makefile-build vendored Normal file
View File

269
install-sh Executable file
View File

@ -0,0 +1,269 @@
#!/bin/sh
#
# install - install a program, script, or datafile
#
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

198
missing Executable file
View File

@ -0,0 +1,198 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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, 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.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.in; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`$configure_ac'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`$configure_ac'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`$configure_ac'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

40
mkinstalldirs Executable file
View File

@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

2
samples/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
examplesdir = $(prefix)/share/doc/bip/examples/
examples_DATA = bip.conf bip.vim

202
samples/Makefile.in Normal file
View File

@ -0,0 +1,202 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in 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.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
CC = @CC@
HAVE_LIB = @HAVE_LIB@
LEX = @LEX@
LIB = @LIB@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
YACC = @YACC@
examplesdir = $(prefix)/share/doc/bip/examples/
examples_DATA = bip.conf bip.vim
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../src/config.h
CONFIG_CLEAN_FILES =
DATA = $(examples_DATA)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu samples/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
install-examplesDATA: $(examples_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(examplesdir)
@list='$(examples_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(examplesdir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(examplesdir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(examplesdir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(examplesdir)/$$p; \
fi; fi; \
done
uninstall-examplesDATA:
@$(NORMAL_UNINSTALL)
list='$(examples_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(examplesdir)/$$p; \
done
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = samples
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu samples/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am: install-examplesDATA
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-examplesDATA
uninstall: uninstall-am
all-am: Makefile $(DATA)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(examplesdir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: uninstall-examplesDATA install-examplesDATA tags distdir info-am \
info dvi-am dvi check check-am installcheck-am installcheck \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

122
samples/bip.conf Normal file
View File

@ -0,0 +1,122 @@
# bip default config file.
# Thou shoult change thy password
ip = "0.0.0.0";
# To connect a client to bip, try the port below, and
# be sure to set the username and password to the values
# specified in the network you want to connect to.
port = 7778;
# If you set this to true, you'll only be able to connect to bip
# with a SSL capable IRC client. Be sure to generate a certificate
# for bip with 'make cert'
client_side_ssl = false;
log_level = 3;
# This is where logs go. Channel and private messages will use that
# configuration value as a prefix, and then log_format to determine
# full log filename.
#log_root = "/var/proxy/logs";
# Log format allows you to make log filenames depend on the log line's
# attributes. Here's a list :
# %u -> user name
# %n -> network name
# %Y -> 4 digit year
# %m -> 2 digit month
# %d -> 2 digit day
# %c -> destination (#chan, privates, ...)
#log_format = "%n/%Y-%m/%c.%d.log";
# Sets the frequency (in seconds) of log syncing (real write to kernel)
#log_sync_interval = 5;
# Makes bip send the log of each channel and privates while
# you were not connected to the proxy upon connection.
#no_backlog = false; # disable backlog
backlog_lines = 10; # number of lines in backlog, 0 means no limit
always_backlog = true; # backlog even lines already backlogged
# Network definition, a name and server info
network {
name = "iiens";
server { host = "irc.iiens.net"; port = 6667; };
};
network {
name = "freenode";
server { host = "irc.freenode.org"; port = 6667; };
server { host = "brown.freenode.net"; port = 6667; };
server { host = "thunder.stealer.net"; port = 6667; };
};
# Configuration example with one user who connects to two irc networks
# To use the multi-server feature:
# - define the connections
# - chose and setup a different login for each connection
# on your irc client:
# - Use the multi server feature of your client, the server beeing each time
# the server where bip is running. In your client setup realname or username
# to the value of login in the corresponding connection.
# User structure is grouping information for a given user
user {
# The name in bip of the user
# This is used by bip only
name = "nohar";
# this user's password
password = "233a8d53b55a268d4a84a3acdd5ed57d"; # (md5(md5("tata")))
# A user can have mutiple connections to irc networks.
# define a connection:
connection {
name = "iiens"; # used by bip only
network = "iiens"; # which ircnet to connect to
login = "bipbip"; # used to auth user and to diffenciate
# among multiple connections of a user.
# in your irc client setup username or
# realname to this login value.
# Information sent to the irc server:
nick = "bip`luser";
user = "bipbip";
realname = "coyote";
#password = "serverpassword";
# Some options:
#away_nick = "bip`away";
#follow_nick = true;
#ignore_first_nick = true;
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
# Autojoined channels:
channel { name = "#bip"; };
};
connection {
name = "freenode"; # used by bip only
network = "freenode"; # which ircnet to connect to
login = "bipfnode"; # used to auth user and to diffenciate
# among multiple connections of a user.
# in your irc client setup username or
# realname to this login value.
# Information sent to the irc server:
nick = "bip`luser";
user = "bipbip";
realname = "coyote";
#password = "serverpassword";
# Some options:
#away_nick = "bip`away";
#follow_nick = true;
#ignore_first_nick = true;
#on_connect_send = "PRIVMSG NickServ :IDENTIFY nspassword";
# Autojoined channels:
channel { name = "#bip"; };
};
};

135
samples/bip.vim Normal file
View File

@ -0,0 +1,135 @@
" Vim syntax file
" Language: Bip configuration file
" Copyright: Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
" License: This file is part of the bip project. See the file 'COPYING' for
" the exact licensing terms.
"
"
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
" Global elements
syn match bipComment contained %\s*#.*$%
syn match bipEndError contained /\(#.*\)\@<![^;{]$/
" Possible values types.
syn region bipString contained start=+"+ end=+"+
syn keyword bipBool contained true false
syn match bipNumeric contained /\d\d*/
syn region bipIP contained start=+"+ end=+"+ contains=bipAddrTk,bipDot
syn region bipNetmask contained start=+"+ end=+"+ contains=bipAddrTk,bipDot,bipSlash,bipMask
syn match bipAddrTk contained #\d\{1,3}#
syn match bipDot contained #\.#
syn match bipSlash contained #/#
syn match bipMask contained #\d\{1,2}#
syn match bipWhite contained +#\@!\s*+
" wrong
" syn match bipWhite contained +^\s*\ze[^#]*+
" Values syntax
syn region bipStringV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipString
syn region bipBoolV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipBool
syn region bipNumericV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipNumeric
syn region bipIPV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipIP
syn region bipNetmaskV contained matchgroup=Delimiter start=/\s*=\s*/ end=/\s*;\s*/ contains=bipNetmask
syn region bipMain start=/\%^/ end=/\%$/ contains=bipKeyword,bipNetwork,bipUser,bipComment,bipEndError
" Top level elements
syn keyword bipKeyword contained nextgroup=bipBoolV client_side_ssl no_backlog always_backlog
syn keyword bipKeyword contained nextgroup=bipStringV log_root log_format pid_file
syn keyword bipKeyword contained nextgroup=bipNumericV port log_level backlog_lines log_sync_interval
syn keyword bipKeyword contained nextgroup=bipIPV ip
" Network block (level 1)
syn region bipNetwork contained matchgroup=Macro start=/network\s*{\s*/ end=/};/
\ contains=bipNKeyword,bipServer,bipComment,bipEndError,bipWhite
syn keyword bipNKeyword contained nextgroup=bipStringV name
syn keyword bipNKeyword contained nextgroup=bipBoolV ssl
" User block (level 1)
syn region bipUser contained matchgroup=Macro start=/user\s*{\s*/ end=/};/
\ contains=bipUKeyword,bipConnection,bipComment,bipEndError,bipWhite
syn keyword bipUKeyword contained nextgroup=bipStringV nick user realname password username name
" Connection block (level 2)
syn region bipConnection contained matchgroup=Macro start=/connection\s*{\s*/ end=/};/
\ contains=bipCoKeyword,bipChannel,bipComment,bipEndError,bipWhite
syn keyword bipCoKeyword contained nextgroup=bipBoolV ssl follow_nick ignore_first_nick
syn keyword bipCoKeyword contained nextgroup=bipStringV name user network password vhost away_nick on_connect_send
syn keyword bipCoKeyword contained nextgroup=bipNumericV source_port
" Channel elements (lvl 2)
syn region bipChannel contained matchgroup=Macro start=/channel\s*{\s*/ end=/};/
\ contains=bipCKeyword,bipComment,bipEndError,bipWhite
syn keyword bipCKeyword contained nextgroup=bipStringV name key
" Server elements (lvl 2)
syn region bipServer contained matchgroup=Macro start=/server\s*{\s*/ end=/};/
\ contains=bipSKeyword,bipComment,bipEndError,bipWhite
syn keyword bipSKeyword contained nextgroup=bipStringV host
syn keyword bipSKeyword contained nextgroup=bipNumericV port
" Client elements (lvl 2)
syn region bipClient contained matchgroup=Macro start=/client\s*{\s*/ end=/};/
\ contains=bipCLKeyword,bipComment,bipEndError,bipWhite
syn keyword bipCLKeyword contained nextgroup=bipStringV user password
" Synchronization
syn sync match bipSyncNet grouphere bipNetwork /\_.\s*\(network\s*{\)\@=+/
syn sync match bipSyncUser grouphere bipUser /\_.\s*\(user\s*{\)\@=+/
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version < 508
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink bipMain Error
HiLink bipNetwork Error
HiLink bipChannel Error
HiLink bipServer Error
HiLink bipUser Error
" We do not HiLink bipWhite, siec we only want to ignore it.
HiLink bipKeyword Keyword
HiLink bipNKeyword Keyword
HiLink bipUKeyword Keyword
HiLink bipCKeyword Keyword
HiLink bipSKeyword Keyword
HiLink bipCoKeyword Keyword
HiLink bipComment Comment
HiLink bipMatch Include
HiLink bipStringV Error
HiLink bipBoolV Error
HiLink bipNumericV Error
HiLink bipIPV Error
HiLink bipEndError Error
HiLink bipString String
HiLink bipBool Boolean
HiLink bipNumeric Number
HiLink bipIP String
HiLink bipAddrTk String
HiLink bipDot Delimiter
HiLink bipSlash Delimiter
HiLink bipMask Number
delcommand HiLink
let b:current_syntax = "bip"
" vim: ts=8

5
src/Makefile.am Normal file
View File

@ -0,0 +1,5 @@
bin_PROGRAMS = bip genpwent
bip_SOURCES = conf.y lex.l bip.c connection.c irc.c line.c log.c md5.c util.c
genpwent_SOURCES = genpwent.c md5.c util.c
AM_YFLAGS= -d
CFLAGS=-Wall

375
src/Makefile.in Normal file
View File

@ -0,0 +1,375 @@
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in 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.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
CC = @CC@
HAVE_LIB = @HAVE_LIB@
LEX = @LEX@
LIB = @LIB@
LTLIB = @LTLIB@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
YACC = @YACC@
bin_PROGRAMS = bip genpwent
bip_SOURCES = conf.y lex.l bip.c connection.c irc.c line.c log.c md5.c util.c
genpwent_SOURCES = genpwent.c md5.c util.c
AM_YFLAGS = -d
CFLAGS = -Wall
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
bip_OBJECTS = conf.o lex.o bip.o connection.o irc.o line.o log.o md5.o \
util.o
bip_LDADD = $(LDADD)
bip_DEPENDENCIES =
bip_LDFLAGS =
genpwent_OBJECTS = genpwent.o md5.o util.o
genpwent_LDADD = $(LDADD)
genpwent_DEPENDENCIES =
genpwent_LDFLAGS =
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LEXLIB = @LEXLIB@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in conf.c config.h.in \
lex.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
DEP_FILES = .deps/bip.P .deps/conf.P .deps/connection.P \
.deps/genpwent.P .deps/irc.P .deps/lex.P .deps/line.P .deps/log.P \
.deps/md5.P .deps/util.P
SOURCES = $(bip_SOURCES) $(genpwent_SOURCES)
OBJECTS = $(bip_OBJECTS) $(genpwent_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .l .o .s .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=src/config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
bip: $(bip_OBJECTS) $(bip_DEPENDENCIES)
@rm -f bip
$(LINK) $(bip_LDFLAGS) $(bip_OBJECTS) $(bip_LDADD) $(LIBS)
genpwent: $(genpwent_OBJECTS) $(genpwent_DEPENDENCIES)
@rm -f genpwent
$(LINK) $(genpwent_LDFLAGS) $(genpwent_OBJECTS) $(genpwent_LDADD) $(LIBS)
.l.c:
$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
conf.h: conf.c
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP))
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = src
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am: install-binPROGRAMS
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) config.h
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-test -z "lexcconfhconfc" || rm -f lexc confh confc
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-compile mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \
clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \
distclean-tags distclean-depend distclean-generic \
clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
distclean-depend clean-depend maintainer-clean-depend info-am info \
dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

981
src/bip.c Normal file
View File

@ -0,0 +1,981 @@
/*
* $Id: bip.c,v 1.39 2005/04/21 06:58:50 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdarg.h>
#include "irc.h"
#include "conf.h"
#include "tuple.h"
#include "log.h"
#include "irc.h"
#include "bip.h"
#include "line.h"
int sighup = 0;
char *conf_log_root;
char *conf_log_format;
int conf_log_level;
char *conf_ip;
unsigned short conf_port;
int conf_css;
#ifdef HAVE_LIBSSL
char *conf_ssl_certfile;
#endif
int conf_daemonize;
char *conf_pid_file;
hash_t conf_networks;
hash_t conf_users;
char *conf_biphome;
hash_t adm_users;
/* log options, for sure the trickiest :) */
/* no backlog at all */
int conf_no_backlog;
/* number of lines in backlog */
int conf_backlog_lines = 10;
/* backlog even lines already backlogged */
int conf_always_backlog;
int conf_log_sync_interval;
static void conf_die(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
exit(1);
}
static void hash_binary(char *hex, unsigned char **password, unsigned int *seed)
{
unsigned char *md5;
unsigned int buf;
int i;
if (strlen(hex) != 40)
fatal("Incorrect password format %s\n", hex);
md5 = malloc(20);
for (i = 0; i < 20; i++) {
sscanf(hex + 2 * i, "%02x", &buf);
md5[i] = buf;
}
*seed = 0;
sscanf(hex, "%02x", &buf);
*seed |= buf << 24;
sscanf(hex + 2, "%02x", &buf);
*seed |= buf << 16;
sscanf(hex + 2 * 2, "%02x", &buf);
*seed |= buf << 8;
sscanf(hex + 2 * 3, "%02x", &buf);
*seed |= buf;
*password = md5;
}
void server_free(struct server *s)
{
free(s->host);
free(s);
}
static void add_server(list_t *serverl, list_t *data)
{
struct tuple *t;
struct server *s;
s = calloc(sizeof(struct server), 1);
s->port = 6667; /* default port */
while ((t = list_remove_first(data))) {
switch (t->type) {
case LEX_HOST:
s->host = t->pdata;
break;
case LEX_PORT:
s->port = t->ndata;
break;
default:
fatal("Config error in server block (%d)", t->type);
}
}
if (!s->host)
fatal("Server conf: host not set");
list_add_last(serverl, s);
}
extern list_t *root_list;
int yyparse();
int conf_error;
#define ERRBUFSZ 80
char conf_errstr[ERRBUFSZ];
void free_conf(list_t *l);
list_t *parse_conf(FILE *file);
void free_conf(list_t *l)
{
struct tuple *t;
list_iterator_t li;
for (list_it_init(l, &li); (t = list_it_item(&li)); list_it_next(&li)) {
switch (t->tuple_type) {
case TUPLE_STR:
free(t->pdata); /* no break, for the style */
case TUPLE_INT:
free(t);
break;
case TUPLE_LIST:
free_conf(t->pdata);
break;
default:
fatal("internal error free_conf");
break;
}
}
}
FILE *conf_global_log_file;
static pid_t daemonize(void)
{
char buf[4096];
switch (fork()) {
case -1:
fatal("Fork failed");
break;
case 0:
break;
default:
exit(0);
}
if (setsid() < 0)
fatal("setsid() failed");
snprintf(buf, 4095, "%s/bip.syslog", conf_log_root);
FILE *f = fopen(buf, "a");
if (!f)
fatal("Can't open %s: %s", buf, strerror(errno));
close(0);
close(1);
close(2);
/* This better be the very last action since fatal makes use of
* conf_global_log_file */
conf_global_log_file = f;
return getpid();
}
/* RACE CONDITION! */
int do_pid_stuff(void)
{
char hname[1024];
char longpath[1024];
FILE *f;
try_again:
f = fopen(conf_pid_file, "r");
if (f)
goto pid_is_there;
if (gethostname(hname, 1023) == -1)
fatal("%s %s", "gethostname", strerror(errno));
snprintf(longpath, 1023, "%s.%s.%ld", conf_pid_file, hname,
(long unsigned int)getpid());
int fd;
if ((fd = open(longpath, O_CREAT|O_WRONLY, S_IWUSR|S_IRUSR)) == -1)
fatal("%s %s", "open", strerror(errno));
if (link(longpath, conf_pid_file) == -1) {
struct stat buf;
if (stat(longpath, &buf) == -1) {
if (buf.st_nlink != 2) {
f = fopen(conf_pid_file, "r");
goto pid_is_there;
}
}
}
unlink(longpath);
return fd;
pid_is_there:
{
pid_t pid;
long unsigned int p;
if (f) {
int c = fscanf(f, "%ld", &p);
pid = p;
if (c != 1 || p == 0) {
mylog(LOG_INFO, "pid file found but invalid "
"data inside. Continuing...\n");
if (unlink(conf_pid_file)) {
fatal("Cannot delete pid file '%s', "
"check permissions.\n",
conf_pid_file);
}
goto try_again;
}
} else
pid = 0;
int kr = kill(pid, 0);
if (kr == -1 && (errno == ESRCH || errno == EPERM)) {
/* that's not bip! */
fclose(f);
if (unlink(conf_pid_file)) {
fatal("Cannot delete pid file '%s', check "
"permissions.\n",
conf_pid_file);
}
goto try_again;
}
if (pid)
mylog(LOG_INFO, "pid file found (pid %ld).", pid);
mylog(LOG_INFO, "Another instance of bip is certainly runing.");
mylog(LOG_INFO, "If you are sure this is not the case remove"
" %s.", conf_pid_file);
exit(2);
}
return 0;
}
#define S_CONF "/.bip/bip.conf"
static void usage(char *name)
{
printf(
"Usage: %s [-f config_file] [-h] [-n]\n"
" -f config_file: Use config_file as the configuration file\n"
" If no config file is given %s will try to open ~" S_CONF "\n"
" -n: Don't daemonize, log in stderr\n"
" -h: This help\n", name, name);
exit(1);
}
void reload_config(int i)
{
sighup = 1;
}
void bad_quit(int i)
{
unlink(conf_pid_file);
exit(i);
}
#if 0
void check_networks(list_t *networkl)
{
list_iterator_t li;
struct irc_server *is;
hash_t *netnames;
netnames = hash_new(HASH_DEFAULT);
for (list_it_init(networkl, &li); (is = list_it_item(&li));
list_it_next(&li)) {
/*
hash_iterator_t hi;
*/
/* Should *NEVER* happen */
if (!is->name)
fatal("CONF: Unnamed network !");
if (hash_get(netnames, is->name))
fatal("CONF: Two networks have the same name !");
hash_insert(netnames, is->name, is);
if (!is->serverc)
fatal("CONF: No servers to connect to in network %s",
is->name);
/* TODO check for identical channels or servers */
/* It could be great to check it here, but we need to check it
* before...
*/
/*
for (hash_it_init(&is->chan_infos, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
struct chan_info *ci = hash_it_item(&hi);
if (!ci->name)
fatal("CONF: Unnamed channel in network %s",
is->name);
}
*/
}
hash_free(netnames);
}
void check_clients(list_t *clientl)
{
list_iterator_t li;
struct client *ic;
for (list_it_init(clientl, &li); (ic = list_it_item(&li));
list_it_next(&li)) {
char *netname;
/* TODO hash(user => pass) to check for auth collision */
/* Should *NEVER* happen */
if (!ic->server)
fatal("CONF: Unaffected client in list...");
netname = ic->server->name;
/*
if (!ic->user)
fatal("CONF: Client block with no user in network %s",
netname);
*/
if (!ic->pass)
fatal("CONF: Client block with no pass in network %s",
netname);
}
}
#endif
void c_network_free(struct c_network *on)
{
struct server *s;
free(on->name);
s = list_remove_first(&on->serverl);
free(s->host);
free(on);
}
void add_network(list_t *data)
{
struct tuple *t;
struct c_network *n;
n = calloc(sizeof(struct c_network), 1);
list_init(&n->serverl, NULL);
while ((t = list_remove_first(data))) {
switch (t->type) {
case LEX_NAME:
n->name = t->pdata;
break;
#ifdef HAVE_LIBSSL
case LEX_SSL:
n->ssl = t->ndata;
break;
#endif
case LEX_SERVER:
add_server(&n->serverl, t->pdata);
break;
default:
conf_die("uknown keyword in network statement");
break;
}
}
if (!n->name)
conf_die("Network with no name");
struct c_network *old_n;
old_n = hash_get(&conf_networks, n->name);
if (old_n) {
hash_remove(&conf_networks, n->name);
c_network_free(old_n);
}
hash_insert(&conf_networks, n->name, n);
}
void add_channel(list_t *channell, list_t *data)
{
struct tuple *t;
struct c_channel *c;
c = calloc(sizeof(struct c_channel), 1);
while ((t = list_remove_first(data))) {
switch (t->type) {
case LEX_NAME:
c->name = t->pdata;
break;
case LEX_KEY:
c->key = t->pdata;
break;
default:
conf_die("uknown keyword in channel statement");
break;
}
}
if (!c->name)
conf_die("channel wo a name !");
list_add_last(channell, c);
}
void c_connection_free(struct c_connection *c)
{
/* XXX network free! */
free(c->user);
free(c->password);
free(c->vhost);
struct c_channel *chan;
while ((chan = list_remove_first(&c->channell))) {
free(chan->name);
if (chan->key)
free(chan->key);
free(chan);
}
free(c->away_nick);
free(c->on_connect_send);
}
void add_connection(list_t *connectionl, list_t *data, list_t *old_c_connl)
{
struct tuple *t;
struct c_connection *c, *old_c = NULL;
c = calloc(sizeof(struct c_connection), 1);
list_init(&c->channell, NULL);
while ((t = list_remove_first(data))) {
switch (t->type) {
case LEX_NAME:
c->name = t->pdata;
break;
case LEX_NETWORK:
c->network = hash_get(&conf_networks, t->pdata);
if (!c->network)
conf_die("networkd:%s used but not defined\n",
t->pdata);
break;
case LEX_LOGIN:
if (!is_valid_username(t->pdata))
conf_die("Invalid login (%s)", t->pdata);
c->login = t->pdata;
break;
case LEX_NICK:
if (!is_valid_nick(t->pdata))
conf_die("Invalid nickname (%s)", t->pdata);
c->nick = t->pdata;
break;
case LEX_USER:
c->user = t->pdata;
break;
case LEX_REALNAME:
c->realname = t->pdata;
break;
case LEX_PASSWORD:
c->password = t->pdata;
break;
case LEX_CHANNEL:
add_channel(&c->channell, t->pdata);
break;
case LEX_FOLLOW_NICK:
c->follow_nick = t->ndata;
break;
case LEX_IGN_FIRST_NICK:
c->ignore_first_nick = t->ndata;
break;
case LEX_AWAY_NICK:
c->away_nick = t->pdata;
break;
case LEX_ON_CONNECT_SEND:
c->on_connect_send = t->pdata;
break;
default:
conf_die("uknown keyword in connection statement");
break;
}
}
/* checks that can only be here, or must */
if (!c->network)
conf_die("Missing network in connection block");
if (!c->user)
conf_die("Missing user in connection block");
list_add_last(connectionl, c);
if (old_c_connl) {
old_c = list_remove_first(old_c_connl);
if (old_c)
c_connection_free(old_c);
}
}
void c_user_free(struct c_user *cu)
{
free(cu->name);
free(cu->password);
struct c_connection *con;
while ((con = list_remove_first(&cu->connectionl)))
c_connection_free(con);
free(cu);
}
void add_user(list_t *data)
{
struct tuple *t;
struct c_user *u;
struct c_user *old_u;
u = calloc(sizeof(struct c_user), 1);
list_init(&u->connectionl, NULL);
while ((t = list_remove_first(data))) {
switch (t->type) {
case LEX_NAME:
u->name = t->pdata;
old_u = hash_get(&conf_users, u->name);
break;
case LEX_PASSWORD:
hash_binary(t->pdata, &u->password, &u->seed);
free(t->pdata);
break;
case LEX_CONNECTION:
if (!u->name)
conf_die("name statement must be first in user"
"block");
if (!old_u)
add_connection(&u->connectionl, t->pdata, NULL);
else
add_connection(&u->connectionl, t->pdata,
&old_u->connectionl);
break;
default:
conf_die("uknown keyword in user statement");
break;
}
}
if (!u->name)
conf_die("User w/o a name!");
if (!u->password)
conf_die("Missing password in user block");
if (old_u) {
hash_remove(&conf_users, u->name);
c_user_free(old_u);
}
hash_insert(&conf_users, u->name, u);
}
int fireup(FILE *conf)
{
struct tuple *t;
list_t *l;
l = parse_conf(conf);
if (conf_error)
return 0;
list_iterator_t li;
for (list_it_init(l, &li); (t = list_it_item(&li)); list_it_next(&li)) {
switch (t->type) {
case LEX_LOG_SYNC_INTERVAL:
conf_log_sync_interval = t->ndata;
break;
case LEX_ALWAYS_BACKLOG:
conf_always_backlog = t->ndata;
break;
case LEX_NO_BACKLOG:
conf_no_backlog = t->ndata;
break;
case LEX_BACKLOG_LINES:
conf_backlog_lines = t->ndata;
break;
case LEX_LOG_ROOT:
if (conf_log_root)
free(conf_log_root);
conf_log_root = t->pdata;
break;
case LEX_LOG_FORMAT:
if (conf_log_format)
free(conf_log_format);
conf_log_format = t->pdata;
break;
case LEX_LOG_LEVEL:
conf_log_level = t->ndata;
break;
case LEX_IP:
if (conf_ip)
free(conf_ip);
conf_ip = t->pdata;
break;
case LEX_PORT:
conf_port = t->ndata;
break;
case LEX_CSS:
conf_css = t->ndata;
break;
case LEX_PID_FILE:
if (conf_pid_file)
free(conf_pid_file);
conf_pid_file = t->pdata;
break;
case LEX_NETWORK:
add_network(t->pdata);
break;
case LEX_USER:
add_user(t->pdata);
break;
default:
fatal("Config error in base config (%d)", t->type);
break;
}
}
/*
check_networks(networkl);
check_clients(userl);
*/
if (!conf_biphome) {
char *home = getenv("HOME");
if (!home)
fatal("no $HOME !, do you live in a trailer ?");
conf_biphome = malloc(strlen(home) + strlen("/.bip") + 1);
strcpy(conf_biphome, home);
strcat(conf_biphome, "/.bip");
}
if (!conf_log_root) {
char *ap = "/logs";
conf_log_root = malloc(strlen(conf_biphome) + strlen(ap) + 1);
strcpy(conf_log_root, conf_biphome);
strcat(conf_log_root, ap);
mylog(LOG_INFO, "Default log root: %s", conf_log_root);
}
if (!conf_pid_file) {
char *pid = "/bip.pid";
conf_pid_file = malloc(strlen(conf_biphome) + strlen(pid) + 1);
strcpy(conf_pid_file, conf_biphome);
strcat(conf_pid_file, pid);
mylog(LOG_INFO, "Default pid file: %s", conf_pid_file);
}
#ifdef HAVE_LIBSSL
conf_ssl_certfile = NULL; /* Make into a config option */
if (!conf_ssl_certfile) {
char *home = getenv("HOME");
char *ap = "/.bip/bip.pem";
if (!home)
fatal("no $HOME !, do you live in a trailer ?");
conf_ssl_certfile = malloc(strlen(home) + strlen(ap) + 1);
strcpy(conf_ssl_certfile, home);
strcat(conf_ssl_certfile, ap);
mylog(LOG_INFO, "Default SSL certificate file: %s",
conf_ssl_certfile);
}
#endif
if (!conf_log_format)
conf_log_format = "%u/%n/%Y-%m/%c.%d.log";
return 1;
}
void print_link(struct link *l)
{
printf("\n");
}
void print_sumup(void)
{
hash_iterator_t it;
for (hash_it_init(&adm_users, &it); hash_it_item(&it);
hash_it_next(&it)) {
hash_t *u = hash_it_item(&it);
char *uk = hash_it_key(&it);
printf("user: %s", uk);
hash_iterator_t sit;
for (hash_it_init(u, &sit); hash_it_item(&sit);
hash_it_next(&sit)) {
struct link *l = hash_it_item(&sit);
char *ck = hash_it_key(&sit);
printf(" connection: %s", ck);
print_link(l);
}
}
}
void ircize(list_t *ll)
{
hash_iterator_t it;
for (hash_it_init(&conf_users, &it); hash_it_item(&it);
hash_it_next(&it)) {
struct c_user *u = hash_it_item(&it);
hash_t *adm_conn = hash_get(&adm_users, u->name);
if (!adm_conn) {
adm_conn = hash_new(HASH_NOCASE);
hash_insert(&adm_users, u->name, adm_conn);
mylog(LOG_DEBUG, "new user: \"%s\"", u->name);
} else {
mylog(LOG_DEBUG, "old user: \"%s\"", u->name);
}
/*
* A user has multiple connections.
* For each connections create a irc_client and a irc_server
* instance and register them in connection structure;
*/
list_iterator_t cit;
for (list_it_init(&u->connectionl, &cit); list_it_item(&cit);
list_it_next(&cit)) {
struct c_connection *c = list_it_item(&cit);
struct link *link;
int i;
if (!c->name)
fatal("no name for a connection");
link = hash_get(adm_conn, c->name);
if (!link) {
mylog(LOG_DEBUG, "new connection: \"%s\"",
c->name);
link = irc_link_new();
hash_insert(adm_conn, c->name, link);
link->name = strmaydup(c->name);
link->log = log_new(u->name, link->name);
list_iterator_t chit;
for (list_it_init(&c->channell, &chit);
list_it_item(&chit);
list_it_next(&chit)) {
struct c_channel *chan =
list_it_item(&chit);
struct chan_info *ci = chan_info_new();
ci->name = strdup(chan->name);
ci->key = strmaydup(chan->key);
hash_insert(&link->chan_infos,
ci->name, ci);
}
list_add_last(ll, link);
} else {
mylog(LOG_DEBUG, "old connection: \"%s\"",
c->name);
#define MAYFREE(a) do { \
if (a) { \
free(a); \
(a) = NULL; \
} \
} while(0);
MAYFREE(link->away_nick);
MAYFREE(link->login);
MAYFREE(link->password);
MAYFREE(link->user);
MAYFREE(link->real_name);
MAYFREE(link->s_password);
MAYFREE(link->connect_nick);
MAYFREE(link->vhost);
for (i = 0; i < link->serverc; i++)
server_free(link->serverv[i]);
free(link->serverv);
link->serverv = NULL;
link->serverc = 0;
}
link->follow_nick = c->follow_nick;
link->ignore_first_nick = c->ignore_first_nick;
link->on_connect_send = strmaydup(c->on_connect_send);
link->away_nick = strmaydup(c->away_nick);
link->login = strmaydup(c->login);
link->password = malloc(20);
memcpy(link->password, u->password, 20);
link->seed = u->seed;
list_iterator_t seit;
for (list_it_init(&c->network->serverl, &seit);
list_it_item(&seit);
list_it_next(&seit)) {
struct server *s = list_it_item(&seit);
link->serverv = realloc(link->serverv,
(link->serverc + 1)
* sizeof(struct server *));
link->serverv[link->serverc] = server_new();
/* XXX: wrong */
link->serverv[link->serverc]->host
= strmaydup(s->host);
link->serverv[link->serverc]->port = s->port;
link->serverc++;
}
link->user = strmaydup(c->user);
link->real_name = strmaydup(c->realname);
link->s_password = strmaydup(c->password);
link->connect_nick = strmaydup(c->nick);
link->vhost = strmaydup(c->vhost);
link->bind_port = c->source_port;
#ifdef HAVE_LIBSSL
link->s_ssl = c->network->ssl;
#endif
if (!link->user)
link->user = strmaydup("bip");
if (!link->connect_nick)
link->connect_nick = strmaydup("bip");
if (!link->real_name)
link->real_name = strmaydup("bip");
printf("clientc: %d\n", link->l_clientc);
}
}
print_sumup();
}
int main(int argc, char **argv)
{
FILE *conf = NULL;
char *confpath = NULL;
list_t *ll = list_new(NULL);
int ch;
int r,fd;
char buf[30];
conf_ip = strdup("0.0.0.0");
conf_port = 7778;
conf_css = 0;
hash_init(&adm_users, HASH_NOCASE);
hash_init(&conf_users, HASH_NOCASE);
hash_init(&conf_networks, HASH_NOCASE);
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, reload_config);
signal(SIGINT, bad_quit);
signal(SIGQUIT, bad_quit);
signal(SIGTERM, bad_quit);
conf_log_root = NULL;
conf_log_format = NULL;
conf_log_level = LOG_ERROR;
conf_no_backlog = 0;
conf_backlog_lines = 100;
conf_log_sync_interval = 5;
conf_daemonize = 1;
conf_global_log_file = stderr;
conf_pid_file = NULL;
while ((ch = getopt(argc, argv, "hnf:")) != -1) {
switch (ch) {
case 'f':
confpath = strdup(optarg);
break;
case 'n':
conf_daemonize = 0;
break;
default:
usage(argv[0]);
}
}
if (confpath) {
conf = fopen(confpath, "r");
if (!conf)
fatal("config file not found");
}
if (!conf) {
char *home;
home = getenv("HOME");
if (!home)
fatal("no home");
confpath = malloc(strlen(home) + 1 + strlen(S_CONF) + 1);
*confpath = 0;
strcat(confpath, home);
strcat(confpath, "/");
strcat(confpath, S_CONF);
conf = fopen(confpath, "r");
if (!conf)
fatal("%s config file not found", confpath);
}
r = fireup(conf);
fclose(conf);
if (!r) {
fatal("%s", conf_errstr);
exit(28);
}
fd = do_pid_stuff();
pid_t pid = 0;
if (conf_daemonize)
pid = daemonize();
else
pid = getpid();
snprintf(buf, 29, "%ld\n", (long unsigned int)pid);
write(fd, buf, strlen(buf));
close(fd);
connection_t *inc;
inc = listen_new(conf_ip, conf_port, conf_css);
if (!inc)
fatal("Could not create listening socket");
for (;;) {
if (r)
ircize(ll);
irc_main(inc, ll);
sighup = 0;
conf = fopen(confpath, "r");
if (!conf)
fatal("%s config file not found", confpath);
r = fireup(conf);
fclose(conf);
}
return 1;
}
void write_user_list(connection_t *c, char *dest)
{
hash_iterator_t it;
list_iterator_t lit;
WRITE_LINE2(c, P_IRCMASK, "PRIVMSG", dest, "bip user list:");
for (hash_it_init(&conf_users, &it); hash_it_item(&it);
hash_it_next(&it)) {
struct c_user *u = hash_it_item(&it);
WRITE_LINE2(c, P_IRCMASK, "PRIVMSG", dest, u->name);
for (list_it_init(&u->connectionl, &lit); list_it_item(&lit);
list_it_next(&lit)) {
struct c_connection *con = list_it_item(&lit);
WRITE_LINE2(c, P_IRCMASK, "PRIVMSG", dest, con->name);
}
}
WRITE_LINE2(c, P_IRCMASK, "PRIVMSG", dest,
"end of bip user list");
}
extern struct link_client *reloading_client;
void adm_bip(struct link_client *ic, struct line *line)
{
char *nick;
if (LINK(ic)->l_server)
nick = LINK(ic)->l_server->nick;
else
nick = LINK(ic)->prev_nick;
if (line->elemc < 2)
return;
if (strcasecmp(line->elemv[1], "RELOAD") == 0) {
reloading_client = ic;
sighup = 1;
} else if (strcasecmp(line->elemv[1], "LIST") == 0) {
write_user_list(CONN(ic), nick);
} else if (strcasecmp(line->elemv[1], "JUMP") == 0) {
if (LINK(ic)->l_server) {
WRITE_LINE1(CONN(LINK(ic)->l_server), NULL, "QUIT",
"jumpin' jumpin'");
connection_close(CONN(LINK(ic)->l_server));
}
} else if (strcasecmp(line->elemv[1], "HELP") == 0) {
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", nick,
"/BIP (RELOAD|LIST|JUMP|HELP)");
}
}

59
src/bip.h Normal file
View File

@ -0,0 +1,59 @@
/*
* $Id: bip.h,v 1.6 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef BIP_H
#define BIP_H
struct c_network
{
char *name;
#ifdef HAVE_LIBSSL
int ssl;
#endif
list_t serverl;
};
struct c_user
{
char *name;
unsigned char *password;
unsigned int seed;
list_t connectionl;
};
struct c_connection
{
char *name;
struct c_network *network;
char *realname, *user, *nick;
char *login; /* connection id for a user */
char *password; /* server pass */
char *vhost;
unsigned short source_port;
list_t channell;
int follow_nick;
int ignore_first_nick;
char *away_nick;
char *on_connect_send;
struct client *client;
};
struct c_channel
{
char *name;
char *key;
};
#endif

1753
src/conf.c Normal file

File diff suppressed because it is too large Load Diff

140
src/conf.h Normal file
View File

@ -0,0 +1,140 @@
/* A Bison parser, made by GNU Bison 1.875d. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 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 2, 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. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
LEX_IP = 258,
LEX_EQ = 259,
LEX_PORT = 260,
LEX_CSS = 261,
LEX_SEMICOLON = 262,
LEX_CONNECTION = 263,
LEX_NETWORK = 264,
LEX_LBRA = 265,
LEX_RBRA = 266,
LEX_USER = 267,
LEX_NAME = 268,
LEX_USERNAME = 269,
LEX_NICK = 270,
LEX_SERVER = 271,
LEX_PASSWORD = 272,
LEX_SRCIP = 273,
LEX_HOST = 274,
LEX_VHOST = 275,
LEX_SOURCE_PORT = 276,
LEX_NONE = 277,
LEX_COMMENT = 278,
LEX_BUNCH = 279,
LEX_REALNAME = 280,
LEX_SSL = 281,
LEX_CHANNEL = 282,
LEX_KEY = 283,
LEX_LOG_ROOT = 284,
LEX_LOG_FORMAT = 285,
LEX_LOG_LEVEL = 286,
LEX_BACKLOG_LINES = 287,
LEX_NO_BACKLOG = 288,
LEX_LOG_SYNC_INTERVAL = 289,
LEX_FOLLOW_NICK = 290,
LEX_ON_CONNECT_SEND = 291,
LEX_AWAY_NICK = 292,
LEX_PID_FILE = 293,
LEX_IGN_FIRST_NICK = 294,
LEX_ALWAYS_BACKLOG = 295,
LEX_LOGIN = 296,
LEX_BOOL = 297,
LEX_INT = 298,
LEX_STRING = 299
};
#endif
#define LEX_IP 258
#define LEX_EQ 259
#define LEX_PORT 260
#define LEX_CSS 261
#define LEX_SEMICOLON 262
#define LEX_CONNECTION 263
#define LEX_NETWORK 264
#define LEX_LBRA 265
#define LEX_RBRA 266
#define LEX_USER 267
#define LEX_NAME 268
#define LEX_USERNAME 269
#define LEX_NICK 270
#define LEX_SERVER 271
#define LEX_PASSWORD 272
#define LEX_SRCIP 273
#define LEX_HOST 274
#define LEX_VHOST 275
#define LEX_SOURCE_PORT 276
#define LEX_NONE 277
#define LEX_COMMENT 278
#define LEX_BUNCH 279
#define LEX_REALNAME 280
#define LEX_SSL 281
#define LEX_CHANNEL 282
#define LEX_KEY 283
#define LEX_LOG_ROOT 284
#define LEX_LOG_FORMAT 285
#define LEX_LOG_LEVEL 286
#define LEX_BACKLOG_LINES 287
#define LEX_NO_BACKLOG 288
#define LEX_LOG_SYNC_INTERVAL 289
#define LEX_FOLLOW_NICK 290
#define LEX_ON_CONNECT_SEND 291
#define LEX_AWAY_NICK 292
#define LEX_PID_FILE 293
#define LEX_IGN_FIRST_NICK 294
#define LEX_ALWAYS_BACKLOG 295
#define LEX_LOGIN 296
#define LEX_BOOL 297
#define LEX_INT 298
#define LEX_STRING 299
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 84 "conf.y"
typedef union YYSTYPE {
int number;
char *string;
void *list;
struct tuple *tuple;
} YYSTYPE;
/* Line 1285 of yacc.c. */
#line 132 "y.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;

190
src/conf.y Normal file
View File

@ -0,0 +1,190 @@
%{
/*
* $Id: conf.y,v 1.26 2005/04/17 15:20:32 nohar Exp $
*
* This file is part of the bip proproject
* Copyright (C) 2004 Arnaud Cornet
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include <stdlib.h>
#include "util.h"
#include "irc.h"
#include "tuple.h"
extern int yylex (void);
extern char *yytext;
extern int linec;
extern int conf_error;
#define ERRBUFSZ 80
extern char conf_errstr[ERRBUFSZ];
int yywrap()
{
return 1;
}
int yyerror()
{
snprintf(conf_errstr, ERRBUFSZ, "Parse error near %s, line %d\n",
yytext, linec + 1);
conf_errstr[ERRBUFSZ - 1] = 0;
conf_error = 1;
return 1;
}
int yydebug = 1;
list_t *root_list;
struct tuple *tuple_i_new(int type, int i)
{
struct tuple *t;
t = malloc(sizeof(struct tuple));
if (!t)
fatal("malloc");
t->type = type;
t->ndata = i;
t->tuple_type = TUPLE_INT;
return t;
}
struct tuple *tuple_p_new(int type, void *p)
{
struct tuple *t;
t = malloc(sizeof(struct tuple));
if (!t)
fatal("malloc");
t->type = type;
t->pdata = p;
return t;
}
struct tuple *tuple_s_new(int type, void *p)
{
struct tuple *t = tuple_p_new(type, p);
t->tuple_type = TUPLE_STR;
return t;
}
struct tuple *tuple_l_new(int type, void *p)
{
struct tuple *t = tuple_p_new(type, p);
t->tuple_type = TUPLE_LIST;
return t;
}
%}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_USERNAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_NO_BACKLOG LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_LOGIN
%union {
int number;
char *string;
void *list;
struct tuple *tuple;
}
%token <number> LEX_BOOL LEX_INT
%token <string> LEX_STRING
%type <list> commands server network channel user connection
%type <tuple> command ser_command net_command cha_command usr_command con_command
%%
commands:
{ $$ = root_list = list_new(NULL); }
| commands command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; }
;
command:
LEX_LOG_ROOT LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_LOG_ROOT, $3); }
| LEX_LOG_FORMAT LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_LOG_FORMAT,
$3); }
| LEX_LOG_LEVEL LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_LOG_LEVEL, $3); }
| LEX_IP LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_IP, $3); }
| LEX_PORT LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_PORT, $3); }
| LEX_CSS LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_CSS, $3); }
| LEX_BACKLOG_LINES LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_BACKLOG_LINES,
$3); }
| LEX_NO_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_NO_BACKLOG,
$3); }
| LEX_ALWAYS_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(
LEX_ALWAYS_BACKLOG, $3); }
| LEX_LOG_SYNC_INTERVAL LEX_EQ LEX_INT { $$ = tuple_i_new(
LEX_LOG_SYNC_INTERVAL, $3); }
| LEX_PID_FILE LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PID_FILE, $3); }
| LEX_NETWORK LEX_LBRA network LEX_RBRA { $$ = tuple_l_new(LEX_NETWORK,
$3); }
| LEX_USER LEX_LBRA user LEX_RBRA { $$ = tuple_l_new(LEX_USER, $3); }
network:
{ $$ = list_new(NULL); }
| network net_command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; }
net_command:
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
| LEX_SSL LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_SSL, $3); }
| LEX_SERVER LEX_LBRA server LEX_RBRA {
$$ = tuple_l_new(LEX_SERVER, $3); }
user:
{ $$ = list_new(NULL); }
| user usr_command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; }
usr_command:
LEX_NAME LEX_EQ LEX_STRING {
$$ = tuple_s_new(LEX_NAME, $3); }
| LEX_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PASSWORD,
$3); }
| LEX_CONNECTION LEX_LBRA connection LEX_RBRA {
$$ = tuple_l_new(LEX_CONNECTION, $3); }
connection:
{ $$ = list_new(NULL); }
| connection con_command LEX_SEMICOLON {
list_add_last($1, $2); $$ = $1; }
con_command:
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
| LEX_NETWORK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NETWORK,
$3); }
| LEX_LOGIN LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_LOGIN, $3); }
| LEX_NICK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NICK, $3); }
| LEX_USER LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_USER, $3); }
| LEX_REALNAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_REALNAME,
$3); }
| LEX_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PASSWORD,
$3); }
| LEX_VHOST LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_VHOST, $3); }
| LEX_SOURCE_PORT LEX_EQ LEX_INT {
$$ = tuple_i_new(LEX_SOURCE_PORT, $3); }
| LEX_SSL LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_SSL, $3); }
| LEX_AWAY_NICK LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_AWAY_NICK,
$3); }
| LEX_FOLLOW_NICK LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_FOLLOW_NICK, $3); }
| LEX_IGN_FIRST_NICK LEX_EQ LEX_BOOL { $$ = tuple_i_new(
LEX_IGN_FIRST_NICK, $3); }
| LEX_CHANNEL LEX_LBRA channel LEX_RBRA { $$ = tuple_l_new(
LEX_CHANNEL, $3); }
| LEX_ON_CONNECT_SEND LEX_EQ LEX_STRING { $$ = tuple_s_new(
LEX_ON_CONNECT_SEND, $3); }
channel:
{ $$ = list_new(NULL); }
| channel cha_command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; }
cha_command:
LEX_NAME LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_NAME, $3); }
| LEX_KEY LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_KEY, $3); }
server:
{ $$ = list_new(NULL); }
| server ser_command LEX_SEMICOLON { list_add_last($1, $2); $$ = $1; }
ser_command:
LEX_HOST LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_HOST, $3); }
| LEX_PORT LEX_EQ LEX_INT { $$ = tuple_i_new(LEX_PORT, $3); }

29
src/config.h.in Normal file
View File

@ -0,0 +1,29 @@
/* src/config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the `ssl' library (-lssl). */
#undef HAVE_LIBSSL
/* 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 version of this package. */
#undef PACKAGE_VERSION
/* Version number of package */
#undef VERSION
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER

1279
src/connection.c Normal file

File diff suppressed because it is too large Load Diff

97
src/connection.h Normal file
View File

@ -0,0 +1,97 @@
/*
* $Id: connection.h,v 1.40 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef CONNECTION_H
#define CONNECTION_H
#include "util.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#ifdef HAVE_LIBSSL
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/rand.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>
#endif
#define CONN_BUFFER_SIZE 2048
#define CONN_OK 1
#define CONN_TIMEOUT 2
#define CONN_ERROR 3
#define CONN_INPROGRESS 4
#define CONN_DISCONN 5
#define CONN_EXCEPT 6
#define CONN_NEW 7
#define CONN_NEED_SSLIZE 8
#define WRITE_OK 0
#define WRITE_ERROR -1
#define WRITE_KEEP -2
struct connecting_data;
typedef struct connection {
int anti_flood;
int ssl;
unsigned long lasttoken;
unsigned token;
int handle;
int connected;
int listening;
int client;
time_t connect_time;
time_t timeout;
char *incoming;
unsigned incoming_end;
list_t *outgoing;
list_t *incoming_lines;
void *user_data;
list_t *ip_list;
struct connecting_data *connecting_data;
#ifdef HAVE_LIBSSL
SSL *ssl_h;
X509 *cert;
#endif
} connection_t;
connection_t *connection_new(char *dsthostname, int dstport, char *srchostname,
int srcport, int ssl, int timeout);
connection_t *listen_new(char *hostname, int port, int ssl);
connection_t *accept_new(connection_t *cn);
void connection_free(connection_t *cn);
void connection_close(connection_t *cn);
void write_line(connection_t *cn, char *line);
void write_line_fast(connection_t *cn, char *line);
list_t *read_lines(connection_t *cn, int *error);
list_t *wait_event(list_t *cn_list, int *msec);
int cn_is_connected(connection_t *cn);
int cn_is_listening(connection_t *cn);
#endif

37
src/genpwent.c Normal file
View File

@ -0,0 +1,37 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
#include "md5.h"
int conf_log_level;
FILE *conf_global_log_file;
int main(int argc, char **argv)
{
int i;
char *ret;
char str[256];
unsigned char *md5;
unsigned int seed;
srand(time(NULL));
printf("Enter password:\n");
ret = fgets(str, 256, stdin);
srand(time(NULL));
if (!ret)
return 1;
for (i = 0; i < 256 && str[i] != '\n'; i++)
;
if (i >= 256)
return 2;
str[i] = 0;
seed = rand();
md5 = chash_double(str, seed);
for (i = 0; i < 20; i++)
printf("%02x", md5[i]);
printf("\n");
free(md5);
return 0;
}

2067
src/irc.c Normal file

File diff suppressed because it is too large Load Diff

180
src/irc.h Normal file
View File

@ -0,0 +1,180 @@
/*
* $Id: irc.h,v 1.43 2005/04/21 06:58:50 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef IRC_H
#define IRC_H
#include "connection.h"
#include "line.h"
#define P_SERV "bip.bip.bip"
#define S_PING "BIPPING"
#define P_IRCMASK "-bip!bip@bip.bip.bip"
struct server {
char *host;
unsigned short port;
};
#define server_new() calloc(sizeof(struct server), 1)
#define NICKOP 1
#define NICKVOICED 2
struct nick {
char *name;
int ovmask;
};
struct channel {
char *name;
char *mode;
char *key;
char *topic;
int limit;
char type;
char *creator;
char *create_ts;
hash_t nicks;
int running_names;
};
#define IRC_TYPE_CLIENT (0)
#define IRC_TYPE_SERVER (1)
#define IRC_TYPE_LOGING_CLIENT (2)
struct link {
char *name; /* id */
/** link live data **/
struct link_server *l_server;
int l_clientc;
struct link_client **l_clientv;
struct log *log;
/* server related live stuff */
int s_state;
char *prev_nick;
list_t init_strings;
/* connection state (reconnecting, was_connected ...) */
int recon_timer;
time_t last_reconnection;
/** link options */
int follow_nick;
int ignore_first_nick;
char *on_connect_send;
char *away_nick;
hash_t chan_infos; /* channels we want */
/** client connection static data **/
char *login;
unsigned char *password;
unsigned int seed;
/** server connection static data **/
/* server list */
int serverc;
struct server **serverv;
int cur_server;
char *user;
char *real_name;
char *s_password;
char *connect_nick;
/* socket creation info */
char *vhost;
int bind_port;
int s_ssl;
};
struct link_connection {
int type;
connection_t *conn;
struct link *link;
};
struct link_any {
struct link_connection _link_c;
};
#define LINK(s) ((s)->_link_c.link)
#define CONN(s) ((s)->_link_c.conn)
#define TYPE(s) ((s)->_link_c.type)
#define IRCC_NONE (0)
#define IRCC_NICK (1)
#define IRCC_USER (1<<1)
#define IRCC_PASS (1<<2)
#define IRCC_READY (IRCC_NICK|IRCC_PASS|IRCC_USER)
struct link_client {
struct link_connection _link_c;
char *init_nick;
char *init_pass;
char *init_user;
char *init_real_name;
int state;
int logging_timer;
};
#define link_client_new() calloc(sizeof(struct link_client), 1)
#define IRCS_NONE (0)
#define IRCS_CONNECTING (1)
#define IRCS_CONNECTED (2)
#define IRCS_WAS_CONNECTED (3)
#define IRCS_RECONNECTING (4)
struct log;
struct chan_info {
char *name;
char *key;
};
#define chan_info_new() calloc(sizeof(struct chan_info), 1)
struct link_server {
struct link_connection _link_c;
char *nick;
char *irc_mask;
/* channels we are in */
hash_t channels;
char *user_mode;
int user_mode_len;
/* init stuff */
int lag;
int laginit_ts;
int lagtest_timeout;
};
struct link_server *irc_server_new(struct link *link, connection_t *conn);
void irc_server_free(struct link_server *is);
struct client *client_new();
void irc_main(connection_t *inc, list_t *clientl);
int ischannel(char p);
void irc_client_close(struct link_client *);
void irc_client_free(struct link_client *);
struct link *irc_link_new();
#endif

2065
src/lex.c Normal file

File diff suppressed because it is too large Load Diff

95
src/lex.l Normal file
View File

@ -0,0 +1,95 @@
%{
/*
* $Id: lex.l,v 1.23 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip proproject
* Copyright (C) 2004 Arnaud Cornet
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include "conf.h"
int linec = 0;
#define YY_NO_UNPUT
#include "util.h"
extern int conf_error;
extern list_t *root_list;
void yyparse(void);
void free_conf(list_t*);
list_t *parse_conf(FILE *file)
{
YY_BUFFER_STATE in = yy_create_buffer(file, YY_BUF_SIZE);
yy_switch_to_buffer(in);
yyparse();
if (conf_error) {
free_conf(root_list);
return NULL;
}
return root_list;
}
%}
%%
(" "|\t)+
\n { linec++; }
"#"[^\n]*$
[0-9]+ {
yylval.number = atoi(yytext);
return LEX_INT;
}
("true"|"false") {
yylval.number = strcmp(yytext, "true")
== 0 ? 1 : 0;
return LEX_BOOL;
}
"ip" { return LEX_IP; }
"port" { return LEX_PORT; }
"client_side_ssl" { return LEX_CSS; }
"server" { return LEX_SERVER; }
"network" { return LEX_NETWORK; }
"host" { return LEX_HOST; }
"name" { return LEX_NAME; }
"username" { return LEX_USERNAME; }
"user" { return LEX_USER; }
"login" { return LEX_LOGIN; }
"connection" { return LEX_CONNECTION; }
"nick" { return LEX_NICK; }
"realname" { return LEX_REALNAME; }
"source_port" { return LEX_SOURCE_PORT; }
"vhost" { return LEX_VHOST; }
"password" { return LEX_PASSWORD; }
"ssl" { return LEX_SSL; }
"key" { return LEX_KEY; }
"channel" { return LEX_CHANNEL; }
"log_level" { return LEX_LOG_LEVEL; }
"log_root" { return LEX_LOG_ROOT; }
"log_format" { return LEX_LOG_FORMAT; }
"backlog_lines" { return LEX_BACKLOG_LINES; }
"no_backlog" { return LEX_NO_BACKLOG; }
"always_backlog" { return LEX_ALWAYS_BACKLOG; }
"log_sync_interval" { return LEX_LOG_SYNC_INTERVAL; }
"follow_nick" { return LEX_FOLLOW_NICK; }
"ignore_first_nick" { return LEX_IGN_FIRST_NICK; }
"away_nick" { return LEX_AWAY_NICK; }
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
"pid_file" { return LEX_PID_FILE; }
\"[^"]*\" {
size_t len = strlen(yytext) - 2;
yylval.string = malloc(len + 1);
if (!yylval.string)
fatal("malloc");
memcpy(yylval.string, yytext + 1, len);
yylval.string[len] = 0;
return LEX_STRING;
}
"=" { return LEX_EQ; }
"{" { return LEX_LBRA; }
"}" { return LEX_RBRA; }
";" { return LEX_SEMICOLON; }
. { printf("Parse error line %d, unknown character '%s'\n", linec + 1, yytext);
return LEX_BUNCH; }
%%

174
src/line.c Normal file
View File

@ -0,0 +1,174 @@
#include "config.h"
#include "line.h"
void irc_line_init(struct line *l)
{
memset(l, 0, sizeof(struct line));
}
struct line *irc_line_new()
{
struct line *l;
l = malloc(sizeof(struct line));
if (!l)
fatal("malloc");
irc_line_init(l);
return l;
}
void irc_line_clear(struct line *l)
{
unsigned i;
for (i = 0; i < l->elemc; i++)
free(l->elemv[i]);
free(l->elemv);
if (l->origin)
free(l->origin);
memset(l, 0, sizeof(struct line));
}
void irc_line_write(struct line *l, connection_t *c)
{
char *bytes = irc_line_to_string(l);
write_line(c, bytes);
free(bytes);
}
struct line *irc_line_dup(struct line *line)
{
unsigned i;
struct line *nl = irc_line_new();
nl->origin = line->origin ? strdup(line->origin) : NULL;
nl->elemc = line->elemc;
nl->elemv = malloc(sizeof(char *) * line->elemc);
for (i = 0; i < line->elemc; i++)
nl->elemv[i] = strdup(line->elemv[i]);
nl->colon = line->colon;
return nl;
}
void _irc_line_append(struct line *l, char *s)
{
l->elemc++;
l->elemv = realloc(l->elemv, l->elemc * sizeof(char *));
if (!l)
fatal("realloc");
l->elemv[l->elemc - 1] = s;
}
void irc_line_append(struct line *l, char *s)
{
_irc_line_append(l, strdup(s));
}
char *irc_line_to_string(struct line *l)
{
size_t len = 0;
unsigned i;
char *ret;
if (l->origin)
len = strlen(l->origin) + 2;
for (i = 0; i < l->elemc; i++)
len += strlen(l->elemv[i]) + 1;
len += 1; /* remove one trailing space and add \r\n */
len++; /* last args ":" */
ret = malloc(len + 1);
ret[0] = 0;
if (l->origin) {
strcat(ret, ":");
strcat(ret, l->origin);
strcat(ret, " ");
}
for (i = 0; i < l->elemc - 1; i++) {
strcat(ret, l->elemv[i]);
strcat(ret, " ");
}
if (strchr(l->elemv[i], ' ') || l->colon)
strcat(ret, ":");
strcat(ret, l->elemv[i]);
strcat(ret, "\r\n");
return ret;
}
/*
* takes a null terminated string as input w/o \r\n
*/
struct line *irc_line(char *str)
{
struct line *line;
char *space;
size_t len;
int curelem = 0;
line = calloc(sizeof(struct line), 1);
if (!line)
fatal("calloc");
if (str[0] == ':') {
space = str + 1;
while (*space && *space != ' ')
space++;
if (!*space)
return NULL;
len = space - str - 1; /* leading ':' */
line->origin = malloc(len + 1);
if (!line->origin)
fatal("malloc");
memcpy(line->origin, str + 1, len);
line->origin[len] = 0;
str = space;
}
while (*str == ' ')
str++;
while (*str) {
char *tmp;
line->elemc++;
line->elemv = realloc(line->elemv,
line->elemc * sizeof(char *));
if (!line->elemv)
fatal("realloc");
space = str;
if (*space == ':') {
line->colon = 1;
str++;
while (*space)
space++;
} else {
while (*space && *space != ' ')
space++;
}
len = space - str;
tmp = line->elemv[curelem] = malloc(len + 1);
if (!tmp)
fatal("malloc");
memcpy(tmp, str, len);
tmp[len] = 0;
if (curelem == 0)
strucase(line->elemv[curelem]);
curelem++;
str = space;
while (*str == ' ')
str++;
}
return line;
}
void irc_line_free(struct line *l)
{
unsigned i;
for (i = 0; i < l->elemc; i++)
free(l->elemv[i]);
free(l->elemv);
if (l->origin)
free(l->origin);
free(l);
}

74
src/line.h Normal file
View File

@ -0,0 +1,74 @@
#ifndef IRC_LINE_H
#define IRC_LINE_H
#include "connection.h"
#define WRITE_LINE1(con, org, com, a) \
do { \
struct line l; \
irc_line_init(&l); \
l.origin = org; \
_irc_line_append(&l, com); \
_irc_line_append(&l, a); \
irc_line_write(&l, con); \
free(l.elemv); \
} while(0)
#define WRITE_LINE2(con, org, com, a1, a2) \
do { \
struct line l; \
irc_line_init(&l); \
l.origin = org; \
_irc_line_append(&l, com); \
_irc_line_append(&l, a1); \
_irc_line_append(&l, a2); \
irc_line_write(&l, con); \
free(l.elemv); \
} while(0)
#define WRITE_LINE3(con, org, com, a1, a2, a3) \
do { \
struct line l; \
irc_line_init(&l); \
l.origin = org; \
_irc_line_append(&l, com); \
_irc_line_append(&l, a1); \
_irc_line_append(&l, a2); \
_irc_line_append(&l, a3); \
irc_line_write(&l, con); \
free(l.elemv); \
} while(0)
#define WRITE_LINE4(con, org, com, a1, a2, a3, a4) \
do { \
struct line l; \
irc_line_init(&l); \
l.origin = org; \
_irc_line_append(&l, com); \
_irc_line_append(&l, a1); \
_irc_line_append(&l, a2); \
_irc_line_append(&l, a3); \
_irc_line_append(&l, a4); \
irc_line_write(&l, con); \
free(l.elemv); \
} while(0)
struct line {
char *origin;
unsigned int elemc;
char **elemv;
int colon;
};
void irc_line_init(struct line *l);
struct line *irc_line_new();
void irc_line_clear(struct line *l);
void irc_line_write(struct line *l, connection_t *c);
void irc_line_append(struct line *l, char *s);
struct line *irc_line(char *str);
char *irc_line_to_string(struct line *l);
void irc_line_free(struct line *l);
struct line *irc_line_dup(struct line *line);
void _irc_line_append(struct line *l, char *s);
#endif

870
src/log.c Normal file
View File

@ -0,0 +1,870 @@
/*
* $Id: log.c,v 1.56 2005/04/21 06:58:50 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include "config.h"
#include "log.h"
#include "irc.h"
#include "util.h"
extern int errno;
extern int log_level;
extern char *conf_log_root;
extern char *conf_log_format;
/* conf_always_backlog => conf_backlog_lines != 0 */
extern int conf_no_backlog;
extern int conf_backlog_lines;
extern int conf_always_backlog;
int log_set_backlog_offset(log_t *logdata, char *dest);
static int _log_write(log_t *logdata, logfilegroup_t *lf, char *str);
void logfile_free(logfile_t *lf);
/* TODO: change fatal("out of memory") to cleanup & return NULL */
int check_dir(char *filename)
{
int err;
struct stat statbuf;
err = stat(filename, &statbuf);
if (err && errno == ENOENT) {
err = mkdir(filename, 0750);
if (err) {
mylog(LOG_ERROR, "mkdir(%s) %s", filename,
strerror(errno));
return 1;
}
} else if (err) {
mylog(LOG_ERROR, "stat(%s) %s", filename,
strerror(errno));
return 1;
} else if (!(statbuf.st_mode & S_IFDIR)) {
mylog(LOG_ERROR, "%s is not a directory", filename);
return 1;
}
return 0;
}
int check_dir_r(char *dirname)
{
int pos, count = 0;
char *dir, *tmp;
int len = strlen(dirname);
mylog(LOG_DEBUGVERB, "Recursive check of %s engaged", dirname);
tmp = dirname;
dir = (char *)malloc(sizeof(char) * (len + 1));
while (*tmp) {
int slash_ok = 1;
while (*tmp == '/') {
if (slash_ok) {
strncpy(dir + count, "/", 1);
count++;
slash_ok = 0;
}
tmp++;
}
pos = strcspn(tmp, "/");
strncpy(dir + count, tmp, pos);
tmp += pos;
count += pos;
*(dir + count) = '\0';
mylog(LOG_DEBUGVERB,"check_dir_r: %s", dir);
if (check_dir(dir)) {
free(dir);
return 1;
}
}
free(dir);
return 0;
}
void strtolower(char *str)
{
char *c;
for (c = str; *c != '\0'; c++)
*c = tolower(*c);
}
/*
* Replace all occurences of var in str by value.
* This function modifies its first argument!
* Truncate the string after max characters.
*/
void replace_var(char *str, char *var, char *value, unsigned int max)
{
char *pos;
unsigned int lenvar = strlen(var);
unsigned int lenval = strlen(value);
while((pos = strstr(str, var))) {
/* Make room */
if (strlen(str) + (lenval - lenvar) >= max)
return;
memmove(pos + lenval, pos + lenvar,
(strlen(pos + lenvar) + 1)*sizeof(char));
memcpy(pos, value, lenval*sizeof(char));
}
}
char *log_build_filename(log_t *logdata, char *destination)
{
char *logfile, year[5], day[3], month[3], *tmp, *logdir;
int log_format_len;
struct tm *now;
time_t s;
char *dest = strdup(destination);
strtolower(dest);
log_format_len = strlen(conf_log_format);
logfile = (char*)malloc((MAX_PATH_LEN + 1)*sizeof(char));
if (!logfile)
fatal("out of memory");
time(&s);
now = localtime(&s);
snprintf(year, 5, "%04d", now->tm_year + 1900);
snprintf(day, 3, "%02d", now->tm_mday);
snprintf(month, 3, "%02d", now->tm_mon + 1);
snprintf(logfile, MAX_PATH_LEN, "%s/%s", conf_log_root,
conf_log_format);
replace_var(logfile, "%u", logdata->user, MAX_PATH_LEN);
replace_var(logfile, "%n", logdata->network, MAX_PATH_LEN);
replace_var(logfile, "%c", dest, MAX_PATH_LEN);
replace_var(logfile, "%Y", year, MAX_PATH_LEN);
replace_var(logfile, "%d", day, MAX_PATH_LEN);
replace_var(logfile, "%m", month, MAX_PATH_LEN);
logdir = strdup(logfile);
if (!logdir)
fatal("out of memory");
/* strrchr works on bytes, not on char (if sizeof(char) != 1) */
tmp = strrchr(logdir, '/');
if (tmp)
*tmp = '\0';
free(dest);
if (check_dir_r(logdir)) {
free(logfile);
free(logdir);
return NULL;
}
free(logdir);
return logfile;
}
void log_updatelast(logfile_t *lf)
{
time_t t;
time(&t);
localtime_r(&t, &lf->last_log);
}
void log_reinit(logfilegroup_t *lfg)
{
mylog(LOG_ERROR, "%s is inconsistant, droping backlog info\n",
lfg->name);
logfile_t *olf;
while ((olf = list_get_first(&lfg->file_group)) !=
list_get_last(&lfg->file_group)) {
logfile_free(olf);
list_remove_first(&lfg->file_group);
}
if (!olf->file)
fatal("internal, (NULL logfile)");
fseek(olf->file, 0, SEEK_END);
olf->len = ftell(olf->file);
olf->backlog_offset = olf->len;
}
static int log_add_file(log_t *logdata, char *destination, char *filename)
{
FILE *f;
logfile_t *lf;
logfilegroup_t *lfg;
f = fopen(filename, "a+");
if (!f) {
mylog(LOG_ERROR, "fopen(%s) %s", filename, strerror(errno));
return 0;
}
lf = malloc(sizeof(logfile_t));
if (!lf)
fatal("out of memory");
lf->file = f;
lf->filename = strdup(filename);
if (!lf->filename)
fatal("out of memory");
fseek(lf->file, 0, SEEK_END);
if (ftell(f) < 0)
fatal("ftell");
lf->len = ftell(f);
lf->backlog_offset = lf->len;
log_updatelast(lf);
lfg = hash_get(&logdata->logfgs, destination);
if (!lfg) {
lfg = malloc(sizeof(logfilegroup_t));
if (!lfg)
fatal("out of memory");
list_init(&lfg->file_group, NULL);
lfg->name = strdup(destination);
if (!lfg->name)
fatal("out of memory");
lfg->skip_advance = 0;
hash_insert(&logdata->logfgs, destination, lfg);
}
list_add_last(&lfg->file_group, lf);
return 1;
}
/*
* XXX: must not free file_group
*/
void logfile_free(logfile_t *lf)
{
if (!lf)
return;
if (lf->file)
fclose(lf->file);
if (lf->filename)
free(lf->filename);
free(lf);
}
logfilegroup_t *log_find_file(log_t *logdata, char *destination)
{
logfile_t *lf;
logfilegroup_t *lfg;
char *filename;
time_t t;
struct tm *ltime;
if (!ischannel(*destination))
destination = "privates";
lfg = hash_get(&logdata->logfgs, destination);
if (!lfg) {
filename = log_build_filename(logdata, destination);
if (!filename)
return NULL;
mylog(LOG_DEBUG, "Creating new logfile for %s: %s", destination,
filename);
if (!log_add_file(logdata, destination, filename)) {
free(filename);
return NULL;
}
lfg = hash_get(&logdata->logfgs, destination);
if (!lfg)
fatal("internal log_find_file");
free(filename);
return lfg;
}
/* This is reached if lfg already exists */
time(&t);
ltime = localtime(&t);
lf = list_get_last(&lfg->file_group);
if (ltime->tm_mday != lf->last_log.tm_mday) {
logfile_t *oldlf;
/* day changed, we might want to rotate logfile */
filename = log_build_filename(logdata, destination);
if (!filename)
return NULL;
if (strcmp(lf->filename, filename) == 0) {
/* finally we don't */
free(filename);
return lfg;
}
/* we do want do rotate logfiles */
mylog(LOG_DEBUG, "Rotating logfile for %s from", destination);
oldlf = list_get_last(&lfg->file_group);
if (!log_add_file(logdata, destination, filename)) {
free(filename);
return NULL;
}
free(filename);
if (conf_no_backlog) {
/* remove oldlf from file_group */
if (list_remove_first(&lfg->file_group) != oldlf)
fatal("internal log_find_file 2");
logfile_free(oldlf);
if (list_get_first(&lfg->file_group)
!= list_get_last(&lfg->file_group))
fatal("internal log_find_file 3");
} else {
fclose(oldlf->file);
oldlf->file = NULL;
}
}
return lfg;
}
/*
* Da log routines
*/
void log_join(log_t *logdata, char *ircmask, char *channel)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s has joined %s\n", timestamp(), ircmask,
channel);
log_write(logdata, channel, logdata->buffer);
}
void log_part(log_t *logdata, char *ircmask, char *channel,
char *message)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s has left %s [%s]\n", timestamp(), ircmask,
channel, message);
log_write(logdata, channel, logdata->buffer);
}
void log_kick(log_t *logdata, char *ircmask, char *channel,
char *who, char *message)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s has been kicked by %s [%s]\n", timestamp(),
who, ircmask, message);
log_write(logdata, channel, logdata->buffer);
}
void log_quit(log_t *logdata, char *ircmask, char *channel, char *message)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s has quit [%s]\n", timestamp(), ircmask,
message);
log_write(logdata, channel, logdata->buffer);
}
void log_nick(log_t *logdata, char *ircmask, char *channel, char *newnick)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s is now known as %s\n",
timestamp(), ircmask, newnick);
log_write(logdata, channel, logdata->buffer);
}
void log_privmsg(log_t *logdata, char *ircmask, char *destination,
char *message)
{
if (!ircmask)
ircmask = "Server message";
if (*message == '\001' && *(message + strlen(message) - 1) == '\001') {
char *msg = strdup(message);
if (!msg)
fatal("out of memory");
if (strncmp(msg, "\001ACTION ", 8) != 0) {
free(msg);
return;
}
*(msg + strlen(msg) - 1) = '\0';
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s * %s %s\n",
timestamp(), ircmask, msg + 8);
free(msg);
} else {
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s %s: %s\n",
timestamp(), ircmask, message);
}
log_write(logdata, destination, logdata->buffer);
}
void log_notice(log_t *logdata, char *ircmask, char *channel,
char *message)
{
if (!ircmask)
ircmask = "Server message";
if (*message == '\001' && *(message + strlen(message) - 1) == '\001')
return;
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s %s: %s %s\n", timestamp(),
ircmask, channel, message);
log_write(logdata, channel, logdata->buffer);
}
void log_topic(log_t *logdata, char *ircmask, char *channel, char *message)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- %s changed topic of %s to: %s\n", timestamp(),
ircmask, channel, message);
log_write(logdata, channel, logdata->buffer);
}
void log_init_topic(log_t *logdata, char *channel, char *message)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- Topic for %s: %s\n", timestamp(), channel,
message);
log_write(logdata, channel, logdata->buffer);
}
void log_init_topic_time(log_t *logdata, char *channel, char *who, char *when)
{
struct tm *time;
char *timestr;
time_t seconds;
seconds = atoi(when);
time = localtime(&seconds);
timestr = (char*)malloc(sizeof(char) * (50 + 1));
timestr[0] = '\0';
if (time)
strftime(timestr, 50, "%A %d %B %Y, %H:%M:%S", time);
timestr[50] = '\0';
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- Topic set by %s [%s]\n", timestamp(), who,
timestr);
free(timestr);
log_write(logdata, channel, logdata->buffer);
}
void log_mode(log_t *logdata, char *ircmask, char *channel, char *modes,
char **modargv, unsigned modargc)
{
unsigned i;
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s -!- mode/%s [%s ",
timestamp(), channel, modes);
log_write(logdata, channel, logdata->buffer);
for (i = 0; i < modargc; i++) {
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s%c", modargv[i],
i == modargc-1 ? ']' : ' ');
log_write(logdata, channel, logdata->buffer);
}
snprintf(logdata->buffer, LOGLINE_MAXLEN, " by %s\n", ircmask);
log_write(logdata, channel, logdata->buffer);
}
void log_disconnected(log_t *logdata)
{
logfilegroup_t *lfg;
hash_iterator_t hi;
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s -!- Disconnected"
" from server...\n", timestamp());
for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
lfg = hash_it_item(&hi);
_log_write(logdata, lfg, logdata->buffer);
}
}
void log_ping_timeout(log_t *logdata)
{
snprintf(logdata->buffer, LOGLINE_MAXLEN,
"%s -!- Ping timeout with server...\n", timestamp());
log_write(logdata, "privates", logdata->buffer);
log_disconnected(logdata);
}
void log_connected(log_t *logdata)
{
logfilegroup_t *lfg;
hash_iterator_t hi;
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s -!- Connected to"
" server...\n", timestamp());
for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
lfg = hash_it_item(&hi);
_log_write(logdata, lfg, logdata->buffer);
}
}
void log_client_disconnected(log_t *logdata)
{
mylog(LOG_DEBUG, "A client disconnected");
}
void log_client_none_connected(log_t *logdata)
{
logfilegroup_t *lfg;
logfile_t *lf;
hash_iterator_t hi;
logdata->connected = 0;
if (conf_always_backlog)
return;
for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
lfg = hash_it_item(&hi);
lf = list_get_last(&lfg->file_group);
if (lf != list_get_first(&lfg->file_group))
fatal("internal log_client_none_connected");
lf->backlog_offset = lf->len;
lfg->skip_advance = 0;
}
}
void log_client_connected(log_t *logdata)
{
mylog(LOG_DEBUG, "A client connected");
logdata->connected = 1;
}
void log_advance_backlogs(log_t* ld, logfilegroup_t *lfg)
{
int c;
if (conf_no_backlog || conf_backlog_lines == 0)
return;
if (lfg->skip_advance < conf_backlog_lines) {
lfg->skip_advance++;
return;
}
logfile_t *lf;
while ((lf = list_get_first(&lfg->file_group))) {
if (!lf->file) {
lf->file = fopen(lf->filename, "r");
if (!lf->file) {
mylog(LOG_ERROR, "Can't open %s for reading",
lf->filename);
log_reinit(lfg);
return;
}
}
if (fseek(lf->file, lf->backlog_offset, SEEK_SET)) {
log_reinit(lfg);
return;
}
while ((c = fgetc(lf->file)) != EOF) {
lf->backlog_offset++;
if (c == '\n')
return;
}
if (lf == list_get_last(&lfg->file_group))
return;
fclose(lf->file);
lf->file = NULL;
list_remove_first(&lfg->file_group);
logfile_free(lf);
}
}
int log_has_backlog(log_t *logdata, char *destination)
{
logfilegroup_t *lfg = hash_get(&logdata->logfgs, destination);
if (!lfg)
return 0;
logfile_t *lf;
lf = list_get_first(&lfg->file_group);
if (lf != list_get_last(&lfg->file_group))
return 1;
return lf->backlog_offset != lf->len;
}
#define BOLD_CHAR 0x02
#define LAMESTRING "!bip@bip.bip.bip PRIVMSG "
static char *log_beautify(char *buf, char *dest, int *raw)
{
int action = 0;
char *p;
/*
* so = start, lo = length
* ts = timestamp, n = sender nick, m = message or action
*/
char *sots, *son, *som;
size_t lots, lon, lom;
char *ret;
*raw = 0;
if (!buf)
return NULL;
p = strchr(buf, ' ');
if (!p || !p[0] || !p[1])
return buf;
p++;
sots = p;
p = strchr(p, ' ');
if (!p || !p[0] || !p[1])
return buf;
lots = p - sots;
p++;
if (strncmp(p, "-!-", 3) == 0)
return buf;
if (*p == '*') {
action = 1;
if (!p[1] || !p[2])
return buf;
p += 2;
}
son = p;
/* 'date time blawithnoexcl bla bla ! bla' --> ? */
p = strchr(p, '!');
if (!p || !p[0] || !p[1])
return buf;
lon = p - son;
p = strchr(p, ' ');
if (!p || !p[0] || !p[1])
return buf;
p++;
som = p;
lom = strlen(p);
*raw = 1;
p = ret = (char *)malloc(
1 + lon + strlen(LAMESTRING) + strlen(dest) + 2 + lots +
1 + lom + 3 + action * (2 + strlen("ACTION")));
if (!p)
fatal("out of memory");
*p++ = ':';
memcpy(p, son, lon);
p += lon;
strcpy(p, LAMESTRING);
p += strlen(LAMESTRING);
strcpy(p, dest);
p += strlen(dest);
strcpy(p, " :");
p += 2;
if (action) {
*p++ = 1;
memcpy(p, "ACTION", strlen("ACTION"));
p += strlen("ACTION");
}
memcpy(p, sots, lots);
p+=lots;
*p++ = ' ';
memcpy(p, som, lom);
p += lom;
if (action)
*p++ = 1;
*p++ = '\r';
*p++ = '\n';
*p = 0;
free(buf);
return ret;
}
char *log_backread(log_t *logdata, char *destination, int *raw)
{
char *buf;
size_t pos = 0;
logfile_t *lf;
logfilegroup_t *lfg;
int c;
if (!conf_always_backlog && logdata->connected)
return NULL;
buf = (char *)malloc((LOGLINE_MAXLEN + 1) * sizeof(char));
lfg = hash_get(&logdata->logfgs, destination);
if (!lfg)
return NULL;
if (!logdata->backlogging) {
list_it_init(&lfg->file_group, &logdata->file_it);
logdata->backlogging = 1;
}
next_file:
/* check the files containing data to backlog */
lf = list_it_item(&logdata->file_it);
if (lf != list_get_last(&lfg->file_group)) {
/* if the file is not the current open for logging
* (it is an old file that has been rotated)
* open if necessary, backlog line per line, and close */
if (!lf->file) {
lf->file = fopen(lf->filename, "r");
if (!lf->file) {
mylog(LOG_ERROR, "Can't open %s for reading",
lf->filename);
log_reinit(lfg);
return strdup("Error reading logfile");
}
if (fseek(lf->file, lf->backlog_offset, SEEK_SET)) {
log_reinit(lfg);
return strdup("Error reading in logfile");
}
}
for(;;) {
c = fgetc(lf->file);
if (!conf_always_backlog)
lf->backlog_offset++;
if (c == EOF || c == '\n'
|| pos + 1 >= LOGLINE_MAXLEN) {
if (c == EOF) {
list_it_next(&logdata->file_it);
if (!conf_always_backlog) {
list_remove_first(
&lfg->file_group);
logfile_free(lf);
} else {
fclose(lf->file);
lf->file = NULL;
}
pos = 0;
goto next_file;
}
buf[pos] = 0;
return log_beautify(buf, destination, raw);
}
buf[pos++] = c;
}
}
/* the logfile to read is the one open for writing */
if (!logdata->lastfile_seeked) {
if (fseek(lf->file, lf->backlog_offset, SEEK_SET)) {
log_reinit(lfg);
return strdup("Error reading in logfile");
}
logdata->lastfile_seeked = 1;
}
c = fgetc(lf->file);
if (c == EOF) {
logdata->lastfile_seeked = 0;
logdata->backlogging = 0;
free(buf);
return NULL;
}
if (!conf_always_backlog)
lf->backlog_offset++;
if (c != '\n')
buf[pos++] = c;
for(;;) {
c = fgetc(lf->file);
if (!conf_always_backlog)
lf->backlog_offset++;
if (c == EOF || c == '\n' || pos + 1 >= LOGLINE_MAXLEN) {
if (conf_always_backlog && c == EOF)
lf->backlog_offset--;
buf[pos] = 0;
return log_beautify(buf, destination, raw);
}
buf[pos++] = c;
}
/* unreachable */
fatal("internal error 12");
return NULL;
}
static int _log_write(log_t *logdata, logfilegroup_t *lfg, char *str)
{
size_t nbwrite;
size_t len;
logfile_t *lf = list_get_last(&lfg->file_group);
len = strlen(str);
nbwrite = fwrite(str, sizeof(char), len, lf->file);
log_updatelast(lf);
if (nbwrite != len)
mylog(LOG_ERROR, "Error writing to %s logfile", lf->filename);
lf->len += nbwrite;
if (!logdata->connected || conf_always_backlog)
log_advance_backlogs(logdata, lfg);
return nbwrite;
}
void log_write(log_t *logdata, char *destination, char *str)
{
logfilegroup_t *lfg = log_find_file(logdata, destination);
if (!lfg) {
mylog(LOG_ERROR, "Unable to find/create logfile for '%s'",
destination);
return;
}
_log_write(logdata, lfg, str);
}
static list_t *log_all_logs = NULL;
void log_flush_all(void)
{
list_iterator_t li;
if (!log_all_logs)
return;
for (list_it_init(log_all_logs, &li); list_it_item(&li);
list_it_next(&li)) {
log_t *log = list_it_item(&li);
hash_iterator_t hi;
for (hash_it_init(&log->logfgs, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
logfilegroup_t *lfg = hash_it_item(&hi);
list_iterator_t lj;
for (list_it_init(&lfg->file_group, &lj);
list_it_item(&lj); list_it_next(&lj)) {
logfile_t *lf = list_it_item(&lj);
if (lf->file)
fflush(lf->file);
}
}
}
}
log_t *log_new(char *user, char *network)
{
log_t *logdata;
logdata = (log_t*)calloc(sizeof(log_t), 1);
if (!logdata)
fatal("out of memory");
logdata->user = strdup(user);
logdata->network = strdup(network);
hash_init(&logdata->logfgs, HASH_NOCASE);
logdata->buffer = (char *)malloc(LOGLINE_MAXLEN * sizeof(char));
if (!logdata->user || !logdata->network || !logdata->buffer)
fatal("out of memory");
logdata->connected = 0;
if (!log_all_logs)
log_all_logs = list_new(NULL);
list_add_last(log_all_logs, logdata);
return logdata;
}
#ifdef TEST
int main(void)
{
log_t *logdata;
log_level = 4;
check_dir_r("/home/bip//subdir///subdir2");
conf_log_root = "/home/bip/logs";
conf_log_format = "%n/%Y-%m/%c.%d.log";
logdata = log_new(strdup("Marmite"));
log_privmsg(logdata, strdup("blah!ident@host"), strdup("to"),
strdup("Message"));
log_privmsg(logdata, strdup("blah!ident@host"), strdup("to"),
strdup("Message"));
log_join(logdata, strdup("blah!ident@host"), strdup("#pOrcSy"));
log_part(logdata, strdup("blah!ident@host"), strdup("#bip"),
strdup("blah"));
log_privmsg(logdata, strdup("blah!ident@host"), strdup("#poRcsy"),
strdup("Message"));
log_join(logdata, strdup("blah!ident@host"), strdup("#marmite"));
log_join(logdata, strdup("blah!ident@host"), strdup("#bip"));
log_join(logdata, strdup("blah!ident@host"), strdup("#bip"));
return 0;
}
#endif

87
src/log.h Normal file
View File

@ -0,0 +1,87 @@
/*
* $Id: log.h,v 1.26 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef LOG_H
#define LOG_H
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include "util.h"
#define MAX_PATH_LEN 1024
#define LOGLINE_MAXLEN 400
#define S_PRIVATES "privates"
struct list;
typedef struct logfile {
FILE *file;
char *filename;
struct tm last_log;
size_t backlog_offset;
size_t len;
} logfile_t;
typedef struct logfilegroup
{
char *name;
list_t file_group;
int skip_advance;
} logfilegroup_t;
typedef struct log {
hash_t logfgs;
char *network;
char *user;
char *buffer;
int connected;
int backlogging;
list_iterator_t file_it;
int lastfile_seeked;
} log_t;
void log_close_all(log_t *logdata);
log_t *log_new(char *user, char *network);
void logdata_free(log_t *logdata);
int log_compare_files(logfile_t *f1, char *f2);
void log_join(log_t *logdata, char *ircmask, char *channel);
void log_part(log_t *logdata, char *ircmask, char *channel, char *message);
void log_kick(log_t *logdata, char *ircmask, char *channel, char *who,
char *message);
void log_quit(log_t *logdata, char *ircmask, char *channel, char *message);
void log_nick(log_t *logdata, char *ircmask, char *channel, char *newnick);
void log_privmsg(log_t *logdata, char *ircmask, char *destination,
char *message);
void log_notice(log_t *logdata, char *ircmask, char *channel, char *message);
void log_write(log_t *logdata, char *str, char *destination);
void log_mode(log_t *logdata, char *ircmask, char *channel,
char *modes, char **modargv, unsigned modargc);
void log_topic(log_t *logdata, char *ircmask, char *channel, char *message);
void log_init_topic(log_t *logdata, char *channel, char *message);
void log_init_topic_time(log_t *logdata, char *channel, char *who, char *when);
void log_connected(log_t *logdata);
void log_disconnected(log_t *logdata);
void log_ping_timeout(log_t *logdata);
void log_client_disconnected(log_t *logdata);
void log_client_connected(log_t *logdata);
char *log_backread(log_t *logdata, char *destination, int *raw);
int log_has_backlog(log_t *logdata, char *destination);
void log_flush_all(void);
void log_client_none_connected(log_t *logdata);
#endif

418
src/md5.c Normal file
View File

@ -0,0 +1,418 @@
/*
* RFC 1321 compliant MD5 implementation
*
* Copyright (C) 2001-2003 Christophe Devine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <string.h>
#include "md5.h"
#define GET_UINT32(n,b,i) \
{ \
(n) = ( (uint32) (b)[(i) ] ) \
| ( (uint32) (b)[(i) + 1] << 8 ) \
| ( (uint32) (b)[(i) + 2] << 16 ) \
| ( (uint32) (b)[(i) + 3] << 24 ); \
}
#define PUT_UINT32(n,b,i) \
{ \
(b)[(i) ] = (uint8) ( (n) ); \
(b)[(i) + 1] = (uint8) ( (n) >> 8 ); \
(b)[(i) + 2] = (uint8) ( (n) >> 16 ); \
(b)[(i) + 3] = (uint8) ( (n) >> 24 ); \
}
void md5_starts( md5_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
}
void md5_process( md5_context *ctx, uint8 data[64] )
{
uint32 X[16], A, B, C, D;
GET_UINT32( X[0], data, 0 );
GET_UINT32( X[1], data, 4 );
GET_UINT32( X[2], data, 8 );
GET_UINT32( X[3], data, 12 );
GET_UINT32( X[4], data, 16 );
GET_UINT32( X[5], data, 20 );
GET_UINT32( X[6], data, 24 );
GET_UINT32( X[7], data, 28 );
GET_UINT32( X[8], data, 32 );
GET_UINT32( X[9], data, 36 );
GET_UINT32( X[10], data, 40 );
GET_UINT32( X[11], data, 44 );
GET_UINT32( X[12], data, 48 );
GET_UINT32( X[13], data, 52 );
GET_UINT32( X[14], data, 56 );
GET_UINT32( X[15], data, 60 );
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define P(a,b,c,d,k,s,t) \
{ \
a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
}
A = ctx->state[0];
B = ctx->state[1];
C = ctx->state[2];
D = ctx->state[3];
#define F(x,y,z) (z ^ (x & (y ^ z)))
P( A, B, C, D, 0, 7, 0xD76AA478 );
P( D, A, B, C, 1, 12, 0xE8C7B756 );
P( C, D, A, B, 2, 17, 0x242070DB );
P( B, C, D, A, 3, 22, 0xC1BDCEEE );
P( A, B, C, D, 4, 7, 0xF57C0FAF );
P( D, A, B, C, 5, 12, 0x4787C62A );
P( C, D, A, B, 6, 17, 0xA8304613 );
P( B, C, D, A, 7, 22, 0xFD469501 );
P( A, B, C, D, 8, 7, 0x698098D8 );
P( D, A, B, C, 9, 12, 0x8B44F7AF );
P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
P( B, C, D, A, 11, 22, 0x895CD7BE );
P( A, B, C, D, 12, 7, 0x6B901122 );
P( D, A, B, C, 13, 12, 0xFD987193 );
P( C, D, A, B, 14, 17, 0xA679438E );
P( B, C, D, A, 15, 22, 0x49B40821 );
#undef F
#define F(x,y,z) (y ^ (z & (x ^ y)))
P( A, B, C, D, 1, 5, 0xF61E2562 );
P( D, A, B, C, 6, 9, 0xC040B340 );
P( C, D, A, B, 11, 14, 0x265E5A51 );
P( B, C, D, A, 0, 20, 0xE9B6C7AA );
P( A, B, C, D, 5, 5, 0xD62F105D );
P( D, A, B, C, 10, 9, 0x02441453 );
P( C, D, A, B, 15, 14, 0xD8A1E681 );
P( B, C, D, A, 4, 20, 0xE7D3FBC8 );
P( A, B, C, D, 9, 5, 0x21E1CDE6 );
P( D, A, B, C, 14, 9, 0xC33707D6 );
P( C, D, A, B, 3, 14, 0xF4D50D87 );
P( B, C, D, A, 8, 20, 0x455A14ED );
P( A, B, C, D, 13, 5, 0xA9E3E905 );
P( D, A, B, C, 2, 9, 0xFCEFA3F8 );
P( C, D, A, B, 7, 14, 0x676F02D9 );
P( B, C, D, A, 12, 20, 0x8D2A4C8A );
#undef F
#define F(x,y,z) (x ^ y ^ z)
P( A, B, C, D, 5, 4, 0xFFFA3942 );
P( D, A, B, C, 8, 11, 0x8771F681 );
P( C, D, A, B, 11, 16, 0x6D9D6122 );
P( B, C, D, A, 14, 23, 0xFDE5380C );
P( A, B, C, D, 1, 4, 0xA4BEEA44 );
P( D, A, B, C, 4, 11, 0x4BDECFA9 );
P( C, D, A, B, 7, 16, 0xF6BB4B60 );
P( B, C, D, A, 10, 23, 0xBEBFBC70 );
P( A, B, C, D, 13, 4, 0x289B7EC6 );
P( D, A, B, C, 0, 11, 0xEAA127FA );
P( C, D, A, B, 3, 16, 0xD4EF3085 );
P( B, C, D, A, 6, 23, 0x04881D05 );
P( A, B, C, D, 9, 4, 0xD9D4D039 );
P( D, A, B, C, 12, 11, 0xE6DB99E5 );
P( C, D, A, B, 15, 16, 0x1FA27CF8 );
P( B, C, D, A, 2, 23, 0xC4AC5665 );
#undef F
#define F(x,y,z) (y ^ (x | ~z))
P( A, B, C, D, 0, 6, 0xF4292244 );
P( D, A, B, C, 7, 10, 0x432AFF97 );
P( C, D, A, B, 14, 15, 0xAB9423A7 );
P( B, C, D, A, 5, 21, 0xFC93A039 );
P( A, B, C, D, 12, 6, 0x655B59C3 );
P( D, A, B, C, 3, 10, 0x8F0CCC92 );
P( C, D, A, B, 10, 15, 0xFFEFF47D );
P( B, C, D, A, 1, 21, 0x85845DD1 );
P( A, B, C, D, 8, 6, 0x6FA87E4F );
P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
P( C, D, A, B, 6, 15, 0xA3014314 );
P( B, C, D, A, 13, 21, 0x4E0811A1 );
P( A, B, C, D, 4, 6, 0xF7537E82 );
P( D, A, B, C, 11, 10, 0xBD3AF235 );
P( C, D, A, B, 2, 15, 0x2AD7D2BB );
P( B, C, D, A, 9, 21, 0xEB86D391 );
#undef F
ctx->state[0] += A;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
}
void md5_update( md5_context *ctx, uint8 *input, uint32 length )
{
uint32 left, fill;
if( ! length ) return;
left = ctx->total[0] & 0x3F;
fill = 64 - left;
ctx->total[0] += length;
ctx->total[0] &= 0xFFFFFFFF;
if( ctx->total[0] < length )
ctx->total[1]++;
if( left && length >= fill )
{
memcpy( (void *) (ctx->buffer + left),
(void *) input, fill );
md5_process( ctx, ctx->buffer );
length -= fill;
input += fill;
left = 0;
}
while( length >= 64 )
{
md5_process( ctx, input );
length -= 64;
input += 64;
}
if( length )
{
memcpy( (void *) (ctx->buffer + left),
(void *) input, length );
}
}
static uint8 md5_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void md5_finish( md5_context *ctx, uint8 digest[16] )
{
uint32 last, padn;
uint32 high, low;
uint8 msglen[8];
high = ( ctx->total[0] >> 29 )
| ( ctx->total[1] << 3 );
low = ( ctx->total[0] << 3 );
PUT_UINT32( low, msglen, 0 );
PUT_UINT32( high, msglen, 4 );
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
md5_update( ctx, md5_padding, padn );
md5_update( ctx, msglen, 8 );
PUT_UINT32( ctx->state[0], digest, 0 );
PUT_UINT32( ctx->state[1], digest, 4 );
PUT_UINT32( ctx->state[2], digest, 8 );
PUT_UINT32( ctx->state[3], digest, 12 );
}
#ifdef TEST
#include <stdlib.h>
#include <stdio.h>
/*
* those are the standard RFC 1321 test vectors
*/
static char *msg[] =
{
"",
"a",
"abc",
"message digest",
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
"12345678901234567890123456789012345678901234567890123456789012" \
"345678901234567890"
};
static char *val[] =
{
"d41d8cd98f00b204e9800998ecf8427e",
"0cc175b9c0f1b6a831c399e269772661",
"900150983cd24fb0d6963f7d28e17f72",
"f96b697d7cb7938d525a2f31aaf161d0",
"c3fcd3d76192e4007dfb496cca67e13b",
"d174ab98d277d9f5a5611c2c9f419d9f",
"57edf4a22be3c955ac49da2e2107b67a"
};
int main( int argc, char *argv[] )
{
FILE *f;
int i, j;
char output[33];
md5_context ctx;
unsigned char buf[1000];
unsigned char md5sum[16];
if( argc < 2 )
{
printf( "\n MD5 Validation Tests:\n\n" );
for( i = 0; i < 7; i++ )
{
printf( " Test %d ", i + 1 );
md5_starts( &ctx );
md5_update( &ctx, (uint8 *) msg[i], strlen( msg[i] ) );
md5_finish( &ctx, md5sum );
for( j = 0; j < 16; j++ )
{
sprintf( output + j * 2, "%02x", md5sum[j] );
}
if( memcmp( output, val[i], 32 ) )
{
printf( "failed!\n" );
return( 1 );
}
printf( "passed.\n" );
}
printf( "\n" );
}
else
{
if( ! ( f = fopen( argv[1], "rb" ) ) )
{
perror( "fopen" );
return( 1 );
}
md5_starts( &ctx );
while( ( i = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
{
md5_update( &ctx, buf, i );
}
md5_finish( &ctx, md5sum );
for( j = 0; j < 16; j++ )
{
printf( "%02x", md5sum[j] );
}
printf( " %s\n", argv[1] );
}
return( 0 );
}
#endif
/* this was added for bip */
#include <stdlib.h>
/*
unsigned char *md5dup(unsigned char *data, size_t len)
{
md5_context ctx;
unsigned char *md5 = malloc(16);
md5_starts(&ctx);
md5_update(&ctx, data, len);
md5_finish(&ctx, md5);
return md5;
}
unsigned char *strmd5(char *str)
{
size_t length;
if (!str)
return NULL;
length = strlen(str);
if (length == 0)
return NULL;
return md5dup((unsigned char*)str, length);
}
*/
unsigned char *chash_double(char *str, unsigned int seed)
{
size_t length;
md5_context ctx;
unsigned char *ptr;
unsigned char *md5;
length = strlen(str);
length += 4;
ptr = malloc(length);
ptr[0] = seed >> 24 & 0xff;
ptr[1] = seed >> 16 & 0xff;
ptr[2] = seed >> 8 & 0xff;
ptr[3] = seed & 0xff;
memcpy(ptr + 4, str, length - 4);
md5 = malloc(16 + 4);
memcpy(md5, ptr, 4);
md5_starts(&ctx);
md5_update(&ctx, ptr, length);
md5_finish(&ctx, md5 + 4);
md5_starts(&ctx);
md5_update(&ctx, md5, 20);
md5_finish(&ctx, md5 + 4);
return md5;
}
int chash_cmp(char *try, unsigned char *pass, unsigned int seed)
{
int i;
unsigned char *try_hash;
try_hash = chash_double(try, seed);
for (i = 0; i < 20; i++) {
if (try_hash[i] != pass[i]) {
free(try_hash);
return 1; /* like strcmp 0 means == */
}
}
free(try_hash);
return 0;
}

23
src/md5.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef _MD5_H
#define _MD5_H
#ifndef uint8
#define uint8 unsigned char
#endif
#ifndef uint32
#define uint32 unsigned long int
#endif
typedef struct
{
uint32 total[2];
uint32 state[4];
uint8 buffer[64];
}
md5_context;
int chash_cmp(char *try, unsigned char *pass,
unsigned int seed);
unsigned char *chash_double(char *str, unsigned int seed);
#endif /* md5.h */

1
src/stamp-h.in Normal file
View File

@ -0,0 +1 @@
timestamp

27
src/tuple.h Normal file
View File

@ -0,0 +1,27 @@
/*
* $Id: conf.h,v 1.5 2005/04/17 15:20:32 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef TUPLE_H
#define TUPLE_H
#define TUPLE_STR 0
#define TUPLE_INT 1
#define TUPLE_LIST 2
struct tuple {
int type;
void *pdata;
int ndata;
int tuple_type;
};
#endif

631
src/util.c Normal file
View File

@ -0,0 +1,631 @@
/*
* $Id: util.c,v 1.60 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include "config.h"
#include "util.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
extern int conf_log_level;
extern int errno;
/*
* <nick> ::= <letter> { <letter> | <number> | <special> }
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
*/
int is_valid_nick(char *str)
{
char *tmp;
if (!str || !isalpha(*str))
return 0;
tmp = str;
while (*tmp != '\0' && (isalnum(*tmp) || *tmp == '-' || *tmp == '[' ||
*tmp == ']' || *tmp == '\\' || *tmp == '`' ||
*tmp == '^' || *tmp == '{' || *tmp == '}' ||
*tmp == '|'))
tmp++;
return (*tmp == '\0');
}
int is_valid_username(char *str)
{
char *tmp;
if (!str || *str == '\0' || *str == ' ' || *str == '\n' || *str == '\r')
return 0;
tmp = str;
while (*tmp != '\0' && *tmp != ' ' && *tmp != '\0' && *tmp != '\r' &&
*tmp != '\n')
tmp++;
return (*tmp == '\0');
}
char *timestamp(void)
{
static char ts[20];
time_t tv;
struct tm *tm;
time(&tv);
tm = localtime(&tv);
snprintf(ts, 20, "%02d-%02d-%04d %02d:%02d:%02d", tm->tm_mday,
tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour,
tm->tm_min, tm->tm_sec);
return ts;
}
extern FILE *conf_global_log_file;
void _mylog(int level, char *fmt, va_list ap)
{
char *prefix;
if (level > conf_log_level)
return;
switch (level) {
case LOG_FATAL:
prefix = "FATAL: ";
break;
case LOG_DEBUGVERB:
prefix = "DEBUG: ";
break;
case LOG_DEBUG:
prefix = "DEBUG: ";
break;
case LOG_ERROR:
prefix = "ERROR: ";
break;
case LOG_WARN:
prefix = "WARNING: ";
break;
case LOG_INFO:
prefix = "INFO: ";
break;
default:
prefix = "";
break;
}
fprintf(conf_global_log_file, "%s %s", timestamp(), prefix);
vfprintf(conf_global_log_file, fmt, ap);
fprintf(conf_global_log_file, "\n");
#ifdef DEBUG
fflush(conf_global_log_file);
#endif
}
void mylog(int level, char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_mylog(level, fmt, ap);
va_end(ap);
}
extern char *conf_pid_file;
void fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_mylog(LOG_FATAL, fmt, ap);
va_end(ap);
exit(200);
}
/*
* list handling functions
*/
struct list_item {
struct list_item *next;
struct list_item *prev;
void *ptr;
};
int list_ptr_cmp(void *a, void *b)
{
if (a == b)
return 0;
return -1;
}
void list_init(list_t *l, int (*cmp)(void *, void *))
{
l->first = NULL;
l->last = NULL;
l->cmp = cmp;
}
list_t *list_new(int (*cmp)(void *, void *))
{
list_t *l;
l = malloc(sizeof(list_t));
if (!l)
fatal("malloc");
list_init(l, cmp);
return l;
}
static struct list_item *list_item(void *ptr)
{
struct list_item *l;
l = malloc(sizeof(struct list_item));
if (!l)
fatal("malloc");
l->ptr = ptr;
l->next = NULL;
l->prev = NULL;
return l;
}
void list_add_first(list_t *list, void *ptr)
{
struct list_item *li;
li = list_item(ptr);
if (!list->first) {
list->first = list->last = li;
return;
}
li->next = list->first;
list->first = li;
li->next->prev = li;
}
void list_add_first_uniq(list_t *list, void *ptr)
{
if (list_get(list, ptr))
return;
list_add_first(list, ptr);
}
void list_add_last(list_t *list, void *ptr)
{
struct list_item *li;
li = list_item(ptr);
if (!list->first) {
list->first = list->last = li;
return;
}
li->prev = list->last;
list->last = li;
li->prev->next = li;
}
void *list_get_first(list_t *list)
{
if (!list->first)
return NULL;
return list->first->ptr;
}
void *list_get_last(list_t *list)
{
if (!list->last)
return NULL;
return list->last->ptr;
}
void *list_remove_first(list_t *list)
{
struct list_item *l;
void *ptr = list_get_first(list);
if (!ptr)
return NULL;
l = list->first;
list->first = list->first->next;
if (list->first == NULL)
list->last = NULL;
free(l);
return ptr;
}
void *list_remove_last(list_t *list)
{
struct list_item *l;
void *ptr = list_get_last(list);
if (!ptr)
return NULL;
l = list->last;
list->last = list->last->prev;
if (list->last == NULL)
list->first = NULL;
free(l);
return ptr;
}
/*
static void *list_remove_item(list_t *l, struct list_item *li)
{
void *ret = li->ptr;
if (!li->prev) {
if (l->first != li)
fatal("list_remove_item");
l->first = li->next;
} else
li->prev->next = li->next;
if (!li->next) {
if (l->last != li)
fatal("list_remove_item");
l->last = li->prev;
} else
li->next->prev = li->prev;
free(li);
return ret;
}
*/
void *list_remove_if_exists(list_t *list, void *ptr)
{
list_iterator_t li;
int debug = 0;
void *ret;
if (!list->cmp)
fatal("list_remove: list does not have a cmp function\n");
for (list_it_init(list, &li); list_it_item(&li); list_it_next(&li)) {
if (list->cmp(list_it_item(&li), ptr) == 0) {
if (debug == 1)
fatal("%x appears twice in list\n", ptr);
ret = list_it_remove(&li);
debug = 1;
}
}
if (debug)
return ret;
return NULL;
}
void *list_remove(list_t *list, void *ptr)
{
void *ret;
if (!(ret = list_remove_if_exists(list, ptr)))
fatal("list_remove: item not found");
return ret;
}
void *list_get(list_t *list, void *ptr)
{
struct list_item *it;
if (!list->cmp)
fatal("list_get: list does not have a cmp function\n");
for (it = list->first; it; it = it->next) {
if (list->cmp(it->ptr, ptr) == 0)
return it->ptr;
}
return NULL;
}
int list_is_empty(list_t *l)
{
return (l->first ? 0 : 1);
}
void list_it_init(list_t *list, list_iterator_t *ti)
{
ti->list = list;
ti->cur = list->first;
}
void list_it_next(list_iterator_t *ti)
{
if (ti->cur)
ti->cur = ti->cur->next;
}
void *list_it_item(list_iterator_t *ti)
{
if (!ti->cur)
return NULL;
return ti->cur->ptr;
}
void *list_it_remove(list_iterator_t *li)
{
if (!li->cur)
return NULL;
if (li->cur->prev)
li->cur->prev->next = li->cur->next;
else
li->list->first = li->cur->next;
if (li->cur->next)
li->cur->next->prev = li->cur->prev;
else
li->list->last = li->cur->prev;
void *ptr = li->cur->ptr;
struct list_item *item = li->cur;
li->cur = li->cur->next;
free(item);
return ptr;
}
void list_free_force(list_t *t)
{
free(t);
}
void list_free(list_t *t)
{
if (t->first != NULL)
fprintf(stderr, "Warning, freeing non empty list\n");
free(t);
}
void list_append(list_t *src, list_t *dest)
{
list_iterator_t it;
for (list_it_init(src, &it); list_it_item(&it); list_it_next(&it))
list_add_last(dest, list_it_item(&it));
}
/*
* Hash stuff
*/
struct hash_item {
char *key;
void *item;
};
static int hash_item_nocase_cmp(struct hash_item *a, char *b)
{
return strcasecmp(a->key, b);
}
static int hash_item_cmp(struct hash_item *a, char *b)
{
return strcmp(a->key, b);
}
void hash_init(hash_t *h, int options)
{
int i;
memset(h, 0, sizeof(hash_t));
for (i = 0; i < 256; i++) {
switch (options) {
case HASH_NOCASE:
list_init(&h->lists[i],
(int (*)(void*,void*))hash_item_nocase_cmp);
break;
case HASH_DEFAULT:
list_init(&h->lists[i],
(int (*)(void*,void*))hash_item_cmp);
break;
default:
fatal("wrong hash option %d", options);
}
}
}
void hash_clean(hash_t *h)
{
int i;
for (i = 0; i < 256; i++) {
while (list_remove_first(&h->lists[i]))
;
}
}
void hash_free(hash_t *h)
{
hash_clean(h);
free(h);
}
hash_t *hash_new(int options)
{
hash_t *h;
h = malloc(sizeof(hash_t));
if (!h)
fatal("malloc");
hash_init(h, options);
return h;
}
static unsigned char hash_func(char *pkey)
{
unsigned char i = 0;
while (*pkey)
i += (unsigned char)toupper(*pkey++);
return i;
}
void hash_insert(hash_t *hash, char *key, void *ptr)
{
struct hash_item *it;
if (hash_get(hash, key))
fatal("Element with key %s already in hash %x\n", key, hash);
it = malloc(sizeof(struct hash_item));
if (!it)
fatal("malloc");
it->key = strdup(key);
it->item = ptr;
list_add_first(&hash->lists[hash_func(key)], it);
}
void *hash_get(hash_t *hash, char *key)
{
struct hash_item *hi;
list_t *list = &hash->lists[hash_func(key)];
hi = list_get(list, key);
if (!hi)
return NULL;
return hi->item;
}
void *hash_remove_if_exists(hash_t *hash, char *key)
{
if (hash_get(hash, key) == NULL)
return NULL;
return hash_remove(hash, key);
}
void *hash_remove(hash_t *hash, char *key)
{
struct hash_item *it;
void *ptr;
it = (struct hash_item *)list_remove(&hash->lists[hash_func(key)], key);
if (!it)
return NULL;
ptr = it->item;
free(it->key);
free(it);
return ptr;
}
void hash_it_init(hash_t *h, hash_iterator_t *hi)
{
memset(hi, 0, sizeof(hash_iterator_t));
hi->hash = h;
while (list_is_empty(&h->lists[hi->list]) && hi->list < 256)
hi->list++;
if (hi->list < 256)
hi->cur = h->lists[hi->list].first;
else
hi->cur = NULL;
}
void hash_it_next(hash_iterator_t *hi)
{
hash_t *hash = hi->hash;
hi->cur = hi->cur->next;
while (!hi->cur) {
hi->list++;
if (hi->list == 256) {
hi->cur = NULL;
return;
}
hi->cur = hash->lists[hi->list].first;
}
}
void *hash_it_item(hash_iterator_t *h)
{
if (!h->cur)
return NULL;
struct hash_item *hi = h->cur->ptr;
return hi->item;
}
char *hash_it_key(hash_iterator_t *h)
{
if (!h->cur)
return NULL;
struct hash_item *hi = h->cur->ptr;
return hi->key;
}
char *strmaydup(char *s)
{
if (!s)
return s;
return strdup(s);
}
/* returns 1 on error */
int ident_spoof(char *user)
{
char *h;
char buf[1024];
mode_t ou;
FILE *of;
int cnt = 0;
/* get home dir or return an error */
h = getenv("HOME");
if (h == NULL)
return 1;
/* first we set umask correctly */
ou = umask(0022);
snprintf(buf, 1024, "%s/.ispoof", h);
of = fopen(buf, "w");
if (of) {
fprintf(of, "%s\n", user);
fclose(of);
cnt++;
}
snprintf(buf, 1024, "%s/.oidentd.conf", h);
of = fopen(buf, "w");
if (of) {
fprintf(of, "global { reply \"%s\" }\n", user);
fclose(of);
cnt++;
}
/* restore old umask */
umask(ou);
return (cnt == 2);
}
/* returns 1 on error */
int ident_nospoof()
{
char *h;
char buf[1024];
int e, cnt;
/* get home dir or return an error */
h = getenv("HOME");
if (h == NULL)
return 1;
snprintf(buf, 1024, "%s/.ispoof", h);
e = unlink(buf);
cnt = (e == -1 && errno != ENOENT ? 1 : 0);
snprintf(buf, 1024, "%s/.oidentd.conf", h);
e = unlink(buf);
return cnt+(e == -1 && errno != ENOENT ? 1 : 0);
}
void strucase(char *s)
{
while (*s) {
*s = toupper(*s);
s++;
}
}
int ischannel(char p)
{
return (p == '#' || p == '&' || p == '+' || p == '!');
}

103
src/util.h Normal file
View File

@ -0,0 +1,103 @@
/*
* $Id: util.h,v 1.35 2005/04/12 19:34:35 nohar Exp $
*
* This file is part of the bip project
* Copyright (C) 2004 Arnaud Cornet and Loïc Gomez
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef UTIL_H
#define UTIL_H
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
/* Warning: must be in order, 0 = less output */
#define LOG_FATAL 0
#define LOG_ERROR 1
#define LOG_WARN 2
#define LOG_INFO 3
#define LOG_DEBUG 4
#define LOG_STD 4
#define LOG_DEBUGVERB 5
#define LOG_DEBUGTOOMUCH 6
#define HASH_NOCASE 1
#define HASH_DEFAULT 0
void mylog(int level, char *fmt, ...);
void fatal(char *fmt, ...);
char *timestamp(void);
struct list_item;
typedef struct list {
struct list_item *first;
struct list_item *last;
int (*cmp)();
} list_t;
typedef struct list_iterator {
list_t *list;
struct list_item *cur;
} list_iterator_t;
/* our hash is also a list */
typedef struct hash {
list_t lists[256];
} hash_t;
typedef struct hash_iterator {
int list;
struct list_item *cur;
hash_t *hash;
} hash_iterator_t;
void list_init(list_t *list, int (*cmp)(void*,void*));
int list_ptr_cmp(void *a, void *b);
list_t *list_new(int (*cmp)(void *, void *));
void *list_remove(list_t *list, void *ptr);
void *list_remove_if_exists(list_t *list, void *ptr);
void *list_get(list_t *list, void *ptr);
void list_add_first(list_t *list, void *ptr);
void list_add_first_uniq(list_t *list, void *ptr);
void list_add_last(list_t *list, void *ptr);
void *list_get_first(list_t *list);
void *list_get_last(list_t *list);
void *list_remove_first(list_t *list);
void *list_remove_last(list_t *list);
void list_it_init(list_t *list, list_iterator_t *ti);
void list_it_next(list_iterator_t *ti);
void *list_it_item(list_iterator_t *ti);
void *list_it_remove(list_iterator_t *li);
void list_free(list_t *t);
void list_free_force(list_t *t);
void list_copy(list_t *src, list_t *dest);
void list_append(list_t *src, list_t *dest);
int list_is_empty(list_t *l);
void hash_init(hash_t *h, int);
void hash_free(hash_t *h);
void hash_clean(hash_t *h);
hash_t *hash_new(int options);
void hash_insert(hash_t *hash, char *key, void *ptr);
void *hash_get(hash_t *, char *key);
void *hash_remove(hash_t *hash, char *key);
void *hash_remove_if_exists(hash_t *hash, char *key);
void hash_it_init(hash_t *hash, hash_iterator_t *i);
void hash_it_next(hash_iterator_t *hi);
void *hash_it_item(hash_iterator_t *h);
char *hash_it_key(hash_iterator_t *h);
int is_valid_nick(char *str);
int is_valid_username(char *str);
char *strmaydup(char *s);
int ident_spoof(char *user);
int ident_nospoof();
void strucase(char *s);
int ischannel(char p);
#endif

1
stamp-h.in Normal file
View File

@ -0,0 +1 @@
timestamp