Seeding from the 1.2 tree.
This commit is contained in:
46
dll/Make-windll.sh
Normal file
46
dll/Make-windll.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
RM=rm
|
||||
CP=cp
|
||||
|
||||
$GCC -c init.cc
|
||||
$GCC -c fixup.cc
|
||||
$GCC -I../include -c pkga.c
|
||||
|
||||
echo EXPORTS > pkga.def
|
||||
$NM pkga.o init.o fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> pkga.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file pkga.base --dll -o pkga.dll pkga.o init.o fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname pkga.dll --def pkga.def --base-file\
|
||||
pkga.base --output-exp pkga.exp
|
||||
$LD --base-file pkga.base pkga.exp --dll -o pkga.dll pkga.o\
|
||||
init.o fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname pkga.dll --def pkga.def --base-file\
|
||||
pkga.base --output-exp pkga.exp
|
||||
$LD pkga.exp --dll -o pkga.dll pkga.o init.o fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the pkgaB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname pkga.dll --def pkga.def --output-lib pkga.a
|
||||
|
||||
$RM *.base *.def *.exp
|
||||
(cd abot; sh ./abot.sh)
|
||||
(cd acro; sh ./acro.sh)
|
||||
(cd blowfish; sh ./blowfish.sh)
|
||||
(cd possum; sh ./possum.sh)
|
||||
(cd hint; sh ./hint.sh)
|
||||
(cd cavlink; sh ./cavlink.sh)
|
||||
(cd identd; sh ./identd.sh)
|
||||
(cd encrypt; sh ./encrypt.sh)
|
||||
(cd fserv; sh ./fserv.sh)
|
||||
(cd nap; sh ./nap.sh)
|
||||
|
||||
250
dll/Makefile.in
Normal file
250
dll/Makefile.in
Normal file
@@ -0,0 +1,250 @@
|
||||
# dll/Makefile.in
|
||||
#
|
||||
# This Makefile is used to create dll/dynamic link libs for BitchX
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
ALL_PLUGINS = abot acro aim amp arcfour autocycle blowfish cavlink cdrom encrypt europa fserv hint identd nap nicklist pkga possum qbx qmail wavplay xmms
|
||||
|
||||
#PLUGINS = abot acro aim arcfour autocycle blowfish cavlink encrypt europa fserv hint identd nap pkga possum qbx qmail wavplay
|
||||
PLUGINS = @PLUGINS@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
$(SHLIB_SUFFIX).o:
|
||||
$(SHLIB_LD) $(SHLIB_CFLAGS) $< -o $@$(SHLIB_SUFFIX)
|
||||
|
||||
all: Makefile dllinit.o
|
||||
@( \
|
||||
makeflags=$$2; \
|
||||
target="$@"; \
|
||||
list="$(PLUGINS)"; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) $$target) \
|
||||
|| case "$$makeflags" in *=*) exit 1;; *k*) ;; *) exit 1;; esac; \
|
||||
done; \
|
||||
)
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in
|
||||
cd $(topdir) \
|
||||
&& $(SHELL) ./config.status
|
||||
|
||||
dummy:
|
||||
|
||||
dllinit.o:
|
||||
@( \
|
||||
if test x"$(PLUGINS)" != x""; then \
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/dllinit.c; \
|
||||
fi; \
|
||||
)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d $(DESTDIR)$(PLUGINDIR)
|
||||
@( \
|
||||
makeflags=$$2; \
|
||||
target="$@"; \
|
||||
list="$(PLUGINS)"; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) 'DESTDIR=$(DESTDIR)' $$target) \
|
||||
|| case "$$makeflags" in *=*) exit 1;; *k*) ;; *) exit 1;; esac; \
|
||||
done; \
|
||||
)
|
||||
@( \
|
||||
if test x"$(PLUGINS)" != x""; then \
|
||||
strip --strip-unneeded $(DESTDIR)$(PLUGINDIR)/*$(SHLIB_SUFFIX) || :; \
|
||||
echo Your plugins [$(PLUGINS)] are now located in $(PLUGINDIR);\
|
||||
fi; \
|
||||
)
|
||||
|
||||
install_local: all
|
||||
$(INSTALL) -d $(local_dir)/.BitchX/plugins
|
||||
@( \
|
||||
makeflags=$$2; \
|
||||
target="$@"; \
|
||||
list="$(PLUGINS)"; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) 'PLUGINDIR=$(local_dir)/.BitchX' $$target) \
|
||||
|| case "$$makeflags" in *=*) exit 1;; *k*) ;; *) exit 1;; esac; \
|
||||
done; \
|
||||
)
|
||||
@( \
|
||||
if test x"$(PLUGINS)" != x""; then \
|
||||
echo Your plugins [$(PLUGINS)] are now located in $(PLUGINDIR) ;\
|
||||
fi; \
|
||||
)
|
||||
|
||||
clean: dummy
|
||||
@( \
|
||||
makeflags=$$2; \
|
||||
target="$@"; \
|
||||
list="$(PLUGINS)"; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) $$target) \
|
||||
|| case "$$makeflags" in *=*) exit 1;; *k*) ;; *) exit 1;; esac; \
|
||||
done; \
|
||||
)
|
||||
-$(RM) *~ *.o *$(SHLIB_SUFFIX)
|
||||
|
||||
distclean: clean
|
||||
@( \
|
||||
makeflags=$$2; \
|
||||
target="$@"; \
|
||||
list="$(ALL_PLUGINS)"; \
|
||||
for subdir in $$list; do \
|
||||
(cd $$subdir && $(MAKE) $$target) \
|
||||
|| case "$$makeflags" in *=*) exit 1;; *k*) ;; *) exit 1;; esac; \
|
||||
done; \
|
||||
)
|
||||
-$(RM) Makefile
|
||||
175
dll/abot/Makefile.in
Normal file
175
dll/abot/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = autobot
|
||||
|
||||
all: Makefile autobot$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
autobot.o: $(srcdir)/autobot.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/autobot.c
|
||||
|
||||
autobot$(SHLIB_SUFFIX): autobot.o ../dllinit.o
|
||||
$(SHLIB_LD) autobot.o ../dllinit.o $(SHLIB_CFLAGS) -o autobot$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.so *.a *.dll *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
33
dll/abot/abot.sh
Normal file
33
dll/abot/abot.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
CP=cp
|
||||
RM=rm
|
||||
|
||||
$GCC -I../../include -c autobot.c
|
||||
|
||||
echo EXPORTS > autobot.def
|
||||
$NM autobot.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> autobot.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file autobot.base --dll -o autobot.dll autobot.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname autobot.dll --def autobot.def --base-file\
|
||||
autobot.base --output-exp autobot.exp
|
||||
$LD --base-file autobot.base autobot.exp --dll -o autobot.dll autobot.o\
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname autobot.dll --def autobot.def --base-file\
|
||||
autobot.base --output-exp autobot.exp
|
||||
$LD autobot.exp --dll -o autobot.dll autobot.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the autobotB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname autobot.dll --def autobot.def --output-lib autobot.a
|
||||
|
||||
$RM *.base *.exp *.def
|
||||
$CP *.dll ..
|
||||
242
dll/abot/autobot.c
Normal file
242
dll/abot/autobot.c
Normal file
@@ -0,0 +1,242 @@
|
||||
#define AUTO_VERSION "1.00"
|
||||
|
||||
/*
|
||||
*
|
||||
* Written by Colten Edwards. (C) August 97, March 98
|
||||
* Based on script by suicide for evolver script.
|
||||
*/
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "dcc.h"
|
||||
#include "ircaux.h"
|
||||
#include "ctcp.h"
|
||||
#include "status.h"
|
||||
#include "lastlog.h"
|
||||
#include "screen.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "hook.h"
|
||||
#include "hash2.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define cparse convert_output_format
|
||||
char auto_bot_version[] = "Auto-Bot 1.000";
|
||||
UserList *auto_bot = NULL;
|
||||
char *auto_filename = NULL;
|
||||
|
||||
BUILT_IN_DLL(add_abot);
|
||||
BUILT_IN_DLL(remove_abot);
|
||||
|
||||
void write_abot (char *, int);
|
||||
void read_abot (char *);
|
||||
int join_proc (char *, char *, char **);
|
||||
|
||||
int check_userop(UserList *u, char *channel, int server)
|
||||
{
|
||||
NickList *n;
|
||||
ChannelList *cptr;
|
||||
cptr = get_server_channels(server);
|
||||
cptr = (ChannelList *)find_in_list((List **)&cptr, channel, 0);
|
||||
if (cptr && (n = find_nicklist_in_channellist(u->nick, cptr, 0)))
|
||||
{
|
||||
if (n->host && u->host && !my_stricmp(u->host, n->host) && wild_match(u->channels, channel))
|
||||
{
|
||||
if (!nick_isop(n))
|
||||
{
|
||||
put_it("%s", cparse("$G %G$0 is not a channel op on $1", "%s %s", u->nick, channel));
|
||||
return 0;
|
||||
}
|
||||
put_it("%s", cparse("$G %GRequesting OPS from $0 on $1", "%s %s", u->nick, channel));
|
||||
switch(get_dllint_var("autobot-type"))
|
||||
{
|
||||
case 0:
|
||||
send_to_server("PRIVMSG %s :OP %s", u->nick, u->password);
|
||||
break;
|
||||
case 1:
|
||||
send_to_server("PRIVMSG %s :OP %s %s", u->nick, channel, u->password);
|
||||
break;
|
||||
case 2:
|
||||
send_to_server("PRIVMSG %s :+OP %s", u->nick, get_server_nickname(server));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int join_proc (char *which, char *str, char **unused)
|
||||
{
|
||||
char channel[BIG_BUFFER_SIZE];
|
||||
char *p;
|
||||
strncpy(channel, str, BIG_BUFFER_SIZE-10);
|
||||
if (!(p = strchr(channel, ' ')))
|
||||
return 1;
|
||||
*p = 0;
|
||||
if (!is_chanop(channel, get_server_nickname(from_server)))
|
||||
{
|
||||
UserList *u;
|
||||
for (u = auto_bot; u; u = u->next)
|
||||
check_userop(u, channel, from_server);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BUILT_IN_DLL(remove_abot)
|
||||
{
|
||||
UserList *n;
|
||||
char *nick;
|
||||
int count = 0;
|
||||
nick = next_arg(args, &args);
|
||||
if (nick)
|
||||
{
|
||||
while ((n = (UserList *)remove_from_list((List **)&auto_bot, nick)))
|
||||
{
|
||||
put_it("%s", cparse("$G Removing Abot entry $0", "%s", n->nick));
|
||||
new_free(&n->nick);
|
||||
new_free(&n->host);
|
||||
new_free(&n->channels);
|
||||
new_free(&n->password);
|
||||
new_free((char **)&n);
|
||||
write_abot(auto_filename, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (!count)
|
||||
put_it("%s", cparse("$G Couldn't find Abot entry $0", "%s", nick?nick:empty_string));
|
||||
return;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(add_abot)
|
||||
{
|
||||
ChannelList *chan;
|
||||
NickList *n = NULL;
|
||||
char *nick, *password, *channels;
|
||||
nick = next_arg(args, &args);
|
||||
password = next_arg(args, &args);
|
||||
channels = next_arg(args, &args);
|
||||
if (from_server == -1)
|
||||
return;
|
||||
if (!nick || !password)
|
||||
{
|
||||
if (auto_bot)
|
||||
{
|
||||
int count = 0;
|
||||
UserList *u;
|
||||
for (u = auto_bot; u; u = u->next, count++)
|
||||
put_it("%s", cparse("$0 $1!$2 $4", "%d %s %s %s", count, u->nick, u->host, u->channels));
|
||||
}
|
||||
userage("abot", helparg);
|
||||
return;
|
||||
}
|
||||
if (!channels || !*channels)
|
||||
channels = "*";
|
||||
chan = get_server_channels(from_server);
|
||||
for ( ; chan; chan = chan->next)
|
||||
{
|
||||
for (n = next_nicklist(chan, NULL); n; n = next_nicklist(chan, n))
|
||||
if (!my_stricmp(nick, n->nick))
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
if (n)
|
||||
{
|
||||
UserList *new;
|
||||
new = (UserList *) new_malloc(sizeof(UserList));
|
||||
new->nick = m_strdup(n->nick);
|
||||
new->host = m_strdup(n->host);
|
||||
new->password = m_strdup(password);
|
||||
new->channels = m_strdup(channels);
|
||||
add_to_list((List **)&auto_bot, (List *)new);
|
||||
write_abot(auto_filename, 1);
|
||||
}
|
||||
}
|
||||
|
||||
char *auto_Version(IrcCommandDll **intp)
|
||||
{
|
||||
return auto_bot_version;
|
||||
}
|
||||
|
||||
void write_abot(char *filename, int out)
|
||||
{
|
||||
FILE *f;
|
||||
UserList *u;
|
||||
if (filename && (f = fopen(filename, "w")))
|
||||
{
|
||||
if (out)
|
||||
put_it("%s", cparse("$G Auto-Saving $0", "%s", filename));
|
||||
for (u = auto_bot; u; u = u->next)
|
||||
fprintf(f, "%s!%s,%s,%s\n", u->nick,u->host,u->password,u->channels);
|
||||
fclose(f);
|
||||
} else if (filename)
|
||||
put_it("%s", cparse("$G Could not open $0 for write", "%s", filename));
|
||||
}
|
||||
|
||||
void read_abot(char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
char buffer[BIG_BUFFER_SIZE];
|
||||
char *u, *h, *p, *c;
|
||||
UserList *new;
|
||||
|
||||
if (!(f = fopen(filename, "r")))
|
||||
{
|
||||
put_it("Could not open %s for reading", filename);
|
||||
return;
|
||||
}
|
||||
while (!feof(f))
|
||||
{
|
||||
if ((fgets(buffer, sizeof(buffer), f)))
|
||||
{
|
||||
chop(buffer, 1);
|
||||
u = buffer;
|
||||
h = strchr(u, '!');
|
||||
*h++ = 0;
|
||||
p = strchr(h, ',');
|
||||
*p++ = 0;
|
||||
if ((c = strchr(p, ',')))
|
||||
*c++ = 0;
|
||||
else
|
||||
c = "*";
|
||||
|
||||
new = (UserList *) new_malloc(sizeof(UserList));
|
||||
new->nick = m_strdup(u);
|
||||
new->host = m_strdup(h);
|
||||
new->password = m_strdup(p);
|
||||
new->channels = m_strdup(c);
|
||||
add_to_list((List **)&auto_bot, (List *)new);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
char *Autobot_Version(IrcCommandDll **intp)
|
||||
{
|
||||
return AUTO_VERSION;
|
||||
}
|
||||
|
||||
|
||||
int Autobot_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
char buffer[BIG_BUFFER_SIZE+1];
|
||||
initialize_module("Autobot");
|
||||
|
||||
add_module_proc(VAR_PROC, "Autobot", "autobot-type", NULL, INT_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(COMMAND_PROC, "Autobot", "abot", NULL, 0, 0, add_abot, "Add bot to msg for auto-ops");
|
||||
add_module_proc(COMMAND_PROC, "Autobot", "rbot", NULL, 0, 0, remove_abot, "Remove bot from autoop list");
|
||||
add_module_proc(HOOK_PROC, "Autobot", NULL, "*", CHANNEL_SYNCH_LIST, 1, NULL, join_proc);
|
||||
|
||||
put_it("%s", convert_output_format("$G $0 v$1 by panasync. Based on suicide's Abot script.", "%s %s", auto_bot_version, AUTO_VERSION));
|
||||
sprintf(buffer, "%s/abots.sav", get_string_var(CTOOLZ_DIR_VAR));
|
||||
auto_filename = expand_twiddle(buffer);
|
||||
/* read abots.sav */
|
||||
read_abot(auto_filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
175
dll/acro/Makefile.in
Normal file
175
dll/acro/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = acro
|
||||
|
||||
all: Makefile acro$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
acro.o: $(srcdir)/acro.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/acro.c
|
||||
|
||||
acro$(SHLIB_SUFFIX): acro.o ../dllinit.o
|
||||
$(SHLIB_LD) acro.o ../dllinit.o $(SHLIB_CFLAGS) -o acro$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o acro$(SHLIB_SUFFIX) *.a *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
17
dll/acro/README
Normal file
17
dll/acro/README
Normal file
@@ -0,0 +1,17 @@
|
||||
First public release of a dll-ized version of my TCL acromania script.
|
||||
You need the BitchX include files for it to compile (duh).
|
||||
Seems to work fine in testing, alert me of any problems.
|
||||
|
||||
************ WARNING ************
|
||||
DO NOT /UNLOADDLL WHILE A GAME IS IN PROGRESS, YOUR CLIENT WILL CORE!
|
||||
If you MUST stop a game in progress, FIRST KILL THE TIMER(S) and unload it.
|
||||
Maybe panasync will take these race conditions into account someday :)...
|
||||
************ WARNING ************
|
||||
|
||||
|
||||
Greetz to (in NO particular order) dh, hammz, scoop, hammz, oweff, shewp
|
||||
ice-man, sideshow, BlackJac, fudd, shade, psykotyk, MHacker, Sheik, easyme
|
||||
macker, |Fingers|, mrr, Timer, and anyone else I'm forgetting (let me know)
|
||||
|
||||
Major super-kudo greets to panasync, without his help I never would have got
|
||||
this working properly, and of course for making bX in the first place.. =)
|
||||
7
dll/acro/TODO
Normal file
7
dll/acro/TODO
Normal file
@@ -0,0 +1,7 @@
|
||||
Things to do...
|
||||
|
||||
Everyone seems to want point deductions for playing and not voting, maybe
|
||||
I'll make that an option or something:)
|
||||
|
||||
Need to get rid of all the compile time defines and make them dynamic with a
|
||||
command in bx.
|
||||
621
dll/acro/acro.c
Normal file
621
dll/acro/acro.c
Normal file
@@ -0,0 +1,621 @@
|
||||
#include "acro.h"
|
||||
|
||||
srec *scores = NULL, *gscores = NULL;
|
||||
prec *player = NULL;
|
||||
vrec *voter = NULL;
|
||||
grec *game = NULL;
|
||||
|
||||
int Acro_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
initialize_module("Acromania");
|
||||
add_module_proc(RAW_PROC, "acro", "PRIVMSG", NULL, 0, 0, acro_main, NULL);
|
||||
add_module_proc(COMMAND_PROC, "scores", "scores", NULL, 0, 0, put_scores, NULL);
|
||||
|
||||
gscores = read_scores();
|
||||
if (!game)
|
||||
game = init_acro(game);
|
||||
put_it("BitchX Acromania dll v0.9b by By-Tor loaded...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int acro_main (char *comm, char *from, char *userhost, char **args)
|
||||
{
|
||||
if (*args[1] && !strncasecmp(args[1], "acro ", 5) && !strcasecmp(args[0], get_server_nickname(from_server)))
|
||||
{
|
||||
PasteArgs(args, 1);
|
||||
switch(game->progress) {
|
||||
case 0:
|
||||
send_to_server("notice %s :Sorry, no game in progress.", from);
|
||||
break;
|
||||
case 1:
|
||||
if (valid_acro(game, args[1]+5))
|
||||
player = take_acro(game, player, from, userhost, args[1]+5);
|
||||
else
|
||||
send_to_server("PRIVMSG %s :Invalid acronym", from);
|
||||
break;
|
||||
case 2:
|
||||
voter = take_vote(game, voter, player, from, userhost, args[1]+5);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (*args[0] == '#' && *args[1] && !my_stricmp(args[1], "start"))
|
||||
{
|
||||
if (game && game->progress)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :Game already in progress, %s. Puzzle is: %s", from, from, game->nym);
|
||||
return 0;
|
||||
}
|
||||
make_acro(game);
|
||||
game->progress = 1;
|
||||
send_to_server("PRIVMSG %s :Round %d", args[0], game->round);
|
||||
send_to_server("PRIVMSG %s :The acronym for this round is %s. You have 60 seconds.", args[0], game->nym);
|
||||
send_to_server("PRIVMSG %s :/msg %s \"acro <your answer>\"", args[0], get_server_nickname(from_server));
|
||||
add_timer(0, "Acro", 60 * 1000, 1, (int(*)(void *))warn_acro, m_sprintf("%s", args[0]), NULL, NULL, "acro");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BUILT_IN_DLL(put_scores)
|
||||
{
|
||||
srec *stmp = NULL;
|
||||
if (scores) {
|
||||
put_it("Start Normal scores");
|
||||
for (stmp = scores; stmp; stmp = stmp->next)
|
||||
put_it("Nick: %s\tScore: %lu", stmp->nick, stmp->score);
|
||||
put_it("End scores");
|
||||
}
|
||||
/*
|
||||
if (gscores) {
|
||||
put_it("GLOBAL SCORES START HERE!");
|
||||
for (stmp = gscores; stmp; stmp = stmp->next)
|
||||
put_it("Nick: %s\tScore %lu", stmp->nick, stmp->score);
|
||||
put_it("GLOBAL SCORES END HERE!");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void warn_acro(char *chan)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :30 seconds! Puzzle is: %s", chan, game->nym);
|
||||
add_timer(0, "Acro", 30 * 1000, 1, (int(*)(void *))start_vote, m_sprintf("%s", chan), NULL, NULL, "acro");
|
||||
}
|
||||
|
||||
void start_vote(char *chan)
|
||||
{
|
||||
if (game->players >= MINPLAYERS)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :Time's up, lets vote!\r\nPRIVMSG %s :/msg %s \"acro #\" to vote", chan, chan, get_server_nickname(from_server));
|
||||
game->progress = 2;
|
||||
show_acros(player, chan);
|
||||
add_timer(0, "Acro", 30 * 1000, 1, (int(*)(void *))warn_vote, m_sprintf("%s", chan), NULL, NULL, "acro");
|
||||
}
|
||||
else if (game->extended < EXTENSIONS)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :Aww, too few players! Puzzle is: %s", chan, game->nym);
|
||||
add_timer(0, "Acro", 30 * 1000, 1, (int(*)(void *))start_vote, m_sprintf("%s", chan), NULL, NULL, "acro");
|
||||
game->extended++;
|
||||
}
|
||||
else
|
||||
{
|
||||
send_to_server("PRIVMSG %s :Not enough players, ending game...", chan);
|
||||
free_round(&player, &voter);
|
||||
game->players = 0;
|
||||
game->progress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void warn_vote(char *chan)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :30 seconds left to vote!", chan);
|
||||
add_timer(0, "Acro", 30 * 1000, 1, (int(*)(void *))end_voting, m_sprintf("%s", chan), NULL, NULL, "acro");
|
||||
}
|
||||
|
||||
void end_voting(char *chan)
|
||||
{
|
||||
put_it("END_VOTING");
|
||||
send_to_server("PRIVMSG %s :Voting complete, sorting scores...", chan);
|
||||
gscores = end_vote(voter, player, gscores);
|
||||
scores = end_vote(voter, player, scores);
|
||||
write_scores(gscores);
|
||||
show_scores(game, scores, gscores, chan);
|
||||
free_round(&player, &voter);
|
||||
if (player)
|
||||
{
|
||||
put_it("Player was non-null!!");
|
||||
player = NULL;
|
||||
}
|
||||
if (voter)
|
||||
{
|
||||
put_it("voter was non-null!!");
|
||||
voter = NULL;
|
||||
}
|
||||
if (game->round < game->rounds)
|
||||
{
|
||||
init_acro(game);
|
||||
send_to_server("PRIVMSG %s :Round %d", chan, game->round);
|
||||
send_to_server("PRIVMSG %s :The acronym for this round is %s. You have 60 seconds.", chan, game->nym);
|
||||
send_to_server("PRIVMSG %s :/msg %s \"acro <your answer>\"", chan, get_server_nickname(from_server));
|
||||
add_timer(0, "Acro", 60 * 1000, 1, (int(*)(void *))warn_acro, m_sprintf("%s", chan), NULL, NULL, "acro");
|
||||
}
|
||||
else
|
||||
{
|
||||
game->round = 1;
|
||||
game->progress = 0;
|
||||
free_score(&scores);
|
||||
new_free(&game->nym);
|
||||
init_acro(game);
|
||||
}
|
||||
}
|
||||
|
||||
grec *init_acro(grec *gtmp)
|
||||
{
|
||||
if (!gtmp)
|
||||
gtmp = (grec *)new_malloc(sizeof(grec));
|
||||
if (gtmp->nym)
|
||||
{
|
||||
gtmp->progress = 1;
|
||||
gtmp->round++;
|
||||
gtmp->players = 0;
|
||||
gtmp->extended = 0;
|
||||
new_free(>mp->nym);
|
||||
make_acro(gtmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtmp->progress = 0;
|
||||
gtmp->round = 1;
|
||||
gtmp->rounds = ROUNDS;
|
||||
gtmp->players = 0;
|
||||
gtmp->extended = 0;
|
||||
gtmp->top = TOP;
|
||||
gtmp->maxlen = MAXLEN;
|
||||
gtmp->nym = NULL;
|
||||
}
|
||||
return gtmp;
|
||||
}
|
||||
|
||||
void make_acro(grec *acro)
|
||||
{
|
||||
int i, r;
|
||||
char *p;
|
||||
if (acro->nym)
|
||||
new_free(&acro->nym);
|
||||
r = MINLENGTH+(int)((float) (1+MAXLENGTH-MINLENGTH)*random()/(RAND_MAX+1.0));
|
||||
p = acro->nym = (char *)new_malloc(r+1);
|
||||
for (i = 0; i < r; i++)
|
||||
*p++ = letters[(int)((float)(strlen(letters))*random()/(RAND_MAX+1.0))];
|
||||
return;
|
||||
}
|
||||
|
||||
int valid_acro(grec *acro, char *p)
|
||||
{
|
||||
int spaces = 0, len = 0, gotsp = 1;
|
||||
if (!p)
|
||||
return 0;
|
||||
if (!acro)
|
||||
return 0;
|
||||
for (; *p; p++)
|
||||
{
|
||||
if (isalpha(*p))
|
||||
{
|
||||
len++;
|
||||
if (gotsp && (toupper(*p) != acro->nym[spaces]))
|
||||
return 0;
|
||||
gotsp = 0;
|
||||
}
|
||||
else if (*p == 32)
|
||||
{
|
||||
if (!gotsp)
|
||||
{
|
||||
spaces++;
|
||||
gotsp = 1;
|
||||
}
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
if ((len > strlen(acro->nym)) && (spaces+1 == strlen(acro->nym)))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
prec *take_acro(grec *acro, prec *players, char *nick, char *host, char *stuff)
|
||||
{
|
||||
prec *tmp, *last = NULL;
|
||||
if (!players)
|
||||
{
|
||||
players = (prec *)new_malloc(sizeof(prec));
|
||||
players->nick = (char *)new_malloc(strlen(nick)+1);
|
||||
players->host = (char *)new_malloc(strlen(host)+1);
|
||||
players->acro = (char *)new_malloc(strlen(stuff)+1);
|
||||
strcpy(players->nick, nick);
|
||||
strcpy(players->host, host);
|
||||
strcpy(players->acro, stuff);
|
||||
send_to_server("PRIVMSG %s :Answer set to \"%s\"\r\nPRIVMSG %s :You are player #%d", nick, stuff, nick, ++acro->players);
|
||||
return players;
|
||||
}
|
||||
for (tmp = players; tmp; tmp = tmp->next)
|
||||
{
|
||||
if (tmp->host && !strcasecmp(host, tmp->host))
|
||||
{
|
||||
if (tmp->acro && !strcasecmp(stuff, tmp->acro))
|
||||
{
|
||||
send_to_server("PRIVMSG %s :Your answer is alreay \"%s\"", nick, stuff);
|
||||
return players;
|
||||
}
|
||||
else if (tmp->last && !strcasecmp(stuff, tmp->last))
|
||||
{
|
||||
RESIZE(tmp->acro, char, strlen(stuff)+1);
|
||||
strcpy(tmp->acro, stuff);
|
||||
send_to_server("PRIVMSG %s :Answer changed to \"%s\"", nick, stuff);
|
||||
new_free(&tmp->last);
|
||||
return players;
|
||||
}
|
||||
else {
|
||||
tmp->last = (char *)new_malloc(strlen(stuff)+1);
|
||||
strcpy(tmp->last, stuff);
|
||||
send_to_server("PRIVMSG %s :You already submitted an answer, submit once more to change.", nick);
|
||||
return players;
|
||||
}
|
||||
}
|
||||
last = tmp;
|
||||
}
|
||||
if (acro->players < MAXPLAYERS && last)
|
||||
{
|
||||
tmp = last->next = (prec *)new_malloc(sizeof(prec));
|
||||
tmp->nick = (char *)new_malloc(strlen(nick)+1);
|
||||
tmp->host = (char *)new_malloc(strlen(host)+1);
|
||||
tmp->acro = (char *)new_malloc(strlen(stuff)+1);
|
||||
strcpy(tmp->nick, nick);
|
||||
strcpy(tmp->host, host);
|
||||
strcpy(tmp->acro, stuff);
|
||||
send_to_server("PRIVMSG %s :Answer set to \"%s\"\r\nPRIVMSG %s :You are player #%d", nick, stuff, nick, ++acro->players);
|
||||
}
|
||||
else
|
||||
send_to_server("PRIVMSG %s :Sorry, too many players.", nick);
|
||||
return players;
|
||||
}
|
||||
|
||||
vrec *take_vote(grec *acro, vrec *voters, prec *players, char *nick, char *host, char *num)
|
||||
{
|
||||
vrec *tmp = NULL, *last = voters;
|
||||
int i;
|
||||
if (atoi(num) > acro->players || atoi(num) < 1)
|
||||
{
|
||||
send_to_server("PRIVMSG %s :No such answer...", nick);
|
||||
return voters;
|
||||
}
|
||||
for (i = 1; i < atoi(num); i++)
|
||||
players = players->next;
|
||||
if (players->nick && nick && !strcasecmp(players->nick, nick))
|
||||
{
|
||||
send_to_server("PRIVMSG %s :You can't vote for yourself.", nick);
|
||||
return voters;
|
||||
}
|
||||
if (!voters)
|
||||
{
|
||||
voters = (vrec *)new_malloc(sizeof(vrec));
|
||||
voters->nick = (char *)new_malloc(strlen(nick)+1);
|
||||
voters->host = (char *)new_malloc(strlen(host)+1);
|
||||
voters->vote = atoi(num)-1;
|
||||
strcpy(voters->nick, nick);
|
||||
strcpy(voters->host, host);
|
||||
send_to_server("PRIVMSG %s :Vote recorded...", nick);
|
||||
return voters;
|
||||
}
|
||||
for (tmp = voters; tmp; tmp = tmp->next)
|
||||
{
|
||||
if ((tmp->nick && !strcasecmp(tmp->nick, nick)) || (tmp->host && !strcasecmp(tmp->host, host)))
|
||||
{
|
||||
send_to_server("PRIVMSG %s :You already voted.", nick);
|
||||
return voters;
|
||||
}
|
||||
last = tmp;
|
||||
}
|
||||
if (last && !last->next)
|
||||
{
|
||||
last = last->next = (vrec *)new_malloc(sizeof(vrec));
|
||||
last->nick = (char *)new_malloc(strlen(nick)+1+sizeof(char *));
|
||||
last->host = (char *)new_malloc(strlen(host)+1+sizeof(char *));
|
||||
last->vote = atoi(num)-1;
|
||||
strcpy(last->nick, nick);
|
||||
strcpy(last->host, host);
|
||||
send_to_server("PRIVMSG %s :Vote recorded...", nick);
|
||||
}
|
||||
return voters;
|
||||
}
|
||||
|
||||
srec *read_scores()
|
||||
{
|
||||
srec *tmp, *tmp2;
|
||||
char buff[100], *p;
|
||||
FILE *sf;
|
||||
tmp = tmp2 = (srec *)new_malloc(sizeof(srec));
|
||||
memset(buff, 0, sizeof(buff));
|
||||
sf = fopen(SCOREFILE, "r");
|
||||
if (!sf)
|
||||
return 0;
|
||||
while (!feof(sf))
|
||||
{
|
||||
if (fgets(buff, 51, sf))
|
||||
{
|
||||
if (tmp->nick)
|
||||
tmp = tmp->next = (srec *)new_malloc(sizeof(srec));
|
||||
if (buff[strlen(buff)-1] == '\n')
|
||||
buff[strlen(buff)-1] = 0;
|
||||
if (!*buff)
|
||||
break;
|
||||
if ((p = (char *)strchr(buff, ',')))
|
||||
*p++ = 0;
|
||||
else if (!p)
|
||||
{
|
||||
return tmp2;
|
||||
fclose(sf);
|
||||
}
|
||||
tmp->nick = (char *)new_malloc(strlen(buff+1));
|
||||
strcpy(tmp->nick, buff);
|
||||
if (p)
|
||||
tmp->score = strtoul(p, NULL, 10);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
fclose(sf);
|
||||
return tmp2;
|
||||
}
|
||||
|
||||
int write_scores(srec *tmp)
|
||||
{
|
||||
FILE *sf;
|
||||
if (!tmp)
|
||||
return 0;
|
||||
tmp = sort_scores(tmp);
|
||||
sf = fopen(SCOREFILE, "w");
|
||||
if (!sf)
|
||||
return 0;
|
||||
for (; tmp; tmp = tmp->next)
|
||||
if (tmp->score > 0)
|
||||
fprintf(sf, "%s,%lu\n", tmp->nick, tmp->score);
|
||||
fclose(sf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we take the votes from the current round and translate them into
|
||||
* scores for the players. gscores is the score per game, while scores
|
||||
* is the overall score for all games... So we call it with a ptr to the
|
||||
* score record we want to update and it makes it more useful :)
|
||||
* The dual for () loop is probably inefficient, but its all I can think of
|
||||
* right now ;), besides we aren't talking about 10,000 members here
|
||||
|
||||
* Eventually I'll convert this to support variable arg lengths and thus
|
||||
* update for multiple scores with one call...
|
||||
* This function is a mess right now, I'll clean it up later.
|
||||
*/
|
||||
|
||||
srec *end_vote(vrec *voters, prec *players, srec *stmp)
|
||||
{
|
||||
int i, gotscore;
|
||||
vrec *tmp = NULL;
|
||||
prec *tmp2 = NULL;
|
||||
srec *tmp3 = NULL, *last;
|
||||
if (!stmp && voters && players)
|
||||
stmp = (srec *)new_malloc(sizeof(srec));
|
||||
for (tmp = voters; tmp; tmp = tmp->next)
|
||||
{
|
||||
gotscore = 0;
|
||||
tmp2 = players;
|
||||
for (i = 0; i < tmp->vote; i++)
|
||||
tmp2 = tmp2->next;
|
||||
if (stmp && !stmp->nick)
|
||||
{
|
||||
stmp->nick = (char *)new_malloc(strlen(tmp2->nick)+1);
|
||||
strcpy(stmp->nick, tmp2->nick);
|
||||
stmp->score = 1;
|
||||
continue;
|
||||
}
|
||||
for (tmp3 = last = stmp; tmp3; tmp3 = tmp3->next)
|
||||
{
|
||||
if (tmp2->nick && tmp3->nick && !strcasecmp(tmp2->nick, tmp3->nick))
|
||||
{
|
||||
tmp3->score++;
|
||||
gotscore = 1;
|
||||
break;
|
||||
}
|
||||
last = tmp3;
|
||||
}
|
||||
if (!gotscore)
|
||||
{
|
||||
tmp3 = last->next = (srec *)new_malloc(sizeof(srec));
|
||||
tmp3->nick = (char *)new_malloc(strlen(tmp2->nick)+1);
|
||||
strcpy(tmp3->nick, tmp2->nick);
|
||||
tmp3->score = 1;
|
||||
}
|
||||
}
|
||||
return stmp;
|
||||
}
|
||||
|
||||
srec *sort_scores(srec *stmp)
|
||||
{
|
||||
int i = 0;
|
||||
srec *tmp;
|
||||
srec **sort, **ctmp;
|
||||
if (!stmp->next)
|
||||
return stmp;
|
||||
for (tmp = stmp; tmp; tmp = tmp->next)
|
||||
i++;
|
||||
ctmp = sort = (srec **)new_malloc(i*sizeof(srec *));
|
||||
put_it("START SORTING");
|
||||
put_scores(NULL, NULL, NULL, NULL, NULL);
|
||||
for (tmp = stmp; tmp; tmp = tmp->next)
|
||||
*ctmp++ = tmp;
|
||||
qsort((void *)sort, i+1, sizeof(srec *), (int (*)(const void *, const void *))comp_score);
|
||||
ctmp = sort;
|
||||
for (tmp = *ctmp++; *ctmp; ctmp++)
|
||||
tmp = tmp->next = *ctmp;
|
||||
tmp->next = NULL;
|
||||
tmp = *sort;
|
||||
new_free(&sort);
|
||||
put_scores(NULL, NULL, NULL, NULL, NULL);
|
||||
put_it("END SCORES");
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we sort deeze babys ... The return values are "opposite" so we can
|
||||
* sort in descending order instead of ascending... Stupid declarations had
|
||||
* me going for a while, no wonder it didnt sort right at first! :)
|
||||
*/
|
||||
|
||||
int comp_score(srec **one, srec **two)
|
||||
{
|
||||
if ((*one)->score > (*two)->score)
|
||||
return -1;
|
||||
if ((*one)->score < (*two)->score)
|
||||
return 1;
|
||||
else
|
||||
return strcasecmp((*one)->nick, (*two)->nick);
|
||||
}
|
||||
|
||||
void show_acros(prec *players, char *chan)
|
||||
{
|
||||
prec *tmp;
|
||||
int i = 1;
|
||||
char *line, buff[201];
|
||||
if (!players)
|
||||
return;
|
||||
line = (char *)new_malloc(513);
|
||||
memset(buff, 0, sizeof(buff));
|
||||
for (tmp = players; tmp; tmp = tmp->next)
|
||||
{
|
||||
snprintf(buff, 198, "PRIVMSG %s :%2d: %s", chan, i++, tmp->acro);
|
||||
strcat(buff, "\r\n");
|
||||
if (strlen(line)+strlen(buff) >= 512)
|
||||
{
|
||||
send_to_server("%s", line);
|
||||
memset(line, 0, 513);
|
||||
}
|
||||
strcat(line, buff);
|
||||
memset(buff, 0, sizeof(buff));
|
||||
}
|
||||
if (line)
|
||||
send_to_server("%s", line);
|
||||
new_free(&line);
|
||||
}
|
||||
|
||||
void show_scores(grec *acro, srec *score, srec *gscore, char *chan)
|
||||
{
|
||||
char *line, buff[201];
|
||||
int i;
|
||||
line = (char *)new_malloc(513);
|
||||
memset(buff, 0, sizeof(buff));
|
||||
if (score)
|
||||
score = sort_scores(score);
|
||||
if (gscore && (acro->round >= acro->rounds))
|
||||
gscore = sort_scores(gscore);
|
||||
if (acro->round < acro->rounds)
|
||||
sprintf(line, "PRIVMSG %s :Scores for round %d\r\nPRIVMSG %s :Nick Score\r\nPRIVMSG %s :-----------------\r\n", chan, acro->round, chan, chan);
|
||||
else
|
||||
sprintf(line, "PRIVMSG %s :Game over, tallying final scores...\r\nPRIVMSG %s : Game Score Overall Score\r\nPRIVMSG %s :Nick Score Nick Score\r\nPRIVMSG %s :----------------- -----------------\r\n", chan, chan, chan, chan);
|
||||
for (i = 0; i < acro->top && (score || gscore); i++)
|
||||
{
|
||||
if ((acro->round < acro->rounds) && score)
|
||||
{
|
||||
snprintf(buff, 198, "PRIVMSG %s :%-9s %lu", chan, score->nick, score->score);
|
||||
strcat(buff, "\r\n");
|
||||
score = score->next;
|
||||
}
|
||||
else if (acro->round == acro->rounds && (score || gscore))
|
||||
{
|
||||
if (!score && gscore)
|
||||
{
|
||||
snprintf(buff, 198, "PRIVMSG %s : %-9s %lu", chan, gscore->nick, gscore->score);
|
||||
strcat(buff, "\r\n");
|
||||
gscore = gscore->next;
|
||||
}
|
||||
else if (score && !gscore)
|
||||
{
|
||||
snprintf(buff, 198, "PRIVMSG %s :%-9s %lu", chan, score->nick, score->score);
|
||||
strcat(buff, "\r\n");
|
||||
score = score->next;
|
||||
}
|
||||
else if (gscore && score)
|
||||
{
|
||||
snprintf(buff, 198, "PRIVMSG %s :%-9s %-5lu %-9s %lu", chan, score->nick, score->score, gscore->nick, gscore->score);
|
||||
strcat(buff, "\r\n");
|
||||
gscore = gscore->next;
|
||||
score = score->next;
|
||||
}
|
||||
}
|
||||
if (strlen(line)+strlen(buff) >= 512)
|
||||
{
|
||||
send_to_server("%s", line);
|
||||
memset(line, 0, 513);
|
||||
}
|
||||
strcat(line, buff);
|
||||
memset(buff, 0, sizeof(buff));
|
||||
}
|
||||
if (line)
|
||||
send_to_server("%s", line);
|
||||
new_free(&line);
|
||||
}
|
||||
|
||||
void free_round(prec **players, vrec **voters)
|
||||
{
|
||||
prec *ptmp, *ptmp2;
|
||||
vrec *vtmp, *vtmp2;
|
||||
if (players && *players) {
|
||||
for (ptmp = *players; ptmp;)
|
||||
{
|
||||
if (ptmp->nick)
|
||||
new_free(&ptmp->nick);
|
||||
if (ptmp->host)
|
||||
new_free(&ptmp->host);
|
||||
if (ptmp->acro)
|
||||
new_free(&ptmp->acro);
|
||||
if (ptmp->last)
|
||||
new_free(&ptmp->last);
|
||||
if (ptmp->next)
|
||||
ptmp2 = ptmp->next;
|
||||
else
|
||||
ptmp2 = NULL;
|
||||
new_free(&ptmp);
|
||||
ptmp = ptmp2;
|
||||
}
|
||||
*players = NULL;
|
||||
}
|
||||
if (voters && *voters) {
|
||||
for (vtmp = *voters; vtmp;)
|
||||
{
|
||||
if (vtmp->nick)
|
||||
new_free(&vtmp->nick);
|
||||
if (vtmp->host)
|
||||
new_free(&vtmp->host);
|
||||
if (vtmp->next)
|
||||
vtmp2 = vtmp->next;
|
||||
else
|
||||
vtmp2 = NULL;
|
||||
new_free(&vtmp);
|
||||
vtmp = vtmp2;
|
||||
}
|
||||
*voters = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void free_score(srec **score)
|
||||
{
|
||||
srec *stmp, *stmp2;
|
||||
for (stmp = *score; stmp;)
|
||||
{
|
||||
if (stmp->nick)
|
||||
new_free(&stmp->nick);
|
||||
if (stmp->next)
|
||||
stmp2 = stmp->next;
|
||||
else
|
||||
stmp2 = NULL;
|
||||
new_free(&stmp);
|
||||
stmp = stmp2;
|
||||
}
|
||||
*score = NULL;
|
||||
}
|
||||
116
dll/acro/acro.h
Normal file
116
dll/acro/acro.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "server.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "parse.h"
|
||||
#include "timer.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
/*
|
||||
* I put this here because pana said I should use it, but its commented out
|
||||
* in ircaux.h :)
|
||||
*/
|
||||
#ifndef new_realloc
|
||||
#define new_realloc(x,y) n_realloc((x),(y),__FILE__,__LINE__)
|
||||
#endif
|
||||
|
||||
#define MINPLAYERS 2 /* Minimum number of players per game */
|
||||
#define MAXPLAYERS 10 /* Max number of players per game */
|
||||
#define MINLENGTH 3 /* Minimum number of letters per acronym */
|
||||
#define MAXLENGTH 5 /* Max number of letters per acronym */
|
||||
#define ROUNDS 10 /* Number of rounds to play */
|
||||
#define EXTENSIONS 3 /* Max number of 30 second extensions */
|
||||
#define TOP 10 /* Show the top XX names for the scores */
|
||||
#define MAXLEN 15 /* Max number of characters per acro word */
|
||||
|
||||
/*
|
||||
* These must be "proper" paths -- ie the ENTIRE path must exist and there
|
||||
* are no expansion characters in there (IE ~ or $(HOME))
|
||||
*/
|
||||
|
||||
#define SCOREFILE ".BitchX/acro.score"
|
||||
#define WEBSCORE "acro.html"
|
||||
|
||||
/* prec -- a linked list containing all the player info */
|
||||
|
||||
typedef struct _prec {
|
||||
char *nick;
|
||||
char *host;
|
||||
char *acro;
|
||||
char *last;
|
||||
struct _prec *next;
|
||||
} prec;
|
||||
|
||||
/* vrec -- linked list storing voters, and who they voted for */
|
||||
|
||||
typedef struct _vrec {
|
||||
char *nick;
|
||||
char *host;
|
||||
int vote;
|
||||
struct _vrec *next;
|
||||
} vrec;
|
||||
|
||||
/* grec -- struct containing the info about the current game */
|
||||
|
||||
typedef struct {
|
||||
int progress;
|
||||
int round;
|
||||
int rounds;
|
||||
int players;
|
||||
int extended;
|
||||
int top;
|
||||
int maxlen;
|
||||
char *nym;
|
||||
} grec;
|
||||
|
||||
/* srec -- linked list of scores */
|
||||
|
||||
typedef struct _srec {
|
||||
char *nick;
|
||||
unsigned long score;
|
||||
struct _srec *next;
|
||||
} srec;
|
||||
|
||||
struct settings {
|
||||
int minplayers;
|
||||
int maxplayers;
|
||||
int minlength;
|
||||
int maxlength;
|
||||
int rounds;
|
||||
int extensions;
|
||||
int top;
|
||||
int maxlen;
|
||||
char *scorefile;
|
||||
char *webscore;
|
||||
};
|
||||
|
||||
static char letters[] = "ABCDEFGHIJKLMNOPRSTUVWY";
|
||||
|
||||
static int acro_main (char *, char *, char *, char **);
|
||||
int Acro_Init(IrcCommandDll **, Function_ptr *);
|
||||
BUILT_IN_DLL(put_scores);
|
||||
grec *init_acro(grec *);
|
||||
void make_acro(grec *);
|
||||
int valid_acro(grec *, char *);
|
||||
srec *read_scores(void);
|
||||
int write_scores(srec *);
|
||||
prec *take_acro(grec *, prec *, char *, char *, char *);
|
||||
vrec *take_vote(grec *, vrec *, prec *, char *, char *, char *);
|
||||
srec *end_vote(vrec *, prec *, srec *);
|
||||
srec *sort_scores(srec *);
|
||||
int comp_score(srec **one, srec **two);
|
||||
void show_scores(grec *, srec *, srec *, char *);
|
||||
void warn_acro(char *);
|
||||
void start_vote(char *);
|
||||
void warn_vote(char *);
|
||||
void end_voting(char *);
|
||||
void show_acros(prec *, char *);
|
||||
void free_round(prec **, vrec **);
|
||||
void free_score(srec **);
|
||||
/* static void game_setup _(( IrcCommandDll *, char *, char *, char *)); */
|
||||
32
dll/acro/acro.sh
Normal file
32
dll/acro/acro.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
RM=rm
|
||||
CP=cp
|
||||
|
||||
$GCC -I../../include -c acro.c
|
||||
|
||||
echo EXPORTS > acro.def
|
||||
$NM acro.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> acro.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file acro.base --dll -o acro.dll acro.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname acro.dll --def acro.def --base-file\
|
||||
acro.base --output-exp acro.exp
|
||||
$LD --base-file acro.base acro.exp --dll -o acro.dll acro.o\
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname acro.dll --def acro.def --base-file\
|
||||
acro.base --output-exp acro.exp
|
||||
$LD acro.exp --dll -o acro.dll acro.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the acroB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname acro.dll --def acro.def --output-lib acro.a
|
||||
$RM *.base *.exp *.def
|
||||
$CP *.dll ..
|
||||
199
dll/aim/Makefile.in
Normal file
199
dll/aim/Makefile.in
Normal file
@@ -0,0 +1,199 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
AIMDEFS = $(DEFS) -I$(srcdir)/toc
|
||||
|
||||
PLUGIN_NAME = aim
|
||||
|
||||
OBJS = toc.o util.o cmd.o aim.o compat.o
|
||||
|
||||
all: Makefile toc aim$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
compat.o: $(top_srcdir)/source/compat.c
|
||||
$(CC) $(AIMDEFS) $(SHLIB_CFLAGS) $(CFLAGS) \
|
||||
-c $(top_srcdir)/source/compat.c
|
||||
|
||||
toc.o: $(srcdir)/toc.c
|
||||
$(CC) $(AIMDEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/toc.c
|
||||
|
||||
util.o: $(srcdir)/util.c
|
||||
$(CC) $(AIMDEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/util.c
|
||||
|
||||
cmd.o: $(srcdir)/cmd.c
|
||||
$(CC) $(AIMDEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/cmd.c
|
||||
|
||||
aim.o: $(srcdir)/aim.c
|
||||
$(CC) $(AIMDEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/aim.c
|
||||
|
||||
aim$(SHLIB_SUFFIX): $(OBJS)
|
||||
$(SHLIB_LD) $(OBJS) $(SHLIB_CFLAGS) -o aim$(SHLIB_SUFFIX) -Ltoc -ltoc
|
||||
|
||||
dummy:
|
||||
|
||||
toc: dummy
|
||||
@(cd toc && $(MAKE) all)
|
||||
|
||||
clean:
|
||||
cd toc && $(MAKE) clean
|
||||
$(RM) *~ *.o *.so *.a *.dll *.def .#*
|
||||
|
||||
distclean: clean
|
||||
cd toc && $(MAKE) distclean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
7
dll/aim/README
Normal file
7
dll/aim/README
Normal file
@@ -0,0 +1,7 @@
|
||||
Quite a bit borrowed from the napster module written by panasync.
|
||||
libtoc (backened) was written (put together) by me also, and is mostly
|
||||
composed of code from gaim (see freshmeat).
|
||||
|
||||
bx.patch is a small patch to modify bx to allow custom module completion
|
||||
routines. If not patched, just remove -DBITCHX_PATCH from CFLAGS in the
|
||||
Makefile
|
||||
409
dll/aim/aim.c
Normal file
409
dll/aim/aim.c
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* AOL Instant Messanger Module for BitchX
|
||||
*
|
||||
* By Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* aim.c
|
||||
*
|
||||
* Window, Init, Cleanup, and Version Routines
|
||||
*/
|
||||
|
||||
|
||||
#include <irc.h>
|
||||
#include <struct.h>
|
||||
#include <hook.h>
|
||||
#include <ircaux.h>
|
||||
#include <output.h>
|
||||
#include <lastlog.h>
|
||||
#include <status.h>
|
||||
#include <vars.h>
|
||||
#include <window.h>
|
||||
#include <input.h>
|
||||
#include <module.h>
|
||||
#define INIT_MODULE
|
||||
#include <modval.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "toc.h"
|
||||
#include "aim.h"
|
||||
|
||||
|
||||
char *name = "aim";
|
||||
char *timer_id;
|
||||
|
||||
#ifdef BITCHX_PATCH
|
||||
struct tab_key_struct tks;
|
||||
|
||||
int do_aim_tabkey_overwrite(int x, char *p, int *c, char **s) {
|
||||
if ( get_dllint_var("aim_window") && current_window == get_window_by_name("AIM") )
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * get_next_buddy_complete() {
|
||||
char *bud = NULL;
|
||||
int a;
|
||||
LLE t;
|
||||
/*
|
||||
* This is about as badly written as humany possible
|
||||
* ^- some would say its even worse than that
|
||||
*/
|
||||
while ( 1 ) {
|
||||
if ( tks.list == 1 ) {
|
||||
/* We traverse the buddy list forwards */
|
||||
LL mems;
|
||||
if ( tks.pos > groups->items ) {
|
||||
break;
|
||||
}
|
||||
t = groups->head;
|
||||
for (a=0; a < tks.pos; a++)
|
||||
t = t->next;
|
||||
mems = ((struct group *)t->data)->members;
|
||||
if ( tks.subpos == -1 )
|
||||
tks.subpos = 1;
|
||||
if ( tks.subpos > mems->items ) {
|
||||
tks.pos++;
|
||||
continue;
|
||||
}
|
||||
t = mems->head;
|
||||
for (a=0; a<tks.subpos; a++)
|
||||
t = t->next;
|
||||
tks.subpos++;
|
||||
bud = t->key;
|
||||
break;
|
||||
} else {
|
||||
/* Traverse the msd'd them list in reverse (last msg'd = first completed) */
|
||||
t = msgdthem->head;
|
||||
tks.list = 0;
|
||||
/* If we haven't msg'd anyone yet, go through the buddy list */
|
||||
if ( msgdthem == NULL || msgdthem->items == 0) {
|
||||
debug_printf("msgdthem == null or has no items");
|
||||
tks.list = 1;
|
||||
tks.pos = 1;
|
||||
tks.subpos = -1;
|
||||
continue;
|
||||
}
|
||||
/* Initilization */
|
||||
if ( tks.pos == -1 ) {
|
||||
debug_printf("set tks.pos to %d",msgdthem->items);
|
||||
tks.pos = msgdthem->items;
|
||||
}
|
||||
for (a=0; a < tks.pos; a++) {
|
||||
t = t->next;
|
||||
}
|
||||
bud = t->key;
|
||||
debug_printf("tks.pos == %d name = %s",tks.pos,t->key);
|
||||
tks.pos--;
|
||||
/* No more msg'd them nicks, next call we switch over to buddy list */
|
||||
if ( tks.pos == 0 ) {
|
||||
tks.list = 1;
|
||||
tks.pos = 1;
|
||||
tks.subpos = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bud;
|
||||
}
|
||||
|
||||
char * aim_tabkey_overwrite(int x, char *p, int *c, char **s) {
|
||||
char *z = NULL;
|
||||
char *bud = NULL;
|
||||
char *t;
|
||||
(*c) = 0;
|
||||
|
||||
if ( state != STATE_ONLINE )
|
||||
return NULL;
|
||||
|
||||
bud = get_next_buddy_complete();
|
||||
|
||||
if ( bud == NULL )
|
||||
return NULL;
|
||||
debug_printf("bud = %s",bud);
|
||||
t = (char *) malloc(strlen(bud)+50);
|
||||
sprintf(t,"/amsg %s ",bud);
|
||||
m_s3cat(&z,space,t);
|
||||
(*c) = 1;
|
||||
return z;
|
||||
}
|
||||
|
||||
char * amsg_complete_func(int x, char *p, int *c, char **s) {
|
||||
/* statusprintf("x = %d",x); */
|
||||
char *z = NULL;
|
||||
char *inp;
|
||||
int wc;
|
||||
LLE g,m;
|
||||
LL l;
|
||||
(*c) = 0;
|
||||
if ( state != STATE_ONLINE )
|
||||
return NULL;
|
||||
|
||||
|
||||
l = CreateLL();
|
||||
|
||||
debug_printf("possible = '%s' len = %d",p,strlen(p));
|
||||
inp = m_strdup( get_input() ? get_input() : empty_string);
|
||||
wc = word_count(inp);
|
||||
debug_printf("input = %s wc = %d",inp,wc);
|
||||
new_free(&inp);
|
||||
if ( wc > 2 )
|
||||
return NULL;
|
||||
|
||||
/* First go through people we've msg'd already */
|
||||
for ( TLL(msgdus,g) ) {
|
||||
if ( p && my_strnicmp(p, g->key, strlen(p)) )
|
||||
continue;
|
||||
AddToLL(l,g->key,NULL);
|
||||
}
|
||||
|
||||
/* Then people who msg'd us */
|
||||
for ( TLL(msgdthem,g) ) {
|
||||
if ( p && my_strnicmp(p, g->key, strlen(p)) )
|
||||
continue;
|
||||
if ( ! FindInLL(l,g->key) )
|
||||
AddToLL(l,g->key,NULL);
|
||||
}
|
||||
|
||||
/* And last, the Buddy */
|
||||
for ( TLL(groups,g) ) {
|
||||
struct group *grp = (struct group *)g->data;
|
||||
for ( TLL(grp->members,m) ) {
|
||||
struct buddy *bud = (struct buddy *)m->data;
|
||||
if ( p && my_strnicmp(p, bud->name, strlen(p)) )
|
||||
continue;
|
||||
if ( ! FindInLL(l,bud->name) )
|
||||
AddToLL(l,bud->name,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if ( l->items == 1 && ! strcasecmp(l->head->next->key,p) ) {
|
||||
char *bud = NULL;
|
||||
(*c) = 1;
|
||||
bud = get_next_buddy_complete();
|
||||
debug_printf("We are going to go to get_next_buddy_comp!");
|
||||
if ( bud )
|
||||
m_s3cat(&z,space,bud);
|
||||
else
|
||||
debug_printf("set z to null because bud is null");
|
||||
} else {
|
||||
for( TLL(l,g) ) {
|
||||
(*c)++;
|
||||
debug_printf("adding %s",g->key);
|
||||
m_s3cat(&z,space,g->key);
|
||||
}
|
||||
}
|
||||
|
||||
debug_printf("in test func!, p = %s",p);
|
||||
FreeLL(l);
|
||||
return (z);
|
||||
}
|
||||
#endif /* BITCHX_PATCH */
|
||||
|
||||
/* Window code, straight from nap module by panasync */
|
||||
|
||||
void update_aim_window(Window *tmp) {
|
||||
char statbuff[1024];
|
||||
char st[1024];
|
||||
char *t;
|
||||
char s[80];
|
||||
int numbuds_online, numbuds_total;
|
||||
|
||||
if ( state == STATE_ONLINE ) {
|
||||
t= ctime(&login_time);
|
||||
t[strlen(t)-6] = '\0'; /* remove \n, year, & space -- NOT Y10K READY !@! */
|
||||
sprintf(st,"Online since: %s", t);
|
||||
} else
|
||||
strcpy(st,"Offline");
|
||||
|
||||
if ( is_idle ) {
|
||||
strcpy(s,"(Idle)");
|
||||
} else if ( is_away ) {
|
||||
strcpy(s,"(Away)");
|
||||
} else {
|
||||
strcpy(s,"");
|
||||
}
|
||||
|
||||
/* Find the number of buddies online */
|
||||
numbuds_online = numbuds_total = 0;
|
||||
if ( groups != NULL ) {
|
||||
LLE g,b;
|
||||
struct group *grp;
|
||||
struct buddy *bud;
|
||||
for ( TLL(groups,g) ) {
|
||||
grp = (struct group *) g->data;
|
||||
numbuds_total += grp->members->items;
|
||||
for( TLL(grp->members,b) ) {
|
||||
bud = (struct buddy *) b->data;
|
||||
if ( bud->present)
|
||||
numbuds_online++;
|
||||
}
|
||||
}
|
||||
}
|
||||
sprintf(statbuff, "[1;45m Buddies: %d/%d Lag: %d Evil: %d %s %%>%s ", numbuds_online, numbuds_total,(lag_ms / 1000000),my_evil,s,st);
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT1_WSET, statbuff);
|
||||
|
||||
sprintf(statbuff, "[1;45m %%>%s ", st);
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT2_WSET, statbuff);
|
||||
|
||||
update_window_status(tmp, 1);
|
||||
}
|
||||
|
||||
int build_aim_status(Window *tmp)
|
||||
{
|
||||
Window *tmp1;
|
||||
if (!(tmp1 = tmp))
|
||||
tmp1 = get_window_by_name("AIM");
|
||||
if (tmp1)
|
||||
{
|
||||
update_aim_window(tmp1);
|
||||
build_status(tmp1, NULL, 0);
|
||||
update_all_windows();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void toggle_aimwin_hide (Window *win, char *unused, int onoff) {
|
||||
Window *tmp;
|
||||
if ((tmp = get_window_by_name("AIM")))
|
||||
{
|
||||
if (onoff)
|
||||
{
|
||||
if (tmp->screen)
|
||||
hide_window(tmp);
|
||||
build_aim_status(tmp);
|
||||
update_all_windows();
|
||||
cursor_to_input();
|
||||
}
|
||||
else
|
||||
{
|
||||
show_window(tmp);
|
||||
resize_window(2, tmp, 6);
|
||||
build_aim_status(tmp);
|
||||
update_all_windows();
|
||||
cursor_to_input();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void toggle_aimwin (Window *win, char *unused, int onoff){
|
||||
Window *tmp;
|
||||
if (onoff)
|
||||
{
|
||||
if ((tmp = get_window_by_name("AIM")))
|
||||
return;
|
||||
if ((tmp = new_window(win->screen)))
|
||||
{
|
||||
resize_window(2, tmp, 6);
|
||||
tmp->name = m_strdup("AIM");
|
||||
#undef query_cmd
|
||||
tmp->query_cmd = m_strdup("asay");
|
||||
tmp->double_status = 0;
|
||||
tmp->absolute_size = 1;
|
||||
tmp->update_status = update_aim_window;
|
||||
tmp->server = -2;
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT1_WSET, NULL);
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT2_WSET, NULL);
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT3_WSET, NULL);
|
||||
set_wset_string_var(tmp->wset, STATUS_FORMAT_WSET, NULL);
|
||||
|
||||
if (get_dllint_var("aim_window_hidden"))
|
||||
hide_window(tmp);
|
||||
else
|
||||
set_screens_current_window(tmp->screen, tmp);
|
||||
build_aim_status(tmp);
|
||||
update_all_windows();
|
||||
cursor_to_input();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((tmp = get_window_by_name("AIM")))
|
||||
{
|
||||
if (tmp == target_window)
|
||||
target_window = NULL;
|
||||
delete_window(tmp);
|
||||
update_all_windows();
|
||||
cursor_to_input();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *Aim_Version(IrcCommandDll *intp) {
|
||||
return AIM_VERSION;
|
||||
}
|
||||
|
||||
int Aim_Cleanup(IrcCommandDll **interp, Function_ptr *global_table) {
|
||||
if ( state == STATE_ONLINE )
|
||||
toc_signoff();
|
||||
#ifdef BITCHX_PATCH
|
||||
overwrite_tabkey_comp(NULL,NULL);
|
||||
debug_printf("Didn't remove completions, thats probably gonna cause problems");
|
||||
#endif
|
||||
remove_module_proc(VAR_PROC, name, NULL, NULL);
|
||||
remove_module_proc(COMMAND_PROC,name,NULL,NULL);
|
||||
remove_module_proc(ALIAS_PROC,name,NULL,NULL);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
int Aim_Init(IrcCommandDll **interp, Function_ptr *global_table) {
|
||||
char buffer[BIG_BUFFER_SIZE+1];
|
||||
char *p;
|
||||
initialize_module(name);
|
||||
|
||||
add_module_proc(VAR_PROC, name, "aim_user", NULL, STR_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_pass", NULL, STR_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_prompt", (char *)convert_output_format("%K[%YAIM%K]%n ", NULL, NULL), STR_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_permdeny_mode", NULL, INT_TYPE_VAR, 1, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_toc_host", TOC_HOST, STR_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_toc_port", NULL, INT_TYPE_VAR, TOC_PORT, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_auth_host", AUTH_HOST, STR_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_auth_port", NULL, INT_TYPE_VAR, AUTH_PORT, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_permdeny_mode", NULL, INT_TYPE_VAR, 1, NULL, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_minutes_to_idle", NULL, INT_TYPE_VAR, time_to_idle/60, achange_idle, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_window", NULL, BOOL_TYPE_VAR, 0, toggle_aimwin, NULL);
|
||||
add_module_proc(VAR_PROC, name, "aim_window_hidden", NULL, BOOL_TYPE_VAR, 0, toggle_aimwin_hide, NULL);
|
||||
|
||||
|
||||
add_module_proc(COMMAND_PROC, name, "amsg", "amsg", 0, 0, amsg, "<screen name|buddy chat> <message> instant messages");
|
||||
add_module_proc(COMMAND_PROC, name, "asignon", "asignon", 0, 0, asignon, "logs into aol instant messanger");
|
||||
add_module_proc(COMMAND_PROC, name, "asignoff", "asignoff", 0, 0, asignoff, "logs off of aol instant messanger");
|
||||
add_module_proc(COMMAND_PROC, name, "abl", "abl", 0, 0, abl, "<command> <args...> Modify your buddy list\n/abl show -- Shows buddy list\n/abl add [group] <buddy> -- Adds buddy to group in buddy list\n/abl del <buddy> Removes buddy from buddy llist\n/abl addg <group> Create group group\n/abl delg <group> <newgroup|1> delete group group");
|
||||
add_module_proc(COMMAND_PROC, name, "apd", "apd", 0, 0, apd, "<command> <args...> Modify your permit/deny lists\n/apd show -- Shows your permit & deny list\n/apd mode <permitall|denyall|permitsome|denysome> -- change your mode\n/apd addp <sn> -- Adds sn to your permit list\n/apd delp <sn> -- Removes sn from your permit list\n/apd addd <sn> -- Adds <sn> to your deny list\n/apd deld <sn> -- Removes sn from your deny list");
|
||||
add_module_proc(COMMAND_PROC, name, "adir", "adir", 0, 0, adir, "<command> <args...> Use the user directory\n/adir get <sn> Get sn's dir info\n/adir search -- Not implemented yet\n/adir set <first name> <middle name> <last name> <maiden name> <city> <state> <country> <email> <allow web searches? 1|0>");
|
||||
add_module_proc(COMMAND_PROC, name, "awarn", "awarn", 0, 0, awarn, "<aim screen name> [anon] warns user");
|
||||
add_module_proc(COMMAND_PROC, name, "awhois", "awhois", 0, 0, awhois, "<screen name> displays info on sn (sn has to be in buddy list)");
|
||||
add_module_proc(COMMAND_PROC, name, "asave", "asave", 0, 0, asave, "Saves AIM settings");
|
||||
add_module_proc(COMMAND_PROC, name, "asay", "asay", 0, 0, achat, "<message> send a message to the current buddy chat");
|
||||
add_module_proc(COMMAND_PROC, name, "apart", "apart", 0, 0, achat, "<buddy chat> leave buddy chat");
|
||||
add_module_proc(COMMAND_PROC, name, "ajoin", "ajoin", 0, 0, achat, "<buddy chat> join buddy chat (first searches invite list, if its in it then joins that one, otherwise creats anew)");
|
||||
add_module_proc(COMMAND_PROC, name, "achats", "achats", 0, 0, achat, "display buddy chats you are on");
|
||||
add_module_proc(COMMAND_PROC, name, "ainvite", "ainvite", 0, 0, achat, "<screen name> <buddy chat> <msg> invite user to buddy chat with msg");
|
||||
add_module_proc(COMMAND_PROC, name, "anames", "anames", 0, 0, achat, "<buddy chat>");
|
||||
add_module_proc(COMMAND_PROC, name, "acwarn", "acwarn", 0, 0, achat, "<buddy chat> <screen name> <anon>");
|
||||
add_module_proc(COMMAND_PROC, name, "aaway", "aaway", 0, 0, aaway, "<away msg> Go away or come back if away");
|
||||
add_module_proc(COMMAND_PROC, name, "aquery", "aquery", 0, 0, aquery, "query user");
|
||||
add_module_proc(COMMAND_PROC, name, "ainfo", "ainfo", 0, 0, ainfo, "<command> <args>\n/ainfo set <your info...> Sets your info\n/ainfo get <screen name> Retreives sn's info");
|
||||
|
||||
#ifdef BITCHX_PATCH
|
||||
add_completion_type("amsg", 2, CUSTOM_COMPLETION, &amsg_complete_func);
|
||||
overwrite_tabkey_comp(&do_aim_tabkey_overwrite,&aim_tabkey_overwrite);
|
||||
#endif
|
||||
|
||||
statusprintf("Aol Instant Messanger Module Loaded");
|
||||
sprintf(buffer, "$0+AIM %s by panasync - $2 $3", AIM_VERSION);
|
||||
fset_string_var(FORMAT_VERSION_FSET, buffer);
|
||||
snprintf(buffer, BIG_BUFFER_SIZE, "%s/AIM.sav", get_string_var(CTOOLZ_DIR_VAR));
|
||||
p = expand_twiddle(buffer);
|
||||
load("LOAD", p, empty_string, NULL);
|
||||
new_free(&p);
|
||||
bx_init_toc();
|
||||
return 0;
|
||||
}
|
||||
88
dll/aim/aim.h
Normal file
88
dll/aim/aim.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef _AIM_H
|
||||
#define _AIM_H
|
||||
|
||||
#define AIM_VERSION "0.02"
|
||||
#define AIM_DEBUG_LOG "/tmp/aim-bx.log"
|
||||
|
||||
/* Twice the actual length, we should never have problems */
|
||||
#define MAX_STATUS_MSG_LEN 4096
|
||||
#define cparse convert_output_format
|
||||
|
||||
/* Macro Fun */
|
||||
#define CHECK_TOC_ONLINE() if ( state != STATE_ONLINE ) { statusprintf("Please connect to aim first (/asignon)"); return; }
|
||||
#define VALID_ARG(x) !(!x || ! *x || ! strcasecmp(x,""))
|
||||
#define REQUIRED_ARG(x,y,z) if ( ! VALID_ARG(x) ) { userage(y,z); return; }
|
||||
|
||||
|
||||
/* cmd.c */
|
||||
|
||||
void asignon(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg);
|
||||
void asignoff(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void abl(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg);
|
||||
void apd(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg);
|
||||
void awarn(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void apermdeny(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void aspermdeny(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void aarpermitdeny(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void awhois(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void asave (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void achat (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void adir (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void aaway (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg);
|
||||
void aquery(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg);
|
||||
void ainfo(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg);
|
||||
void achange_idle(Window *w, char *s, int i);
|
||||
|
||||
extern char current_chat[512];
|
||||
extern char away_message[2048];
|
||||
extern LL msgdus;
|
||||
extern LL msgdthem;
|
||||
|
||||
|
||||
/* toc.c */
|
||||
void bx_init_toc();
|
||||
int toc_add_input_stream(int fd,int (*func)(int));
|
||||
int toc_remove_input_stream(int fd) ;
|
||||
int toc_main_interface(int type, char **args);
|
||||
int toc_timer(int type, char **args);
|
||||
|
||||
extern void (*chatprintf)(char *, ...);
|
||||
|
||||
|
||||
/* aim.c */
|
||||
#ifdef BITCHX_PATCH
|
||||
char * amsg_complete_func(int, char *, int *, char **);
|
||||
char * get_next_buddy_complete();
|
||||
int do_aim_tabkey_overwrite(int x, char *p, int *c, char **s);
|
||||
char * aim_tabkey_overwrite(int x, char *p, int *c, char **s);
|
||||
#endif
|
||||
void update_aim_window(Window *tmp);
|
||||
int build_aim_status(Window *tmp);
|
||||
void toggle_aimwin_hide (Window *win, char *unused, int onoff);
|
||||
void toggle_aimwin (Window *win, char *unused, int onoff);
|
||||
int Aim_Cleanup(IrcCommandDll **interp, Function_ptr *global_table);
|
||||
int Aim_Init(IrcCommandDll **interp, Function_ptr *global_table);
|
||||
char *Aim_Version(IrcCommandDll *intp);
|
||||
|
||||
extern char *name;
|
||||
extern char *timer_id;
|
||||
#ifdef BITCHX_PATCH
|
||||
struct tab_key_struct {
|
||||
int list;
|
||||
int pos;
|
||||
int subpos;
|
||||
};
|
||||
extern struct tab_key_struct tks;
|
||||
#endif
|
||||
|
||||
|
||||
/* util.c */
|
||||
|
||||
void statusprintf(char *fmt, ...);
|
||||
void statusput(int log_type, char *buf);
|
||||
void msgprintf(char *fmt, ...);
|
||||
void debug_printf(char *fmt, ...);
|
||||
char *rm_space(char *s);
|
||||
|
||||
#endif /* _AIM_H */
|
||||
294
dll/aim/bx.patch
Normal file
294
dll/aim/bx.patch
Normal file
@@ -0,0 +1,294 @@
|
||||
--- .//dll/fserv/fserv.c.orig Tue Jan 18 21:00:07 2000
|
||||
+++ .//dll/fserv/fserv.c Tue Jan 18 21:00:19 2000
|
||||
@@ -1162,7 +1162,7 @@
|
||||
add_module_proc(HOOK_PROC, "Fserv", NULL, "*", MSG_LIST, 1, NULL, search_proc);
|
||||
add_module_proc(HOOK_PROC, "Fserv", NULL, "*", PUBLIC_OTHER_LIST, 1, NULL, search_proc);
|
||||
|
||||
- add_completion_type("fsload", 3, FILE_COMPLETION);
|
||||
+ add_completion_type("fsload", 3, FILE_COMPLETION,NULL);
|
||||
|
||||
add_timer(0, empty_string, get_dllint_var("fserv_time"), 1, impress_me, NULL, NULL, -1, "fserv");
|
||||
strcpy(FSstr, cparse(FS, NULL, NULL));
|
||||
@@ -1177,4 +1177,4 @@
|
||||
put_it("%s for help with this fserv, /fshelp", FSstr);
|
||||
return 0;
|
||||
}
|
||||
-
|
||||
\ No newline at end of file
|
||||
+
|
||||
--- .//dll/nap/nap.c.orig Wed Jan 19 14:17:52 2000
|
||||
+++ .//dll/nap/nap.c Tue Jan 18 21:01:34 2000
|
||||
@@ -2139,8 +2139,8 @@
|
||||
add_module_proc(VAR_PROC, nap_name, "napster_format", NULL, STR_TYPE_VAR, 0, set_numeric_string, NULL);
|
||||
add_module_proc(VAR_PROC, nap_name, "napster_dir", NULL, STR_TYPE_VAR, 0, NULL, NULL);
|
||||
|
||||
- add_completion_type("nload", 4, FILE_COMPLETION);
|
||||
- add_completion_type("nreload", 4, FILE_COMPLETION);
|
||||
+ add_completion_type("nload", 4, FILE_COMPLETION,NULL);
|
||||
+ add_completion_type("nreload", 4, FILE_COMPLETION,NULL);
|
||||
|
||||
naphelp(NULL, NULL, NULL, NULL, NULL);
|
||||
sprintf(buffer, "$0+Napster %s by panasync - $2 $3", nap_version);
|
||||
--- .//include/module.h.orig Tue Jan 18 01:24:49 2000
|
||||
+++ .//include/module.h Tue Jan 18 20:29:36 2000
|
||||
@@ -633,7 +633,14 @@
|
||||
CHECK_EXT_MAIL,
|
||||
DEFAULT_OUTPUT_FUNCTION,
|
||||
DEFAULT_STATUS_OUTPUT_FUNCTION,
|
||||
- NUMBER_OF_GLOBAL_FUNCTIONS
|
||||
+ NUMBER_OF_GLOBAL_FUNCTIONS,
|
||||
+
|
||||
+/* window.c again */
|
||||
+ WINDOW_QUERY,
|
||||
+
|
||||
+/* input.c again */
|
||||
+
|
||||
+ OVERWRITE_TABKEY_COMP
|
||||
};
|
||||
|
||||
extern Function_ptr global_table[];
|
||||
--- .//include/modval.h.orig Tue Jan 18 16:50:22 2000
|
||||
+++ .//include/modval.h Tue Jan 18 20:28:58 2000
|
||||
@@ -360,7 +360,8 @@
|
||||
#define getnextnick(x, y, z, a) ((NickTab *) (global[GETNEXTNICK]((int)x, (char *)y, (char *)z, (char *)a)))
|
||||
#define getchannick(x, y) ((char *) (global[GETCHANNICK]((char *)x, (char *)y)))
|
||||
#define lookup_nickcompletion(x, y) ((NickList *) (global[LOOKUP_NICKCOMPLETION]((ChannelList *)x, (char *)y)))
|
||||
-#define add_completion_type(x, y, z) ((int) (global[ADD_COMPLETION_TYPE]((char *)x, (int)y, (enum completion)z)))
|
||||
+#define add_completion_type(x, y, z, a) ((int) (global[ADD_COMPLETION_TYPE]((char *)x, (int)y, (enum completion)z, a)))
|
||||
+#define overwrite_tabkey_comp(a,b) (global[OVERWRITE_TABKEY_COMP](a,b))
|
||||
|
||||
/* names.c */
|
||||
#define is_channel(x) ((int) (global[IS_CHANNEL]((char *)x)))
|
||||
--- .//include/input.h.orig Tue Jan 18 16:23:49 2000
|
||||
+++ .//include/input.h Thu Jan 20 17:05:28 2000
|
||||
@@ -157,11 +157,15 @@
|
||||
DCC_COMPLETION,
|
||||
LOAD_COMPLETION,
|
||||
SERVER_COMPLETION,
|
||||
- CDCC_COMPLETION
|
||||
+ CDCC_COMPLETION,
|
||||
+ CUSTOM_COMPLETION,
|
||||
+ TABKEY_OVERWRITE
|
||||
};
|
||||
|
||||
- char *get_completions (enum completion, char *, int *, char **);
|
||||
- int add_completion_type (char *, int, enum completion);
|
||||
+ char *get_completions (enum completion *, char *, int *, char **, char * (*)(int, char *, int *, char **));
|
||||
+ int add_completion_type (char *, int, enum completion, char * (*)(int, char *, int *, char **));
|
||||
+
|
||||
+void overwrite_tabkey_comp(int (*)(int, char *, int *, char **), char * (*)(int, char *, int *, char **));
|
||||
|
||||
extern NickTab *tabkey_array;
|
||||
extern NickTab *autoreply_array;
|
||||
--- .//source/modules.c.orig Tue Jan 18 01:38:07 2000
|
||||
+++ .//source/modules.c Tue Jan 18 20:53:49 2000
|
||||
@@ -423,6 +423,7 @@
|
||||
global_table[RECALCULATE_WINDOW_CURSOR] = (Function_ptr) recalculate_window_cursor;
|
||||
global_table[MAKE_WINDOW_CURRENT] = (Function_ptr) make_window_current;
|
||||
global_table[CLEAR_SCROLLBACK] = (Function_ptr) clear_scrollback;
|
||||
+ global_table[WINDOW_QUERY] = (Function_ptr) window_query;
|
||||
|
||||
global_table[RESET_DISPLAY_TARGET] = (Function_ptr) reset_display_target;
|
||||
global_table[SET_DISPLAY_TARGET] = (Function_ptr) set_display_target;
|
||||
@@ -475,6 +476,7 @@
|
||||
global_table[GETCHANNICK] = (Function_ptr) getchannick;
|
||||
global_table[LOOKUP_NICKCOMPLETION] = (Function_ptr) lookup_nickcompletion;
|
||||
global_table[ADD_COMPLETION_TYPE] = (Function_ptr) add_completion_type;
|
||||
+ global_table[OVERWRITE_TABKEY_COMP] = (Function_ptr) overwrite_tabkey_comp;
|
||||
|
||||
/* names.c */
|
||||
global_table[IS_CHANOP] = (Function_ptr) is_chanop;
|
||||
--- .//source/input.c.orig Tue Jan 18 15:58:30 2000
|
||||
+++ .//source/input.c Thu Jan 20 20:10:02 2000
|
||||
@@ -62,6 +62,9 @@
|
||||
NickTab *tabkey_array = NULL, *autoreply_array = NULL;
|
||||
|
||||
|
||||
+int (*do_over_write_tabkey_complete)(int, char *, int *, char **) = NULL;
|
||||
+char * (*over_write_tabkey_complete_func)(int, char *, int *, char **) = NULL;
|
||||
+
|
||||
|
||||
const int WIDTH = 10;
|
||||
|
||||
@@ -2119,7 +2122,8 @@
|
||||
struct _ext_name_type *next;
|
||||
char *name;
|
||||
int len;
|
||||
- enum completion type;
|
||||
+ enum completion type;
|
||||
+ char * (*comp_func)(int, char *, int *, char **);
|
||||
} Ext_Name_Type;
|
||||
|
||||
Ext_Name_Type *ext_completion = NULL;
|
||||
@@ -2161,7 +2165,14 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-char *get_completions(enum completion type, char *possible, int *count, char **suggested)
|
||||
+void overwrite_tabkey_comp(int (*check)(int, char *, int *, char **) , char * (*overwrite)(int, char *, int *, char **) )
|
||||
+{
|
||||
+ do_over_write_tabkey_complete = check;
|
||||
+ over_write_tabkey_complete_func = overwrite;
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+char *get_completions(enum completion *t, char *possible, int *count, char **suggested, char * (*cf)(int, char *, int *, char **))
|
||||
{
|
||||
char *booya = NULL;
|
||||
char *path = NULL;
|
||||
@@ -2169,6 +2180,7 @@
|
||||
glob_t globbers;
|
||||
int numglobs = 0, i;
|
||||
int globtype = GLOB_MARK;
|
||||
+enum completion type = *t;
|
||||
|
||||
#if defined(__EMX__) || defined(WINNT)
|
||||
if (possible && *possible)
|
||||
@@ -2191,6 +2203,18 @@
|
||||
case TABKEY_COMPLETION:
|
||||
{
|
||||
NickTab *n = tabkey_array;
|
||||
+ /*
|
||||
+ * bad hack
|
||||
+ * better idea would be to make this into a list
|
||||
+ * and allow multiple modules to create over writes
|
||||
+ * then, go to the first module that says it wants to
|
||||
+ * do a tab_complete
|
||||
+ */
|
||||
+ if ( do_over_write_tabkey_complete != NULL && over_write_tabkey_complete_func != NULL && do_over_write_tabkey_complete((int) type, possible, count, suggested) ) {
|
||||
+ *t = TABKEY_OVERWRITE;
|
||||
+ return over_write_tabkey_complete_func((int) type, possible, count, suggested);
|
||||
+ }
|
||||
+ /* put_it("opted not do!"); */
|
||||
*count = 0;
|
||||
if (possible)
|
||||
{
|
||||
@@ -2377,6 +2401,18 @@
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
+ case CUSTOM_COMPLETION:
|
||||
+ {
|
||||
+ char *c;
|
||||
+ if ( cf == NULL ) {
|
||||
+ return NULL;
|
||||
+ /* put_it("CF IS NULL!"); */
|
||||
+ }
|
||||
+ c = cf((int)type, possible, count ,suggested);
|
||||
+ /* put_it(c); */
|
||||
+ return c;
|
||||
+ break;
|
||||
+ }
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -2507,6 +2543,7 @@
|
||||
int got_space = 0;
|
||||
char *get = NULL;
|
||||
Ext_Name_Type *extcomp = ext_completion;
|
||||
+char * (*cf)(int, char *, int *, char **) = NULL;
|
||||
|
||||
/*
|
||||
* is this the != second word, then just complete from the
|
||||
@@ -2597,6 +2634,7 @@
|
||||
case CDCC:
|
||||
if (wcount == 2 || wcount == 3)
|
||||
type = CDCC_COMPLETION;
|
||||
+
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -2609,6 +2647,7 @@
|
||||
if (!my_strnicmp(p, extcomp->name, extcomp->len))
|
||||
{
|
||||
type = extcomp->type;
|
||||
+ cf = extcomp->comp_func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2628,7 +2667,7 @@
|
||||
#endif
|
||||
do_more_tab:
|
||||
count = 0;
|
||||
- if ((get = get_completions(type, possible, &count, &suggested)))
|
||||
+ if ((get = get_completions(&type, possible, &count, &suggested, cf)))
|
||||
{
|
||||
char buffer[BIG_BUFFER_SIZE+1];
|
||||
char *p = NULL;
|
||||
@@ -2640,8 +2679,11 @@
|
||||
p = extract(get_input(), 0, wcount - 2);
|
||||
else if (suggested && *suggested)
|
||||
p = m_3dup("/", suggested, "");
|
||||
- if (type == TABKEY_COMPLETION)
|
||||
+
|
||||
+ if (type == TABKEY_COMPLETION)
|
||||
snprintf(buffer, BIG_BUFFER_SIZE, "%s %s%s%s ", (p && *p == '/') ? p : "/m", get, (p && (*p != '/'))?space:empty_string, (p && (*p != '/'))?p:empty_string);
|
||||
+ else if ( type == TABKEY_OVERWRITE )
|
||||
+ snprintf(buffer, BIG_BUFFER_SIZE, "%s",get);
|
||||
else
|
||||
{
|
||||
if (wcount == 1 && got_space)
|
||||
@@ -2729,10 +2771,11 @@
|
||||
case SERVER_COMPLETION:
|
||||
case TABKEY_COMPLETION:
|
||||
case CHAN_COMPLETION:
|
||||
+ case CUSTOM_COMPLETION:
|
||||
{
|
||||
char *n, *use = get;
|
||||
n = new_next_arg(use, &use);
|
||||
- count = 0;
|
||||
+ count = 0;
|
||||
while (n && *n)
|
||||
{
|
||||
strmcat(buffer, n, BIG_BUFFER_SIZE);
|
||||
@@ -2750,6 +2793,7 @@
|
||||
put_it("%s", convert_output_format(fget_string_var(FORMAT_COMPLETE_FSET),"%s", buffer));
|
||||
break;
|
||||
}
|
||||
+ case TABKEY_OVERWRITE:
|
||||
case NO_COMPLETION:
|
||||
break;
|
||||
default:
|
||||
@@ -2776,15 +2820,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
-int add_completion_type(char *name, int len, enum completion type)
|
||||
+int add_completion_type(char *name, int len, enum completion type, char * (*cf)(int, char *, int *, char **))
|
||||
{
|
||||
-Ext_Name_Type *new;
|
||||
+ Ext_Name_Type *new;
|
||||
if (!find_in_list((List **)&ext_completion, name, 0))
|
||||
{
|
||||
new = (Ext_Name_Type *)new_malloc(sizeof(Ext_Name_Type));
|
||||
new->name = m_strdup(name);
|
||||
new->len = len;
|
||||
new->type = type;
|
||||
+ new->comp_func =cf;
|
||||
add_to_list((List **)&ext_completion, (List *)new);
|
||||
return 1;
|
||||
}
|
||||
--- .//source/functions.c.orig Tue Jan 18 16:44:28 2000
|
||||
+++ .//source/functions.c Thu Jan 20 17:10:53 2000
|
||||
@@ -7020,8 +7020,9 @@
|
||||
#ifdef WANT_TABKEY
|
||||
char *ret, *possible;
|
||||
int count = 0; /* 6 */
|
||||
+enum completion comp_type = 3;
|
||||
possible = next_arg(input, &input);
|
||||
- ret = get_completions(3, possible, &count, NULL);
|
||||
+ ret = get_completions(&comp_type, possible, &count, NULL, NULL);
|
||||
return m_sprintf("%d %s", count, ret ? ret : empty_string);
|
||||
#else
|
||||
RETURN_EMPTY;
|
||||
@@ -7033,8 +7034,9 @@
|
||||
#ifdef WANT_TABKEY
|
||||
char *ret, *possible;
|
||||
int count = 0;/* 4 */
|
||||
+enum completion comp_type = 7;
|
||||
possible = next_arg(input, &input);
|
||||
- ret = get_completions(7, possible, &count, NULL);
|
||||
+ ret = get_completions(&comp_type, possible, &count, NULL, NULL);
|
||||
return m_sprintf("%d %s", count, ret ? ret : empty_string);
|
||||
#else
|
||||
RETURN_EMPTY;
|
||||
716
dll/aim/cmd.c
Normal file
716
dll/aim/cmd.c
Normal file
@@ -0,0 +1,716 @@
|
||||
/*
|
||||
* AOL Instant Messanger Module for BitchX
|
||||
*
|
||||
* By Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* cmd.c
|
||||
*
|
||||
* User commands (aliases) (client -> libtoc)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <irc.h>
|
||||
#include <struct.h>
|
||||
#include <hook.h>
|
||||
#include <ircaux.h>
|
||||
#include <output.h>
|
||||
#include <lastlog.h>
|
||||
#include <status.h>
|
||||
#include <vars.h>
|
||||
#include <window.h>
|
||||
#include <sys/stat.h>
|
||||
#include <module.h>
|
||||
#include <modval.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "toc.h"
|
||||
#include "aim.h"
|
||||
|
||||
char current_chat[512];
|
||||
char away_message[2048];
|
||||
LL msgdus;
|
||||
LL msgdthem;
|
||||
|
||||
/* Commands */
|
||||
|
||||
void asignon(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg) {
|
||||
char *user;
|
||||
char *pass;
|
||||
char *tochost,*authhost;
|
||||
int tocport, authport;
|
||||
int x;
|
||||
|
||||
if ( state == STATE_ONLINE ) {
|
||||
statusprintf("You are already online.");
|
||||
statusprintf("Please disconnect first (/asignoff), before trying to reoconnect.");
|
||||
return;
|
||||
}
|
||||
|
||||
user = get_dllstring_var("aim_user");
|
||||
pass = get_dllstring_var("aim_pass");
|
||||
tochost = get_dllstring_var("aim_toc_host");
|
||||
authhost = get_dllstring_var("aim_auth_host");
|
||||
x = get_dllint_var("aim_permdeny");
|
||||
tocport = get_dllint_var("aim_toc_port");
|
||||
authport = get_dllint_var("aim_auth_port");
|
||||
|
||||
|
||||
if ( ! VALID_ARG(user) || ! VALID_ARG(pass) ) {
|
||||
statusprintf("Please set your password and user name, by doing");
|
||||
statusprintf("/set aim_user <user name>");
|
||||
statusprintf("/set aim_pass <password>");
|
||||
return;
|
||||
}
|
||||
|
||||
/* This doent change anything-- should rm it */
|
||||
if ( x < 1 || x > 4)
|
||||
permdeny = PERMIT_PERMITALL;
|
||||
else
|
||||
permdeny = x;
|
||||
|
||||
|
||||
if ( VALID_ARG(tochost) )
|
||||
strncpy(aim_host,tochost,513);
|
||||
if ( tocport > 0 && tocport < (64*1024) )
|
||||
aim_port = tocport;
|
||||
if ( VALID_ARG(authhost) )
|
||||
strncpy(login_host,authhost,513);
|
||||
if ( authport > 0 && authport < (64*1024) )
|
||||
login_port = authport;
|
||||
|
||||
if ( toc_login(user,pass) < 0) {
|
||||
statusprintf("Couldn't connect to instant messanger");
|
||||
}
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
|
||||
msgdthem = CreateLL();
|
||||
msgdus = CreateLL();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void asignoff(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
if ( state != STATE_ONLINE ) {
|
||||
statusprintf("Please connect to aim first (/aconnect)");
|
||||
return;
|
||||
}
|
||||
delete_timer("aimtime");
|
||||
toc_signoff();
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
FreeLL(msgdthem);
|
||||
FreeLL(msgdus);
|
||||
}
|
||||
|
||||
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *nick,*nnick,*loc;
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
/* loc = msg, nick = username to send msg to */
|
||||
loc = LOCAL_COPY(args);
|
||||
nick = new_next_arg(loc, &loc);
|
||||
|
||||
REQUIRED_ARG(nick,command,helparg);
|
||||
|
||||
if ( nick[0] == '#' ) {
|
||||
struct buddy_chat *b;
|
||||
nick++;
|
||||
REQUIRED_ARG(nick,command,helparg);
|
||||
b = (struct buddy_chat *) find_buddy_chat(nick);
|
||||
if ( ! b ) {
|
||||
statusprintf("Error not on buddy chat %s", nick);
|
||||
return;
|
||||
}
|
||||
/* chatprintf("sent msg %s to buddy chat %s",loc,nick); */
|
||||
serv_chat_send(b->id,loc);
|
||||
} else {
|
||||
char *ruser,*rnick;
|
||||
nnick = (char *) malloc(strlen(nick)+10);
|
||||
rnick = rm_space(nick);
|
||||
ruser = rm_space(get_dllstring_var("aim_user"));
|
||||
sprintf(nnick,"%s@AIM",rnick);
|
||||
msgprintf("%s", cparse(fget_string_var(FORMAT_SEND_MSG_FSET),
|
||||
"%s %s %s %s",update_clock(GET_TIME),
|
||||
nnick, ruser, loc));
|
||||
serv_send_im(nick,loc);
|
||||
RemoveFromLLByKey(msgdthem,rnick);
|
||||
AddToLL(msgdthem,rnick,NULL);
|
||||
#ifdef BITCHX_PATCH
|
||||
tks.list = 0;
|
||||
tks.pos = -1;
|
||||
#endif
|
||||
free(rnick); free(ruser);
|
||||
}
|
||||
|
||||
debug_printf("sending msg to %s '%s'",nick,loc);
|
||||
return;
|
||||
}
|
||||
|
||||
void abl(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg) {
|
||||
char *cmd,*loc;
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
/* loc = msg, nick = username to send msg to */
|
||||
loc = LOCAL_COPY(args);
|
||||
cmd = new_next_arg(loc, &loc);
|
||||
|
||||
REQUIRED_ARG(cmd,command,helparg);
|
||||
|
||||
if ( ! strcasecmp(cmd,"show" ) ) {
|
||||
struct buddy *b;
|
||||
LLE tg,tb;
|
||||
LL mems;
|
||||
for ( TLL(groups,tg) ) {
|
||||
mems = ((struct group *) tg->data)->members;
|
||||
statusprintf("Group: %s", tg->key);
|
||||
for ( TLL(mems,tb) ) {
|
||||
b = (struct buddy *)tb->data;
|
||||
statusprintf("\t\t%s %d",b->name,b->present);
|
||||
}
|
||||
}
|
||||
} else if ( ! strcasecmp(cmd,"add") ) {
|
||||
char *buddy,*group;
|
||||
group = new_next_arg(loc, &loc);
|
||||
REQUIRED_ARG(group,command,helparg);
|
||||
|
||||
if ( ! VALID_ARG(loc) ) {
|
||||
buddy = group;
|
||||
group = (char *) malloc(strlen("Buddies")+2);
|
||||
strcpy(group,"Buddies");
|
||||
} else {
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
}
|
||||
|
||||
if ( user_add_buddy(group,buddy) > 0 ) {
|
||||
statusprintf("Added buddy %s to group %s",buddy,group);
|
||||
} else {
|
||||
statusprintf("%s is already in your buddy list",buddy);
|
||||
}
|
||||
} else if ( ! strcasecmp(cmd,"del") ) {
|
||||
char *buddy;
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( user_remove_buddy(buddy) > 0 ) {
|
||||
statusprintf("Removed buddy %s",buddy);
|
||||
} else {
|
||||
statusprintf("%s is not in your buddy list",buddy);
|
||||
}
|
||||
} else if ( ! strcasecmp(cmd,"addg") ) {
|
||||
char *group;
|
||||
struct group *g;
|
||||
group = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(group,command,helparg);
|
||||
|
||||
g = find_group(group);
|
||||
if ( g ) {
|
||||
statusprintf("Group %s already exists",args);
|
||||
return;
|
||||
}
|
||||
|
||||
add_group(group);
|
||||
statusprintf("Created group %s",group);
|
||||
} else if ( ! strcasecmp(cmd,"delg") ) {
|
||||
char *group,*newgroup;
|
||||
int ret;
|
||||
|
||||
group = new_next_arg(loc, &loc);
|
||||
newgroup = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(group,command,helparg);
|
||||
|
||||
if ( ! VALID_ARG(newgroup) ) {
|
||||
statusprintf("Usage: /abl delg <old group> 1 (delete group and all buddies in it)");
|
||||
statusprintf(" /abl delg <old group> <new group> (delete group and move all buddies in it to new group)");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! strcasecmp(newgroup,"1") )
|
||||
ret = remove_group(group,NULL,2);
|
||||
else
|
||||
ret = remove_group(group,newgroup,1);
|
||||
if ( ret > 0 )
|
||||
statusprintf("Removed group %s",group);
|
||||
else
|
||||
statusprintf("Group %s doesn't exist",group);
|
||||
} else
|
||||
statusprintf("Error unknown buddy list management command: %s", cmd);
|
||||
}
|
||||
|
||||
void awarn(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *buddy,*mode,*loc;
|
||||
mode = NULL;
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
loc = LOCAL_COPY(args);
|
||||
buddy = new_next_arg(loc, &loc);
|
||||
mode = new_next_arg(loc,&loc);
|
||||
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( VALID_ARG(mode) && ! strcasecmp(mode,"anon") ) {
|
||||
serv_warn(buddy,1);
|
||||
} else {
|
||||
serv_warn(buddy,0);
|
||||
}
|
||||
statusprintf("Warned: %s",buddy);
|
||||
}
|
||||
|
||||
void apd(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *cmd,*loc;
|
||||
loc = LOCAL_COPY(args);
|
||||
cmd = new_next_arg(loc,&loc);
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
REQUIRED_ARG(cmd,command,helparg);
|
||||
|
||||
if ( ! strcasecmp(cmd,"show") ) {
|
||||
LLE t;
|
||||
statusprintf("User Mode: %s",((permdeny >= 1 && permdeny <= 4) ? PERMIT_MODES[permdeny] : "ERROR: Unknown"));
|
||||
statusprintf("Permit:");
|
||||
ResetLLPosition(permit);
|
||||
while ( (t=GetNextLLE(permit)) ) {
|
||||
statusprintf("\t\t%s",t->key);
|
||||
}
|
||||
|
||||
ResetLLPosition(deny);
|
||||
statusprintf("Deny:");
|
||||
while ( (t=GetNextLLE(deny)) ) {
|
||||
statusprintf("\t\t%s",t->key);
|
||||
}
|
||||
} else if ( ! strcasecmp(cmd,"mode") ) {
|
||||
char *mode;
|
||||
int newmode;
|
||||
mode = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(mode,command,helparg);
|
||||
|
||||
if ( ! strcasecmp(mode,"permitall") ) {
|
||||
newmode = PERMIT_PERMITALL;
|
||||
} else if ( ! strcasecmp(mode,"denyall") ) {
|
||||
newmode = PERMIT_DENYALL;
|
||||
} else if ( ! strcasecmp(mode,"denysome") ) {
|
||||
newmode = PERMIT_DENYSOME;
|
||||
} else if ( ! strcasecmp(mode,"permitsome") ) {
|
||||
newmode = PERMIT_PERMITSOME;
|
||||
} else {
|
||||
userage(command,helparg);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( newmode == permdeny ) {
|
||||
statusprintf("We are already in %s mode",mode);
|
||||
return;
|
||||
} else {
|
||||
permdeny = newmode;
|
||||
set_dllint_var("aim_permdeny_mode",permdeny);
|
||||
serv_set_permit_deny();
|
||||
serv_save_config();
|
||||
}
|
||||
|
||||
statusprintf("Switch to %s mode",mode);
|
||||
} else if ( !strcasecmp(cmd,"addp") ) {
|
||||
char *buddy;
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( add_permit(buddy) < 0 ) {
|
||||
statusprintf("%s is already in your permit list!");
|
||||
return;
|
||||
}
|
||||
if ( permdeny != PERMIT_PERMITSOME )
|
||||
statusprintf("Note: although %s will be added to your permit list, no tangible change will occur because you are in the improper mode (see help on apermdeny)",buddy);
|
||||
statusprintf("Added %s to your permit list",buddy);
|
||||
} else if ( !strcasecmp(cmd,"delp") ) {
|
||||
char *buddy;
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( remove_permit(buddy) < 0 )
|
||||
statusprintf("%s is not in your permit list!",buddy);
|
||||
else
|
||||
statusprintf("Remvoed %s from your permit list",buddy);
|
||||
} else if ( !strcasecmp(cmd,"addd") ) {
|
||||
char *buddy;
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( add_deny(buddy) < 0 ) {
|
||||
statusprintf("%s is already in your deny list!");
|
||||
return;
|
||||
}
|
||||
if ( permdeny != PERMIT_DENYSOME )
|
||||
statusprintf("Note: although %s will be added to your deny list, no tangible change will occur because you are in the improper mode (see help on apermdeny)",buddy);
|
||||
statusprintf("Added %s to your deny list",buddy);
|
||||
} else if ( !strcasecmp(cmd,"deld") ) {
|
||||
char *buddy;
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
if ( remove_deny(buddy) < 0 )
|
||||
statusprintf("%s is not in your deny list!",buddy);
|
||||
else
|
||||
statusprintf("Remvoed %s from your deny list",buddy);
|
||||
} else
|
||||
statusprintf("Error unknown permit/deny cmd %s",cmd);
|
||||
}
|
||||
|
||||
void awhois(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *buddy,*loc;
|
||||
struct buddy *b;
|
||||
loc = LOCAL_COPY(args);
|
||||
buddy = new_next_arg(loc,&loc);
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
REQUIRED_ARG(buddy,command,helparg);
|
||||
|
||||
b = find_buddy(buddy);
|
||||
if ( ! b ) {
|
||||
statusprintf("%s is not in your buddy list and thus I have no info stored on him/her",buddy);
|
||||
return;
|
||||
}
|
||||
|
||||
statusprintf("%s", cparse("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---<2D>--<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---<2D>--<2D><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--- -- -", NULL));
|
||||
statusprintf("%s", cparse("| User : $0-", "%s", b->name));
|
||||
statusprintf("%s", cparse("<EFBFBD> Class : $0-", "%s", ((b->uc <= 5 && b->uc >= 0) ? USER_CLASSES[b->uc] : "Unknown")));
|
||||
statusprintf("%s", cparse("<EFBFBD> Evil : $0-", "%d", b->evil));
|
||||
statusprintf("%s", cparse("<EFBFBD> SignOn : $0-", "%s", my_ctime(b->signon)));
|
||||
statusprintf("%s", cparse(": Idle : $0-", "%d", b->idle));
|
||||
}
|
||||
|
||||
void asave (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
IrcVariableDll *newv = NULL;
|
||||
FILE *outf = NULL;
|
||||
char *expanded = NULL;
|
||||
char buffer[BIG_BUFFER_SIZE+1];
|
||||
if (get_string_var(CTOOLZ_DIR_VAR))
|
||||
snprintf(buffer, BIG_BUFFER_SIZE, "%s/AIM.sav", get_string_var(CTOOLZ_DIR_VAR));
|
||||
else
|
||||
sprintf(buffer, "~/AIM.sav");
|
||||
expanded = expand_twiddle(buffer);
|
||||
if (!expanded || !(outf = fopen(expanded, "w")))
|
||||
{
|
||||
statusprintf("error opening %s", expanded ? expanded : buffer);
|
||||
new_free(&expanded);
|
||||
return;
|
||||
}
|
||||
for (newv = dll_variable; newv; newv = newv->next)
|
||||
{
|
||||
if (!my_strnicmp(newv->name, name, 3))
|
||||
{
|
||||
if (newv->type == STR_TYPE_VAR)
|
||||
{
|
||||
if (newv->string)
|
||||
fprintf(outf, "SET %s %s\n", newv->name, newv->string);
|
||||
}
|
||||
else if (newv->type == BOOL_TYPE_VAR)
|
||||
fprintf(outf, "SET %s %s\n", newv->name, on_off(newv->integer));
|
||||
else
|
||||
fprintf(outf, "SET %s %d\n", newv->name, newv->integer);
|
||||
}
|
||||
}
|
||||
|
||||
/* Buddy list, perm/deny list, etc. stored on AIM server */
|
||||
|
||||
/*
|
||||
* Not sure what that does?
|
||||
if (do_hook(MODULE_LIST, "NAP SAVE %s", buffer))
|
||||
nap_say("Finished saving Napster variables to %s", buffer);
|
||||
*/
|
||||
statusprintf("Finished saving AIM variables to %s",buffer);
|
||||
fclose(outf);
|
||||
new_free(&expanded);
|
||||
return;
|
||||
}
|
||||
|
||||
void achat (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *arg1, *arg2, *arg3, *loc;
|
||||
|
||||
loc = LOCAL_COPY(args);
|
||||
|
||||
debug_printf("in achat!");
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
if ( ! strcasecmp(command,"asay") ) {
|
||||
if ( VALID_ARG(current_chat) ) {
|
||||
struct buddy_chat *b;
|
||||
b = find_buddy_chat(current_chat);
|
||||
if ( ! b ) {
|
||||
statusprintf("Not on a buddy chat");
|
||||
return;
|
||||
}
|
||||
serv_chat_send(b->id,loc);
|
||||
} else
|
||||
statusprintf("Not on a buddy chat");
|
||||
} else if ( ! strcasecmp(command,"ajoin") ) {
|
||||
arg1 = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(arg1,command,helparg);
|
||||
if ( arg1[0] == '#' )
|
||||
arg1++;
|
||||
REQUIRED_ARG(arg1,command,helparg);
|
||||
if ( find_buddy_chat(arg1) ) {
|
||||
strncpy(current_chat,arg1,511);
|
||||
return;
|
||||
}
|
||||
buddy_chat_join(arg1);
|
||||
} else if ( ! strcasecmp(command,"apart") ) {
|
||||
arg1 = new_next_arg(loc,&loc);
|
||||
if ( VALID_ARG(arg1) && arg1[0] == '#' )
|
||||
arg1++;
|
||||
if ( VALID_ARG(arg1) ) {
|
||||
if ( buddy_chat_leave(arg1) ) {
|
||||
if ( ! strcasecmp(arg1,current_chat) ) {
|
||||
/* Replace Current Chat */
|
||||
strcpy(current_chat,"");
|
||||
}
|
||||
} else
|
||||
statusprintf("Not on buddy chat %s",arg1);
|
||||
} else {
|
||||
if ( VALID_ARG(current_chat) ) {
|
||||
buddy_chat_leave(current_chat);
|
||||
/* Repalce Current Chat */
|
||||
strcpy(current_chat,"");
|
||||
} else
|
||||
statusprintf("Not on a buddy chat");
|
||||
}
|
||||
} else if ( ! strcasecmp(command,"ainvite") ) {
|
||||
arg1 = new_next_arg(loc,&loc);
|
||||
arg2 = new_next_arg(loc,&loc);
|
||||
arg3 = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(arg1,command,helparg);
|
||||
if ( arg1[0] == '#' )
|
||||
arg1++;
|
||||
REQUIRED_ARG(arg1,command,helparg);
|
||||
REQUIRED_ARG(arg2,command,helparg);
|
||||
REQUIRED_ARG(arg3,command,helparg);
|
||||
|
||||
if ( buddy_chat_invite(arg1,arg2,arg3) < 0 ) {
|
||||
statusprintf("Not on buddy chat %s",arg1);
|
||||
}
|
||||
} else if ( !strcasecmp(command,"achats") ) {
|
||||
LLE t;
|
||||
statusprintf("Currently on: ");
|
||||
ResetLLPosition(buddy_chats);
|
||||
while ( (t=GetNextLLE(buddy_chats)) ) {
|
||||
statusprintf("\t\t%s",t->key);
|
||||
}
|
||||
} else if ( ! strcasecmp(command,"anames") ) {
|
||||
char *chat;
|
||||
arg1 = new_next_arg(loc,&loc);
|
||||
if ( VALID_ARG(arg1) )
|
||||
chat = arg1;
|
||||
else
|
||||
chat = current_chat;
|
||||
if ( VALID_ARG(chat) ) {
|
||||
struct buddy_chat *b;
|
||||
LLE t;
|
||||
b = find_buddy_chat(chat);
|
||||
if ( ! b ) {
|
||||
statusprintf("Not on buddy chat %s",chat);
|
||||
return;
|
||||
}
|
||||
statusprintf("Names on %s",b->name);
|
||||
ResetLLPosition(b->in_room);
|
||||
while ( (t=GetNextLLE(b->in_room)) ) {
|
||||
statusprintf("%s",t->key);
|
||||
}
|
||||
} else
|
||||
statusprintf("Not on a buddy chat");
|
||||
} else if ( ! strcasecmp(command,"acwarn") ) {
|
||||
int anon = 0;
|
||||
char *chat = NULL, *user = NULL, *mode = NULL;
|
||||
arg1 = new_next_arg(loc, &loc);
|
||||
arg2 = new_next_arg(loc,&loc);
|
||||
arg3 = new_next_arg(loc,&loc);
|
||||
if ( VALID_ARG(arg1) && VALID_ARG(arg2) && VALID_ARG(arg3) ) {
|
||||
chat = arg1;
|
||||
user = arg2;
|
||||
mode = arg3;
|
||||
} else if ( VALID_ARG(arg1) && VALID_ARG(arg2) ) {
|
||||
chat = current_chat;
|
||||
user = arg1;
|
||||
mode = arg2;
|
||||
} else if ( VALID_ARG(arg1) ) {
|
||||
chat = current_chat;
|
||||
user = arg2;
|
||||
mode = NULL;
|
||||
}
|
||||
if ( VALID_ARG(mode) && ! strcasecmp(mode,"anon") )
|
||||
anon = 1;
|
||||
if ( chat[0] == '#' ) {
|
||||
chat++;
|
||||
REQUIRED_ARG(chat,command,helparg);
|
||||
}
|
||||
if ( buddy_chat_warn(chat,user,1) < 0 )
|
||||
statusprintf("Not on buddy chat %s",chat);
|
||||
else
|
||||
statusprintf("Buddy Chat Warned %s",user);
|
||||
} else
|
||||
debug_printf("Unknown command in achat %s",command);
|
||||
}
|
||||
|
||||
void adir (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *cmd,*loc;
|
||||
|
||||
loc = LOCAL_COPY(args);
|
||||
cmd = new_next_arg(loc,&loc);
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
REQUIRED_ARG(cmd,command,helparg);
|
||||
if ( !strcasecmp(cmd,"get") ) {
|
||||
char *sn;
|
||||
sn = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(sn,command,helparg);
|
||||
|
||||
serv_get_dir(sn);
|
||||
} else if ( ! strcasecmp(cmd,"search") ) {
|
||||
int fields = 0;
|
||||
char *field,*data;
|
||||
char *first,*middle,*last,*maiden;
|
||||
char *city,*state,*country,*email;
|
||||
first = middle = last = maiden = NULL;
|
||||
city = state = country = email = NULL;
|
||||
|
||||
field = new_next_arg(loc,&loc);
|
||||
while ( VALID_ARG(field) ) {
|
||||
data = new_next_arg(loc,&loc);
|
||||
if ( VALID_ARG(data) ) {
|
||||
fields++;
|
||||
if ( ! strcasecmp(field,"first") || ! strcasecmp(field,"-first") )
|
||||
first = data;
|
||||
else if ( ! strcasecmp(field,"middle") || ! strcasecmp(field,"-middle") )
|
||||
middle = data;
|
||||
else if ( ! strcasecmp(field,"last") || ! strcasecmp(field,"-last") )
|
||||
last = data;
|
||||
else if ( ! strcasecmp(field,"maiden") || ! strcasecmp(field,"-maiden") )
|
||||
maiden = data;
|
||||
else if ( ! strcasecmp(field,"city") || ! strcasecmp(field,"-city") )
|
||||
city = data;
|
||||
else if ( ! strcasecmp(field,"state") || ! strcasecmp(field,"-state") )
|
||||
state = data;
|
||||
else if ( ! strcasecmp(field,"country") || ! strcasecmp(field,"-country") )
|
||||
country = data;
|
||||
else if ( ! strcasecmp(field,"email") || ! strcasecmp(field,"-email") )
|
||||
email = data;
|
||||
else
|
||||
statusprintf("Illegal field: %s",field);
|
||||
} else {
|
||||
statusprintf("No search item for field %s",field);
|
||||
}
|
||||
serv_dir_search(first,middle,last,maiden,city,state,country,email);
|
||||
}
|
||||
} else if ( ! strcasecmp(cmd,"set") ) {
|
||||
char *first = new_next_arg(loc,&loc);
|
||||
char *middle = new_next_arg(loc,&loc);
|
||||
char *last = new_next_arg(loc,&loc);
|
||||
char *maiden = new_next_arg(loc,&loc);
|
||||
char *city = new_next_arg(loc,&loc);
|
||||
char *state =new_next_arg(loc,&loc);
|
||||
char *country = new_next_arg(loc,&loc);
|
||||
char *email = new_next_arg(loc,&loc);
|
||||
char *allow = new_next_arg(loc,&loc);
|
||||
int x;
|
||||
|
||||
REQUIRED_ARG(allow,command,helparg);
|
||||
if ( atoi(allow) ) {
|
||||
x = 1;
|
||||
} else {
|
||||
x = 0;
|
||||
}
|
||||
/* apparently sending email messes this up? */
|
||||
serv_set_dir(first,middle,last,maiden,city,state,country,email,x);
|
||||
} else
|
||||
debug_printf("Unknown command in adir %s",command);
|
||||
}
|
||||
|
||||
void achange_idle(Window *w, char *s, int i) {
|
||||
time_to_idle = i * 60;
|
||||
debug_printf("time to idle = %d",time_to_idle);
|
||||
}
|
||||
|
||||
void aaway (IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
|
||||
char *loc;
|
||||
|
||||
loc = LOCAL_COPY(args);
|
||||
CHECK_TOC_ONLINE();
|
||||
|
||||
serv_set_away(args);
|
||||
|
||||
if ( is_away ) {
|
||||
strncpy(away_message,args,2047);
|
||||
statusprintf("You are now marked as away");
|
||||
} else
|
||||
statusprintf("You are now back.");
|
||||
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
}
|
||||
|
||||
void aquery(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg) {
|
||||
Window *tmp = NULL;
|
||||
char *loc,*n,*msg;
|
||||
char say[10] = "say";
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
loc = LOCAL_COPY(args);
|
||||
n = new_next_arg(loc,&loc);
|
||||
|
||||
if ( get_dllint_var("aim_window") ) {
|
||||
strcpy(say,"asay");
|
||||
tmp = get_window_by_name("AIM");
|
||||
}
|
||||
if ( ! tmp )
|
||||
tmp = current_window;
|
||||
|
||||
if ( VALID_ARG(n) ) {
|
||||
#ifdef BITCHX_PATCH
|
||||
msg = (char *) malloc(strlen(n)+50);
|
||||
sprintf(msg,"-cmd amsg %s",n);
|
||||
debug_printf("Querying: %s",msg);
|
||||
window_query(tmp,&msg,NULL);
|
||||
#else
|
||||
|
||||
msg = (char *) malloc(strlen(n)+10);
|
||||
sprintf(msg,"amsg %s",n);
|
||||
debug_printf("nick = '%s' msg = '%s'",n,msg);
|
||||
#undef query_cmd
|
||||
tmp->query_cmd = m_strdup("amsg");
|
||||
#undef query_nick
|
||||
tmp->query_nick = m_strdup(n);
|
||||
update_input(tmp);
|
||||
#endif
|
||||
} else {
|
||||
#undef query_cmd
|
||||
tmp->query_cmd = m_strdup(say);
|
||||
}
|
||||
debug_printf("Leaking memory in aquery");
|
||||
}
|
||||
|
||||
void ainfo(IrcCommandDll *intp, char *command, char *args, char *subargs,char *helparg) {
|
||||
char *cmd,*loc;
|
||||
|
||||
loc = LOCAL_COPY(args);
|
||||
cmd = new_next_arg(loc,&loc);
|
||||
|
||||
CHECK_TOC_ONLINE();
|
||||
REQUIRED_ARG(cmd,command,helparg);
|
||||
|
||||
if ( ! strcasecmp(cmd,"get") ) {
|
||||
char *nick = new_next_arg(loc,&loc);
|
||||
REQUIRED_ARG(nick,command,helparg);
|
||||
|
||||
serv_get_info(nick);
|
||||
} else if ( ! strcasecmp(cmd,"set") ) {
|
||||
REQUIRED_ARG(loc,command,helparg);
|
||||
serv_set_info(loc);
|
||||
} else
|
||||
statusprintf("Unknown command sent to ainfo: '%s'", cmd);
|
||||
}
|
||||
158
dll/aim/toc.c
Normal file
158
dll/aim/toc.c
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* AOL Instant Messanger Module for BitchX
|
||||
*
|
||||
* By Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* toc.c
|
||||
*
|
||||
* Interface to libtoc (libtoc -> client)
|
||||
*/
|
||||
|
||||
|
||||
#include <irc.h>
|
||||
#include <struct.h>
|
||||
#include <hook.h>
|
||||
#include <ircaux.h>
|
||||
#include <output.h>
|
||||
#include <lastlog.h>
|
||||
#include <status.h>
|
||||
#include <vars.h>
|
||||
#include <window.h>
|
||||
#include <sys/stat.h>
|
||||
#include <module.h>
|
||||
#include <modval.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "toc.h"
|
||||
#include "aim.h"
|
||||
|
||||
int sock_read_id;
|
||||
void (*chatprintf)(char *, ...) = statusprintf;
|
||||
|
||||
/* LIBToc Call back functions */
|
||||
|
||||
int toc_add_input_stream(int fd,int (*func)(int)) {
|
||||
sock_read_id = add_socketread(fd, 0, 0, "bleh", func, func);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int toc_remove_input_stream(int fd) {
|
||||
close_socketread(sock_read_id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int toc_main_interface(int type, char **args) {
|
||||
|
||||
switch (type) {
|
||||
case TOC_IM_IN: {
|
||||
char *msg, *nick;
|
||||
nick = rm_space(args[0]);
|
||||
msg = strip_html(args[1]);
|
||||
RemoveFromLLByKey(msgdus,nick);
|
||||
AddToLL(msgdus,nick,NULL);
|
||||
msgprintf("%s", cparse(fget_string_var(FORMAT_MSG_FSET),
|
||||
"%s %s %s %s",update_clock(GET_TIME),
|
||||
nick, "AIM", msg));
|
||||
if ( is_away )
|
||||
serv_send_im(args[0],away_message);
|
||||
free(nick);
|
||||
break;
|
||||
}
|
||||
case TOC_TRANSLATED_ERROR:
|
||||
case TOC_CONNECT_MSGS:
|
||||
statusprintf(args[0]);
|
||||
break;
|
||||
case TOC_BUDDY_LOGGED_OFF:
|
||||
statusprintf("%s logged off",args[0]);
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
break;
|
||||
case TOC_BUDDY_LOGGED_ON:
|
||||
statusprintf("%s logged on", args[0]);
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
break;
|
||||
case TOC_EVILED:
|
||||
statusprintf("You have been warned by %s.", ((args[0] == NULL) ? "an anonymous person" : args[0]));
|
||||
statusprintf("Your new warning level is %s%%" , args[1]);
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
break;
|
||||
case TOC_CHAT_JOIN:
|
||||
chatprintf("Joined buddy chat %s",args[1]);
|
||||
strncpy(current_chat,args[1],511);
|
||||
break;
|
||||
case TOC_BUDDY_LEFT_CHAT:
|
||||
chatprintf("%s left %s",args[1],args[0]);
|
||||
break;
|
||||
case TOC_BUDDY_JOIN_CHAT:
|
||||
chatprintf("%s joined %s",args[1],args[0]);
|
||||
break;
|
||||
case TOC_CHAT_LEFT:
|
||||
chatprintf("Left chat id: %s",args[0]);
|
||||
break;
|
||||
case TOC_CHAT_IN: {
|
||||
char *e,*name,*chat;
|
||||
/* chatprintf("got msg from chat: <%s@AIM> %s",args[1],args[3]); */
|
||||
/* Need to take better action here */
|
||||
e = strip_html(args[3]);
|
||||
name = rm_space(args[1]);
|
||||
chat = rm_space(args[4]);
|
||||
msgprintf("%s",cparse(fget_string_var(FORMAT_PUBLIC_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME), name, chat, e));
|
||||
free(name); free(chat);
|
||||
break;
|
||||
}
|
||||
case TOC_GOTO_URL:
|
||||
statusprintf("GOTO_URL: %s",args[0]);
|
||||
break;
|
||||
case TOC_CHAT_INVITE:
|
||||
statusprintf("Invited to %s by %s '%s'",args[0],args[2],args[3]);
|
||||
break;
|
||||
case TOC_LAG_UPDATE:
|
||||
case TOC_WENT_IDLE:
|
||||
if ( get_dllint_var("aim_window") )
|
||||
build_aim_status(get_window_by_name("AIM"));
|
||||
break;
|
||||
case TOC_DIR_STATUS:
|
||||
if ( atoi(args[0]) == 1 )
|
||||
statusprintf("Directory information successfully changed.");
|
||||
else
|
||||
statusprintf("Error altering directory information, error code: %s",args[0]);
|
||||
break;
|
||||
default:
|
||||
statusprintf("INTERNAL ERROR: Unknown toc type: %d",type);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int toc_timer(int type, char **args) {
|
||||
timer_id = add_timer(0,"aimtime",20000,0,&check_idle,NULL,NULL,0,"aimtime");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* int toc_buddy_logged_on( */
|
||||
|
||||
void bx_init_toc() {
|
||||
init_toc();
|
||||
strcpy(current_chat,"");
|
||||
/* Setup Hanlders */
|
||||
install_handler(TOC_IM_IN,&toc_main_interface);
|
||||
install_handler(TOC_TRANSLATED_ERROR,&toc_main_interface);
|
||||
install_handler(TOC_CONNECT_MSGS,&toc_main_interface);
|
||||
install_handler(TOC_BUDDY_LOGGED_ON,&toc_main_interface);
|
||||
install_handler(TOC_BUDDY_LOGGED_OFF,&toc_main_interface);
|
||||
install_handler(TOC_EVILED,&toc_main_interface);
|
||||
install_handler(TOC_CHAT_JOIN,&toc_main_interface);
|
||||
install_handler(TOC_BUDDY_LEFT_CHAT,&toc_main_interface);
|
||||
install_handler(TOC_BUDDY_JOIN_CHAT,&toc_main_interface);
|
||||
install_handler(TOC_CHAT_LEFT,&toc_main_interface);
|
||||
install_handler(TOC_CHAT_IN,&toc_main_interface);
|
||||
install_handler(TOC_CHAT_INVITE,&toc_main_interface);
|
||||
install_handler(TOC_GOTO_URL,&toc_main_interface);
|
||||
install_handler(TOC_LAG_UPDATE,&toc_main_interface);
|
||||
install_handler(TOC_WENT_IDLE,&toc_main_interface);
|
||||
install_handler(TOC_DIR_STATUS,&toc_main_interface);
|
||||
install_handler(TOC_REINSTALL_TIMER,&toc_timer);
|
||||
}
|
||||
3
dll/aim/toc/BUGS
Normal file
3
dll/aim/toc/BUGS
Normal file
@@ -0,0 +1,3 @@
|
||||
- If you are in permitsome or denysome mdoe and remove someone from either
|
||||
your permit or deny list, the changes do not take effect until you
|
||||
resigon on.
|
||||
174
dll/aim/toc/Makefile.in
Normal file
174
dll/aim/toc/Makefile.in
Normal file
@@ -0,0 +1,174 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
#DEBUG_CFLAGS = -g -DDEBUG_LIB_TOC
|
||||
|
||||
.c.o:
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) $(DEBUG_CFLAGS) -c $<
|
||||
|
||||
LOBJS = toc.o network.o util.o server.o interface.o buddy.o ll.o misc.o
|
||||
|
||||
all: libtoc.a
|
||||
|
||||
libtoc.a: $(LOBJS)
|
||||
ar cru libtoc.a $(LOBJS)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
clean:
|
||||
$(RM) $(LOBJS) libtoc.a
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
438
dll/aim/toc/PROTOCOL
Normal file
438
dll/aim/toc/PROTOCOL
Normal file
@@ -0,0 +1,438 @@
|
||||
# Copyright (c) 1998-9 America Online, Inc. All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
Version: TOC1.0
|
||||
|
||||
This document describes the protocol between TOC and TOC clients.
|
||||
The protocol is built on TCP. Framing is done by SFLAP,
|
||||
described at the bottom of this document. Inside each
|
||||
SFLAP frame is a TOC command.
|
||||
|
||||
The TOC protocol is ASCII based, and special attention
|
||||
must be placed argument separation. The separator and
|
||||
the rules of separation are different for messages inbound
|
||||
to TOC and outbound to the client. The rules of separation
|
||||
are described in sections below.
|
||||
|
||||
The TOC server is built mainly to service the TIC and TiK clients. Since
|
||||
the TIC client is a Java applet, and downloadable, TOC will NOT support
|
||||
multiple TOC protocol versions at the same time. Therefore, TiK
|
||||
users will be forced to upgrade if the protocol version changes.
|
||||
TOC sends down the protocol version it expects the client
|
||||
to speak and understand. Note, the protocol version is a string.
|
||||
|
||||
Important Notes
|
||||
===============
|
||||
* TOC will drop the connection if a command exceeds the maximum
|
||||
length, which is currently 2048 bytes. So the client needs to
|
||||
spend special attention to im, chat, and config message lengths.
|
||||
There is an 8k length maximum from TOC to the client.
|
||||
|
||||
* No commands should be sent to TOC (besides toc_signon) before
|
||||
a SIGN_ON is received. If you do send a command before SIGN_ON
|
||||
the command will be ignored, and in some case the connection
|
||||
will be dropped.
|
||||
|
||||
* Initial permit/deny items should be sent after receiving SIGN_ON
|
||||
but before sending toc_init_done, otherwise the user will flash
|
||||
on peoples buddylist who the user has denied. You will probably
|
||||
want to send the toc_add_buddies at this time also.
|
||||
|
||||
* After TOC sends the PAUSE message to a client, all messages sent
|
||||
to TOC will be ignored, and in some cases the connection will
|
||||
be dropped. Another SIGN_ON message will be sent to the client
|
||||
when it is online again. The buddy list and permit/deny items must
|
||||
be sent again, followed by the toc_init_done. In most cases the
|
||||
SIGN_ON message will be sent between 1-2 seconds after the
|
||||
PAUSE message. Therefore a client could choose to ignore the
|
||||
PAUSE message and hope nothing bad happens.
|
||||
|
||||
|
||||
Client -> TOC
|
||||
==============
|
||||
The commands and the arguments are usually separated by whitespaces. Arguments
|
||||
with whitespace characters should be enclosed in quotes. Dollar signs,
|
||||
curly brackets, square brackets, parentheses, quotes, and backslashes
|
||||
must all be backslashed whether in quotes or not. It is usually
|
||||
a good idea just to use quotes no matter what. All user names from clients
|
||||
to TOC should be normalized (spaces removed and lowercased), and therefore
|
||||
are the one exception to the always use quotes rule.
|
||||
|
||||
When sending commands to the server you will not get a response
|
||||
back confirming that the command format was correct or not! However
|
||||
in some cases if the command format was incorrect the connection
|
||||
will be dropped.
|
||||
|
||||
|
||||
RoastingString="Tic/Toc"
|
||||
|
||||
toc_signon <authorizer host> <authorizer port> <User Name> <Password>
|
||||
<language> <version>
|
||||
The password needs to be roasted with the Roasting String if
|
||||
coming over a FLAP connection, CP connections don't use
|
||||
roasted passwords. The language specified will be used
|
||||
when generating web pages, such as the get info pages.
|
||||
Currently the only supported language is "english".
|
||||
If the language sent isn't found, the default "english"
|
||||
language will be used. The version string will be used
|
||||
for the client identity, and must be less then 50
|
||||
characters.
|
||||
|
||||
Passwords are roasted when sent to the host. This is done so they
|
||||
aren't sent in "clear text" over the wire, although they are still
|
||||
trivial to decode. Roasting is performed by first xoring each byte
|
||||
in the password with the equivalent modulo byte in the roasting
|
||||
string. The result is then converted to ascii hex, and prepended
|
||||
with "0x". So for example the password "password" roasts to
|
||||
"0x2408105c23001130"
|
||||
|
||||
toc_init_done
|
||||
Tells TOC that we are ready to go online. TOC clients should first
|
||||
send TOC the buddy list and any permit/deny lists. However toc_init_done
|
||||
must be called within 30 seconds after toc_signon, or the connection
|
||||
will be dropped. Remember, it can't be called until after the SIGN_ON
|
||||
message is received. Calling this before or multiple times after a
|
||||
SIGN_ON will cause the connection to be dropped.
|
||||
|
||||
toc_send_im <Destination User> <Message> [auto]
|
||||
Send a message to a remote user. Remember to quote and encode the
|
||||
message. If the optional string "auto" is the last argument, then the
|
||||
auto response flag will be turned on for the im.
|
||||
|
||||
toc_add_buddy <Buddy User 1> [<Buddy User2> [<Buddy User 3> [...]]]
|
||||
Add buddies to your buddy list. This does not change your
|
||||
saved config.
|
||||
|
||||
toc_remove_buddy <Buddy User 1> [<Buddy User2> [<Buddy User 3> [...]]]
|
||||
Remove buddies from your buddy list. This does not change your
|
||||
saved config.
|
||||
|
||||
toc_set_config <Config Info>
|
||||
Set the config information for this user. The config information
|
||||
is line oriented with the first character being the item type,
|
||||
followed by a space, with the rest of the line being the item
|
||||
value. Only letters, numbers, and spaces should be used. Remember
|
||||
you will have to enclose the entire config in quotes.
|
||||
|
||||
Item Types:
|
||||
g - Buddy Group (All Buddies until the next g or the end of config
|
||||
are in this group.)
|
||||
b - A Buddy
|
||||
p - Person on permit list
|
||||
d - Person on deny list
|
||||
m - Permit/Deny Mode. Possible values are
|
||||
1 - Permit All
|
||||
2 - Deny All
|
||||
3 - Permit Some
|
||||
4 - Deny Some
|
||||
|
||||
toc_evil <User> <norm|anon>
|
||||
Evil/Warn someone else. The 2nd argument is either the string
|
||||
"norm" for a normal warning, or "anon" for an anonymous
|
||||
warning. You can only evil people who have recently sent you
|
||||
ims. The higher someones evil level, the slower they can
|
||||
send message.
|
||||
|
||||
toc_add_permit [ <User 1> [<User 2> [...]]]
|
||||
ADD the following people to your permit mode. If
|
||||
you are in deny mode it will switch you to permit
|
||||
mode first. With no arguments and in deny mode
|
||||
this will switch you to permit none. If already
|
||||
in permit mode, no arguments does nothing
|
||||
and your permit list remains the same.
|
||||
|
||||
toc_add_deny [ <User 1> [<User 2> [... ]]]
|
||||
ADD the following people to your deny mode. If
|
||||
you are in permit mode it will switch you to
|
||||
deny mode first. With no arguments and in permit
|
||||
mode, this will switch you to deny none. If
|
||||
already in deny mode, no arguments does nothing
|
||||
and your deny list remains unchanged.
|
||||
|
||||
toc_chat_join <Exchange> <Chat Room Name>
|
||||
Join a chat room in the given exchange. Exchange is
|
||||
an integer that represents a group of chat rooms.
|
||||
Different exchanges have different properties. For
|
||||
example some exchanges might have room replication (ie
|
||||
a room never fills up, there are just multiple
|
||||
instances.) and some exchanges might have navigational
|
||||
information, and some exchanges might have ... Currently
|
||||
exchange should always be 4, however this may
|
||||
change in the future. You will either
|
||||
receive an ERROR if the room couldn't be joined
|
||||
or a CHAT_JOIN message. The Chat Room Name
|
||||
is case insensitive and consecutive spaces
|
||||
are removed.
|
||||
|
||||
toc_chat_send <Chat Room ID> <Message>
|
||||
Send a message in a chat room using the chat room
|
||||
id from CHAT_JOIN. Since reflection is always on in
|
||||
TOC, you do not need to add the message to your chat UI,
|
||||
since you will get a CHAT_IN with the message.
|
||||
Remember to quote and encode the message.
|
||||
|
||||
toc_chat_whisper <Chat Room ID> <dst_user> <Message>
|
||||
Send a message in a chat room using the chat room
|
||||
id from CHAT_JOIN. This message is directed at
|
||||
only one person. (Currently you DO need to add this to
|
||||
your UI.) Remember to quote and encode the message.
|
||||
Chat whispering is different from IMs since it is linked
|
||||
to a chat room, and should usually be displayed in the chat
|
||||
room UI.
|
||||
|
||||
toc_chat_evil <Chat Room ID> <User> <norm|anon>
|
||||
Evil/Warn someone else inside a chat room. The 3rd argument is either
|
||||
the string "norm" for a normal warning, or "anon" for an anonymous
|
||||
warning. Currently chat evil is not turned on in the chat complex.
|
||||
|
||||
toc_chat_invite <Chat Room ID> <Invite Msg> <buddy1> [<buddy2> [<buddy3> [...]]]
|
||||
Once you are inside a chat room you can invite other people into
|
||||
that room. Remember to quote and encode the invite message.
|
||||
|
||||
toc_chat_leave <Chat Room ID>
|
||||
Leave the chat room.
|
||||
|
||||
toc_chat_accept <Chat Room ID>
|
||||
Accept a CHAT_INVITE message from TOC. The server will send a
|
||||
CHAT_JOIN in response.
|
||||
|
||||
toc_get_info <username>
|
||||
Gets a user's info a GOTO_URL or ERROR message will be sent back to the
|
||||
client.
|
||||
|
||||
toc_set_info <info information>
|
||||
Set the LOCATE user information. This is basic HTML.
|
||||
Remember to encode the info.
|
||||
|
||||
toc_set_away [<away message>]
|
||||
if the away message is present, then the unavailable
|
||||
status flag is set for the user. If the away message
|
||||
is not present, then the unavailable status flag is
|
||||
unset. The away message is basic HTML, remember to
|
||||
encode the information.
|
||||
|
||||
toc_get_dir <username>
|
||||
Gets a user's dir info a GOTO_URL or ERROR message will be sent back to the
|
||||
client.
|
||||
|
||||
toc_set_dir <info information>
|
||||
Set the DIR user information. This is a colon separated fields as in:
|
||||
"first name":"middle name":"last name":"maiden name":"city":"state":"country":"email":"allow web searches"
|
||||
Should return a DIR_STATUS msg. Having anything in the "allow web searches"
|
||||
field allows people to use web-searches to find your directory info.
|
||||
Otherwise, they'd have to use the client.
|
||||
|
||||
toc_dir_search <info information>
|
||||
Perform a search of the Oscar Directory, using colon separated fields as in:
|
||||
"first name":"middle name":"last name":"maiden name":"city":"state":"country":"email"
|
||||
Returns either a GOTO_URL or ERROR msg.
|
||||
|
||||
toc_set_idle <idle secs>
|
||||
Set idle information. If <idle secs> is 0 then the user isn't idle at all.
|
||||
If <idle secs> is greater then 0 then the user has already been idle
|
||||
for <idle secs> number of seconds. The server will automatically
|
||||
keep incrementing this number, so do not repeatedly call with new
|
||||
idle times.
|
||||
|
||||
|
||||
TOC -> Client
|
||||
==============
|
||||
All user names from TOC to client are NOT normalized, and are
|
||||
sent as they should be displayed. String are NOT encoded, instead
|
||||
we use colons as separators. So that you can have colons inside
|
||||
of messages, everything after the colon before :<Message> should
|
||||
be considered part of the message (ie don't just "split" on colons,
|
||||
instead split with a max number of results.)
|
||||
|
||||
|
||||
SIGN_ON:<Client Version Supported>
|
||||
This is sent after a successful toc_signon command is sent to TOC.
|
||||
If the command was unsuccessful either the FLAP connection will
|
||||
be dropped or you will receive a ERROR message.
|
||||
|
||||
CONFIG:<config>
|
||||
A user's config. Config can be empty in which case the host was not able to
|
||||
retrieve it, or a config didn't exist for the user. See toc_set_config
|
||||
above for the format.
|
||||
|
||||
NICK:<Nickname>
|
||||
Tells you your correct nickname (ie how it should be capitalized and
|
||||
spacing)
|
||||
|
||||
IM_IN:<Source User>:<Auto Response T/F?>:<Message>
|
||||
Receive an IM from some one. Everything after the third colon is
|
||||
the incoming message, including other colons.
|
||||
|
||||
UPDATE_BUDDY:<Buddy User>:<Online? T/F>:<Evil Amount>:<Signon Time>:<IdleTime>:<UC>
|
||||
This one command handles arrival/depart/updates. Evil Amount is
|
||||
a percentage, Signon Time is UNIX epoc, idle time is in minutes, UC (User Class)
|
||||
is a two/three character string.
|
||||
uc[0]:
|
||||
' ' - Ignore
|
||||
'A' - On AOL
|
||||
uc[1]
|
||||
' ' - Ignore
|
||||
'A' - Oscar Admin
|
||||
'U' - Oscar Unconfirmed
|
||||
'O' - Oscar Normal
|
||||
uc[2]
|
||||
'\0' - Ignore
|
||||
' ' - Ignore
|
||||
'U' - The user has set their unavailable flag.
|
||||
|
||||
|
||||
|
||||
ERROR:<Error Code>:Var args
|
||||
* General Errors *
|
||||
901 - $1 not currently available
|
||||
902 - Warning of $1 not currently available
|
||||
903 - A message has been dropped, you are exceeding
|
||||
the server speed limit
|
||||
* Chat Errors *
|
||||
950 - Chat in $1 is unavailable.
|
||||
|
||||
* IM & Info Errors *
|
||||
960 - You are sending message too fast to $1
|
||||
961 - You missed an im from $1 because it was too big.
|
||||
962 - You missed an im from $1 because it was sent too fast.
|
||||
|
||||
* Dir Errors *
|
||||
970 - Failure
|
||||
971 - Too many matches
|
||||
972 - Need more qualifiers
|
||||
973 - Dir service temporarily unavailable
|
||||
974 - Email lookup restricted
|
||||
975 - Keyword Ignored
|
||||
976 - No Keywords
|
||||
977 - Language not supported
|
||||
978 - Country not supported
|
||||
979 - Failure unknown $1
|
||||
|
||||
* Auth errors *
|
||||
980 - Incorrect nickname or password.
|
||||
981 - The service is temporarily unavailable.
|
||||
982 - Your warning level is currently too high to sign on.
|
||||
983 - You have been connecting and
|
||||
disconnecting too frequently. Wait 10 minutes and try again.
|
||||
If you continue to try, you will need to wait even longer.
|
||||
989 - An unknown signon error has occurred $1
|
||||
|
||||
|
||||
EVILED:<new evil>:<name of eviler, blank if anonymous>
|
||||
The user was just eviled.
|
||||
|
||||
CHAT_JOIN:<Chat Room Id>:<Chat Room Name>
|
||||
We were able to join this chat room. The Chat Room Id is
|
||||
internal to TOC.
|
||||
|
||||
CHAT_IN:<Chat Room Id>:<Source User>:<Whisper? T/F>:<Message>
|
||||
A chat message was sent in a chat room.
|
||||
|
||||
CHAT_UPDATE_BUDDY:<Chat Room Id>:<Inside? T/F>:<User 1>:<User 2>...
|
||||
This one command handles arrival/departs from a chat room. The
|
||||
very first message of this type for each chat room contains the
|
||||
users already in the room.
|
||||
|
||||
CHAT_INVITE:<Chat Room Name>:<Chat Room Id>:<Invite Sender>:<Message>
|
||||
We are being invited to a chat room.
|
||||
|
||||
CHAT_LEFT:<Chat Room Id>
|
||||
Tells tic connection to chat room has been dropped
|
||||
|
||||
GOTO_URL:<Window Name>:<Url>
|
||||
Goto a URL. Window Name is the suggested internal name of the window
|
||||
to use. (Java supports this.)
|
||||
|
||||
DIR_STATUS:<Return Code>
|
||||
|
||||
|
||||
PAUSE
|
||||
Tells TIC to pause so we can do migration
|
||||
|
||||
Typical Signon Process
|
||||
======================
|
||||
Except for the section marked optional this is an sequential
|
||||
process. Each line MUST occur before the following line.
|
||||
|
||||
* Client connects to TOC
|
||||
* Client sends "FLAPON\r\n\r\n"
|
||||
* TOC sends Client FLAP SIGNON
|
||||
* Client sends TOC FLAP SIGNON
|
||||
* Client sends TOC "toc_signon" message
|
||||
* if login fails TOC drops client's connection
|
||||
else TOC sends client SIGN_ON reply
|
||||
* if Client doesn't support version it drops the connection
|
||||
|
||||
[BEGIN OPTIONAL]
|
||||
* TOC sends Client CONFIG
|
||||
* Client sends TOC permit/deny stuff
|
||||
* Client sends TOC toc_add_buddy message
|
||||
[END OPTIONAL]
|
||||
|
||||
* Client sends TOC toc_init_done message
|
||||
|
||||
|
||||
SFLAP Documentation
|
||||
===================
|
||||
SFLAP is pretty much a FLAP connection except the DATA frame payload is a null
|
||||
terminated string when traveling from client to host, it is NOT null
|
||||
terminated when traveling from host to client. The FLAP Header is binary
|
||||
data, and is in network byte order. The data portion is at offset 6, after the
|
||||
header. The sequence number is sequential in each direction. So
|
||||
packets from the server to client have one sequence number, while
|
||||
the packets from the client to server have an independent
|
||||
increasing number.
|
||||
|
||||
FLAP Header (6 bytes)
|
||||
-----------
|
||||
Offset Size Type
|
||||
0 1 ASTERISK (literal ASCII '*')
|
||||
1 1 Frame Type
|
||||
2 2 Sequence Number
|
||||
4 2 Data Length
|
||||
|
||||
|
||||
Valid Frame Type Values
|
||||
-----------------------
|
||||
1 SIGNON
|
||||
2 DATA
|
||||
3 ERROR (Not used by TOC)
|
||||
4 SIGNOFF (Not used by TOC)
|
||||
5 KEEP_ALIVE
|
||||
|
||||
|
||||
TOC SIGNON FRAME TYPE
|
||||
---------------------
|
||||
Sequence Number contains the initial sequence number used in each direction.
|
||||
Data Length contains the payload length, with the payload described
|
||||
below. The payload area is NOT null terminated.
|
||||
|
||||
Host To Client:
|
||||
4 byte FLAP version (1)
|
||||
|
||||
Client To Host:
|
||||
4 byte FLAP version (1)
|
||||
2 byte TLV Tag (1)
|
||||
2 byte Normalized User Name Length
|
||||
N byte Normalized User Name (NOT null terminated)
|
||||
|
||||
|
||||
TOC DATA FRAME TYPE
|
||||
-------------------
|
||||
Sequence Number contains the next sequence number.
|
||||
Data Length is the length of the payload, including the null termination
|
||||
from client to host.
|
||||
|
||||
5
dll/aim/toc/README
Normal file
5
dll/aim/toc/README
Normal file
@@ -0,0 +1,5 @@
|
||||
Most of this code is from gaim, I just hacked it up a bit to un gtkify it
|
||||
and separated it from the interface code. Anyway, I plan to completely
|
||||
seperate this from the interface code and release it so anyone can add a
|
||||
aim client to whatever they like.
|
||||
|
||||
3
dll/aim/toc/TODO
Normal file
3
dll/aim/toc/TODO
Normal file
@@ -0,0 +1,3 @@
|
||||
- fix BUGS
|
||||
- code cleanup
|
||||
- create better docummentation on usage
|
||||
345
dll/aim/toc/buddy.c
Normal file
345
dll/aim/toc/buddy.c
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* gaim
|
||||
*
|
||||
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Heavily modified by Nadeem Riaz (nads@bleh.org)
|
||||
* for use in libtoc
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "ll.h"
|
||||
#include "toc.h"
|
||||
|
||||
LL groups;
|
||||
LL permit;
|
||||
LL deny;
|
||||
LL buddy_chats;
|
||||
LL invited_chats;
|
||||
|
||||
struct buddy *add_buddy(char *group, char *buddy)
|
||||
{
|
||||
struct buddy *b;
|
||||
struct group *g;
|
||||
|
||||
toc_debug_printf("adding '%s' to '%s'\n",buddy,group);
|
||||
|
||||
if ((b = find_buddy(buddy)) != NULL)
|
||||
return b;
|
||||
|
||||
g = find_group(group);
|
||||
|
||||
if (g == NULL)
|
||||
g = add_group(group);
|
||||
|
||||
b = (struct buddy *) malloc(sizeof(struct buddy));
|
||||
|
||||
if (!b)
|
||||
return NULL;
|
||||
|
||||
b->present = 0;
|
||||
|
||||
snprintf(b->name, sizeof(b->name), "%s", buddy);
|
||||
AddToLL(g->members,b->name,b);
|
||||
|
||||
b->idle = 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
struct group *add_group(char *group)
|
||||
{
|
||||
struct group *g;
|
||||
g = (struct group *) malloc(sizeof(struct group));
|
||||
if (!g)
|
||||
return NULL;
|
||||
|
||||
strncpy(g->name, group, sizeof(g->name));
|
||||
AddToLL(groups, g->name, g);
|
||||
|
||||
g->members = CreateLL();
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
struct group *find_group(char *group)
|
||||
{
|
||||
struct group *g;
|
||||
LLE e;
|
||||
char *grpname = malloc(strlen(group) + 1);
|
||||
strcpy(grpname, normalize(group));
|
||||
|
||||
for ( TLL(groups,e) ) {
|
||||
g = (struct group *)e->data;
|
||||
if (!strcasecmp(normalize(g->name), grpname)) {
|
||||
free(grpname);
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
free(grpname);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
struct buddy *find_buddy(char *who)
|
||||
{
|
||||
struct group *g;
|
||||
struct buddy *b;
|
||||
LLE tg,tb;
|
||||
LL mems;
|
||||
char *whoname = malloc(strlen(who) + 1);
|
||||
|
||||
strcpy(whoname, normalize(who));
|
||||
|
||||
for ( TLL(groups,tg) ) {
|
||||
g = (struct group *) tg->data;
|
||||
mems = g->members;
|
||||
|
||||
for ( TLL(mems,tb) ) {
|
||||
b = (struct buddy *)tb->data;
|
||||
if (!strcasecmp(normalize(b->name), whoname)) {
|
||||
free(whoname);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free(whoname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int user_remove_buddy(char *buddy) {
|
||||
struct group *g;
|
||||
struct buddy *b;
|
||||
LLE e,m;
|
||||
char *budname = malloc(strlen(buddy) + 1);
|
||||
strcpy(budname, normalize(buddy));
|
||||
|
||||
for ( TLL(groups,e) ) {
|
||||
g = (struct group *)e->data;
|
||||
|
||||
for ( TLL(g->members,m) ) {
|
||||
b = (struct buddy *)m->data;
|
||||
if ( ! strcasecmp(normalize(b->name),budname) ) {
|
||||
RemoveFromLLByKey(g->members,buddy);
|
||||
serv_remove_buddy(buddy);
|
||||
serv_save_config();
|
||||
free(budname);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(budname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int user_add_buddy(char *group, char *buddy) {
|
||||
struct buddy *b;
|
||||
b = find_buddy(buddy);
|
||||
if ( b != NULL )
|
||||
return -1;
|
||||
add_buddy(group,buddy);
|
||||
serv_add_buddy(buddy);
|
||||
serv_save_config();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* mode 1 = move current group members to a enw group
|
||||
* mode 2 = delete current group members from buddy list
|
||||
*/
|
||||
int remove_group(char *group, char *newgroup, int mode)
|
||||
{
|
||||
LL mem;
|
||||
LLE t;
|
||||
|
||||
struct group *delg = find_group(group);
|
||||
struct group *newg = NULL;
|
||||
struct buddy *delb;
|
||||
|
||||
if ( ! delg ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mode == 1 ) {
|
||||
newg = find_group(newgroup);
|
||||
if ( ! newg ) {
|
||||
newg = add_group(newgroup);
|
||||
}
|
||||
}
|
||||
|
||||
mem = delg->members;
|
||||
for ( TLL(mem,t) ) {
|
||||
delb = (struct buddy *)t->data;
|
||||
if ( mode == 1 ) {
|
||||
AddToLL(newg->members,delb->name,delb);
|
||||
} else {
|
||||
serv_remove_buddy(delb->name);
|
||||
/* free(delb); */
|
||||
}
|
||||
}
|
||||
|
||||
RemoveFromLLByKey(groups,delg->name);
|
||||
serv_save_config();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int add_permit(char *sn) {
|
||||
LLE t;
|
||||
t = FindInLL(permit,sn);
|
||||
if ( t )
|
||||
return -1;
|
||||
AddToLL(permit,sn,NULL);
|
||||
if ( permdeny == PERMIT_PERMITSOME )
|
||||
serv_add_permit(sn);
|
||||
serv_save_config();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int remove_permit(char *sn) {
|
||||
LLE t;
|
||||
t = FindInLL(permit,sn);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
RemoveFromLLByKey(permit,sn);
|
||||
serv_save_config();
|
||||
if (permdeny == PERMIT_PERMITSOME )
|
||||
serv_set_permit_deny();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int add_deny(char *sn) {
|
||||
LLE t;
|
||||
t = FindInLL(deny,sn);
|
||||
if ( t )
|
||||
return -1;
|
||||
AddToLL(deny,sn,NULL);
|
||||
if ( permdeny == PERMIT_DENYSOME )
|
||||
serv_add_deny(sn);
|
||||
serv_save_config();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int remove_deny(char *sn) {
|
||||
LLE t;
|
||||
t = FindInLL(deny,sn);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
RemoveFromLLByKey(deny,sn);
|
||||
if ( permdeny == PERMIT_DENYSOME ) {
|
||||
/*
|
||||
* DAMN AOL HOEBAGS to lazzy toinclude a delete from deny list
|
||||
* Thus we need to first go into permit mode */
|
||||
serv_set_permit_deny();
|
||||
}
|
||||
serv_save_config();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buddy_invite(char *chat, char *buddy, char *msg) {
|
||||
LLE t;
|
||||
struct buddy_chat *b;
|
||||
t = FindInLL(buddy_chats,chat);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
b = (struct buddy_chat *)t->data;
|
||||
serv_chat_invite(b->id, msg, buddy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks invite list first
|
||||
* then tries to create chat
|
||||
*/
|
||||
|
||||
void buddy_chat_join(char *chan) {
|
||||
LLE t = FindInLL(invited_chats,chan);
|
||||
if ( ! t ) {
|
||||
/* Standard exchange is 4 */
|
||||
toc_debug_printf("Creating chan %s",chan);
|
||||
serv_join_chat(4,chan);
|
||||
} else {
|
||||
/* The chat is in our invite list */
|
||||
int *d;
|
||||
d = (int *) t->data;
|
||||
serv_accept_chat(*d);
|
||||
toc_debug_printf("Trying to join invited to %s %d",t->key, *d);
|
||||
RemoveFromLLByKey(invited_chats,chan);
|
||||
}
|
||||
}
|
||||
|
||||
struct buddy_chat *find_buddy_chat(char *chat) {
|
||||
LLE t;
|
||||
t = FindInLL(buddy_chats,chat);
|
||||
if ( ! t )
|
||||
return NULL;
|
||||
else
|
||||
return (struct buddy_chat *) t->data;
|
||||
}
|
||||
|
||||
int buddy_chat_leave(char *chan) {
|
||||
LLE t;
|
||||
struct buddy_chat *b;
|
||||
t = FindInLL(buddy_chats,chan);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
b = (struct buddy_chat *) t->data;
|
||||
serv_chat_leave(b->id);
|
||||
/* Removed from buddy_chats in toc_callback */
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct buddy_chat *buddy_chat_getbyid(int id) {
|
||||
LLE t;
|
||||
struct buddy_chat *b;
|
||||
for ( TLL(buddy_chats,t) ) {
|
||||
b = (struct buddy_chat *) t->data;
|
||||
if ( id == b->id )
|
||||
return b;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int buddy_chat_invite(char *chat, char *buddy, char *msg) {
|
||||
LLE t;
|
||||
struct buddy_chat *b;
|
||||
t = FindInLL(buddy_chats,chat);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
b = (struct buddy_chat *) t->data;
|
||||
serv_chat_invite(b->id, msg, buddy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int buddy_chat_warn(char *chat, char *user, int anon) {
|
||||
LLE t;
|
||||
struct buddy_chat *b;
|
||||
t = FindInLL(buddy_chats,chat);
|
||||
if ( ! t )
|
||||
return -1;
|
||||
b = (struct buddy_chat *) t->data;
|
||||
serv_chat_warn(b->id, user, anon);
|
||||
return 1;
|
||||
}
|
||||
86
dll/aim/toc/interface.c
Normal file
86
dll/aim/toc/interface.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* interface.c
|
||||
*
|
||||
* by Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* Probably should be renamed misc.c (oh well)
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "toc.h"
|
||||
|
||||
int (*TOC_RAW_HANDLERS[30])(int, char *);
|
||||
int (*TOC_HANDLERS[30])(int, char **);
|
||||
|
||||
void init_toc() {
|
||||
int x;
|
||||
groups = NULL;
|
||||
permit = NULL;
|
||||
deny = NULL;
|
||||
buddy_chats = NULL;
|
||||
invited_chats = NULL;
|
||||
strcpy(aim_host,TOC_HOST);
|
||||
aim_port = TOC_PORT;
|
||||
strcpy(login_host,AUTH_HOST);
|
||||
login_port = AUTH_PORT;
|
||||
|
||||
/* Init Handlers */
|
||||
for (x=0;x<30;x++)
|
||||
TOC_HANDLERS[x] = NULL;
|
||||
for (x=0;x<30;x++)
|
||||
TOC_RAW_HANDLERS[x] = NULL;
|
||||
|
||||
}
|
||||
|
||||
void init_lists() {
|
||||
if ( groups == NULL ) {
|
||||
groups = (LL) CreateLL();
|
||||
SetFreeLLE(groups,&misc_free_group);
|
||||
}
|
||||
if ( permit == NULL )
|
||||
permit = (LL) CreateLL();
|
||||
if ( deny == NULL )
|
||||
deny = (LL) CreateLL();
|
||||
if ( buddy_chats == NULL ) {
|
||||
buddy_chats = CreateLL();
|
||||
SetFreeLLE(buddy_chats,&misc_free_buddy_chat);
|
||||
}
|
||||
if ( invited_chats == NULL ) {
|
||||
invited_chats = CreateLL();
|
||||
SetFreeLLE(invited_chats,&misc_free_invited_chats);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int install_handler(int type, int (*func)(int, char **)) {
|
||||
TOC_HANDLERS[type] = func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int install_raw_handler(int type, int (*func)(int, char *)) {
|
||||
TOC_RAW_HANDLERS[type] = func;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int use_handler(int mode,int type, void *args) {
|
||||
int ret = 0;
|
||||
toc_debug_printf("use_handler: mode = %d type = %d",mode,type);
|
||||
if ( mode == TOC_HANDLE ) {
|
||||
if ( TOC_HANDLERS[type] == NULL )
|
||||
toc_debug_printf("Error, no handler installed for %d type",type);
|
||||
else
|
||||
ret = TOC_HANDLERS[type](type, (char **) args);
|
||||
} else if ( mode == TOC_RAW_HANDLE ) {
|
||||
if ( TOC_RAW_HANDLERS[type] == NULL )
|
||||
toc_debug_printf("Error, no raw handler installed for %d type",type);
|
||||
else
|
||||
ret = TOC_RAW_HANDLERS[type](type, (char *) args);
|
||||
} else {
|
||||
toc_debug_printf("Error: %d : unkown handle mode!",mode);
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
148
dll/aim/toc/ll.c
Normal file
148
dll/aim/toc/ll.c
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Simple linked list library (replaces GList stuff)
|
||||
* Yea, it isnt efficient, but its only meant to be used for buddy lists (n < 100) THAT AINT LARGE :)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ll.h"
|
||||
|
||||
/* Creation */
|
||||
|
||||
LL CreateLL() {
|
||||
LL newlist;
|
||||
LLE head;
|
||||
newlist = (LL) malloc(sizeof(struct _ll));
|
||||
head = (LLE) CreateLLE("head element",NULL,NULL);
|
||||
if ( ! head )
|
||||
return NULL;
|
||||
newlist->head = head;
|
||||
newlist->items = 0;
|
||||
newlist->curr = head;
|
||||
newlist->free_e = NULL;
|
||||
return newlist;
|
||||
}
|
||||
|
||||
LLE CreateLLE (char *key, void *data, LLE next) {
|
||||
LLE newe;
|
||||
newe = (LLE) malloc(sizeof(struct _lle));
|
||||
if ( ! newe ) {
|
||||
perror("MEM allocation errory!");
|
||||
return NULL;
|
||||
}
|
||||
newe->key = (char *) malloc(strlen(key)+1);
|
||||
strcpy(newe->key,key);
|
||||
newe->data = data;
|
||||
newe->next = next;
|
||||
return newe;
|
||||
}
|
||||
|
||||
void SetFreeLLE(LL List, void (*free_e)(void *)) {
|
||||
List->free_e = free_e;
|
||||
}
|
||||
|
||||
int AddToLL(LL List, char *key, void *data) {
|
||||
LLE p = List->head;
|
||||
LLE e;
|
||||
while ( p->next != NULL ) {
|
||||
p = p->next;
|
||||
}
|
||||
e = CreateLLE(key,data,NULL);
|
||||
p->next = e;
|
||||
List->items++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
LLE FindInLL(LL List, char *key) {
|
||||
LLE p = List->head->next;
|
||||
while ( p != NULL ) {
|
||||
/* debug_printf("p != null, key = '%s'",p->key); */
|
||||
if ( ! strcasecmp(p->key,key) )
|
||||
break;
|
||||
p = p->next;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void *GetDataFromLLE(LLE e) {
|
||||
if ( e == NULL )
|
||||
return NULL;
|
||||
else
|
||||
return e->data;
|
||||
}
|
||||
|
||||
/* Removing Items from List */
|
||||
|
||||
int RemoveFromLL(LL List, LLE e) {
|
||||
LLE p = List->head;
|
||||
LLE b = NULL;
|
||||
while ( p != NULL && p != e ) {
|
||||
b = p;
|
||||
p = p->next;
|
||||
}
|
||||
if ( p == NULL )
|
||||
return -1;
|
||||
b->next = p->next;
|
||||
FreeLLE(p, List->free_e);
|
||||
List->items--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RemoveFromLLByKey(LL List, char *key) {
|
||||
LLE b = List->head;
|
||||
LLE p = b->next;
|
||||
while ( p != NULL ) {
|
||||
if ( ! strcasecmp(p->key,key) )
|
||||
break;
|
||||
b = p;
|
||||
p = p->next;
|
||||
}
|
||||
if ( p == NULL )
|
||||
return -1;
|
||||
b->next = p->next;
|
||||
FreeLLE(p, List->free_e);
|
||||
List->items--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* For easy loop traversals */
|
||||
|
||||
LLE GetNextLLE(LL List) {
|
||||
if ( List->curr != NULL )
|
||||
List->curr = List->curr->next;
|
||||
return List->curr;
|
||||
}
|
||||
|
||||
void ResetLLPosition(LL List) {
|
||||
List->curr = List->head;
|
||||
}
|
||||
|
||||
/* Only Free the keys at the moment */
|
||||
|
||||
void FreeLLE(LLE e, void (*free_e)(void *)) {
|
||||
if ( e->key != NULL )
|
||||
free(e->key);
|
||||
if ( free_e != NULL && e->data != NULL)
|
||||
free_e(e->data);
|
||||
free(e);
|
||||
return;
|
||||
}
|
||||
|
||||
void FreeLL(LL List) {
|
||||
LLE e;
|
||||
LLE n;
|
||||
if ( List == NULL ) {
|
||||
perror("SERIOUS ERROR: tried to free null list!");
|
||||
return;
|
||||
}
|
||||
e = List->head->next;
|
||||
free(List->head);
|
||||
while ( e != NULL ) {
|
||||
n = e->next;
|
||||
FreeLLE(e, List->free_e);
|
||||
e = n;
|
||||
}
|
||||
free(List);
|
||||
return;
|
||||
}
|
||||
44
dll/aim/toc/ll.h
Normal file
44
dll/aim/toc/ll.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _LL_H
|
||||
#define _LL_H
|
||||
|
||||
/*
|
||||
* Really bad list implementation
|
||||
*/
|
||||
|
||||
#define TLL(list,e) e = list->head->next; e; e = e->next
|
||||
|
||||
struct _lle {
|
||||
char *key;
|
||||
void *data;
|
||||
struct _lle *next;
|
||||
};
|
||||
|
||||
typedef struct _lle * LLE;
|
||||
|
||||
struct _ll {
|
||||
LLE head;
|
||||
LLE curr;
|
||||
void (*free_e)(void *);
|
||||
int items;
|
||||
|
||||
};
|
||||
|
||||
typedef struct _ll * LL;
|
||||
|
||||
LL CreateLL();
|
||||
void SetFreeLLE(LL List, void (*free_e)(void *));
|
||||
LLE CreateLLE (char *key, void *data, LLE next);
|
||||
int AddToLL(LL List, char *key, void *data);
|
||||
LLE FindInLL(LL List, char *key);
|
||||
void *GetDataFromLLE(LLE e);
|
||||
int RemoveFromLL(LL List, LLE e);
|
||||
int RemoveFromLLByKey(LL List, char *key);
|
||||
LLE GetNextLLE(LL List);
|
||||
void ResetLLPosition(LL List);
|
||||
void FreeLLE(LLE e, void (*free_e)(void *));
|
||||
void FreeLL(LL List);
|
||||
|
||||
|
||||
/* Internal */
|
||||
|
||||
#endif // _LL_H
|
||||
59
dll/aim/toc/misc.c
Normal file
59
dll/aim/toc/misc.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* misc.c
|
||||
*
|
||||
* by Nadeem Riaz (nads@bleh.org)
|
||||
*/
|
||||
|
||||
#include "toc.h"
|
||||
|
||||
char aim_host[512];
|
||||
int aim_port;
|
||||
char login_host[512];
|
||||
int login_port;
|
||||
char toc_addy[16];
|
||||
char aim_username[80];
|
||||
char aim_password[16];
|
||||
char *quad_addr;
|
||||
char debug_buff[1024];
|
||||
char user_info[2048];
|
||||
int registered;
|
||||
|
||||
char *USER_CLASSES[5] = {
|
||||
"AOL User",
|
||||
"AIM Admin",
|
||||
"Trial Aim User",
|
||||
"Normal Aim User",
|
||||
"Unavailable"
|
||||
};
|
||||
|
||||
char *PERMIT_MODES[4] = {
|
||||
"Permit All",
|
||||
"Deny All",
|
||||
"Permit Some",
|
||||
"Deny Some"
|
||||
};
|
||||
|
||||
void save_prefs()
|
||||
{
|
||||
}
|
||||
|
||||
void misc_free_group(void *data) {
|
||||
struct group *g;
|
||||
g = (struct group *) data;
|
||||
FreeLL(g->members);
|
||||
free(g);
|
||||
}
|
||||
|
||||
void misc_free_buddy_chat(void *data) {
|
||||
struct buddy_chat *b;
|
||||
b = (struct buddy_chat *) data;
|
||||
FreeLL(b->in_room);
|
||||
FreeLL(b->ignored);
|
||||
free(b);
|
||||
}
|
||||
|
||||
void misc_free_invited_chats(void *data) {
|
||||
int *t;
|
||||
t = (int *) data;
|
||||
free(t);
|
||||
}
|
||||
223
dll/aim/toc/network.c
Normal file
223
dll/aim/toc/network.c
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* gaim
|
||||
*
|
||||
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Modified by Nadeem Riaz (nads@bleh.org) (just rewrote the get_address function)
|
||||
* for use in libtoc
|
||||
*/
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/socket.h>
|
||||
#include "toc.h"
|
||||
#include "proxy.h"
|
||||
|
||||
int proxy_type = 0;
|
||||
char proxy_host[256];
|
||||
int proxy_port = 3128;
|
||||
char *proxy_realhost = NULL;
|
||||
|
||||
unsigned int *get_address(char *hostname)
|
||||
{
|
||||
struct hostent *hp;
|
||||
unsigned int *sin=NULL;
|
||||
if ((hp = proxy_gethostbyname(hostname))) {
|
||||
sin = (unsigned int *) malloc(sizeof(unsigned int));
|
||||
bcopy((char *)(*(hp->h_addr_list)),(char *)sin,sizeof(hp->h_addr_list));
|
||||
}
|
||||
return sin;
|
||||
}
|
||||
|
||||
|
||||
int connect_address(unsigned int addy, unsigned short port)
|
||||
{
|
||||
int fd;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
sin.sin_addr.s_addr = addy;
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (fd > -1) {
|
||||
quad_addr=strdup(inet_ntoa(sin.sin_addr));
|
||||
if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) {
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Proxy stuff
|
||||
*/
|
||||
|
||||
/* this code is borrowed from cvs 1.10 */
|
||||
static int
|
||||
proxy_recv_line (int sock, char **resultp)
|
||||
{
|
||||
int c;
|
||||
char *result;
|
||||
size_t input_index = 0;
|
||||
size_t result_size = 80;
|
||||
|
||||
result = (char *) malloc (result_size);
|
||||
|
||||
while (1)
|
||||
{
|
||||
char ch;
|
||||
if (recv (sock, &ch, 1, 0) < 0)
|
||||
fprintf (stderr, "recv() error from proxy server\n");
|
||||
c = ch;
|
||||
|
||||
if (c == EOF)
|
||||
{
|
||||
free (result);
|
||||
|
||||
/* It's end of file. */
|
||||
fprintf(stderr, "end of file from server\n");
|
||||
}
|
||||
|
||||
if (c == '\012')
|
||||
break;
|
||||
|
||||
result[input_index++] = c;
|
||||
while (input_index + 1 >= result_size)
|
||||
{
|
||||
result_size *= 2;
|
||||
result = (char *) realloc (result, result_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultp)
|
||||
*resultp = result;
|
||||
|
||||
/* Terminate it just for kicks, but we *can* deal with embedded NULs. */
|
||||
result[input_index] = '\0';
|
||||
|
||||
if (resultp == NULL)
|
||||
free (result);
|
||||
return input_index;
|
||||
}
|
||||
|
||||
|
||||
struct hostent *proxy_gethostbyname(char *host)
|
||||
{
|
||||
|
||||
if (proxy_type == PROXY_NONE)
|
||||
return (gethostbyname(host));
|
||||
|
||||
if (proxy_realhost != NULL)
|
||||
free(proxy_realhost);
|
||||
|
||||
/* we keep the real host name for the Connect command */
|
||||
proxy_realhost = (char *) strdup(host);
|
||||
|
||||
return (gethostbyname(proxy_host));
|
||||
|
||||
}
|
||||
|
||||
|
||||
int proxy_connect(int sockfd, struct sockaddr *serv_addr, int
|
||||
addrlen )
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int ret;
|
||||
|
||||
switch (proxy_type) {
|
||||
case PROXY_NONE:
|
||||
/* normal use */
|
||||
return (connect(sockfd,serv_addr,addrlen));
|
||||
break;
|
||||
case PROXY_HTTP: /* Http proxy */
|
||||
/* do the tunneling */
|
||||
/* step one : connect to proxy */
|
||||
{
|
||||
struct hostent *hostinfo;
|
||||
unsigned short shortport = proxy_port;
|
||||
|
||||
memset (&name, 0, sizeof (name));
|
||||
name.sin_family = AF_INET;
|
||||
name.sin_port = htons (shortport);
|
||||
hostinfo = gethostbyname (proxy_host);
|
||||
if (hostinfo == NULL) {
|
||||
fprintf (stderr, "Unknown host %s.\n", proxy_host);
|
||||
return (-1);
|
||||
}
|
||||
name.sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
||||
}
|
||||
toc_debug_printf("Trying to connect ...\n");
|
||||
if ((ret = connect(sockfd,(struct sockaddr *)&name,sizeof(name)))<0)
|
||||
return(ret);
|
||||
|
||||
/* step two : do proxy tunneling init */
|
||||
{
|
||||
char cmd[80];
|
||||
char *inputline;
|
||||
unsigned short realport=ntohs(((struct sockaddr_in *)serv_addr)->sin_port);
|
||||
sprintf(cmd,"CONNECT %s:%d HTTP/1.1\n\r\n\r",proxy_realhost,realport);
|
||||
toc_debug_printf("<%s>\n",cmd);
|
||||
if (send(sockfd,cmd,strlen(cmd),0)<0)
|
||||
return(-1);
|
||||
if (proxy_recv_line(sockfd,&inputline) < 0) {
|
||||
return(-1);
|
||||
}
|
||||
toc_debug_printf("<%s>\n",inputline);
|
||||
if (memcmp("HTTP/1.0 200 Connection established",inputline,35))
|
||||
if (memcmp("HTTP/1.1 200 Connection established",inputline,35)) {
|
||||
free(inputline);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
while (strlen(inputline)>1) {
|
||||
free(inputline);
|
||||
if (proxy_recv_line(sockfd,&inputline) < 0) {
|
||||
return(-1);
|
||||
}
|
||||
toc_debug_printf("<%s>\n",inputline);
|
||||
}
|
||||
free(inputline);
|
||||
}
|
||||
|
||||
return ret;
|
||||
break;
|
||||
case PROXY_SOCKS:
|
||||
fprintf(stderr,"Socks proxy is not yet implemented.\n");
|
||||
return(-1);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Unknown proxy type : %d.\n",proxy_type);
|
||||
break;
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
244
dll/aim/toc/out
Normal file
244
dll/aim/toc/out
Normal file
@@ -0,0 +1,244 @@
|
||||
toc.c: In function `toc_callback':
|
||||
toc.c:525: parse error before `;'
|
||||
toc.c:525: warning: statement with no effect
|
||||
toc.c:525: parse error before `)'
|
||||
toc.c:528: break statement not within loop or switch
|
||||
toc.c:515: warning: unused variable `buddy'
|
||||
toc.c:532: `b' undeclared (first use in this function)
|
||||
toc.c:532: (Each undeclared identifier is reported only once
|
||||
toc.c:532: for each function it appears in.)
|
||||
toc.c:536: `in' undeclared (first use in this function)
|
||||
toc.c:537: `buddy' undeclared (first use in this function)
|
||||
toc.c: At top level:
|
||||
toc.c:571: parse error before `else'
|
||||
toc.c:575: parse error before `2'
|
||||
toc.c:575: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:575: warning: data definition has no type or storage class
|
||||
toc.c:576: warning: type defaults to `int' in declaration of `idc'
|
||||
toc.c:576: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:576: initializer element is not constant
|
||||
toc.c:576: warning: data definition has no type or storage class
|
||||
toc.c:577: parse error before string constant
|
||||
toc.c:577: warning: type defaults to `int' in declaration of `sscanf'
|
||||
toc.c:577: warning: data definition has no type or storage class
|
||||
toc.c:579: warning: type defaults to `int' in declaration of `serv_got_chat_left'
|
||||
toc.c:579: warning: parameter names (without types) in function declaration
|
||||
toc.c:579: conflicting types for `serv_got_chat_left'
|
||||
toc.h:191: previous declaration of `serv_got_chat_left'
|
||||
toc.c:579: warning: data definition has no type or storage class
|
||||
toc.c:581: warning: type defaults to `int' in declaration of `numargs'
|
||||
toc.c:581: warning: data definition has no type or storage class
|
||||
toc.c:582: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:582: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:582: initializer element is not constant
|
||||
toc.c:582: warning: data definition has no type or storage class
|
||||
toc.c:583: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:583: conflicting types for `args'
|
||||
toc.c:582: previous declaration of `args'
|
||||
toc.c:583: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:583: invalid initializer
|
||||
toc.c:583: warning: data definition has no type or storage class
|
||||
toc.c:584: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:584: conflicting types for `args'
|
||||
toc.c:583: previous declaration of `args'
|
||||
toc.c:584: invalid initializer
|
||||
toc.c:584: warning: data definition has no type or storage class
|
||||
toc.c:585: parse error before `1'
|
||||
toc.c:585: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:585: warning: data definition has no type or storage class
|
||||
toc.c:589: conflicting types for `idc'
|
||||
toc.c:576: previous declaration of `idc'
|
||||
toc.c:591: `b' used prior to declaration
|
||||
toc.c:593: parse error before `2'
|
||||
toc.c:593: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:593: warning: data definition has no type or storage class
|
||||
toc.c:594: warning: type defaults to `int' in declaration of `idc'
|
||||
toc.c:594: conflicting types for `idc'
|
||||
toc.c:589: previous declaration of `idc'
|
||||
toc.c:594: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:594: initializer element is not constant
|
||||
toc.c:594: warning: data definition has no type or storage class
|
||||
toc.c:595: parse error before string constant
|
||||
toc.c:595: warning: type defaults to `int' in declaration of `sscanf'
|
||||
toc.c:595: warning: data definition has no type or storage class
|
||||
toc.c:596: warning: type defaults to `int' in declaration of `who'
|
||||
toc.c:596: conflicting types for `who'
|
||||
toc.c:590: previous declaration of `who'
|
||||
toc.c:596: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:596: initializer element is not constant
|
||||
toc.c:596: warning: data definition has no type or storage class
|
||||
toc.c:597: warning: type defaults to `int' in declaration of `whisper'
|
||||
toc.c:597: conflicting types for `whisper'
|
||||
toc.c:590: previous declaration of `whisper'
|
||||
toc.c:597: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:597: initializer element is not constant
|
||||
toc.c:597: warning: data definition has no type or storage class
|
||||
toc.c:598: warning: type defaults to `int' in declaration of `m'
|
||||
toc.c:598: conflicting types for `m'
|
||||
toc.c:589: previous declaration of `m'
|
||||
toc.c:598: initializer element is not constant
|
||||
toc.c:598: warning: data definition has no type or storage class
|
||||
toc.c:599: parse error before `while'
|
||||
toc.c:608: warning: type defaults to `int' in declaration of `b'
|
||||
toc.c:608: conflicting types for `b'
|
||||
toc.c:591: previous declaration of `b'
|
||||
toc.c:608: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:608: initializer element is not constant
|
||||
toc.c:608: warning: data definition has no type or storage class
|
||||
toc.c:609: parse error before `if'
|
||||
toc.c:611: parse error before string constant
|
||||
toc.c:611: warning: type defaults to `int' in declaration of `strcpy'
|
||||
toc.c:611: warning: data definition has no type or storage class
|
||||
toc.c:614: parse error before `->'
|
||||
toc.c:614: warning: type defaults to `int' in declaration of `strcpy'
|
||||
toc.c:614: warning: data definition has no type or storage class
|
||||
toc.c:616: warning: type defaults to `int' in declaration of `numargs'
|
||||
toc.c:616: redefinition of `numargs'
|
||||
toc.c:581: `numargs' previously defined here
|
||||
toc.c:616: warning: data definition has no type or storage class
|
||||
toc.c:617: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:617: conflicting types for `args'
|
||||
toc.c:584: previous declaration of `args'
|
||||
toc.c:617: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:617: initializer element is not constant
|
||||
toc.c:617: warning: data definition has no type or storage class
|
||||
toc.c:618: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:618: conflicting types for `args'
|
||||
toc.c:617: previous declaration of `args'
|
||||
toc.c:618: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:618: invalid initializer
|
||||
toc.c:618: warning: data definition has no type or storage class
|
||||
toc.c:619: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:619: conflicting types for `args'
|
||||
toc.c:618: previous declaration of `args'
|
||||
toc.c:619: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:619: invalid initializer
|
||||
toc.c:619: warning: data definition has no type or storage class
|
||||
toc.c:620: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:620: conflicting types for `args'
|
||||
toc.c:619: previous declaration of `args'
|
||||
toc.c:620: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:620: invalid initializer
|
||||
toc.c:620: warning: data definition has no type or storage class
|
||||
toc.c:621: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:621: conflicting types for `args'
|
||||
toc.c:620: previous declaration of `args'
|
||||
toc.c:621: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:621: invalid initializer
|
||||
toc.c:621: warning: data definition has no type or storage class
|
||||
toc.c:623: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:623: conflicting types for `args'
|
||||
toc.c:621: previous declaration of `args'
|
||||
toc.c:623: invalid initializer
|
||||
toc.c:623: warning: data definition has no type or storage class
|
||||
toc.c:624: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:624: conflicting types for `args'
|
||||
toc.c:623: previous declaration of `args'
|
||||
toc.c:624: invalid initializer
|
||||
toc.c:624: warning: data definition has no type or storage class
|
||||
toc.c:625: parse error before `1'
|
||||
toc.c:625: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:625: warning: data definition has no type or storage class
|
||||
toc.c:628: conflicting types for `who'
|
||||
toc.c:596: previous declaration of `who'
|
||||
toc.c:629: conflicting types for `idc'
|
||||
toc.c:594: previous declaration of `idc'
|
||||
toc.c:632: parse error before `2'
|
||||
toc.c:632: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:632: warning: data definition has no type or storage class
|
||||
toc.c:633: warning: type defaults to `int' in declaration of `name'
|
||||
toc.c:633: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:633: initializer element is not constant
|
||||
toc.c:633: warning: data definition has no type or storage class
|
||||
toc.c:634: warning: type defaults to `int' in declaration of `idc'
|
||||
toc.c:634: conflicting types for `idc'
|
||||
toc.c:629: previous declaration of `idc'
|
||||
toc.c:634: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:634: initializer element is not constant
|
||||
toc.c:634: warning: data definition has no type or storage class
|
||||
toc.c:635: parse error before string constant
|
||||
toc.c:635: warning: type defaults to `int' in declaration of `sscanf'
|
||||
toc.c:635: warning: data definition has no type or storage class
|
||||
toc.c:636: warning: type defaults to `int' in declaration of `who'
|
||||
toc.c:636: conflicting types for `who'
|
||||
toc.c:628: previous declaration of `who'
|
||||
toc.c:636: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:636: initializer element is not constant
|
||||
toc.c:636: warning: data definition has no type or storage class
|
||||
toc.c:637: warning: type defaults to `int' in declaration of `message'
|
||||
toc.c:637: conflicting types for `message'
|
||||
toc.c:629: previous declaration of `message'
|
||||
toc.c:637: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:637: initializer element is not constant
|
||||
toc.c:637: warning: data definition has no type or storage class
|
||||
toc.c:639: warning: type defaults to `int' in declaration of `pid'
|
||||
toc.c:639: conflicting types for `pid'
|
||||
toc.c:630: previous declaration of `pid'
|
||||
toc.c:639: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:639: initializer element is not constant
|
||||
toc.c:639: warning: data definition has no type or storage class
|
||||
toc.c:640: warning: type defaults to `int' in declaration of `pid'
|
||||
toc.c:640: conflicting types for `pid'
|
||||
toc.c:639: previous declaration of `pid'
|
||||
toc.c:640: warning: initialization makes pointer from integer without a cast
|
||||
toc.c:640: initializer element is not constant
|
||||
toc.c:640: warning: data definition has no type or storage class
|
||||
toc.c:641: warning: type defaults to `int' in declaration of `AddToLL'
|
||||
toc.c:641: warning: parameter names (without types) in function declaration
|
||||
toc.c:641: warning: data definition has no type or storage class
|
||||
toc.c:642: warning: type defaults to `int' in declaration of `numargs'
|
||||
toc.c:642: redefinition of `numargs'
|
||||
toc.c:616: `numargs' previously defined here
|
||||
toc.c:642: warning: data definition has no type or storage class
|
||||
toc.c:643: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:643: conflicting types for `args'
|
||||
toc.c:624: previous declaration of `args'
|
||||
toc.c:643: warning: initialization makes integer from pointer without a cast
|
||||
toc.c:643: initializer element is not constant
|
||||
toc.c:643: warning: data definition has no type or storage class
|
||||
toc.c:644: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:644: conflicting types for `args'
|
||||
toc.c:643: previous declaration of `args'
|
||||
toc.c:644: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:644: invalid initializer
|
||||
toc.c:644: warning: data definition has no type or storage class
|
||||
toc.c:645: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:645: conflicting types for `args'
|
||||
toc.c:644: previous declaration of `args'
|
||||
toc.c:645: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:645: invalid initializer
|
||||
toc.c:645: warning: data definition has no type or storage class
|
||||
toc.c:646: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:646: conflicting types for `args'
|
||||
toc.c:645: previous declaration of `args'
|
||||
toc.c:646: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:646: invalid initializer
|
||||
toc.c:646: warning: data definition has no type or storage class
|
||||
toc.c:647: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:647: conflicting types for `args'
|
||||
toc.c:646: previous declaration of `args'
|
||||
toc.c:647: warning: passing arg 1 of `strdup' makes pointer from integer without a cast
|
||||
toc.c:647: invalid initializer
|
||||
toc.c:647: warning: data definition has no type or storage class
|
||||
toc.c:648: warning: type defaults to `int' in declaration of `args'
|
||||
toc.c:648: conflicting types for `args'
|
||||
toc.c:647: previous declaration of `args'
|
||||
toc.c:648: invalid initializer
|
||||
toc.c:648: warning: data definition has no type or storage class
|
||||
toc.c:649: parse error before `1'
|
||||
toc.c:649: warning: type defaults to `int' in declaration of `use_handler'
|
||||
toc.c:649: warning: data definition has no type or storage class
|
||||
toc.c:653: warning: type defaults to `int' in declaration of `free'
|
||||
toc.c:653: warning: parameter names (without types) in function declaration
|
||||
toc.c:653: conflicting types for `free'
|
||||
/usr/include/stdlib.h:484: previous declaration of `free'
|
||||
toc.c:653: warning: data definition has no type or storage class
|
||||
toc.c:654: warning: type defaults to `int' in declaration of `free'
|
||||
toc.c:654: warning: parameter names (without types) in function declaration
|
||||
toc.c:654: warning: data definition has no type or storage class
|
||||
toc.c:655: parse error before `if'
|
||||
toc.c:664: warning: type defaults to `int' in declaration of `free'
|
||||
toc.c:664: warning: parameter names (without types) in function declaration
|
||||
toc.c:664: warning: data definition has no type or storage class
|
||||
toc.c:665: parse error before `}'
|
||||
make: *** [toc.o] Error 1
|
||||
18
dll/aim/toc/proxy.h
Normal file
18
dll/aim/toc/proxy.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _PROXY_H
|
||||
#define _PROXY_H
|
||||
|
||||
/* proxy types */
|
||||
#define PROXY_NONE 0
|
||||
#define PROXY_HTTP 1
|
||||
#define PROXY_SOCKS 2 /* Not Implemented !! */
|
||||
|
||||
|
||||
extern struct hostent * proxy_gethostbyname(char *host);
|
||||
extern int proxy_connect(int sockfd, struct sockaddr *serv_addr, int addrlen );
|
||||
|
||||
extern int proxy_type;
|
||||
extern char proxy_host[256];
|
||||
extern int proxy_port;
|
||||
extern char *proxy_realhost;
|
||||
|
||||
#endif /* _PROXY_H */
|
||||
520
dll/aim/toc/server.c
Normal file
520
dll/aim/toc/server.c
Normal file
@@ -0,0 +1,520 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include "toc.h"
|
||||
|
||||
static time_t lastsent = 0;
|
||||
time_t login_time = 0;
|
||||
int my_evil;
|
||||
int is_idle = 0;
|
||||
int lag_ms = 0;
|
||||
int time_to_idle = 600;
|
||||
int is_away = 0;
|
||||
static struct timeval lag_tv;
|
||||
|
||||
void serv_add_buddy(char *name)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_remove_buddy(char *name)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
int serv_got_im(char *name, char *message, int away)
|
||||
{
|
||||
/*
|
||||
struct conversation *cnv;
|
||||
int is_idle = -1;
|
||||
*/
|
||||
char *nname;
|
||||
|
||||
nname = strdup(normalize(name));
|
||||
|
||||
if (!strcasecmp(normalize(name), nname)) {
|
||||
if (!strcmp(message, LAGOMETER_STR)) {
|
||||
struct timeval tv;
|
||||
int ms;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
ms = 1000000 * (tv.tv_sec - lag_tv.tv_sec);
|
||||
|
||||
ms += tv.tv_usec - lag_tv.tv_usec;
|
||||
|
||||
lag_ms = ms;
|
||||
use_handler(TOC_HANDLE,TOC_LAG_UPDATE,NULL);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
cnv = find_conversation(name);
|
||||
|
||||
if (cnv == NULL)
|
||||
cnv = new_conversation(name);
|
||||
|
||||
if (away)
|
||||
write_to_conv(cnv, message, WFLAG_AUTO | WFLAG_RECV);
|
||||
else
|
||||
write_to_conv(cnv, message, WFLAG_RECV);
|
||||
|
||||
|
||||
if (cnv->makesound && extrasounds)
|
||||
play_sound(RECEIVE);
|
||||
|
||||
|
||||
if (awaymessage != NULL) {
|
||||
time_t t;
|
||||
|
||||
time(&t);
|
||||
|
||||
|
||||
if ((cnv == NULL) || (t - cnv->sent_away) < 120)
|
||||
return;
|
||||
|
||||
cnv->sent_away = t;
|
||||
|
||||
if (is_idle)
|
||||
is_idle = -1;
|
||||
|
||||
|
||||
serv_send_im(name, awaymessage->message, 1);
|
||||
|
||||
if (is_idle == -1)
|
||||
is_idle = 1;
|
||||
|
||||
write_to_conv(cnv, awaymessage->message, WFLAG_SEND | WFLAG_AUTO);
|
||||
}
|
||||
*/
|
||||
toc_debug_printf("Received im from %s : %s\n",name,message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void serv_finish_login()
|
||||
{
|
||||
char *buf;
|
||||
|
||||
buf = strdup(user_info);
|
||||
escape_text(buf);
|
||||
serv_set_info(buf);
|
||||
free(buf);
|
||||
|
||||
use_handler(TOC_HANDLE,TOC_REINSTALL_TIMER,NULL);
|
||||
|
||||
time(&login_time);
|
||||
serv_touch_idle();
|
||||
|
||||
serv_add_buddy(aim_username);
|
||||
|
||||
if (!registered)
|
||||
{
|
||||
/* show_register_dialog(); */
|
||||
save_prefs();
|
||||
}
|
||||
}
|
||||
|
||||
void serv_add_buddies(LL buddies)
|
||||
{
|
||||
char buf[MSG_LEN];
|
||||
LLE e;
|
||||
int n, num = 0;
|
||||
|
||||
n = snprintf(buf, sizeof(buf), "toc_add_buddy");
|
||||
for ( TLL(buddies,e) ) {
|
||||
if (num == 20) {
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
n = snprintf(buf, sizeof(buf), "toc_add_buddy");
|
||||
num = 0;
|
||||
}
|
||||
++num;
|
||||
n += snprintf(buf + n, sizeof(buf) - n, " %s", normalize((char *)e->key));
|
||||
}
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void serv_got_update(char *name, int loggedin, int evil, time_t signon, time_t idle, int type)
|
||||
{
|
||||
struct buddy *b;
|
||||
char *nname,**args;
|
||||
|
||||
b = find_buddy(name);
|
||||
|
||||
nname = strdup(normalize(name));
|
||||
if (!strcasecmp(nname, normalize(aim_username))) {
|
||||
/*
|
||||
correction_time = (int)(signon - login_time);
|
||||
update_all_buddies();
|
||||
*/
|
||||
my_evil = evil;
|
||||
if (!b)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!b) {
|
||||
toc_debug_printf("Error, no such person\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* This code will 'align' the name from the TOC */
|
||||
/* server with what's in our record. We want to */
|
||||
/* store things how THEY want it... */
|
||||
/*
|
||||
if (strcmp(name, b->name)) {
|
||||
GList *cnv = conversations;
|
||||
struct conversation *cv;
|
||||
|
||||
char *who = g_malloc(80);
|
||||
|
||||
strcpy(who, normalize(name));
|
||||
|
||||
while(cnv) {
|
||||
cv = (struct conversation *)cnv->data;
|
||||
if (!strcasecmp(who, normalize(cv->name))) {
|
||||
g_snprintf(cv->name, sizeof(cv->name), "%s", name);
|
||||
if (find_log_info(name) || log_all_conv)
|
||||
g_snprintf(who, 63, LOG_CONVERSATION_TITLE, name);
|
||||
else
|
||||
g_snprintf(who, 63, CONVERSATION_TITLE, name);
|
||||
gtk_window_set_title(GTK_WINDOW(cv->window), who);
|
||||
*/
|
||||
/* no free 'who', set_title needs it.
|
||||
*/
|
||||
/*
|
||||
break;
|
||||
}
|
||||
cnv = cnv->next;
|
||||
}
|
||||
|
||||
g_snprintf(b->name, sizeof(b->name), "%s", name); */
|
||||
/*gtk_label_set_text(GTK_LABEL(b->label), b->name);*/
|
||||
|
||||
/* okay lets save the new config... */
|
||||
|
||||
/* } */
|
||||
|
||||
b->idle = idle;
|
||||
b->evil = evil;
|
||||
b->uc = type;
|
||||
|
||||
b->signon = signon;
|
||||
|
||||
if (loggedin) {
|
||||
if (!b->present) {
|
||||
b->present = 1;
|
||||
args = (char **) malloc(sizeof(char *)*1);
|
||||
args[0] = strdup(b->name);
|
||||
use_handler(TOC_HANDLE,TOC_BUDDY_LOGGED_ON,args);
|
||||
free(args[0]); free(args);
|
||||
/* do_pounce(b->name); */
|
||||
}
|
||||
} else {
|
||||
if ( b->present ) {
|
||||
args = (char **) malloc(sizeof(char *)*1);
|
||||
args[0] = strdup(b->name);
|
||||
use_handler(TOC_HANDLE,TOC_BUDDY_LOGGED_OFF,args);
|
||||
free(args[0]); free(args);
|
||||
}
|
||||
b->present = 0;
|
||||
}
|
||||
/*
|
||||
set_buddy(b);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void serv_send_im(char *name, char *message)
|
||||
{
|
||||
char buf[MSG_LEN - 7];
|
||||
snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name),
|
||||
message, ((is_away) ? " auto" : ""));
|
||||
sflap_send(buf, strlen(buf), TYPE_DATA);
|
||||
|
||||
if (!is_away && strcasecmp(message,LAGOMETER_STR) != 0)
|
||||
serv_touch_idle();
|
||||
|
||||
}
|
||||
|
||||
void serv_close()
|
||||
{
|
||||
toc_close();
|
||||
}
|
||||
|
||||
void serv_save_config()
|
||||
{
|
||||
char *buf = malloc(BUF_LONG);
|
||||
char *buf2 = malloc(MSG_LEN);
|
||||
toc_build_config(buf, BUF_LONG / 2);
|
||||
snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf);
|
||||
sflap_send(buf2, -1, TYPE_DATA);
|
||||
free(buf2);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void serv_warn(char *name, int anon)
|
||||
{
|
||||
char *send = malloc(256);
|
||||
snprintf(send, 255, "toc_evil %s %s", name,
|
||||
((anon) ? "anon" : "norm"));
|
||||
sflap_send(send, -1, TYPE_DATA);
|
||||
free(send);
|
||||
}
|
||||
|
||||
void serv_add_permit(char *name)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "toc_add_permit %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void serv_add_deny(char *name)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "toc_add_deny %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void serv_set_permit_deny()
|
||||
{
|
||||
char buf[MSG_LEN];
|
||||
char type[30];
|
||||
int at;
|
||||
LLE t;
|
||||
LL l;
|
||||
/* FIXME! We flash here. */
|
||||
if (permdeny == PERMIT_PERMITALL || permdeny == PERMIT_PERMITSOME) {
|
||||
strcpy(type,"toc_add_permit");
|
||||
l = permit;
|
||||
} else {
|
||||
strcpy(type,"toc_add_deny");
|
||||
l = deny;
|
||||
|
||||
}
|
||||
sflap_send(type, -1, TYPE_DATA);
|
||||
|
||||
if ( permdeny == PERMIT_DENYALL || permdeny == PERMIT_PERMITALL ) {
|
||||
if ( permdeny == PERMIT_DENYALL )
|
||||
strcpy(type,"toc_add_permit");
|
||||
else
|
||||
strcpy(type,"toc_add_deny");
|
||||
sflap_send(type, -1, TYPE_DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
at = snprintf(buf, sizeof(buf), "%s",type);
|
||||
for ( TLL(l,t) ) {
|
||||
at += snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(t->key));
|
||||
}
|
||||
buf[at] = 0;
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
|
||||
}
|
||||
|
||||
void serv_got_joined_chat(int id, char *name)
|
||||
{
|
||||
struct buddy_chat *b;
|
||||
|
||||
b = (struct buddy_chat *) malloc(sizeof(struct buddy_chat));
|
||||
b->ignored = CreateLL();
|
||||
b->in_room = CreateLL();
|
||||
b->id = id;
|
||||
b->init_chat = 0;
|
||||
snprintf(b->name, 80, "%s", name);
|
||||
|
||||
AddToLL(buddy_chats,name,b);
|
||||
}
|
||||
|
||||
void serv_got_chat_left(int id)
|
||||
{
|
||||
LLE t;
|
||||
struct buddy_chat *b = NULL;
|
||||
|
||||
for ( TLL(buddy_chats,t) ) {
|
||||
b = (struct buddy_chat *)t->data;
|
||||
if (id == b->id) {
|
||||
break;
|
||||
}
|
||||
b = NULL;
|
||||
}
|
||||
|
||||
if (!b)
|
||||
return;
|
||||
|
||||
RemoveFromLLByKey(buddy_chats,b->name);
|
||||
|
||||
toc_debug_printf("leaking memory in serv_got_chat_left");
|
||||
}
|
||||
|
||||
void serv_accept_chat(int i)
|
||||
{
|
||||
char *buf = malloc(256);
|
||||
snprintf(buf, 255, "toc_chat_accept %d", i);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void serv_join_chat(int exchange, char *name)
|
||||
{
|
||||
char buf[BUF_LONG];
|
||||
snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_chat_invite(int id, char *message, char *name)
|
||||
{
|
||||
char buf[BUF_LONG];
|
||||
snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_chat_leave(int id)
|
||||
{
|
||||
char *buf = malloc(256);
|
||||
snprintf(buf, 255, "toc_chat_leave %d", id);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void serv_chat_whisper(int id, char *who, char *message)
|
||||
{
|
||||
char buf2[MSG_LEN];
|
||||
snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message);
|
||||
sflap_send(buf2, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_chat_send(int id, char *message)
|
||||
{
|
||||
char buf[MSG_LEN];
|
||||
snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
serv_touch_idle();
|
||||
}
|
||||
|
||||
void serv_chat_warn(int id, char *user, int anon) {
|
||||
char send[256];
|
||||
snprintf(send, 255, "toc_chat_evil %d %s %s", id, user, ((anon) ? "anon" : "norm"));
|
||||
sflap_send(send, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
|
||||
void serv_get_dir(char *name) {
|
||||
char buf[MSG_LEN];
|
||||
snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_set_dir(char *first, char *middle, char *last, char *maiden,
|
||||
char *city, char *state, char *country, char *email, int web)
|
||||
{
|
||||
char buf2[BUF_LEN], buf[BUF_LEN];
|
||||
/* sending email seems to mess this up? */
|
||||
snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first,
|
||||
middle, last, maiden, city, state, country,
|
||||
(web == 1) ? "Y" : "");
|
||||
escape_text(buf2);
|
||||
snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_dir_search(char *first, char *middle, char *last, char *maiden,
|
||||
char *city, char *state, char *country, char *email)
|
||||
{
|
||||
char buf[BUF_LONG];
|
||||
snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, last, maiden, city, state, country, email);
|
||||
toc_debug_printf("Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
|
||||
void serv_get_info(char *name)
|
||||
{
|
||||
char buf[MSG_LEN];
|
||||
snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name));
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_set_info(char *info)
|
||||
{
|
||||
char buf[MSG_LEN];
|
||||
snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
void serv_touch_idle() {
|
||||
/* Are we idle? If so, not anymore */
|
||||
if (is_idle > 0) {
|
||||
is_idle = 0;
|
||||
serv_set_idle(0);
|
||||
use_handler(TOC_HANDLE,TOC_WENT_IDLE,NULL);
|
||||
}
|
||||
time(&lastsent);
|
||||
}
|
||||
|
||||
void serv_set_idle(int time)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "toc_set_idle %d", time);
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
int check_idle() {
|
||||
time_t t;
|
||||
|
||||
time(&t);
|
||||
|
||||
use_handler(TOC_HANDLE,TOC_REINSTALL_TIMER,NULL);
|
||||
gettimeofday(&lag_tv, NULL);
|
||||
serv_send_im(aim_username, LAGOMETER_STR);
|
||||
|
||||
/*
|
||||
if (report_idle != IDLE_GAIM)
|
||||
return TRUE;
|
||||
*/
|
||||
|
||||
|
||||
if (is_idle || is_away)
|
||||
return 1;
|
||||
|
||||
toc_debug_printf("time_to_idle = %d, current idle = %d, t = %d, last_sent = %d",time_to_idle,(t - lastsent),t,lastsent);
|
||||
if ((t - lastsent) > time_to_idle) { /* 10 minutes! */
|
||||
serv_set_idle((int)t - lastsent);
|
||||
toc_debug_printf("went idle wieth time_to_idle = %d",time_to_idle);
|
||||
use_handler(TOC_HANDLE,TOC_WENT_IDLE,NULL);
|
||||
is_idle = 1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
void serv_set_away(char *message) {
|
||||
char buf[MSG_LEN];
|
||||
if ( ! is_away && message ) {
|
||||
is_away = 1;
|
||||
snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message);
|
||||
} else {
|
||||
is_away = 0;
|
||||
snprintf(buf, MSG_LEN, "toc_set_away");
|
||||
}
|
||||
sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
17
dll/aim/toc/test/Makefile
Normal file
17
dll/aim/toc/test/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -g
|
||||
INCLUDES = -I../ -I../../
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $<
|
||||
|
||||
LTOBJS = lltest.o
|
||||
|
||||
lltest: $(LTOBJS)
|
||||
$(CC) -o lltest $(LTOBJS) ../ll.o
|
||||
|
||||
test: main.o
|
||||
gcc -o test main.o ../libtoc.a
|
||||
|
||||
clean:
|
||||
rm -rf lltest test main.o $(LTOBJS)
|
||||
60
dll/aim/toc/test/lltest.c
Normal file
60
dll/aim/toc/test/lltest.c
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "ll.h"
|
||||
|
||||
void myfunc(void *data) {
|
||||
char *t;
|
||||
t = (char *) data;
|
||||
printf("GOT data = %s\n",t);
|
||||
free(t);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
LL l = CreateLL();
|
||||
LL z = CreateLL();
|
||||
LLE e;
|
||||
char *b;
|
||||
FreeLL(z);
|
||||
SetFreeLLE(l,&myfunc);
|
||||
b = (char *) malloc(1000);
|
||||
strcpy(b,"I like you, you like me");
|
||||
AddToLL(l,"1",b);
|
||||
b = (char *) malloc(1000);
|
||||
strcpy(b,"or maybe not?");
|
||||
AddToLL(l,"2",b);
|
||||
b = (char *) malloc(1000);
|
||||
strcpy(b,"I hope you do at least!@$");
|
||||
AddToLL(l,"3",b);
|
||||
b = (char *) malloc(1000);
|
||||
strcpy(b,"8if you dont, why the fuxor not1@$");
|
||||
AddToLL(l,"4",b);
|
||||
ResetLLPosition(l);
|
||||
while ( (e = GetNextLLE(l)) ) {
|
||||
printf("key = %s, data = %s\n",e->key,(char *)e->data);
|
||||
}
|
||||
printf("Going to TLL Traversal\n");
|
||||
for ( TLL(l,e) ) {
|
||||
printf("key = %s, data = %s\n",e->key,(char *)e->data);
|
||||
}
|
||||
ResetLLPosition(l);
|
||||
e = FindInLL(l,"3");
|
||||
printf("result of find = %s\n",(char *)e->data);
|
||||
RemoveFromLLByKey(l,"2");
|
||||
while ( (e = GetNextLLE(l)) ) {
|
||||
printf("key = %s, data = %s\n",e->key,(char *)e->data);
|
||||
}
|
||||
e = FindInLL(l,"9");
|
||||
if ( e ) {
|
||||
printf("Found 9\n");
|
||||
} else {
|
||||
printf("didnt find key 9\n");
|
||||
}
|
||||
FreeLL(l);
|
||||
printf("l is freed, all good!\n");
|
||||
l = CreateLL();
|
||||
printf("back here\n");
|
||||
printf("%d\n",sizeof(struct _lle));
|
||||
printf("%d\n",sizeof(LLE));
|
||||
return 1;
|
||||
}
|
||||
61
dll/aim/toc/test/main.c
Normal file
61
dll/aim/toc/test/main.c
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include "toc.h"
|
||||
|
||||
extern int state;
|
||||
int sfd;
|
||||
int (*cb)(int);
|
||||
|
||||
int toc_got_im(char **args) {
|
||||
printf("msg: %s %s",args[0],args[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int toc_remove_input_stream(int fd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int toc_add_input_stream(int fd,int (*func)(int)) {
|
||||
sfd = fd;
|
||||
cb = func;
|
||||
printf("got input stream!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void statusput(char *buf) {
|
||||
printf("%s\n",buf);
|
||||
}
|
||||
|
||||
void statusprintf(char *fmt, ...)
|
||||
{
|
||||
char data[MAX_OUTPUT_MSG_LEN];
|
||||
va_list ptr;
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr);
|
||||
va_end(ptr);
|
||||
statusput(data);
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
fd_set set;
|
||||
init_toc();
|
||||
printf("state: %d\n",state);
|
||||
toc_login(argv[1],argv[2]);
|
||||
install_handler(TOC_IM_IN,&toc_got_im);
|
||||
printf("back from toc login call!\n");
|
||||
while ( 1 ) {
|
||||
FD_SET(sfd,&set);
|
||||
if ( select(sfd+1,&set,NULL,NULL,NULL) ) {
|
||||
if ( FD_ISSET(sfd,&set) ) {
|
||||
printf("data on sock!\n");
|
||||
cb(sfd);
|
||||
}
|
||||
}
|
||||
FD_ZERO(&set);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
869
dll/aim/toc/toc.c
Normal file
869
dll/aim/toc/toc.c
Normal file
@@ -0,0 +1,869 @@
|
||||
/*
|
||||
* gaim
|
||||
*
|
||||
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Heavily modified by Nadeem Riaz (nads@bleh.org)
|
||||
* for use in libtoc
|
||||
*/
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "toc.h"
|
||||
|
||||
/* descriptor for talking to TOC */
|
||||
static int toc_fd;
|
||||
static int seqno;
|
||||
static unsigned int peer_ver=0;
|
||||
int state;
|
||||
/* static int inpa=-1; */
|
||||
int permdeny = PERMIT_PERMITALL;
|
||||
|
||||
int toc_login(char *username, char *password)
|
||||
{
|
||||
char *config;
|
||||
struct in_addr *sin;
|
||||
char buf[80];
|
||||
char buf2[2048];
|
||||
|
||||
toc_debug_printf("looking up host! %s", aim_host);
|
||||
|
||||
sin = (struct in_addr *)get_address(aim_host);
|
||||
if (!sin) {
|
||||
set_state(STATE_OFFLINE);
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Unable to lookup %s", aim_host);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(toc_addy, sizeof(toc_addy), "%s", inet_ntoa(*sin));
|
||||
snprintf(buf, sizeof(buf), "Connecting to %s", inet_ntoa(*sin));
|
||||
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"%s",buf);
|
||||
|
||||
toc_fd = connect_address(sin->s_addr, aim_port);
|
||||
|
||||
if (toc_fd < 0) {
|
||||
set_state(STATE_OFFLINE);
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Connect to %s failed", inet_ntoa(*sin));
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(sin);
|
||||
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Signon: %s",username);
|
||||
|
||||
if (toc_signon(username, password) < 0) {
|
||||
set_state(STATE_OFFLINE);
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Disconnected.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Waiting for reply...");
|
||||
if (toc_wait_signon() < 0) {
|
||||
set_state(STATE_OFFLINE);
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Authentication Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
snprintf(aim_username, sizeof(aim_username), "%s", username);
|
||||
snprintf(aim_password, sizeof(aim_password), "%s", password);
|
||||
|
||||
save_prefs();
|
||||
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Retrieving config...");
|
||||
if ((config=toc_wait_config()) == NULL) {
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"No Configuration\n");
|
||||
set_state(STATE_OFFLINE);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
init_lists();
|
||||
/* gtk_widget_hide(mainwindow);
|
||||
show_buddy_list(); */
|
||||
parse_toc_buddy_list(config);
|
||||
/* refresh_buddy_window(); */
|
||||
|
||||
snprintf(buf2, sizeof(buf2), "toc_init_done");
|
||||
sflap_send(buf2, -1, TYPE_DATA);
|
||||
|
||||
serv_finish_login();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void toc_close()
|
||||
{
|
||||
seqno = 0;
|
||||
state = STATE_OFFLINE;
|
||||
toc_remove_input_stream(toc_fd);
|
||||
close(toc_fd);
|
||||
toc_fd=-1;
|
||||
}
|
||||
|
||||
int toc_signon(char *username, char *password)
|
||||
{
|
||||
char buf[BUF_LONG];
|
||||
int res;
|
||||
struct signon so;
|
||||
|
||||
toc_debug_printf("State = %d\n", state);
|
||||
|
||||
strncpy(aim_username, username, sizeof(aim_username));
|
||||
|
||||
if ((res = write(toc_fd, FLAPON, strlen(FLAPON))) < 0)
|
||||
return res;
|
||||
/* Wait for signon packet */
|
||||
|
||||
state = STATE_FLAPON;
|
||||
|
||||
if ((res = wait_reply(buf, sizeof(buf)) < 0))
|
||||
return res;
|
||||
|
||||
if (state != STATE_SIGNON_REQUEST) {
|
||||
toc_debug_printf( "State should be %d, but is %d instead\n", STATE_SIGNON_REQUEST, state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Compose a response */
|
||||
|
||||
snprintf(so.username, sizeof(so.username), "%s", username);
|
||||
so.ver = ntohl(1);
|
||||
so.tag = ntohs(1);
|
||||
so.namelen = htons(strlen(so.username));
|
||||
|
||||
sflap_send((char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON);
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"toc_signon %s %d %s %s %s \"%s\"",
|
||||
login_host, login_port, normalize(username), roast_password(password), LANGUAGE, REVISION);
|
||||
|
||||
toc_debug_printf("Send: %s\n", buf);
|
||||
|
||||
return sflap_send(buf, -1, TYPE_DATA);
|
||||
}
|
||||
|
||||
int toc_wait_signon()
|
||||
{
|
||||
/* Wait for the SIGNON to be approved */
|
||||
char buf[BUF_LEN];
|
||||
int res;
|
||||
res = wait_reply(buf, sizeof(buf));
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (state != STATE_SIGNON_ACK) {
|
||||
toc_debug_printf("State should be %d, but is %d instead\n",STATE_SIGNON_ACK, state);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wait_reply(char *buffer, int buflen)
|
||||
{
|
||||
int res=6;
|
||||
struct sflap_hdr *hdr=(struct sflap_hdr *)buffer;
|
||||
char *c;
|
||||
|
||||
while((res = read(toc_fd, buffer, 1))) {
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (buffer[0] == '*')
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
res = read(toc_fd, buffer+1, sizeof(struct sflap_hdr) - 1);
|
||||
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
res += 1;
|
||||
|
||||
|
||||
toc_debug_printf( "Rcv: %s %s\n",print_header(buffer), "");
|
||||
|
||||
while (res < (sizeof(struct sflap_hdr) + ntohs(hdr->len))) {
|
||||
res += read(toc_fd, buffer + res, (ntohs(hdr->len) + sizeof(struct sflap_hdr)) - res);
|
||||
/* while(gtk_events_pending())
|
||||
gtk_main_iteration(); */
|
||||
}
|
||||
|
||||
if (res >= sizeof(struct sflap_hdr))
|
||||
buffer[res]='\0';
|
||||
else
|
||||
return res - sizeof(struct sflap_hdr);
|
||||
|
||||
switch(hdr->type) {
|
||||
case TYPE_SIGNON:
|
||||
memcpy(&peer_ver, buffer + sizeof(struct sflap_hdr), 4);
|
||||
peer_ver = ntohl(peer_ver);
|
||||
seqno = ntohs(hdr->seqno);
|
||||
state = STATE_SIGNON_REQUEST;
|
||||
break;
|
||||
case TYPE_DATA:
|
||||
if (!strncasecmp(buffer + sizeof(struct sflap_hdr), "SIGN_ON:", strlen("SIGN_ON:")))
|
||||
state = STATE_SIGNON_ACK;
|
||||
else if (!strncasecmp(buffer + sizeof(struct sflap_hdr), "CONFIG:", strlen("CONFIG:"))) {
|
||||
state = STATE_CONFIG;
|
||||
} else if (state != STATE_ONLINE && !strncasecmp(buffer + sizeof(struct sflap_hdr), "ERROR:", strlen("ERROR:"))) {
|
||||
c = strtok(buffer + sizeof(struct sflap_hdr) + strlen("ERROR:"), ":");
|
||||
translate_toc_error_code(c);
|
||||
toc_debug_printf("ERROR CODE: %s\n",c);
|
||||
}
|
||||
|
||||
toc_debug_printf("Data: %s\n",buffer + sizeof(struct sflap_hdr));
|
||||
|
||||
break;
|
||||
default:
|
||||
toc_debug_printf("Unknown/unimplemented packet type %d\n",hdr->type);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int sflap_send(char *buf, int olen, int type)
|
||||
{
|
||||
int len;
|
||||
int slen=0;
|
||||
struct sflap_hdr hdr;
|
||||
char obuf[MSG_LEN];
|
||||
|
||||
/* One _last_ 2048 check here! This shouldn't ever
|
||||
* get hit though, hopefully. If it gets hit on an IM
|
||||
* It'll lose the last " and the message won't go through,
|
||||
* but this'll stop a segfault. */
|
||||
if (strlen(buf) > (MSG_LEN - sizeof(hdr))) {
|
||||
buf[MSG_LEN - sizeof(hdr) - 3] = '"';
|
||||
buf[MSG_LEN - sizeof(hdr) - 2] = '\0';
|
||||
}
|
||||
|
||||
toc_debug_printf("%s [Len %d]\n", buf, strlen(buf));
|
||||
|
||||
|
||||
if (olen < 0)
|
||||
len = escape_message(buf);
|
||||
else
|
||||
len = olen;
|
||||
hdr.ast = '*';
|
||||
hdr.type = type;
|
||||
hdr.seqno = htons(seqno++ & 0xffff);
|
||||
hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1));
|
||||
|
||||
toc_debug_printf("Escaped message is '%s'\n",buf);
|
||||
|
||||
memcpy(obuf, &hdr, sizeof(hdr));
|
||||
slen += sizeof(hdr);
|
||||
memcpy(&obuf[slen], buf, len);
|
||||
slen += len;
|
||||
if (type != TYPE_SIGNON) {
|
||||
obuf[slen]='\0';
|
||||
slen += 1;
|
||||
}
|
||||
/* print_buffer(obuf, slen); */
|
||||
|
||||
return write(toc_fd, obuf, slen);
|
||||
}
|
||||
|
||||
unsigned char *roast_password(char *pass)
|
||||
{
|
||||
/* Trivial "encryption" */
|
||||
static char rp[256];
|
||||
static char *roast = ROAST;
|
||||
int pos=2;
|
||||
int x;
|
||||
strcpy(rp, "0x");
|
||||
for (x=0;(x<150) && pass[x]; x++)
|
||||
pos+=sprintf(&rp[pos],"%02x", pass[x] ^ roast[x % strlen(roast)]);
|
||||
rp[pos]='\0';
|
||||
return rp;
|
||||
}
|
||||
|
||||
char *print_header(void *hdr_v)
|
||||
{
|
||||
static char s[80];
|
||||
struct sflap_hdr *hdr = (struct sflap_hdr *)hdr_v;
|
||||
snprintf(s,sizeof(s), "[ ast: %c, type: %d, seqno: %d, len: %d ]",
|
||||
hdr->ast, hdr->type, ntohs(hdr->seqno), ntohs(hdr->len));
|
||||
return s;
|
||||
}
|
||||
|
||||
int toc_callback(int fd)
|
||||
{
|
||||
char *buf;
|
||||
char *c;
|
||||
char **args = NULL;
|
||||
char *dup,*raw;
|
||||
char *l;
|
||||
int numargs =0;
|
||||
|
||||
buf = malloc(BUF_LONG);
|
||||
|
||||
if (wait_reply(buf, BUF_LONG) < 0) {
|
||||
toc_signoff();
|
||||
toc_debug_printf("need to do proper sign off on this\n");
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"Connection Closed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dup = strdup(buf+sizeof(struct sflap_hdr));
|
||||
raw = rindex(dup,':');
|
||||
c=strtok(buf+sizeof(struct sflap_hdr),":"); /* Ditch the first part */
|
||||
if (!strcasecmp(c,"UPDATE_BUDDY")) {
|
||||
char *uc, *t;
|
||||
int logged, evil, idle, type = 0;
|
||||
time_t signon;
|
||||
time_t time_idle;
|
||||
|
||||
numargs = 7;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
use_handler(TOC_RAW_HANDLE,TOC_UPDATE_BUDDY,raw);
|
||||
c = strtok(NULL,":"); /* c is name */
|
||||
args[0] = strdup(c);
|
||||
|
||||
l = strtok(NULL,":"); /* l is T/F logged status */
|
||||
args[1] = strdup(l);
|
||||
|
||||
t = strtok(NULL, ":");
|
||||
args[2] = strdup(t);
|
||||
sscanf(t, "%d", &evil);
|
||||
|
||||
t = strtok(NULL, ":");
|
||||
args[3] = strdup(t);
|
||||
sscanf(t, "%ld", &signon);
|
||||
|
||||
t = strtok(NULL, ":");
|
||||
args[4] = strdup(t);
|
||||
sscanf(t, "%d", &idle);
|
||||
|
||||
uc = strtok(NULL, ":");
|
||||
args[5] = strdup(uc);
|
||||
|
||||
if (!strncasecmp(l,"T",1))
|
||||
logged = 1;
|
||||
else
|
||||
logged = 0;
|
||||
|
||||
|
||||
if (uc[0] == 'A')
|
||||
type |= UC_AOL;
|
||||
|
||||
switch(uc[1]) {
|
||||
case 'A':
|
||||
type |= UC_ADMIN;
|
||||
break;
|
||||
case 'U':
|
||||
type |= UC_UNCONFIRMED;
|
||||
break;
|
||||
case 'O':
|
||||
type |= UC_NORMAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(uc[2]) {
|
||||
case 'U':
|
||||
type |= UC_UNAVAILABLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (idle) {
|
||||
time(&time_idle);
|
||||
time_idle -= idle*60;
|
||||
} else
|
||||
time_idle = 0;
|
||||
|
||||
serv_got_update(c, logged, evil, signon, time_idle, type);
|
||||
args[6] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_UPDATE_BUDDY,args);
|
||||
} else if (!strcasecmp(c, "ERROR")) {
|
||||
use_handler(TOC_RAW_HANDLE,TOC_ERROR,raw);
|
||||
c = strtok(NULL,":");
|
||||
translate_toc_error_code(c);
|
||||
args = (char **) malloc(sizeof(char *)*1 + 1);
|
||||
numargs = 1;
|
||||
args[0] = strdup(c);
|
||||
use_handler(TOC_HANDLE,TOC_ERROR,args);
|
||||
toc_debug_printf("ERROR: %s",c);
|
||||
} else if (!strcasecmp(c, "NICK")) {
|
||||
use_handler(TOC_RAW_HANDLE,TOC_NICK,raw);
|
||||
c = strtok(NULL,":");
|
||||
snprintf(aim_username, sizeof(aim_username), "%s", c);
|
||||
numargs = 2;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(c);
|
||||
args[1] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_NICK,args);
|
||||
} else if (!strcasecmp(c, "IM_IN")) {
|
||||
char *away, *message;
|
||||
int a = 0;
|
||||
use_handler(TOC_RAW_HANDLE,TOC_IM_IN,raw);
|
||||
c = strtok(NULL,":");
|
||||
away = strtok(NULL,":");
|
||||
|
||||
message = away;
|
||||
|
||||
while(*message && (*message != ':'))
|
||||
message++;
|
||||
|
||||
message++;
|
||||
|
||||
if (!strncasecmp(away, "T", 1))
|
||||
a = 1;
|
||||
|
||||
if ( serv_got_im(c, message,a) > 0 ) {
|
||||
numargs = 3;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(c);
|
||||
args[1] = strdup(message);
|
||||
args[2] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_IM_IN,args);
|
||||
}
|
||||
} else if (!strcasecmp(c, "GOTO_URL")) {
|
||||
char *name;
|
||||
char *url;
|
||||
|
||||
char tmp[256];
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_GOTO_URL,raw);
|
||||
name = strtok(NULL, ":");
|
||||
url = strtok(NULL, ":");
|
||||
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", toc_addy, aim_port, url);
|
||||
/* fprintf(stdout, "Name: %s\n%s\n", name, url);
|
||||
printf("%s", grab_url(tmp));*/
|
||||
|
||||
numargs = 2;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(tmp);
|
||||
args[1] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_GOTO_URL,args);
|
||||
/* statusprintf("GOTO_URL: %s","tmp"); */
|
||||
} else if (!strcasecmp(c, "EVILED")) {
|
||||
int lev;
|
||||
char *name = NULL;
|
||||
char *levc;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_EVILED,raw);
|
||||
levc = strtok(NULL, ":");
|
||||
sscanf(levc, "%d", &lev);
|
||||
name = strtok(NULL, ":");
|
||||
|
||||
toc_debug_printf("evil: %s | %d\n", name, lev);
|
||||
|
||||
numargs = 3;
|
||||
my_evil = lev;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
if ( name != NULL )
|
||||
args[0] = strdup(name);
|
||||
else
|
||||
args[0] = NULL;
|
||||
args[1] = strdup(levc);
|
||||
args[2] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_EVILED,args);
|
||||
|
||||
} else if (!strcasecmp(c, "CHAT_JOIN")) {
|
||||
char *name,*idc;
|
||||
int id;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_CHAT_JOIN,raw);
|
||||
idc = strtok(NULL, ":");
|
||||
sscanf(idc, "%d", &id);
|
||||
name = strtok(NULL, ":");
|
||||
serv_got_joined_chat(id, name);
|
||||
numargs = 3;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(idc);
|
||||
args[1] = strdup(name);
|
||||
args[2] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_CHAT_JOIN,args);
|
||||
} else if (!strcasecmp(c, "DIR_STATUS")) {
|
||||
char *status;
|
||||
use_handler(TOC_RAW_HANDLE,TOC_DIR_STATUS,raw);
|
||||
status = strtok(NULL,":");
|
||||
numargs = 2;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(status);
|
||||
args[1] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_DIR_STATUS,args);
|
||||
} else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) {
|
||||
int id;
|
||||
char *in,*idc;
|
||||
char *buddy;
|
||||
LLE t;
|
||||
struct buddy_chat *b = NULL;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_CHAT_UPDATE_BUDDY,raw);
|
||||
idc = strtok(NULL, ":");
|
||||
sscanf(idc, "%d", &id);
|
||||
|
||||
in = strtok(NULL, ":");
|
||||
|
||||
for ( TLL(buddy_chats,t) ) {
|
||||
b = (struct buddy_chat *)t->data;
|
||||
if (id == b->id)
|
||||
break;
|
||||
b = NULL;
|
||||
}
|
||||
|
||||
if (!b)
|
||||
return -2;
|
||||
|
||||
|
||||
if (!strcasecmp(in, "T")) {
|
||||
while((buddy = strtok(NULL, ":")) != NULL) {
|
||||
/*
|
||||
* Fuxin aim causes a problem here
|
||||
*/
|
||||
AddToLL(b->in_room, buddy,NULL);
|
||||
if ( b->init_chat ) {
|
||||
args = (char **) malloc(sizeof(char *)*3);
|
||||
args[0] = strdup(b->name);
|
||||
args[1] = strdup(buddy);
|
||||
args[2] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_BUDDY_JOIN_CHAT,args);
|
||||
free(args[0]); free(args[1]); free(args); args = NULL;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* init_chat is so that the user doenst get flooded
|
||||
* with user joined chat when he first joins a chat
|
||||
*/
|
||||
b->init_chat = 1;
|
||||
} else {
|
||||
while((buddy = strtok(NULL, ":")) != NULL) {
|
||||
RemoveFromLLByKey(b->in_room, buddy);
|
||||
/*
|
||||
* Since we might get multiple leave/joins at once
|
||||
* we allocate & deallocate here
|
||||
*/
|
||||
args = (char **) malloc(sizeof(char *)*3);
|
||||
args[0] = strdup(b->name);
|
||||
args[1] = strdup(buddy);
|
||||
args[2] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_BUDDY_LEFT_CHAT,args);
|
||||
free(args[0]); free(args[1]); free(args); args = NULL;
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(c, "CHAT_LEFT")) {
|
||||
char *idc;
|
||||
int id;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_CHAT_LEFT,raw);
|
||||
idc = strtok(NULL, ":");
|
||||
sscanf(idc, "%d", &id);
|
||||
|
||||
serv_got_chat_left(id);
|
||||
|
||||
numargs = 2;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(idc);
|
||||
args[1] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_CHAT_LEFT,args);
|
||||
} else if (!strcasecmp(c, "CHAT_IN")) {
|
||||
|
||||
int id, w;
|
||||
char *m,*idc;
|
||||
char *who, *whisper, *chan;
|
||||
struct buddy_chat *b;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_CHAT_IN,raw);
|
||||
idc = strtok(NULL, ":");
|
||||
sscanf(idc, "%d", &id);
|
||||
who = strtok(NULL, ":");
|
||||
whisper = strtok(NULL, ":");
|
||||
m = whisper;
|
||||
while(*m && (*m != ':')) m++;
|
||||
m++;
|
||||
|
||||
if (!strcasecmp(whisper, "T"))
|
||||
w = 1;
|
||||
else
|
||||
w = 0;
|
||||
|
||||
/* serv_got_chat_in(id, who, w, m); */
|
||||
b = buddy_chat_getbyid(id);
|
||||
if ( ! b ) {
|
||||
chan = (char *) malloc(50);
|
||||
strcpy(chan,"ERROR Couldn't lookup chan!");
|
||||
} else {
|
||||
chan = (char *) malloc(strlen(b->name)+1);
|
||||
strcpy(chan,b->name);
|
||||
}
|
||||
numargs = 6;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(idc);
|
||||
args[1] = strdup(who);
|
||||
args[2] = strdup(whisper);
|
||||
args[3] = strdup(m);
|
||||
/* Added arg to make things simple */
|
||||
args[4] = chan;
|
||||
args[5] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_CHAT_IN,args);
|
||||
} else if (!strcasecmp(c, "CHAT_INVITE")) {
|
||||
char *name;
|
||||
char *who;
|
||||
char *message,*idc;
|
||||
int id, *pid;
|
||||
|
||||
use_handler(TOC_RAW_HANDLE,TOC_CHAT_INVITE,raw);
|
||||
name = strtok(NULL, ":");
|
||||
idc = strtok(NULL, ":");
|
||||
sscanf(idc, "%d", &id);
|
||||
who = strtok(NULL, ":");
|
||||
message = strtok(NULL, ":");
|
||||
/* serv_got_chat_invite(name, id, who, message); */
|
||||
pid = (int *) malloc(sizeof(int));
|
||||
*pid = id;
|
||||
AddToLL(invited_chats,name,pid);
|
||||
numargs = 5;
|
||||
args = (char **) malloc(sizeof(char *)*numargs);
|
||||
args[0] = strdup(name);
|
||||
args[1] = strdup(idc);
|
||||
args[2] = strdup(who);
|
||||
args[3] = strdup(message);
|
||||
args[4] = NULL;
|
||||
use_handler(TOC_HANDLE,TOC_CHAT_INVITE,args);
|
||||
} else {
|
||||
toc_debug_printf("don't know what to do with %s\n", c);
|
||||
}
|
||||
free(dup);
|
||||
free(buf);
|
||||
if ( args != NULL ) {
|
||||
int x;
|
||||
/* toc_debug_printf("\nGOING TO FREE!: numargs = %d",numargs); */
|
||||
for (x=0;x< numargs; x++)
|
||||
if ( args[x] != NULL ) {
|
||||
/* toc_debug_printf("freeing %d",x); */
|
||||
free(args[x]);
|
||||
}
|
||||
/* toc_debug_printf(""); */
|
||||
free(args);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *toc_wait_config()
|
||||
{
|
||||
/* Waits for configuration packet, returning the contents of the packet */
|
||||
static char buf[BUF_LEN];
|
||||
int res;
|
||||
res = wait_reply(buf, sizeof(buf));
|
||||
if (res < 0)
|
||||
return NULL;
|
||||
if (state != STATE_CONFIG) {
|
||||
toc_debug_printf("State should be %d, but is %d instead\n",STATE_CONFIG, state);
|
||||
return NULL;
|
||||
}
|
||||
/* At this point, it's time to setup automatic handling of incoming packets */
|
||||
state = STATE_ONLINE;
|
||||
|
||||
// inpa = gdk_input_add(toc_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, toc_callback, NULL);
|
||||
toc_add_input_stream(toc_fd,&toc_callback);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void parse_toc_buddy_list(char *config)
|
||||
{
|
||||
char *c;
|
||||
char current[256];
|
||||
char *name;
|
||||
LL bud = CreateLL();
|
||||
|
||||
/* skip "CONFIG:" (if it exists)*/
|
||||
|
||||
c = strncmp(config + sizeof(struct sflap_hdr),"CONFIG:",strlen("CONFIG:"))?
|
||||
strtok(config, "\n"):
|
||||
strtok(config + sizeof(struct sflap_hdr)+strlen("CONFIG:"), "\n");
|
||||
|
||||
do {
|
||||
if (c == NULL)
|
||||
break;
|
||||
if (*c == 'g') {
|
||||
strncpy(current,c+2, sizeof(current));
|
||||
add_group(current);
|
||||
} else if (*c == 'b') {
|
||||
add_buddy(current, c+2);
|
||||
AddToLL(bud, c+2, NULL);
|
||||
} else if (*c == 'p') {
|
||||
name = malloc(strlen(c+2) + 2);
|
||||
snprintf(name, strlen(c+2) + 1, "%s", c+2);
|
||||
AddToLL(permit, name, NULL);
|
||||
} else if (*c == 'd') {
|
||||
name = malloc(strlen(c+2) + 2);
|
||||
snprintf(name, strlen(c+2) + 1, "%s", c+2);
|
||||
AddToLL(deny, name,NULL);
|
||||
} else if (*c == 'm') {
|
||||
sscanf(c + strlen(c) - 1, "%d", &permdeny);
|
||||
if (permdeny == 0)
|
||||
permdeny = PERMIT_PERMITALL;
|
||||
}
|
||||
} while ((c=strtok(NULL,"\n")));
|
||||
|
||||
serv_add_buddies(bud);
|
||||
FreeLL(bud);
|
||||
serv_set_permit_deny();
|
||||
}
|
||||
|
||||
int toc_signoff() {
|
||||
/* Leaking memory like a MOFO */
|
||||
FreeLL(groups);
|
||||
FreeLL(buddy_chats);
|
||||
FreeLL(invited_chats);
|
||||
FreeLL(permit);
|
||||
FreeLL(deny);
|
||||
deny = groups = permit = buddy_chats = invited_chats = NULL;
|
||||
toc_debug_printf("LEAKING MEMORY LIKE A BITCH in toc_signoff!");
|
||||
|
||||
serv_close();
|
||||
toc_msg_printf(TOC_CONNECT_MSGS,"%s signed off",aim_username);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void toc_build_config(char *s, int len)
|
||||
{
|
||||
struct group *g;
|
||||
struct buddy *b;
|
||||
LLE t,t1;
|
||||
LL mem;
|
||||
|
||||
int pos=0;
|
||||
toc_debug_printf("FIX this permdeny hack shit!");
|
||||
|
||||
if (!permdeny)
|
||||
permdeny = PERMIT_PERMITALL;
|
||||
pos += snprintf(&s[pos], len - pos, "m %d\n", permdeny);
|
||||
|
||||
/* Create Buddy List */
|
||||
for ( TLL(groups,t) ) {
|
||||
g = (struct group *)t->data;
|
||||
pos += snprintf(&s[pos], len - pos, "g %s\n", g->name);
|
||||
mem = g->members;
|
||||
for ( TLL(mem,t1) ) {
|
||||
b = (struct buddy *)t1->data;
|
||||
pos += snprintf(&s[pos], len - pos, "b %s\n", b->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create Permit and Deny Lists */;
|
||||
for ( TLL(permit,t) ) {
|
||||
toc_debug_printf("permit: added %s\n",(char *)t->key);
|
||||
pos += snprintf(&s[pos], len - pos, "p %s\n", (char *)t->key);
|
||||
}
|
||||
for ( TLL(deny,t) ) {
|
||||
toc_debug_printf("deny: added %s\n",(char *)t->key);
|
||||
pos += snprintf(&s[pos], len - pos, "d %s\n", (char *)t->key);
|
||||
}
|
||||
}
|
||||
|
||||
void translate_toc_error_code(char *c) {
|
||||
|
||||
int no = atoi(c);
|
||||
char *w = strtok(NULL, ":");
|
||||
char buf[256];
|
||||
|
||||
switch ( no ) {
|
||||
case 901:
|
||||
snprintf(buf, sizeof(buf), "%s not currently logged in.", w);
|
||||
break;
|
||||
case 902:
|
||||
snprintf(buf, sizeof(buf), "Warning of %s not allowed.", w);
|
||||
break;
|
||||
case 903:
|
||||
snprintf(buf, sizeof(buf), "A message has been dropped, you are exceeding the server speed limit.");
|
||||
break;
|
||||
case 950:
|
||||
snprintf(buf, sizeof(buf), "Chat in %s is not available.", w);
|
||||
break;
|
||||
case 960:
|
||||
snprintf(buf, sizeof(buf), "You are sending messages too fast to %s.", w);
|
||||
break;
|
||||
case 961:
|
||||
snprintf(buf, sizeof(buf), "You missed an IM from %s because it was too big.", w);
|
||||
break;
|
||||
case 962:
|
||||
snprintf(buf, sizeof(buf), "You missed an IM from %s because it was sent too fast.", w);
|
||||
break;
|
||||
case 970:
|
||||
snprintf(buf, sizeof(buf), "Failure.");
|
||||
break;
|
||||
case 971:
|
||||
snprintf(buf, sizeof(buf), "Too many matches.");
|
||||
break;
|
||||
case 972:
|
||||
snprintf(buf, sizeof(buf), "Need more qualifiers.");
|
||||
break;
|
||||
case 973:
|
||||
snprintf(buf, sizeof(buf), "Dir service temporarily unavailable.");
|
||||
break;
|
||||
case 974:
|
||||
snprintf(buf, sizeof(buf), "Email lookup restricted.");
|
||||
break;
|
||||
case 975:
|
||||
snprintf(buf, sizeof(buf), "Keyword ignored.");
|
||||
break;
|
||||
case 976:
|
||||
snprintf(buf, sizeof(buf), "No keywords.");
|
||||
break;
|
||||
case 977:
|
||||
snprintf(buf, sizeof(buf), "User has no directory information.");
|
||||
/* snprintf(buf, sizeof(buf), "Language not supported."); */
|
||||
break;
|
||||
case 978:
|
||||
snprintf(buf, sizeof(buf), "Country not supported.");
|
||||
break;
|
||||
case 979:
|
||||
snprintf(buf, sizeof(buf), "Failure unknown: %s.", w);
|
||||
break;
|
||||
case 980:
|
||||
snprintf(buf, sizeof(buf), "Incorrect nickname or password.");
|
||||
break;
|
||||
case 981:
|
||||
snprintf(buf, sizeof(buf), "The service is temporarily unavailable.");
|
||||
break;
|
||||
case 982:
|
||||
snprintf(buf, sizeof(buf), "Your warning level is currently too high to log in.");
|
||||
break;
|
||||
case 983:
|
||||
snprintf(buf, sizeof(buf), "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.");
|
||||
break;
|
||||
case 989:
|
||||
snprintf(buf, sizeof(buf), "An unknown signon error has occurred: %s.", w);
|
||||
break;
|
||||
default:
|
||||
snprintf(buf, sizeof(buf), "An unknown error, %d, has occured. Info: %s", no, w);
|
||||
}
|
||||
toc_msg_printf(TOC_TRANSLATED_ERROR,buf);
|
||||
return;
|
||||
}
|
||||
279
dll/aim/toc/toc.h
Normal file
279
dll/aim/toc/toc.h
Normal file
@@ -0,0 +1,279 @@
|
||||
#ifndef _TOC_H
|
||||
#define _TOC_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include "ll.h"
|
||||
|
||||
/* TOC DEFS */
|
||||
#define FLAPON "FLAPON\r\n\r\n"
|
||||
#define MSG_LEN 2048
|
||||
#define BUF_LEN MSG_LEN
|
||||
#define MAX_OUTPUT_MSG_LEN 4096
|
||||
#define BUF_LONG BUF_LEN * 2
|
||||
#define LANGUAGE "english"
|
||||
#define REVISION "gaim-libtoc:$Revision: 40 $"
|
||||
#define ROAST "Tic/Toc"
|
||||
#define TOC_HOST "toc.oscar.aol.com"
|
||||
#define TOC_PORT 9898
|
||||
#define AUTH_HOST "login.oscar.aol.com"
|
||||
#define AUTH_PORT 5190
|
||||
#define LAGOMETER_STR "123CHECKLAG456"
|
||||
|
||||
/* connection states */
|
||||
#define STATE_OFFLINE 0
|
||||
#define STATE_FLAPON 1
|
||||
#define STATE_SIGNON_REQUEST 2
|
||||
#define STATE_SIGNON_ACK 3
|
||||
#define STATE_CONFIG 4
|
||||
#define STATE_ONLINE 5
|
||||
|
||||
/* communication types */
|
||||
#define TYPE_SIGNON 1
|
||||
#define TYPE_DATA 2
|
||||
#define TYPE_ERROR 3
|
||||
#define TYPE_SIGNOFF 4
|
||||
#define TYPE_KEEPALIVE 5
|
||||
|
||||
/* permit modes */
|
||||
#define PERMIT_PERMITALL 1
|
||||
#define PERMIT_DENYALL 2
|
||||
#define PERMIT_PERMITSOME 3
|
||||
#define PERMIT_DENYSOME 4
|
||||
|
||||
/* User Types */
|
||||
#define UC_AOL 1
|
||||
#define UC_ADMIN 2
|
||||
#define UC_UNCONFIRMED 4
|
||||
#define UC_NORMAL 8
|
||||
#define UC_UNAVAILABLE 16
|
||||
|
||||
|
||||
/* INTERFACE */
|
||||
|
||||
#define TOC_HANDLE 1
|
||||
#define TOC_RAW_HANDLE 2
|
||||
|
||||
/* The following can be handlers in either normal or raw mode */
|
||||
|
||||
#define TOC_SIGN_ON 0
|
||||
#define TOC_CONFIG 1
|
||||
#define TOC_NICK 2
|
||||
#define TOC_IM_IN 3
|
||||
#define TOC_UPDATE_BUDDY 4
|
||||
#define TOC_ERROR 5
|
||||
#define TOC_EVILED 6
|
||||
#define TOC_CHAT_JOIN 7
|
||||
#define TOC_CHAT_IN 8
|
||||
#define TOC_CHAT_UPDATE_BUDDY 9
|
||||
#define TOC_CHAT_INVITE 10
|
||||
#define TOC_CHAT_LEFT 11
|
||||
#define TOC_GOTO_URL 12
|
||||
#define TOC_DIR_STATUS 13
|
||||
|
||||
/* TEMP */
|
||||
#define TOC_REINSTALL_TIMER 19
|
||||
|
||||
/* Special HANDLES -- can only be used in Normal mode */
|
||||
|
||||
#define TOC_SOCKFD 20
|
||||
#define TOC_RM_SOCKFD 21
|
||||
#define TOC_RECIEVED_IM TOC_IM_IN
|
||||
#define TOC_BUDDY_LOGGED_ON 22
|
||||
#define TOC_BUDDY_LOGGED_OFF 23
|
||||
#define TOC_CONNECT_MSGS 24
|
||||
#define TOC_TRANSLATED_ERROR 25
|
||||
#define TOC_BUDDY_LEFT_CHAT 26
|
||||
#define TOC_BUDDY_JOIN_CHAT 27
|
||||
#define TOC_LAG_UPDATE 28
|
||||
#define TOC_WENT_IDLE 29
|
||||
|
||||
|
||||
#define TOC_DEBUG_LOG "/tmp/aim-bx.log"
|
||||
|
||||
/* structs */
|
||||
struct sflap_hdr {
|
||||
unsigned char ast;
|
||||
unsigned char type;
|
||||
unsigned short seqno;
|
||||
unsigned short len;
|
||||
};
|
||||
|
||||
struct signon {
|
||||
unsigned int ver;
|
||||
unsigned short tag;
|
||||
unsigned short namelen;
|
||||
char username[80];
|
||||
};
|
||||
|
||||
|
||||
struct buddy {
|
||||
char name[80];
|
||||
int present;
|
||||
int log_timer;
|
||||
int evil;
|
||||
time_t signon;
|
||||
time_t idle;
|
||||
int uc;
|
||||
};
|
||||
|
||||
|
||||
struct group {
|
||||
char name[80];
|
||||
LL members;
|
||||
};
|
||||
|
||||
struct buddy_chat {
|
||||
LL in_room;
|
||||
LL ignored;
|
||||
int makesound;
|
||||
int id;
|
||||
int init_chat;
|
||||
char name[80];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* toc.c */
|
||||
int toc_login(char *username, char *password);
|
||||
int toc_signon(char *username, char *password);
|
||||
int wait_reply(char *buffer, int buflen);
|
||||
unsigned char *roast_password(char *pass);
|
||||
char *print_header(void *hdr_v);
|
||||
int toc_wait_signon();
|
||||
char *toc_wait_config();
|
||||
int sflap_send(char *buf, int olen, int type);
|
||||
int toc_signoff();
|
||||
void toc_close();
|
||||
void toc_build_config(char *s, int len);
|
||||
void parse_toc_buddy_list(char *);
|
||||
void translate_toc_error_code(char *c);
|
||||
|
||||
extern int state;
|
||||
/* extern int inpa; */
|
||||
|
||||
|
||||
/* util.c */
|
||||
void set_state(int i);
|
||||
int escape_message(char *msg);
|
||||
char *normalize(char *s);
|
||||
void strdown(char *s);
|
||||
int escape_text(char *msg);
|
||||
void toc_debug_printf(char *fmt, ...);
|
||||
void toc_msg_printf(int type, char *fmt, ...);
|
||||
char *strip_html(char *text);
|
||||
|
||||
|
||||
/* network.c */
|
||||
unsigned int *get_address(char *hostname);
|
||||
int connect_address(unsigned int addy, unsigned short port);
|
||||
|
||||
|
||||
/* server.c */
|
||||
void serv_finish_login();
|
||||
void serv_add_buddy(char *name);
|
||||
void serv_remove_buddy(char *name);
|
||||
void serv_set_info(char *info);
|
||||
void serv_get_info(char *name);
|
||||
int serv_got_im(char *name, char *message, int away);
|
||||
void serv_add_buddies(LL buddies);
|
||||
void serv_send_im(char *name, char *message);
|
||||
void serv_got_update(char *name, int loggedin, int evil, time_t signon, time_t idle, int type);
|
||||
void serv_close();
|
||||
void serv_save_config();
|
||||
void serv_warn(char *name, int anon);
|
||||
void serv_add_permit(char *);
|
||||
void serv_add_deny(char *);
|
||||
void serv_set_permit_deny();
|
||||
void serv_got_joined_chat(int id, char *name);
|
||||
void serv_got_chat_left(int id);
|
||||
void serv_accept_chat(int);
|
||||
void serv_join_chat(int, char *);
|
||||
void serv_chat_invite(int, char *, char *);
|
||||
void serv_chat_leave(int);
|
||||
void serv_chat_whisper(int, char *, char *);
|
||||
void serv_chat_send(int, char *);
|
||||
void serv_chat_warn(int id, char *user, int anon);
|
||||
void serv_get_dir(char *name);
|
||||
void serv_set_dir(char *first, char *middle, char *last, char *maiden, char *city, char *state, char *country, char *email, int web);
|
||||
void serv_dir_search(char *first, char *middle, char *last, char *maiden, char *city, char *state, char *country, char *email);
|
||||
void serv_touch_idle();
|
||||
void serv_set_idle(int time);
|
||||
int check_idle();
|
||||
void serv_set_away(char *message);
|
||||
|
||||
extern int idle_timer;
|
||||
extern time_t login_time;
|
||||
extern int is_idle;
|
||||
extern int lag_ms;
|
||||
extern int permdeny;
|
||||
extern int my_evil;
|
||||
extern int is_away;
|
||||
extern int time_to_idle;
|
||||
|
||||
|
||||
/* misc.c */
|
||||
void save_prefs();
|
||||
void misc_free_group(void *);
|
||||
void misc_free_buddy_chat(void *);
|
||||
void misc_free_invited_chats(void *);
|
||||
|
||||
extern char aim_host[512];
|
||||
extern int aim_port;
|
||||
extern char login_host[512];
|
||||
extern int login_port;
|
||||
extern char toc_addy[16];
|
||||
extern char aim_username[80];
|
||||
extern char aim_password[16];
|
||||
extern char *quad_addr;
|
||||
extern char debug_buff[1024];
|
||||
extern char user_info[2048];
|
||||
extern int registered;
|
||||
extern char *USER_CLASSES[5];
|
||||
extern char *PERMIT_MODES[4];
|
||||
|
||||
|
||||
/* buddy.c */
|
||||
struct buddy *add_buddy(char *group, char *buddy);
|
||||
struct buddy *find_buddy(char *who);
|
||||
struct group *add_group(char *group);
|
||||
struct group *find_group(char *group);
|
||||
int user_add_buddy(char *group,char *buddy);
|
||||
int user_remove_buddy(char *buddy);
|
||||
int remove_group(char *group, char *newgroup, int mode);
|
||||
int add_permit(char *sn);
|
||||
int remove_permit(char *sn);
|
||||
int add_deny(char *sn);
|
||||
int remove_deny(char *sn);
|
||||
int buddy_chat_invite(char *chat, char *buddy, char *msg);
|
||||
void buddy_chat_join(char *chan);
|
||||
int buddy_chat_leave(char *chan);
|
||||
struct buddy_chat *find_buddy_chat(char *chat);
|
||||
struct buddy_chat *buddy_chat_getbyid(int id);
|
||||
int buddy_chat_warn(char *chat, char *user, int anon);
|
||||
|
||||
extern LL groups;
|
||||
extern LL permit; /* The list of people permitted */
|
||||
extern LL deny; /* The list of people denied */
|
||||
extern LL buddy_chats;
|
||||
extern LL invited_chats;
|
||||
|
||||
|
||||
/* inteface.c */
|
||||
void init_toc();
|
||||
void init_lists();
|
||||
int install_handler(int type, int (*func)(int, char **));
|
||||
int install_raw_handler(int type, int (*func)(int, char *));
|
||||
int use_handler(int mode,int type, void *args);
|
||||
|
||||
extern int (*TOC_RAW_HANDLERS[30])(int, char *);
|
||||
extern int (*TOC_HANDLERS[30])(int, char **);
|
||||
|
||||
|
||||
/* EXTERNAL FUNCTIONS */
|
||||
|
||||
extern int toc_add_input_stream(int,int (*)(int));
|
||||
extern int toc_remove_input_stream(int);
|
||||
|
||||
#endif // _TOC_H
|
||||
197
dll/aim/toc/util.c
Normal file
197
dll/aim/toc/util.c
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* gaim
|
||||
*
|
||||
* Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Modified by Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* Slight changes to better incorporate into libtoc
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
#include "toc.h"
|
||||
|
||||
void set_state(int i)
|
||||
{
|
||||
state = i;
|
||||
}
|
||||
|
||||
int escape_text(char *msg)
|
||||
{
|
||||
char *c, *cpy;
|
||||
int cnt=0;
|
||||
/* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
|
||||
if (strlen(msg) > BUF_LEN) {
|
||||
fprintf(stderr, "Warning: truncating message to 2048 bytes\n");
|
||||
msg[2047]='\0';
|
||||
}
|
||||
|
||||
cpy = strdup(msg);
|
||||
c = cpy;
|
||||
while(*c) {
|
||||
switch(*c) {
|
||||
case '{':
|
||||
case '}':
|
||||
case '\\':
|
||||
case '"':
|
||||
msg[cnt++]='\\';
|
||||
/* Fall through */
|
||||
default:
|
||||
msg[cnt++]=*c;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
msg[cnt]='\0';
|
||||
free(cpy);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
int escape_message(char *msg)
|
||||
{
|
||||
char *c, *cpy;
|
||||
int cnt=0;
|
||||
/* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
|
||||
if (strlen(msg) > BUF_LEN) {
|
||||
toc_debug_printf("Warning: truncating message to 2048 bytes\n");
|
||||
msg[2047]='\0';
|
||||
}
|
||||
|
||||
cpy = strdup(msg);
|
||||
c = cpy;
|
||||
while(*c) {
|
||||
switch(*c) {
|
||||
case '$':
|
||||
case '[':
|
||||
case ']':
|
||||
case '(':
|
||||
case ')':
|
||||
case '#':
|
||||
msg[cnt++]='\\';
|
||||
/* Fall through */
|
||||
default:
|
||||
msg[cnt++]=*c;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
msg[cnt]='\0';
|
||||
free(cpy);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
char *normalize(char *s)
|
||||
{
|
||||
static char buf[BUF_LEN];
|
||||
char *t, *u;
|
||||
int x=0;
|
||||
|
||||
u = t = malloc(strlen(s) + 1);
|
||||
|
||||
strcpy(t, s);
|
||||
strdown(t);
|
||||
|
||||
while(*t) {
|
||||
if (*t != ' ') {
|
||||
buf[x] = *t;
|
||||
x++;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
buf[x]='\0';
|
||||
free(u);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void strdown(char *s) {
|
||||
while ( *s ) {
|
||||
if ( *s >= 65 && *s <= 90)
|
||||
*s += 32;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void toc_debug_printf(char *fmt, ...)
|
||||
{
|
||||
#ifdef DEBUG_LIB_TOC
|
||||
FILE *fp;
|
||||
char data[MAX_OUTPUT_MSG_LEN];
|
||||
va_list ptr;
|
||||
if ( ! (fp=fopen(TOC_DEBUG_LOG,"a")) ) {
|
||||
perror("ERROR couldn't open debug log file!@$\n");
|
||||
}
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr);
|
||||
va_end(ptr);
|
||||
fprintf(fp,"%s\n",data);
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
void toc_msg_printf(int type, char *fmt, ...) {
|
||||
char data[MAX_OUTPUT_MSG_LEN];
|
||||
char *args[1];
|
||||
va_list ptr;
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr);
|
||||
va_end(ptr);
|
||||
args[0] = data;
|
||||
use_handler(TOC_HANDLE,type,args);
|
||||
return;
|
||||
}
|
||||
|
||||
char * strip_html(char * text)
|
||||
{
|
||||
int i, j;
|
||||
int visible = 1;
|
||||
char *text2 = malloc(strlen(text) + 1);
|
||||
|
||||
strcpy(text2, text);
|
||||
for (i = 0, j = 0;text2[i]; i++)
|
||||
{
|
||||
if(text2[i]=='<')
|
||||
{
|
||||
visible = 0;
|
||||
continue;
|
||||
}
|
||||
else if(text2[i]=='>')
|
||||
{
|
||||
visible = 1;
|
||||
continue;
|
||||
}
|
||||
if(visible)
|
||||
{
|
||||
text2[j++] = text2[i];
|
||||
}
|
||||
}
|
||||
text2[j] = '\0';
|
||||
return text2;
|
||||
}
|
||||
|
||||
171
dll/aim/util.c
Normal file
171
dll/aim/util.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* AOL Instant Messanger Module for BitchX
|
||||
*
|
||||
* By Nadeem Riaz (nads@bleh.org)
|
||||
*
|
||||
* util.c
|
||||
*
|
||||
* utility/misc functions
|
||||
*/
|
||||
|
||||
#include <irc.h>
|
||||
#include <struct.h>
|
||||
#include <hook.h>
|
||||
#include <ircaux.h>
|
||||
#include <output.h>
|
||||
#include <lastlog.h>
|
||||
#include <status.h>
|
||||
#include <vars.h>
|
||||
#include <window.h>
|
||||
#include <module.h>
|
||||
#include <modval.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "toc.h"
|
||||
#include "aim.h"
|
||||
|
||||
|
||||
void statusprintf(char *fmt, ...)
|
||||
{
|
||||
char data[MAX_STATUS_MSG_LEN];
|
||||
char *sfmt, *prompt;
|
||||
va_list ptr;
|
||||
|
||||
/* Tack on prompt */
|
||||
prompt = get_dllstring_var("aim_prompt");
|
||||
sfmt = (char *) malloc(strlen(prompt) + strlen(fmt)+5);
|
||||
strcpy(sfmt,prompt);
|
||||
strcat(sfmt," ");
|
||||
strcat(sfmt,fmt);
|
||||
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_STATUS_MSG_LEN - 1 , sfmt, ptr);
|
||||
va_end(ptr);
|
||||
free(sfmt);
|
||||
statusput(LOG_CRAP,data);
|
||||
return;
|
||||
}
|
||||
|
||||
void statusput(int log_type, char *buf) {
|
||||
int lastlog_level;
|
||||
lastlog_level = set_lastlog_msg_level(log_type);
|
||||
|
||||
if (get_dllint_var("aim_window") > 0)
|
||||
if (!(target_window = get_window_by_name("AIM")))
|
||||
target_window = current_window;
|
||||
|
||||
if (window_display && buf)
|
||||
{
|
||||
add_to_log(irclog_fp, 0, buf, 0);
|
||||
add_to_screen(buf);
|
||||
}
|
||||
|
||||
target_window = NULL;
|
||||
set_lastlog_msg_level(lastlog_level);
|
||||
return;
|
||||
}
|
||||
|
||||
void msgprintf(char *fmt, ...)
|
||||
{
|
||||
char data[MAX_STATUS_MSG_LEN];
|
||||
va_list ptr;
|
||||
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_STATUS_MSG_LEN - 1 , fmt, ptr);
|
||||
va_end(ptr);
|
||||
statusput(LOG_CRAP,data);
|
||||
return;
|
||||
}
|
||||
|
||||
void debug_printf(char *fmt, ...)
|
||||
{
|
||||
#ifdef DEBUG_AIM
|
||||
FILE *fp;
|
||||
char data[MAX_OUTPUT_MSG_LEN];
|
||||
va_list ptr;
|
||||
if ( ! (fp=fopen(AIM_DEBUG_LOG,"a")) ) {
|
||||
perror("ERROR couldn't open debug log file!@$\n");
|
||||
}
|
||||
va_start(ptr, fmt);
|
||||
vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr);
|
||||
va_end(ptr);
|
||||
fprintf(fp,"%s\n",data);
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *rm_space(char *s) {
|
||||
char *rs;
|
||||
int x,y;
|
||||
rs = (char *) malloc(strlen(s) + 1);
|
||||
x = y = 0;
|
||||
|
||||
for (x =0; x<strlen(s);x++) {
|
||||
if ( s[x] != ' ' ) {
|
||||
rs[y] = s[x];
|
||||
y++;
|
||||
}
|
||||
}
|
||||
rs[y] = '\0';
|
||||
return rs;
|
||||
}
|
||||
|
||||
/*
|
||||
* Still dont like split args routines in bitchx (new_next_arg)
|
||||
* It doesnt allow for args with "'s in them, next_arg doesnt allow
|
||||
* for args with spaces !@$. Need a *real* split routne that can handle
|
||||
* both (with escaping)
|
||||
*/
|
||||
|
||||
/*
|
||||
char **split_args(char *args,int max;) {
|
||||
int x;
|
||||
char *list[32];
|
||||
int arg = 0;
|
||||
int escape = 0;
|
||||
int open_quote = 0;
|
||||
for (x=0;x<strlen(args);x++) {
|
||||
if ( args[x] == '\' ) {
|
||||
if ( ! escape ) {
|
||||
escape = 1;
|
||||
continue;
|
||||
}
|
||||
} else ( ! escape && args[x] == '"' ) {
|
||||
if ( open_quote ) {
|
||||
push(@args,$warg);
|
||||
$warg ="";
|
||||
arg++;
|
||||
$argbegin = $x+1;
|
||||
open_quote = 0;
|
||||
} else {
|
||||
open_quote = 1;
|
||||
}
|
||||
continue;
|
||||
} elsif ( ! $escape && ! $open_quote && substr($text,$x,1) eq " " ) {
|
||||
if ( ! $space ) {
|
||||
push(@args,$warg);
|
||||
$warg ="";
|
||||
$arg++;
|
||||
$space = 1;
|
||||
}
|
||||
$argbegin = $x+1;
|
||||
next;
|
||||
}
|
||||
if ( $space ) {
|
||||
$argbegin = $x;
|
||||
$space = 0;
|
||||
} elsif ( $escape ) {
|
||||
$escape = 0;
|
||||
}
|
||||
$warg .= substr($text,$x,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
220
dll/amp/Makefile.in
Normal file
220
dll/amp/Makefile.in
Normal file
@@ -0,0 +1,220 @@
|
||||
# Makefile - amp audio mpeg player v0.7
|
||||
# tomislav uzelac 1996,1997
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
OBJ = getbits.o huffman.o layer3.o getdata.o misc2.o\
|
||||
transform.o audio.o buffer.o audioIO.o position.o layer2.o util.o
|
||||
|
||||
PLUGIN_NAME = amp
|
||||
|
||||
all: Makefile amp$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) && \
|
||||
./config.status
|
||||
|
||||
clean:
|
||||
$(RM) *.o core *.a *.dll *~ amp$(SHLIB_SUFFIX) *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) *~ config.status config.cache config.log config.h Makefile
|
||||
|
||||
../dllinit.o:
|
||||
$(CC) -DOS_$(OS) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -o ../dllinit.o -c ../dllinit.c
|
||||
|
||||
amp$(SHLIB_SUFFIX): $(OBJ) ../dllinit.o
|
||||
$(SHLIB_LD) -o amp$(SHLIB_SUFFIX) $(OBJ) ../dllinit.o
|
||||
|
||||
SOURCES = $(OBJECTS:%.o=$(srcdir)/%.c)
|
||||
|
||||
OS := $(shell uname -s)
|
||||
|
||||
.c.o:
|
||||
$(CC) -DOS_$(OS) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
depend:
|
||||
gcc -MM $(CPPFLAGS) $(DEFS) $(CFLAGS) *.c > .depend
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
|
||||
audio.o: audio.c ../../include/irc.h ../../include/defs.h \
|
||||
../../include/config.h ../../include/../.config.h \
|
||||
../../include/color.h ../../include/bsdglob.h ../../include/irc_std.h \
|
||||
../../include/debug.h ../../include/newio.h ../../include/struct.h \
|
||||
../../include/alist.h ../../include/ircaux.h ../../include/hash.h \
|
||||
../../include/input.h ../../include/module.h ../../include/hook.h \
|
||||
../../include/modval.h amp.h proto.h audio.h getbits.h huffman.h \
|
||||
layer2.h layer3.h position.h transform.h misc2.h
|
||||
audioIO.o: audioIO.c
|
||||
audioIO_Linux.o: audioIO_Linux.c amp.h ../../include/defs.h proto.h \
|
||||
audioIO.h
|
||||
buffer.o: buffer.c amp.h ../../include/defs.h proto.h transform.h \
|
||||
audioIO.h audio.h
|
||||
getbits.o: getbits.c amp.h ../../include/defs.h proto.h audio.h \
|
||||
getbits.h
|
||||
getdata.o: getdata.c amp.h ../../include/defs.h proto.h audio.h \
|
||||
getbits.h huffman.h getdata.h
|
||||
huffman.o: huffman.c audio.h getbits.h huffman.h
|
||||
layer2.o: layer2.c amp.h ../../include/defs.h proto.h audio.h \
|
||||
getbits.h transform.h layer2.h
|
||||
layer3.o: layer3.c amp.h ../../include/defs.h proto.h audio.h \
|
||||
getbits.h getdata.h huffman.h misc2.h transform.h layer3.h
|
||||
misc2.o: misc2.c amp.h ../../include/defs.h proto.h audio.h getdata.h \
|
||||
huffman.h misc2.h
|
||||
position.o: position.c amp.h ../../include/defs.h proto.h audio.h \
|
||||
getbits.h position.h
|
||||
transform.o: transform.c audio.h getdata.h misc2.h transform.h
|
||||
util.o: util.c amp.h ../../include/defs.h proto.h audio.h
|
||||
35
dll/amp/amp.h
Normal file
35
dll/amp/amp.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* these should not be touched
|
||||
*/
|
||||
#define SYNCWORD 0xfff
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* version
|
||||
*/
|
||||
#define MAJOR 0
|
||||
#define MINOR 7
|
||||
#define PATCH 6
|
||||
|
||||
|
||||
#include "defs.h"
|
||||
#include "proto.h"
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#define MAX3(a,b,c) ((a) > (b) ? MAX(a, c) : MAX(b, c))
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
extern int AUDIO_BUFFER_SIZE;
|
||||
467
dll/amp/audio.c
Normal file
467
dll/amp/audio.c
Normal file
@@ -0,0 +1,467 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* audio.c main amp source file
|
||||
*
|
||||
* Created by: tomislav uzelac Apr 1996
|
||||
* Karl Anders Oygard added the IRIX code, 10 Mar 1997.
|
||||
* Ilkka Karvinen fixed /dev/dsp initialization, 11 Mar 1997.
|
||||
* Lutz Vieweg added the HP/UX code, 14 Mar 1997.
|
||||
* Dan Nelson added FreeBSD modifications, 23 Mar 1997.
|
||||
* Andrew Richards complete reorganisation, new features, 25 Mar 1997
|
||||
* Edouard Lafargue added sajber jukebox support, 12 May 1997
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "input.h"
|
||||
#include "module.h"
|
||||
#include "hook.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifndef __BEOS__
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "amp.h"
|
||||
#define AUDIO
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
#include "huffman.h"
|
||||
#include "layer2.h"
|
||||
#include "layer3.h"
|
||||
#include "position.h"
|
||||
#include "transform.h"
|
||||
#include "misc2.h"
|
||||
|
||||
int bufferpid = 0;
|
||||
unsigned long filesize = 0;
|
||||
unsigned long framesize = 0;
|
||||
|
||||
|
||||
off_t file_size (char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (!stat(filename, &statbuf))
|
||||
return (off_t)(statbuf.st_size);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void statusDisplay(struct AUDIO_HEADER *header, int frameNo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
volatile int intflag = 0;
|
||||
|
||||
void (*catchsignal(int signum, void(*handler)()))()
|
||||
{
|
||||
struct sigaction new_sa;
|
||||
struct sigaction old_sa;
|
||||
|
||||
new_sa.sa_handler = handler;
|
||||
sigemptyset(&new_sa.sa_mask);
|
||||
new_sa.sa_flags = 0;
|
||||
if (sigaction(signum, &new_sa, &old_sa) == -1)
|
||||
return ((void (*)()) -1);
|
||||
return (old_sa.sa_handler);
|
||||
}
|
||||
#endif
|
||||
|
||||
int decodeMPEG(struct AUDIO_HEADER *header)
|
||||
{
|
||||
int cnt, g, snd_eof;
|
||||
|
||||
/*
|
||||
* decoder loop **********************************
|
||||
*/
|
||||
snd_eof=0;
|
||||
cnt=0;
|
||||
|
||||
while (!snd_eof)
|
||||
{
|
||||
while (!snd_eof && ready_audio())
|
||||
{
|
||||
if ((g=gethdr(header))!=0)
|
||||
{
|
||||
report_header_error(g);
|
||||
snd_eof=1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (header->protection_bit==0)
|
||||
getcrc();
|
||||
|
||||
#if 0
|
||||
statusDisplay(header,cnt);
|
||||
#endif
|
||||
if (header->layer==1)
|
||||
{
|
||||
if (layer3_frame(header,cnt))
|
||||
{
|
||||
yell(" error. blip.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (header->layer==2)
|
||||
{
|
||||
if (layer2_frame(header,cnt))
|
||||
{
|
||||
yell(" error. blip.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BUILT_IN_DLL(mp3_volume)
|
||||
{
|
||||
char *vol;
|
||||
if ((vol = next_arg(args, &args)))
|
||||
{
|
||||
int volume = 0;
|
||||
volume = my_atol(vol);
|
||||
if (volume > 0 && volume <= 100)
|
||||
{
|
||||
audioSetVolume(volume);
|
||||
bitchsay("Volume is now set to %d", volume);
|
||||
}
|
||||
else
|
||||
bitchsay("Volume is between 0 and 100");
|
||||
}
|
||||
else
|
||||
bitchsay("/mp3vol [1-100]");
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(mp3_play)
|
||||
{
|
||||
if (args && *args)
|
||||
{
|
||||
if (!fork())
|
||||
{
|
||||
play(args);
|
||||
update_input(UPDATE_ALL);
|
||||
_exit(1);
|
||||
}
|
||||
update_input(UPDATE_ALL);
|
||||
}
|
||||
else
|
||||
bitchsay("/mp3 filename");
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_convert_time)
|
||||
{
|
||||
int hours, minutes, seconds;
|
||||
if (!input)
|
||||
return m_strdup(empty_string);
|
||||
seconds = my_atol(input);
|
||||
hours = seconds / ( 60 * 60 );
|
||||
minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
return m_sprintf("[%02d:%02d:%02d]", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
int Amp_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
initialize_module("amp");
|
||||
|
||||
initialise_decoder(); /* initialise decoder */
|
||||
A_QUIET = TRUE;
|
||||
AUDIO_BUFFER_SIZE=300*1024;
|
||||
A_SHOW_CNT=FALSE;
|
||||
A_SET_VOLUME=-1;
|
||||
A_SHOW_TIME=0;
|
||||
A_AUDIO_PLAY=TRUE;
|
||||
A_DOWNMIX=FALSE;
|
||||
add_module_proc(COMMAND_PROC, "Amp", "mp3", NULL, 0, 0, mp3_play, NULL);
|
||||
add_module_proc(COMMAND_PROC, "Amp", "mp3vol", NULL, 0, 0, mp3_volume, NULL);
|
||||
add_module_proc(ALIAS_PROC, "Amp", "TIMEDECODE", NULL, 0, 0, func_convert_time, NULL);
|
||||
bitchsay("Amp Module loaded. /mp3 <filename> /mp3vol <L> <R> $timedecode(seconds)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* call this once at the beginning
|
||||
*/
|
||||
void initialise_decoder(void)
|
||||
{
|
||||
premultiply();
|
||||
imdct_init();
|
||||
calculate_t43();
|
||||
}
|
||||
|
||||
/* call this before each file is played
|
||||
*/
|
||||
void initialise_globals(void)
|
||||
{
|
||||
append=data=nch=0;
|
||||
f_bdirty=TRUE;
|
||||
bclean_bytes=0;
|
||||
|
||||
memset(s,0,sizeof s);
|
||||
memset(res,0,sizeof res);
|
||||
}
|
||||
|
||||
void report_header_error(int err)
|
||||
{
|
||||
char *s = NULL;
|
||||
switch (err) {
|
||||
case GETHDR_ERR:
|
||||
s = "error reading mpeg bitstream. exiting.";
|
||||
break;
|
||||
case GETHDR_NS :
|
||||
s = "this is a file in MPEG 2.5 format, which is not defined" \
|
||||
"by ISO/MPEG. It is \"a special Fraunhofer format\"." \
|
||||
"amp does not support this format. sorry.";
|
||||
break;
|
||||
case GETHDR_FL1:
|
||||
s = "ISO/MPEG layer 1 is not supported by amp (yet).";
|
||||
break;
|
||||
case GETHDR_FF :
|
||||
s = "free format bitstreams are not supported. sorry.";
|
||||
break;
|
||||
case GETHDR_SYN:
|
||||
s = "oops, we're out of sync.";
|
||||
break;
|
||||
case GETHDR_EOF:
|
||||
default: ; /* some stupid compilers need the semicolon */
|
||||
}
|
||||
if (s)
|
||||
do_hook(MODULE_LIST, "AMP ERROR blip %s", s);
|
||||
}
|
||||
|
||||
/* TODO: there must be a check here to see if the audio device has been opened
|
||||
* successfuly. This is a bitch because it requires all 6 or 7 OS-specific functions
|
||||
* to be changed. Is anyone willing to do this at all???
|
||||
*/
|
||||
int setup_audio(struct AUDIO_HEADER *header)
|
||||
{
|
||||
if (A_AUDIO_PLAY)
|
||||
{
|
||||
if (AUDIO_BUFFER_SIZE==0)
|
||||
audioOpen(t_sampling_frequency[header->ID][header->sampling_frequency],
|
||||
(header->mode!=3 && !A_DOWNMIX),A_SET_VOLUME);
|
||||
else
|
||||
bufferpid = audioBufferOpen(t_sampling_frequency[header->ID][header->sampling_frequency],
|
||||
(header->mode!=3 && !A_DOWNMIX),A_SET_VOLUME);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void close_audio(void)
|
||||
{
|
||||
if (A_AUDIO_PLAY)
|
||||
{
|
||||
if (AUDIO_BUFFER_SIZE!=0)
|
||||
audioBufferClose();
|
||||
else
|
||||
audioClose();
|
||||
}
|
||||
}
|
||||
|
||||
int ready_audio(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* remove the trailing spaces from a string */
|
||||
static void strunpad(char *str)
|
||||
{
|
||||
int i = strlen(str);
|
||||
|
||||
while ((i > 0) && (str[i-1] == ' '))
|
||||
i--;
|
||||
str[i] = 0;
|
||||
}
|
||||
|
||||
static void print_id3_tag(FILE *fp, char *buf)
|
||||
{
|
||||
struct id3tag {
|
||||
char tag[3];
|
||||
char title[30];
|
||||
char artist[30];
|
||||
char album[30];
|
||||
char year[4];
|
||||
char comment[30];
|
||||
unsigned char genre;
|
||||
};
|
||||
struct idxtag {
|
||||
char tag[3];
|
||||
char title[90];
|
||||
char artist[50];
|
||||
char album[50];
|
||||
char comment[50];
|
||||
};
|
||||
struct id3tag *tag = (struct id3tag *) buf;
|
||||
struct idxtag *xtag = (struct idxtag *) buf;
|
||||
char title[121]="\0";
|
||||
char artist[81]="\0";
|
||||
char album[81]="\0";
|
||||
char year[5]="\0";
|
||||
char comment[81]="\0";
|
||||
|
||||
strncpy(title,tag->title,30);
|
||||
strncpy(artist,tag->artist,30);
|
||||
strncpy(album,tag->album,30);
|
||||
strncpy(year,tag->year,4);
|
||||
strncpy(comment,tag->comment,30);
|
||||
strunpad(title);
|
||||
strunpad(artist);
|
||||
strunpad(album);
|
||||
strunpad(comment);
|
||||
|
||||
if ((fseek(fp, 384, SEEK_END) != -1) && (fread(buf, 256, 1, fp) == 1))
|
||||
{
|
||||
if (!strncmp(buf, "TXG", 3))
|
||||
{
|
||||
strncat(title, xtag->title, 90);
|
||||
strncat(artist, xtag->artist, 50);
|
||||
strncat(album, xtag->album, 50);
|
||||
strncat(comment, xtag->comment, 50);
|
||||
strunpad(title);
|
||||
strunpad(artist);
|
||||
strunpad(album);
|
||||
strunpad(comment);
|
||||
}
|
||||
}
|
||||
if (!do_hook(MODULE_LIST, "AMP ID3 \"%s\" \"%s\" \"%s\" %s %d %s", title, artist, album, year, tag->genre, comment))
|
||||
{
|
||||
bitchsay("Title : %.120s Artist: %s",title, artist);
|
||||
bitchsay("Album : %.80s Year: %4s, Genre: %d",album, year, (int)tag->genre);
|
||||
bitchsay("Comment: %.80s",comment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TODO: add some kind of error reporting here
|
||||
*/
|
||||
void play(char *inFileStr)
|
||||
{
|
||||
char *f;
|
||||
long totalframes = 0;
|
||||
long tseconds = 0;
|
||||
struct AUDIO_HEADER header;
|
||||
int bitrate, fs, g, cnt = 0;
|
||||
|
||||
while ((f = new_next_arg(inFileStr, &inFileStr)))
|
||||
{
|
||||
if (!f || !*f)
|
||||
return;
|
||||
if ((in_file=fopen(f,"r"))==NULL)
|
||||
{
|
||||
if (!do_hook(MODULE_LIST, "AMP ERROR open %s", f))
|
||||
put_it("Could not open file: %s\n", f);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
filesize = file_size(f);
|
||||
initialise_globals();
|
||||
|
||||
if ((g=gethdr(&header))!=0)
|
||||
{
|
||||
report_header_error(g);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header.protection_bit==0)
|
||||
getcrc();
|
||||
|
||||
if (setup_audio(&header)!=0)
|
||||
{
|
||||
yell("Cannot set up audio. Exiting");
|
||||
continue;
|
||||
}
|
||||
|
||||
filesize -= sizeof(header);
|
||||
|
||||
switch (header.layer)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (layer3_frame(&header,cnt))
|
||||
{
|
||||
yell(" error. blip.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (layer2_frame(&header,cnt))
|
||||
{
|
||||
yell(" error. blip.");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
bitrate=t_bitrate[header.ID][3-header.layer][header.bitrate_index];
|
||||
fs=t_sampling_frequency[header.ID][header.sampling_frequency];
|
||||
|
||||
if (header.ID)
|
||||
framesize=144000*bitrate/fs;
|
||||
else
|
||||
framesize=72000*bitrate/fs;
|
||||
|
||||
|
||||
|
||||
totalframes = (filesize / (framesize + 1)) - 1;
|
||||
tseconds = (totalframes * 1152/
|
||||
t_sampling_frequency[header.ID][header.sampling_frequency]);
|
||||
|
||||
if (A_AUDIO_PLAY)
|
||||
{
|
||||
char *p = strrchr(f, '/');
|
||||
if (!p) p = f; else p++;
|
||||
if (!do_hook(MODULE_LIST, "AMP PLAY %lu %lu %s", tseconds, filesize, p))
|
||||
bitchsay("Playing: %s\n", p);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
if (!(fseek(in_file, 0, SEEK_END)))
|
||||
{
|
||||
char id3_tag[256];
|
||||
if (!fseek(in_file, -128, SEEK_END) && (fread(id3_tag,128, 1, in_file) == 1))
|
||||
{
|
||||
if (!strncmp(id3_tag, "TAG", 3))
|
||||
print_id3_tag(in_file, id3_tag);
|
||||
}
|
||||
fseek(in_file,0,SEEK_SET);
|
||||
}
|
||||
decodeMPEG(&header);
|
||||
do_hook(MODULE_LIST, "AMP CLOSE %s", f);
|
||||
close_audio();
|
||||
fclose(in_file);
|
||||
}
|
||||
}
|
||||
|
||||
162
dll/amp/audio.h
Normal file
162
dll/amp/audio.h
Normal file
@@ -0,0 +1,162 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* audio.h some global variables
|
||||
*
|
||||
* Created by: tomislav uzelac Mar/Apr, Jul 96
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct AUDIO_HEADER {
|
||||
int ID;
|
||||
int layer;
|
||||
int protection_bit;
|
||||
int bitrate_index;
|
||||
int sampling_frequency;
|
||||
int padding_bit;
|
||||
int private_bit;
|
||||
int mode;
|
||||
int mode_extension;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
};
|
||||
|
||||
struct SIDE_INFO {
|
||||
int main_data_begin;
|
||||
int scfsi[2][4];
|
||||
int part2_3_length[2][2];
|
||||
int big_values[2][2];
|
||||
int global_gain[2][2];
|
||||
int scalefac_compress[2][2];
|
||||
int window_switching_flag[2][2];
|
||||
int block_type[2][2];
|
||||
int mixed_block_flag[2][2];
|
||||
int table_select[2][2][3];
|
||||
int subblock_gain[2][2][3];
|
||||
int region0_count[2][2];
|
||||
int region1_count[2][2];
|
||||
int preflag[2][2];
|
||||
int scalefac_scale[2][2];
|
||||
int count1table_select[2][2];
|
||||
};
|
||||
|
||||
|
||||
/* global stuff
|
||||
*/
|
||||
|
||||
extern FILE *in_file;
|
||||
|
||||
extern void statusDisplay(struct AUDIO_HEADER *header, int frameNo);
|
||||
extern void initialise_globals(void);
|
||||
extern void report_header_error(int err);
|
||||
|
||||
extern int scalefac_l[2][2][22];
|
||||
extern int scalefac_s[2][2][13][3];
|
||||
extern int t_b8_l[2][3][22];
|
||||
extern int t_b8_s[2][3][13];
|
||||
extern short t_bitrate[2][3][15];
|
||||
|
||||
extern int is[2][578];
|
||||
extern float xr[2][32][18];
|
||||
|
||||
extern int *t_l,*t_s;
|
||||
extern int nch;
|
||||
extern int t_sampling_frequency[2][3];
|
||||
|
||||
extern int A_QUIET,A_SHOW_CNT;
|
||||
extern int A_WRITE_TO_AUDIO;
|
||||
extern short pcm_sample[64];
|
||||
extern int A_AUDIO_PLAY;
|
||||
extern int A_SET_VOLUME,A_SHOW_TIME;
|
||||
extern int A_DOWNMIX;
|
||||
extern int A_SHUFFLE;
|
||||
|
||||
extern int stop_flag;
|
||||
extern int quit_flag;
|
||||
|
||||
/* ...
|
||||
*/
|
||||
|
||||
#ifdef AUDIO
|
||||
|
||||
FILE *in_file;
|
||||
|
||||
int scalefac_l[2][2][22];
|
||||
int scalefac_s[2][2][13][3];
|
||||
|
||||
int is[2][578];
|
||||
float xr[2][32][18];
|
||||
|
||||
int *t_l,*t_s;
|
||||
int nch;
|
||||
int t_sampling_frequency[2][3] = {
|
||||
{ 22050 , 24000 , 16000},
|
||||
{ 44100 , 48000 , 32000}
|
||||
};
|
||||
|
||||
/* GUI control stuff */
|
||||
int send_fd;
|
||||
int receive_fd;
|
||||
|
||||
int stop_flag;
|
||||
int quit_flag;
|
||||
|
||||
int A_QUIET,A_SHOW_CNT;
|
||||
int A_AUDIO_PLAY;
|
||||
int A_SET_VOLUME, A_SHOW_TIME;
|
||||
int A_SHUFFLE;
|
||||
int A_DOWNMIX;
|
||||
|
||||
short pcm_sample[64];
|
||||
|
||||
short t_bitrate[2][3][15] = {{
|
||||
{0,32,48,56,64,80,96,112,128,144,160,176,192,224,256},
|
||||
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160},
|
||||
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160}
|
||||
},{
|
||||
{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448},
|
||||
{0,32,48,56,64,80,96,112,128,160,192,224,256,320,384},
|
||||
{0,32,40,48,56,64,80,96,112,128,160,192,224,256,320}
|
||||
}};
|
||||
|
||||
/* the last sfb is given implicitly on pg.28. of the standard. scalefactors
|
||||
* for that one are 0, pretab also
|
||||
*/
|
||||
/* leftmost index denotes ID, so first three tables are for MPEG2 (header->ID==0)
|
||||
* and the other three are for MPEG1 (header->ID==1)
|
||||
*/
|
||||
/* 22.05, 24, 16 */
|
||||
int t_b8_l[2][3][22]={{ /* table B.8b ISO/IEC 11172-3 */
|
||||
{5,11,17,23,29,35,43,53,65,79,95,115,139,167,199,237,283,335,395,463,521,575},
|
||||
{5,11,17,23,29,35,43,53,65,79,95,113,135,161,193,231,277,331,393,463,539,575},
|
||||
{5,11,17,23,29,35,43,53,65,79,95,115,139,167,199,237,283,335,395,463,521,575}
|
||||
},{
|
||||
{3,7,11,15,19,23,29,35,43,51,61,73,89,109,133,161,195,237,287,341,417,575},
|
||||
{3,7,11,15,19,23,29,35,41,49,59,71,87,105,127,155,189,229,275,329,383,575},
|
||||
{3,7,11,15,19,23,29,35,43,53,65,81,101,125,155,193,239,295,363,447,549,575}
|
||||
}};
|
||||
int t_b8_s[2][3][13]={{ /* table B.8b ISO/IEC 11172-3 */
|
||||
{3,7,11,17,23,31,41,55,73,99,131,173,191},
|
||||
{3,7,11,17,25,35,47,61,79,103,135,179,191},
|
||||
{3,7,11,17,25,35,47,61,79,103,133,173,191}
|
||||
},{
|
||||
{3,7,11,15,21,29,39,51,65,83,105,135,191},
|
||||
{3,7,11,15,21,27,37,49,63,79,99,125,191},
|
||||
{3,7,11,15,21,29,41,57,77,103,137,179,191}
|
||||
}};
|
||||
|
||||
int args(int argc,char **argv);
|
||||
void initialise_decoder(void);
|
||||
int decodeMPEG(struct AUDIO_HEADER *header);
|
||||
void initialise_globals(void);
|
||||
void report_header_error(int err);
|
||||
int setup_audio(struct AUDIO_HEADER *header);
|
||||
void close_audio(void);
|
||||
int ready_audio(void);
|
||||
|
||||
void play(char *inFileStr);
|
||||
|
||||
#endif /* AUDIO */
|
||||
|
||||
27
dll/amp/audioIO.c
Normal file
27
dll/amp/audioIO.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifdef OS_AIX
|
||||
#include "audioIO_AIX.c"
|
||||
#endif
|
||||
|
||||
#ifdef OS_Linux
|
||||
#include "audioIO_Linux.c"
|
||||
#endif
|
||||
|
||||
#ifdef OS_BSD
|
||||
#include "audioIO_Linux.c"
|
||||
#endif
|
||||
|
||||
#if defined(OS_IRIX) || defined(OS_IRIX64)
|
||||
#include "audioIO_IRIX.c"
|
||||
#endif
|
||||
|
||||
#ifdef OS_HPUX
|
||||
#include "audioIO_HPUX.c"
|
||||
#endif
|
||||
|
||||
#ifdef OS_SunOS
|
||||
#include "audioIO_SunOS.c"
|
||||
#endif
|
||||
|
||||
#ifdef __BEOS__
|
||||
#include "audioIO_BeOS.c"
|
||||
#endif
|
||||
28
dll/amp/audioIO.h
Normal file
28
dll/amp/audioIO.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* AUSUZ should be the amount of data your audio device will accept after it
|
||||
* has said it is ready to receive data. ie when the device is ready for data it
|
||||
* will accept it without blocking. It must also be a multiple of 128
|
||||
*/
|
||||
|
||||
#ifdef OS_AIX
|
||||
#define AUSIZ 32768
|
||||
#endif
|
||||
|
||||
#ifdef OS_Linux
|
||||
extern int AUSIZ;
|
||||
#endif
|
||||
|
||||
#ifdef OS_BSD
|
||||
#define AUSIZ 32768
|
||||
#endif
|
||||
|
||||
#if defined(OS_IRIX) || defined(OS_IRIX64)
|
||||
#define AUSIZ 32768
|
||||
#endif
|
||||
|
||||
#ifdef OS_HPUX
|
||||
#define AUSIZ 4096
|
||||
#endif
|
||||
|
||||
#ifdef OS_SunOS
|
||||
#define AUSIZ 4096
|
||||
#endif
|
||||
147
dll/amp/audioIO_Linux.c
Normal file
147
dll/amp/audioIO_Linux.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
|
||||
Origional code by: tomislav uzelac
|
||||
Modified by:
|
||||
* Dan Nelson - BSD mods.
|
||||
* Andrew Richards - moved code from audio.c and added mixer support etc
|
||||
|
||||
*/
|
||||
|
||||
/* Support for Linux and BSD sound devices */
|
||||
|
||||
#include "amp.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "audioIO.h"
|
||||
|
||||
#ifdef HAVE_MACHINE_SOUNDCARD_H
|
||||
#include <machine/soundcard.h>
|
||||
#elif defined(HAVE_LINUX_SOUNDCARD_H)
|
||||
#include <linux/soundcard.h>
|
||||
#elif defined(HAVE_SYS_SOUNDCARD_H)
|
||||
#include <sys/soundcard.h>
|
||||
#else
|
||||
#define NO_SOUNCARD_H
|
||||
#endif
|
||||
|
||||
#ifndef NO_SOUNCARD_H
|
||||
/* optimal fragment size */
|
||||
|
||||
int AUSIZ = 0;
|
||||
|
||||
/* declare these static to effectively isolate the audio device */
|
||||
|
||||
static int audio_fd;
|
||||
static int mixer_fd;
|
||||
static int volumeIoctl;
|
||||
|
||||
/* audioOpen() */
|
||||
/* should open the audio device, perform any special initialization */
|
||||
/* Set the frequency, no of channels and volume. Volume is only set if */
|
||||
/* it is not -1 */
|
||||
|
||||
void
|
||||
audioOpen(int frequency, int stereo, int volume)
|
||||
{
|
||||
int supportedMixers, play_format=AFMT_S16_LE;
|
||||
|
||||
if ((audio_fd = open ("/dev/dsp", O_WRONLY, 0)) == -1)
|
||||
die("Unable to open the audio device\n");
|
||||
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_SETFMT,&play_format) < 0)
|
||||
die("Unable to set required audio format\n");
|
||||
if ((mixer_fd=open("/dev/mixer",O_RDWR)) == -1)
|
||||
warn("Unable to open mixer device\n");
|
||||
|
||||
if (ioctl(mixer_fd, SOUND_MIXER_READ_DEVMASK, &supportedMixers) == -1) {
|
||||
warn("Unable to get mixer info assuming master volume\n");
|
||||
volumeIoctl=SOUND_MIXER_WRITE_VOLUME;
|
||||
} else {
|
||||
if ((supportedMixers & SOUND_MASK_PCM) != 0)
|
||||
volumeIoctl=SOUND_MIXER_WRITE_PCM;
|
||||
else
|
||||
volumeIoctl=0;
|
||||
}
|
||||
|
||||
/* Set 1 or 2 channels */
|
||||
stereo=(stereo ? 1 : 0);
|
||||
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0)
|
||||
die("Unable to set stereo/mono\n");
|
||||
|
||||
/* Set the output frequency */
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &frequency) < 0)
|
||||
die("Unable to set frequency: %d\n",frequency);
|
||||
|
||||
if (volume != -1)
|
||||
audioSetVolume(volume);
|
||||
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &AUSIZ) == -1)
|
||||
die("Unable to get fragment size\n");
|
||||
}
|
||||
|
||||
|
||||
/* audioSetVolume - only code this if your system can change the volume while */
|
||||
/* playing. sets the output volume 0-100 */
|
||||
|
||||
void
|
||||
audioSetVolume(int volume)
|
||||
{
|
||||
|
||||
volume=(volume<<8)+volume;
|
||||
if ((mixer_fd != -1) && (volumeIoctl!=0))
|
||||
if (ioctl(mixer_fd, volumeIoctl, &volume) < 0)
|
||||
warn("Unable to set sound volume\n");
|
||||
}
|
||||
|
||||
|
||||
/* audioFlush() */
|
||||
/* should flush the audio device */
|
||||
|
||||
inline void
|
||||
audioFlush()
|
||||
{
|
||||
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_RESET, 0) == -1)
|
||||
die("Unable to reset audio device\n");
|
||||
}
|
||||
|
||||
|
||||
/* audioClose() */
|
||||
/* should close the audio device and perform any special shutdown */
|
||||
|
||||
void
|
||||
audioClose()
|
||||
{
|
||||
close(audio_fd);
|
||||
if (mixer_fd != -1)
|
||||
close(mixer_fd);
|
||||
}
|
||||
|
||||
|
||||
/* audioWrite */
|
||||
/* writes count bytes from buffer to the audio device */
|
||||
/* returns the number of bytes actually written */
|
||||
|
||||
inline int
|
||||
audioWrite(char *buffer, int count)
|
||||
{
|
||||
return(write(audio_fd,buffer,count));
|
||||
}
|
||||
|
||||
|
||||
/* Let buffer.c have the audio descriptor so it can select on it. This means */
|
||||
/* that the program is dependent on a file descriptor to work. Should really */
|
||||
/* move the select's etc (with inlines of course) in here so that this is the */
|
||||
/* ONLY file which has hardware dependent audio stuff in it */
|
||||
|
||||
int
|
||||
getAudioFd()
|
||||
{
|
||||
return(audio_fd);
|
||||
}
|
||||
#endif
|
||||
267
dll/amp/buffer.c
Normal file
267
dll/amp/buffer.c
Normal file
@@ -0,0 +1,267 @@
|
||||
/* this file is a part of amp software
|
||||
|
||||
buffer.c: written by Andrew Richards <A.Richards@phys.canterbury.ac.nz>
|
||||
(except printout())
|
||||
|
||||
Last modified by:
|
||||
Karl Anders Oygard added flushing of audio buffers, 13 May 1997
|
||||
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "transform.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/signal.h>
|
||||
#ifdef HAVE_MLOCK
|
||||
#ifdef OS_Linux
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "audioIO.h"
|
||||
#include "audio.h"
|
||||
|
||||
#if !defined(OS_Linux) && !defined(AUSIZ)
|
||||
#define AUSIZ 32768
|
||||
#endif
|
||||
|
||||
struct ringBuffer { /* A ring buffer to store the data in */
|
||||
char *bufferPtr; /* buffer pointer */
|
||||
int inPos, outPos; /* positions for reading and writing */
|
||||
};
|
||||
|
||||
|
||||
static int buffer_fd;
|
||||
static int control_fd;
|
||||
|
||||
/* little endian systems do not require any byte swapping whatsoever.
|
||||
* big endian systems require byte swapping when writing .wav files,
|
||||
* but not when playing directly
|
||||
*/
|
||||
|
||||
/* This is a separate (but inlined) function to make it easier to implement */
|
||||
/* a threaded buffer */
|
||||
|
||||
inline void audioBufferWrite(char *buf,int bytes)
|
||||
{
|
||||
write(buffer_fd, buf, bytes);
|
||||
}
|
||||
|
||||
void printout(void)
|
||||
{
|
||||
int j;
|
||||
|
||||
if (nch==2)
|
||||
j=32 * 18 * 2;
|
||||
else
|
||||
j=32 * 18;
|
||||
|
||||
if (AUDIO_BUFFER_SIZE==0)
|
||||
audioWrite((char*)sample_buffer, j * sizeof(short));
|
||||
else
|
||||
audioBufferWrite((char*)sample_buffer, j * sizeof(short));
|
||||
}
|
||||
|
||||
int AUDIO_BUFFER_SIZE;
|
||||
|
||||
#define bufferSize(A) (((A)->inPos+AUDIO_BUFFER_SIZE-(A)->outPos) % AUDIO_BUFFER_SIZE)
|
||||
#define bufferFree(A) (AUDIO_BUFFER_SIZE-1-bufferSize(A))
|
||||
|
||||
void
|
||||
initBuffer(struct ringBuffer *buffer)
|
||||
{
|
||||
buffer->bufferPtr=malloc(AUDIO_BUFFER_SIZE);
|
||||
if (buffer->bufferPtr==NULL)
|
||||
_exit(-1);
|
||||
#ifdef HAVE_MLOCK
|
||||
mlock(buffer->bufferPtr,AUDIO_BUFFER_SIZE);
|
||||
#endif
|
||||
buffer->inPos = 0;
|
||||
buffer->outPos = 0;
|
||||
}
|
||||
|
||||
void
|
||||
freeBuffer(struct ringBuffer *buffer)
|
||||
{
|
||||
#ifdef HAVE_MLOCK
|
||||
munlock(buffer->bufferPtr,AUDIO_BUFFER_SIZE);
|
||||
#endif
|
||||
free(buffer->bufferPtr);
|
||||
}
|
||||
|
||||
/* This just sends some bogus data on the control pipe, which will cause */
|
||||
/* the reader to flush its buffer. */
|
||||
|
||||
void
|
||||
audioBufferFlush()
|
||||
{
|
||||
if (AUDIO_BUFFER_SIZE!=0)
|
||||
{
|
||||
int dummy;
|
||||
|
||||
/* We could use the control pipe for passing commands to the */
|
||||
/* audio player process, but so far we haven't bothered. */
|
||||
|
||||
write(control_fd, &dummy, sizeof dummy);
|
||||
} else
|
||||
audioFlush();
|
||||
}
|
||||
|
||||
|
||||
/* The decoded data are stored in a the ring buffer until they can be sent */
|
||||
/* to the audio device. Variables are named in relation to the buffer */
|
||||
/* ie writes are writes from the codec to the buffer and reads are reads */
|
||||
/* from the buffer to the audio device */
|
||||
|
||||
int
|
||||
audioBufferOpen(int frequency, int stereo, int volume)
|
||||
{
|
||||
struct ringBuffer audioBuffer;
|
||||
|
||||
int inFd,outFd,ctlFd,cnt,pid;
|
||||
int inputFinished=FALSE;
|
||||
int percentFull;
|
||||
fd_set inFdSet,outFdSet;
|
||||
fd_set *outFdPtr;
|
||||
struct timeval timeout;
|
||||
int filedes[2];
|
||||
int controldes[2];
|
||||
|
||||
|
||||
if (pipe(filedes) || pipe(controldes))
|
||||
{
|
||||
perror("pipe");
|
||||
exit(-1);
|
||||
}
|
||||
if ((pid=fork())!=0)
|
||||
{
|
||||
/* if we are the parent */
|
||||
control_fd=controldes[1];
|
||||
close(filedes[0]);
|
||||
buffer_fd=filedes[1];
|
||||
close(controldes[0]);
|
||||
return(pid); /* return the pid */
|
||||
}
|
||||
|
||||
|
||||
/* we are the child */
|
||||
close(filedes[1]);
|
||||
inFd=filedes[0];
|
||||
close(controldes[1]);
|
||||
ctlFd=controldes[0];
|
||||
audioOpen(frequency,stereo,volume);
|
||||
outFd=getAudioFd();
|
||||
initBuffer(&audioBuffer);
|
||||
|
||||
while(1)
|
||||
{
|
||||
timeout.tv_sec=0;
|
||||
timeout.tv_usec=0;
|
||||
FD_ZERO(&inFdSet);
|
||||
FD_ZERO(&outFdSet);
|
||||
FD_SET(ctlFd,&inFdSet);
|
||||
FD_SET(outFd,&outFdSet);
|
||||
|
||||
if (bufferSize(&audioBuffer)<AUSIZ)
|
||||
{ /* is the buffer too empty */
|
||||
outFdPtr = NULL; /* yes, don't try to write */
|
||||
if (inputFinished) /* no more input, buffer exhausted -> exit */
|
||||
break;
|
||||
} else
|
||||
outFdPtr=&outFdSet; /* no, select on write */
|
||||
|
||||
/* check we have at least AUSIZ bytes left (don't want <1k bits) */
|
||||
if ((bufferFree(&audioBuffer)>=AUSIZ) && !inputFinished)
|
||||
FD_SET(inFd,&inFdSet);
|
||||
|
||||
/* The following selects() are basically all that is left of the system
|
||||
dependent code outside the audioIO_*&c files. These selects really
|
||||
need to be moved into the audioIO_*.c files and replaced with a
|
||||
function like audioIOReady(inFd, &checkIn, &checkAudio, wait) where
|
||||
it checks the status of the input or audio output if checkIn or
|
||||
checkAudio are set and returns with checkIn or checkAudio set to TRUE
|
||||
or FALSE depending on whether or not data is available. If wait is
|
||||
FALSE the function should return immediately, if wait is TRUE the
|
||||
process should BLOCK until the required condition is met. NB: The
|
||||
process MUST relinquish the CPU during this check or it will gobble
|
||||
up all the available CPU which sort of defeats the purpose of the
|
||||
buffer.
|
||||
|
||||
This is tricky for people who don't have file descriptors (and
|
||||
select) to do the job. In that case a buffer implemented using
|
||||
threads should work. The way things are set up now a threaded version
|
||||
shouldn't be to hard to implement. When I get some time... */
|
||||
|
||||
/* check if we can read or write */
|
||||
if (select(MAX3(inFd,outFd,ctlFd)+1,&inFdSet,outFdPtr,NULL,NULL) > -1)
|
||||
{
|
||||
if (outFdPtr && FD_ISSET(outFd,outFdPtr))
|
||||
{ /* need to write */
|
||||
int bytesToEnd = AUDIO_BUFFER_SIZE - audioBuffer.outPos;
|
||||
|
||||
percentFull=100*bufferSize(&audioBuffer)/AUDIO_BUFFER_SIZE;
|
||||
if (AUSIZ>bytesToEnd)
|
||||
{
|
||||
cnt = audioWrite(audioBuffer.bufferPtr + audioBuffer.outPos, bytesToEnd);
|
||||
cnt += audioWrite(audioBuffer.bufferPtr, AUSIZ - bytesToEnd);
|
||||
audioBuffer.outPos = AUSIZ - bytesToEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = audioWrite(audioBuffer.bufferPtr + audioBuffer.outPos, AUSIZ);
|
||||
audioBuffer.outPos += AUSIZ;
|
||||
}
|
||||
|
||||
}
|
||||
if (FD_ISSET(inFd,&inFdSet))
|
||||
{ /* need to read */
|
||||
cnt = read(inFd, audioBuffer.bufferPtr + audioBuffer.inPos, MIN(AUSIZ, AUDIO_BUFFER_SIZE - audioBuffer.inPos));
|
||||
if (cnt >= 0)
|
||||
{
|
||||
audioBuffer.inPos = (audioBuffer.inPos + cnt) % AUDIO_BUFFER_SIZE;
|
||||
|
||||
if (cnt==0)
|
||||
inputFinished=TRUE;
|
||||
}
|
||||
else
|
||||
_exit(-1);
|
||||
}
|
||||
if (FD_ISSET(ctlFd,&inFdSet))
|
||||
{
|
||||
int dummy;
|
||||
|
||||
cnt = read(ctlFd, &dummy, sizeof dummy);
|
||||
if (cnt >= 0)
|
||||
{
|
||||
audioBuffer.inPos = audioBuffer.outPos = 0;
|
||||
audioFlush();
|
||||
}
|
||||
else
|
||||
_exit(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
_exit(-1);
|
||||
}
|
||||
close(inFd);
|
||||
audioClose();
|
||||
exit(0);
|
||||
return 0; /* just to get rid of warnings */
|
||||
}
|
||||
|
||||
void
|
||||
audioBufferClose()
|
||||
{
|
||||
/* Close the buffer pipe and wait for the buffer process to close */
|
||||
close(buffer_fd);
|
||||
waitpid(0,0,0);
|
||||
}
|
||||
40
dll/amp/config.h.in
Normal file
40
dll/amp/config.h.in
Normal file
@@ -0,0 +1,40 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
276
dll/amp/getbits.c
Normal file
276
dll/amp/getbits.c
Normal file
@@ -0,0 +1,276 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* getbits.c bit level routines, input buffer
|
||||
*
|
||||
* Created by: tomislav uzelac Apr 1996
|
||||
* better synchronization, tomislav uzelac, Apr 23 1997
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "audio.h"
|
||||
|
||||
#define GETBITS
|
||||
#include "getbits.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* buffer and bit manipulation functions ***************************************
|
||||
*/
|
||||
static inline int _fillbfr(unsigned int size)
|
||||
{
|
||||
_bptr=0;
|
||||
return get_input(_buffer, size);
|
||||
}
|
||||
|
||||
static inline int readsync()
|
||||
{
|
||||
_bptr=0;
|
||||
_buffer[0]=_buffer[1];
|
||||
_buffer[1]=_buffer[2];
|
||||
_buffer[2]=_buffer[3];
|
||||
return get_input(&_buffer[3],1);
|
||||
}
|
||||
|
||||
static inline unsigned int _getbits(int n)
|
||||
{
|
||||
unsigned int pos,ret_value;
|
||||
|
||||
pos = _bptr >> 3;
|
||||
ret_value = _buffer[pos] << 24 |
|
||||
_buffer[pos+1] << 16 |
|
||||
_buffer[pos+2] << 8 |
|
||||
_buffer[pos+3];
|
||||
ret_value <<= _bptr & 7;
|
||||
ret_value >>= 32 - n;
|
||||
_bptr += n;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
int fillbfr(unsigned int advance)
|
||||
{
|
||||
int overflow,retval;
|
||||
|
||||
retval=get_input(&buffer[append], advance);
|
||||
|
||||
if ( append + advance >= BUFFER_SIZE) {
|
||||
overflow = append + advance - BUFFER_SIZE;
|
||||
memcpy (buffer,&buffer[BUFFER_SIZE], overflow);
|
||||
if (overflow < 4) memcpy(&buffer[BUFFER_SIZE],buffer,4);
|
||||
append = overflow;
|
||||
} else {
|
||||
if (append==0) memcpy(&buffer[BUFFER_SIZE],buffer,4);
|
||||
append+=advance;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
unsigned int getbits(int n)
|
||||
{
|
||||
if (n) {
|
||||
unsigned int pos,ret_value;
|
||||
|
||||
pos = data >> 3;
|
||||
ret_value = buffer[pos] << 24 |
|
||||
buffer[pos+1] << 16 |
|
||||
buffer[pos+2] << 8 |
|
||||
buffer[pos+3];
|
||||
ret_value <<= data & 7;
|
||||
ret_value >>= 32 - n;
|
||||
|
||||
data += n;
|
||||
data &= (8*BUFFER_SIZE)-1;
|
||||
|
||||
return ret_value;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* header and side info parsing stuff ******************************************
|
||||
*/
|
||||
static inline void parse_header(struct AUDIO_HEADER *header)
|
||||
{
|
||||
header->ID=_getbits(1);
|
||||
header->layer=_getbits(2);
|
||||
header->protection_bit=_getbits(1);
|
||||
header->bitrate_index=_getbits(4);
|
||||
header->sampling_frequency=_getbits(2);
|
||||
header->padding_bit=_getbits(1);
|
||||
header->private_bit=_getbits(1);
|
||||
header->mode=_getbits(2);
|
||||
header->mode_extension=_getbits(2);
|
||||
if (!header->mode) header->mode_extension=0;
|
||||
header->copyright=_getbits(1);
|
||||
header->original=_getbits(1);
|
||||
header->emphasis=_getbits(2);
|
||||
}
|
||||
|
||||
static inline int header_sanity_check(struct AUDIO_HEADER *header)
|
||||
{
|
||||
if ( header->layer==0 ||
|
||||
header->bitrate_index==15 ||
|
||||
header->sampling_frequency==3) return -1;
|
||||
|
||||
/* an additional check to make shure that stuffing never gets mistaken
|
||||
* for a syncword. This rules out some legal layer1 streams, but who
|
||||
* cares about layer1 anyway :-). I must get this right sometime.
|
||||
*/
|
||||
if ( header->ID==1 && header->layer==3 && header->protection_bit==1) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int gethdr(struct AUDIO_HEADER *header)
|
||||
{
|
||||
int s,retval;
|
||||
struct AUDIO_HEADER tmp;
|
||||
|
||||
/* TODO: add a simple byte counter to check only first, say, 1024
|
||||
* bytes for a new header and then return GETHDR_SYN
|
||||
*/
|
||||
if ((retval=_fillbfr(4))!=0) return retval;
|
||||
|
||||
for(;;) {
|
||||
while ((s=_getbits(12)) != 0xfff) {
|
||||
if (s==0xffe) {
|
||||
parse_header(&tmp);
|
||||
if (header_sanity_check(&tmp)==0) return GETHDR_NS;
|
||||
}
|
||||
if ((retval=readsync())!=0) return retval;
|
||||
}
|
||||
|
||||
parse_header(&tmp);
|
||||
if (header_sanity_check(&tmp)!=0) {
|
||||
if ((retval=readsync())!=0) return retval;
|
||||
} else break;
|
||||
}
|
||||
|
||||
if (tmp.layer==3) return GETHDR_FL1;
|
||||
/* if (tmp.layer==2) return GETHDR_FL2; */
|
||||
if (tmp.bitrate_index==0) return GETHDR_FF;
|
||||
|
||||
memcpy(header,&tmp,sizeof(tmp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* dummy function, to get crc out of the way
|
||||
*/
|
||||
void getcrc()
|
||||
{
|
||||
_fillbfr(2);
|
||||
_getbits(16);
|
||||
}
|
||||
|
||||
/* sizes of side_info:
|
||||
* MPEG1 1ch 17 2ch 32
|
||||
* MPEG2 1ch 9 2ch 17
|
||||
*/
|
||||
void getinfo(struct AUDIO_HEADER *header,struct SIDE_INFO *info)
|
||||
{
|
||||
int gr,ch,scfsi_band,region,window;
|
||||
int nch;
|
||||
if (header->mode==3) {
|
||||
nch=1;
|
||||
if (header->ID) {
|
||||
_fillbfr(17);
|
||||
info->main_data_begin=_getbits(9);
|
||||
_getbits(5);
|
||||
} else {
|
||||
_fillbfr(9);
|
||||
info->main_data_begin=_getbits(8);
|
||||
_getbits(1);
|
||||
}
|
||||
} else {
|
||||
nch=2;
|
||||
if (header->ID) {
|
||||
_fillbfr(32);
|
||||
info->main_data_begin=_getbits(9);
|
||||
_getbits(3);
|
||||
} else {
|
||||
_fillbfr(17);
|
||||
info->main_data_begin=_getbits(8);
|
||||
_getbits(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (header->ID) for (ch=0;ch<nch;ch++)
|
||||
for (scfsi_band=0;scfsi_band<4;scfsi_band++)
|
||||
info->scfsi[ch][scfsi_band]=_getbits(1);
|
||||
|
||||
for (gr=0;gr<(header->ID ? 2:1);gr++)
|
||||
for (ch=0;ch<nch;ch++) {
|
||||
info->part2_3_length[gr][ch]=_getbits(12);
|
||||
info->big_values[gr][ch]=_getbits(9);
|
||||
info->global_gain[gr][ch]=_getbits(8);
|
||||
if (header->ID) info->scalefac_compress[gr][ch]=_getbits(4);
|
||||
else info->scalefac_compress[gr][ch]=_getbits(9);
|
||||
info->window_switching_flag[gr][ch]=_getbits(1);
|
||||
|
||||
if (info->window_switching_flag[gr][ch]) {
|
||||
info->block_type[gr][ch]=_getbits(2);
|
||||
info->mixed_block_flag[gr][ch]=_getbits(1);
|
||||
|
||||
for (region=0;region<2;region++)
|
||||
info->table_select[gr][ch][region]=_getbits(5);
|
||||
info->table_select[gr][ch][2]=0;
|
||||
|
||||
for (window=0;window<3;window++)
|
||||
info->subblock_gain[gr][ch][window]=_getbits(3);
|
||||
} else {
|
||||
for (region=0;region<3;region++)
|
||||
info->table_select[gr][ch][region]=_getbits(5);
|
||||
|
||||
info->region0_count[gr][ch]=_getbits(4);
|
||||
info->region1_count[gr][ch]=_getbits(3);
|
||||
info->block_type[gr][ch]=0;
|
||||
}
|
||||
|
||||
if (header->ID) info->preflag[gr][ch]=_getbits(1);
|
||||
info->scalefac_scale[gr][ch]=_getbits(1);
|
||||
info->count1table_select[gr][ch]=_getbits(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int dummy_getinfo(int n)
|
||||
{
|
||||
n-=4;
|
||||
if ( fseek(in_file,n,SEEK_CUR) != 0)
|
||||
{
|
||||
if (feof(in_file))
|
||||
return GETHDR_EOF;
|
||||
else
|
||||
return GETHDR_ERR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rewind_stream(int nbytes)
|
||||
{
|
||||
nbytes+=5;
|
||||
if (fseek(in_file, -nbytes, SEEK_CUR) != 0)
|
||||
{
|
||||
/* what if we need to be at the very beginning? */
|
||||
nbytes--;
|
||||
if (fseek(in_file, -nbytes, SEEK_CUR) != 0)
|
||||
return GETHDR_ERR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int get_input(unsigned char* bp, unsigned int size)
|
||||
{
|
||||
#ifdef LINUX_REALTIME
|
||||
return prefetch_get_input(bp,size);
|
||||
#else /* LINUX_REALTIME */
|
||||
if ( fread( bp , 1, size, in_file) != size)
|
||||
{
|
||||
if (feof(in_file))
|
||||
return GETHDR_EOF;
|
||||
else
|
||||
return GETHDR_ERR;
|
||||
}
|
||||
return 0;
|
||||
#endif /* LINUX_REALTIME */
|
||||
}
|
||||
79
dll/amp/getbits.h
Normal file
79
dll/amp/getbits.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* getbits.h
|
||||
*
|
||||
* Created by: tomislav uzelac Apr 1996
|
||||
*/
|
||||
|
||||
/* gethdr() error codes
|
||||
*/
|
||||
#define GETHDR_ERR 0x1
|
||||
#define GETHDR_NS 0x2
|
||||
#define GETHDR_FL1 0x4
|
||||
#define GETHDR_FL2 0x8
|
||||
#define GETHDR_FF 0x10
|
||||
#define GETHDR_SYN 0x20
|
||||
#define GETHDR_EOF 0x30
|
||||
|
||||
/* buffer for the 'bit reservoir'
|
||||
*/
|
||||
#define BUFFER_SIZE 4096
|
||||
#define BUFFER_AUX 2048
|
||||
extern unsigned char buffer[];
|
||||
extern int append,data,f_bdirty,bclean_bytes;
|
||||
|
||||
/* exports
|
||||
*/
|
||||
extern int fillbfr(unsigned int advance);
|
||||
extern unsigned int getbits(int n);
|
||||
extern int gethdr(struct AUDIO_HEADER *header);
|
||||
extern void getcrc();
|
||||
extern void getinfo(struct AUDIO_HEADER *header,struct SIDE_INFO *info);
|
||||
extern int dummy_getinfo(int n);
|
||||
extern int rewind_stream(int nbytes);
|
||||
|
||||
|
||||
#ifdef GETBITS
|
||||
|
||||
/* buffer, AUX is used in case of input buffer "overflow", and its contents
|
||||
* are copied to the beginning of the buffer
|
||||
*/
|
||||
unsigned char buffer[BUFFER_SIZE+BUFFER_AUX+1];
|
||||
|
||||
/* buffer pointers: append counts in bytes, data in bits
|
||||
*/
|
||||
int append,data;
|
||||
|
||||
/* bit reservoir stuff. f_bdirty must be set to TRUE when starting play!
|
||||
*/
|
||||
int f_bdirty,bclean_bytes;
|
||||
|
||||
/* internal buffer, _bptr holds the position in _bits_
|
||||
*/
|
||||
static unsigned char _buffer[32];
|
||||
static int _bptr;
|
||||
|
||||
|
||||
/* buffer and bit manipulation functions
|
||||
*/
|
||||
static inline int _fillbfr(unsigned int size);
|
||||
static inline int readsync();
|
||||
static inline int get_input(unsigned char* bp, unsigned int size);
|
||||
static inline unsigned int _getbits(int n);
|
||||
int fillbfr(unsigned int advance);
|
||||
unsigned int getbits(int n);
|
||||
int dummy_getinfo(int n);
|
||||
int rewind_stream(int nbytes);
|
||||
|
||||
/* header and side info parsing stuff
|
||||
*/
|
||||
static inline void parse_header(struct AUDIO_HEADER *header);
|
||||
static inline int header_sanity_check(struct AUDIO_HEADER *header);
|
||||
|
||||
int gethdr(struct AUDIO_HEADER *header);
|
||||
void getcrc();
|
||||
void getinfo(struct AUDIO_HEADER *header,struct SIDE_INFO *info);
|
||||
|
||||
#endif /* GETBITS */
|
||||
|
||||
284
dll/amp/getdata.c
Normal file
284
dll/amp/getdata.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* getdata.c scalefactor & huffman data extraction
|
||||
*
|
||||
* Created by: tomislav uzelac Apr 1996
|
||||
* Last modified by: tomislav uzelac Feb 27 1997
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
#include "huffman.h"
|
||||
|
||||
#define GETDATA
|
||||
#include "getdata.h"
|
||||
|
||||
/* layer3 scalefactor decoding. should we check for the number
|
||||
* of bits read, just in case?
|
||||
*/
|
||||
int decode_scalefactors(struct SIDE_INFO *info,struct AUDIO_HEADER *header,int gr,int ch)
|
||||
{
|
||||
int sfb,window;
|
||||
int slen1,slen2;
|
||||
int i1,i2,i=0;
|
||||
int j,k;
|
||||
if (header->ID==1) {
|
||||
/* this is MPEG-1 scalefactors format, quite different than
|
||||
* the MPEG-2 format.
|
||||
*/
|
||||
slen1=t_slen1[info->scalefac_compress[gr][ch]];
|
||||
slen2=t_slen2[info->scalefac_compress[gr][ch]];
|
||||
i1=3*slen1;
|
||||
i2=3*slen2;
|
||||
|
||||
if (info->window_switching_flag[gr][ch] && info->block_type[gr][ch]==2)
|
||||
{
|
||||
if (info->mixed_block_flag[gr][ch])
|
||||
{
|
||||
for (sfb=0;sfb<8;sfb++)
|
||||
{
|
||||
scalefac_l[gr][ch][sfb]=getbits(slen1);
|
||||
i+=slen1;
|
||||
}
|
||||
for (sfb=3;sfb<6;sfb++)
|
||||
{
|
||||
for (window=0;window<3;window++)
|
||||
scalefac_s[gr][ch][sfb][window]=getbits(slen1);
|
||||
i+=i1;
|
||||
}
|
||||
for (;sfb<12;sfb++)
|
||||
{
|
||||
for (window=0;window<3;window++)
|
||||
scalefac_s[gr][ch][sfb][window]=getbits(slen2);
|
||||
i+=i2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* !mixed_block_flag */
|
||||
for (sfb=0;sfb<6;sfb++)
|
||||
{
|
||||
for (window=0;window<3;window++)
|
||||
scalefac_s[gr][ch][sfb][window]=getbits(slen1);
|
||||
i+=i1;
|
||||
}
|
||||
for (;sfb<12;sfb++)
|
||||
{
|
||||
for (window=0;window<3;window++)
|
||||
scalefac_s[gr][ch][sfb][window]=getbits(slen2);
|
||||
i+=i2;
|
||||
}
|
||||
}
|
||||
for (window=0;window<3;window++)
|
||||
scalefac_s[gr][ch][12][window]=0;
|
||||
}
|
||||
else
|
||||
{ /* block_type!=2 */
|
||||
if ( !info->scfsi[ch][0] || !gr )
|
||||
{
|
||||
for (sfb=0;sfb<6;sfb++)
|
||||
{
|
||||
scalefac_l[gr][ch][sfb]=getbits(slen1);
|
||||
i+=slen1;
|
||||
}
|
||||
}
|
||||
else for (sfb=0;sfb<6;sfb++)
|
||||
{
|
||||
scalefac_l[1][ch][sfb]=scalefac_l[0][ch][sfb];
|
||||
}
|
||||
if ( !info->scfsi[ch][1] || !gr )
|
||||
{
|
||||
for (sfb=6;sfb<11;sfb++)
|
||||
{
|
||||
scalefac_l[gr][ch][sfb]=getbits(slen1);
|
||||
i+=slen1;
|
||||
}
|
||||
}
|
||||
else for (sfb=6;sfb<11;sfb++)
|
||||
{
|
||||
scalefac_l[1][ch][sfb]=scalefac_l[0][ch][sfb];
|
||||
}
|
||||
if ( !info->scfsi[ch][2] || !gr )
|
||||
{
|
||||
for (sfb=11;sfb<16;sfb++)
|
||||
{
|
||||
scalefac_l[gr][ch][sfb]=getbits(slen2);
|
||||
i+=slen2;
|
||||
}
|
||||
}
|
||||
else for (sfb=11;sfb<16;sfb++)
|
||||
{
|
||||
scalefac_l[1][ch][sfb]=scalefac_l[0][ch][sfb];
|
||||
}
|
||||
if ( !info->scfsi[ch][3] || !gr )
|
||||
{
|
||||
for (sfb=16;sfb<21;sfb++)
|
||||
{
|
||||
scalefac_l[gr][ch][sfb]=getbits(slen2);
|
||||
i+=slen2;
|
||||
}
|
||||
}
|
||||
else for (sfb=16;sfb<21;sfb++)
|
||||
{
|
||||
scalefac_l[1][ch][sfb]=scalefac_l[0][ch][sfb];
|
||||
}
|
||||
scalefac_l[gr][ch][21]=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* ID==0 */
|
||||
int index=0,index2,spooky_index;
|
||||
int slen[5],nr_of_sfb[5]; /* actually, there's four of each, not five, labelled 1 through 4, but
|
||||
* what's a word of storage compared to one's sanity. so [0] is irellevant.
|
||||
*/
|
||||
|
||||
/* ok, so we got 3 indexes.
|
||||
* spooky_index - indicates whether we use the normal set of slen eqs and nr_of_sfb tables
|
||||
* or the one for the right channel of intensity stereo coded frame
|
||||
* index - corresponds to the value of scalefac_compress, as listed in the standard
|
||||
* index2 - 0 for long blocks, 1 for short wo/ mixed_block_flag, 2 for short with it
|
||||
*/
|
||||
if ( (header->mode_extension==1 || header->mode_extension==3) && ch==1)
|
||||
{ /* right ch... */
|
||||
int int_scalefac_compress=info->scalefac_compress[0][ch]>>1;
|
||||
intensity_scale=info->scalefac_compress[0][1]&1;
|
||||
spooky_index=1;
|
||||
if (int_scalefac_compress < 180)
|
||||
{
|
||||
slen[1]=int_scalefac_compress/36;
|
||||
slen[2]=(int_scalefac_compress%36)/6;
|
||||
slen[3]=(int_scalefac_compress%36)%6;
|
||||
slen[4]=0;
|
||||
info->preflag[0][ch]=0;
|
||||
index=0;
|
||||
}
|
||||
if ( 180 <= int_scalefac_compress && int_scalefac_compress < 244)
|
||||
{
|
||||
slen[1]=((int_scalefac_compress-180)%64)>>4;
|
||||
slen[2]=((int_scalefac_compress-180)%16)>>2;
|
||||
slen[3]=(int_scalefac_compress-180)%4;
|
||||
slen[4]=0;
|
||||
info->preflag[0][ch]=0;
|
||||
index=1;
|
||||
}
|
||||
if ( 244 <= int_scalefac_compress && int_scalefac_compress < 255)
|
||||
{
|
||||
slen[1]=(int_scalefac_compress-244)/3;
|
||||
slen[2]=(int_scalefac_compress-244)%3;
|
||||
slen[3]=0;
|
||||
slen[4]=0;
|
||||
info->preflag[0][ch]=0;
|
||||
index=2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* the usual */
|
||||
spooky_index=0;
|
||||
if (info->scalefac_compress[0][ch] < 400)
|
||||
{
|
||||
slen[1]=(info->scalefac_compress[0][ch]>>4)/5;
|
||||
slen[2]=(info->scalefac_compress[0][ch]>>4)%5;
|
||||
slen[3]=(info->scalefac_compress[0][ch]%16)>>2;
|
||||
slen[4]=info->scalefac_compress[0][ch]%4;
|
||||
info->preflag[0][ch]=0;
|
||||
index=0;
|
||||
}
|
||||
if (info->scalefac_compress[0][ch] >= 400 && info->scalefac_compress[0][ch] < 500)
|
||||
{
|
||||
slen[1]=((info->scalefac_compress[0][ch]-400)>>2)/5;
|
||||
slen[2]=((info->scalefac_compress[0][ch]-400)>>2)%5;
|
||||
slen[3]=(info->scalefac_compress[0][ch]-400)%4;
|
||||
slen[4]=0;
|
||||
info->preflag[0][ch]=0;
|
||||
index=1;
|
||||
}
|
||||
if (info->scalefac_compress[0][ch] >= 500 && info->scalefac_compress[0][ch] < 512)
|
||||
{
|
||||
slen[1]=(info->scalefac_compress[0][ch]-500)/3;
|
||||
slen[2]=(info->scalefac_compress[0][ch]-500)%3;
|
||||
slen[3]=0;
|
||||
slen[4]=0;
|
||||
info->preflag[0][ch]=1;
|
||||
index=2;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->window_switching_flag[0][ch] && info->block_type[0][ch]==2)
|
||||
{
|
||||
if (info->mixed_block_flag[0][ch])
|
||||
index2=2;
|
||||
else
|
||||
index2=1;
|
||||
}
|
||||
else
|
||||
index2=0;
|
||||
|
||||
for (j=1;j<=4;j++) nr_of_sfb[j]=spooky_table[spooky_index][index][index2][j-1];
|
||||
|
||||
/* now we'll do some actual scalefactor extraction, and a little more.
|
||||
* for each scalefactor band we'll set the value of is_max to indicate
|
||||
* illegal is_pos, since with MPEG2 it's not 'hardcoded' to 7.
|
||||
*/
|
||||
if (!info->window_switching_flag[0][ch] || (info->window_switching_flag[0][ch] && info->block_type[0][ch]!=2))
|
||||
{
|
||||
sfb=0;
|
||||
for (j=1;j<=4;j++)
|
||||
for (k=0;k<nr_of_sfb[j];k++)
|
||||
{
|
||||
scalefac_l[0][ch][sfb]=getbits(slen[j]);
|
||||
i+=slen[j];
|
||||
if (ch) is_max[sfb]=(1<<slen[j])-1;
|
||||
sfb++;
|
||||
}
|
||||
}
|
||||
else if (info->block_type[0][ch]==2)
|
||||
{
|
||||
if (!info->mixed_block_flag[0][ch])
|
||||
{
|
||||
sfb=0;
|
||||
for (j=1;j<=4;j++)
|
||||
for (k=0;k<nr_of_sfb[j];k+=3)
|
||||
{
|
||||
/* we assume here that nr_of_sfb is divisible by 3. it is.
|
||||
*/
|
||||
scalefac_s[0][ch][sfb][0]=getbits(slen[j]);
|
||||
scalefac_s[0][ch][sfb][1]=getbits(slen[j]);
|
||||
scalefac_s[0][ch][sfb][2]=getbits(slen[j]);
|
||||
i+=3*slen[j];
|
||||
if (ch) is_max[sfb+6]=(1<<slen[j])-1;
|
||||
sfb++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* what we do here is:
|
||||
* 1. assume that for every fs, the two lowest subbands are equal to the
|
||||
* six lowest scalefactor bands for long blocks/MPEG2. they are.
|
||||
* 2. assume that for every fs, the two lowest subbands are equal to the
|
||||
* three lowest scalefactor bands for short blocks. they are.
|
||||
*/
|
||||
sfb=0;
|
||||
for (k=0;k<6;k++)
|
||||
{
|
||||
scalefac_l[0][ch][sfb]=getbits(slen[1]);
|
||||
i+=slen[j];
|
||||
if (ch) is_max[sfb]=(1<<slen[1])-1;
|
||||
sfb++;
|
||||
}
|
||||
nr_of_sfb[1]-=6;
|
||||
sfb=3;
|
||||
for (j=1;j<=4;j++)
|
||||
for (k=0;k<nr_of_sfb[j];k+=3)
|
||||
{
|
||||
scalefac_s[0][ch][sfb][0]=getbits(slen[j]);
|
||||
scalefac_s[0][ch][sfb][1]=getbits(slen[j]);
|
||||
scalefac_s[0][ch][sfb][2]=getbits(slen[j]);
|
||||
i+=3*slen[j];
|
||||
if (ch) is_max[sfb+6]=(1<<slen[j])-1;
|
||||
sfb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
42
dll/amp/getdata.h
Normal file
42
dll/amp/getdata.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* getdata.h
|
||||
*
|
||||
* tomislav uzelac Apr 1996
|
||||
*/
|
||||
|
||||
extern int decode_scalefactors(struct SIDE_INFO *info,struct AUDIO_HEADER *header,int gr,int ch);
|
||||
|
||||
extern int is_max[21];
|
||||
extern int intensity_scale;
|
||||
|
||||
#ifdef GETDATA
|
||||
|
||||
static char t_slen1[16]={0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4};
|
||||
static char t_slen2[16]={0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3};
|
||||
|
||||
int is_max[21]; /* the maximum value of is_pos. for short blocks is_max[sfb=0] == is_max[6],
|
||||
* it's sloppy but i'm sick of waisting storage. blaah...
|
||||
*/
|
||||
int intensity_scale;
|
||||
|
||||
int decode_scalefactors(struct SIDE_INFO *info,struct AUDIO_HEADER *header,int gr,int ch);
|
||||
|
||||
/* my implementation of MPEG2 scalefactor decoding is, admitably, horrible
|
||||
* anyway, just take a look at pg.18 of MPEG2 specs, and you'll know what
|
||||
* this is all about
|
||||
*/
|
||||
static const char spooky_table[2][3][3][4]={
|
||||
{
|
||||
{ {6,5,5,5}, {9,9,9,9}, {6,9,9,9} },
|
||||
{ {6,5,7,3}, {9,9,12,6}, {6,9,12,6}},
|
||||
{ {11,10,0,0}, {18,18,0,0}, {15,18,0,0}}
|
||||
},
|
||||
{
|
||||
{ {7,7,7,0}, {12,12,12,0}, {6,15,12,0}},
|
||||
{ {6,6,6,3}, {12,9,9,6}, {6,12,9,6}},
|
||||
{ {8,8,5,0}, {15,12,9,0}, {6,18,9,0}}
|
||||
}};
|
||||
|
||||
#endif /* GETDATA */
|
||||
208
dll/amp/huffman.c
Normal file
208
dll/amp/huffman.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* huffman.c huffman decoding
|
||||
*
|
||||
* Created by: tomislav uzelac Mar,Apr 1996
|
||||
* Last modified by: tomislav uzelac Mar 8 97
|
||||
*/
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
|
||||
#define HUFFMAN
|
||||
#include "huffman.h"
|
||||
|
||||
static inline unsigned int viewbits(int n)
|
||||
{
|
||||
unsigned int pos,ret_value;
|
||||
|
||||
pos = data >> 3;
|
||||
ret_value = buffer[pos] << 24 |
|
||||
buffer[pos+1] << 16 |
|
||||
buffer[pos+2] << 8 |
|
||||
buffer[pos+3];
|
||||
ret_value <<= data & 7;
|
||||
ret_value >>= 32 - n;
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
static inline void sackbits(int n)
|
||||
{
|
||||
data += n;
|
||||
data &= 8*BUFFER_SIZE-1;
|
||||
}
|
||||
|
||||
/* huffman_decode() is supposed to be faster now
|
||||
* decodes one codeword and returns no. of bits
|
||||
*/
|
||||
static inline int huffman_decode(int tbl,int *x,int *y)
|
||||
{
|
||||
unsigned int chunk;
|
||||
register unsigned int *h_tab;
|
||||
register unsigned int lag = 0;
|
||||
register unsigned int half_lag;
|
||||
int len;
|
||||
|
||||
h_tab=tables[tbl];
|
||||
chunk=viewbits(19);
|
||||
|
||||
h_tab += h_cue[tbl][chunk >> (19-NC_O)];
|
||||
|
||||
len=(*h_tab>>8)&0x1f;
|
||||
|
||||
/* check for an immediate hit, so we can decode those short codes very fast
|
||||
*/
|
||||
if ((*h_tab>>(32-len)) != (chunk>>(19-len))) {
|
||||
if (chunk >> (19-NC_O) < N_CUE-1)
|
||||
lag=(h_cue[tbl][(chunk >> (19-NC_O))+1] -
|
||||
h_cue[tbl][chunk >> (19-NC_O)]);
|
||||
else {
|
||||
/* we strongly depend on h_cue[N_CUE-1] to point to
|
||||
* the last entry in the huffman table, so we should
|
||||
* noT get here anyway. if it didn't, we'd have to
|
||||
* have another table with huffman tables lengths, and
|
||||
* it would be a mess. just in case, scream&shout.
|
||||
*/
|
||||
/*printf(" h_cue clobbered. this is a bug. blip.\n");*/
|
||||
_exit (-1);
|
||||
}
|
||||
chunk <<= 32-19;
|
||||
chunk |= 0x1ff;
|
||||
|
||||
half_lag = lag >> 1;
|
||||
|
||||
h_tab += half_lag;
|
||||
lag -= half_lag;
|
||||
|
||||
while (lag > 1) {
|
||||
half_lag = lag >> 1;
|
||||
|
||||
if (*h_tab < chunk)
|
||||
h_tab += half_lag;
|
||||
else
|
||||
h_tab -= half_lag;
|
||||
|
||||
lag -= half_lag;
|
||||
}
|
||||
|
||||
len=(*h_tab>>8)&0x1f;
|
||||
if ((*h_tab>>(32-len)) != (chunk>>(32-len))) {
|
||||
if (*h_tab > chunk)
|
||||
h_tab--;
|
||||
else
|
||||
h_tab++;
|
||||
|
||||
len=(*h_tab>>8)&0x1f;
|
||||
}
|
||||
}
|
||||
sackbits(len);
|
||||
*x=(*h_tab>>4)&0xf;
|
||||
*y=*h_tab&0xf;
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline int _qsign(int x,int *q)
|
||||
{
|
||||
int ret_value=0,i;
|
||||
for (i=3;i>=0;i--)
|
||||
if ((x>>i) & 1) {
|
||||
if (getbits(1)) *q++=-1;
|
||||
else *q++=1;
|
||||
ret_value++;
|
||||
}
|
||||
else *q++=0;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
int decode_huffman_data(struct SIDE_INFO *info,int gr,int ch,int ssize)
|
||||
{
|
||||
int l,i,cnt,x,y;
|
||||
int q[4],r[3],linbits[3],tr[4]={0,0,0,0};
|
||||
int big_value = info->big_values[gr][ch] << 1;
|
||||
|
||||
for (l=0;l<3;l++) {
|
||||
tr[l]=info->table_select[gr][ch][l];
|
||||
linbits[l]=t_linbits[info->table_select[gr][ch][l]];
|
||||
}
|
||||
|
||||
tr[3]=32+info->count1table_select[gr][ch];
|
||||
|
||||
/* we have to be careful here because big_values are not necessarily
|
||||
* aligned with sfb boundaries
|
||||
*/
|
||||
if (!info->window_switching_flag[gr][ch] && info->block_type[gr][ch]==0) {
|
||||
|
||||
/* this code needed some cleanup
|
||||
*/
|
||||
r[0]=t_l[info->region0_count[gr][ch]] + 1;
|
||||
if (r[0] > big_value)
|
||||
r[0]=r[1]=big_value;
|
||||
else {
|
||||
r[1]=t_l[ info->region0_count[gr][ch] + info->region1_count[gr][ch] + 1 ] + 1;
|
||||
if (r[1] > big_value)
|
||||
r[1]=big_value;
|
||||
}
|
||||
r[2]=big_value;
|
||||
|
||||
} else {
|
||||
|
||||
if (info->block_type[gr][ch]==2 && info->mixed_block_flag[gr][ch]==0)
|
||||
r[0]=3*(t_s[2]+1);
|
||||
else
|
||||
r[0]=t_l[7]+1;
|
||||
|
||||
if (r[0] > big_value)
|
||||
r[0]=big_value;
|
||||
|
||||
r[1]=r[2]=big_value;
|
||||
}
|
||||
|
||||
l=0; cnt=0;
|
||||
for (i=0;i<3;i++) {
|
||||
for (;l<r[i];l+=2) {
|
||||
int j = linbits[i];
|
||||
|
||||
cnt+=huffman_decode(tr[i],&x,&y);
|
||||
|
||||
if (x==15 && j>0) {
|
||||
x+=getbits(j);
|
||||
cnt+=j;
|
||||
}
|
||||
if (x) {
|
||||
if (getbits(1)) x=-x;
|
||||
cnt++;
|
||||
}
|
||||
if (y==15 && j>0) {
|
||||
y+=getbits(j);
|
||||
cnt+=j;
|
||||
}
|
||||
if (y) {
|
||||
if (getbits(1)) y=-y;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
is[ch][l]=x;
|
||||
is[ch][l+1]=y;
|
||||
}
|
||||
}
|
||||
while ((cnt < info->part2_3_length[gr][ch]-ssize) && (l<576)) {
|
||||
cnt+=huffman_decode(tr[3],&x,&y);
|
||||
cnt+=_qsign(x,q);
|
||||
for (i=0;i<4;i++) is[ch][l+i]=q[i]; /* ziher je ziher, is[578]*/
|
||||
l+=4;
|
||||
}
|
||||
|
||||
/* set position to start of the next gr/ch
|
||||
*/
|
||||
if (cnt != info->part2_3_length[gr][ch] - ssize ) {
|
||||
data-=cnt-(info->part2_3_length[gr][ch] - ssize);
|
||||
data&= 8*BUFFER_SIZE - 1;
|
||||
}
|
||||
if (l<576) non_zero[ch]=l;
|
||||
else non_zero[ch]=576;
|
||||
/* zero out everything else
|
||||
*/
|
||||
for (;l<576;l++) is[ch][l]=0;
|
||||
return 1;
|
||||
}
|
||||
259
dll/amp/huffman.h
Normal file
259
dll/amp/huffman.h
Normal file
@@ -0,0 +1,259 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* huffman.h
|
||||
*
|
||||
* Created by: tomislav uzelac Mar 1996
|
||||
* Last edited by: tomislav uzelac Mar 8 97
|
||||
*/
|
||||
|
||||
extern int decode_huffman_data(struct SIDE_INFO *info,int gr,int ch,int ssize);
|
||||
|
||||
extern int non_zero[2];
|
||||
extern int t_linbits[32];
|
||||
|
||||
#ifdef HUFFMAN
|
||||
|
||||
static inline unsigned int viewbits(int n);
|
||||
static inline void sackbits(int n);
|
||||
static inline int huffman_decode(int tbl,int *x,int *y);
|
||||
static inline int _qsign(int x,int *q);
|
||||
int decode_huffman_data(struct SIDE_INFO *info,int gr,int ch,int ssize);
|
||||
|
||||
int non_zero[2]; /* this is 2*bigvalues+4*count1, i guess...*/
|
||||
|
||||
#define N_CUE 16
|
||||
#define NC_O 4
|
||||
|
||||
int t_linbits[32]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13};
|
||||
|
||||
/* these are the huffman tables, rearranged for lookup
|
||||
*/
|
||||
unsigned int h0[1]={0x0};
|
||||
unsigned int h1[4]={0x311, 0x20000301, 0x40000210, 0x80000100};
|
||||
unsigned int h2[9]={0x622, 0x4000602, 0x8000512, 0x10000521, 0x18000520, 0x20000311, 0x40000301, 0x60000310,
|
||||
0x80000100};
|
||||
unsigned int h3[9]={ 0x622, 0x4000602, 0x8000512, 0x10000521, 0x18000520, 0x20000310, 0x40000211, 0x80000201,
|
||||
0xc0000200};
|
||||
unsigned int h5[16]={0x833, 0x1000823, 0x2000732, 0x4000631, 0x8000713, 0xa000703, 0xc000730, 0xe000722,
|
||||
0x10000612, 0x14000621, 0x18000602, 0x1c000620, 0x20000311, 0x40000301, 0x60000310, 0x80000100};
|
||||
unsigned int h6[16]={0x733, 0x2000703, 0x4000623, 0x8000632, 0xc000630, 0x10000513, 0x18000531, 0x20000522,
|
||||
0x28000502, 0x30000412, 0x40000421, 0x50000420, 0x60000301, 0x80000211, 0xc0000310, 0xe0000300};
|
||||
unsigned int h7[36]={ 0xa55, 0x400a45, 0x800a54, 0xc00a53, 0x1000935, 0x1800944, 0x2000925, 0x2800952,
|
||||
0x3000815, 0x4000851, 0x5000905, 0x5800934, 0x6000850, 0x7000943, 0x7800933, 0x8000824,
|
||||
0x9000842, 0xa000714, 0xc000741, 0xe000740, 0x10000804, 0x11000823, 0x12000832, 0x13000803,
|
||||
0x14000713, 0x16000731, 0x18000730, 0x1a000722, 0x1c000612, 0x20000521, 0x28000602, 0x2c000620,
|
||||
0x30000411, 0x40000301, 0x60000310, 0x80000100};
|
||||
unsigned int h8[36]={0xb55, 0x200b54, 0x400a45, 0x800953, 0x1000a35, 0x1400a44, 0x1800925, 0x2000952,
|
||||
0x2800905, 0x3000815, 0x4000851, 0x5000934, 0x5800943, 0x6000950, 0x6800933, 0x7000824,
|
||||
0x8000842, 0x9000814, 0xa000741, 0xc000804, 0xd000840, 0xe000823, 0xf000832, 0x10000813,
|
||||
0x11000831, 0x12000803, 0x13000830, 0x14000622, 0x18000602, 0x1c000620, 0x20000412, 0x30000421,
|
||||
0x40000211, 0x80000301, 0xa0000310, 0xc0000200};
|
||||
unsigned int h9[36]={ 0x955, 0x800945, 0x1000835, 0x2000853, 0x3000954, 0x3800905, 0x4000844, 0x5000825,
|
||||
0x6000852, 0x7000815, 0x8000751, 0xa000734, 0xc000743, 0xe000850, 0xf000804, 0x10000724,
|
||||
0x12000742, 0x14000733, 0x16000740, 0x18000614, 0x1c000641, 0x20000623, 0x24000632, 0x28000513,
|
||||
0x30000531, 0x38000603, 0x3c000630, 0x40000522, 0x48000502, 0x50000412, 0x60000421, 0x70000420,
|
||||
0x80000311, 0xa0000301, 0xc0000310, 0xe0000300};
|
||||
unsigned int h10[64]={ 0xb77, 0x200b67, 0x400b76, 0x600b57, 0x800b75, 0xa00b66, 0xc00a47, 0x1000a74,
|
||||
0x1400a56, 0x1800a65, 0x1c00a37, 0x2000a73, 0x2400a46, 0x2800b55, 0x2a00b54, 0x2c00a63,
|
||||
0x3000927, 0x3800972, 0x4000a64, 0x4400a07, 0x4800970, 0x5000962, 0x5800a45, 0x5c00a35,
|
||||
0x6000906, 0x6800a53, 0x6c00a44, 0x7000817, 0x8000871, 0x9000936, 0x9800926, 0xa000a25,
|
||||
0xa400a52, 0xa800915, 0xb000951, 0xb800a34, 0xbc00a43, 0xc000816, 0xd000861, 0xe000860,
|
||||
0xf000905, 0xf800950, 0x10000924, 0x10800942, 0x11000933, 0x11800904, 0x12000814, 0x13000841,
|
||||
0x14000840, 0x15000823, 0x16000832, 0x17000803, 0x18000713, 0x1a000731, 0x1c000730, 0x1e000722,
|
||||
0x20000612, 0x24000621, 0x28000602, 0x2c000620, 0x30000411, 0x40000301, 0x60000310, 0x80000100};
|
||||
unsigned int h11[64]={ 0xa77, 0x400a67, 0x800a76, 0xc00a75, 0x1000a66, 0x1400a47, 0x1800a74, 0x1c00b57,
|
||||
0x1e00b55, 0x2000a56, 0x2400a65, 0x2800937, 0x3000973, 0x3800946, 0x4000a45, 0x4400a54,
|
||||
0x4800a35, 0x4c00a53, 0x5000827, 0x6000872, 0x7000964, 0x7800907, 0x8000771, 0xa000817,
|
||||
0xb000870, 0xc000836, 0xd000863, 0xe000860, 0xf000944, 0xf800925, 0x10000952, 0x10800905,
|
||||
0x11000815, 0x12000762, 0x14000826, 0x15000806, 0x16000716, 0x18000761, 0x1a000851, 0x1b000834,
|
||||
0x1c000850, 0x1d000943, 0x1d800933, 0x1e000824, 0x1f000842, 0x20000814, 0x21000841, 0x22000804,
|
||||
0x23000840, 0x24000723, 0x26000732, 0x28000613, 0x2c000631, 0x30000703, 0x32000730, 0x34000622,
|
||||
0x38000521, 0x40000412, 0x50000502, 0x58000520, 0x60000311, 0x80000301, 0xa0000310, 0xc0000200};
|
||||
unsigned int h12[64]={ 0xa77, 0x400a67, 0x800976, 0x1000957, 0x1800975, 0x2000966, 0x2800947, 0x3000974,
|
||||
0x3800965, 0x4000856, 0x5000837, 0x6000973, 0x6800955, 0x7000827, 0x8000872, 0x9000846,
|
||||
0xa000864, 0xb000817, 0xc000871, 0xd000907, 0xd800970, 0xe000836, 0xf000863, 0x10000845,
|
||||
0x11000854, 0x12000844, 0x13000906, 0x13800905, 0x14000726, 0x16000762, 0x18000761, 0x1a000816,
|
||||
0x1b000860, 0x1c000835, 0x1d000853, 0x1e000825, 0x1f000852, 0x20000715, 0x22000751, 0x24000734,
|
||||
0x26000743, 0x28000850, 0x29000804, 0x2a000724, 0x2c000742, 0x2e000714, 0x30000633, 0x34000641,
|
||||
0x38000623, 0x3c000632, 0x40000740, 0x42000703, 0x44000630, 0x48000513, 0x50000531, 0x58000522,
|
||||
0x60000412, 0x70000421, 0x80000502, 0x88000520, 0x90000400, 0xa0000311, 0xc0000301, 0xe0000310};
|
||||
unsigned int h13[256]={
|
||||
0x13fe, 0x33fc, 0x52fd, 0x91ed, 0x110ff, 0x210ef, 0x310df, 0x410ee,
|
||||
0x510cf, 0x610de, 0x710bf, 0x810fb, 0x910ce, 0xa10dc, 0xb11af, 0xb91e9,
|
||||
0xc0fec, 0xe0fdd, 0x1010fa, 0x1110cd, 0x120fbe, 0x140feb, 0x160f9f, 0x180ff9,
|
||||
0x1a0fea, 0x1c0fbd, 0x1e0fdb, 0x200f8f, 0x220ff8, 0x240fcc, 0x2610ae, 0x27109e,
|
||||
0x280f8e, 0x2a107f, 0x2b107e, 0x2c0ef7, 0x300eda, 0x340fad, 0x360fbc, 0x380fcb,
|
||||
0x3a0ff6, 0x3c0e6f, 0x400ee8, 0x440e5f, 0x480e9d, 0x4c0ed9, 0x500ef5, 0x540ee7,
|
||||
0x580eac, 0x5c0ebb, 0x600e4f, 0x640ef4, 0x680fca, 0x6a0fe6, 0x6c0ef3, 0x700d3f,
|
||||
0x780e8d, 0x7c0ed8, 0x800d2f, 0x880df2, 0x900e6e, 0x940e9c, 0x980d0f, 0xa00ec9,
|
||||
0xa40e5e, 0xa80dab, 0xb00e7d, 0xb40ed7, 0xb80d4e, 0xc00ec8, 0xc40ed6, 0xc80d3e,
|
||||
0xd00db9, 0xd80e9b, 0xdc0eaa, 0xe00c1f, 0xf00cf1, 0x1000cf0, 0x1100dba, 0x1180de5,
|
||||
0x1200de4, 0x1280d8c, 0x1300d6d, 0x1380de3, 0x1400ce2, 0x1500d2e, 0x1580d0e, 0x1600c1e,
|
||||
0x1700ce1, 0x1800de0, 0x1880d5d, 0x1900dd5, 0x1980d7c, 0x1a00dc7, 0x1a80d4d, 0x1b00d8b,
|
||||
0x1b80db8, 0x1c00dd4, 0x1c80d9a, 0x1d00da9, 0x1d80d6c, 0x1e00cc6, 0x1f00c3d, 0x2000dd3,
|
||||
0x2080d7b, 0x2100c2d, 0x2200cd2, 0x2300c1d, 0x2400cb7, 0x2500d5c, 0x2580dc5, 0x2600d99,
|
||||
0x2680d7a, 0x2700cc3, 0x2800da7, 0x2880d97, 0x2900c4b, 0x2a00bd1, 0x2c00c0d, 0x2d00cd0,
|
||||
0x2e00c8a, 0x2f00ca8, 0x3000c4c, 0x3100cc4, 0x3200c6b, 0x3300cb6, 0x3400b3c, 0x3600b2c,
|
||||
0x3800bc2, 0x3a00b5b, 0x3c00cb5, 0x3d00c89, 0x3e00b1c, 0x4000bc1, 0x4200c98, 0x4300c0c,
|
||||
0x4400bc0, 0x4600cb4, 0x4700c6a, 0x4800ca6, 0x4900c79, 0x4a00b3b, 0x4c00bb3, 0x4e00c88,
|
||||
0x4f00c5a, 0x5000b2b, 0x5200ca5, 0x5300c69, 0x5400ba4, 0x5600c78, 0x5700c87, 0x5800b94,
|
||||
0x5a00c77, 0x5b00c76, 0x5c00ab2, 0x6000a1b, 0x6400ab1, 0x6800b0b, 0x6a00bb0, 0x6c00b96,
|
||||
0x6e00b4a, 0x7000b3a, 0x7200ba3, 0x7400b59, 0x7600b95, 0x7800a2a, 0x7c00aa2, 0x8000a1a,
|
||||
0x8400aa1, 0x8800b0a, 0x8a00b68, 0x8c00aa0, 0x9000b86, 0x9200b49, 0x9400a93, 0x9800b39,
|
||||
0x9a00b58, 0x9c00b85, 0x9e00b67, 0xa000a29, 0xa400a92, 0xa800b57, 0xaa00b75, 0xac00a38,
|
||||
0xb000a83, 0xb400b66, 0xb600b47, 0xb800b74, 0xba00b56, 0xbc00b65, 0xbe00b73, 0xc000919,
|
||||
0xc800991, 0xd000a09, 0xd400a90, 0xd800a48, 0xdc00a84, 0xe000a72, 0xe400b46, 0xe600b64,
|
||||
0xe800928, 0xf000982, 0xf800918, 0x10000a37, 0x10400a27, 0x10800917, 0x11000971, 0x11800a55,
|
||||
0x11c00a07, 0x12000a70, 0x12400a36, 0x12800a63, 0x12c00a45, 0x13000a54, 0x13400a26, 0x13800a62,
|
||||
0x13c00a35, 0x14000881, 0x15000908, 0x15800980, 0x16000916, 0x16800961, 0x17000906, 0x17800960,
|
||||
0x18000a53, 0x18400a44, 0x18800925, 0x19000952, 0x19800905, 0x1a000815, 0x1b000851, 0x1c000934,
|
||||
0x1c800943, 0x1d000950, 0x1d800924, 0x1e000942, 0x1e800933, 0x1f000814, 0x20000741, 0x22000804,
|
||||
0x23000840, 0x24000823, 0x25000832, 0x26000713, 0x28000731, 0x2a000703, 0x2c000730, 0x2e000722,
|
||||
0x30000612, 0x34000621, 0x38000602, 0x3c000620, 0x40000411, 0x50000401, 0x60000310, 0x80000100};
|
||||
unsigned int h15[256]={ 0xdff, 0x80def, 0x100dfe, 0x180ddf, 0x200cee, 0x300dfd, 0x380dcf, 0x400dfc,
|
||||
0x480dde, 0x500ded, 0x580dbf, 0x600cfb, 0x700dce, 0x780dec, 0x800cdd, 0x900caf,
|
||||
0xa00cfa, 0xb00cbe, 0xc00ceb, 0xd00ccd, 0xe00cdc, 0xf00c9f, 0x1000cf9, 0x1100cea,
|
||||
0x1200cbd, 0x1300cdb, 0x1400c8f, 0x1500cf8, 0x1600ccc, 0x1700c9e, 0x1800ce9, 0x1900c7f,
|
||||
0x1a00cf7, 0x1b00cad, 0x1c00cda, 0x1d00cbc, 0x1e00c6f, 0x1f00dae, 0x1f80d0f, 0x2000bcb,
|
||||
0x2200bf6, 0x2400c8e, 0x2500ce8, 0x2600c5f, 0x2700c9d, 0x2800bf5, 0x2a00b7e, 0x2c00be7,
|
||||
0x2e00bac, 0x3000bca, 0x3200bbb, 0x3400cd9, 0x3500c8d, 0x3600b4f, 0x3800bf4, 0x3a00b3f,
|
||||
0x3c00bf3, 0x3e00bd8, 0x4000be6, 0x4200b2f, 0x4400bf2, 0x4600c6e, 0x4700cf0, 0x4800b1f,
|
||||
0x4a00bf1, 0x4c00b9c, 0x4e00bc9, 0x5000b5e, 0x5200bab, 0x5400bba, 0x5600be5, 0x5800b7d,
|
||||
0x5a00bd7, 0x5c00b4e, 0x5e00be4, 0x6000b8c, 0x6200bc8, 0x6400b3e, 0x6600b6d, 0x6800bd6,
|
||||
0x6a00be3, 0x6c00b9b, 0x6e00bb9, 0x7000b2e, 0x7200baa, 0x7400be2, 0x7600b1e, 0x7800be1,
|
||||
0x7a00c0e, 0x7b00ce0, 0x7c00b5d, 0x7e00bd5, 0x8000b7c, 0x8200bc7, 0x8400b4d, 0x8600b8b,
|
||||
0x8800ad4, 0x8c00bb8, 0x8e00b9a, 0x9000ba9, 0x9200b6c, 0x9400bc6, 0x9600b3d, 0x9800ad3,
|
||||
0x9c00ad2, 0xa000b2d, 0xa200b0d, 0xa400a1d, 0xa800a7b, 0xac00ab7, 0xb000ad1, 0xb400b5c,
|
||||
0xb600bd0, 0xb800ac5, 0xbc00a8a, 0xc000aa8, 0xc400a4c, 0xc800ac4, 0xcc00a6b, 0xd000ab6,
|
||||
0xd400b99, 0xd600b0c, 0xd800a3c, 0xdc00ac3, 0xe000a7a, 0xe400aa7, 0xe800aa6, 0xec00bc0,
|
||||
0xee00b0b, 0xf0009c2, 0xf800a2c, 0xfc00a5b, 0x10000ab5, 0x10400a1c, 0x10800a89, 0x10c00a98,
|
||||
0x11000ac1, 0x11400a4b, 0x11800ab4, 0x11c00a6a, 0x12000a3b, 0x12400a79, 0x128009b3, 0x13000a97,
|
||||
0x13400a88, 0x13800a2b, 0x13c00a5a, 0x140009b2, 0x14800aa5, 0x14c00a1b, 0x150009b1, 0x15800ab0,
|
||||
0x15c00a69, 0x16000a96, 0x16400a4a, 0x16800aa4, 0x16c00a78, 0x17000a87, 0x17400a3a, 0x178009a3,
|
||||
0x18000959, 0x18800995, 0x1900092a, 0x198009a2, 0x1a00091a, 0x1a8009a1, 0x1b000a0a, 0x1b400aa0,
|
||||
0x1b800968, 0x1c000986, 0x1c800949, 0x1d000994, 0x1d800939, 0x1e000993, 0x1e800a77, 0x1ec00a09,
|
||||
0x1f000958, 0x1f800985, 0x20000929, 0x20800967, 0x21000976, 0x21800992, 0x22000891, 0x23000919,
|
||||
0x23800990, 0x24000948, 0x24800984, 0x25000957, 0x25800975, 0x26000938, 0x26800983, 0x27000966,
|
||||
0x27800947, 0x28000828, 0x29000882, 0x2a000818, 0x2b000881, 0x2c000974, 0x2c800908, 0x2d000980,
|
||||
0x2d800956, 0x2e000965, 0x2e800937, 0x2f000973, 0x2f800946, 0x30000827, 0x31000872, 0x32000864,
|
||||
0x33000817, 0x34000855, 0x35000871, 0x36000907, 0x36800970, 0x37000836, 0x38000863, 0x39000845,
|
||||
0x3a000854, 0x3b000826, 0x3c000862, 0x3d000816, 0x3e000906, 0x3e800960, 0x3f000835, 0x40000761,
|
||||
0x42000853, 0x43000844, 0x44000725, 0x46000752, 0x48000715, 0x4a000751, 0x4c000805, 0x4d000850,
|
||||
0x4e000734, 0x50000743, 0x52000724, 0x54000742, 0x56000733, 0x58000641, 0x5c000714, 0x5e000704,
|
||||
0x60000623, 0x64000632, 0x68000740, 0x6a000703, 0x6c000613, 0x70000631, 0x74000630, 0x78000522,
|
||||
0x80000512, 0x88000521, 0x90000502, 0x98000520, 0xa0000311, 0xc0000401, 0xd0000410, 0xe0000300};
|
||||
unsigned int h16[256]={ 0xbef, 0x200bfe, 0x400bdf, 0x600bfd, 0x800bcf, 0xa00bfc, 0xc00bbf, 0xe00bfb,
|
||||
0x1000aaf, 0x1400bfa, 0x1600b9f, 0x1800bf9, 0x1a00bf8, 0x1c00a8f, 0x2000a7f, 0x2400af7,
|
||||
0x2800a6f, 0x2c00af6, 0x30008ff, 0x4000a5f, 0x4400af5, 0x480094f, 0x50009f4, 0x58009f3,
|
||||
0x60009f0, 0x6800a3f, 0x6c010ce, 0x6c111ec, 0x6c191dd, 0x6c20fde, 0x6c40fe9, 0x6c610ea,
|
||||
0x6c710d9, 0x6c80eee, 0x6cc0fed, 0x6ce0feb, 0x6d00ebe, 0x6d40ecd, 0x6d80fdc, 0x6da0fdb,
|
||||
0x6dc0eae, 0x6e00ecc, 0x6e40fad, 0x6e60fda, 0x6e80f7e, 0x6ea0fac, 0x6ec0eca, 0x6f00fc9,
|
||||
0x6f20f7d, 0x6f40e5e, 0x6f80dbd, 0x70008f2, 0x800092f, 0x880090f, 0x900081f, 0xa0008f1,
|
||||
0xb000d9e, 0xb080ebc, 0xb0c0ecb, 0xb100e8e, 0xb140ee8, 0xb180e9d, 0xb1c0ee7, 0xb200ebb,
|
||||
0xb240e8d, 0xb280ed8, 0xb2c0e6e, 0xb300de6, 0xb380d9c, 0xb400eab, 0xb440eba, 0xb480ee5,
|
||||
0xb4c0ed7, 0xb500d4e, 0xb580ee4, 0xb5c0e8c, 0xb600dc8, 0xb680d3e, 0xb700d6d, 0xb780ed6,
|
||||
0xb7c0e9b, 0xb800eb9, 0xb840eaa, 0xb880de1, 0xb900dd4, 0xb980eb8, 0xb9c0ea9, 0xba00d7b,
|
||||
0xba80eb7, 0xbac0ed0, 0xbb00ce3, 0xbc00d0e, 0xbc80de0, 0xbd00d5d, 0xbd80dd5, 0xbe00d7c,
|
||||
0xbe80dc7, 0xbf00d4d, 0xbf80d8b, 0xc000d9a, 0xc080d6c, 0xc100dc6, 0xc180d3d, 0xc200d5c,
|
||||
0xc280dc5, 0xc300c0d, 0xc400d8a, 0xc480da8, 0xc500d99, 0xc580d4c, 0xc600db6, 0xc680d7a,
|
||||
0xc700c3c, 0xc800d5b, 0xc880d89, 0xc900c1c, 0xca00cc0, 0xcb00d98, 0xcb80d79, 0xcc00be2,
|
||||
0xce00c2e, 0xcf00c1e, 0xd000cd3, 0xd100c2d, 0xd200cd2, 0xd300cd1, 0xd400c3b, 0xd500d97,
|
||||
0xd580d88, 0xd600b1d, 0xd800cc4, 0xd900c6b, 0xda00cc3, 0xdb00ca7, 0xdc00b2c, 0xde00cc2,
|
||||
0xdf00cb5, 0xe000cc1, 0xe100c0c, 0xe200c4b, 0xe300cb4, 0xe400c6a, 0xe500ca6, 0xe600bb3,
|
||||
0xe800c5a, 0xe900ca5, 0xea00b2b, 0xec00bb2, 0xee00b1b, 0xf000bb1, 0xf200c0b, 0xf300cb0,
|
||||
0xf400c69, 0xf500c96, 0xf600c4a, 0xf700ca4, 0xf800c78, 0xf900c87, 0xfa00ba3, 0xfc00c3a,
|
||||
0xfd00c59, 0xfe00b2a, 0x10000c95, 0x10100c68, 0x10200ba1, 0x10400c86, 0x10500c77, 0x10600b94,
|
||||
0x10800c49, 0x10900c57, 0x10a00b67, 0x10c00aa2, 0x11000a1a, 0x11400b0a, 0x11600ba0, 0x11800b39,
|
||||
0x11a00b93, 0x11c00b58, 0x11e00b85, 0x12000a29, 0x12400a92, 0x12800b76, 0x12a00b09, 0x12c00a19,
|
||||
0x13000a91, 0x13400b90, 0x13600b48, 0x13800b84, 0x13a00b75, 0x13c00b38, 0x13e00b83, 0x14000b66,
|
||||
0x14200b28, 0x14400a82, 0x14800b47, 0x14a00b74, 0x14c00a18, 0x15000a81, 0x15400a80, 0x15800b08,
|
||||
0x15a00b56, 0x15c00a37, 0x16000a73, 0x16400b65, 0x16600b46, 0x16800a27, 0x16c00a72, 0x17000b64,
|
||||
0x17200b55, 0x17400a07, 0x17800917, 0x18000971, 0x18800a70, 0x18c00a36, 0x19000a63, 0x19400a45,
|
||||
0x19800a54, 0x19c00a26, 0x1a000962, 0x1a800916, 0x1b000961, 0x1b800a06, 0x1bc00a60, 0x1c000953,
|
||||
0x1c800a35, 0x1cc00a44, 0x1d000925, 0x1d800952, 0x1e000851, 0x1f000915, 0x1f800905, 0x20000934,
|
||||
0x20800943, 0x21000950, 0x21800924, 0x22000942, 0x22800933, 0x23000814, 0x24000841, 0x25000904,
|
||||
0x25800940, 0x26000823, 0x27000832, 0x28000713, 0x2a000731, 0x2c000803, 0x2d000830, 0x2e000722,
|
||||
0x30000612, 0x34000621, 0x38000602, 0x3c000620, 0x40000411, 0x50000401, 0x60000310, 0x80000100};
|
||||
unsigned int h24[256]={ 0x8ef, 0x10008fe, 0x20008df, 0x30008fd, 0x40008cf, 0x50008fc, 0x60008bf, 0x70008fb,
|
||||
0x80007fa, 0xa0008af, 0xb00089f, 0xc0007f9, 0xe0007f8, 0x1000088f, 0x1100087f, 0x120007f7,
|
||||
0x1400076f, 0x160007f6, 0x1800075f, 0x1a0007f5, 0x1c00074f, 0x1e0007f4, 0x2000073f, 0x220007f3,
|
||||
0x2400072f, 0x260007f2, 0x280007f1, 0x2a00081f, 0x2b0008f0, 0x2c00090f, 0x2c800bee, 0x2ca00bde,
|
||||
0x2cc00bed, 0x2ce00bce, 0x2d000bec, 0x2d200bdd, 0x2d400bbe, 0x2d600beb, 0x2d800bcd, 0x2da00bdc,
|
||||
0x2dc00bae, 0x2de00bea, 0x2e000bbd, 0x2e200bdb, 0x2e400bcc, 0x2e600b9e, 0x2e800be9, 0x2ea00bad,
|
||||
0x2ec00bda, 0x2ee00bbc, 0x2f000bcb, 0x2f200b8e, 0x2f400be8, 0x2f600b9d, 0x2f800bd9, 0x2fa00b7e,
|
||||
0x2fc00be7, 0x2fe00bac, 0x300004ff, 0x40000bca, 0x40200bbb, 0x40400b8d, 0x40600bd8, 0x40800c0e,
|
||||
0x40900ce0, 0x40a00b0d, 0x40c00ae6, 0x41000b6e, 0x41200b9c, 0x41400ac9, 0x41800a5e, 0x41c00aba,
|
||||
0x42000ae5, 0x42400bab, 0x42600b7d, 0x42800ad7, 0x42c00ae4, 0x43000a8c, 0x43400ac8, 0x43800b4e,
|
||||
0x43a00b2e, 0x43c00a3e, 0x44000a6d, 0x44400ad6, 0x44800ae3, 0x44c00a9b, 0x45000ab9, 0x45400aaa,
|
||||
0x45800ae2, 0x45c00a1e, 0x46000ae1, 0x46400a5d, 0x46800ad5, 0x46c00a7c, 0x47000ac7, 0x47400a4d,
|
||||
0x47800a8b, 0x47c00ab8, 0x48000ad4, 0x48400a9a, 0x48800aa9, 0x48c00a6c, 0x49000ac6, 0x49400a3d,
|
||||
0x49800ad3, 0x49c00a2d, 0x4a000ad2, 0x4a400a1d, 0x4a800a7b, 0x4ac00ab7, 0x4b000ad1, 0x4b400a5c,
|
||||
0x4b800ac5, 0x4bc00a8a, 0x4c000aa8, 0x4c400a99, 0x4c800a4c, 0x4cc00ac4, 0x4d000a6b, 0x4d400ab6,
|
||||
0x4d800bd0, 0x4da00b0c, 0x4dc00a3c, 0x4e000ac3, 0x4e400a7a, 0x4e800aa7, 0x4ec00a2c, 0x4f000ac2,
|
||||
0x4f400a5b, 0x4f800ab5, 0x4fc00a1c, 0x50000a89, 0x50400a98, 0x50800ac1, 0x50c00a4b, 0x51000bc0,
|
||||
0x51200b0b, 0x51400a3b, 0x51800bb0, 0x51a00b0a, 0x51c00a1a, 0x520009b4, 0x52800a6a, 0x52c00aa6,
|
||||
0x53000a79, 0x53400a97, 0x53800ba0, 0x53a00b09, 0x53c00a90, 0x540009b3, 0x54800988, 0x55000a2b,
|
||||
0x55400a5a, 0x558009b2, 0x56000aa5, 0x56400a1b, 0x56800ab1, 0x56c00a69, 0x57000996, 0x578009a4,
|
||||
0x58000a4a, 0x58400a78, 0x58800987, 0x5900093a, 0x598009a3, 0x5a000959, 0x5a800995, 0x5b00092a,
|
||||
0x5b8009a2, 0x5c0009a1, 0x5c800968, 0x5d000986, 0x5d800977, 0x5e000949, 0x5e800994, 0x5f000939,
|
||||
0x5f800993, 0x60000958, 0x60800985, 0x61000929, 0x61800967, 0x62000976, 0x62800992, 0x63000919,
|
||||
0x63800991, 0x64000948, 0x64800984, 0x65000957, 0x65800975, 0x66000938, 0x66800983, 0x67000966,
|
||||
0x67800928, 0x68000982, 0x68800918, 0x69000947, 0x69800974, 0x6a000981, 0x6a800a08, 0x6ac00a80,
|
||||
0x6b000956, 0x6b800965, 0x6c000917, 0x6c800a07, 0x6cc00a70, 0x6d000873, 0x6e000937, 0x6e800927,
|
||||
0x6f000872, 0x70000846, 0x71000864, 0x72000855, 0x73000871, 0x74000836, 0x75000863, 0x76000845,
|
||||
0x77000854, 0x78000826, 0x79000862, 0x7a000816, 0x7b000861, 0x7c000906, 0x7c800960, 0x7d000835,
|
||||
0x7e000853, 0x7f000844, 0x80000825, 0x81000852, 0x82000815, 0x83000905, 0x83800950, 0x84000751,
|
||||
0x86000834, 0x87000843, 0x88000724, 0x8a000742, 0x8c000733, 0x8e000714, 0x90000741, 0x92000804,
|
||||
0x93000840, 0x94000723, 0x96000732, 0x98000613, 0x9c000631, 0xa0000703, 0xa2000730, 0xa4000622,
|
||||
0xa8000512, 0xb0000521, 0xb8000602, 0xbc000620, 0xc0000411, 0xd0000401, 0xe0000410, 0xf0000400};
|
||||
unsigned int hA[16]={ 0x6b0, 0x40006f0, 0x80006d0, 0xc0006e0, 0x10000670, 0x14000650, 0x18000590, 0x20000560,
|
||||
0x28000530, 0x300005a0, 0x380005c0, 0x40000420, 0x50000410, 0x60000440, 0x70000480, 0x80000100};
|
||||
unsigned int hB[16]={ 0x4f0, 0x100004e0, 0x200004d0, 0x300004c0, 0x400004b0, 0x500004a0, 0x60000490, 0x70000480,
|
||||
0x80000470, 0x90000460, 0xa0000450, 0xb0000440, 0xc0000430, 0xd0000420, 0xe0000410, 0xf0000400};
|
||||
|
||||
/* now the cues, remember to change these tables if you change N_CUE
|
||||
*/
|
||||
unsigned char h_cue[34][N_CUE]={
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3},
|
||||
{0,3,5,5,6,6,7,7,8,8,8,8,8,8,8,8},
|
||||
{0,3,5,5,6,6,6,6,7,7,7,7,8,8,8,8},
|
||||
{0,8,12,12,13,13,14,14,15,15,15,15,15,15,15,15},
|
||||
{0,8,12,12,13,13,14,14,15,15,15,15,15,15,15,15},
|
||||
{0,5,7,9,10,11,12,12,13,13,13,13,14,14,15,15},
|
||||
{0,20,29,32,33,33,34,34,35,35,35,35,35,35,35,35},
|
||||
{0,23,30,31,32,32,32,32,33,33,34,34,35,35,35,35},
|
||||
{0,15,21,24,27,29,30,31,32,32,33,33,34,34,35,35},
|
||||
{0,42,56,60,61,61,62,62,63,63,63,63,63,63,63,63},
|
||||
{0,30,45,53,57,58,60,60,61,61,62,62,63,63,63,63},
|
||||
{0,23,37,46,50,54,56,57,58,60,61,61,62,62,63,63},
|
||||
{0,203,238,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,132,178,205,223,233,240,245,248,250,252,252,253,254,255,255},
|
||||
{0,132,178,205,223,233,240,245,248,250,252,252,253,254,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,162,231,248,252,253,254,254,255,255,255,255,255,255,255,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,13,22,58,59,131,177,209,226,238,245,249,252,253,254,255},
|
||||
{0,4,7,9,11,12,13,14,15,15,15,15,15,15,15,15},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
|
||||
};
|
||||
|
||||
/* h4->h5, h14->h15 as suggested by Fraunhofer
|
||||
* tomislav Aug 21 1997
|
||||
*/
|
||||
unsigned int *tables[34]={h0,h1,h2,h3,h5,h5,h6,h7,h8,h9,h10,h11,h12,h13,h15,h15,
|
||||
h16,h16,h16,h16,h16,h16,h16,h16,h24,h24,h24,h24,h24,h24,h24,h24,hA,hB};
|
||||
#endif /* HUFFMAN */
|
||||
321
dll/amp/layer2.c
Normal file
321
dll/amp/layer2.c
Normal file
@@ -0,0 +1,321 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* layer2.c MPEG audio layer2 support
|
||||
*
|
||||
* Created by: Tomislav Uzelac Mar 1996
|
||||
* merged with amp, May 19 1997
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
#include "transform.h"
|
||||
|
||||
#define LAYER2
|
||||
#include "layer2.h"
|
||||
|
||||
int layer2_frame(struct AUDIO_HEADER *header,int cnt)
|
||||
{
|
||||
int i,s,sb,ch,gr,bitrate,bound = 0;
|
||||
char (*nbal)[] = &t_nbal0,(*bit_alloc_index)[][16] = &t_alloc0;
|
||||
|
||||
unsigned char allocation[2][32];
|
||||
unsigned char scfsi[2][32];
|
||||
float scalefactor[2][32][3];
|
||||
float subband_sample[2][32][36];
|
||||
int sblimit = 0,nlevels,grouping;
|
||||
|
||||
float c,d;
|
||||
int no_of_bits,mpi;
|
||||
unsigned short sb_sample_buf[3];
|
||||
|
||||
int hsize,fs,mean_frame_size;
|
||||
|
||||
hsize=4;
|
||||
if (header->protection_bit==0) hsize+=2;
|
||||
|
||||
bitrate=t_bitrate[header->ID][3-header->layer][header->bitrate_index];
|
||||
fs=t_sampling_frequency[header->ID][header->sampling_frequency];
|
||||
if (header->ID) mean_frame_size=144000*bitrate/fs;
|
||||
else mean_frame_size=72000*bitrate/fs;
|
||||
|
||||
/* layers 1 and 2 do not have a 'bit reservoir'
|
||||
*/
|
||||
append=data=0;
|
||||
|
||||
fillbfr(mean_frame_size + header->padding_bit - hsize);
|
||||
|
||||
switch (header->mode)
|
||||
{
|
||||
case 0 :
|
||||
case 2 : nch=2; bound=32; bitrate=bitrate/2;
|
||||
break;
|
||||
case 3 : nch=1; bound=32;
|
||||
break;
|
||||
case 1 : nch=2; bitrate=bitrate/2; bound=(header->mode_extension+1)*4;
|
||||
}
|
||||
|
||||
if (header->ID==1) switch (header->sampling_frequency) {
|
||||
case 0 : switch (bitrate) /* 0 = 44.1 kHz */
|
||||
{
|
||||
case 56 :
|
||||
case 64 :
|
||||
case 80 : bit_alloc_index=&t_alloc0;
|
||||
nbal=&t_nbal0;
|
||||
sblimit=27;
|
||||
break;
|
||||
case 96 :
|
||||
case 112 :
|
||||
case 128 :
|
||||
case 160 :
|
||||
case 192 : bit_alloc_index=&t_alloc1;
|
||||
nbal=&t_nbal1;
|
||||
sblimit=30;
|
||||
break;
|
||||
case 32 :
|
||||
case 48 : bit_alloc_index=&t_alloc2;
|
||||
nbal=&t_nbal2;
|
||||
sblimit=8;
|
||||
break;
|
||||
default : /*printf(" bit alloc info no gud ");*/
|
||||
}
|
||||
break;
|
||||
case 1 : switch (bitrate) /* 1 = 48 kHz */
|
||||
{
|
||||
case 56 :
|
||||
case 64 :
|
||||
case 80 :
|
||||
case 96 :
|
||||
case 112 :
|
||||
case 128 :
|
||||
case 160 :
|
||||
case 192 : bit_alloc_index=&t_alloc0;
|
||||
nbal=&t_nbal0;
|
||||
sblimit=27;
|
||||
break;
|
||||
case 32 :
|
||||
case 48 : bit_alloc_index=&t_alloc2;
|
||||
nbal=&t_nbal2;
|
||||
sblimit=8;
|
||||
break;
|
||||
default : /*printf(" bit alloc info no gud ");*/
|
||||
}
|
||||
break;
|
||||
case 2 : switch (bitrate) /* 2 = 32 kHz */
|
||||
{
|
||||
case 56 :
|
||||
case 64 :
|
||||
case 80 : bit_alloc_index=&t_alloc0;
|
||||
nbal=&t_nbal0;
|
||||
sblimit=27;
|
||||
break;
|
||||
case 96 :
|
||||
case 112 :
|
||||
case 128 :
|
||||
case 160 :
|
||||
case 192 : bit_alloc_index=&t_alloc1;
|
||||
nbal=&t_nbal1;
|
||||
sblimit=30;
|
||||
break;
|
||||
case 32 :
|
||||
case 48 : bit_alloc_index=&t_alloc3;
|
||||
nbal=&t_nbal3;
|
||||
sblimit=12;
|
||||
break;
|
||||
default : /*printf("bit alloc info not ok\n");*/
|
||||
}
|
||||
break;
|
||||
default : /*printf("sampling freq. not ok/n");*/
|
||||
} else {
|
||||
bit_alloc_index=&t_allocMPG2;
|
||||
nbal=&t_nbalMPG2;
|
||||
sblimit=30;
|
||||
}
|
||||
|
||||
/*
|
||||
* bit allocation per subband per channel decoding *****************************
|
||||
*/
|
||||
|
||||
if (bound==32) bound=sblimit; /* bound=32 means there is no intensity stereo */
|
||||
|
||||
for (sb=0;sb<bound;sb++)
|
||||
for (ch=0;ch<nch;ch++)
|
||||
allocation[ch][sb]=getbits((*nbal)[sb]);
|
||||
|
||||
for (sb=bound;sb<sblimit;sb++)
|
||||
allocation[1][sb] = allocation[0][sb] = getbits((*nbal)[sb]);
|
||||
|
||||
|
||||
/*
|
||||
* scfsi ***********************************************************************
|
||||
*/
|
||||
|
||||
for (sb=0;sb<sblimit;sb++)
|
||||
for (ch=0;ch<nch;ch++)
|
||||
if (allocation[ch][sb]!=0) scfsi[ch][sb]=getbits(2);
|
||||
else scfsi[ch][sb]=0;
|
||||
|
||||
/*
|
||||
* scalefactors ****************************************************************
|
||||
*/
|
||||
|
||||
for (sb=0;sb<sblimit;sb++)
|
||||
for (ch=0;ch<nch;ch++)
|
||||
if (allocation[ch][sb]!=0) {
|
||||
scalefactor[ch][sb][0]=t_scalefactor[getbits(6)];
|
||||
switch (scfsi[ch][sb])
|
||||
{
|
||||
case 0: scalefactor[ch][sb][1]=t_scalefactor[getbits(6)];
|
||||
scalefactor[ch][sb][2]=t_scalefactor[getbits(6)];
|
||||
break;
|
||||
case 1: scalefactor[ch][sb][2]=t_scalefactor[getbits(6)];
|
||||
scalefactor[ch][sb][1]=scalefactor[ch][sb][0];
|
||||
break;
|
||||
case 2: scalefactor[ch][sb][1]=scalefactor[ch][sb][0];
|
||||
scalefactor[ch][sb][2]=scalefactor[ch][sb][0];
|
||||
break;
|
||||
case 3: scalefactor[ch][sb][2]=t_scalefactor[getbits(6)];
|
||||
scalefactor[ch][sb][1]=scalefactor[ch][sb][2];
|
||||
}
|
||||
}
|
||||
else scalefactor[ch][sb][0]=scalefactor[ch][sb][1]=\
|
||||
scalefactor[ch][sb][2]=0.0;
|
||||
|
||||
|
||||
/*
|
||||
* samples *********************************************************************
|
||||
*/
|
||||
|
||||
for (gr=0;gr<12;gr++) {
|
||||
/*
|
||||
* normal ********************************
|
||||
*/
|
||||
|
||||
for (sb=0;sb<bound;sb++)
|
||||
for (ch=0;ch<nch;ch++)
|
||||
if (allocation[ch][sb]!=0) {
|
||||
mpi=(*bit_alloc_index)[sb][allocation[ch][sb]];
|
||||
no_of_bits=t_bpc[mpi];
|
||||
c=t_c[mpi];
|
||||
d=t_d[mpi];
|
||||
grouping=t_grouping[mpi];
|
||||
nlevels=t_nlevels[mpi];
|
||||
|
||||
if (grouping) {
|
||||
int samplecode=getbits(no_of_bits);
|
||||
convert_samplecode(samplecode,grouping,sb_sample_buf);
|
||||
|
||||
for (s=0;s<3;s++)
|
||||
subband_sample[ch][sb][3*gr+s]=requantize_sample (sb_sample_buf[s],nlevels,c,d,scalefactor[ch][sb][gr/4]);
|
||||
} else {
|
||||
for (s=0;s<3;s++) sb_sample_buf[s]=getbits(no_of_bits);
|
||||
|
||||
for (s=0;s<3;s++) {
|
||||
/*subband_sample[ch][sb][3*gr+s]=requantize_sample (sb_sample_buf[s],nlevels,c,d,scalefactor[ch][sb][gr/4]);*/
|
||||
subband_sample[ch][sb][3*gr+s]=(t_dd[mpi]+sb_sample_buf[s]*t_nli[mpi])*c*scalefactor[ch][sb][gr>>2];
|
||||
}
|
||||
}
|
||||
} else
|
||||
for (s=0;s<3;s++) subband_sample[ch][sb][3*gr+s]=0;
|
||||
|
||||
|
||||
/*
|
||||
* joint stereo ********************************************
|
||||
*/
|
||||
|
||||
for (sb=bound;sb<sblimit;sb++)
|
||||
if (allocation[0][sb]!=0) {
|
||||
/*ispravka!
|
||||
*/
|
||||
mpi=(*bit_alloc_index)[sb][allocation[0][sb]];
|
||||
no_of_bits=t_bpc[mpi];
|
||||
c=t_c[mpi];
|
||||
d=t_d[mpi];
|
||||
grouping=t_grouping[mpi];
|
||||
nlevels=t_nlevels[mpi];
|
||||
|
||||
if (grouping) {
|
||||
int samplecode=getbits(no_of_bits);
|
||||
convert_samplecode(samplecode,grouping,sb_sample_buf);
|
||||
|
||||
for (s=0;s<3;s++) {
|
||||
subband_sample[0][sb][3*gr+s]=requantize_sample (sb_sample_buf[s],nlevels,c,d,scalefactor[0][sb][gr/4]);
|
||||
subband_sample[1][sb][3*gr+s]=subband_sample[0][sb][3*gr+s];
|
||||
}
|
||||
} else {
|
||||
for (s=0;s<3;s++) sb_sample_buf[s]=getbits(no_of_bits);
|
||||
|
||||
for (s=0;s<3;s++) {
|
||||
subband_sample[0][sb][3*gr+s]=subband_sample[1][sb][3*gr+s]=\
|
||||
(t_dd[mpi]+sb_sample_buf[s]*t_nli[mpi])*c*scalefactor[0][sb][gr>>2];
|
||||
}
|
||||
}
|
||||
|
||||
} else for (s=0;s<3;s++) {
|
||||
subband_sample[0][sb][3*gr+s]=0;
|
||||
subband_sample[1][sb][3*gr+s]=0;
|
||||
}
|
||||
|
||||
/*
|
||||
* the rest *******************************************
|
||||
*/
|
||||
for (sb=sblimit;sb<32;sb++)
|
||||
for (ch=0;ch<nch;ch++)
|
||||
|
||||
for (s=0;s<3;s++) subband_sample[ch][sb][3*gr+s]=0;
|
||||
}
|
||||
|
||||
/*
|
||||
* this is, in fact, horrible, but I had to adjust it to amp/mp3. The hack to make downmixing
|
||||
* work is as ugly as possible.
|
||||
*/
|
||||
|
||||
if (A_DOWNMIX && header->mode!=3) {
|
||||
for (ch=0;ch<nch;ch++)
|
||||
for (sb=0;sb<32;sb++)
|
||||
for (i=0;i<36;i++)
|
||||
subband_sample[0][sb][i]=(subband_sample[0][sb][i]+subband_sample[1][sb][i])*0.5f;
|
||||
nch=1;
|
||||
}
|
||||
|
||||
for (ch=0;ch<nch;ch++) {
|
||||
for (sb=0;sb<32;sb++)
|
||||
for (i=0;i<18;i++) res[sb][i]=subband_sample[ch][sb][i];
|
||||
for (i=0;i<18;i++)
|
||||
poly(ch,i);
|
||||
}
|
||||
printout();
|
||||
for (ch=0;ch<nch;ch++) {
|
||||
for (sb=0;sb<32;sb++)
|
||||
for (i=0;i<18;i++) res[sb][i]=subband_sample[ch][sb][i+18];
|
||||
for (i=0;i<18;i++)
|
||||
poly(ch,i);
|
||||
}
|
||||
printout();
|
||||
|
||||
if (A_DOWNMIX && header->mode!=3) nch=2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
void convert_samplecode(unsigned int samplecode,unsigned int nlevels,unsigned short* sb_sample_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<3;i++) {
|
||||
*sb_sample_buf=samplecode%nlevels;
|
||||
samplecode=samplecode/nlevels;
|
||||
sb_sample_buf++;
|
||||
}
|
||||
}
|
||||
|
||||
float requantize_sample(unsigned short s4,unsigned short nlevels,float c,float d,float factor)
|
||||
{
|
||||
register float s,s2,s3;
|
||||
s3=-1.0+s4*2.0/(nlevels+1);
|
||||
s2=c*(s3+d);
|
||||
s=factor*s2;
|
||||
return s;
|
||||
}
|
||||
190
dll/amp/layer2.h
Normal file
190
dll/amp/layer2.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
/* layer2.h
|
||||
* Tomislav Uzelac - cca. Feb 1996
|
||||
*/
|
||||
|
||||
|
||||
extern int layer2_frame(struct AUDIO_HEADER *header,int cnt);
|
||||
|
||||
#ifdef LAYER2
|
||||
|
||||
int layer2_frame(struct AUDIO_HEADER *header,int cnt);
|
||||
float requantize_sample(unsigned short s4,unsigned short nlevels,float c,float d,float factor);
|
||||
void convert_samplecode(unsigned int samplecode,unsigned int nlevels,unsigned short* sb_sample_buf);
|
||||
|
||||
char t_nbal0[27]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2};
|
||||
char t_nbal1[30]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2};
|
||||
char t_nbal2[8] ={4,4,3,3,3,3,3,3};
|
||||
char t_nbal3[12]={4,4,3,3,3,3,3,3,3,3,3,3};
|
||||
char t_nbalMPG2[30]={4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
|
||||
|
||||
char t_alloc0[27][16] = { /* table B.2a ISO/IEC 11172-3 */
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17}};
|
||||
|
||||
char t_alloc1[30][16] = { /* table B.2b ISO/IEC 11172-3 */
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,3,4,5,6,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17},
|
||||
{0,1,2,17}};
|
||||
|
||||
char t_alloc2[8][16] = { /* table B.2c ISO/IEC 11172-3 */
|
||||
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
|
||||
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127}};
|
||||
|
||||
char t_alloc3[12][16] = { /* table B.2d ISO/IEC 11172-3 */
|
||||
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
|
||||
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127},
|
||||
{0,1,2,4,5,6,7,127}};
|
||||
|
||||
char t_allocMPG2[30][16] = { /* table B.1. ISO/IEC 13818-3 */
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
|
||||
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4,5,6,7,8},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4},
|
||||
{0,1,2,4}};
|
||||
|
||||
double t_scalefactor[64] = {
|
||||
2.00000000000000, 1.58740105196820, 1.25992104989487,
|
||||
1.00000000000000, 0.79370052598410, 0.62996052494744, 0.50000000000000,
|
||||
0.39685026299205, 0.31498026247372, 0.25000000000000, 0.19842513149602,
|
||||
0.15749013123686, 0.12500000000000, 0.09921256574801, 0.07874506561843,
|
||||
0.06250000000000, 0.04960628287401, 0.03937253280921, 0.03125000000000,
|
||||
0.02480314143700, 0.01968626640461, 0.01562500000000, 0.01240157071850,
|
||||
0.00984313320230, 0.00781250000000, 0.00620078535925, 0.00492156660115,
|
||||
0.00390625000000, 0.00310039267963, 0.00246078330058, 0.00195312500000,
|
||||
0.00155019633981, 0.00123039165029, 0.00097656250000, 0.00077509816991,
|
||||
0.00061519582514, 0.00048828125000, 0.00038754908495, 0.00030759791257,
|
||||
0.00024414062500, 0.00019377454248, 0.00015379895629, 0.00012207031250,
|
||||
0.00009688727124, 0.00007689947814, 0.00006103515625, 0.00004844363562,
|
||||
0.00003844973907, 0.00003051757813, 0.00002422181781, 0.00001922486954,
|
||||
0.00001525878906, 0.00001211090890, 0.00000961243477, 0.00000762939453,
|
||||
0.00000605545445, 0.00000480621738, 0.00000381469727, 0.00000302772723,
|
||||
0.00000240310869, 0.00000190734863, 0.00000151386361, 0.00000120155435,
|
||||
1E-20};
|
||||
|
||||
double t_c[18] = { 0,
|
||||
1.33333333333, 1.60000000000, 1.14285714286,
|
||||
1.77777777777, 1.06666666666, 1.03225806452,
|
||||
1.01587301587, 1.00787401575, 1.00392156863,
|
||||
1.00195694716, 1.00097751711, 1.00048851979,
|
||||
1.00024420024, 1.00012208522, 1.00006103888,
|
||||
1.00003051851, 1.00001525902 };
|
||||
|
||||
double t_d[18] = {0,
|
||||
0.500000000, 0.500000000, 0.250000000, 0.500000000,
|
||||
0.125000000, 0.062500000, 0.031250000, 0.015625000,
|
||||
0.007812500, 0.003906250, 0.001953125, 0.0009765625,
|
||||
0.00048828125,0.00024414063,0.00012207031,
|
||||
0.00006103516,0.00003051758 };
|
||||
|
||||
float t_dd[18]={ -1, -0.5, -0.5, -0.75, -0.5, -0.875, -0.9375, -0.96875, -0.984375,
|
||||
-0.992188, -0.996094, -0.998047, -0.999023, -0.999512, -0.999756, -0.999878, -0.999939,
|
||||
-0.999969};
|
||||
|
||||
char t_grouping[18]={0,3,5,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
/*
|
||||
int t_nlevels[18] = {0,3,5,7,9,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
|
||||
*/
|
||||
int t_nlevels[18] = {0,3,7,7,15,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
|
||||
|
||||
|
||||
float t_nli[18]={ 0, 0.5, 0.25, 0.25, 0.125, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625,
|
||||
0.00195313, 0.000976563, 0.000488281, 0.000244141, 0.00012207, 6.10352e-05, 3.05176e-05};
|
||||
|
||||
int t_bpc[18] = {0,5,7,3,10,4,5,6,7,8,9,10,11,12,13,14,15,16};
|
||||
|
||||
#endif /* LAYER2 */
|
||||
197
dll/amp/layer3.c
Normal file
197
dll/amp/layer3.c
Normal file
@@ -0,0 +1,197 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* layer3.c layer3 audio decoding
|
||||
*
|
||||
* Created by: tomislav uzelac Mar 1 97
|
||||
* Last modified by:
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
#include "getdata.h"
|
||||
#include "huffman.h"
|
||||
#include "misc2.h"
|
||||
#include "transform.h"
|
||||
|
||||
#define LAYER3
|
||||
#include "layer3.h"
|
||||
|
||||
/* this function decodes one layer3 audio frame, except for the header decoding
|
||||
* which is done in main() [audio.c]. returns 0 if everything is ok.
|
||||
*/
|
||||
int layer3_frame(struct AUDIO_HEADER *header,int cnt)
|
||||
{
|
||||
static struct SIDE_INFO info;
|
||||
|
||||
int gr,ch,sb,i;
|
||||
int mean_frame_size,bitrate,fs,hsize,ssize;
|
||||
|
||||
/* we need these later, hsize is the size of header+side_info
|
||||
*/
|
||||
if (header->ID)
|
||||
if (header->mode==3) {
|
||||
nch=1;
|
||||
hsize=21;
|
||||
} else {
|
||||
nch=2;
|
||||
hsize=36;
|
||||
}
|
||||
else
|
||||
if (header->mode==3) {
|
||||
nch=1;
|
||||
hsize=13;
|
||||
} else {
|
||||
nch=2;
|
||||
hsize=21;
|
||||
}
|
||||
|
||||
/* crc increases hsize by 2
|
||||
*/
|
||||
if (header->protection_bit==0) hsize+=2;
|
||||
|
||||
|
||||
/* read layer3 specific side_info
|
||||
*/
|
||||
getinfo(header,&info);
|
||||
|
||||
|
||||
/* MPEG2 only has one granule
|
||||
*/
|
||||
bitrate=t_bitrate[header->ID][3-header->layer][header->bitrate_index];
|
||||
fs=t_sampling_frequency[header->ID][header->sampling_frequency];
|
||||
if (header->ID) mean_frame_size=144000*bitrate/fs;
|
||||
else mean_frame_size=72000*bitrate/fs;
|
||||
|
||||
|
||||
/* check if mdb is too big for the first few frames. this means that
|
||||
* a part of the stream could be missing. We must still fill the buffer
|
||||
*
|
||||
* don't forget to (re)initialise bclean_bytes to 0, and f_bdirty to FALSE!!!
|
||||
*/
|
||||
if (f_bdirty)
|
||||
{
|
||||
if (info.main_data_begin > bclean_bytes)
|
||||
{
|
||||
fillbfr(mean_frame_size + header->padding_bit - hsize);
|
||||
bclean_bytes+=mean_frame_size + header->padding_bit - hsize;
|
||||
/* warn(" frame %d discarded, incomplete main_data\n",cnt); */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* re-initialise */
|
||||
f_bdirty=FALSE;
|
||||
bclean_bytes=0;
|
||||
}
|
||||
}
|
||||
/* now update the data 'pointer' (counting in bits) according to
|
||||
* the main_data_begin information
|
||||
*/
|
||||
data = 8 * ((append - info.main_data_begin) & (BUFFER_SIZE-1));
|
||||
|
||||
|
||||
/* read into the buffer all bytes up to the start of next header
|
||||
*/
|
||||
fillbfr(mean_frame_size + header->padding_bit - hsize);
|
||||
|
||||
|
||||
/* these two should go away
|
||||
*/
|
||||
t_l=&t_b8_l[header->ID][header->sampling_frequency][0];
|
||||
t_s=&t_b8_s[header->ID][header->sampling_frequency][0];
|
||||
|
||||
/* decode the scalefactors and huffman data
|
||||
* this part needs to be enhanced for error robustness
|
||||
*/
|
||||
for (gr=0;gr < ((header->ID) ? 2 : 1);gr++) {
|
||||
for (ch=0;ch<nch;ch++) {
|
||||
ssize=decode_scalefactors(&info,header,gr,ch);
|
||||
decode_huffman_data(&info,gr,ch,ssize);
|
||||
}
|
||||
|
||||
/* requantization, stereo processing, reordering(shortbl)
|
||||
*/
|
||||
|
||||
if (A_DOWNMIX && nch==2)
|
||||
requantize_downmix(gr,&info,header);
|
||||
else
|
||||
{
|
||||
if (header->mode!=1 || (header->mode==1 && header->mode_extension==0))
|
||||
{
|
||||
for (ch=0;ch<nch;ch++)
|
||||
requantize_mono(gr,ch,&info,header);
|
||||
}
|
||||
else
|
||||
requantize_ms(gr,&info,header);
|
||||
}
|
||||
/* just which window?
|
||||
*/
|
||||
|
||||
/* this is a very temporary, very ugly hack.
|
||||
*/
|
||||
if (A_DOWNMIX) nch=1;
|
||||
|
||||
for (ch=0; ch < (A_DOWNMIX ? 1:nch) ;ch++) {
|
||||
int win_type; /* same as in the standard, long=0, start=1 ,.... */
|
||||
int window_switching_flag = info.window_switching_flag[gr][ch];
|
||||
int block_type = info.block_type[gr][ch];
|
||||
int mixed_block_flag = info.mixed_block_flag[gr][ch];
|
||||
|
||||
/* antialiasing butterflies
|
||||
*/
|
||||
if (!(window_switching_flag &&
|
||||
block_type==2))
|
||||
alias_reduction(ch);
|
||||
|
||||
if (window_switching_flag &&
|
||||
block_type==2 &&
|
||||
mixed_block_flag)
|
||||
win_type=0;
|
||||
else
|
||||
if (!window_switching_flag) win_type=0;
|
||||
else win_type=block_type;
|
||||
|
||||
/* imdct ...
|
||||
*/
|
||||
for (sb=0;sb<2;sb++)
|
||||
imdct(win_type,sb,ch);
|
||||
|
||||
if (window_switching_flag &&
|
||||
block_type==2 &&
|
||||
mixed_block_flag)
|
||||
win_type=2;
|
||||
|
||||
/* no_of_imdcts tells us how many subbands from the top are all zero
|
||||
* it is set by the requantize functions in misc2.c
|
||||
*/
|
||||
for (sb=2;sb<no_of_imdcts[ch];sb++)
|
||||
imdct(win_type,sb,ch);
|
||||
|
||||
for (;sb<32;sb++)
|
||||
for (i=0;i<18;i++) {
|
||||
res[sb][i]=s[ch][sb][i];
|
||||
s[ch][sb][i]=0.0f;
|
||||
}
|
||||
|
||||
/* polyphase filterbank
|
||||
*/
|
||||
/* if (nch == 2) this was a bug, tomislav */
|
||||
for (i=0;i<18;i++)
|
||||
poly(ch,i);
|
||||
}
|
||||
|
||||
printout();
|
||||
|
||||
/* this is part2 of a particularily ugly hack. this should vanish as soon as nch isn't
|
||||
a global variable anymore
|
||||
*/
|
||||
if (A_DOWNMIX && header->mode!=3) nch=2;
|
||||
|
||||
} /* for (gr... */
|
||||
|
||||
/* return status: 0 for ok, errors will be added
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
16
dll/amp/layer3.h
Normal file
16
dll/amp/layer3.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* layer3.h
|
||||
*
|
||||
* Created by: tomislav uzelac Mar 1 97
|
||||
* Last modified by:
|
||||
*/
|
||||
|
||||
extern int layer3_frame(struct AUDIO_HEADER *header,int cnt);
|
||||
|
||||
#ifdef LAYER3
|
||||
|
||||
int layer3_frame(struct AUDIO_HEADER *header,int cnt);
|
||||
|
||||
#endif /* LAYER3 */
|
||||
1105
dll/amp/misc2.c
Normal file
1105
dll/amp/misc2.c
Normal file
File diff suppressed because it is too large
Load Diff
34
dll/amp/misc2.h
Normal file
34
dll/amp/misc2.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* misc2.h
|
||||
*
|
||||
* Created by: tomislav uzelac May 1996
|
||||
* Last modified by: tomislav uzelac Jan 8 1997
|
||||
*/
|
||||
#ifndef _MISC2_H_
|
||||
#define _MISC2_H_
|
||||
void requantize_mono(int, int, struct SIDE_INFO *, struct AUDIO_HEADER *);
|
||||
void requantize_ms(int, struct SIDE_INFO *, struct AUDIO_HEADER *);
|
||||
void requantize_downmix(int, struct SIDE_INFO *, struct AUDIO_HEADER *);
|
||||
|
||||
void alias_reduction(int);
|
||||
void calculate_t43(void);
|
||||
|
||||
extern int no_of_imdcts[];
|
||||
|
||||
#ifdef MISC2
|
||||
|
||||
#define i_sq2 0.707106781188
|
||||
#define IS_ILLEGAL 0xfeed
|
||||
|
||||
static inline float fras_l(int,int,int,int,int);
|
||||
static inline float fras_s(int,int,int,int);
|
||||
static inline float fras2(int,float);
|
||||
static int find_isbound(int isbound[3],int gr,struct SIDE_INFO *info,struct AUDIO_HEADER *header);
|
||||
static inline void stereo_s(int l,float a[2],int pos,int ms_flag,int is_pos,struct AUDIO_HEADER *header);
|
||||
static inline void stereo_l(int l,float a[2],int ms_flag,int is_pos,struct AUDIO_HEADER *header);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
101
dll/amp/position.c
Normal file
101
dll/amp/position.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
/* position.c ffwd/rew within a stream
|
||||
*
|
||||
* Creted by: Tomislav Uzelac, May 10 1997
|
||||
*/
|
||||
#include "amp.h"
|
||||
#include "audio.h"
|
||||
#include "getbits.h"
|
||||
|
||||
#define POSITION
|
||||
#include "position.h"
|
||||
|
||||
/* Returns the number of frames actually skipped, -1 on error.
|
||||
*
|
||||
* Values in header are not changed if retval!=nframes.
|
||||
* This is not necessary because gethdr() doesn't clobber
|
||||
* the contents of header, but I don't want to rely on that.
|
||||
*/
|
||||
int ffwd(struct AUDIO_HEADER *header, int nframes)
|
||||
{
|
||||
int cnt=0,g;
|
||||
int hsize,bitrate,fs,mean_frame_size;
|
||||
struct AUDIO_HEADER tmp;
|
||||
memcpy(&tmp,header,sizeof(tmp));
|
||||
|
||||
while (cnt < nframes) {
|
||||
if (tmp.ID)
|
||||
if (tmp.mode==3) hsize=21;
|
||||
else hsize=36;
|
||||
else
|
||||
if (tmp.mode==3) hsize=13;
|
||||
else hsize=21;
|
||||
if (tmp.protection_bit==0) hsize+=2;
|
||||
if ((g=dummy_getinfo(hsize))) /* dummy_getinfo: reads hsize-4 bytes */
|
||||
switch (g) {
|
||||
case GETHDR_EOF: return cnt;
|
||||
case GETHDR_ERR:
|
||||
default: return -1;
|
||||
}
|
||||
|
||||
bitrate=t_bitrate[tmp.ID][3-tmp.layer][tmp.bitrate_index];
|
||||
fs=t_sampling_frequency[tmp.ID][tmp.sampling_frequency];
|
||||
if (tmp.ID) mean_frame_size=144000*bitrate/fs;
|
||||
else mean_frame_size=72000*bitrate/fs;
|
||||
fillbfr(mean_frame_size + tmp.padding_bit - hsize);
|
||||
|
||||
if ((g=gethdr(&tmp)))
|
||||
switch (g) {
|
||||
case GETHDR_EOF: return cnt;
|
||||
case GETHDR_ERR:
|
||||
default: return -1;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
||||
memcpy(header,&tmp,sizeof(tmp));
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Mostly the same as ffwd. Some streams might be 'tough', i.e.
|
||||
* the ones switching bitrates.
|
||||
*/
|
||||
int rew(struct AUDIO_HEADER *header, int nframes)
|
||||
{
|
||||
int cnt=0;
|
||||
int bitrate,fs,mean_frame_size;
|
||||
struct AUDIO_HEADER tmp;
|
||||
memcpy(&tmp,header,sizeof(tmp));
|
||||
|
||||
while (cnt < nframes) {
|
||||
/* ffwd/rew functions are to be called right after the header has been parsed
|
||||
* so we have to go back one frame + 4 bytes + 1 byte (in case padding was used).
|
||||
*/
|
||||
bitrate=t_bitrate[tmp.ID][3-tmp.layer][tmp.bitrate_index];
|
||||
fs=t_sampling_frequency[tmp.ID][tmp.sampling_frequency];
|
||||
if (tmp.ID) mean_frame_size=144000*bitrate/fs;
|
||||
else mean_frame_size=72000*bitrate/fs;
|
||||
|
||||
if (rewind_stream(mean_frame_size) !=0) {
|
||||
memcpy(header,&tmp,sizeof(tmp));
|
||||
return cnt;
|
||||
}
|
||||
if ((gethdr(&tmp))) return -1;
|
||||
cnt++;
|
||||
}
|
||||
/* We have to make sure that the bit reservoir contains enough data.
|
||||
* Hopefully, layer3_frame will take care of that.
|
||||
*/
|
||||
f_bdirty=TRUE;
|
||||
bclean_bytes=0;
|
||||
|
||||
memcpy(header,&tmp,sizeof(tmp));
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* TODO: after the gethdr function is enhanced with the counter to count
|
||||
* the number of bytes to search for the next syncword, make the call to
|
||||
* gethdr() from rew() have that counter something like (frame_size-1) so
|
||||
* that we don't go back again and again to the same header. (not very important)
|
||||
*/
|
||||
10
dll/amp/position.h
Normal file
10
dll/amp/position.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
extern int ffwd(struct AUDIO_HEADER *header, int nframes);
|
||||
extern int rew(struct AUDIO_HEADER *header, int nframes);
|
||||
|
||||
#ifdef POSITION
|
||||
int ffwd(struct AUDIO_HEADER *header, int nframes);
|
||||
int rew(struct AUDIO_HEADER *header, int nframes);
|
||||
#endif
|
||||
26
dll/amp/proto.h
Normal file
26
dll/amp/proto.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* From: util.c */
|
||||
void die(char *, ...);
|
||||
void warn(char *, ...);
|
||||
void msg(char *, ...);
|
||||
void debugSetup(char *);
|
||||
void debugOptions();
|
||||
|
||||
/* From: audioIO_<OSTYPE>.c */
|
||||
void audioOpen(int frequency, int stereo, int volume);
|
||||
void audioSetVolume(int);
|
||||
void audioFlush();
|
||||
void audioClose();
|
||||
int audioWrite(char *, int);
|
||||
int getAudioFd();
|
||||
void audioBufferOn(int);
|
||||
|
||||
|
||||
/* From: buffer.c */
|
||||
void printout(void);
|
||||
int audioBufferOpen(int, int, int);
|
||||
void audioBufferClose();
|
||||
void audioBufferWrite(char *, int);
|
||||
void audioBufferFlush();
|
||||
|
||||
/* From: audio.c */
|
||||
void displayUsage();
|
||||
1523
dll/amp/transform.c
Normal file
1523
dll/amp/transform.c
Normal file
File diff suppressed because it is too large
Load Diff
168
dll/amp/transform.h
Normal file
168
dll/amp/transform.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
|
||||
*/
|
||||
|
||||
/* transform.h tables galore
|
||||
*
|
||||
* Created by: tomislav uzelac May 1996
|
||||
* Last modified by: tomislav uzelac Mar 1 97
|
||||
*/
|
||||
extern void imdct_init();
|
||||
extern void imdct(int win_type,int sb,int ch);
|
||||
extern void poly(int ch,int i);
|
||||
extern void premultiply();
|
||||
|
||||
extern short sample_buffer[18][32][2];
|
||||
extern float res[32][18];
|
||||
extern float s[2][32][18];
|
||||
|
||||
#ifdef TRANSFORM
|
||||
|
||||
void imdct_init();
|
||||
void imdct(int win_type,int sb,int ch);
|
||||
void poly(int ch,int i);
|
||||
void premultiply();
|
||||
|
||||
short sample_buffer[18][32][2];
|
||||
float s[2][32][18];
|
||||
float res[32][18];
|
||||
float win[4][36];
|
||||
|
||||
static const float t_sin[4][36]={{
|
||||
-0.032160, 0.103553, -0.182543, 0.266729, -0.353554, 0.440377,
|
||||
-0.524563, 0.603553, -0.674947, 0.736575, -0.786566, 0.823400,
|
||||
-0.845957, 0.853554, -0.845957, 0.823399, -0.786566, 0.736575,
|
||||
-0.674947, 0.603553, -0.524564, 0.440378, -0.353553, 0.266729,
|
||||
-0.182544, 0.103553, -0.032160, -0.029469, 0.079459, -0.116293,
|
||||
0.138851, -0.146446, 0.138851, -0.116293, 0.079459, -0.029469
|
||||
},{
|
||||
-0.032160, 0.103553, -0.182543, 0.266729, -0.353554, 0.440377,
|
||||
-0.524563, 0.603553, -0.674947, 0.736575, -0.786566, 0.823400,
|
||||
-0.845957, 0.853554, -0.845957, 0.823399, -0.786566, 0.736575,
|
||||
-0.675590, 0.608761, -0.537300, 0.461749, -0.382683, 0.300706,
|
||||
-0.214588, 0.120590, -0.034606, -0.026554, 0.049950, -0.028251,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
|
||||
},{
|
||||
-0.103553, 0.353554, -0.603553, 0.786566, -0.853554, 0.786566,
|
||||
-0.603553, 0.353553, -0.103553, -0.079459, 0.146446, -0.079459,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
|
||||
},{
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
-0.127432, 0.379410, -0.608182, 0.792598, -0.915976, 0.967944,
|
||||
-0.953717, 0.923880, -0.887011, 0.843391, -0.793353, 0.737277,
|
||||
-0.674947, 0.603553, -0.524564, 0.440378, -0.353553, 0.266729,
|
||||
-0.182544, 0.103553, -0.032160, -0.029469, 0.079459, -0.116293,
|
||||
0.138851, -0.146446, 0.138851, -0.116293, 0.079459, -0.029469
|
||||
}};
|
||||
|
||||
static const float t_2cos[4][18]={
|
||||
{ -0.174311, -0.517638, -0.845237, -1.147153, -1.414214, -1.638304, -1.812616, -1.931852, -1.992389,
|
||||
0.174311, 0.517638, 0.845237, 1.147153, 1.414214, 1.638304, 1.812616, 1.931852, 1.992389},
|
||||
{ -0.174311, -0.517638, -0.845237, -1.147153, -1.414214, -1.638304, -1.812616, -1.931852, -1.992389,
|
||||
0.174311, 0.517638, 0.845237, 1.147153, 1.414214, 1.638304, 1.812616, 1.931852, 1.992389},
|
||||
{ -0.517638, -1.41421, -1.93185, 0.517638, 1.41421, 1.93185,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{ -0.174311, -0.517638, -0.845237, -1.147153, -1.414214, -1.638304, -1.812616, -1.931852, -1.992389,
|
||||
0.174311, 0.517638, 0.845237, 1.147153, 1.414214, 1.638304, 1.812616, 1.931852, 1.992389}
|
||||
};
|
||||
|
||||
static const float b1 = 1.997590912; static const float b2 = 1.990369453; static const float b3 = 1.978353019;
|
||||
static const float b4 = 1.961570560; static const float b5 = 1.940062506; static const float b6 = 1.913880671;
|
||||
static const float b7 = 1.883088130; static const float b8 = 1.847759065; static const float b9 = 1.807978586;
|
||||
static const float b10= 1.763842529; static const float b11= 1.715457220; static const float b12= 1.662939225;
|
||||
static const float b13= 1.606415063; static const float b14= 1.546020907; static const float b15= 1.481902251;
|
||||
static const float b16= 1.414213562; static const float b17= 1.343117910; static const float b18= 1.268786568;
|
||||
static const float b19= 1.191398609; static const float b20= 1.111140466; static const float b21= 1.028205488;
|
||||
static const float b22= 0.942793474; static const float b23= 0.855110187; static const float b24= 0.765366865;
|
||||
static const float b25= 0.673779707; static const float b26= 0.580569355; static const float b27= 0.485960360;
|
||||
static const float b28= 0.390180644; static const float b29= 0.293460949; static const float b30= 0.196034281;
|
||||
static const float b31= 0.098135349;
|
||||
|
||||
static float t_dewindow[17][32] = {{
|
||||
0.000000000 ,-0.000442505 , 0.003250122 ,-0.007003784 , 0.031082153 ,-0.078628540 , 0.100311279 ,-0.572036743 ,
|
||||
1.144989014 , 0.572036743 , 0.100311279 , 0.078628540 , 0.031082153 , 0.007003784 , 0.003250122 , 0.000442505 ,
|
||||
0.000000000 ,-0.000442505 , 0.003250122 ,-0.007003784 , 0.031082153 ,-0.078628540 , 0.100311279 ,-0.572036743 ,
|
||||
1.144989014 , 0.572036743 , 0.100311279 , 0.078628540 , 0.031082153 , 0.007003784 , 0.003250122 , 0.000442505 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000473022 , 0.003326416 ,-0.007919312 , 0.030517578 ,-0.084182739 , 0.090927124 ,-0.600219727 ,
|
||||
1.144287109 , 0.543823242 , 0.108856201 , 0.073059082 , 0.031478882 , 0.006118774 , 0.003173828 , 0.000396729 ,
|
||||
-0.000015259 ,-0.000473022 , 0.003326416 ,-0.007919312 , 0.030517578 ,-0.084182739 , 0.090927124 ,-0.600219727 ,
|
||||
1.144287109 , 0.543823242 , 0.108856201 , 0.073059082 , 0.031478882 , 0.006118774 , 0.003173828 , 0.000396729 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000534058 , 0.003387451 ,-0.008865356 , 0.029785156 ,-0.089706421 , 0.080688477 ,-0.628295898 ,
|
||||
1.142211914 , 0.515609741 , 0.116577148 , 0.067520142 , 0.031738281 , 0.005294800 , 0.003082275 , 0.000366211 ,
|
||||
-0.000015259 ,-0.000534058 , 0.003387451 ,-0.008865356 , 0.029785156 ,-0.089706421 , 0.080688477 ,-0.628295898 ,
|
||||
1.142211914 , 0.515609741 , 0.116577148 , 0.067520142 , 0.031738281 , 0.005294800 , 0.003082275 , 0.000366211 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000579834 , 0.003433228 ,-0.009841919 , 0.028884888 ,-0.095169067 , 0.069595337 ,-0.656219482 ,
|
||||
1.138763428 , 0.487472534 , 0.123474121 , 0.061996460 , 0.031845093 , 0.004486084 , 0.002990723 , 0.000320435 ,
|
||||
-0.000015259 ,-0.000579834 , 0.003433228 ,-0.009841919 , 0.028884888 ,-0.095169067 , 0.069595337 ,-0.656219482 ,
|
||||
1.138763428 , 0.487472534 , 0.123474121 , 0.061996460 , 0.031845093 , 0.004486084 , 0.002990723 , 0.000320435 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000625610 , 0.003463745 ,-0.010848999 , 0.027801514 ,-0.100540161 , 0.057617187 ,-0.683914185 ,
|
||||
1.133926392 , 0.459472656 , 0.129577637 , 0.056533813 , 0.031814575 , 0.003723145 , 0.002899170 , 0.000289917 ,
|
||||
-0.000015259 ,-0.000625610 , 0.003463745 ,-0.010848999 , 0.027801514 ,-0.100540161 , 0.057617187 ,-0.683914185 ,
|
||||
1.133926392 , 0.459472656 , 0.129577637 , 0.056533813 , 0.031814575 , 0.003723145 , 0.002899170 , 0.000289917 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000686646 , 0.003479004 ,-0.011886597 , 0.026535034 ,-0.105819702 , 0.044784546 ,-0.711318970 ,
|
||||
1.127746582 , 0.431655884 , 0.134887695 , 0.051132202 , 0.031661987 , 0.003005981 , 0.002792358 , 0.000259399 ,
|
||||
-0.000015259 ,-0.000686646 , 0.003479004 ,-0.011886597 , 0.026535034 ,-0.105819702 , 0.044784546 ,-0.711318970 ,
|
||||
1.127746582 , 0.431655884 , 0.134887695 , 0.051132202 , 0.031661987 , 0.003005981 , 0.002792358 , 0.000259399 ,
|
||||
},{
|
||||
-0.000015259 ,-0.000747681 , 0.003479004 ,-0.012939453 , 0.025085449 ,-0.110946655 , 0.031082153 ,-0.738372803 ,
|
||||
1.120223999 , 0.404083252 , 0.139450073 , 0.045837402 , 0.031387329 , 0.002334595 , 0.002685547 , 0.000244141 ,
|
||||
-0.000015259 ,-0.000747681 , 0.003479004 ,-0.012939453 , 0.025085449 ,-0.110946655 , 0.031082153 ,-0.738372803 ,
|
||||
1.120223999 , 0.404083252 , 0.139450073 , 0.045837402 , 0.031387329 , 0.002334595 , 0.002685547 , 0.000244141 ,
|
||||
},{
|
||||
-0.000030518 ,-0.000808716 , 0.003463745 ,-0.014022827 , 0.023422241 ,-0.115921021 , 0.016510010 ,-0.765029907 ,
|
||||
1.111373901 , 0.376800537 , 0.143264771 , 0.040634155 , 0.031005859 , 0.001693726 , 0.002578735 , 0.000213623 ,
|
||||
-0.000030518 ,-0.000808716 , 0.003463745 ,-0.014022827 , 0.023422241 ,-0.115921021 , 0.016510010 ,-0.765029907 ,
|
||||
1.111373901 , 0.376800537 , 0.143264771 , 0.040634155 , 0.031005859 , 0.001693726 , 0.002578735 , 0.000213623 ,
|
||||
},{
|
||||
-0.000030518 ,-0.000885010 , 0.003417969 ,-0.015121460 , 0.021575928 ,-0.120697021 , 0.001068115 ,-0.791213989 ,
|
||||
1.101211548 , 0.349868774 , 0.146362305 , 0.035552979 , 0.030532837 , 0.001098633 , 0.002456665 , 0.000198364 ,
|
||||
-0.000030518 ,-0.000885010 , 0.003417969 ,-0.015121460 , 0.021575928 ,-0.120697021 , 0.001068115 ,-0.791213989 ,
|
||||
1.101211548 , 0.349868774 , 0.146362305 , 0.035552979 , 0.030532837 , 0.001098633 , 0.002456665 , 0.000198364 ,
|
||||
},{
|
||||
-0.000030518 ,-0.000961304 , 0.003372192 ,-0.016235352 , 0.019531250 ,-0.125259399 ,-0.015228271 ,-0.816864014 ,
|
||||
1.089782715 , 0.323318481 , 0.148773193 , 0.030609131 , 0.029937744 , 0.000549316 , 0.002349854 , 0.000167847 ,
|
||||
-0.000030518 ,-0.000961304 , 0.003372192 ,-0.016235352 , 0.019531250 ,-0.125259399 ,-0.015228271 ,-0.816864014 ,
|
||||
1.089782715 , 0.323318481 , 0.148773193 , 0.030609131 , 0.029937744 , 0.000549316 , 0.002349854 , 0.000167847 ,
|
||||
},{
|
||||
-0.000030518 ,-0.001037598 , 0.003280640 ,-0.017349243 , 0.017257690 ,-0.129562378 ,-0.032379150 ,-0.841949463 ,
|
||||
1.077117920 , 0.297210693 , 0.150497437 , 0.025817871 , 0.029281616 , 0.000030518 , 0.002243042 , 0.000152588 ,
|
||||
-0.000030518 ,-0.001037598 , 0.003280640 ,-0.017349243 , 0.017257690 ,-0.129562378 ,-0.032379150 ,-0.841949463 ,
|
||||
1.077117920 , 0.297210693 , 0.150497437 , 0.025817871 , 0.029281616 , 0.000030518 , 0.002243042 , 0.000152588 ,
|
||||
},{
|
||||
-0.000045776 ,-0.001113892 , 0.003173828 ,-0.018463135 , 0.014801025 ,-0.133590698 ,-0.050354004 ,-0.866363525 ,
|
||||
1.063217163 , 0.271591187 , 0.151596069 , 0.021179199 , 0.028533936 ,-0.000442505 , 0.002120972 , 0.000137329 ,
|
||||
-0.000045776 ,-0.001113892 , 0.003173828 ,-0.018463135 , 0.014801025 ,-0.133590698 ,-0.050354004 ,-0.866363525 ,
|
||||
1.063217163 , 0.271591187 , 0.151596069 , 0.021179199 , 0.028533936 ,-0.000442505 , 0.002120972 , 0.000137329 ,
|
||||
},{
|
||||
-0.000045776 ,-0.001205444 , 0.003051758 ,-0.019577026 , 0.012115479 ,-0.137298584 ,-0.069168091 ,-0.890090942 ,
|
||||
1.048156738 , 0.246505737 , 0.152069092 , 0.016708374 , 0.027725220 ,-0.000869751 , 0.002014160 , 0.000122070 ,
|
||||
-0.000045776 ,-0.001205444 , 0.003051758 ,-0.019577026 , 0.012115479 ,-0.137298584 ,-0.069168091 ,-0.890090942 ,
|
||||
1.048156738 , 0.246505737 , 0.152069092 , 0.016708374 , 0.027725220 ,-0.000869751 , 0.002014160 , 0.000122070 ,
|
||||
},{
|
||||
-0.000061035 ,-0.001296997 , 0.002883911 ,-0.020690918 , 0.009231567 ,-0.140670776 ,-0.088775635 ,-0.913055420 ,
|
||||
1.031936646 , 0.221984863 , 0.151962280 , 0.012420654 , 0.026840210 ,-0.001266479 , 0.001907349 , 0.000106812 ,
|
||||
-0.000061035 ,-0.001296997 , 0.002883911 ,-0.020690918 , 0.009231567 ,-0.140670776 ,-0.088775635 ,-0.913055420 ,
|
||||
1.031936646 , 0.221984863 , 0.151962280 , 0.012420654 , 0.026840210 ,-0.001266479 , 0.001907349 , 0.000106812 ,
|
||||
},{
|
||||
-0.000061035 ,-0.001388550 , 0.002700806 ,-0.021789551 , 0.006134033 ,-0.143676758 ,-0.109161377 ,-0.935195923 ,
|
||||
1.014617920 , 0.198059082 , 0.151306152 , 0.008316040 , 0.025909424 ,-0.001617432 , 0.001785278 , 0.000106812 ,
|
||||
-0.000061035 ,-0.001388550 , 0.002700806 ,-0.021789551 , 0.006134033 ,-0.143676758 ,-0.109161377 ,-0.935195923 ,
|
||||
1.014617920 , 0.198059082 , 0.151306152 , 0.008316040 , 0.025909424 ,-0.001617432 , 0.001785278 , 0.000106812 ,
|
||||
},{
|
||||
-0.000076294 ,-0.001480103 , 0.002487183 ,-0.022857666 , 0.002822876 ,-0.146255493 ,-0.130310059 ,-0.956481934 ,
|
||||
0.996246338 , 0.174789429 , 0.150115967 , 0.004394531 , 0.024932861 ,-0.001937866 , 0.001693726 , 0.000091553 ,
|
||||
-0.000076294 ,-0.001480103 , 0.002487183 ,-0.022857666 , 0.002822876 ,-0.146255493 ,-0.130310059 ,-0.956481934 ,
|
||||
0.996246338 , 0.174789429 , 0.150115967 , 0.004394531 , 0.024932861 ,-0.001937866 , 0.001693726 , 0.000091553 ,
|
||||
},{
|
||||
-0.000076294 ,-0.001586914 , 0.002227783 ,-0.023910522 ,-0.000686646 ,-0.148422241 ,-0.152206421 ,-0.976852417 ,
|
||||
0.976852417 , 0.152206421 , 0.148422241 , 0.000686646 , 0.023910522 ,-0.002227783 , 0.001586914 , 0.000076294 ,
|
||||
-0.000076294 ,-0.001586914 , 0.002227783 ,-0.023910522 ,-0.000686646 ,-0.148422241 ,-0.152206421 ,-0.976852417 ,
|
||||
0.976852417 , 0.152206421 , 0.148422241 , 0.000686646 , 0.023910522 ,-0.002227783 , 0.001586914 , 0.000076294 ,
|
||||
} };
|
||||
#endif /* TRANSFORM */
|
||||
64
dll/amp/util.c
Normal file
64
dll/amp/util.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/* this file is a part of amp software
|
||||
|
||||
util.c: created by Andrew Richards
|
||||
|
||||
*/
|
||||
|
||||
#define AMP_UTIL
|
||||
#include "amp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "audio.h"
|
||||
|
||||
/* die - for terminal conditions prints the error message and exits */
|
||||
/* can not be suppressed with -q,-quiet */
|
||||
void
|
||||
die(char *fmt, ...)
|
||||
{
|
||||
#if 0
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
#endif
|
||||
_exit(-1);
|
||||
}
|
||||
|
||||
|
||||
/* warn - for warning messages. Can be suppressed by -q,-quiet */
|
||||
void
|
||||
warn(char *fmt, ...)
|
||||
{
|
||||
#if 0
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
if (!A_QUIET) {
|
||||
fprintf(stderr,"Warning: ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* msg - for general output. Can be suppressed by -q,-quiet. Output */
|
||||
/* goes to stderr so it doesn't conflict with stdout output */
|
||||
void
|
||||
msg(char *fmt, ...)
|
||||
{
|
||||
#if 0
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
|
||||
if (!A_QUIET)
|
||||
if (A_MSG_STDOUT) {
|
||||
vfprintf(stdout, fmt, ap);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fflush(stderr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
178
dll/arcfour/Makefile.in
Normal file
178
dll/arcfour/Makefile.in
Normal file
@@ -0,0 +1,178 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = arcfour
|
||||
|
||||
all: Makefile arcfour$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
arcfour.o: $(srcdir)/arcfour.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/arcfour.c
|
||||
|
||||
md5.o: $(srcdir)/md5.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/md5.c
|
||||
|
||||
arcfour$(SHLIB_SUFFIX): arcfour.o md5.o ../dllinit.o
|
||||
$(SHLIB_LD) arcfour.o md5.o ../dllinit.o $(SHLIB_CFLAGS) -o arcfour$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o arcfour$(SHLIB_SUFFIX) *.a *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
7
dll/arcfour/README
Normal file
7
dll/arcfour/README
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
This module is incomplete. It's purpose was to implement a secure dcc chat
|
||||
using RSA style encryption. If you feel like taking a stab at completing
|
||||
this, please email me edwards@bitchx.dimension6.com as well as letting
|
||||
humble@efnet know that you are interested.
|
||||
|
||||
Colten Edwards
|
||||
307
dll/arcfour/arcfour.c
Normal file
307
dll/arcfour/arcfour.c
Normal file
@@ -0,0 +1,307 @@
|
||||
/* ARCFour - a symmetric streaming cipher - Implimentation by Humble
|
||||
*
|
||||
* This is a variable-key-length symmetric stream cipher developed in 1987
|
||||
* by Ron Rivest (the R in RSA). It used to be proprietary but was reverse
|
||||
* engineered and released publicly in September 1994. The cipher is now
|
||||
* freely available but the name RC4 is a trademark of RSA Data Security
|
||||
* Inc. This cipher is secure, proven, easy to impliment, and quite fast.
|
||||
*/
|
||||
#define IN_MODULE
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "ctcp.h"
|
||||
#include "status.h"
|
||||
#include "lastlog.h"
|
||||
#include "server.h"
|
||||
#include "screen.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "hash2.h"
|
||||
#include "hook.h"
|
||||
#include "dcc.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include "arcfour.h"
|
||||
#include "md5.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
typedef struct {
|
||||
int sock;
|
||||
char ukey[16];
|
||||
arckey *outbox;
|
||||
arckey *inbox;
|
||||
} arclist;
|
||||
|
||||
/* from dcc.c. Why isnt this in dcc.h? */
|
||||
|
||||
typedef struct _DCC_List
|
||||
{
|
||||
struct _DCC_List *next;
|
||||
char *nick; /* do NOT free this. it's a shared pointer. */
|
||||
SocketList sock;
|
||||
} DCC_List;
|
||||
|
||||
|
||||
static arclist *keyboxes[16];
|
||||
|
||||
static const double arc_ver = 1.0;
|
||||
static unsigned int typenum = 0;
|
||||
|
||||
/*
|
||||
* Initialize our box, and return the key used. It better be enough to hold
|
||||
* 16 chars + 1 null!
|
||||
*/
|
||||
|
||||
static char *init_box(char *ukey, arckey *key)
|
||||
{
|
||||
MD5_CTX md5context;
|
||||
char buf[256];
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
read(fd, buf, sizeof(buf));
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[(int)buf[69]] ^= getpid();
|
||||
buf[(int)buf[226]] ^= getuid();
|
||||
buf[(int)buf[119]] ^= getpid();
|
||||
}
|
||||
|
||||
MD5Init(&md5context);
|
||||
MD5Update(&md5context, buf, sizeof(buf));
|
||||
MD5Final(&md5context);
|
||||
|
||||
memcpy(ukey, buf, 16);
|
||||
ukey[16] = '\0';
|
||||
|
||||
arcfourInit(key, md5context.digest, 16);
|
||||
return ukey;
|
||||
}
|
||||
|
||||
static inline void arcfourInit(arckey *arc, char *userkey, unsigned short len)
|
||||
{
|
||||
register arcword *S = arc->state, x = 0, y = 0, pos = 0, tmp;
|
||||
|
||||
/* Seed the S-box linearly, then mix in the key while stiring briskly */
|
||||
arc->i = arc->j = 0; /* Initialize i and j to 0 */
|
||||
while((S[x] = --x)); /* Initialize S-box, backwards */
|
||||
|
||||
/* Note: Some of these optimizations REQUIRE arcword to be 8-bit unsigned */
|
||||
do { /* Spread user key into real key */
|
||||
y += S[x] + userkey[pos]; /* Keys, shaken, not stirred */
|
||||
tmp = S[x]; S[x] = S[y]; S[y] = tmp; /* Swap S[i] and S[j] */
|
||||
if (++pos >= len) pos = 0; /* Repeat user key to fill array */
|
||||
} while(++x); /* ++x is faster than x++ */
|
||||
}
|
||||
|
||||
static inline char *arcfourCrypt(arckey *arc, char *data, int len)
|
||||
{
|
||||
register arcword *S = arc->state, i = arc->i, j = arc->j, tmp;
|
||||
register int c = 0;
|
||||
|
||||
do {
|
||||
j += S[++i]; /* Shake S-box, stir well */
|
||||
tmp = S[i]; S[i] = S[j]; S[j] = tmp; /* Swap S[i] and S[j] */
|
||||
data[c] ^= S[(S[i] + S[j])]; /* XOR the crypto into our data */
|
||||
} while (++c < len); /* Neat, ++x is faster then x++ */
|
||||
|
||||
arc->i = i; /* Save modified i and j counters */
|
||||
arc->j = j; /* Continue where we left off */
|
||||
return data; /* Return pointer to ciphertext */
|
||||
}
|
||||
|
||||
int Arcfour_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
initialize_module("arcfour");
|
||||
memset(keyboxes, 0, sizeof(keyboxes));
|
||||
/*
|
||||
dcc_output_func = send_dcc_encrypt;
|
||||
dcc_input_func = get_dcc_encrypt;
|
||||
dcc_open_func = start_dcc_crypt;
|
||||
dcc_close_func = end_dcc_crypt;
|
||||
*/
|
||||
typenum = add_dcc_bind("SCHAT", "schat", init_schat, start_dcc_crypt, get_dcc_encrypt, send_dcc_encrypt, end_dcc_crypt);
|
||||
add_module_proc(DCC_PROC, "schat", "schat", "Secure DCC Chat", 0, 0, dcc_sdcc, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Arcfour_Cleanup(IrcCommandDll **intp)
|
||||
{
|
||||
/* remove_dcc_bind("SCHAT", typenum); */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static arclist *find_box(int sock)
|
||||
{
|
||||
int i, tmp;
|
||||
tmp = sizeof(keyboxes)/sizeof(arclist *);
|
||||
for (i = 0; i < tmp; i++)
|
||||
if (keyboxes[i] && (keyboxes[i]->sock == sock))
|
||||
return keyboxes[i];
|
||||
return (arclist *)NULL;
|
||||
}
|
||||
|
||||
|
||||
static char *dcc_crypt (int sock, char *buf, int len)
|
||||
{
|
||||
arclist *box;
|
||||
if ((box = find_box(sock))) {
|
||||
arcfourCrypt(box->outbox, buf, len-2);
|
||||
return buf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int send_dcc_encrypt (int type, int sock, char *buf, int len)
|
||||
{
|
||||
if (type == DCC_CHAT) {
|
||||
if (dcc_crypt(sock, buf, len)) {
|
||||
write(sock, buf, len);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int get_dcc_encrypt (int type, int sock, char *buf, int parm, int len)
|
||||
{
|
||||
if (type == DCC_CHAT) {
|
||||
if ((len = dgets(buf, sock, parm, BIG_BUFFER_SIZE, NULL)) > 0) {
|
||||
buf[len-1] = '\0';
|
||||
dcc_crypt(sock, buf, len);
|
||||
if (buf[len])
|
||||
buf[len] = '\0';
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/* Here we initialize the cryptography. Send the other end our key, and read
|
||||
* in theirs. The socket "s" won't have a crypt box unless it is supposed to
|
||||
* an encrypted connection.
|
||||
*/
|
||||
|
||||
|
||||
static int start_dcc_crypt (int s, int type, unsigned long d_addr, int d_port)
|
||||
{
|
||||
arclist *tmpbox;
|
||||
put_it("start_dcc_crypt");
|
||||
if ((tmpbox = find_box(s))) {
|
||||
int len;
|
||||
char randkey[17];
|
||||
char buf[BIG_BUFFER_SIZE+1];
|
||||
memset(randkey, 0, sizeof(randkey));
|
||||
memset(buf, 0, sizeof(buf));
|
||||
tmpbox->outbox = (arckey *)new_malloc(sizeof(arckey));
|
||||
init_box(randkey, tmpbox->outbox);
|
||||
snprintf(buf, BIG_BUFFER_SIZE, "SecureDCC %s\r\n%n", randkey, &len);
|
||||
write(s, buf, len);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if ((len = dgets(buf, s, 1, BIG_BUFFER_SIZE, NULL)) > 0) {
|
||||
if (!my_strnicmp("SecureDCC", buf, 9)) {
|
||||
tmpbox->inbox = (arckey *)new_malloc(sizeof(arckey));
|
||||
arcfourInit(tmpbox->inbox, next_arg(buf, &buf), 16);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int end_dcc_crypt (int s, unsigned long d_addr, int d_port)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if (keyboxes[i] && (keyboxes[i]->sock == s)) {
|
||||
new_free(&(keyboxes[i]->inbox));
|
||||
new_free(&(keyboxes[i]->outbox));
|
||||
new_free(&keyboxes[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static void start_dcc_chat(int s)
|
||||
{
|
||||
struct sockaddr_in remaddr;
|
||||
int sra;
|
||||
int type;
|
||||
int new_s = -1;
|
||||
char *nick = NULL;
|
||||
unsigned long flags;
|
||||
DCC_int *n = NULL;
|
||||
SocketList *sa;
|
||||
|
||||
sa = get_socket(s);
|
||||
flags = sa->flags;
|
||||
nick = sa->server;
|
||||
sra = sizeof(struct sockaddr_in);
|
||||
new_s = accept(s, (struct sockaddr *) &remaddr, &sra);
|
||||
type = flags & DCC_TYPES;
|
||||
n = get_socketinfo(s);
|
||||
if ((add_socketread(new_s, ntohs(remaddr.sin_port), flags, nick, get_dcc_encrypt, NULL)) < 0)
|
||||
{
|
||||
erase_dcc_info(s, 0, "%s", convert_output_format("$G %RDCC error: accept() failed. punt!!", NULL, NULL));
|
||||
close_socketread(s);
|
||||
return;
|
||||
}
|
||||
flags &= ~DCC_WAIT;
|
||||
flags |= DCC_ACTIVE;
|
||||
set_socketflags(new_s, flags);
|
||||
set_socketinfo(new_s, n);
|
||||
|
||||
/*
|
||||
put_it("%s", convert_output_format(fget_string_var(FORMAT_DCC_CONNECT_FSET),
|
||||
"%s %s %s %s %s %d", update_clock(GET_TIME),
|
||||
dcc_types[type],
|
||||
nick, n->userhost?n->userhost:"u@h",
|
||||
inet_ntoa(remaddr.sin_addr),ntohs(remaddr.sin_port)));
|
||||
*/
|
||||
get_time(&n->starttime);
|
||||
close_socketread(s);
|
||||
start_dcc_crypt(new_s, type, n->remote.s_addr, ntohs(remaddr.sin_port));
|
||||
}
|
||||
|
||||
/* set up the dcc hooks */
|
||||
|
||||
void dcc_sdcc (char *name, char *args)
|
||||
{
|
||||
char *p;
|
||||
int tmp, i;
|
||||
DCC_int *new_sdcc;
|
||||
if (!my_stricmp(name, "schat") && (strlen(args) > 0)) {
|
||||
if (*args == ' ')
|
||||
new_next_arg(args, &args);
|
||||
else {
|
||||
p = strchr(args, ' ');
|
||||
if (p && *p)
|
||||
*p = 0;
|
||||
}
|
||||
new_sdcc = dcc_create(args, "SCHAT", NULL, 0, 0, typenum, DCC_TWOCLIENTS, start_dcc_chat);
|
||||
/* find_dcc_pending(new_sdcc->user, new_sdcc->filename, NULL, typenum, 1, -1); */
|
||||
/* new_i = find_dcc_pending(nick, filename, NULL, type, 1, -1); */
|
||||
tmp = sizeof(keyboxes)/sizeof(arclist *);
|
||||
for (i = 0; i < tmp; i++)
|
||||
if (!keyboxes[i])
|
||||
/* keyboxes[i]->sock = new_i->sock */;
|
||||
}
|
||||
}
|
||||
|
||||
/* thanks to the new add_dcc_bind, we dont have to worry about any hooking... */
|
||||
|
||||
static int init_schat(char *type, char *nick, char *userhost, char *description, char *size, char *extra, unsigned long ip, unsigned int port)
|
||||
{
|
||||
/* new_sdcc = dcc_create(args, "SCHAT", NULL, 0, 0, typenum, DCC_TWOCLIENTS, start_dcc_chat); */
|
||||
return 0;
|
||||
}
|
||||
15
dll/arcfour/arcfour.h
Normal file
15
dll/arcfour/arcfour.h
Normal file
@@ -0,0 +1,15 @@
|
||||
typedef unsigned char arcword; /* 8-bit groups */
|
||||
|
||||
typedef struct {
|
||||
arcword state[256], i, j;
|
||||
} arckey;
|
||||
|
||||
/* Prototypes */
|
||||
static inline void arcfourInit(arckey *, char *, unsigned short);
|
||||
static inline char *arcfourCrypt(arckey *, char *, int);
|
||||
static int send_dcc_encrypt (int, int, char *, int);
|
||||
static int get_dcc_encrypt (int, int, char *, int, int);
|
||||
static int start_dcc_crypt (int, int, unsigned long, int);
|
||||
static int end_dcc_crypt (int, unsigned long, int);
|
||||
static int init_schat(char *, char *, char *, char *, char *, char *, unsigned long, unsigned int);
|
||||
void dcc_sdcc (char *, char *);
|
||||
1
dll/arcfour/asdf
Normal file
1
dll/arcfour/asdf
Normal file
@@ -0,0 +1 @@
|
||||
name, module, init func, start func, input func, output func, close func
|
||||
239
dll/arcfour/md5.c
Normal file
239
dll/arcfour/md5.c
Normal file
@@ -0,0 +1,239 @@
|
||||
/* MD5 Message Digest algorithm */
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
/* Prototypes */
|
||||
static void Transform(UINT_32 *, UINT_32 *);
|
||||
|
||||
static unsigned char 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 };
|
||||
|
||||
/* F, G and H are basic MD5 functions: selection, majority, parity */
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits */
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
|
||||
/* Rotation is separate from addition to prevent recomputation */
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (UINT_32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (UINT_32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (UINT_32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (UINT_32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||
|
||||
void MD5Init(MD5_CTX *mdContext)
|
||||
{
|
||||
mdContext->i[0] = mdContext->i[1] = (UINT_32) 0;
|
||||
|
||||
/* Load magic initialization constants. */
|
||||
mdContext->buf[0] = (UINT_32) 0x67452301;
|
||||
mdContext->buf[1] = (UINT_32) 0xefcdab89;
|
||||
mdContext->buf[2] = (UINT_32) 0x98badcfe;
|
||||
mdContext->buf[3] = (UINT_32) 0x10325476;
|
||||
}
|
||||
|
||||
void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
|
||||
{
|
||||
unsigned int i, ii;
|
||||
UINT_32 in[16];
|
||||
int mdi;
|
||||
|
||||
/* compute number of bytes mod 64 */
|
||||
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
|
||||
|
||||
/* update number of bits */
|
||||
if ((mdContext->i[0] + ((UINT_32) inLen << 3)) < mdContext->i[0])
|
||||
mdContext->i[1]++;
|
||||
mdContext->i[0] += ((UINT_32) inLen << 3);
|
||||
mdContext->i[1] += ((UINT_32) inLen >> 29);
|
||||
|
||||
while (inLen--) {
|
||||
/* add new character to buffer, increment mdi */
|
||||
mdContext->in[mdi++] = *inBuf++;
|
||||
|
||||
/* transform if necessary */
|
||||
if (mdi == 0x40) {
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4)
|
||||
in[i] = (((UINT_32) mdContext->in[ii + 3]) << 24) |
|
||||
(((UINT_32) mdContext->in[ii + 2]) << 16) |
|
||||
(((UINT_32) mdContext->in[ii + 1]) << 8) |
|
||||
((UINT_32) mdContext->in[ii]);
|
||||
Transform(mdContext->buf, in);
|
||||
mdi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MD5Final(MD5_CTX *mdContext)
|
||||
{
|
||||
UINT_32 in[16];
|
||||
unsigned int i, ii;
|
||||
unsigned int padLen;
|
||||
int mdi;
|
||||
|
||||
/* save number of bits */
|
||||
in[14] = mdContext->i[0];
|
||||
in[15] = mdContext->i[1];
|
||||
|
||||
/* compute number of bytes mod 64 */
|
||||
mdi = (int) ((mdContext->i[0] >> 3) & 0x3F);
|
||||
|
||||
/* pad out to 56 mod 64 */
|
||||
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
|
||||
MD5Update(mdContext, PADDING, padLen);
|
||||
|
||||
/* append length in bits and transform */
|
||||
for (i = 0, ii = 0; i < 14; i++, ii += 4)
|
||||
in[i] = (((UINT_32) mdContext->in[ii + 3]) << 24) |
|
||||
(((UINT_32) mdContext->in[ii + 2]) << 16) |
|
||||
(((UINT_32) mdContext->in[ii + 1]) << 8) |
|
||||
((UINT_32) mdContext->in[ii]);
|
||||
Transform(mdContext->buf, in);
|
||||
|
||||
/* store buffer in digest */
|
||||
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
|
||||
mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF);
|
||||
mdContext->digest[ii + 1] =
|
||||
(unsigned char) ((mdContext->buf[i] >> 8) & 0xFF);
|
||||
mdContext->digest[ii + 2] =
|
||||
(unsigned char) ((mdContext->buf[i] >> 16) & 0xFF);
|
||||
mdContext->digest[ii + 3] =
|
||||
(unsigned char) ((mdContext->buf[i] >> 24) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
/* Basic MD5 step. Transform buf based on in. */
|
||||
static void Transform(UINT_32 *buf, UINT_32 *in)
|
||||
{
|
||||
UINT_32 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
||||
|
||||
/* Round 1 */
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
FF (a, b, c, d, in[ 0], S11, 0xd76aa478); /* 1 */
|
||||
FF (d, a, b, c, in[ 1], S12, 0xe8c7b756); /* 2 */
|
||||
FF (c, d, a, b, in[ 2], S13, 0x242070db); /* 3 */
|
||||
FF (b, c, d, a, in[ 3], S14, 0xc1bdceee); /* 4 */
|
||||
FF (a, b, c, d, in[ 4], S11, 0xf57c0faf); /* 5 */
|
||||
FF (d, a, b, c, in[ 5], S12, 0x4787c62a); /* 6 */
|
||||
FF (c, d, a, b, in[ 6], S13, 0xa8304613); /* 7 */
|
||||
FF (b, c, d, a, in[ 7], S14, 0xfd469501); /* 8 */
|
||||
FF (a, b, c, d, in[ 8], S11, 0x698098d8); /* 9 */
|
||||
FF (d, a, b, c, in[ 9], S12, 0x8b44f7af); /* 10 */
|
||||
FF (c, d, a, b, in[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF (b, c, d, a, in[11], S14, 0x895cd7be); /* 12 */
|
||||
FF (a, b, c, d, in[12], S11, 0x6b901122); /* 13 */
|
||||
FF (d, a, b, c, in[13], S12, 0xfd987193); /* 14 */
|
||||
FF (c, d, a, b, in[14], S13, 0xa679438e); /* 15 */
|
||||
FF (b, c, d, a, in[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
GG (a, b, c, d, in[ 1], S21, 0xf61e2562); /* 17 */
|
||||
GG (d, a, b, c, in[ 6], S22, 0xc040b340); /* 18 */
|
||||
GG (c, d, a, b, in[11], S23, 0x265e5a51); /* 19 */
|
||||
GG (b, c, d, a, in[ 0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG (a, b, c, d, in[ 5], S21, 0xd62f105d); /* 21 */
|
||||
GG (d, a, b, c, in[10], S22, 0x2441453 ); /* 22 */
|
||||
GG (c, d, a, b, in[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG (b, c, d, a, in[ 4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG (a, b, c, d, in[ 9], S21, 0x21e1cde6); /* 25 */
|
||||
GG (d, a, b, c, in[14], S22, 0xc33707d6); /* 26 */
|
||||
GG (c, d, a, b, in[ 3], S23, 0xf4d50d87); /* 27 */
|
||||
GG (b, c, d, a, in[ 8], S24, 0x455a14ed); /* 28 */
|
||||
GG (a, b, c, d, in[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG (d, a, b, c, in[ 2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG (c, d, a, b, in[ 7], S23, 0x676f02d9); /* 31 */
|
||||
GG (b, c, d, a, in[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
HH (a, b, c, d, in[ 5], S31, 0xfffa3942); /* 33 */
|
||||
HH (d, a, b, c, in[ 8], S32, 0x8771f681); /* 34 */
|
||||
HH (c, d, a, b, in[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH (b, c, d, a, in[14], S34, 0xfde5380c); /* 36 */
|
||||
HH (a, b, c, d, in[ 1], S31, 0xa4beea44); /* 37 */
|
||||
HH (d, a, b, c, in[ 4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH (c, d, a, b, in[ 7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH (b, c, d, a, in[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH (a, b, c, d, in[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH (d, a, b, c, in[ 0], S32, 0xeaa127fa); /* 42 */
|
||||
HH (c, d, a, b, in[ 3], S33, 0xd4ef3085); /* 43 */
|
||||
HH (b, c, d, a, in[ 6], S34, 0x4881d05 ); /* 44 */
|
||||
HH (a, b, c, d, in[ 9], S31, 0xd9d4d039); /* 45 */
|
||||
HH (d, a, b, c, in[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH (c, d, a, b, in[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH (b, c, d, a, in[ 2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
II (a, b, c, d, in[ 0], S41, 0xf4292244); /* 49 */
|
||||
II (d, a, b, c, in[ 7], S42, 0x432aff97); /* 50 */
|
||||
II (c, d, a, b, in[14], S43, 0xab9423a7); /* 51 */
|
||||
II (b, c, d, a, in[ 5], S44, 0xfc93a039); /* 52 */
|
||||
II (a, b, c, d, in[12], S41, 0x655b59c3); /* 53 */
|
||||
II (d, a, b, c, in[ 3], S42, 0x8f0ccc92); /* 54 */
|
||||
II (c, d, a, b, in[10], S43, 0xffeff47d); /* 55 */
|
||||
II (b, c, d, a, in[ 1], S44, 0x85845dd1); /* 56 */
|
||||
II (a, b, c, d, in[ 8], S41, 0x6fa87e4f); /* 57 */
|
||||
II (d, a, b, c, in[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II (c, d, a, b, in[ 6], S43, 0xa3014314); /* 59 */
|
||||
II (b, c, d, a, in[13], S44, 0x4e0811a1); /* 60 */
|
||||
II (a, b, c, d, in[ 4], S41, 0xf7537e82); /* 61 */
|
||||
II (d, a, b, c, in[11], S42, 0xbd3af235); /* 62 */
|
||||
II (c, d, a, b, in[ 2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II (b, c, d, a, in[ 9], S44, 0xeb86d391); /* 64 */
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
|
||||
memset((void *)in, 0, sizeof(in));
|
||||
}
|
||||
|
||||
#if 0
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MD5_CTX md5Context;
|
||||
unsigned int len = strlen(argv[1]);
|
||||
unsigned char i;
|
||||
|
||||
MD5Init(&md5Context);
|
||||
MD5Update(&md5Context, argv[1], len);
|
||||
MD5Final(&md5Context);
|
||||
|
||||
printf("MD5sum: ");
|
||||
for(i=0;i<16;i++)
|
||||
printf("%02x", md5Context.digest[i]);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
#endif
|
||||
14
dll/arcfour/md5.h
Normal file
14
dll/arcfour/md5.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* typedef a 32 bit type */
|
||||
typedef unsigned long int UINT_32;
|
||||
|
||||
/* Data structure for MD5 (Message Digest) computation */
|
||||
typedef struct {
|
||||
UINT_32 i[2]; /* number of _bits_ handled mod 2^64 */
|
||||
UINT_32 buf[4]; /* scratch buffer */
|
||||
unsigned char in[64]; /* input buffer */
|
||||
unsigned char digest[16]; /* actual digest after MD5Final call */
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5Final(MD5_CTX *);
|
||||
void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
|
||||
void MD5Init(MD5_CTX *);
|
||||
178
dll/autocycle/Makefile.in
Normal file
178
dll/autocycle/Makefile.in
Normal file
@@ -0,0 +1,178 @@
|
||||
# dll/autocycle/Makefile
|
||||
# (c) David Walluck 2000
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = autocycle
|
||||
|
||||
all: Makefile autocycle$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
autocycle.o: $(srcdir)/autocycle.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/autocycle.c
|
||||
|
||||
autocycle$(SHLIB_SUFFIX): autocycle.o ../dllinit.o
|
||||
$(SHLIB_LD) autocycle.o ../dllinit.o $(SHLIB_CFLAGS) -o autocycle$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.a *.dll autocycle$(SHLIB_SUFFIX) *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
63
dll/autocycle/autocycle.c
Normal file
63
dll/autocycle/autocycle.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* dll/autocycle/autocycle.c - Auto-cycle plugin for BitchX
|
||||
* Copyright (c) David Walluck 1999
|
||||
*/
|
||||
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "server.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "module.h"
|
||||
#include "hook.h"
|
||||
#ifndef INIT_MODULE
|
||||
#define INIT_MODULE
|
||||
#endif
|
||||
#include "modval.h"
|
||||
|
||||
#define MODULE_NAME "Autocycle"
|
||||
#define _MODULE_VERSION "0.01"
|
||||
|
||||
int auto_cycle(IrcCommandDll *interp, char *command, char *args, char *subargs)
|
||||
{
|
||||
char * channel = current_window->current_channel;
|
||||
int netsplit = (int)next_arg(args, &args);
|
||||
int this_server = current_window->server;
|
||||
ChannelList * chan = lookup_channel(channel, this_server, 0);
|
||||
NickList * tmp = NULL;
|
||||
int counter = 0;
|
||||
|
||||
/*
|
||||
* This may look a little odd, but I had a hard time assuring otherwise
|
||||
* that there's only one person left on the channel
|
||||
*/
|
||||
for (tmp = next_nicklist(chan, NULL); tmp && counter != 2; tmp = next_nicklist(chan, tmp), counter++);
|
||||
|
||||
if (get_dllint_var("AUTO_CYCLE"))
|
||||
{
|
||||
if (counter == 1 && (!netsplit || get_dllint_var("AUTO_CYCLE") > 1) && !is_chanop(channel, get_server_nickname(from_server)) && channel[0] != '+')
|
||||
{
|
||||
put_it("%s", convert_output_format("$G Auto-cycling $0 to gain ops", "%s", channel));
|
||||
my_send_to_server(from_server, "PART %s\nJOIN %s%s%s",chan->channel, chan->channel, chan->key ? " " : "", chan->key ? chan->key : "");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Autocycle_Cleanup(IrcCommandDll **interp, Function_ptr *global_table)
|
||||
{
|
||||
remove_module_proc(VAR_PROC, MODULE_NAME, NULL, NULL);
|
||||
remove_module_proc(HOOK_PROC, MODULE_NAME, NULL, NULL);
|
||||
put_it("%s", convert_output_format("$G $0 $1 by DavidW2 unloaded","%s %s", MODULE_NAME, _MODULE_VERSION));
|
||||
return 2;
|
||||
}
|
||||
|
||||
int Autocycle_Init(IrcCommandDll **interp, Function_ptr *global_table)
|
||||
{
|
||||
initialize_module(MODULE_NAME);
|
||||
add_module_proc(VAR_PROC, MODULE_NAME, "AUTO_CYCLE", NULL, INT_TYPE_VAR, 0, NULL, NULL);
|
||||
add_module_proc(HOOK_PROC, MODULE_NAME, NULL, "*", NETSPLIT_LIST, 1, NULL, auto_cycle);
|
||||
put_it("%s", convert_output_format("$G $0 $1 by DavidW2 loaded", "%s %s", MODULE_NAME, _MODULE_VERSION));
|
||||
return 0;
|
||||
}
|
||||
5
dll/blowfish/CREDITS
Normal file
5
dll/blowfish/CREDITS
Normal file
@@ -0,0 +1,5 @@
|
||||
This is a total rip-off of the eggdrop blowfish implementation. Some
|
||||
versions of tcl will have trouble encrypting strings with a ";" in them, so
|
||||
use quotes...
|
||||
|
||||
By-Tor
|
||||
175
dll/blowfish/Makefile.in
Normal file
175
dll/blowfish/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = blowfish
|
||||
|
||||
all: Makefile blowfish$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
blowfish.o: $(srcdir)/blowfish.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/blowfish.c
|
||||
|
||||
blowfish$(SHLIB_SUFFIX): blowfish.o ../dllinit.o
|
||||
$(SHLIB_LD) blowfish.o ../dllinit.o $(SHLIB_CFLAGS) -o blowfish$(SHLIB_SUFFIX) $(TCL_LIBS)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o blowfish$(SHLIB_SUFFIX) *.a *.dll *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
4
dll/blowfish/README
Normal file
4
dll/blowfish/README
Normal file
@@ -0,0 +1,4 @@
|
||||
This is a hacked up blowfish encryption module for bitchx...
|
||||
It is stolen from eggdrop. And no, im not going to include the entire
|
||||
eggdrop source. If you want it, go get it. Otherwise, bleh!
|
||||
|
||||
275
dll/blowfish/bf_tab.h
Normal file
275
dll/blowfish/bf_tab.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/* bf_tab.h: Blowfish P-box and S-box tables */
|
||||
#ifndef _H_TAB_BF
|
||||
#define _H_TAB_BF
|
||||
|
||||
static UWORD_32bits initbf_P[bf_N + 2] = {
|
||||
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
|
||||
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
|
||||
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
|
||||
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
|
||||
0x9216d5d9, 0x8979fb1b,
|
||||
};
|
||||
static UWORD_32bits initbf_S[4][256] = {
|
||||
{
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
|
||||
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
|
||||
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
|
||||
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
|
||||
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
|
||||
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
|
||||
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
|
||||
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
|
||||
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
|
||||
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
|
||||
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
|
||||
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
|
||||
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
|
||||
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
|
||||
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
|
||||
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
|
||||
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
|
||||
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
|
||||
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
|
||||
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
|
||||
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
|
||||
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
|
||||
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
|
||||
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
|
||||
0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
|
||||
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
|
||||
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
|
||||
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
|
||||
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
|
||||
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
|
||||
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
|
||||
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
|
||||
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
|
||||
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
|
||||
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
|
||||
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
|
||||
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
|
||||
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
|
||||
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
|
||||
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
|
||||
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
|
||||
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
|
||||
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
|
||||
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
|
||||
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
|
||||
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
|
||||
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
|
||||
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
|
||||
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
|
||||
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
|
||||
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
|
||||
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
|
||||
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
|
||||
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
|
||||
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
|
||||
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
|
||||
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
|
||||
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
|
||||
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
|
||||
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
|
||||
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a },
|
||||
{
|
||||
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
|
||||
0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
|
||||
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
|
||||
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
|
||||
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
|
||||
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
|
||||
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
|
||||
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
|
||||
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
|
||||
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
|
||||
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
|
||||
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
|
||||
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
|
||||
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
|
||||
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
|
||||
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
|
||||
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
|
||||
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
|
||||
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
|
||||
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
|
||||
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
|
||||
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
|
||||
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
|
||||
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
|
||||
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
|
||||
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
|
||||
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
|
||||
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
|
||||
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
|
||||
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
|
||||
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
|
||||
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
|
||||
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
|
||||
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
|
||||
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
|
||||
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
|
||||
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
|
||||
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
|
||||
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
|
||||
0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
|
||||
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
|
||||
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
|
||||
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
|
||||
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
|
||||
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
|
||||
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
|
||||
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
|
||||
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
|
||||
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
|
||||
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
|
||||
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
|
||||
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
|
||||
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
|
||||
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
|
||||
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
|
||||
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
|
||||
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
|
||||
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
|
||||
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
|
||||
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
|
||||
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
|
||||
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
|
||||
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
|
||||
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 },
|
||||
{
|
||||
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
|
||||
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
|
||||
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
|
||||
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
|
||||
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
|
||||
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
|
||||
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
|
||||
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
|
||||
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
|
||||
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
|
||||
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
|
||||
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
|
||||
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
|
||||
0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
|
||||
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
|
||||
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
|
||||
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
|
||||
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
|
||||
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
|
||||
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
|
||||
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
|
||||
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
|
||||
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
|
||||
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
|
||||
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
|
||||
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
|
||||
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
|
||||
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
|
||||
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
|
||||
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
|
||||
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
|
||||
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
|
||||
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
|
||||
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
|
||||
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
|
||||
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
|
||||
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
|
||||
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
|
||||
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
|
||||
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
|
||||
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
|
||||
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
|
||||
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
|
||||
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
|
||||
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
|
||||
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
|
||||
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
|
||||
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
|
||||
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
|
||||
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
|
||||
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
|
||||
0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
|
||||
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
|
||||
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
|
||||
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
|
||||
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
|
||||
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
|
||||
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
|
||||
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
|
||||
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
|
||||
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
|
||||
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
|
||||
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
|
||||
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 },
|
||||
{
|
||||
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
|
||||
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
|
||||
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
|
||||
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
|
||||
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
|
||||
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
|
||||
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
|
||||
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
|
||||
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
|
||||
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
|
||||
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
|
||||
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
|
||||
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
|
||||
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
|
||||
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
|
||||
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
|
||||
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
|
||||
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
|
||||
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
|
||||
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
|
||||
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
|
||||
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
|
||||
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
|
||||
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
|
||||
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
|
||||
0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
|
||||
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
|
||||
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
|
||||
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
|
||||
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
|
||||
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
|
||||
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
|
||||
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
|
||||
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
|
||||
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
|
||||
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
|
||||
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
|
||||
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
|
||||
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
|
||||
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
|
||||
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
|
||||
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
|
||||
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
|
||||
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
|
||||
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
|
||||
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
|
||||
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
|
||||
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
|
||||
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
|
||||
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
|
||||
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
|
||||
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
|
||||
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
|
||||
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
|
||||
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
|
||||
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
|
||||
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
|
||||
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
|
||||
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
|
||||
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
|
||||
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
|
||||
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
|
||||
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
|
||||
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 }
|
||||
};
|
||||
|
||||
#endif
|
||||
387
dll/blowfish/blowfish.c
Normal file
387
dll/blowfish/blowfish.c
Normal file
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
blowfish.c -- handles:
|
||||
encryption and decryption of passwords
|
||||
|
||||
The first half of this is very lightly edited from public domain
|
||||
sourcecode. For simplicity, this entire module will remain public
|
||||
domain.
|
||||
*/
|
||||
|
||||
#include "blowfish.h"
|
||||
#include "bf_tab.h" /* P-box P-array, S-box */
|
||||
|
||||
#define BOXES 3
|
||||
|
||||
/* #define S(x,i) (bf_S[i][x.w.byte##i]) */
|
||||
#define S0(x) (bf_S[0][x.w.byte0])
|
||||
#define S1(x) (bf_S[1][x.w.byte1])
|
||||
#define S2(x) (bf_S[2][x.w.byte2])
|
||||
#define S3(x) (bf_S[3][x.w.byte3])
|
||||
#define bf_F(x) (((S0(x) + S1(x)) ^ S2(x)) + S3(x))
|
||||
#define ROUND(a,b,n) (a.word ^= bf_F(b) ^ bf_P[n])
|
||||
|
||||
/* keep a set of rotating P & S boxes */
|
||||
static struct box_t {
|
||||
UWORD_32bits *P;
|
||||
UWORD_32bits **S;
|
||||
char key[81];
|
||||
char keybytes;
|
||||
time_t lastuse;
|
||||
} blowbox[BOXES];
|
||||
|
||||
/*
|
||||
static UWORD_32bits bf_P[bf_N+2];
|
||||
static UWORD_32bits bf_S[4][256];
|
||||
*/
|
||||
|
||||
static UWORD_32bits *bf_P;
|
||||
static UWORD_32bits **bf_S;
|
||||
|
||||
static char blowfish_version[] = "BitchX blowfish encryption module v1.0";
|
||||
|
||||
static void blowfish_encipher (UWORD_32bits * xl, UWORD_32bits * xr)
|
||||
{
|
||||
union aword Xl;
|
||||
union aword Xr;
|
||||
|
||||
Xl.word = *xl;
|
||||
Xr.word = *xr;
|
||||
|
||||
Xl.word ^= bf_P[0];
|
||||
ROUND(Xr, Xl, 1);
|
||||
ROUND(Xl, Xr, 2);
|
||||
ROUND(Xr, Xl, 3);
|
||||
ROUND(Xl, Xr, 4);
|
||||
ROUND(Xr, Xl, 5);
|
||||
ROUND(Xl, Xr, 6);
|
||||
ROUND(Xr, Xl, 7);
|
||||
ROUND(Xl, Xr, 8);
|
||||
ROUND(Xr, Xl, 9);
|
||||
ROUND(Xl, Xr, 10);
|
||||
ROUND(Xr, Xl, 11);
|
||||
ROUND(Xl, Xr, 12);
|
||||
ROUND(Xr, Xl, 13);
|
||||
ROUND(Xl, Xr, 14);
|
||||
ROUND(Xr, Xl, 15);
|
||||
ROUND(Xl, Xr, 16);
|
||||
Xr.word ^= bf_P[17];
|
||||
|
||||
*xr = Xl.word;
|
||||
*xl = Xr.word;
|
||||
}
|
||||
|
||||
static void blowfish_decipher (UWORD_32bits * xl, UWORD_32bits * xr)
|
||||
{
|
||||
union aword Xl;
|
||||
union aword Xr;
|
||||
|
||||
Xl.word = *xl;
|
||||
Xr.word = *xr;
|
||||
|
||||
Xl.word ^= bf_P[17];
|
||||
ROUND(Xr, Xl, 16);
|
||||
ROUND(Xl, Xr, 15);
|
||||
ROUND(Xr, Xl, 14);
|
||||
ROUND(Xl, Xr, 13);
|
||||
ROUND(Xr, Xl, 12);
|
||||
ROUND(Xl, Xr, 11);
|
||||
ROUND(Xr, Xl, 10);
|
||||
ROUND(Xl, Xr, 9);
|
||||
ROUND(Xr, Xl, 8);
|
||||
ROUND(Xl, Xr, 7);
|
||||
ROUND(Xr, Xl, 6);
|
||||
ROUND(Xl, Xr, 5);
|
||||
ROUND(Xr, Xl, 4);
|
||||
ROUND(Xl, Xr, 3);
|
||||
ROUND(Xr, Xl, 2);
|
||||
ROUND(Xl, Xr, 1);
|
||||
Xr.word ^= bf_P[0];
|
||||
|
||||
*xl = Xr.word;
|
||||
*xr = Xl.word;
|
||||
}
|
||||
|
||||
static void blowfish_init (UBYTE_08bits * key, short keybytes)
|
||||
{
|
||||
int i, j, bx;
|
||||
time_t lowest;
|
||||
UWORD_32bits data;
|
||||
UWORD_32bits datal;
|
||||
UWORD_32bits datar;
|
||||
union aword temp;
|
||||
|
||||
/* is buffer already allocated for this? */
|
||||
for (i = 0; i < BOXES; i++)
|
||||
if (blowbox[i].P != NULL)
|
||||
{
|
||||
if ((blowbox[i].keybytes == keybytes) &&
|
||||
(strncmp((char *) (blowbox[i].key), (char *) key, keybytes) == 0))
|
||||
{
|
||||
blowbox[i].lastuse = now;
|
||||
bf_P = blowbox[i].P;
|
||||
bf_S = blowbox[i].S;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* no pre-allocated buffer: make new one */
|
||||
/* set 'bx' to empty buffer */
|
||||
bx = (-1);
|
||||
for (i = 0; i < BOXES; i++)
|
||||
{
|
||||
if (blowbox[i].P == NULL)
|
||||
{
|
||||
bx = i;
|
||||
i = BOXES + 1;
|
||||
}
|
||||
}
|
||||
if (bx < 0)
|
||||
{
|
||||
/* find oldest */
|
||||
lowest = now;
|
||||
for (i = 0; i < BOXES; i++)
|
||||
if (blowbox[i].lastuse <= lowest)
|
||||
{
|
||||
lowest = blowbox[i].lastuse;
|
||||
bx = i;
|
||||
}
|
||||
new_free(&blowbox[bx].P);
|
||||
for (i = 0; i < 4; i++)
|
||||
new_free(&blowbox[bx].S[i]);
|
||||
new_free(&blowbox[bx].S);
|
||||
}
|
||||
/* initialize new buffer */
|
||||
/* uh... this is over 4k */
|
||||
blowbox[bx].P = (UWORD_32bits *) new_malloc((bf_N + 2) * sizeof(UWORD_32bits));
|
||||
blowbox[bx].S = (UWORD_32bits **) new_malloc(4 * sizeof(UWORD_32bits *));
|
||||
for (i = 0; i < 4; i++)
|
||||
blowbox[bx].S[i] = (UWORD_32bits *) new_malloc(256 * sizeof(UWORD_32bits));
|
||||
bf_P = blowbox[bx].P;
|
||||
bf_S = blowbox[bx].S;
|
||||
blowbox[bx].keybytes = keybytes;
|
||||
strncpy(blowbox[bx].key, key, keybytes);
|
||||
blowbox[bx].lastuse = now;
|
||||
|
||||
/* robey: reset blowfish boxes to initial state */
|
||||
/* (i guess normally it just keeps scrambling them, but here it's */
|
||||
/* important to get the same encrypted result each time) */
|
||||
for (i = 0; i < bf_N + 2; i++)
|
||||
bf_P[i] = initbf_P[i];
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 256; j++)
|
||||
bf_S[i][j] = initbf_S[i][j];
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < bf_N + 2; ++i)
|
||||
{
|
||||
temp.word = 0;
|
||||
temp.w.byte0 = key[j];
|
||||
temp.w.byte1 = key[(j + 1) % keybytes];
|
||||
temp.w.byte2 = key[(j + 2) % keybytes];
|
||||
temp.w.byte3 = key[(j + 3) % keybytes];
|
||||
data = temp.word;
|
||||
bf_P[i] = bf_P[i] ^ data;
|
||||
j = (j + 4) % keybytes;
|
||||
}
|
||||
|
||||
datal = 0x00000000;
|
||||
datar = 0x00000000;
|
||||
|
||||
for (i = 0; i < bf_N + 2; i += 2)
|
||||
{
|
||||
blowfish_encipher(&datal, &datar);
|
||||
bf_P[i] = datal;
|
||||
bf_P[i + 1] = datar;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
for (j = 0; j < 256; j += 2)
|
||||
{
|
||||
blowfish_encipher(&datal, &datar);
|
||||
bf_S[i][j] = datal;
|
||||
bf_S[i][j + 1] = datar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* stuff below this line was written by robey for eggdrop use */
|
||||
|
||||
/* convert 64-bit encrypted password to text for userfile */
|
||||
static char *base64 = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
static int base64dec (char c)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 64; i++)
|
||||
if (base64[i] == c)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* returned string must be freed when done with it! */
|
||||
static char *encrypt_string (char * key, char * str)
|
||||
{
|
||||
UWORD_32bits left, right;
|
||||
char *p, *s, *dest, *d;
|
||||
int i;
|
||||
dest = (char *) new_malloc((strlen(str) + 9) * 2);
|
||||
/* pad fake string with 8 bytes to make sure there's enough */
|
||||
s = (char *) new_malloc(strlen(str) + 9);
|
||||
strcpy(s, str);
|
||||
p = s;
|
||||
while (*p)
|
||||
p++;
|
||||
for (i = 0; i < 8; i++)
|
||||
*p++ = 0;
|
||||
blowfish_init(key, strlen(key));
|
||||
p = s;
|
||||
d = dest;
|
||||
while (*p)
|
||||
{
|
||||
left = ((*p++) << 24);
|
||||
left += ((*p++) << 16);
|
||||
left += ((*p++) << 8);
|
||||
left += (*p++);
|
||||
right = ((*p++) << 24);
|
||||
right += ((*p++) << 16);
|
||||
right += ((*p++) << 8);
|
||||
right += (*p++);
|
||||
blowfish_encipher(&left, &right);
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
*d++ = base64[right & 0x3f];
|
||||
right = (right >> 6);
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
*d++ = base64[left & 0x3f];
|
||||
left = (left >> 6);
|
||||
}
|
||||
}
|
||||
*d = 0;
|
||||
new_free(&s);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* returned string must be freed when done with it! */
|
||||
static char *decrypt_string (char * key, char * str)
|
||||
{
|
||||
UWORD_32bits left, right;
|
||||
char *p, *s, *dest, *d;
|
||||
int i;
|
||||
dest = (char *) new_malloc(strlen(str) + 12);
|
||||
/* pad encoded string with 0 bits in case it's bogus */
|
||||
s = (char *) new_malloc(strlen(str) + 12);
|
||||
strcpy(s, str);
|
||||
p = s;
|
||||
while (*p)
|
||||
p++;
|
||||
for (i = 0; i < 12; i++)
|
||||
*p++ = 0;
|
||||
blowfish_init(key, strlen(key));
|
||||
p = s;
|
||||
d = dest;
|
||||
while (*p) {
|
||||
right = 0L;
|
||||
left = 0L;
|
||||
for (i = 0; i < 6; i++)
|
||||
right |= (base64dec(*p++)) << (i * 6);
|
||||
for (i = 0; i < 6; i++)
|
||||
left |= (base64dec(*p++)) << (i * 6);
|
||||
blowfish_decipher(&left, &right);
|
||||
for (i = 0; i < 4; i++)
|
||||
*d++ = (left & (0xff << ((3 - i) * 8))) >> ((3 - i) * 8);
|
||||
for (i = 0; i < 4; i++)
|
||||
*d++ = (right & (0xff << ((3 - i) * 8))) >> ((3 - i) * 8);
|
||||
}
|
||||
*d = 0;
|
||||
new_free(&s);
|
||||
return dest;
|
||||
}
|
||||
|
||||
#ifdef WANT_TCL
|
||||
static int tcl_encrypt STDVAR
|
||||
{
|
||||
char *p;
|
||||
BADARGS(3, 3, " key string");
|
||||
p = encrypt_string(argv[1], argv[2]);
|
||||
Tcl_AppendResult(irp, p, NULL);
|
||||
new_free(&p);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int tcl_decrypt STDVAR
|
||||
{
|
||||
char *p;
|
||||
BADARGS(3, 3, " key string");
|
||||
p = decrypt_string(argv[1], argv[2]);
|
||||
Tcl_AppendResult(irp, p, NULL);
|
||||
new_free(&p);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#endif /* WANT_TCL */
|
||||
|
||||
BUILT_IN_FUNCTION(ircii_encrypt)
|
||||
{
|
||||
char *p, *q, *r;
|
||||
if (!input)
|
||||
return m_strdup("1");
|
||||
p = input;
|
||||
if ((q = strchr(input, ' ')))
|
||||
{
|
||||
*q++ = 0;
|
||||
r = encrypt_string(p, q);
|
||||
return r;
|
||||
}
|
||||
return m_strdup(empty_string);
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(ircii_decrypt)
|
||||
{
|
||||
char *p, *q, *r;
|
||||
if (!input)
|
||||
return m_strdup("1");
|
||||
p = input;
|
||||
if ((q = strchr(input, ' ')))
|
||||
{
|
||||
*q++ = 0;
|
||||
r = decrypt_string(p, q);
|
||||
return r;
|
||||
}
|
||||
return m_strdup(empty_string);
|
||||
}
|
||||
|
||||
int Blowfish_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
int i;
|
||||
initialize_module("Blowfish");
|
||||
|
||||
for (i = 0; i < BOXES; i++) {
|
||||
blowbox[i].P = NULL;
|
||||
blowbox[i].S = NULL;
|
||||
blowbox[i].key[0] = 0;
|
||||
blowbox[i].lastuse = 0L;
|
||||
}
|
||||
#ifdef WANT_TCL
|
||||
Tcl_CreateCommand(tcl_interp, "encrypt", tcl_encrypt, NULL, NULL);
|
||||
Tcl_CreateCommand(tcl_interp, "decrypt", tcl_decrypt, NULL, NULL);
|
||||
Tcl_SetVar(tcl_interp, "blowfish_version", blowfish_version, TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
add_module_proc(ALIAS_PROC, "blowfish", "encrypt", "Blowfish Encryption", 0, 0, ircii_encrypt, NULL);
|
||||
add_module_proc(ALIAS_PROC, "blowfish", "decrypt", "Blowfish Decryption", 0, 0, ircii_decrypt, NULL);
|
||||
put_it("%s loaded.", blowfish_version);
|
||||
put_it("Adapted from eggdrop by By-Tor");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Blowfish_Cleanup(IrcCommandDll **intp)
|
||||
{
|
||||
#ifdef WANT_TCL
|
||||
Tcl_DeleteCommand(tcl_interp, "encrypt");
|
||||
Tcl_DeleteCommand(tcl_interp, "decrypt");
|
||||
Tcl_UnsetVar(tcl_interp, "blowfish_version", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
674
dll/blowfish/blowfish.doc
Normal file
674
dll/blowfish/blowfish.doc
Normal file
@@ -0,0 +1,674 @@
|
||||
Description of a New Variable-Length Key, 64-Bit Block Cipher
|
||||
(Blowfish)
|
||||
|
||||
Bruce Schneier
|
||||
Counterpane Systems, 730 Fair Oaks Ave, Oak Park, IL 60302
|
||||
schneier@chinet.com
|
||||
|
||||
|
||||
Abstract:
|
||||
|
||||
Blowfish, a new secret-key block cipher, is proposed. It is a
|
||||
Feistel network, iterating a simple encryption function 16 times.
|
||||
The block size is 64 bits, and the key can be any length up to
|
||||
448 bits. Although there is a complex initialization phase
|
||||
required before any encryption can take place, the actual
|
||||
encryption of data is very efficient on large microprocessors.
|
||||
|
||||
|
||||
|
||||
The cryptographic community needs to provide the world with a new
|
||||
encryption standard. DES [16], the workhorse encryption
|
||||
algorithm for the past fifteen years, is nearing the end of its
|
||||
useful life. Its 56-bit key size is vulnerable to a brute-force
|
||||
attack [22], and recent advances in differential cryptanalysis
|
||||
[1] and linear cryptanalysis [10] indicate that DES is vulnerable
|
||||
to other attacks as well.
|
||||
|
||||
Many of the other unbroken algorithms in the literature<72>Khufu
|
||||
[11,12], REDOC II [2,23, 20], and IDEA [7,8,9]<5D>are protected by
|
||||
patents. RC2 and RC4, approved for export with a small key size,
|
||||
are proprietary [18]. GOST [6], a Soviet government algorithm,
|
||||
is specified without the S-boxes. The U.S. government is moving
|
||||
towards secret algorithms, such as the Skipjack algorithm in the
|
||||
Clipper and Capstone chips [17].
|
||||
|
||||
If the world is to have a secure, unpatented, and freely-
|
||||
available encryption algorithm by the turn of the century, we
|
||||
need to develop several candidate encryption algorithms now.
|
||||
These algorithms can then be subjected to years of public
|
||||
scrutiny and cryptanalysis. Then, the hope is that one or more
|
||||
candidate algorithms will survive this process, and can
|
||||
eventually become a new standard.
|
||||
|
||||
This paper discusses the requirements for a standard encryption
|
||||
algorithm. While it may not be possible to satisfy all
|
||||
requirements with a single algorithm, it may be possible to
|
||||
satisfy them with a family of algorithms based on the same
|
||||
cryptographic principles.
|
||||
|
||||
AREAS OF APPLICATION
|
||||
|
||||
A standard encryption algorithm must be suitable for many
|
||||
different applications:
|
||||
|
||||
Bulk encryption. The algorithm should be efficient in
|
||||
encrypting data files or a continuous data stream.
|
||||
|
||||
Random bit generation. The algorithm should be efficient in
|
||||
producing single random bits.
|
||||
|
||||
Packet encryption. The algorithm should be efficient in
|
||||
encrypting packet-sized data. (An ATM packet has a 48-
|
||||
byte data field.) It should implementable in an
|
||||
application where successive packets may be encrypted
|
||||
or decrypted with different keys.
|
||||
|
||||
Hashing. The algorithm should be efficient in being
|
||||
converted to a one-way hash function.
|
||||
|
||||
PLATFORMS
|
||||
|
||||
A standard encryption algorithm must be implementable on a
|
||||
variety of different platforms, each with their own requirements.
|
||||
These include:
|
||||
|
||||
Special hardware. The algorithm should be efficiently
|
||||
implementable in custom VLSI hardware.
|
||||
|
||||
Large processors. While dedicated hardware will always be
|
||||
used for the fastest applications, software
|
||||
implementations are more common. The algorithm should
|
||||
be efficient on 32-bit microprocessors with 4 kbyte
|
||||
program and data caches.
|
||||
|
||||
Medium-size processors. The algorithm should run on
|
||||
microcontrollers and other medium-size processors, such
|
||||
as the 68HC11.
|
||||
|
||||
Small processors. It should be possible to implement the
|
||||
algorithm on smart cards, even inefficiently.
|
||||
|
||||
The requirements for small processors are the most difficult.
|
||||
RAM and ROM limitations are severe for this platform. Also,
|
||||
efficiency is more important on these small machines.
|
||||
Workstations double their capacity almost annually. Small
|
||||
embedded systems are the same year after year, and there is
|
||||
little capacity to spare. If there is a choice, the extra
|
||||
computation burden should be on large processors rather than
|
||||
small processors.
|
||||
|
||||
ADDITIONAL REQUIREMENTS
|
||||
|
||||
These additional requirements should, if possible, be levied on a
|
||||
standard encryption algorithm.
|
||||
|
||||
The algorithm should be simple to code. Experiences with
|
||||
DES [19] show that programmers will often make
|
||||
implementation mistakes if the algorithm is complicated. If
|
||||
possible, the algorithm should be robust against these
|
||||
mistakes.
|
||||
|
||||
The algorithm should have a flat keyspace, allowing any
|
||||
random bit string of the required length to be a possible
|
||||
key. There should be no weak keys.
|
||||
|
||||
The algorithm should facilitate easy key-management for
|
||||
software implementations. Software implementations of DES
|
||||
generally use poor key management techniques. In
|
||||
particular, the password that the user types in becomes the
|
||||
key. This means that although DES has a theoretical
|
||||
keyspace of 256, the actual keyspace is limited to keys
|
||||
constructed with the 95 characters of printable ASCII.
|
||||
Additionally, keys corresponding to words and near words are
|
||||
much more likely.
|
||||
|
||||
The algorithm should be easily modifiable for different
|
||||
levels of security, both minimum and maximum requirements.
|
||||
|
||||
All operations should manipulate data in byte-sized blocks.
|
||||
Where possible, operations should manipulate data in 32-bit
|
||||
blocks.
|
||||
|
||||
DESIGN DECISIONS
|
||||
|
||||
Based on the above parameters, we have made these design
|
||||
decisions. The algorithm should:
|
||||
|
||||
Manipulate data in large blocks, preferably 32 bits in size
|
||||
(and not in single bits, such as DES).
|
||||
|
||||
Have either a 64-bit or a 128-bit block size.
|
||||
|
||||
Have a scalable key, from 32 bits to at least 256 bits.
|
||||
|
||||
Use simple operations that are efficient on microprocessors:
|
||||
e.g., exclusive-or, addition, table lookup, modular-
|
||||
multiplication. It should not use variable-length shifts or
|
||||
bit-wise permutations, or conditional jumps.
|
||||
|
||||
Be implementable on an 8-bit processor with a minimum of 24
|
||||
bytes of RAM (in addition to the RAM required to store the
|
||||
key) and 1 kilobyte of ROM.
|
||||
|
||||
Employ precomputable subkeys. On large-memory systems,
|
||||
these subkeys can be precomputed for faster operation. Not
|
||||
precomputing the subkeys will result in slower operation,
|
||||
but it should still be possible to encrypt data without any
|
||||
precomputations.
|
||||
|
||||
Consist of a variable number of iterations. For
|
||||
applications with a small key size, the trade-off between
|
||||
the complexity of a brute-force attack and a differential
|
||||
attack make a large number of iterations superfluous.
|
||||
Hence, it should be possible to reduce the number of
|
||||
iterations with no loss of security (beyond that of the
|
||||
reduced key size).
|
||||
|
||||
If possible, have no weak keys. If not possible, the
|
||||
proportion of weak keys should be small enough to make it
|
||||
unlikely to choose one at random. Also, any weak keys
|
||||
should be explicitly known so they can be weeded out during
|
||||
the key generation process.
|
||||
|
||||
Use subkeys that are a one-way hash of the key. This would
|
||||
allow the use of long passphrases for the key without
|
||||
compromising security.
|
||||
|
||||
Have no linear structures (e.g., the complementation
|
||||
propertie of DES) that reduce the complexity of exhaustive
|
||||
search [4].
|
||||
|
||||
Use a design that is simple to understand. This will
|
||||
facilitate analysis and increase the confidence in the
|
||||
algorithm. In practice, this means that the algorithm will
|
||||
be a Feistel iterated block cipher [21].
|
||||
|
||||
Most of these design decisions are not new. Almost all block
|
||||
ciphers since Lucifer [5,21] are Feistel ciphers, and all have a
|
||||
flat keyspace (with the possible exception of a few weak keys).
|
||||
FEAL [13,14,15] and Khufu [11] use a variable number of
|
||||
iterations. Khufu [11] has a large number of subkeys that are a
|
||||
one-way function of the key. RC2 [18] has a variable-length key.
|
||||
GOST [6] uses a 32-bit word length and a 64-bit block size. MMB
|
||||
[2] uses a 32-bit word length and a 128-bit block size.
|
||||
|
||||
BUILDING BLOCKS
|
||||
|
||||
There are a number of building blocks that have been demonstrated
|
||||
to produce strong ciphers. Many of these can be efficiently
|
||||
implemented on 32-bit microprocessors.
|
||||
|
||||
Large S-boxes. Larger S-boxes are more resistant to
|
||||
differential cryptanalysis. An algorithm with a 32-bit word
|
||||
length can use 32-bit S-boxes. Khufu and REDOC III both use
|
||||
a 256-entry, 32-bit wide S-box [11,20].
|
||||
|
||||
Key-dependent S-boxes. While fixed S-boxes must be designed
|
||||
to be resistant to differential and linear cryptanalysis,
|
||||
key-dependent S-boxes are much more resistant to these
|
||||
attacks. They are used in the Khufu algorithm [11].
|
||||
Variable S-boxes, which could possibly be key dependent, are
|
||||
used in GOST [6].
|
||||
|
||||
Combining operations from different algebraic groups. The
|
||||
IDEA cipher introduced this concept, combining XOR mod 216,
|
||||
addition mod 216, and multiplication mod 216+1 [7]. The MMB
|
||||
cipher uses a 32-bit word, and combines XOR mod 232 with
|
||||
multiplication mod 232-1 [2].
|
||||
|
||||
Key-dependent permutations. The fixed initial and final
|
||||
permutations of DES have been long regarded as
|
||||
cryptographically worthless. Khufu XORs the text block with
|
||||
key material at the beginning and the end of the algorithm
|
||||
[11].
|
||||
|
||||
BLOWFISH
|
||||
|
||||
Blowfish is a variable-length key block cipher. It does not meet
|
||||
all the requirements for a new cryptographic standard discussed
|
||||
above: it is only suitable for applications where the key does
|
||||
not change often, like a communications link or an automatic file
|
||||
encryptor. It is significantly faster than DES when implemented
|
||||
on 32-bit microprocessors with large data caches, such as the
|
||||
Pentium and the PowerPC.
|
||||
|
||||
DESCRIPTION OF THE ALGORITHM
|
||||
|
||||
Blowfish is a variable-length key, 64-bit block cipher. The
|
||||
algorithm consists of two parts: a key-expansion part and a data-
|
||||
encryption part. Key expansion converts a key of at most 448
|
||||
bits into several subkey arrays totaling 4168 bytes.
|
||||
|
||||
Data encryption occurs via a 16-round Feistel network. Each
|
||||
round consists of a key-dependent permutation, and a key- and
|
||||
data-dependent substitution. All operations are XORs and
|
||||
additions on 32-bit words. The only additional operations are
|
||||
four indexed array data lookups per round.
|
||||
|
||||
Subkeys:
|
||||
|
||||
Blowfish uses a large number of subkeys. These keys must be
|
||||
precomputed before any data encryption or decryption.
|
||||
|
||||
1. The P-array consists of 18 32-bit subkeys:
|
||||
P1, P2,..., P18.
|
||||
|
||||
2. There are four 32-bit S-boxes with 256 entries each:
|
||||
S1,0, S1,1,..., S1,255;
|
||||
S2,0, S2,1,..,, S2,255;
|
||||
S3,0, S3,1,..., S3,255;
|
||||
S4,0, S4,1,..,, S4,255.
|
||||
|
||||
The exact method used to calculate these subkeys will be
|
||||
described later.
|
||||
|
||||
Encryption:
|
||||
|
||||
Blowfish is a Feistel network consisting of 16 rounds (see Figure
|
||||
1). The input is a 64-bit data element, x.
|
||||
|
||||
Divide x into two 32-bit halves: xL, xR
|
||||
For i = 1 to 16:
|
||||
xL = xL XOR Pi
|
||||
xR = F(xL) XOR xR
|
||||
Swap xL and xR
|
||||
Swap xL and xR (Undo the last swap.)
|
||||
xR = xR XOR P17
|
||||
xL = xL XOR P18
|
||||
Recombine xL and xR
|
||||
|
||||
Function F (see Figure 2):
|
||||
Divide xL into four eight-bit quarters: a, b, c, and d
|
||||
F(xL) = ((S1,a + S2,b mod 232) XOR S3,c) + S4,d mod 232
|
||||
|
||||
Decryption is exactly the same as encryption, except that P1,
|
||||
P2,..., P18 are used in the reverse order.
|
||||
|
||||
Implementations of Blowfish that require the fastest speeds
|
||||
should unroll the loop and ensure that all subkeys are stored in
|
||||
cache.
|
||||
|
||||
Generating the Subkeys:
|
||||
|
||||
The subkeys are calculated using the Blowfish algorithm. The
|
||||
exact method is as follows:
|
||||
|
||||
1. Initialize first the P-array and then the four S-boxes,
|
||||
in order, with a fixed string. This string consists of the
|
||||
hexadecimal digits of pi (less the initial 3). For example:
|
||||
|
||||
P1 = 0x243f6a88
|
||||
P2 = 0x85a308d3
|
||||
P3 = 0x13198a2e
|
||||
P4 = 0x03707344
|
||||
|
||||
2. XOR P1 with the first 32 bits of the key, XOR P2 with the
|
||||
second 32-bits of the key, and so on for all bits of the key
|
||||
(possibly up to P14). Repeatedly cycle through the key bits
|
||||
until the entire P-array has been XORed with key bits. (For
|
||||
every short key, there is at least one equivalent longer
|
||||
key; for example, if A is a 64-bit key, then AA, AAA, etc.,
|
||||
are equivalent keys.)
|
||||
|
||||
3. Encrypt the all-zero string with the Blowfish algorithm,
|
||||
using the subkeys described in steps (1) and (2).
|
||||
|
||||
4. Replace P1 and P2 with the output of step (3).
|
||||
|
||||
5. Encrypt the output of step (3) using the Blowfish
|
||||
algorithm with the modified subkeys.
|
||||
|
||||
6. Replace P3 and P4 with the output of step (5).
|
||||
|
||||
7. Continue the process, replacing all entries of the P-
|
||||
array, and then all four S-boxes in order, with the output
|
||||
of the continuously-changing Blowfish algorithm.
|
||||
|
||||
In total, 521 iterations are required to generate all required
|
||||
subkeys. Applications can store the subkeys rather than execute
|
||||
this derivation process multiple times.
|
||||
|
||||
MINI-BLOWFISH
|
||||
|
||||
The following mini versions of Blowfish are defined solely for
|
||||
cryptanalysis. They are not suggested for actual implementation.
|
||||
Blowfish-32 has a 32-bit block size and subkey arrays of 16-bit
|
||||
entries (each S-box has 16 entries). Blowfish-16 has a 16-bit
|
||||
block size and subkey arrays of 8-bit entries (each S-box has 4
|
||||
entries).
|
||||
|
||||
DESIGN DECISIONS
|
||||
|
||||
The underlying philosophy behind Blowfish is that simplicity of
|
||||
design yields an algorithm that is both easier to understand and
|
||||
easier to implement. Through the use of a streamlined Feistel
|
||||
network<EFBFBD>a simple S-box substitution and a simple P-box
|
||||
substitution<EFBFBD>I hope that the design will not contain any flaws.
|
||||
|
||||
A 64-bit block size yields a 32-bit word size, and maintains
|
||||
block-size compatibility with existing algorithms. Blowfish is
|
||||
easy to scale up to a 128-bit block, and down to smaller block
|
||||
sizes. Cryptanalysis of the mini-Blowfish variants may be
|
||||
significantly easier than cryptanalysis of the full version.
|
||||
|
||||
The fundamental operations were chosen with speed in mind. XOR,
|
||||
ADD, and MOV from a cache are efficient on both Intel and
|
||||
Motorola architectures. All subkeys fit in the cache of a 80486,
|
||||
68040, Pentium, and PowerPC.
|
||||
|
||||
The Feistel network that makes up the body of Blowfish is
|
||||
designed to be as simple as possible, while still retaining the
|
||||
desirable cryptographic properties of the structure. Figure 3 is
|
||||
round i of a general Feistel network: Rn,i are reversible
|
||||
functions of text and key, and Ni is a non-reversible function of
|
||||
text and key. For speed and simplicity, I chose XOR as my
|
||||
reversible function. This let me collapse the four XORs into a
|
||||
single XOR, since:
|
||||
|
||||
R<>1,i+1 = R1,i+1 XOR R2,i-1 XOR R3,i XOR R4,i
|
||||
|
||||
This is the P-array substitution in Blowfish. The XOR can also
|
||||
be considered to be part of the non-reversible function, Ni,
|
||||
occurring at the end of the function. (Although equivalent, I
|
||||
chose not to illustrate them in this way because it simplifies
|
||||
description of the subkey-generation process.) There are two
|
||||
XORs that remain after this reduction: R1 in the first round and
|
||||
R2 in the last round. I chose not to eliminate these in order to
|
||||
hide the input to the first non-reversible function.
|
||||
|
||||
I considered a more complicated reversible function, one with
|
||||
modular multiplications and rotations. However, these operations
|
||||
would greatly increase the algorithm's execution time. Since
|
||||
function F is the primary source of the algorithm's security, I
|
||||
decided to save time-consuming complications for that function.
|
||||
|
||||
Function F, the non-reversible function, gives Blowfish the best
|
||||
possible avalanche effect for a Feistel network: every text bit
|
||||
on the left half of the round affects every text bit on the right
|
||||
half. Additionally, since every subkey bit is affected by every
|
||||
key bit, the function also has a perfect avalanche effect between
|
||||
the key and the right half of the text after every round. Hence,
|
||||
the algorithm exhibits a perfect avalanche effect after three
|
||||
rounds and again every two rounds after that.
|
||||
|
||||
I considered adding a reversible mixing function, more
|
||||
complicated than XOR, before the first and after the last round.
|
||||
This would further confuse the entry values into the Feistel
|
||||
network and ensure a complete avalanche effect after the first
|
||||
two rounds. I eventually discarded the addition as a time-
|
||||
consuming complication with no clear cryptographic benefits.
|
||||
|
||||
The non-reversible function is designed for strength, speed, and
|
||||
simplicity. Ideally, I wanted a single S-box with 232 32-bit
|
||||
words, but that was impractical. My eventual choice of 256-entry
|
||||
S-boxes was a compromise between my three design goals. The
|
||||
small-number of bits to large-number of bits may have weaknesses
|
||||
with respect to linear cryptanalysis, but these weaknesses are
|
||||
hidden both by combining the output of four S-boxes and making
|
||||
them dependent on the key.
|
||||
|
||||
I used four different S-boxes instead of one S-box primarily to
|
||||
avoid symmetries when different bytes of the input are equal, or
|
||||
when the 32-bit input to function F is a bytewise permutation of
|
||||
another 32-bit input. I could have used one S-box and made each
|
||||
of the four different outputs a non-trivial permutation of the
|
||||
single output, but the four S-box design is faster, easier to
|
||||
program, and seems more secure.
|
||||
|
||||
The function that combines the four S-box outputs is as fast as
|
||||
possible. A simpler function would be to XOR the four values,
|
||||
but mixing addition mod 232 and XOR combines two different
|
||||
algebraic groups with no additional instructions. The
|
||||
alternation of addition and XOR ends with an addition operation
|
||||
because an XOR combines the final result with xR.
|
||||
|
||||
If the four indexes chose values out of the same S-box, a more
|
||||
complex combining function would be required to eliminate
|
||||
symmetries. I considered using a more complex combining function
|
||||
in Blowfish (using modular multiplications, rotations, etc.), but
|
||||
chose not to because the added complication seemed unnecessary.
|
||||
|
||||
The key-dependent S-boxes protect against differential and linear
|
||||
cryptanalysis. Since the structure of the S-boxes is completely
|
||||
hidden from the cryptanalyst, these attacks have a more difficult
|
||||
time exploiting that structure. While it would be possible to
|
||||
replace these variable S-boxes with four fixed S-boxes that were
|
||||
designed to be resistant to these attacks, key-dependent S-boxes
|
||||
are easier to implement and less susceptible to arguments of
|
||||
"hidden" properties. Additionally, these S-boxes can be created
|
||||
on demand, reducing the need for large data structures stored
|
||||
with the algorithm.
|
||||
|
||||
Each bit of xL is only used as the input to one S-box. In DES
|
||||
many bits are used as inputs to two S-boxes, which strengthens
|
||||
the algorithm considerably against differential attacks. I feel
|
||||
that this added complication is not as necessary with key-
|
||||
dependent S-boxes. Additionally, larger S-boxes would take up
|
||||
considerably more memory space.
|
||||
|
||||
Function F does not depend on the iteration. I considered adding
|
||||
this dependency, but did not feel that it had any cryptographic
|
||||
merit. The P-array substitution can be considered to be part of
|
||||
this function, and that is already iteration-dependent.
|
||||
|
||||
The number of rounds is set at 16 primarily out of desire to be
|
||||
conservative. However, this number affects the size of the P-
|
||||
array and therefore the subkey-generation process; 16 iterations
|
||||
permits key lengths up to 448 bits. I expect to be able to
|
||||
reduce this number, and greatly speed up the algorithm in the
|
||||
process, as I accumulate more cryptanalysis data.
|
||||
|
||||
In algorithm design, there are two basic ways to ensure that the
|
||||
key is long enough to ensure a particular security level. One is
|
||||
to carefully design the algorithm so that the entire entropy of
|
||||
the key is preserved, so there is no better way to cryptanalyze
|
||||
the algorithm other than brute force. The other is to design the
|
||||
algorithm with so many key bits that attacks that reduce the
|
||||
effective key length by several bits are irrelevant. Since
|
||||
Blowfish is designed for large microprocessors with large amounts
|
||||
of memory, I chose the latter.
|
||||
|
||||
The subkey generation process is designed to preserve the entire
|
||||
entropy of the key and to distribute that entropy uniformly
|
||||
throughout the subkeys. It is also designed to distribute the
|
||||
set of allowed subkeys randomly throughout the domain of possible
|
||||
subkeys. I chose the digits of pi as the initial subkey table
|
||||
for two reasons: because it is a random sequence not related to
|
||||
the algorithm, and because it could either be stored as part of
|
||||
the algorithm or derived when needed. There is nothing sacred
|
||||
about pi; any string of random bits<74>digits of e, RAND tables,
|
||||
output of a random number generator<6F>will suffice. However, if
|
||||
the initial string is non-random in any way (for example, ASCII
|
||||
text with the high bit of every byte a 0), this non-randomness
|
||||
will propagate throughout the algorithm.
|
||||
|
||||
In the subkey generation process, the subkeys change slightly
|
||||
with every pair of subkeys generated. This is primarily to
|
||||
protect against any attacked of the subkey generation process
|
||||
that exploit the fixed and known subkeys. It also reduces
|
||||
storage requirements. The 448 limit on the key size ensures that
|
||||
the every bit of every subkey depends on every bit of the key.
|
||||
(Note that every bit of P15, P16, P17, and P18 does not affect every
|
||||
bit of the ciphertext, and that any S-box entry only has a .06
|
||||
probability of affecting any single ciphertext block.)
|
||||
|
||||
The key bits are repeatedly XORed with the digits of pi in the
|
||||
initial P-array to prevent the following potential attack:
|
||||
Assume that the key bits are not repeated, but instead padded
|
||||
with zeros to extend it to the length of the P-array. An
|
||||
attacker might find two keys that differ only in the 64-bit value
|
||||
XORed with P1 and P2 that, using the initial known subkeys,
|
||||
produce the same encrypted value. If so, he can find two keys
|
||||
that produce all the same subkeys. This is a highly tempting
|
||||
attack for a malicious key generator.
|
||||
|
||||
To prevent this same type of attack, I fixed the initial
|
||||
plaintext value in the subkey-generation process. There is
|
||||
nothing special about the all-zeros string, but it is important
|
||||
that this value be fixed.
|
||||
|
||||
The subkey-generation algorithm does not assume that the key bits
|
||||
are random. Even highly correlated key bits, such as an
|
||||
alphanumeric ASCII string with the bit of every byte set to 0,
|
||||
will produce random subkeys. However, to produce subkeys with
|
||||
the same entropy, a longer alphanumeric key is required.
|
||||
|
||||
The time-consuming subkey-generation process adds considerable
|
||||
complexity for a brute-force attack. The subkeys are too long to
|
||||
be stored on a massive tape, so they would have to be generated
|
||||
by a brute-force cracking machine as required. A total of 522
|
||||
iterations of the encryption algorithm are required to test a
|
||||
single key, effectively adding 29 steps to any brute-force
|
||||
attack.
|
||||
|
||||
POSSIBLE SIMPLIFICATIONS
|
||||
|
||||
I am exploring several possible simplifications, aimed at
|
||||
decreasing memory requirements and execution time. These are
|
||||
outlined below:
|
||||
|
||||
Fewer and smaller S-boxes. It may be possible to reduce the
|
||||
number of S-boxes from four to one. Additionally, it may be
|
||||
possible to overlap entries in a single S-box: entry 0 would
|
||||
consist of bytes 0 through 3, entry 1 would consist of bytes
|
||||
1 through 4, etc. The former simplification would reduce
|
||||
the memory requirements for the four S-boxes from 4096 bytes
|
||||
to 1024 bytes, the latter would reduce the requirements for
|
||||
a single S-box from 1024 bytes to 259 bytes. Additional
|
||||
steps may be required to eliminate the symmetries that these
|
||||
simplifications would introduce. Additionally, four
|
||||
different 10- or 12-bit indexes into a single large S-box
|
||||
could be used instead of the current series of S-boxes.
|
||||
|
||||
Fewer iterations. It is probably safe to reduce the number
|
||||
of iterations from 16 to 8 without compromising security.
|
||||
The number of iterations required for security may be
|
||||
dependent on the length of the key. Note that with the
|
||||
current subkey generation procedure, an 8-iteration
|
||||
algorithm cannot accept a key longer than 192 bits.
|
||||
|
||||
On-the-fly subkey calculation. The current method of subkey
|
||||
calculation requires all subkeys to be calculated advance of
|
||||
any data encryption. In fact, it is impossible to calculate
|
||||
the last subkey of the last S-box without calculating every
|
||||
subkey that comes before. An alternate method of subkey
|
||||
calculation would be preferable: one where every subkey can
|
||||
be calculated independently of any other. High-end
|
||||
implementations could still precompute the subkeys for
|
||||
increased speed, but low-end applications could only compute
|
||||
the required subkeys when needed.
|
||||
|
||||
CONCLUSIONS
|
||||
|
||||
I conjecture that the most efficient way to break Blowfish is
|
||||
through exhaustive search of the keyspace. I encourage all
|
||||
cryptanalytic attacks, modifications, and improvements to the
|
||||
algorithm. Attacks on mini versions of Blowfish, those with a
|
||||
32- or even a 16-bit block size, are also encouraged. Source
|
||||
code in C and test data can be provided to anyone wishing to
|
||||
implement the algorithm, in accordance with U.S. export laws.
|
||||
|
||||
The software magazine Dr. Dobbs Journal is sponsoring $1000
|
||||
contest for the best cryptanalysis of Blowfish received before
|
||||
April 1995. Please contact me for details.
|
||||
|
||||
Blowfish is unpatented, and will remain so in all countries. The
|
||||
algorithm is hereby placed in the public domain, and can be
|
||||
freely used by anyone.
|
||||
|
||||
ACKNOWLEDGEMENTS
|
||||
|
||||
Much of the motivation for this algorithm, as well as the design
|
||||
criteria, was developed with Niels Fergusen. I would also like
|
||||
to thank Eli Biham, Agnes Chan, Peter Gutmann, Angel Johnston,
|
||||
Lars Kundsen, and Matt Robshaw for their helpful suggestions.
|
||||
|
||||
|
||||
REFERENCES
|
||||
|
||||
1. E. Biham and A. Shamir, Differential Cryptanalysis of the
|
||||
Data Encryption Standard, Springer-Verlag, 1993.
|
||||
|
||||
2. T.W. Cusick and M.C. Wood, "The REDOC-II Cryptosystem,"
|
||||
Advances in Cryptology<67>CRYPTO '90 Proceedings, Springer-
|
||||
Verlag, 1991, pp. 545-563.
|
||||
|
||||
3. J. Deamen, R. Govaerts, and J. Vandewalle, "Block Ciphers
|
||||
Based on Modular Arithmetic," Proceedings of the 3rd
|
||||
Symposium on State and Progress of Research in Cryptography,
|
||||
Rome, Italy, 15-16 Feb 1993, pp. 80-89.
|
||||
|
||||
4. J.-H. Evertse, "Linear Structures in Blockciphers," Advances
|
||||
in Cryptology<67>EUROCRPYT '87, Springer-Verlag, 1988, pp. 249-
|
||||
266.
|
||||
|
||||
5. H. Feistel, "Cryptography and Computer Privacy," Scientific
|
||||
American, v. 228, n. 5, May 73, pp. 15-23.
|
||||
|
||||
6. GOST 28147-89, "Cryptographic Protection for Data Processing
|
||||
Systems," "Cryptographic Transformation Algorithm,"
|
||||
Government Standard of the U.S.S.R., Inv. No. 3583, UDC
|
||||
681.325.6:006.354. (in Russian)
|
||||
|
||||
7. X. Lai, J. Massey, and S. Murphy, "Markov Ciphers and
|
||||
Differential Cryptanalysis," Advances in
|
||||
Cryptology<67>EUROCRYPT '91 Proceedings, Springer-Verlag, 1991,
|
||||
pp. 17-38.
|
||||
|
||||
8. J.L. Massey and X. Lai, "Device for Converting a Digital
|
||||
Block and the Use Thereof," International Patent
|
||||
PCT/CH91/00117, 16 May 1991.
|
||||
|
||||
9. J.L. Massey and X. Lai, "Device for the Conversion of a
|
||||
Digital Block and Use of Same," U.S. Patent 5,214,703, 25
|
||||
May 1993.
|
||||
|
||||
10. M. Matsui, "Linear Cryptanalysis Method for DES Cipher,"
|
||||
Advances in Cryptology<67>CRYPTO '93 Proceedings, Springer-
|
||||
Verlag, 1994, in preparation.
|
||||
|
||||
11. R.C. Merkle, "Fast Software Encryption Functions," Advances
|
||||
in Cryptology<67>CRYPTO '90 Proceedings, Springer-Verlag, 1991,
|
||||
pp. 476-501.
|
||||
|
||||
12. R.C. Merkle, "Method and Apparatus for Data Encryption,"
|
||||
U.S. Patent 5,003,597, 26 Mar 1991.
|
||||
|
||||
13. S. Miyaguchi, "The FEAL-8 Cryptosystem and Call for Attack,"
|
||||
Advances in Cryptology<67>CRYPTO '89 Proceedings, Springer-
|
||||
Verlag, 1990, pp. 624-627.
|
||||
|
||||
14. S. Miyaguchi, "Expansion of the FEAL Cipher," NTT Review, v.
|
||||
2, n. 6, Nov 1990.
|
||||
|
||||
15. S. Miyaguchi, "The FEAL Cipher Family," Advances in
|
||||
Cryptology<67>CRYPTO '90 Proceedings, Springer-Verlag, 1991,
|
||||
pp. 627-638.
|
||||
|
||||
16. National Bureau of Standards, Data Encryption Standard, U.S.
|
||||
Department of Commerce, FIPS Publication 46, Jan 1977.
|
||||
|
||||
17. National Institute of Standards and Technology, "Clipper
|
||||
Chip Technology," 30 Apr 1993.
|
||||
|
||||
18. RSA Laboratories, Answers to Frequently Asked Questions
|
||||
About Today's Cryptography, Revision 2.0, RSA Data Security
|
||||
Inc., 5 Oct 1993.
|
||||
|
||||
19. B. Schneier, "Data Guardians," MacWorld, Feb 1993, 145-151.
|
||||
|
||||
20. B. Schneier, Applied Cryptography, John Wiley & Sons, New
|
||||
York, 1994.
|
||||
|
||||
21. J.L Smith, The Design of Lucifer, A Cryptographic Device for
|
||||
Data Communication, RC 3326, White Plains: IBM Research.
|
||||
|
||||
22. M.J. Weiner, "Efficient DES Key Search," Advances in
|
||||
Cryptology<67>CRYPTO '93 Proceedings, Springer-Verlag, in
|
||||
preparation.
|
||||
|
||||
23. M.C. Wood, "Method of Cryptographically Transforming
|
||||
Electronic Digital Data from One Form to Another," U.S.
|
||||
Patent 5,003,596, 26 Mar 1991.
|
||||
|
||||
86
dll/blowfish/blowfish.h
Normal file
86
dll/blowfish/blowfish.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "ctcp.h"
|
||||
#include "status.h"
|
||||
#include "lastlog.h"
|
||||
#include "server.h"
|
||||
#include "screen.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "hash2.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WANT_TCL
|
||||
# include <tcl.h>
|
||||
# include "tcl_bx.h"
|
||||
|
||||
#ifndef STDVAR
|
||||
# define STDVAR (ClientData cd, Tcl_Interp *irp, int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifndef BADARGS
|
||||
#define BADARGS(nl,nh,example) \
|
||||
if ((argc<(nl)) || (argc>(nh))) { \
|
||||
Tcl_AppendResult(intp,"wrong # args: should be \"",argv[0], \
|
||||
(example),"\"",NULL); \
|
||||
return TCL_ERROR; \
|
||||
}
|
||||
#endif /* BADARGS */
|
||||
|
||||
#endif /* WANT_TCL */
|
||||
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#define MAXKEYBYTES 56 /* 448 bits */
|
||||
#define bf_N 16
|
||||
#define noErr 0
|
||||
#define DATAERROR -1
|
||||
#define KEYBYTES 8
|
||||
|
||||
#define UBYTE_08bits unsigned char
|
||||
#define UWORD_16bits unsigned short
|
||||
|
||||
# define UWORD_32bits unsigned int
|
||||
/*
|
||||
#else
|
||||
# if SIZEOF_LONG==4
|
||||
# define UWORD_32bits unsigned long
|
||||
# endif
|
||||
#endif
|
||||
*/
|
||||
/* choose a byte order for your hardware */
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
/* ABCD - big endian - motorola */
|
||||
union aword {
|
||||
UWORD_32bits word;
|
||||
UBYTE_08bits byte [4];
|
||||
struct {
|
||||
unsigned int byte0:8;
|
||||
unsigned int byte1:8;
|
||||
unsigned int byte2:8;
|
||||
unsigned int byte3:8;
|
||||
} w;
|
||||
};
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* DCBA - little endian - intel */
|
||||
union aword {
|
||||
UWORD_32bits word;
|
||||
UBYTE_08bits byte [4];
|
||||
struct {
|
||||
unsigned int byte3:8;
|
||||
unsigned int byte2:8;
|
||||
unsigned int byte1:8;
|
||||
unsigned int byte0:8;
|
||||
} w;
|
||||
};
|
||||
#endif /* !WORDS_BIGENDIAN */
|
||||
33
dll/blowfish/blowfish.sh
Normal file
33
dll/blowfish/blowfish.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
RM=rm
|
||||
CP=cp
|
||||
|
||||
$GCC -I../../include -c blowfish.c
|
||||
|
||||
echo EXPORTS > blowfish.def
|
||||
$NM blowfish.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> blowfish.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file blowfish.base --dll -o blowfish.dll blowfish.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname blowfish.dll --def blowfish.def --base-file\
|
||||
blowfish.base --output-exp blowfish.exp
|
||||
$LD --base-file blowfish.base blowfish.exp --dll -o blowfish.dll blowfish.o\
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname blowfish.dll --def blowfish.def --base-file\
|
||||
blowfish.base --output-exp blowfish.exp
|
||||
$LD blowfish.exp --dll -o blowfish.dll blowfish.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the blowfishB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname blowfish.dll --def blowfish.def --output-lib blowfish.a
|
||||
|
||||
$RM *.base *.exp *.def
|
||||
$CP *.dll ..
|
||||
74
dll/blowfish/bot-crypt.tcl
Normal file
74
dll/blowfish/bot-crypt.tcl
Normal file
@@ -0,0 +1,74 @@
|
||||
global crypttimeout cryptlength
|
||||
set crypttimeout 60
|
||||
set cryptlength 50
|
||||
#borrowed from alltools.tcl
|
||||
proc randstring {count} {
|
||||
set rs ""
|
||||
for {set j 0} {$j < $count} {incr j} {
|
||||
set x [rand 62]
|
||||
append rs [string range "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" $x $x]
|
||||
}
|
||||
unset x
|
||||
unset j
|
||||
return $rs
|
||||
}
|
||||
|
||||
bind msg o crypt_op crypt_challenge
|
||||
bind msg o crypt_reply crypt_response
|
||||
|
||||
proc crypt_challenge {n u h a} {
|
||||
global cryptlist crypttimeout crypt_string cryptlength
|
||||
set ln [string tolower $n]
|
||||
if {[llength [getuser $h XTRA crypt]] != 2} {
|
||||
putserv "notice $n :You have no crypt keys set."
|
||||
return 0
|
||||
}
|
||||
if [info exists cryptlist($ln)] {
|
||||
putlog "Ignoring outstanding crypt-op request from $n."
|
||||
return 0
|
||||
} {
|
||||
set cryptlist($ln) [utimer $crypttimeout "unset cryptlist($ln)"]
|
||||
putserv "privmsg $ln :crypt_op [encrypt [lindex [getuser $h XTRA crypt] 0] [set crypt_string($ln) [randstring $cryptlength]]]"
|
||||
}
|
||||
}
|
||||
|
||||
proc crypt_response {n u h a} {
|
||||
global cryptlist crypt_string
|
||||
set ln [string tolower $n]
|
||||
if {![info exists cryptlist($ln)]} {
|
||||
putlog "Ignoring unrequested or late crypt response from $n."
|
||||
return 0
|
||||
}
|
||||
if {![string compare $crypt_string($ln) [decrypt [lindex [getuser $h XTRA crypt] 1] $a]]} {
|
||||
killutimer $cryptlist($ln)
|
||||
unset cryptlist($ln)
|
||||
foreach chan [channels] {
|
||||
if [onchan $n $chan] {
|
||||
pushmode $chan +o $n
|
||||
}
|
||||
}
|
||||
putlog "($n@$u) !$h! crypt-op"
|
||||
} {
|
||||
putlog "$n ($h) FAILED crypt authorization!"
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
bind dcc o crypt crypt_set
|
||||
|
||||
proc crypt_set {h i a} {
|
||||
if {[llength $a] != 2} {
|
||||
putdcc $i "Usage: crypt <key1> <key2>"
|
||||
return 0
|
||||
}
|
||||
putdcc $i "Key1: [lindex $a 0] key2: [lindex $a 1]"
|
||||
if {![string compare [lindex $a 0] [lindex $a 1]]} {
|
||||
putdcc $i "key1 and key2 MUST be different."
|
||||
return 0
|
||||
}
|
||||
setuser $h XTRA crypt $a
|
||||
putdcc $i "Set crypt keys to \"[lindex $a 0]\" and \"[lindex $a 1]\""
|
||||
putlog "#$h# crypt ..."
|
||||
return 0
|
||||
}
|
||||
|
||||
132
dll/blowfish/op-crypt.tcl
Normal file
132
dll/blowfish/op-crypt.tcl
Normal file
@@ -0,0 +1,132 @@
|
||||
if {![info exists blowfish_version]} {
|
||||
putscr "You MUST load the blowfish encryption module prior to loading this!"
|
||||
return
|
||||
}
|
||||
global crypt_timeout cryptfile
|
||||
set crypt_timeout 60
|
||||
set cryptfile "/home/by-tor/.BitchX/cryptkeys"
|
||||
|
||||
#borrowed from alltools.tcl
|
||||
proc randstring {count} {
|
||||
set rs ""
|
||||
for {set j 0} {$j < $count} {incr j} {
|
||||
set x [rand 62]
|
||||
append rs [string range "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" $x $x]
|
||||
}
|
||||
unset x
|
||||
unset j
|
||||
return $rs
|
||||
}
|
||||
|
||||
proc crop {n args} {
|
||||
global cryptkeeper cryptlist crypt_timeout
|
||||
set ln [string tolower $n]
|
||||
if {([onchan $n [_T]]) && ([isop $n [_T]])} {
|
||||
if {![info exists cryptkeeper($ln)]} {
|
||||
putscr "You must first set a pair of crypt keys before using this."
|
||||
putscr "Try /addcrypt <nick> <key1> <key2>"
|
||||
return
|
||||
}
|
||||
putserv "privmsg $n :crypt_op"
|
||||
set cryptlist($ln) [utimer $crypt_timeout "killcrypt $n"]
|
||||
} {
|
||||
putscr "$n is not on [_T], or is not an op."
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
proc killcrypt {n} {
|
||||
global cryptlist
|
||||
if [info exists cryptlist($n)] { unset cryptlist($n) }
|
||||
}
|
||||
|
||||
bind msg -1 crypt_op crypt_response
|
||||
|
||||
proc crypt_response {n u h a} {
|
||||
global cryptkeeper cryptlist
|
||||
set ln [string tolower $n]
|
||||
if {![info exists cryptlist($ln)]} {
|
||||
putscr "$n requesting UNAUTHORIZED crypt verification!"
|
||||
return
|
||||
} {
|
||||
killutimer $cryptlist($ln)
|
||||
unset cryptlist($ln)
|
||||
putserv "privmsg $n :crypt_reply [encrypt [lindex $cryptkeeper($ln) 1] [decrypt [lindex $cryptkeeper($ln) 0] $a]]"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
proc addcrypt {n k1 k2 args} {
|
||||
global cryptkeeper
|
||||
set cryptkeeper([string tolower $n]) "$k1 $k2"
|
||||
putscr "Added $n to the crypt keeper with keys $k1 and $k2."
|
||||
savecrypt
|
||||
}
|
||||
|
||||
proc savecrypt {} {
|
||||
global cryptfile cryptkeeper filekey
|
||||
if {![info exists cryptkeeper]} { return 0 }
|
||||
if [set fd [open $cryptfile w]] {
|
||||
if [info exists filekey] {
|
||||
puts $fd "encrypted"
|
||||
puts $fd [encrypt $filekey verified]
|
||||
foreach name [array names cryptkeeper] {
|
||||
puts $fd [encrypt $filekey "$name $cryptkeeper($name)"]
|
||||
}
|
||||
} {
|
||||
foreach name [array names cryptkeeper] {
|
||||
puts $fd "$name $cryptkeeper($name)"
|
||||
}
|
||||
}
|
||||
close $fd
|
||||
}
|
||||
}
|
||||
|
||||
proc readcrypt {args} {
|
||||
global cryptfile cryptkeeper filekey
|
||||
if [file exists $cryptfile] {
|
||||
if [info exists cryptkeeper] { unset cryptkeeper }
|
||||
set fd [open $cryptfile r]
|
||||
set text [gets $fd]
|
||||
# Is our file encrypted? (Maximum security here!)
|
||||
if {![string compare "encrypted" $text]} {
|
||||
set text [gets $fd]
|
||||
if {[llength $args] < 1} {
|
||||
return "You must supply a file key for the encrypted file."
|
||||
}
|
||||
set filekey [lindex $args 0]
|
||||
if {![string compare "verified" [decrypt $filekey $text]]} {
|
||||
while {![eof $fd]} {
|
||||
set text [decrypt $filekey [gets $fd]]
|
||||
if {[llength $text] == 3} {
|
||||
set cryptkeeper([lindex $text 0]) [lrange $text 1 end]
|
||||
}
|
||||
}
|
||||
return
|
||||
} {
|
||||
return "Invalid cryptfile key."
|
||||
}
|
||||
}
|
||||
while {![eof $fd]} {
|
||||
set text [gets $fd]
|
||||
if {[llength $text] == 3} {
|
||||
set cryptkeeper([lindex $text 0]) [lrange $text 1 end]
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
proc filekey {args} {
|
||||
global filekey cryptkeeper
|
||||
if {[llength $args] > 0} {
|
||||
set filekey [lindex $args 0]
|
||||
if [info exists cryptkeeper] { savecrypt }
|
||||
return "Set crypt file key to \"$filekey\""
|
||||
} {
|
||||
return "You must supply a key!"
|
||||
}
|
||||
}
|
||||
|
||||
readcrypt
|
||||
return
|
||||
175
dll/cavlink/Makefile.in
Normal file
175
dll/cavlink/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = cavlink
|
||||
|
||||
all: Makefile cavlink$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
cavlink.o: $(srcdir)/cavlink.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/cavlink.c
|
||||
|
||||
cavlink$(SHLIB_SUFFIX): cavlink.o ../dllinit.o
|
||||
$(SHLIB_LD) cavlink.o ../dllinit.o ${SHLIB_CFLAGS} -o cavlink$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.a *.so *.dll cavlink$(SHLIB_SUFFIX) *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
1342
dll/cavlink/cavlink.c
Normal file
1342
dll/cavlink/cavlink.c
Normal file
File diff suppressed because it is too large
Load Diff
27
dll/cavlink/cavlink.sh
Normal file
27
dll/cavlink/cavlink.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
|
||||
$GCC -I../../include -c cavlink.c
|
||||
|
||||
echo EXPORTS > cavlink.def
|
||||
$NM cavlink.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> cavlink.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file cavlink.base --dll -o cavlink.dll cavlink.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname cavlink.dll --def cavlink.def --base-file\
|
||||
cavlink.base --output-exp cavlink.exp
|
||||
$LD --base-file cavlink.base cavlink.exp --dll -o cavlink.dll cavlink.o\
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname cavlink.dll --def cavlink.def --base-file\
|
||||
cavlink.base --output-exp cavlink.exp
|
||||
$LD cavlink.exp --dll -o cavlink.dll cavlink.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the cavlinkB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname cavlink.dll --def cavlink.def --output-lib cavlink.a
|
||||
175
dll/cdrom/Makefile.in
Normal file
175
dll/cdrom/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = cdrom
|
||||
|
||||
all: Makefile cdrom$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
cdrom.o: $(srcdir)/cdrom.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/cdrom.c
|
||||
|
||||
cdrom$(SHLIB_SUFFIX): cdrom.o ../dllinit.o
|
||||
$(SHLIB_LD) cdrom.o ../dllinit.o ${SHLIB_CFLAGS} -o cdrom$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.a *.dll cdrom$(SHLIB_SUFFIX) *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
410
dll/cdrom/cdrom.c
Normal file
410
dll/cdrom/cdrom.c
Normal file
@@ -0,0 +1,410 @@
|
||||
/*
|
||||
* cdrom.c: This file handles all the CDROM routines, in BitchX
|
||||
*
|
||||
* Written by Tom Zickel
|
||||
* a.k.a. IceBreak on the irc
|
||||
*
|
||||
* Copyright(c) 1996
|
||||
* Modified Colten Edwards aka panasync.
|
||||
*
|
||||
*/
|
||||
#ifdef __linux__
|
||||
#define CDROM_VERSION "0.02"
|
||||
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#define MODULE_CDROM
|
||||
#include "cdrom.h"
|
||||
#include "output.h"
|
||||
#include "misc.h"
|
||||
#include "vars.h"
|
||||
|
||||
#include "module.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#define cparse(s) convert_output_format(s, NULL, NULL)
|
||||
|
||||
static int drive = 0;
|
||||
|
||||
static char cdrom_prompt[]="%gC%Gd%gROM%w";
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
static struct cdrom_tochdr hdr;
|
||||
static struct cdrom_ti ti;
|
||||
#else
|
||||
static struct ioc_toc_header hdr;
|
||||
#include <sys/disklabel.h>
|
||||
#define MOUNT_CD9660 FS_ISO9660
|
||||
#endif
|
||||
|
||||
static struct cdrom_etocentry TocEntry[101];
|
||||
|
||||
static char *cd_device = NULL;
|
||||
|
||||
static int cd_init(char *);
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
void play_chunk(int start, int end)
|
||||
{
|
||||
struct cdrom_msf msf;
|
||||
|
||||
end--;
|
||||
if (start >= end)
|
||||
start = end-1;
|
||||
|
||||
msf.cdmsf_min0 = start / (60*75);
|
||||
msf.cdmsf_sec0 = (start % (60*75)) / 75;
|
||||
msf.cdmsf_frame0 = start % 75;
|
||||
msf.cdmsf_min1 = end / (60*75);
|
||||
msf.cdmsf_sec1 = (end % (60*75)) / 75;
|
||||
msf.cdmsf_frame1 = end % 75;
|
||||
|
||||
if (ioctl(drive, CDROMSTART))
|
||||
{
|
||||
put_it("%s: Could not start the cdrom",cparse(cdrom_prompt));
|
||||
return;
|
||||
}
|
||||
if (ioctl(drive, CDROMPLAYMSF, &msf))
|
||||
{
|
||||
put_it("%s: Could not play the track",cparse(cdrom_prompt));
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int check_cdrom_str(void)
|
||||
{
|
||||
if (cd_device)
|
||||
return 1;
|
||||
put_it("%s: /CDDEVICE - The name of the CDROM device",cparse(cdrom_prompt));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void lba2msf(int lba, unsigned char *msf)
|
||||
{
|
||||
#if !defined(CD_BLOCK_OFFSET)
|
||||
#define CD_BLOCK_OFFSET CD_MSF_OFFSET
|
||||
#endif
|
||||
lba += CD_BLOCK_OFFSET;
|
||||
msf[0] = lba / (CD_SECS*CD_FRAMES);
|
||||
lba %= CD_SECS*CD_FRAMES;
|
||||
msf[1] = lba / CD_FRAMES;
|
||||
msf[2] = lba % CD_FRAMES;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cd_init(char *dev)
|
||||
{
|
||||
int i, rc, pos;
|
||||
|
||||
if (!dev || ((drive = open(dev, O_RDONLY)) < 0))
|
||||
return (-1);
|
||||
|
||||
if ((rc = ioctl(drive, CDROMREADTOCHDR, &hdr)) == -1)
|
||||
{
|
||||
put_it("%s: can't get TocHeader (error %d).",cparse(cdrom_prompt), rc);
|
||||
return (-2);
|
||||
}
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
for (i=1;i<=hdr.cdth_trk1+1;i++)
|
||||
{
|
||||
if (i!=hdr.cdth_trk1+1)
|
||||
TocEntry[i].cdte_track = i;
|
||||
else
|
||||
TocEntry[i].cdte_track = CDROM_LEADOUT;
|
||||
TocEntry[i].cdte_format = CDROM_MSF;
|
||||
if (ioctl(drive,CDROMREADTOCENTRY,&TocEntry[i]))
|
||||
put_it("%s: Can't get TocEntry #%d",cparse(cdrom_prompt), i);
|
||||
else
|
||||
{
|
||||
TocEntry[i].avoid=TocEntry[i].cdte_ctrl & CDROM_DATA_TRACK ? 1 : 0;
|
||||
TocEntry[i].m_length = TocEntry[i].cdte_addr.msf.minute * 60 + TocEntry[i].cdte_addr.msf.second;
|
||||
TocEntry[i].m_start = TocEntry[i].m_length * 75 + TocEntry[i].cdte_addr.msf.frame;
|
||||
}
|
||||
}
|
||||
|
||||
pos = TocEntry[1].m_length;
|
||||
|
||||
for (i=1;i<=hdr.cdth_trk1+1;i++)
|
||||
{
|
||||
TocEntry[i].m_length = TocEntry[i+1].m_length - pos;
|
||||
pos = TocEntry[i+1].m_length;
|
||||
if (TocEntry[i].avoid)
|
||||
TocEntry[i].m_length = (TocEntry[i+1].m_start - TocEntry[i+1].m_start) *2;
|
||||
}
|
||||
return (hdr.cdth_trk1);
|
||||
#else
|
||||
for (i = hdr.starting_track; i <= hdr.ending_track; i++)
|
||||
{
|
||||
TocEntry[i].avoid=0;
|
||||
TocEntry[i].m_start=1;
|
||||
TocEntry[i].m_length=1;
|
||||
}
|
||||
return (hdr.ending_track);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int check_mount(char *device)
|
||||
{
|
||||
#ifndef __FreeBSD__
|
||||
FILE *fp;
|
||||
struct mntent *mnt;
|
||||
|
||||
if ((fp = setmntent(MOUNTED, "r")) == NULL)
|
||||
return 0;
|
||||
|
||||
while ((mnt = getmntent (fp)) != NULL)
|
||||
{
|
||||
if (!strcmp (mnt->mnt_type, "iso9660") && !strcmp (mnt->mnt_fsname, device))
|
||||
{
|
||||
endmntent(fp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
endmntent (fp);
|
||||
#else
|
||||
struct statfs *mntinfo;
|
||||
int i,count;
|
||||
|
||||
if (!(count = getmntinfo(&mntinfo,MNT_WAIT|MOUNT_CD9660)))
|
||||
return 0;
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
if (strstr(mntinfo[i].f_mntfromname,device) && !stricmp(mntinfo[i].f_dstypename, "iso9660"))
|
||||
return 0;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(set_cd_device)
|
||||
{
|
||||
char *str;
|
||||
int code;
|
||||
if (!(str = next_arg(args , &args)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (drive)
|
||||
close(drive);
|
||||
if (!str || !check_mount(str))
|
||||
{
|
||||
put_it("%s: ERROR: CDROM is already mounted, please unmount, and try again",cparse(cdrom_prompt));
|
||||
new_free(&cd_device);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((code = cd_init(str)) < 0)
|
||||
{
|
||||
put_it("%s: ERROR(%d): Could not initalize the CDROM, check if a disk is inside",cparse(cdrom_prompt), code);
|
||||
new_free(&cd_device);
|
||||
return;
|
||||
}
|
||||
put_it("%s: CDROM device is now set to - %s",cparse(cdrom_prompt),str);
|
||||
malloc_strcpy(&cd_device, str);
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_stop)
|
||||
{
|
||||
if (!check_cdrom_str())
|
||||
return;
|
||||
if (!ioctl(drive, CDROMSTOP))
|
||||
put_it("%s: Stopped playing cdrom",cparse(cdrom_prompt));
|
||||
else
|
||||
put_it("%s: Stopped playing cdrom",cparse(cdrom_prompt));
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_eject)
|
||||
{
|
||||
if (!check_cdrom_str() || !drive)
|
||||
return;
|
||||
|
||||
if (!ioctl(drive,CDROMEJECT))
|
||||
put_it("%s: ejected cdrom tray",cparse(cdrom_prompt));
|
||||
else
|
||||
put_it("%s: Stopped playing cdrom",cparse(cdrom_prompt));
|
||||
close(drive);
|
||||
drive=0;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_play)
|
||||
{
|
||||
|
||||
int tn;
|
||||
char *trackn;
|
||||
#ifndef __FreeBSD__
|
||||
unsigned char first, last;
|
||||
struct cdrom_tochdr tocHdr;
|
||||
#else
|
||||
struct ioc_play_track cdrom_play_args;
|
||||
int result;
|
||||
#endif
|
||||
|
||||
if (!check_cdrom_str() || !drive)
|
||||
return;
|
||||
|
||||
if (args && *args)
|
||||
{
|
||||
trackn=next_arg(args, &args);
|
||||
tn=atoi(trackn);
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
if ((ioctl(drive,CDROMREADTOCHDR,&tocHdr)))
|
||||
{
|
||||
put_it("%s: Couldnt get cdrom heder",cparse(cdrom_prompt));
|
||||
return;
|
||||
}
|
||||
|
||||
first = tocHdr.cdth_trk0;
|
||||
last = tocHdr.cdth_trk1;
|
||||
ti.cdti_trk0=tn;
|
||||
|
||||
if (ti.cdti_trk0<first)
|
||||
ti.cdti_trk0=first;
|
||||
if (ti.cdti_trk0>last)
|
||||
ti.cdti_trk0=last;
|
||||
|
||||
ti.cdti_ind0=0;
|
||||
ti.cdti_trk1=last;
|
||||
ti.cdti_ind1=0;
|
||||
#else
|
||||
if (tn < hdr.starting_track)
|
||||
tn=hdr.starting_track;
|
||||
if (tn > hdr.ending_track)
|
||||
tn=hdr.ending_track;
|
||||
#endif
|
||||
if (TocEntry[tn].avoid==0)
|
||||
{
|
||||
#ifndef __FreeBSD__
|
||||
play_chunk(TocEntry[tn].m_start,TocEntry[last+1].m_start - 1);
|
||||
#else
|
||||
cdrom_play_args.start_track=tn;
|
||||
cdrom_play_args.start_index=1;
|
||||
cdrom_play_args.end_track=hdr.ending_track;
|
||||
cdrom_play_args.end_index=1;
|
||||
(void)ioctl(drive,CDIOCPLAYTRACKS,&cdrom_play_args);
|
||||
#endif
|
||||
put_it("%s: Playing track number #%d",cparse(cdrom_prompt),tn);
|
||||
}
|
||||
else
|
||||
put_it("%s: Cannot play track #%d (Might be data track)",cparse(cdrom_prompt),tn);
|
||||
}
|
||||
else
|
||||
put_it("%s: Usage: /cdplay <track number>",cparse(cdrom_prompt));
|
||||
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_list)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!check_cdrom_str())
|
||||
return;
|
||||
#ifndef __FreeBSD__
|
||||
for (i=1;i<=hdr.cdth_trk1;i++)
|
||||
#else
|
||||
for (i = hdr.starting_track; i < hdr.ending_track; i++)
|
||||
#endif
|
||||
{
|
||||
put_it("%s: Track #%02d: %02d:%02d:%02d %02d:%02d:%02d",
|
||||
cparse(cdrom_prompt),
|
||||
i,
|
||||
TocEntry[i].m_length / (60*75),
|
||||
(TocEntry[i].m_length % (60*75)) / 75,
|
||||
TocEntry[i].m_length % 75,
|
||||
TocEntry[i].m_start / (60*75),
|
||||
(TocEntry[i].m_start % (60*75)) /75,
|
||||
TocEntry[i].m_start % 75
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_volume)
|
||||
{
|
||||
char *left, *right;
|
||||
#ifndef __FreeBSD__
|
||||
struct cdrom_volctrl volctrl;
|
||||
#else
|
||||
struct ioc_vol volctrl;
|
||||
#endif
|
||||
if (!check_cdrom_str())
|
||||
return;
|
||||
|
||||
if (args && *args)
|
||||
{
|
||||
left=next_arg(args, &args);
|
||||
right=next_arg(args, &args);
|
||||
ioctl(drive, CDROMVOLREAD, &volctrl);
|
||||
if (left && *left)
|
||||
#ifndef __FreeBSD__
|
||||
volctrl.channel0 = atoi(left);
|
||||
#else
|
||||
volctrl.vol[0] = atoi(left);
|
||||
#endif
|
||||
if (right && *right)
|
||||
#ifndef __FreeBSD__
|
||||
volctrl.channel1 = atoi(right);
|
||||
#else
|
||||
volctrl.vol[1] = atoi(right);
|
||||
#endif
|
||||
if (ioctl(drive,CDROMVOLCTRL,&volctrl))
|
||||
put_it("%s: Couldnt set cdrom volume",cparse(cdrom_prompt));
|
||||
else
|
||||
put_it("%s: CDROM Volume is now <%d> <%d>",cparse(cdrom_prompt),
|
||||
#ifndef __FreeBSD__
|
||||
volctrl.channel0,volctrl.channel1);
|
||||
#else
|
||||
volctrl.vol[0],volctrl.vol[1]);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
put_it("%s: Usage: /cdvol <left> <right>",cparse(cdrom_prompt));
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_pause)
|
||||
{
|
||||
static int cpause = 0;
|
||||
if (!check_cdrom_str())
|
||||
return;
|
||||
if (ioctl(drive, !cpause?CDROMPAUSE:CDROMRESUME))
|
||||
put_it("%s: Couldnt pause/resume your cdrom",cparse(cdrom_prompt));
|
||||
else
|
||||
put_it("%s: %s",cparse(cdrom_prompt),!cpause?"Your cdrom has been paused":"Your cdrom has been resumed");
|
||||
cpause ^= 1;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(cd_help)
|
||||
{
|
||||
put_it("%s: CDPLAY - Play a CDROM Track Number",cparse(cdrom_prompt));
|
||||
put_it("%s: CDSTOP - Make the CDROM Stop playing",cparse(cdrom_prompt));
|
||||
put_it("%s: CDEJECT - Eject the CDROM Tray",cparse(cdrom_prompt));
|
||||
put_it("%s: CDVOL - Set's the CDROM Volume",cparse(cdrom_prompt));
|
||||
put_it("%s: CDLIST - List of CDROM tracks",cparse(cdrom_prompt));
|
||||
put_it("%s: CDPAUSE - Pause/resume the CDROM",cparse(cdrom_prompt));
|
||||
}
|
||||
|
||||
char *Cdrom_Version (IrcCommandDll **interp)
|
||||
{
|
||||
return CDROM_VERSION;
|
||||
}
|
||||
|
||||
int Cdrom_Init(IrcCommandDll **interp, Function_ptr *global_table)
|
||||
{
|
||||
char *name = "cdrom";
|
||||
initialize_module(name);
|
||||
add_module_proc(COMMAND_PROC, name, "cdstop", NULL, 0, 0, cd_stop, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdplay", NULL, 0, 0, cd_play, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdeject", NULL, 0, 0, cd_eject, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdlist", NULL, 0, 0, cd_list, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdhelp", NULL, 0, 0, cd_help, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdvolume", NULL, 0, 0, cd_volume, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cdpause", NULL, 0, 0, cd_pause, NULL);
|
||||
add_module_proc(COMMAND_PROC, name, "cddevice", NULL, 0, 0, set_cd_device, NULL);
|
||||
put_it("%s: Module loaded and ready. /cddevice <dev> to start", cparse(cdrom_prompt));
|
||||
put_it("%s: /cdhelp for list of new commands.", cparse(cdrom_prompt));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
84
dll/dllinit.c
Normal file
84
dll/dllinit.c
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifdef WINNT
|
||||
/* dllinit.c -- Portable DLL initialization.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Contributed by Mumit Khan (khan@xraylith.wisc.edu).
|
||||
|
||||
I've used DllMain as the DLL "main" since that's the most common
|
||||
usage. MSVC and Mingw32 both default to DllMain as the standard
|
||||
callback from the linker entry point. Cygwin, as of b20.1, also
|
||||
uses DllMain as the default callback from the entry point.
|
||||
|
||||
The real entry point is typically always defined by the runtime
|
||||
library, and usually never overridden by (casual) user. What you can
|
||||
override however is the callback routine that the entry point calls,
|
||||
and this file provides such a callback function, DllMain.
|
||||
|
||||
Mingw32: The default entry point for mingw32 is DllMainCRTStartup
|
||||
which is defined in libmingw32.a This in turn calls DllMain which is
|
||||
defined here. If not defined, there is a stub in libmingw32.a which
|
||||
does nothing.
|
||||
|
||||
Cygwin: The default entry point for Cygwin b20.1 or newer is
|
||||
__cygwin_dll_entry which is defined in libcygwin.a. This in turn
|
||||
calls the routine DllMain. If not defined, there is a stub in
|
||||
libcygwin.a which does nothing.
|
||||
|
||||
MSVC: MSVC runtime calls DllMain, just like Mingw32.
|
||||
|
||||
Summary: If you need to do anything special in DllMain, just add it
|
||||
here. Otherwise, the default setup should be just fine for 99%+ of
|
||||
the time. I strongly suggest that you *not* change the entry point,
|
||||
but rather change DllMain as appropriate.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <stdio.h>
|
||||
|
||||
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
|
||||
LPVOID reserved /* Not used. */ );
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* DllMain --
|
||||
*
|
||||
* This routine is called by the Mingw32, Cygwin32 or VC++ C run
|
||||
* time library init code, or the Borland DllEntryPoint routine. It
|
||||
* is responsible for initializing various dynamically loaded
|
||||
* libraries.
|
||||
*
|
||||
* Results:
|
||||
* TRUE on sucess, FALSE on failure.
|
||||
*
|
||||
* Side effects:
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
BOOL APIENTRY
|
||||
DllMain (
|
||||
HINSTANCE hInst /* Library instance handle. */ ,
|
||||
DWORD reason /* Reason this function is being called. */ ,
|
||||
LPVOID reserved /* Not used. */ )
|
||||
{
|
||||
|
||||
switch (reason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
176
dll/encrypt/Makefile.in
Normal file
176
dll/encrypt/Makefile.in
Normal file
@@ -0,0 +1,176 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = encrypt
|
||||
|
||||
all: Makefile encrypt$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
encrypt.o: $(srcdir)/encrypt.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/encrypt.c
|
||||
|
||||
encrypt$(SHLIB_SUFFIX): encrypt.o ../dllinit.o
|
||||
$(SHLIB_LD) encrypt.o ../dllinit.o ${SHLIB_CFLAGS} -o encrypt$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.so *.a *.dll *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
76
dll/encrypt/encrypt.c
Normal file
76
dll/encrypt/encrypt.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#define ENCODE_VERSION "0.001"
|
||||
|
||||
/*
|
||||
*
|
||||
* Written by Colten Edwards. (C) August 97
|
||||
* Based on script by suicide for evolver script.
|
||||
*/
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#define cparse convert_output_format
|
||||
char encode_version[] = "Encode 0.001";
|
||||
unsigned char *encode_string = NULL;
|
||||
|
||||
BUILT_IN_FUNCTION(func_encode)
|
||||
{
|
||||
char *new;
|
||||
if (!input)
|
||||
return m_strdup(empty_string);
|
||||
new = m_strdup(input);
|
||||
my_encrypt(new, strlen(new), encode_string);
|
||||
return new;
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_decode)
|
||||
{
|
||||
char *new;
|
||||
if (!input)
|
||||
return m_strdup(empty_string);
|
||||
new = m_strdup(input);
|
||||
my_decrypt(new, strlen(new), encode_string);
|
||||
return new;
|
||||
}
|
||||
|
||||
char *Encode_Version(IrcCommandDll **intp)
|
||||
{
|
||||
return ENCODE_VERSION;
|
||||
}
|
||||
|
||||
|
||||
int Encrypt_Init(IrcCommandDll **intp, Function_ptr *global_table)
|
||||
{
|
||||
int i, j;
|
||||
char buffer[BIG_BUFFER_SIZE+1];
|
||||
initialize_module("encrypt");
|
||||
|
||||
add_module_proc(ALIAS_PROC, "encrypt", "MENCODE", NULL, 0, 0, func_encode, NULL);
|
||||
add_module_proc(ALIAS_PROC, "encrypt", "MDECODE", NULL, 0, 0, func_decode, NULL);
|
||||
encode_string = (char *)new_malloc(512);
|
||||
for (i = 1, j = 255; i <= 255; i++, j--)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 27:
|
||||
case 127:
|
||||
case 255:
|
||||
encode_string[i-1] = i;
|
||||
break;
|
||||
default:
|
||||
encode_string[i-1] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sprintf(buffer, "$0+%s by panasync - $2 $3", encode_version);
|
||||
fset_string_var(FORMAT_VERSION_FSET, buffer);
|
||||
put_it("%s", convert_output_format("$G $0 v$1 by panasync. Based on suicide's Abot script.", "%s %s", encode_version, ENCODE_VERSION));
|
||||
return 0;
|
||||
}
|
||||
|
||||
33
dll/encrypt/encrypt.sh
Normal file
33
dll/encrypt/encrypt.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
CP=cp
|
||||
RM=rm
|
||||
|
||||
$GCC -I../../include -c encrypt.c
|
||||
|
||||
echo EXPORTS > encrypt.def
|
||||
$NM encrypt.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> encrypt.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file encrypt.base --dll -o encrypt.dll encrypt.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname encrypt.dll --def encrypt.def --base-file\
|
||||
encrypt.base --output-exp encrypt.exp
|
||||
$LD --base-file encrypt.base encrypt.exp --dll -o encrypt.dll encrypt.o\
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname encrypt.dll --def encrypt.def --base-file\
|
||||
encrypt.base --output-exp encrypt.exp
|
||||
$LD encrypt.exp --dll -o encrypt.dll encrypt.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the encryptB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname encrypt.dll --def encrypt.def --output-lib encrypt.a
|
||||
|
||||
$RM *.base *.exp *.def
|
||||
$CP *.dll ..
|
||||
340
dll/europa/COPYING
Normal file
340
dll/europa/COPYING
Normal 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) 19yy <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) 19yy 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
dll/europa/CREDITS
Normal file
4
dll/europa/CREDITS
Normal file
@@ -0,0 +1,4 @@
|
||||
Jeremy Tregunna (aka zdt on EFnet #linuxinfo) contributed the pengy database
|
||||
entries from his Pengy bot. This provides a nice knowledgebase that gives
|
||||
Europa a running start towards being useful. Thanks!
|
||||
|
||||
180
dll/europa/Makefile.in
Normal file
180
dll/europa/Makefile.in
Normal file
@@ -0,0 +1,180 @@
|
||||
# dll/europa/Makefile
|
||||
# (c) David Walluck 2000
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
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 = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
MYSQL_LIBS = @MYSQL_LIBS@
|
||||
|
||||
PLUGIN_NAME = europa
|
||||
|
||||
all: Makefile europa$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
europa.o: $(srcdir)/europa.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/europa.c
|
||||
|
||||
europa$(SHLIB_SUFFIX): europa.o ../dllinit.o
|
||||
$(SHLIB_LD) europa.o ../dllinit.o $(SHLIB_CFLAGS) -o europa$(SHLIB_SUFFIX) $(MYSQL_LIBS)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.a *.dll europa$(SHLIB_SUFFIX) *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
139
dll/europa/README
Normal file
139
dll/europa/README
Normal file
@@ -0,0 +1,139 @@
|
||||
Europa v0.01
|
||||
Copyright (c) 1999, Ed Schlunder <zilym@asu.edu>
|
||||
|
||||
This is Free Software licensed under the GNU GPL. Please see COPYING for
|
||||
details.
|
||||
|
||||
WARNING - YOUR MILEAGE MAY VARY. USE AT YOUR OWN RISK. AUTHOR IS NOT
|
||||
RESPONSIBLE FOR ANY DAMAGES INCURRED THROUGH THE USE OF THIS PACKAGE.
|
||||
|
||||
SUMMARY
|
||||
--------------------------------------------------------------------------
|
||||
Europa is a BitchX (popular irc client) plugin to provide easy access to
|
||||
an SQL knowledgebase. This is helpful for use in help channels where
|
||||
common questions repeatedly come up.
|
||||
|
||||
BACKGROUND
|
||||
--------------------------------------------------------------------------
|
||||
For the past 2-3 years, we've been answering people's questions about Linux
|
||||
in the EFnet IRC channel #linuxinfo. Jeremy Tregunna wrote a bot
|
||||
in Perl called 'Penguin' that stored tons of keyword/answers pairs in
|
||||
a database so that channel operators could store commonly asked question
|
||||
answers in. When a Linux newbie came in and asked a question already
|
||||
answered several times before in prior conversations, we simply ask
|
||||
Penguin to please explain the keyword associated with the question, saving
|
||||
us a lot of typing time.
|
||||
|
||||
I've always admired the Penguin bot a lot and wished I could run one
|
||||
myself. However, I don't have access to any IRC servers that allow bots.
|
||||
This led to the developement of Europa, a BitchX plugin that listens to
|
||||
channels you are chatting on and automatically responds when it sees
|
||||
someone giving it a command. This lets you chat on IRC as a normal user
|
||||
like you've always done, but also have a nice SQL knowledgebase available
|
||||
at your (and your friends) finger tips.
|
||||
|
||||
REQUIREMENTS
|
||||
--------------------------------------------------------------------------
|
||||
Europa currently only support MySQL (http://www.mysql.com/) for the
|
||||
database backend. You will need to have MySQL already installed
|
||||
and working to use Europa.
|
||||
|
||||
To use Europa, you need to be using BitchX (http://www.bitchx.org/). In
|
||||
addition, to compile Europa, you will need a copy of the BitchX source
|
||||
code extracted as ../BitchX (relative to Europa's directory).
|
||||
|
||||
INSTALLATION
|
||||
--------------------------------------------------------------------------
|
||||
1. Extract the Europa source code and the BitchX source code:
|
||||
gzip -cd europa-xxx.tar.gz | tar xvf -
|
||||
gzip -cd BitchX-1.0c13.tar.gz | tar xvf -
|
||||
|
||||
These should be extracted this way so that the Europa makefile can
|
||||
access the BitchX include files (see Makefile to see what I mean).
|
||||
|
||||
2. Compile and install BitchX
|
||||
cd BitchX/
|
||||
less INSTALL
|
||||
|
||||
3. Create a database for Europa to use on your mysql server:
|
||||
mysql mysql -u root -p
|
||||
create database europa;
|
||||
insert into user values('%','europa',password('APASSWD'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N');
|
||||
insert into db values('%','europa','europa','Y','Y','Y','Y','N','N','N','N','N','N');
|
||||
exit
|
||||
|
||||
mysqladmin reload -u root -p
|
||||
mysql europa -u root -p < knowledgebase.sql
|
||||
|
||||
4. Edit europa.h to match your settings, should be self explanatory.
|
||||
|
||||
5. Compile the Europa source code:
|
||||
make
|
||||
|
||||
6. Copy the resulting europa.so file to your ~/.BitchX/plugins/ directory,
|
||||
or alternatively you could put it in your system wide BitchX plugins
|
||||
directory (/usr/local/lib/bx/plugins/ on my system).
|
||||
|
||||
7. Start up BitchX. Do a "/loaddll europa.so" and you should see
|
||||
Europa load and connect to your SQL knowledgebase.
|
||||
|
||||
You may want to add the command "LOADDLL europa.so" to your
|
||||
~/.BitchX/BitchX.sav file so that Europa loads automatically everytime
|
||||
you start BitchX.
|
||||
|
||||
USING EUROPA
|
||||
--------------------------------------------------------------------------
|
||||
Now that you've got it running, what can you do? Join a channel with
|
||||
some people on it. You may want to start another IRC session so you
|
||||
can talk to yourself (Europa can only see public commands from other
|
||||
clients, someone tell me how to fix that ;-). Suppose the client running
|
||||
Europa has the nick "jonny" and your second session has the nick "jon".
|
||||
A typical chat might look like:
|
||||
|
||||
<jon> jonny: explain winnt
|
||||
<jonny> jon: Windows NT is a fully 32-bit operating system for the i386 and
|
||||
Alpha hardware playforms with superb multi-tasking and server
|
||||
functionality. Written by Microsoft Corporation
|
||||
(http://www.microsoft.com/).
|
||||
<jon> jonny: forget winnt
|
||||
<jonny> jon: winnt forgotten...
|
||||
<jon> jonny learn winnt Windows NT is a 32-bit operating system for the i386
|
||||
and Alpha architectures with superb multitasking and server
|
||||
functionality (yeah, uh-huh, and pigs fly)... See
|
||||
http://www.microsoft.com/ and
|
||||
http://www.cnn.com/TECH/computing/9907/15/nt-mare.idg/
|
||||
<jonny> jon: winnt learned, thanks...
|
||||
|
||||
Public command reference:
|
||||
NICK: explain KEYWORD
|
||||
NICK: forget KEYWORD
|
||||
NICK: learn KEYWORD ANSWER TEXT
|
||||
NICK: shutup
|
||||
-- europa disables saying anything to others
|
||||
NICK: hello
|
||||
-- europa turns back on and talks again
|
||||
|
||||
And thus is the gist of using Europa. Also, Europa installs a new
|
||||
irc command "/explain USER KEYWORD" which lets you send a private
|
||||
message to a specific user containing the answer to KEYWORD. You
|
||||
could also do "/explain #CHANNEL KEYWORD" to send it to a channel
|
||||
you are currently on publically.
|
||||
|
||||
I haven't implemented "/forget KEYWORD" or "/learn KEYWORD ANSWER" yet,
|
||||
sorry.
|
||||
|
||||
FUTURE PLANS
|
||||
--------------------------------------------------------------------------
|
||||
I'd really like to redo Europa in Java and implement some natural
|
||||
language processing capabilities in it. You can see some of my
|
||||
experimenting with interfacing C to Java in the corba/ directory.
|
||||
|
||||
Processing text in C is not particularly easy to do in a safe manner.
|
||||
Doing AI stuff is even harder to do without a nice garbage collector
|
||||
taking care of memory management for you. Normally, I depise Java for
|
||||
just about every project due to its closed sourced nature and buggy Linux
|
||||
support. But this is one case where it might be a good choice, we'll see.
|
||||
|
||||
You can see my previous NLP work in the cse476/ folder. If you actually
|
||||
figure out what the code is doing in there, you'll understand why a
|
||||
garbage collector would be really nice for this and why C isn't.
|
||||
BIN
dll/europa/corba/EuropaAI/Europa.class
Normal file
BIN
dll/europa/corba/EuropaAI/Europa.class
Normal file
Binary file not shown.
13
dll/europa/corba/EuropaAI/Europa.java
Normal file
13
dll/europa/corba/EuropaAI/Europa.java
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* File: ./EuropaAI/Europa.java
|
||||
* From: europa.idl
|
||||
* Date: Thu Dec 23 02:08:42 1999
|
||||
* By: idltojava Java IDL 1.2 Aug 11 1998 02:00:18
|
||||
*/
|
||||
|
||||
package EuropaAI;
|
||||
public interface Europa
|
||||
extends org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
|
||||
void inputChat(String text)
|
||||
;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user