mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 15:36:50 +00:00
april2
This commit is contained in:
parent
d9fac6178c
commit
f50111b895
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,7 @@ src/Makefile
|
|||||||
src/config.h
|
src/config.h
|
||||||
src/mcmd.h
|
src/mcmd.h
|
||||||
src/usercombo.h
|
src/usercombo.h
|
||||||
|
trivia/*.index
|
||||||
|
|
||||||
# compiled files
|
# compiled files
|
||||||
energymech
|
energymech
|
||||||
@ -14,6 +15,7 @@ src/*.o
|
|||||||
src/gencmd
|
src/gencmd
|
||||||
src/aliastest
|
src/aliastest
|
||||||
src/safepathtest
|
src/safepathtest
|
||||||
|
trivia/mkindex
|
||||||
|
|
||||||
# mech typical user config files
|
# mech typical user config files
|
||||||
*~
|
*~
|
||||||
|
|||||||
31
Makefile
31
Makefile
@ -18,7 +18,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
MISCFILES = CREDITS LICENSE README README.TCL TODO VERSIONS VERSIONS-1 Makefile configure \
|
MISCFILES = CREDITS LICENSE README README.TCL TODO VERSIONS VERSIONS-1 Makefile configure \
|
||||||
checkmech sample.conf sample.py sample.tcl sample.userfile default.bigchars public/README
|
checkmech sample.conf sample.py sample.tcl sample.userfile default.bigchars public/README trivia/README
|
||||||
|
|
||||||
|
ASCIIFILES = ascii/README ascii/bbw ascii/camel ascii/goatse ascii/mech ascii/phooler
|
||||||
|
|
||||||
HELPFILES = help/8BALL help/ACCESS help/ALIAS help/AWAY help/BAN help/BANLIST help/BYE \
|
HELPFILES = help/8BALL help/ACCESS help/ALIAS help/AWAY help/BAN help/BANLIST help/BYE \
|
||||||
help/CCHAN help/CHACCESS help/CHANBAN help/CHANNELS help/CHAT help/CLEARSHIT \
|
help/CCHAN help/CHACCESS help/CHANBAN help/CHANNELS help/CHAT help/CLEARSHIT \
|
||||||
@ -47,11 +49,9 @@ RANDFILES = messages/8ball.txt messages/away.txt messages/insult.txt \
|
|||||||
|
|
||||||
STUBFILES = src/Makefile.in src/config.h.in src/ld/README src/ld/elf32-i386 src/ld/elf64-x86-64
|
STUBFILES = src/Makefile.in src/config.h.in src/ld/README src/ld/elf32-i386 src/ld/elf64-x86-64
|
||||||
|
|
||||||
TESTFILES = config/cc.c config/endian.c config/inet_addr.c config/ldtest.c \
|
TESTFILES = config/cc.c config/endian.c config/inet_addr.c config/inet_aton.c config/ldtest.c config/md5.h config/md5_internal.c \
|
||||||
config/ptr_size.c config/socket.c config/tcl.c config/which \
|
config/perl.c config/ptr_size.c config/python.c config/pw.c config/sha1.h config/sha_internal.c config/socket.c config/tcl.c \
|
||||||
config/md5.h config/md5_internal.c config/pw.c \
|
config/unaligned.c config/which
|
||||||
config/sha_internal.c config/sha1.h \
|
|
||||||
config/inet_aton.c config/unaligned.c config/python.c
|
|
||||||
|
|
||||||
TRIVFILES = trivia/mkindex.c
|
TRIVFILES = trivia/mkindex.c
|
||||||
|
|
||||||
@ -69,46 +69,48 @@ HDRFILES = src/defines.h src/global.h src/h.h src/settings.h src/structs.h src/t
|
|||||||
|
|
||||||
CONFFILES = src/Makefile src/config.h
|
CONFFILES = src/Makefile src/config.h
|
||||||
|
|
||||||
DISTFILES = $(MISCFILES) $(RANDFILES) $(SRCFILES) $(HELPFILES) \
|
DISTFILES = $(MISCFILES) $(RANDFILES) $(SRCFILES) $(HELPFILES) $(ASCIIFILES) \
|
||||||
$(STUBFILES) $(HDRFILES) $(TRIVFILES) $(TESTFILES)
|
$(STUBFILES) $(HDRFILES) $(TRIVFILES) $(TESTFILES)
|
||||||
|
|
||||||
#
|
#
|
||||||
# simple make rules
|
# simple make rules
|
||||||
#
|
#
|
||||||
|
|
||||||
|
.PHONY: clean install mech mega mega-install test dist dist2
|
||||||
|
|
||||||
mech: $(SRCFILES) $(CONFFILES)
|
mech: $(SRCFILES) $(CONFFILES)
|
||||||
$(MAKE) -C src energymech
|
$(MAKE) -C src energymech
|
||||||
|
|
||||||
energymech: $(SRCFILES) $(CONFFILES)
|
energymech: $(SRCFILES) $(CONFFILES)
|
||||||
$(MAKE) -C src energymech
|
$(MAKE) -C src energymech
|
||||||
|
|
||||||
clean: FORCE
|
clean:
|
||||||
$(MAKE) -C src clean
|
$(MAKE) -C src clean
|
||||||
|
|
||||||
install: FORCE
|
install:
|
||||||
$(MAKE) -C src install
|
$(MAKE) -C src install
|
||||||
|
|
||||||
mega: FORCE
|
mega:
|
||||||
$(MAKE) -C src mega
|
$(MAKE) -C src mega
|
||||||
|
|
||||||
mega-install: FORCE
|
mega-install:
|
||||||
$(MAKE) -C src mega-install
|
$(MAKE) -C src mega-install
|
||||||
|
|
||||||
#
|
#
|
||||||
# code validation tests
|
# code validation tests
|
||||||
#
|
#
|
||||||
|
|
||||||
test: FORCE
|
test:
|
||||||
$(MAKE) -C src test
|
$(MAKE) -C src test
|
||||||
|
|
||||||
#
|
#
|
||||||
# packing things up for distribution
|
# packing things up for distribution
|
||||||
#
|
#
|
||||||
|
|
||||||
dist: FORCE
|
dist:
|
||||||
$(MAKE) dist2 DISTDIR=`sed 's/^.*VERSION.*"\(.*\)".*$$/emech-\1/p; d;' src/global.h`
|
$(MAKE) dist2 DISTDIR=`sed 's/^.*VERSION.*"\(.*\)".*$$/emech-\1/p; d;' src/global.h`
|
||||||
|
|
||||||
dist2: FORCE
|
dist2:
|
||||||
rm -rf /tmp/$(DISTDIR)
|
rm -rf /tmp/$(DISTDIR)
|
||||||
mkdir /tmp/$(DISTDIR)
|
mkdir /tmp/$(DISTDIR)
|
||||||
tar cf - $(DISTFILES) | ( cd /tmp/$(DISTDIR) ; tar --preserve-permissions -xf - )
|
tar cf - $(DISTFILES) | ( cd /tmp/$(DISTDIR) ; tar --preserve-permissions -xf - )
|
||||||
@ -116,4 +118,3 @@ dist2: FORCE
|
|||||||
rm -rf /tmp/$(DISTDIR)
|
rm -rf /tmp/$(DISTDIR)
|
||||||
chmod 644 /tmp/$(DISTDIR).tar.gz
|
chmod 644 /tmp/$(DISTDIR).tar.gz
|
||||||
|
|
||||||
FORCE:
|
|
||||||
|
|||||||
5
README
5
README
@ -37,6 +37,10 @@ To compile the source:
|
|||||||
export CROSS_COMPILE="armv7a-hardfloat-linux-gnueabi-"
|
export CROSS_COMPILE="armv7a-hardfloat-linux-gnueabi-"
|
||||||
|
|
||||||
4) make clean install
|
4) make clean install
|
||||||
|
-- On a modern multi-core cpu, you can run make with the appropriate
|
||||||
|
-j switch to shave off a few seconds of compile time.
|
||||||
|
For example:
|
||||||
|
``make -j4'' for a 4 core cpu system.
|
||||||
|
|
||||||
If all went well you should now have an executable called
|
If all went well you should now have an executable called
|
||||||
``energymech''.
|
``energymech''.
|
||||||
@ -88,6 +92,7 @@ to see what's going on with...
|
|||||||
|
|
||||||
If you get an 'Unknown option -d', you need to answer 'Y' to debug
|
If you get an 'Unknown option -d', you need to answer 'Y' to debug
|
||||||
support when running ./configure from the compiling section above.
|
support when running ./configure from the compiling section above.
|
||||||
|
Or run with ``./configure --with-debug''.
|
||||||
|
|
||||||
---*---
|
---*---
|
||||||
|
|
||||||
|
|||||||
3
VERSIONS
3
VERSIONS
@ -1,5 +1,8 @@
|
|||||||
3.0.99p4 -- WORK IN PROGRESS (~March, 2018)
|
3.0.99p4 -- WORK IN PROGRESS (~March, 2018)
|
||||||
|
|
||||||
|
* Added: Energymech can now link with libmusl (--with-libmusl[=/PATH/TO/musl-gcc])
|
||||||
|
* Added: (ALPHA) Perl scripting support (PERL, PERLSCRIPT)
|
||||||
|
* Changed: Trivia question file must be placed in ./trivia/*
|
||||||
* Changed: If compiled with debug, Free() on unknown memory no longer shuts down the bot,
|
* Changed: If compiled with debug, Free() on unknown memory no longer shuts down the bot,
|
||||||
now it just ignores the panic and swallows the (possible) leak.
|
now it just ignores the panic and swallows the (possible) leak.
|
||||||
* Added: Experimental code to suppress certain commands to run on only one bot even
|
* Added: Experimental code to suppress certain commands to run on only one bot even
|
||||||
|
|||||||
17
config/perl.c
Normal file
17
config/perl.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <EXTERN.h>
|
||||||
|
#include <perl.h>
|
||||||
|
|
||||||
|
static PerlInterpreter *my_perl;
|
||||||
|
|
||||||
|
int main(int argc, char **argv, char **env)
|
||||||
|
{
|
||||||
|
PERL_SYS_INIT3(&argc,&argv,&env);
|
||||||
|
my_perl = perl_alloc();
|
||||||
|
perl_construct(my_perl);
|
||||||
|
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
|
||||||
|
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
|
||||||
|
perl_run(my_perl);
|
||||||
|
perl_destruct(my_perl);
|
||||||
|
perl_free(my_perl);
|
||||||
|
PERL_SYS_TERM();
|
||||||
|
}
|
||||||
215
configure
vendored
215
configure
vendored
@ -20,15 +20,50 @@
|
|||||||
|
|
||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
# perl still unsupported
|
|
||||||
#has_perl=no
|
|
||||||
compile=no
|
compile=no
|
||||||
install=no
|
install=no
|
||||||
silentopt=no
|
silentopt=no
|
||||||
|
try_libmusl=no
|
||||||
|
|
||||||
# default optimization goal, speed = -O2, size = -Os
|
# default optimization goal, speed = -O2, size = -Os
|
||||||
optitype=size
|
optitype=size
|
||||||
|
|
||||||
|
set_feature_defaults() {
|
||||||
|
ft_alias=$ft_default
|
||||||
|
ft_botnet=$ft_default
|
||||||
|
ft_bounce=$ft_default
|
||||||
|
ft_chanban=$ft_default
|
||||||
|
ft_ctcp=$ft_default
|
||||||
|
ft_dccfile=$ft_default
|
||||||
|
ft_debug=$ft_default
|
||||||
|
ft_dynamode=$ft_default
|
||||||
|
ft_dyncmd=$ft_default
|
||||||
|
ft_greet=$ft_default
|
||||||
|
ft_hostinfo=$ft_default
|
||||||
|
ft_ircd_ext=$ft_default
|
||||||
|
ft_md5=$ft_default
|
||||||
|
ft_newbie=$ft_default
|
||||||
|
ft_note=$ft_default
|
||||||
|
ft_notify=$ft_default
|
||||||
|
ft_perl=$ft_default
|
||||||
|
ft_python=$ft_default
|
||||||
|
ft_rawdns=$ft_default
|
||||||
|
ft_redirect=$ft_default
|
||||||
|
ft_seen=$ft_default
|
||||||
|
ft_session=$ft_default
|
||||||
|
ft_sha=$ft_default
|
||||||
|
ft_stats=$ft_default
|
||||||
|
ft_suppress=$ft_default
|
||||||
|
ft_tcl=$ft_default
|
||||||
|
ft_telnet=$ft_default
|
||||||
|
ft_toybox=$ft_default
|
||||||
|
ft_trivia=$ft_default
|
||||||
|
ft_uptime=$ft_default
|
||||||
|
ft_urlcapture=$ft_default
|
||||||
|
ft_web=$ft_default
|
||||||
|
ft_wingate=$ft_default
|
||||||
|
}
|
||||||
|
|
||||||
for opt
|
for opt
|
||||||
do
|
do
|
||||||
|
|
||||||
@ -115,17 +150,20 @@ do
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$feature" in
|
case "$feature" in
|
||||||
debug | botnet | telnet | alias | seen | session | dyncmd | newbie | wingate | md5 | sha \
|
alias | botnet | bounce | chanban | ctcp | dccfile | debug | dynamode | dyncmd | greet | hostinfo | idwrap | ircd_ext | libmusl | md5 | newbie | note | notify | perl \
|
||||||
| ctcp | dccfile | uptime | redirect | greet | perl | profiling | tcl | dynamode | web | hostinfo \
|
| profiling | python | rawdns | redirect | seen | session | sha | stats | suppress | tcl | telnet | toybox | trivia | uptime | urlcapture | web | wingate )
|
||||||
| note | notify | trivia | toybox | bounce | stats | suppress | rawdns | ircd_ext | idwrap | chanban | python | urlcapture )
|
|
||||||
case _"$optarg"_ in
|
case _"$optarg"_ in
|
||||||
_yes_ | _no_ | __ )
|
_yes_ | _no_ | __ )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
if [ "$feature" = libmusl ]; then
|
||||||
|
try_libmusl="$optarg"
|
||||||
|
else
|
||||||
echo "unknown argument for $feature":" $optarg"
|
echo "unknown argument for $feature":" $optarg"
|
||||||
echo "Usage: configure [options]"
|
echo "Usage: configure [options]"
|
||||||
echo "use \"$0 --help\" for help"
|
echo "use \"$0 --help\" for help"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
___none___ )
|
___none___ )
|
||||||
@ -254,6 +292,7 @@ do
|
|||||||
;;
|
;;
|
||||||
--compile) compile=yes ;;
|
--compile) compile=yes ;;
|
||||||
--install) install=yes ;;
|
--install) install=yes ;;
|
||||||
|
--with-libmusl) try_libmusl=/usr/local/musl/bin/musl-gcc ;;
|
||||||
--silence=options) silentopt=yes ;;
|
--silence=options) silentopt=yes ;;
|
||||||
--md5=internal) ft_md5=internal ;;
|
--md5=internal) ft_md5=internal ;;
|
||||||
--sha=internal) ft_sha=internal ;;
|
--sha=internal) ft_sha=internal ;;
|
||||||
@ -271,39 +310,8 @@ do
|
|||||||
--no-pipeflag) cc_pipe_opt=no ;;
|
--no-pipeflag) cc_pipe_opt=no ;;
|
||||||
--use-ofp) cc_ofp_opt=yes ;;
|
--use-ofp) cc_ofp_opt=yes ;;
|
||||||
--no-ofp) cc_ofp_opt=no ;;
|
--no-ofp) cc_ofp_opt=no ;;
|
||||||
--yes) ft_alias=yes
|
--default-yes) ft_default=yes set_feature_defaults ;;
|
||||||
ft_botnet=yes
|
--default-no) ft_default=no set_feature_defaults ;;
|
||||||
ft_bounce=yes
|
|
||||||
ft_chanban=yes
|
|
||||||
ft_ctcp=yes
|
|
||||||
ft_dccfile=yes
|
|
||||||
ft_debug=yes
|
|
||||||
ft_dynamode=yes
|
|
||||||
ft_dyncmd=yes
|
|
||||||
ft_greet=yes
|
|
||||||
ft_hostinfo=yes
|
|
||||||
ft_ircd_ext=yes
|
|
||||||
ft_md5=yes
|
|
||||||
ft_newbie=yes
|
|
||||||
ft_note=yes
|
|
||||||
ft_notify=yes
|
|
||||||
ft_python=yes
|
|
||||||
ft_rawdns=yes
|
|
||||||
ft_redirect=yes
|
|
||||||
ft_seen=yes
|
|
||||||
ft_session=yes
|
|
||||||
ft_sha=yes
|
|
||||||
ft_stats=yes
|
|
||||||
ft_suppress=yes
|
|
||||||
ft_tcl=yes
|
|
||||||
ft_telnet=yes
|
|
||||||
ft_toybox=yes
|
|
||||||
ft_trivia=yes
|
|
||||||
ft_uptime=yes
|
|
||||||
ft_urlcapture=yes
|
|
||||||
ft_web=yes
|
|
||||||
ft_wingate=yes
|
|
||||||
;;
|
|
||||||
--help | -h)
|
--help | -h)
|
||||||
cat <<__EOT__
|
cat <<__EOT__
|
||||||
Usage: configure [options]
|
Usage: configure [options]
|
||||||
@ -312,29 +320,49 @@ Configuration:
|
|||||||
Features and packages:
|
Features and packages:
|
||||||
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
||||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||||
--with-FEATURE[=ARG] use FEATURE [ARG=yes]
|
--with-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||||
--without-FEATURE do not use FEATURE (same as --with-FEATURE=no)
|
--without-FEATURE do not include FEATURE (same as --with-FEATURE=no)
|
||||||
|
--default-yes Default answer for all feature selections is Yes
|
||||||
|
--default-no Default answer for all feature selections is No
|
||||||
--md5=internal Use internal routines for MD5 password hashes instead of system libraries
|
--md5=internal Use internal routines for MD5 password hashes instead of system libraries
|
||||||
--sha=internal Use internal routines for SHA password hashes instead of system libraries
|
--sha=internal Use internal routines for SHA password hashes instead of system libraries
|
||||||
--use-ofp Try to use compiler flag -fomit-frame-pointer
|
--use-ofp Try to use compiler flag -fomit-frame-pointer
|
||||||
--no-ofp Do not use compiler flag -fomit-frame-pointer
|
--no-ofp Do not use compiler flag -fomit-frame-pointer
|
||||||
#md5 | ctcp | dccfile | uptime | redirect | greet | perl | dynamode | web \
|
|
||||||
#note | notify | trivia | toybox | bounce | stats | rawdns | ircd_ext | idwrap | chanban | python )
|
|
||||||
--with-alias ALIAS support
|
--with-alias ALIAS support
|
||||||
--with-botnet Botnet support
|
--with-botnet Botnet support
|
||||||
|
--with-bounce
|
||||||
|
--with-chanban
|
||||||
|
--with-ctcp
|
||||||
|
--with-dccfile
|
||||||
--with-debug Debug support
|
--with-debug Debug support
|
||||||
|
--with-dynamode
|
||||||
--with-dyncmd Dynamic command levels support
|
--with-dyncmd Dynamic command levels support
|
||||||
--with-hostinfo Support for code that reveals/displays/shares information about the host
|
--with-greet
|
||||||
that the bot is running on
|
--with-hostinfo Support for code that reveals/displays/shares information about the host that the bot is running on
|
||||||
--with-newbie Newbie support
|
--with-ircd_ext
|
||||||
|
--with-libmusl[=/PATH/TO/musl-gcc]
|
||||||
|
Try to use libmusl instead of system default
|
||||||
|
--with-md5
|
||||||
|
--with-newbie Newbie support for extra sanity checks and error messages
|
||||||
|
--with-note
|
||||||
|
--with-notify
|
||||||
|
--with-perl
|
||||||
--with-profiling Profiling (gcc+gprof)
|
--with-profiling Profiling (gcc+gprof)
|
||||||
|
--with-python
|
||||||
|
--with-rawdns
|
||||||
|
--with-redirect
|
||||||
--with-seen SEEN support
|
--with-seen SEEN support
|
||||||
--with-session Session support
|
--with-session Session support
|
||||||
|
--with-sha
|
||||||
|
--with-stats
|
||||||
--with-suppress Command duplication suppression
|
--with-suppress Command duplication suppression
|
||||||
--with-tcl Tcl support
|
--with-tcl Tcl scripting support
|
||||||
--with-telnet Telnet support
|
--with-telnet Telnet support
|
||||||
|
--with-toybox
|
||||||
|
--with-trivia
|
||||||
--with-uptime Include code that sends uptime reports to the IRC bot uptime contest server
|
--with-uptime Include code that sends uptime reports to the IRC bot uptime contest server
|
||||||
--with-urlcapture URL capture support
|
--with-urlcapture URL capture support
|
||||||
|
--with-web
|
||||||
--with-wingate Wingate support
|
--with-wingate Wingate support
|
||||||
__EOT__
|
__EOT__
|
||||||
exit 0
|
exit 0
|
||||||
@ -434,6 +462,32 @@ TESTO=./test$$.o
|
|||||||
TESTP=./test$$
|
TESTP=./test$$
|
||||||
rm -f $TESTO $TESTP
|
rm -f $TESTO $TESTP
|
||||||
|
|
||||||
|
has_musl=no
|
||||||
|
#
|
||||||
|
# if directed to use libmusl instead of (g)libc ...
|
||||||
|
#
|
||||||
|
if [ ! "$try_libmusl" = no ]; then
|
||||||
|
echo $ac_n "checking for libmusl ... "$ac_c
|
||||||
|
mgcc=`config/which musl-gcc`
|
||||||
|
if [ -x "$mgcc" ]; then
|
||||||
|
CC="$mgcc"
|
||||||
|
fi
|
||||||
|
if [ -x "$try_musl" ]; then
|
||||||
|
CC="$try_musl"
|
||||||
|
fi
|
||||||
|
if [ -x "$try_musl/musl-gcc" ]; then
|
||||||
|
CC="$try_musl/musl-gcc"
|
||||||
|
fi
|
||||||
|
if [ -x "$try_musl/bin/musl-gcc" ]; then
|
||||||
|
CC="$try_musl/bin/musl-gcc"
|
||||||
|
fi
|
||||||
|
if [ -x /opt/musl/bin/musl-gcc ]; then
|
||||||
|
CC=/opt/musl/bin/musl-gcc
|
||||||
|
fi
|
||||||
|
CCshort=$CC
|
||||||
|
echo $ac_t yes
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# does the C compile work?
|
# does the C compile work?
|
||||||
#
|
#
|
||||||
@ -829,6 +883,29 @@ elif [ ! "$ft_md5" = no ]; then
|
|||||||
rm -f $TESTP
|
rm -f $TESTP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# check for perl scripting support
|
||||||
|
#
|
||||||
|
has_perl=no
|
||||||
|
perlinclude=
|
||||||
|
libperl=
|
||||||
|
if [ ! "$ft_perl" = no ]; then
|
||||||
|
echo $ac_n "checking for perl ... "$ac_c
|
||||||
|
pinc1=`perl -MConfig -e 'print $Config{archlib}'`
|
||||||
|
if [ -r $pinc1/CORE/perl.h -a -r $pinc1/CORE/EXTERN.h -a -r $pinc1/CORE/XSUB.h ]; then
|
||||||
|
perlinclude=$pinc1/CORE
|
||||||
|
TESTC=config/perl.c
|
||||||
|
if $CC -o $TESTP $TESTC -I$perlinclude -L$perlinclude -lperl 1> /dev/null 2> /dev/null; then
|
||||||
|
has_perl=yes
|
||||||
|
libperl=-lperl
|
||||||
|
I_PERL=-I$perlinclude
|
||||||
|
L_PERL=-L$perlinclude
|
||||||
|
fi
|
||||||
|
rm -f $TESTP
|
||||||
|
fi
|
||||||
|
echo $ac_t "$has_perl"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# check for tcl
|
# check for tcl
|
||||||
#
|
#
|
||||||
@ -977,6 +1054,28 @@ if [ "$silentopt" = yes ]; then
|
|||||||
out=/bin/true
|
out=/bin/true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# is this a git environment
|
||||||
|
#
|
||||||
|
echo $ac_n "checking for git ... "$ac_c
|
||||||
|
GITEXE=`config/which git`
|
||||||
|
echo $ac_t "$GITEXE"
|
||||||
|
|
||||||
|
#
|
||||||
|
# multiple cpus/cores for multiple parallell compiler jobs (make -j#)
|
||||||
|
#
|
||||||
|
cores=1
|
||||||
|
if [ -r /proc/cpuinfo ]; then
|
||||||
|
echo $ac_n "checking for multiple cpus or multiple cores ... "$ac_c
|
||||||
|
cores=`cat /proc/cpuinfo | grep '^processor' | wc -l`
|
||||||
|
echo $ac_t "$cores cpus/cores"
|
||||||
|
fi
|
||||||
|
|
||||||
|
makejobs=
|
||||||
|
if [ ! "$cores" = 1 ]; then
|
||||||
|
makejobs="-j$cores"
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
$out "Do you want ..."
|
$out "Do you want ..."
|
||||||
$out
|
$out
|
||||||
@ -1141,11 +1240,11 @@ fi
|
|||||||
#
|
#
|
||||||
def_perl='#undef PERL'
|
def_perl='#undef PERL'
|
||||||
unset ans
|
unset ans
|
||||||
echo $ac_n "[ ALPHA] Perl scripting support? .................... [y/N] "$ac_c
|
$out $ac_n "[ ALPHA] Perl scripting support? .................... [y/N] "$ac_c
|
||||||
if [ "$has_perl" = no ]; then
|
if [ "$has_perl" = no ]; then
|
||||||
echo 'no (unsupported)'
|
$out 'no (unsupported)'
|
||||||
else
|
else
|
||||||
test "$ft_perl" && echo "$ft_perl" && ans=$ft_perl
|
test "$ft_perl" && $out "$ft_perl" && ans=$ft_perl
|
||||||
test -z "$ft_perl" && read ans
|
test -z "$ft_perl" && read ans
|
||||||
test "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_perl='#define PERL'
|
test "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_perl='#define PERL'
|
||||||
fi
|
fi
|
||||||
@ -1248,7 +1347,7 @@ echo "Creating src/Makefile"
|
|||||||
|
|
||||||
O_FLAGS="$cc_optimize_flag $cc_arch_flag $cc_march_flag $cc_ofp_flag"
|
O_FLAGS="$cc_optimize_flag $cc_arch_flag $cc_march_flag $cc_ofp_flag"
|
||||||
W_FLAGS="$cc_wall_flag $cc_wshadow_flag $cc_fnostrictalias"
|
W_FLAGS="$cc_wall_flag $cc_wshadow_flag $cc_fnostrictalias"
|
||||||
libflags="$libcrypt $libtcl $libnsl $libsocket $libresolv $libpython"
|
libflags="$libcrypt $libtcl $libnsl $libsocket $libresolv $libpython $libperl"
|
||||||
lflags="$cc_g_flag -o"
|
lflags="$cc_g_flag -o"
|
||||||
cprof="$cc_pg_flag $cc_pg_define"
|
cprof="$cc_pg_flag $cc_pg_define"
|
||||||
lprof="$cc_pg_flag $cc_pg_define $libpgdl"
|
lprof="$cc_pg_flag $cc_pg_define $libpgdl"
|
||||||
@ -1265,12 +1364,15 @@ s%@gdbflag@%$cc_g_flag%;
|
|||||||
/@libflags@/ { s,@libflags@,$libflags,; };
|
/@libflags@/ { s,@libflags@,$libflags,; };
|
||||||
/@W_FLAGS@/ { s/@W_FLAGS@/$W_FLAGS/; };
|
/@W_FLAGS@/ { s/@W_FLAGS@/$W_FLAGS/; };
|
||||||
/@O_FLAGS@/ { s/@O_FLAGS@/$O_FLAGS/; };
|
/@O_FLAGS@/ { s/@O_FLAGS@/$O_FLAGS/; };
|
||||||
|
/@I_PERL@/ { s,@I_PERL@,$I_PERL,; };
|
||||||
|
/@L_PERL@/ { s,@L_PERL@,$L_PERL,; };
|
||||||
/@PYINCLUDE@/ { s,@PYINCLUDE@,$incpython,; };
|
/@PYINCLUDE@/ { s,@PYINCLUDE@,$incpython,; };
|
||||||
/@TCLINCLUDE@/ { s,@TCLINCLUDE@,$inctcl,; };
|
/@TCLINCLUDE@/ { s,@TCLINCLUDE@,$inctcl,; };
|
||||||
s|@MD5_O@|$MD5_O|;
|
s|@MD5_O@|$MD5_O|;
|
||||||
s|@SHA_O@|$SHA_O|;
|
s|@SHA_O@|$SHA_O|;
|
||||||
s%@oc@%$objcomment%;
|
s%@oc@%$objcomment%;
|
||||||
s%@sz@%$sizecomment%;
|
s%@sz@%$sizecomment%;
|
||||||
|
s%@makejobs@%$makejobs%;
|
||||||
s/[ ]*\$//g;
|
s/[ ]*\$//g;
|
||||||
" < src/Makefile.in >> src/Makefile || exit 1
|
" < src/Makefile.in >> src/Makefile || exit 1
|
||||||
|
|
||||||
@ -1333,19 +1435,26 @@ s|@UNALIGNED_MEM@|$UNALIGNED_MEM|;
|
|||||||
" < src/config.h.in >> src/config.h
|
" < src/config.h.in >> src/config.h
|
||||||
|
|
||||||
if [ "$install" = yes ]; then
|
if [ "$install" = yes ]; then
|
||||||
make -C src energymech
|
make $makejobs -C src energymech
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$compile" = yes ]; then
|
if [ "$compile" = yes ]; then
|
||||||
make -C src energymech
|
make $makejobs -C src energymech
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ''
|
echo ''
|
||||||
echo 'All done. You can now "make clean install"'
|
echo 'All done. You can now "make install"'
|
||||||
|
if [ ! "$cores" = 1 ]; then
|
||||||
|
echo "For speedy compiling, use \`\`make -j$cores''"
|
||||||
|
fi
|
||||||
echo ''
|
echo ''
|
||||||
echo 'Submit your bugreports at https://github.com/MadCamel/energymech/issues'
|
echo 'Submit your bugreports at https://github.com/MadCamel/energymech/issues'
|
||||||
echo ''
|
echo ''
|
||||||
echo 'You have read the README file I hope?'
|
echo 'You have read the README file I hope?'
|
||||||
echo ''
|
echo ''
|
||||||
|
|
||||||
|
# make: 7.962u 0.870s 0:08.52 103.6% 0+0k 0+0io 0pf+0w
|
||||||
|
# make -j4: 8.779u 1.069s 0:03.11 316.0% 0+0k 0+0io 0pf+0w
|
||||||
|
# make -j8: 8.977u 1.064s 0:02.92 343.4% 0+0k 0+0io 0pf+0w
|
||||||
|
|||||||
@ -31,6 +31,8 @@ WARNFLAG = @W_FLAGS@
|
|||||||
OPTIMIZE = @O_FLAGS@
|
OPTIMIZE = @O_FLAGS@
|
||||||
PYINCLUDE = @PYINCLUDE@
|
PYINCLUDE = @PYINCLUDE@
|
||||||
TCLINCLUDE = @TCLINCLUDE@
|
TCLINCLUDE = @TCLINCLUDE@
|
||||||
|
I_PERL = @I_PERL@
|
||||||
|
L_PERL = @L_PERL@
|
||||||
|
|
||||||
CFLAGS = $(PIPEFLAG) $(GDBFLAG) $(WARNFLAG) $(OPTIMIZE)
|
CFLAGS = $(PIPEFLAG) $(GDBFLAG) $(WARNFLAG) $(OPTIMIZE)
|
||||||
LFLAGS = $(PIPEFLAG) $(GDBFLAG)
|
LFLAGS = $(PIPEFLAG) $(GDBFLAG)
|
||||||
@ -58,6 +60,8 @@ SRCFILES = alias.c auth.c bounce.c chanban.c channel.c core.c \
|
|||||||
spy.c stats.c tcl.c telnet.c toybox.c trivia.c uptime.c urlcap.c \
|
spy.c stats.c tcl.c telnet.c toybox.c trivia.c uptime.c urlcap.c \
|
||||||
user.c vars.c web.c
|
user.c vars.c web.c
|
||||||
|
|
||||||
|
.PHONY: all clean mega-install mega mega-static test commands
|
||||||
|
|
||||||
all: $(INSTALLNAME)
|
all: $(INSTALLNAME)
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -78,16 +82,16 @@ install: $(INSTALLNAME)
|
|||||||
$(CHMOD) $(INSTALLMODE) $(INSTALLNAME)
|
$(CHMOD) $(INSTALLMODE) $(INSTALLNAME)
|
||||||
$(MV) $(INSTALLNAME) $(INSTALLDIR)
|
$(MV) $(INSTALLNAME) $(INSTALLDIR)
|
||||||
|
|
||||||
clean: FORCE
|
clean:
|
||||||
$(RM) $(INSTALLNAME) gencmd mcmd.h usercombo.h core $(TESTFILES) $(OFILES)
|
$(RM) $(INSTALLNAME) gencmd mcmd.h usercombo.h core $(TESTFILES) $(OFILES)
|
||||||
|
|
||||||
$(INSTALLNAME): $(OFILES)
|
$(INSTALLNAME): $(OFILES)
|
||||||
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT)
|
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL)
|
||||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||||
@sz@ size $(INSTALLNAME)
|
@sz@ size $(INSTALLNAME)
|
||||||
|
|
||||||
$(INSTALLNAME)-static: $(OFILES)
|
$(INSTALLNAME)-static: $(OFILES)
|
||||||
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) -static
|
$(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL) -static
|
||||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||||
@sz@ size $(INSTALLNAME)
|
@sz@ size $(INSTALLNAME)
|
||||||
|
|
||||||
@ -103,12 +107,12 @@ mega-install: mega $(SRCFILES) $(INCS) usage.h
|
|||||||
$(MV) $(INSTALLNAME) $(INSTALLDIR)
|
$(MV) $(INSTALLNAME) $(INSTALLDIR)
|
||||||
|
|
||||||
mega: $(SRCFILES) $(INCS) usage.h
|
mega: $(SRCFILES) $(INCS) usage.h
|
||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE)
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL)
|
||||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||||
@sz@ size $(INSTALLNAME)
|
@sz@ size $(INSTALLNAME)
|
||||||
|
|
||||||
mega-static: $(SRCFILES) $(INCS) usage.h
|
mega-static: $(SRCFILES) $(INCS) usage.h
|
||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) -static
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) -static
|
||||||
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME)
|
||||||
@sz@ size $(INSTALLNAME)
|
@sz@ size $(INSTALLNAME)
|
||||||
|
|
||||||
@ -203,7 +207,7 @@ parse.o: parse.c $(INCS)
|
|||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||||
|
|
||||||
perl.o: perl.c $(INCS)
|
perl.o: perl.c $(INCS)
|
||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) $(I_PERL) -c $< $(CPROF)
|
||||||
|
|
||||||
prot.o: prot.c $(INCS)
|
prot.o: prot.c $(INCS)
|
||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF)
|
||||||
@ -265,4 +269,3 @@ md5/md5.o: md5/md5.c $(INCS)
|
|||||||
sha/sha1.o: sha/sha1.c $(INCS)
|
sha/sha1.o: sha/sha1.c $(INCS)
|
||||||
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Isha1 $(CPROF)
|
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@ -Isha1 $(CPROF)
|
||||||
|
|
||||||
FORCE:
|
|
||||||
|
|||||||
@ -1238,7 +1238,7 @@ void debug_rawdns(void)
|
|||||||
|
|
||||||
#endif /* RAWDNS */
|
#endif /* RAWDNS */
|
||||||
|
|
||||||
#if defined(TCL) || defined(PYTHON)
|
#if defined(TCL) || defined(PYTHON) || defined(PERL)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@ -179,7 +179,7 @@ struct
|
|||||||
* Level 70 == JOINLEVEL
|
* Level 70 == JOINLEVEL
|
||||||
*/
|
*/
|
||||||
{ 0, "CYCLE", "do_cycle", 70 | CCPW | CAXS | ACCHAN },
|
{ 0, "CYCLE", "do_cycle", 70 | CCPW | CAXS | ACCHAN },
|
||||||
{ 0, "FORGET", "do_forget", 70 | CCPW | CARGS },
|
{ 0, "FORGET", "do_forget", 70 | CCPW | CAXS | CARGS },
|
||||||
{ 0, "JOIN", "do_join", 70 | CCPW | CARGS },
|
{ 0, "JOIN", "do_join", 70 | CCPW | CARGS },
|
||||||
{ 0, "KS", "do_kicksay", 70 | CCPW | REDIR | LBUF },
|
{ 0, "KS", "do_kicksay", 70 | CCPW | REDIR | LBUF },
|
||||||
{ 0, "PART", "do_part", 70 | CCPW | CAXS | ACCHAN },
|
{ 0, "PART", "do_part", 70 | CCPW | CAXS | ACCHAN },
|
||||||
@ -251,6 +251,12 @@ struct
|
|||||||
{ 0, "DEBUG", "do_debug", 100 | CCPW | GAXS },
|
{ 0, "DEBUG", "do_debug", 100 | CCPW | GAXS },
|
||||||
{ 0, "CRASH", "do_crash", 100 | CCPW | GAXS },
|
{ 0, "CRASH", "do_crash", 100 | CCPW | GAXS },
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
#ifdef PERL
|
||||||
|
#ifdef PLEASE_HACK_MY_SHELL
|
||||||
|
{ 0, "PERL", "do_perl", 100 | CCPW | GAXS | CARGS },
|
||||||
|
#endif /* PLEASE_HACK_MY_SHELL */
|
||||||
|
{ 0, "PERLSCRIPT", "do_perlscript", 100 | CCPW | GAXS | CARGS },
|
||||||
|
#endif /* PERL */
|
||||||
#ifdef PYTHON
|
#ifdef PYTHON
|
||||||
#ifdef PLEASE_HACK_MY_SHELL
|
#ifdef PLEASE_HACK_MY_SHELL
|
||||||
{ 0, "PYTHON", "do_python", 100 | CCPW | GAXS | CARGS },
|
{ 0, "PYTHON", "do_python", 100 | CCPW | GAXS | CARGS },
|
||||||
|
|||||||
4
src/h.h
4
src/h.h
@ -190,6 +190,10 @@ LS void netchanSuppress(BotNet *, char *) __page(CORE_SEG);
|
|||||||
/* ons.c */
|
/* ons.c */
|
||||||
/* parse.c */
|
/* parse.c */
|
||||||
/* perl.c */
|
/* perl.c */
|
||||||
|
|
||||||
|
LS void do_perl(COMMAND_ARGS) __page(CMD1_SEG);
|
||||||
|
LS void do_perlscript(COMMAND_ARGS) __page(CMD1_SEG);
|
||||||
|
|
||||||
/* prot.c */
|
/* prot.c */
|
||||||
/* python.c */
|
/* python.c */
|
||||||
/* redirect.c */
|
/* redirect.c */
|
||||||
|
|||||||
@ -948,6 +948,9 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
|
|||||||
else
|
else
|
||||||
to_file(1,"error: Missing argument for -p <string>\n");
|
to_file(1,"error: Missing argument for -p <string>\n");
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
case 't':
|
||||||
|
startup = 666;
|
||||||
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
debug_on_exit = TRUE;
|
debug_on_exit = TRUE;
|
||||||
break;
|
break;
|
||||||
@ -1120,6 +1123,8 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
|
|||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (startup == 666)
|
||||||
|
exit(0);
|
||||||
startup = FALSE;
|
startup = FALSE;
|
||||||
doit();
|
doit();
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/perl.c
42
src/perl.c
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
EnergyMech, IRC bot software
|
EnergyMech, IRC bot software
|
||||||
Copyright (c) 2001-2009 proton
|
|
||||||
Copyright (c) 2001 MadCamel
|
Copyright (c) 2001 MadCamel
|
||||||
|
Copyright (c) 2001-2018 proton
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -19,11 +19,17 @@
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PERL_C
|
#define PERL_C
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef PERL
|
#ifdef PERL
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
typedef __off64_t off64_t;
|
||||||
|
#define __off64_t_defined
|
||||||
|
#endif /* __x86_64__ */
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@ -32,11 +38,11 @@
|
|||||||
#include "mcmd.h"
|
#include "mcmd.h"
|
||||||
|
|
||||||
#include "EXTERN.h"
|
#include "EXTERN.h"
|
||||||
#include "perl.h"
|
|
||||||
#include "XSUB.h"
|
#include "XSUB.h"
|
||||||
#include "perl.h"
|
#include "perl.h"
|
||||||
|
|
||||||
PerlInterpreter *energymech_perl = NULL;
|
PerlInterpreter *energymech_perl = NULL;
|
||||||
|
#define my_perl energymech_perl
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parse_jump() translates from C to perl
|
* parse_jump() translates from C to perl
|
||||||
@ -55,8 +61,8 @@ int perl_parse_jump(char *from, char *rest, Hook *hook)
|
|||||||
args[1] = rest;
|
args[1] = rest;
|
||||||
args[2] = NULL;
|
args[2] = NULL;
|
||||||
|
|
||||||
/* Call_argv returns the # of args returned from perl */
|
/* call_argv returns the # of args returned from perl */
|
||||||
if (call_argv(Hook->self, G_EVAL|G_SCALAR, args) < 1)
|
if (call_argv(hook->self, G_EVAL|G_SCALAR, args) < 1)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
SPAGAIN; /* Rehash stack, it's probably been clobbered */
|
SPAGAIN; /* Rehash stack, it's probably been clobbered */
|
||||||
@ -86,29 +92,23 @@ XS(XS_perl_parse_hook)
|
|||||||
* but I don't know if it's safe to point directly in to perl
|
* but I don't know if it's safe to point directly in to perl
|
||||||
* space like that.
|
* space like that.
|
||||||
*/
|
*/
|
||||||
if ((name = strdup(SvPV(ST(0), i)))) == NULL)
|
if ((name = SvPV_nolen(ST(0))) == NULL)
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
|
|
||||||
if ((sub = strdup(SvPV(ST(0), i)))) == NULL)
|
if ((sub = SvPV_nolen(ST(0))) == NULL)
|
||||||
{
|
|
||||||
free(name);
|
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make a Hook struct and link it into the parse hook list
|
* make a Hook struct and link it into the parse hook list
|
||||||
*/
|
*/
|
||||||
set_mallocdoer(perl_parse_hook);
|
set_mallocdoer(XS_perl_parse_hook);
|
||||||
hook = (Hook*)Calloc(sizeof(Hook) + Strlen2(name,sub)); // sub is never NULL
|
hook = (Hook*)Calloc(sizeof(Hook) + Strlen2(name,sub)); // sub is never NULL
|
||||||
hook->func = perl_parse_jump;
|
hook->func = perl_parse_jump;
|
||||||
hook->next = hooklist;
|
hook->next = hooklist;
|
||||||
hooklist = hook;
|
hooklist = hook;
|
||||||
|
|
||||||
hook->command = Strcpy(hook->self,sub) + 1;
|
hook->type.command = Strcpy(hook->self,sub) + 1;
|
||||||
Strcpy(hook->command,name);
|
Strcpy(hook->type.command,name);
|
||||||
|
|
||||||
free(name);
|
|
||||||
free(sub);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return successful status to script
|
* return successful status to script
|
||||||
@ -126,7 +126,7 @@ void init_perl(void)
|
|||||||
/*
|
/*
|
||||||
* make parse_hook() callable from scripts
|
* make parse_hook() callable from scripts
|
||||||
*/
|
*/
|
||||||
newXS("mech::parse_hook", XS_perl_parse_hook, "mech");
|
newXS("mech::hook", XS_perl_parse_hook, "mech");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_perl(COMMAND_ARGS)
|
void do_perl(COMMAND_ARGS)
|
||||||
@ -134,6 +134,8 @@ void do_perl(COMMAND_ARGS)
|
|||||||
/*
|
/*
|
||||||
* call init_perl() if the perl interpreter isnt initialized yet
|
* call init_perl() if the perl interpreter isnt initialized yet
|
||||||
*/
|
*/
|
||||||
|
if (energymech_perl == NULL)
|
||||||
|
init_perl();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call the perl interpreter with the content of *rest
|
* call the perl interpreter with the content of *rest
|
||||||
@ -152,6 +154,8 @@ void do_perlscript(COMMAND_ARGS)
|
|||||||
/*
|
/*
|
||||||
* call init_perl() if the perl interpreter isnt initialized yet
|
* call init_perl() if the perl interpreter isnt initialized yet
|
||||||
*/
|
*/
|
||||||
|
if (energymech_perl == NULL)
|
||||||
|
init_perl();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* chop(&rest) for name of script filename and load it into the perl interpreter
|
* chop(&rest) for name of script filename and load it into the perl interpreter
|
||||||
@ -160,10 +164,10 @@ void do_perlscript(COMMAND_ARGS)
|
|||||||
args[1] = chop(&rest);
|
args[1] = chop(&rest);
|
||||||
|
|
||||||
/* FIXME: Trap parse errors */
|
/* FIXME: Trap parse errors */
|
||||||
perl_parse(energymech_perl, NULL, 1, argv, (char **)NULL);
|
perl_parse(energymech_perl, NULL, 1, args, (char **)NULL);
|
||||||
|
|
||||||
/* Call sub named Init, what should contain
|
/* Call sub named Init, what should contain
|
||||||
* mech::perl_parse_hook("PRIVMSG", "yoink_privmsg");
|
* mech::hook("PRIVMSG", "yoink_privmsg");
|
||||||
* Note to self: Wouldn't it be better to pass subs by
|
* Note to self: Wouldn't it be better to pass subs by
|
||||||
* Reference(perl ver of pointer) instead of name?
|
* Reference(perl ver of pointer) instead of name?
|
||||||
* How the fsck do i do that?!
|
* How the fsck do i do that?!
|
||||||
@ -173,7 +177,7 @@ void do_perlscript(COMMAND_ARGS)
|
|||||||
{
|
{
|
||||||
STRLEN n_a;
|
STRLEN n_a;
|
||||||
to_user(from, "perl script %s failed to init: %s",
|
to_user(from, "perl script %s failed to init: %s",
|
||||||
argv[1], SvPV(ERRSV, n_a));
|
args[1], SvPV(ERRSV, n_a));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* be verbose about success or fail to the user
|
* be verbose about success or fail to the user
|
||||||
|
|||||||
18
src/trivia.c
18
src/trivia.c
@ -325,7 +325,7 @@ void trivia_no_answer(void)
|
|||||||
|
|
||||||
char *random_question(char *triv_rand)
|
char *random_question(char *triv_rand)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p,tmpname[120];
|
||||||
off_t sz;
|
off_t sz;
|
||||||
int fd,ifd;
|
int fd,ifd;
|
||||||
int n;
|
int n;
|
||||||
@ -336,10 +336,22 @@ char *random_question(char *triv_rand)
|
|||||||
|
|
||||||
} entry;
|
} entry;
|
||||||
|
|
||||||
if ((fd = open(triv_qfile,O_RDONLY)) < 0)
|
if (STRCHR(triv_qfile,'/') || strlen(triv_qfile) > 100) // really bad filenames...
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
Strcpy(triv_rand,triv_qfile);
|
Strcat(Strcpy(tmpname,"trivia/"),triv_qfile);
|
||||||
|
|
||||||
|
if ((fd = open(tmpname,O_RDONLY)) < 0)
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
debug("(random_question) %s: %s\n",tmpname,strerror(errno));
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return(NULL);
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
Strcpy(triv_rand,tmpname);
|
||||||
if ((p = STRCHR(triv_rand,'.')) == NULL)
|
if ((p = STRCHR(triv_rand,'.')) == NULL)
|
||||||
p = STREND(triv_rand);
|
p = STREND(triv_rand);
|
||||||
Strcpy(p,".index");
|
Strcpy(p,".index");
|
||||||
|
|||||||
7
trivia/README
Normal file
7
trivia/README
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Trivia game files
|
||||||
|
|
||||||
|
trivia question file needs to be 1 line per question, each line in the form ``question*answer''
|
||||||
|
|
||||||
|
compile mkindex and run ``./mkindex <triviafile>'' to build the necessary index
|
||||||
|
|
||||||
|
put ``set qfile <triviafile>'' in your mechs config file, the mech will try to open ``trivia/<triviafile>'' when you start trivia
|
||||||
Loading…
x
Reference in New Issue
Block a user