Merge branch 'master' into debian
This commit is contained in:
commit
699989ccd5
152
GNUmakefile.debian
Normal file
152
GNUmakefile.debian
Normal file
@ -0,0 +1,152 @@
|
||||
ifdef PREFIX
|
||||
prefix := $(PREFIX)
|
||||
else
|
||||
prefix := /opt/magicka
|
||||
endif
|
||||
|
||||
exec_prefix := $(prefix)
|
||||
datarootdir = $(prefix)/share
|
||||
datadir = $(datarootdir)
|
||||
bindir = $(exec_prefix)/bin
|
||||
localstatedir = $(prefix)/var
|
||||
sysconfdir = $(prefix)/etc
|
||||
|
||||
user := magicka
|
||||
|
||||
all: magicka
|
||||
|
||||
.PHONY: magicka www clean cleanwww install
|
||||
|
||||
magicka:
|
||||
cd src && $(MAKE) -f GNUmakefile.debian MAGIEDIT_ANSI_PATH="$(datarootdir)/magicka/ansis/" MAGIEDIT_DRAFT_PATH="$(datarootdir)/magicka/ansis/"
|
||||
|
||||
www:
|
||||
cd src && $(MAKE) -f GNUmakefile.debian MAGIEDIT_ANSI_PATH="$(datarootdir)/magicka/ansis/" MAGIEDIT_DRAFT_PATH="$(datarootdir)/magicka/ansis/" www
|
||||
|
||||
clean:
|
||||
cd src && $(MAKE) -f GNUmakefile.debian clean
|
||||
|
||||
cleanwww:
|
||||
cd src && $(MAKE) -f GNUmakefile.debian clean
|
||||
|
||||
install:
|
||||
install -m755 -d ${DESTDIR}${bindir}
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/doc/magicka
|
||||
install -m755 -d ${DESTDIR}${localstatedir}/magicka
|
||||
install -m755 -d ${DESTDIR}${sysconfdir}/magicka
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/magicka
|
||||
install -m755 -d ${DESTDIR}${localstatedir}/magicka/logs
|
||||
install -m755 -d ${DESTDIR}${localstatedir}/magicka/msgs
|
||||
install -m755 -d ${DESTDIR}${localstatedir}/magicka/files/misc
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/magicka/scripts/data
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/magicka/ansis
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/magicka/www/static/fonts
|
||||
install -m755 -d ${DESTDIR}${datarootdir}/magicka/menus
|
||||
|
||||
install -m755 magicka ${DESTDIR}${bindir}/magicka
|
||||
install -m755 utils/dosbox_shim/shim ${DESTDIR}${bindir}/magi_shim
|
||||
install -m755 utils/filecenter/filecenter ${DESTDIR}${bindir}/magi_filecenter
|
||||
install -m755 utils/magichat/magichat ${DESTDIR}${bindir}/magichat
|
||||
install -m755 utils/magiedit/magiedit ${DESTDIR}${bindir}/magiedit
|
||||
install -m755 utils/magiftpd/magiftpd ${DESTDIR}${bindir}/magiftpd
|
||||
install -m755 utils/magimail/bin/magiexport ${DESTDIR}${bindir}/magiexport
|
||||
install -m755 utils/magimail/bin/magigetnode ${DESTDIR}${bindir}/magigetnode
|
||||
install -m755 utils/magimail/bin/magilist ${DESTDIR}${bindir}/magilist
|
||||
install -m755 utils/magimail/bin/magilistout ${DESTDIR}${bindir}/magilistout
|
||||
install -m755 utils/magimail/bin/magimail ${DESTDIR}${bindir}/magimail
|
||||
install -m755 utils/magimail/bin/magimaint ${DESTDIR}${bindir}/magimaint
|
||||
install -m755 utils/magimail/bin/magistats ${DESTDIR}${bindir}/magistats
|
||||
install -m755 utils/magimail/bin/magiwrite ${DESTDIR}${bindir}/magiwrite
|
||||
install -m755 utils/massupload/massupload.pl ${DESTDIR}${bindir}/magi_massupload.pl
|
||||
install -m755 utils/mgpost/mgpost ${DESTDIR}${bindir}/mgpost
|
||||
install -m755 utils/nodelistp/nodelistp.pl ${DESTDIR}${bindir}/magi_nodelistp.pl
|
||||
install -m755 utils/reset_pass/reset_pass ${DESTDIR}${bindir}/magi_reset_pass
|
||||
install -m755 utils/ticproc/ticproc ${DESTDIR}${bindir}/magi_ticproc
|
||||
|
||||
install -m644 dist/config/bbs.ini ${DESTDIR}${sysconfdir}/magicka/bbs.ini
|
||||
sed -i "s@__CONFIGPREFIX__@${sysconfdir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/bbs.ini
|
||||
sed -i "s@__LOCALSTATEPREFIX__@${localstatedir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/bbs.ini
|
||||
sed -i "s@__SHAREPREFIX__@${datarootdir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/bbs.ini
|
||||
sed -i "s@__EXECPREFIX__@${bindir}@g" ${DESTDIR}${sysconfdir}/magicka/bbs.ini
|
||||
|
||||
install -m644 dist/config/archivers.ini ${DESTDIR}${sysconfdir}/magicka/archivers.ini
|
||||
install -m644 dist/config/doors.ini ${DESTDIR}${sysconfdir}/magicka/doors.ini
|
||||
install -m644 dist/config/protocols.ini ${DESTDIR}${sysconfdir}/magicka/protocols.ini
|
||||
install -m644 dist/config/s10.ini ${DESTDIR}${sysconfdir}/magicka/s10.ini
|
||||
|
||||
install -m644 dist/config/filesgen.ini ${DESTDIR}${sysconfdir}/magicka/filesgen.ini
|
||||
sed -i "s@__LOCALSTATEPREFIX__@$${localstatedir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/filesgen.ini
|
||||
|
||||
|
||||
install -m644 dist/config/happynet.ini ${DESTDIR}${sysconfdir}/magicka/happynet.ini
|
||||
sed -i "s@__LOCALSTATEPREFIX__@${localstatedir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/happynet.ini
|
||||
|
||||
install -m644 dist/config/localmail.ini ${DESTDIR}${sysconfdir}/magicka/localmail.ini
|
||||
sed -i "s@__LOCALSTATEPREFIX__@${localstatedir}/magicka@g" ${DESTDIR}${sysconfdir}/magicka/localmail.ini
|
||||
|
||||
install -m755 utils/magiedit/magiedit.sh ${DESTDIR}${bindir}/magiedit.sh
|
||||
sed -i "s@__LOCALSTATEPREFIX__@${localstatedir}/magicka@g" ${DESTDIR}${bindir}/magiedit.sh
|
||||
sed -i "s@__EXECPREFIX__@${bindir}@g" ${DESTDIR}${bindir}/magiedit.sh
|
||||
|
||||
install -m644 dist/magicka.strings ${DESTDIR}${datarootdir}/magicka/magicka.strings
|
||||
|
||||
install -m644 dist/scripts/doors.lua ${DESTDIR}${datarootdir}/magicka/scripts/doors.lua
|
||||
install -m644 dist/scripts/filemenu.lua ${DESTDIR}${datarootdir}/magicka/scripts/filemenu.lua
|
||||
install -m644 dist/scripts/login_stanza.lua ${DESTDIR}${datarootdir}/magicka/scripts/login_stanza.lua
|
||||
|
||||
sed -i "s@__SHAREPREFIX__@${datarootdir}/magicka@g" ${DESTDIR}${datarootdir}/magicka/scripts/login_stanza.lua
|
||||
|
||||
install -m644 dist/scripts/logoff.lua ${DESTDIR}${datarootdir}/magicka/scripts/logoff.lua
|
||||
install -m644 dist/scripts/logout_stanza.lua ${DESTDIR}${datarootdir}/magicka/scripts/logout_stanza.lua
|
||||
install -m644 dist/scripts/mailmenu.lua ${DESTDIR}${datarootdir}/magicka/scripts/mailmenu.lua
|
||||
install -m644 dist/scripts/mainmenu.lua ${DESTDIR}${datarootdir}/magicka/scripts/mainmenu.lua
|
||||
install -m644 dist/scripts/data/taglines.txt ${DESTDIR}${datarootdir}/magicka/scripts/data/taglines.txt
|
||||
|
||||
install -m644 dist/ansis/bulletin0.ans ${DESTDIR}${datarootdir}/magicka/ansis/bulletin0.ans
|
||||
install -m644 dist/ansis/bulletin1.ans ${DESTDIR}${datarootdir}/magicka/ansis/bulletin1.ans
|
||||
install -m644 dist/ansis/doors.ans ${DESTDIR}${datarootdir}/magicka/ansis/doors.ans
|
||||
install -m644 dist/ansis/filemenu.ans ${DESTDIR}${datarootdir}/magicka/ansis/filemenu.ans
|
||||
install -m644 dist/ansis/goodbye.ans ${DESTDIR}${datarootdir}/magicka/ansis/goodbye.ans
|
||||
install -m644 dist/ansis/issue.ans ${DESTDIR}${datarootdir}/magicka/ansis/issue.ans
|
||||
install -m644 dist/ansis/logoff.ans ${DESTDIR}${datarootdir}/magicka/ansis/logoff.ans
|
||||
install -m644 dist/ansis/mailmenu.ans ${DESTDIR}${datarootdir}/magicka/ansis/mailmenu.ans
|
||||
install -m644 dist/ansis/mainmenu.ans ${DESTDIR}${datarootdir}/magicka/ansis/mainmenu.ans
|
||||
install -m644 dist/ansis/newuser.ans ${DESTDIR}${datarootdir}/magicka/ansis/newuser.ans
|
||||
install -m644 utils/magiedit/magiedit.ans ${DESTDIR}${datarootdir}/magicka/ansis/magiedit.ans
|
||||
install -m644 utils/magiedit/magiquote.ans ${DESTDIR}${datarootdir}/magicka/ansis/magiquote.ans
|
||||
|
||||
install -m644 dist/www-bootstrap/401.tpl ${DESTDIR}${datarootdir}/magicka/www/401.tpl
|
||||
install -m644 dist/www-bootstrap/403.tpl ${DESTDIR}${datarootdir}/magicka/www/403.tpl
|
||||
install -m644 dist/www-bootstrap/404.tpl ${DESTDIR}${datarootdir}/magicka/www/404.tpl
|
||||
install -m644 dist/www-bootstrap/footer.tpl ${DESTDIR}${datarootdir}/magicka/www/footer.tpl
|
||||
install -m644 dist/www-bootstrap/header.tpl ${DESTDIR}${datarootdir}/magicka/www/header.tpl
|
||||
install -m644 dist/www-bootstrap/index.tpl ${DESTDIR}${datarootdir}/magicka/www/index.tpl
|
||||
install -m644 dist/www-bootstrap/mime.types ${DESTDIR}${datarootdir}/magicka/www/mime.types
|
||||
|
||||
install -m644 dist/www-bootstrap/static/delete.png ${DESTDIR}${datarootdir}/magicka/www/static/delete.png
|
||||
install -m644 dist/www-bootstrap/static/flag.png ${DESTDIR}${datarootdir}/magicka/www/static/flag.png
|
||||
install -m644 dist/www-bootstrap/static/header-m.png ${DESTDIR}${datarootdir}/magicka/www/static/header-m.png
|
||||
install -m644 dist/www-bootstrap/static/header.png ${DESTDIR}${datarootdir}/magicka/www/static/header.png
|
||||
install -m644 dist/www-bootstrap/static/newuser.png ${DESTDIR}${datarootdir}/magicka/www/static/newuser.png
|
||||
install -m644 dist/www-bootstrap/static/style.css ${DESTDIR}${datarootdir}/magicka/www/static/style.css
|
||||
install -m644 dist/www-bootstrap/static/style-mobile.css ${DESTDIR}${datarootdir}/magicka/www/static/style-mobile.css
|
||||
|
||||
install -m644 dist/www-bootstrap/static/fonts/LICENSE.TXT ${DESTDIR}${datarootdir}/magicka/www/static/fonts/LICENSE.TXT
|
||||
install -m644 dist/www-bootstrap/static/fonts/pxplus_ibm_vga8-webfont.svg ${DESTDIR}${datarootdir}/magicka/www/static/fonts/pxplus_ibm_vga8-webfont.svg
|
||||
install -m644 dist/www-bootstrap/static/fonts/pxplus_ibm_vga8-webfont.woff ${DESTDIR}${datarootdir}/magicka/www/static/fonts/pxplus_ibm_vga8-webfont.woff
|
||||
install -m644 dist/www-bootstrap/static/fonts/pxplus_ibm_vga8-webfont.woff2 ${DESTDIR}${datarootdir}/magicka/www/static/fonts/pxplus_ibm_vga8-webfont.woff2
|
||||
|
||||
install -m644 dist/menus/doors.mnu ${DESTDIR}${datarootdir}/magicka/menus/doors.mnu
|
||||
install -m644 dist/menus/main.mnu ${DESTDIR}${datarootdir}/magicka/menus/main.mnu
|
||||
install -m644 dist/menus/file.mnu ${DESTDIR}${datarootdir}/magicka/menus/file.mnu
|
||||
install -m644 dist/menus/logoff.mnu ${DESTDIR}${datarootdir}/magicka/menus/logoff.mnu
|
||||
install -m644 dist/menus/mail.mnu ${DESTDIR}${datarootdir}/magicka/menus/mail.mnu
|
||||
|
||||
echo "You should now create a user to run magicka"
|
||||
echo "and assuming that user is magicka:
|
||||
echo " "
|
||||
echo " chown -R magicka:magicka ${datarootdir}/magicka/scripts/data"
|
||||
echo " chown -R magicka:magicka ${localstatedir}/magicka"
|
||||
echo " "
|
||||
echo "Then configure ${sysconfdir}/magicka/bbs.ini to your liking"
|
||||
|
38
dist/config/bbs.ini
vendored
38
dist/config/bbs.ini
vendored
@ -9,7 +9,7 @@ MagiChat Server = localhost
|
||||
MagiChat Port = 6667
|
||||
MagiChat BBSTag = Magicka
|
||||
Default Tagline = Brought to you by Another Magicka BBS!
|
||||
External Editor cmd = /home/andrew/MagickaBBS/utils/magiedit/magiedit.sh
|
||||
External Editor cmd = __EXECPREFIX__/magiedit.sh
|
||||
External Editor stdio = true
|
||||
External Editor Codepage = CP437
|
||||
Automessage Write Level = 10
|
||||
@ -20,8 +20,8 @@ WWW Port = 8080
|
||||
WWW URL = http://127.0.0.1:8080/
|
||||
Enable SSH = false
|
||||
SSH Port = 2024
|
||||
SSH DSA Key = /home/andrew/MagickaBBS/keys/ssh_host_dsa_key
|
||||
SSH RSA Key = /home/andrew/MagickaBBS/keys/ssh_host_rsa_key
|
||||
SSH DSA Key = __CONFIGPREFIX__/keys/ssh_host_dsa_key
|
||||
SSH RSA Key = __CONFIGPREFIX__/keys/ssh_host_rsa_key
|
||||
Main AKA = 1:2/3.4
|
||||
QWK Name = MAGICKA
|
||||
QWK Max Messages = 5000
|
||||
@ -39,25 +39,25 @@ Date Style = EU
|
||||
Enable IPv6 = true
|
||||
|
||||
[paths]
|
||||
Config Path = /home/andrew/MagickaBBS/config
|
||||
WWW Path = /home/andrew/MagickaBBS/www
|
||||
String File = /home/andrew/MagickaBBS/magicka.strings
|
||||
PID File = /home/andrew/MagickaBBS/magicka.pid
|
||||
ANSI Path = /home/andrew/MagickaBBS/ansis
|
||||
BBS Path = /home/andrew/MagickaBBS
|
||||
Log Path = /home/andrew/MagickaBBS/logs
|
||||
Script Path = /home/andrew/MagickaBBS/scripts
|
||||
Echomail Semaphore = /home/andrew/MagickaBBS/echomail.out
|
||||
Netmail Semaphore = /home/andrew/MagickaBBS/netmail.out
|
||||
Menu Path = /home/andrew/MagickaBBS/menus
|
||||
Config Path = __CONFIGPREFIX__
|
||||
WWW Path = __SHAREPREFIX__/www
|
||||
String File = __SHAREPREFIX__/magicka.strings
|
||||
PID File = __LOCALSTATEPREFIX__/magicka.pid
|
||||
ANSI Path = __SHAREPREFIX__/ansis
|
||||
BBS Path = __LOCALSTATEPREFIX__
|
||||
Log Path = __LOCALSTATEPREFIX__/logs
|
||||
Script Path = __SHAREPREFIX__/scripts
|
||||
Echomail Semaphore = __LOCALSTATEPREFIX__/mail.out
|
||||
Netmail Semaphore = __LOCALSTATEPREFIX__/mail.out
|
||||
Menu Path = __SHAREPREFIX__/menus
|
||||
|
||||
[mail conferences]
|
||||
Local Mail = config/localmail.ini
|
||||
HappyNet = config/happynet.ini
|
||||
Local Mail = __CONFIGPREFIX__/localmail.ini
|
||||
HappyNet = __CONFIGPREFIX__/happynet.ini
|
||||
|
||||
[file directories]
|
||||
General Files = config/filesgen.ini
|
||||
General Files = __CONFIGPREFIX__/filesgen.ini
|
||||
|
||||
[text files]
|
||||
Magicka Advertisement = ansis/bulletin0.ans
|
||||
Whats New = ansis/bulletin1.ans
|
||||
Magicka Advertisement = __SHAREPREFIX__/ansis/bulletin0.ans
|
||||
Whats New = __SHAREPREFIX__/ansis/bulletin1.ans
|
||||
|
2
dist/config/filesgen.ini
vendored
2
dist/config/filesgen.ini
vendored
@ -6,4 +6,4 @@ Visible on Web = false
|
||||
Database = files_misc
|
||||
Download Sec Level = 10
|
||||
Upload Sec Level = 10
|
||||
Upload Path = /home/andrew/MagickaBBS/files/misc
|
||||
Upload Path = __LOCALSTATEPREFIX__/files/misc
|
||||
|
4
dist/config/happynet.ini
vendored
4
dist/config/happynet.ini
vendored
@ -15,7 +15,7 @@ domain = happynet
|
||||
[General]
|
||||
Read Sec Level = 10
|
||||
Write Sec Level = 10
|
||||
Path = /home/andrew/MagickaBBS/msgs/hnet_general
|
||||
Path = __LOCALSTATEPREFIX__/msgs/hnet_general
|
||||
; local / echo or netmail
|
||||
Type = Echo
|
||||
QWK Name = HN_GEN
|
||||
@ -23,7 +23,7 @@ QWK Name = HN_GEN
|
||||
[Netmail]
|
||||
Read Sec Level = 10
|
||||
Write Sec Level = 10
|
||||
Path = /home/andrew/MagickaBBS/msgs/hnet_netmail
|
||||
Path = __LOCALSTATEPREFIX__/msgs/hnet_netmail
|
||||
; local / echo or netmail
|
||||
Type = Netmail
|
||||
QWK Name = HN_NET
|
||||
|
4
dist/config/localmail.ini
vendored
4
dist/config/localmail.ini
vendored
@ -6,13 +6,13 @@ Real Names = false
|
||||
[General]
|
||||
Read Sec Level = 10
|
||||
Write Sec Level = 10
|
||||
Path = /home/andrew/MagickaBBS/msgs/general
|
||||
Path = __LOCALSTATEPREFIX__/msgs/general
|
||||
Type = Local
|
||||
QWK Name = GENERAL
|
||||
|
||||
[Testing]
|
||||
Read Sec Level = 10
|
||||
Write Sec Level = 10
|
||||
Path = /home/andrew/MagickaBBS/msgs/testing
|
||||
Path = __LOCALSTATEPREFIX__/msgs/testing
|
||||
Type = Local
|
||||
QWK Name = TEST
|
||||
|
2
dist/scripts/login_stanza.lua
vendored
2
dist/scripts/login_stanza.lua
vendored
@ -1,4 +1,4 @@
|
||||
local bulletin_path = "/home/andrew/MagickaBBS/ansis";
|
||||
local bulletin_path = "__SHAREPREFIX__/ansis";
|
||||
|
||||
|
||||
function file_exists(name)
|
||||
|
21
setup.sh
21
setup.sh
@ -70,16 +70,21 @@ else
|
||||
fi
|
||||
|
||||
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/bbs.ini
|
||||
$SED -i "s@__CONFIGPREFIX__/keys@${PWD}/keys@g" config/bbs.ini
|
||||
$SED -i "s@__CONFIGPREFIX__@${PWD}/config@g" config/bbs.ini
|
||||
$SED -i "s@__LOCALSTATEPREFIX__@${PWD}@g" config/bbs.ini
|
||||
$SED -i "s@__SHAREPREFIX__@${PWD}@g" config/bbs.ini
|
||||
$SED -i "s@__EXECPREFIX__@${PWD}/utils/magiedit/@g" config/bbs.ini
|
||||
$SED -i "s/BBS Name = Magicka BBS/BBS Name = ${bbsname}/g" config/bbs.ini
|
||||
$SED -i "s/Sysop Name = sysop/Sysop Name = ${handle}/g" config/bbs.ini
|
||||
$SED -i "s/USERNAME/${USERNAME}/g" config/bbs.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/localmail.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/filesgen.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/happynet.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" utils/magiedit/magiedit.sh
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" scripts/login_stanza.lua
|
||||
$SED -i "s@__LOCALSTATEPREFIX__@${PWD}@g" config/localmail.ini
|
||||
$SED -i "s@__LOCALSTATEPREFIX__@${PWD}@g" config/filesgen.ini
|
||||
$SED -i "s@__LOCALSTATEPREFIX__@${PWD}@g" config/happynet.ini
|
||||
$SED -i "s@__BINPREFIX__@${PWD}@g" utils/magiedit/magiedit.sh
|
||||
$SED -i "s@cd __LOCALSTATEPREFIX__@cd ${PWD}/utils/magiedit/@g" utils/magiedit/magiedit.sh
|
||||
$SED -i "s@__LOCALSTATEPREFIX__@${PWD}@g" utils/magiedit/magiedit.sh
|
||||
$SED -i "s@__EXECPREFIX__@.@g" utils/magiedit/magiedit.sh
|
||||
$SED -i "s@__SHAREPREFIX__@${PWD}@g" scripts/login_stanza.lua
|
||||
$SED -i "s/MagiChat Server = localhost/; MagiChat Server = localhost/g" config/bbs.ini
|
||||
$SED -i "s/Default Tagline = Brought to you by Another Magicka BBS!/Default Tagline = ${bbsname}/g" config/bbs.ini
|
||||
$SED -i "s/echomail.out/mail.out/g" config/bbs.ini
|
||||
$SED -i "s/netmail.out/mail.out/g" config/bbs.ini
|
||||
|
@ -14,10 +14,10 @@ UUID:= ${DEPSDIR}/libuuid/.libs/libuuid.a
|
||||
CUTEST:= ${DEPSDIR}/cutest-1.5/libcutest.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat \
|
||||
filecenter dosbox_shim magiftpd reset_pass
|
||||
filecenter dosbox_shim magiftpd reset_pass qwknet
|
||||
|
||||
www: magickawww magimail magiedit ticproc mgpost magichat \
|
||||
filecenter dosbox_shim magiftpd reset_pass
|
||||
filecenter dosbox_shim magiftpd reset_pass qwknet
|
||||
|
||||
${LUA}:
|
||||
cd ${DEPSDIR}/lua && ${MAKE} -f Makefile ${DEPS_LUA_TARGET} MAKEFLAGS= CC=${CC}
|
||||
@ -74,7 +74,7 @@ magicka: ${OBJS} ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
|
||||
|
||||
|
||||
magiedit: ${ODOORS}
|
||||
cd ${UTILSDIR}/magiedit && ${MAKE}
|
||||
cd ${UTILSDIR}/magiedit && ${MAKE} ANSI_PATH=${MAGIEDIT_ANSI_PATH} DRAFT_PATH=${MAGIEDIT_DRAFT_PATH}
|
||||
|
||||
magimail: ${JAMLIB}
|
||||
cd ${UTILSDIR}/magimail && ${MAKE} all
|
||||
@ -100,6 +100,9 @@ magiftpd:
|
||||
reset_pass:
|
||||
cd ${UTILSDIR}/reset_pass && ${MAKE}
|
||||
|
||||
qwknet:
|
||||
cd ${UTILSDIR}/qwknet && ${MAKE}
|
||||
|
||||
.PHONY: clean www
|
||||
|
||||
clean:
|
||||
@ -123,3 +126,4 @@ clean:
|
||||
cd ${DEPSDIR}/libuuid && rm -rf .libs
|
||||
cd ${DEPSDIR}/cutest-1.5 && ${MAKE} clean
|
||||
cd ${DEPSDIR}/jsmn && ${MAKE} clean
|
||||
cd ${UTILSDIR}/qwknet && ${MAKE} clean
|
||||
|
11
src/GNUmakefile.debian
Normal file
11
src/GNUmakefile.debian
Normal file
@ -0,0 +1,11 @@
|
||||
CC:= cc
|
||||
CFLAGS:= -std=gnu99 -I/usr/local/include
|
||||
LIBS:= -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -lmosquitto
|
||||
EXTRAOBJS:= strlcpy/strlcpy.o strlcpy/strlcat.o
|
||||
|
||||
LIBTOOLIZE:= libtoolize
|
||||
|
||||
DEPS_LUA_TARGET:= linux
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
include GNUmakefile.common
|
@ -9,4 +9,7 @@ DEPS_CDK_OPTS:= --with-curses-dir=/usr/local
|
||||
DEPS_LUA_TARGET:= dragonfly
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -7,4 +7,7 @@ LIBTOOLIZE:= libtoolize
|
||||
DEPS_LUA_TARGET:= freebsd
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize
|
||||
DEPS_LUA_TARGET:= haiku
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize
|
||||
DEPS_LUA_TARGET:= linux
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -10,4 +10,7 @@ DEPS_JAMLIB_MAKEFILE:= Makefile.linux-musl
|
||||
|
||||
FTSLIB:= FTSLIB=1
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -8,4 +8,7 @@ DEPS_CDK_OPTS:= --with-curses-dir=/usr/pkg
|
||||
DEPS_LUA_TARGET:= bsd
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -7,4 +7,7 @@ LIBTOOLIZE:= libtoolize
|
||||
DEPS_LUA_TARGET:= bsd
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -7,4 +7,7 @@ LIBTOOLIZE:= glibtoolize
|
||||
DEPS_LUA_TARGET:= macosx
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.linux
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize
|
||||
DEPS_LUA_TARGET:= solaris
|
||||
DEPS_JAMLIB_MAKEFILE:= Makefile.sunos
|
||||
|
||||
MAGIEDIT_ANSI_PATH:= ""
|
||||
MAGIEDIT_DRAFT_PATH:= ""
|
||||
|
||||
include GNUmakefile.common
|
||||
|
@ -151,6 +151,7 @@ struct bbs_config {
|
||||
gid_t gid;
|
||||
int codepage;
|
||||
int ipv6;
|
||||
char *external_address;
|
||||
char *bbs_name;
|
||||
char *bwave_name;
|
||||
char *sysop_name;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sqlite3.h>
|
||||
#include <sys/wait.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "jamlib/jam.h"
|
||||
#include "libuuid/uuid.h"
|
||||
@ -591,8 +592,9 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
s_JamSubfield jsf;
|
||||
int z;
|
||||
char buffer[256];
|
||||
char qwkuuid[38];
|
||||
uuid_t magi_msgid;
|
||||
|
||||
uuid_t qwk_msgid;
|
||||
struct mail_area *ma = get_area(confr, area);
|
||||
jb = open_jam_base(ma->path);
|
||||
if (!jb) {
|
||||
@ -698,6 +700,19 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
jsf.DatLen = strlen(conf.bwave_name);
|
||||
jsf.Buffer = (char *)conf.bwave_name;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
if (conf.external_address != NULL) {
|
||||
|
||||
uuid_generate(qwk_msgid);
|
||||
uuid_unparse_lower(qwk_msgid, qwkuuid);
|
||||
snprintf(buffer, sizeof buffer, "<%s@%s>", qwkuuid, conf.external_address);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
}
|
||||
}
|
||||
} else if (ma->type == TYPE_NETMAIL_AREA && mc->nettype == NETWORK_FIDO) {
|
||||
jmh.Attribute |= JAM_MSG_TYPENET;
|
||||
@ -1082,8 +1097,8 @@ void bwave_upload_reply() {
|
||||
snprintf(originlinebuffer, sizeof originlinebuffer, "\r--- %s\r * Origin: %s (@%d)\r",
|
||||
upl_hdr.reader_tear, tagline, mc->maginode);
|
||||
} else if (mc->nettype == NETWORK_QWK) {
|
||||
snprintf(originlinebuffer, sizeof originlinebuffer, "\r--- $s\r * Origin: %s (%s)\r",
|
||||
upl_hdr.reader_tear, tagline, conf.bwave_name);
|
||||
snprintf(originlinebuffer, sizeof originlinebuffer, "\r---\r * MagickaBBS * %s\r",
|
||||
tagline);
|
||||
} else {
|
||||
snprintf(originlinebuffer, sizeof originlinebuffer, "\r");
|
||||
}
|
||||
|
123
src/lua_glue.c
123
src/lua_glue.c
@ -7,6 +7,7 @@
|
||||
#include "lua/lua.h"
|
||||
#include "lua/lauxlib.h"
|
||||
#include "jamlib/jam.h"
|
||||
#include "libuuid/uuid.h"
|
||||
|
||||
extern int mynode;
|
||||
extern struct bbs_config conf;
|
||||
@ -203,6 +204,12 @@ int l_getUserHandle(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_getUserLocation(lua_State *L) {
|
||||
lua_pushstring(L, gUser->location);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_messageFound(lua_State *L) {
|
||||
int conference = lua_tointeger(L, 1);
|
||||
int area = lua_tointeger(L, 2);
|
||||
@ -407,7 +414,9 @@ int l_postMessage(lua_State *L) {
|
||||
const char *subject = lua_tostring(L, 5);
|
||||
const char *body = lua_tostring(L, 6);
|
||||
int sem_fd;
|
||||
|
||||
uuid_t mnet_msgid;
|
||||
uuid_t qwk_msgid;
|
||||
char qwkuuid[38];
|
||||
char buffer[256];
|
||||
|
||||
s_JamBase *jb;
|
||||
@ -464,47 +473,69 @@ int l_postMessage(lua_State *L) {
|
||||
jsf.Buffer = (char *)subject;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
if (ma->type == TYPE_ECHOMAIL_AREA || ma->type == TYPE_NEWSGROUP_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPEECHO;
|
||||
if (mc->networked) {
|
||||
if (mc->nettype == NETWORK_FIDO) {
|
||||
if (ma->type == TYPE_ECHOMAIL_AREA || ma->type == TYPE_NEWSGROUP_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPEECHO;
|
||||
|
||||
if (mc->fidoaddr->point) {
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node,
|
||||
mc->fidoaddr->point);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node);
|
||||
if (mc->fidoaddr->point) {
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node,
|
||||
mc->fidoaddr->point);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node);
|
||||
}
|
||||
jsf.LoID = JAMSFLD_OADDRESS;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d %08lx",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node,
|
||||
mc->fidoaddr->point,
|
||||
generate_msgid());
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
|
||||
} else if (ma->type == TYPE_NETMAIL_AREA) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
} else if (mc->nettype == NETWORK_MAGI) {
|
||||
uuid_generate(mnet_msgid);
|
||||
uuid_unparse_lower(mnet_msgid, buffer);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
} else if (mc->nettype == NETWORK_QWK) {
|
||||
uuid_generate(qwk_msgid);
|
||||
uuid_unparse_lower(qwk_msgid, qwkuuid);
|
||||
snprintf(buffer, sizeof buffer, "<%s@%s>", qwkuuid, conf.external_address);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
}
|
||||
jsf.LoID = JAMSFLD_OADDRESS;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d %08lx",
|
||||
mc->fidoaddr->zone,
|
||||
mc->fidoaddr->net,
|
||||
mc->fidoaddr->node,
|
||||
mc->fidoaddr->point,
|
||||
generate_msgid());
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
|
||||
} else if (ma->type == TYPE_NETMAIL_AREA) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
z = JAM_LockMB(jb, 100);
|
||||
if (z == 0) {
|
||||
@ -521,7 +552,7 @@ int l_postMessage(lua_State *L) {
|
||||
|
||||
uname(&name);
|
||||
tagline = conf.default_tagline;
|
||||
if (mc != NULL) {
|
||||
if (mc->tagline != NULL) {
|
||||
tagline = mc->tagline;
|
||||
}
|
||||
|
||||
@ -535,9 +566,15 @@ int l_postMessage(lua_State *L) {
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
mc->fidoaddr->zone, mc->fidoaddr->net, mc->fidoaddr->node, mc->fidoaddr->point);
|
||||
}
|
||||
} else if (mc->nettype == NETWORK_MAGI) {
|
||||
snprintf(buffer, sizeof buffer, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (@%d)\r",
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
mc->maginode);
|
||||
} else if (mc->nettype == NETWORK_QWK) {
|
||||
snprintf(buffer, sizeof buffer, "\r---\r * MagickaBBS * %s\r",
|
||||
tagline);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s \r",
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline);
|
||||
snprintf(buffer, sizeof buffer, "\r");
|
||||
}
|
||||
|
||||
stralloc sa = EMPTY_STRALLOC;
|
||||
@ -614,6 +651,8 @@ void lua_push_cfunctions(lua_State *L) {
|
||||
lua_setglobal(L, "bbs_full_mail_scan");
|
||||
lua_pushcfunction(L, l_getUserHandle);
|
||||
lua_setglobal(L, "bbs_get_userhandle");
|
||||
lua_pushcfunction(L, l_getUserLocation);
|
||||
lua_setglobal(L, "bbs_get_userlocation");
|
||||
lua_pushcfunction(L, l_messageFound);
|
||||
lua_setglobal(L, "bbs_message_found");
|
||||
lua_pushcfunction(L, l_readMessageHdr);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/file.h>
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "jamlib/jam.h"
|
||||
#include "lua/lua.h"
|
||||
@ -469,9 +470,8 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
mc->maginode);
|
||||
} else if (mc->nettype == NETWORK_QWK && !email) {
|
||||
snprintf(buffer, sizeof buffer, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%s)\r",
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
conf.bwave_name);
|
||||
snprintf(buffer, sizeof buffer, "\r---\r * MagickaBBS * %s\r",
|
||||
tagline);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "\r");
|
||||
}
|
||||
@ -608,10 +608,8 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
mc->maginode);
|
||||
} else if (mc->nettype == NETWORK_QWK && !email) {
|
||||
snprintf(buffer, sizeof buffer,
|
||||
"\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (%s)\r",
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline,
|
||||
conf.bwave_name);
|
||||
snprintf(buffer, sizeof buffer, "\r---\r * MagickaBBS * %s\r",
|
||||
tagline);
|
||||
} else {
|
||||
strlcpy(buffer, "\r", sizeof buffer);
|
||||
}
|
||||
@ -1390,6 +1388,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
s_JamLastRead jlr;
|
||||
|
||||
char buffer[256];
|
||||
char qwkuuid[38];
|
||||
int z, z2;
|
||||
struct tm msg_date;
|
||||
|
||||
@ -1413,6 +1412,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
int position;
|
||||
int y;
|
||||
uuid_t magi_msgid;
|
||||
uuid_t qwk_msgid;
|
||||
struct ptr_vector msg_lines;
|
||||
|
||||
init_ptr_vector(&msg_lines);
|
||||
@ -1734,6 +1734,27 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
jsf.DatLen = strlen(conf.bwave_name);
|
||||
jsf.Buffer = (char *)conf.bwave_name;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
if (conf.external_address != NULL) {
|
||||
uuid_generate(qwk_msgid);
|
||||
uuid_unparse_lower(qwk_msgid, qwkuuid);
|
||||
snprintf(buffer, sizeof buffer, "<%s@%s>", qwkuuid, conf.external_address);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
if (msghs->msgs[mailno]->msgid != NULL) {
|
||||
strlcpy(buffer, msghs->msgs[mailno]->msgid, sizeof buffer);
|
||||
jsf.LoID = JAMSFLD_REPLYID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ma->type == TYPE_NETMAIL_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPENET;
|
||||
@ -2010,11 +2031,12 @@ void post_message(struct user_record *user) {
|
||||
struct fido_addr *from_addr = NULL;
|
||||
char buffer[256];
|
||||
char buffer2[256];
|
||||
char qwkuuid[38];
|
||||
int z;
|
||||
int sem_fd;
|
||||
char *bbsname;
|
||||
uuid_t magi_msgid;
|
||||
|
||||
uuid_t qwk_msgid;
|
||||
s_JamBase *jb;
|
||||
s_JamMsgHeader jmh;
|
||||
s_JamSubPacket *jsp;
|
||||
@ -2184,6 +2206,18 @@ void post_message(struct user_record *user) {
|
||||
jsf.DatLen = strlen(conf.bwave_name);
|
||||
jsf.Buffer = (char *)conf.bwave_name;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
if (conf.external_address != NULL) {
|
||||
uuid_generate(qwk_msgid);
|
||||
uuid_unparse_lower(qwk_msgid, qwkuuid);
|
||||
snprintf(buffer, sizeof buffer, "<%s@%s>", qwkuuid, conf.external_address);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
}
|
||||
}
|
||||
} else if (ma->type == TYPE_NETMAIL_AREA) {
|
||||
jmh.Attribute |= JAM_MSG_TYPENET;
|
||||
|
@ -308,6 +308,8 @@ static int handler(void *user, const char *section, const char *name,
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
if (strcasecmp(name, "bbs name") == 0) {
|
||||
conf->bbs_name = strdup(value);
|
||||
} else if (strcasecmp(name, "external address") == 0) {
|
||||
conf->external_address = strdup(value);
|
||||
} else if (strcasecmp(name, "telnet port") == 0) {
|
||||
conf->telnet_port = atoi(value);
|
||||
} else if (strcasecmp(name, "enable ssh") == 0) {
|
||||
@ -1178,6 +1180,7 @@ int main(int argc, char **argv) {
|
||||
conf.ipv6 = 0;
|
||||
conf.uid = getuid();
|
||||
conf.gid = getgid();
|
||||
conf.external_address = NULL;
|
||||
|
||||
// Load BBS data
|
||||
if (ini_parse(argv[1], handler, &conf) < 0) {
|
||||
|
@ -778,7 +778,7 @@ struct user_record *new_user() {
|
||||
user->sec_level = conf.newuserlvl;
|
||||
user->bwavepktno = 0;
|
||||
user->sec_info = (struct sec_level_t *)malloz(sizeof(struct sec_level_t));
|
||||
snprintf(buffer, PATH_MAX, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||
snprintf(buffer, PATH_MAX, "%s/s%d.ini", conf.config_path, user->sec_level);
|
||||
|
||||
if (ini_parse(buffer, secLevel, user->sec_info) < 0) {
|
||||
dolog("Unable to load sec Level ini (%s)!", buffer);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iconv.h>
|
||||
#include <libgen.h>
|
||||
#include "www_tree.h"
|
||||
#include "jamlib/jam.h"
|
||||
#include "libuuid/uuid.h"
|
||||
@ -706,6 +707,9 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
child_child_tag = www_tag_new("br", NULL);
|
||||
www_tag_add_child(child_tag, child_child_tag);
|
||||
|
||||
child_child_tag = www_tag_new(NULL, "Subject : ");
|
||||
www_tag_add_child(child_tag, child_child_tag);
|
||||
|
||||
child_child_tag = www_tag_new("input", NULL);
|
||||
www_tag_add_attrib(child_child_tag, "type", "text");
|
||||
www_tag_add_attrib(child_child_tag, "name", "subject");
|
||||
@ -854,7 +858,7 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
}
|
||||
} else if (content[i] == '\r' && content[i + 1] == '\r') {
|
||||
} else if (i < len - 2 && content[i] == '\r' && content[i + 1] == '\r') {
|
||||
content[at++] = '\r';
|
||||
content[at++] = '\r';
|
||||
line_count = 0;
|
||||
@ -941,6 +945,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
int max_len;
|
||||
int len;
|
||||
char buffer[256];
|
||||
char qwkuuid[38];
|
||||
char *body2;
|
||||
char *tagline;
|
||||
struct utsname name;
|
||||
@ -952,7 +957,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
size_t sz;
|
||||
char *inbuf, *oubuf;
|
||||
|
||||
uuid_t magi_msgid;
|
||||
uuid_t magi_msgid, qwk_msgid;
|
||||
|
||||
if (subj == NULL || to == NULL || body == NULL) {
|
||||
return 0;
|
||||
@ -1046,7 +1051,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
jsf.DatLen = strlen(replyid);
|
||||
jsf.Buffer = (char *)replyid;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(replyid));
|
||||
jmh.ReplyCRC = JAM_Crc32(replyid, strlen(replyid));
|
||||
}
|
||||
} else if (mc->nettype == NETWORK_MAGI) {
|
||||
snprintf(buffer, sizeof buffer, "%d", mc->maginode);
|
||||
@ -1072,7 +1077,33 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
jsf.DatLen = strlen(replyid);
|
||||
jsf.Buffer = (char *)replyid;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(replyid));
|
||||
jmh.ReplyCRC = JAM_Crc32(replyid, strlen(replyid));
|
||||
}
|
||||
} else if (mc->nettype == NETWORK_QWK) {
|
||||
jsf.LoID = JAMSFLD_OADDRESS;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(conf.bwave_name);
|
||||
jsf.Buffer = (char *)conf.bwave_name;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
if (conf.external_address != NULL) {
|
||||
uuid_generate(qwk_msgid);
|
||||
uuid_unparse_lower(qwk_msgid, qwkuuid);
|
||||
snprintf(buffer, sizeof buffer, "<%s@%s>", qwkuuid, conf.external_address);
|
||||
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(buffer);
|
||||
jsf.Buffer = (char *)buffer;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
if (strcasecmp(replyid, "NULL") != 0) {
|
||||
jsf.LoID = JAMSFLD_REPLYID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(replyid);
|
||||
jsf.Buffer = (char *)replyid;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
jmh.ReplyCRC = JAM_Crc32(replyid, strlen(replyid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1114,6 +1145,9 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
} else if (mc->nettype == NETWORK_MAGI) {
|
||||
snprintf(buffer, sizeof buffer, "\r\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (@%d)\r",
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, mc->maginode);
|
||||
} else if (mc->nettype == NETWORK_QWK) {
|
||||
snprintf(buffer, sizeof buffer, "\r\r---\r * MagickaBBS * %s\r",
|
||||
tagline);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "\r");
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
CC=cc
|
||||
CFLAGS=-I../../deps/odoors/
|
||||
CFLAGS=-I../../deps/odoors/ -DANSI_PATH="\"$(ANSI_PATH)\"" -DDRAFT_PATH="\"$(DRAFT_PATH)\""
|
||||
DEPS = main.c
|
||||
OS = $(shell uname -s)
|
||||
ODOORS = ../../deps/odoors/libs-${OS}/libODoors.a
|
||||
|
||||
|
||||
ifeq ($(OS), SunOS)
|
||||
EXTRA_LIBS = -lsocket
|
||||
endif
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd /home/andrew/MagickaBBS/utils/magiedit
|
||||
./magiedit -D /home/andrew/MagickaBBS/node$1/dorinfo1.def -MSGTMP /home/andrew/MagickaBBS/node$1
|
||||
cd __LOCALSTATEPREFIX__
|
||||
__EXECPREFIX__/magiedit -D __LOCALSTATEPREFIX__/node$1/dorinfo1.def -MSGTMP __LOCALSTATEPREFIX__/node$1
|
||||
|
@ -16,6 +16,14 @@
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#ifndef DRAFT_PATH
|
||||
#define DRAFT_PATH ""
|
||||
#endif
|
||||
|
||||
#ifndef ANSI_PATH
|
||||
#define ANSI_PATH ""
|
||||
#endif
|
||||
|
||||
char **quote_lines;
|
||||
int quote_line_count;
|
||||
|
||||
@ -27,7 +35,6 @@ int msgpriv;
|
||||
|
||||
char *draft_filename = NULL;
|
||||
|
||||
|
||||
char *load_draft() {
|
||||
DIR *dirp;
|
||||
struct dirent *dent;
|
||||
@ -40,7 +47,7 @@ char *load_draft() {
|
||||
int i;
|
||||
tODInputEvent ch;
|
||||
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s", od_control_get()->user_name);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s", od_control_get()->user_name);
|
||||
|
||||
dirp = opendir(draft_path);
|
||||
|
||||
@ -183,7 +190,7 @@ char *load_draft() {
|
||||
|
||||
return draft_filename;
|
||||
} else if (ch.chKeyPress == 'd') {
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s/%s.draft", od_control_get()->user_name, filenames[selected]);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s/%s.draft", od_control_get()->user_name, filenames[selected]);
|
||||
unlink(draft_path);
|
||||
|
||||
free(filenames[selected]);
|
||||
@ -213,7 +220,7 @@ char *load_draft() {
|
||||
void delete_draft(char *filename) {
|
||||
char draft_path[PATH_MAX];
|
||||
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s/%s.draft", od_control_get()->user_name, filename);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s/%s.draft", od_control_get()->user_name, filename);
|
||||
|
||||
unlink(draft_path);
|
||||
}
|
||||
@ -233,13 +240,13 @@ int check_draft_filename(char *filename) {
|
||||
mkdir("drafts", 0700);
|
||||
}
|
||||
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s", od_control_get()->user_name);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s", od_control_get()->user_name);
|
||||
|
||||
if (stat(draft_path, &s) != 0) {
|
||||
mkdir(draft_path, 0700);
|
||||
}
|
||||
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s/%s.draft", od_control_get()->user_name, filename);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s/%s.draft", od_control_get()->user_name, filename);
|
||||
|
||||
if (stat(draft_path, &s) != 0) {
|
||||
return 1;
|
||||
@ -290,7 +297,7 @@ char *message_editor() {
|
||||
while (!done) {
|
||||
od_clr_scr();
|
||||
od_set_cursor(1, 1);
|
||||
od_send_file("magiedit.ans");
|
||||
od_send_file(ANSI_PATH "magiedit.ans");
|
||||
od_set_color(D_GREY, D_BLACK);
|
||||
od_set_cursor(2, 13);
|
||||
od_printf("%-26.26s", msgto);
|
||||
@ -444,7 +451,7 @@ char *message_editor() {
|
||||
}
|
||||
|
||||
// write
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s/%s.draft", od_control_get()->user_name, draft_filename);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s/%s.draft", od_control_get()->user_name, draft_filename);
|
||||
fptr = fopen(draft_path, "w");
|
||||
|
||||
if (!fptr) {
|
||||
@ -467,7 +474,7 @@ char *message_editor() {
|
||||
// restore screen
|
||||
od_clr_scr();
|
||||
od_set_cursor(1, 1);
|
||||
od_send_file("magiedit.ans");
|
||||
od_send_file(ANSI_PATH "magiedit.ans");
|
||||
od_set_color(D_GREY, D_BLACK);
|
||||
od_set_cursor(2, 13);
|
||||
od_printf("%-26.26s", msgto);
|
||||
@ -494,7 +501,7 @@ char *message_editor() {
|
||||
} else if (ch.chKeyPress == OD_KEY_F10) {
|
||||
// load draft
|
||||
if (load_draft() != NULL) {
|
||||
snprintf(draft_path, PATH_MAX, "drafts/%s/%s.draft", od_control_get()->user_name, draft_filename);
|
||||
snprintf(draft_path, PATH_MAX, DRAFT_PATH "drafts/%s/%s.draft", od_control_get()->user_name, draft_filename);
|
||||
fptr = fopen(draft_path, "r");
|
||||
if (!fptr) {
|
||||
// error loading draft
|
||||
@ -535,7 +542,7 @@ char *message_editor() {
|
||||
// restore screen
|
||||
od_clr_scr();
|
||||
od_set_cursor(1, 1);
|
||||
od_send_file("magiedit.ans");
|
||||
od_send_file(ANSI_PATH "magiedit.ans");
|
||||
od_set_color(D_GREY, D_BLACK);
|
||||
od_set_cursor(2, 13);
|
||||
od_printf("%-26.26s", msgto);
|
||||
@ -846,7 +853,7 @@ char *message_editor() {
|
||||
// Quote
|
||||
od_clr_scr();
|
||||
od_set_cursor(1, 1);
|
||||
od_send_file("magiquote.ans");
|
||||
od_send_file(ANSI_PATH "magiquote.ans");
|
||||
od_set_color(D_GREY, D_BLACK);
|
||||
od_set_cursor(2, 13);
|
||||
od_printf("%-26.26s", msgto);
|
||||
@ -1015,7 +1022,7 @@ char *message_editor() {
|
||||
// restore screen
|
||||
od_clr_scr();
|
||||
od_set_cursor(1, 1);
|
||||
od_send_file("magiedit.ans");
|
||||
od_send_file(ANSI_PATH "magiedit.ans");
|
||||
od_set_color(D_GREY, D_BLACK);
|
||||
od_set_cursor(2, 13);
|
||||
od_printf("%-26.26s", msgto);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 31cd8fcb781c73c97ac7cc963eed0f8caefbf86b
|
||||
Subproject commit 6dc6b7559cd0730e44b61447df18761a0fc497f9
|
@ -1,21 +1,25 @@
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include -ggdb
|
||||
DEPS = qwktoss.c
|
||||
CFLAGS=-I/usr/local/include
|
||||
DEPS = qwktoss.c qwkscan.c
|
||||
JAMLIB = ../../deps/jamlib/jamlib.a
|
||||
OBJ = qwktoss.o ../../src/inih/ini.o
|
||||
SOBJ = qwkscan.o ../../src/inih/ini.o
|
||||
|
||||
all: qwktoss
|
||||
all: qwktoss qwkscan
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(JAMLIB):
|
||||
cd ../../deps/jamlib && make -f Makefile.linux
|
||||
cd ../../deps/jamlib && make -f $(JAMMAKE)
|
||||
|
||||
qwktoss: $(OBJ) $(JAMLIB)
|
||||
$(CC) -o qwktoss $^ $(CFLAGS) -L/usr/local/lib
|
||||
|
||||
qwkscan: $(SOBJ) $(JAMLIB)
|
||||
$(CC) -o qwkscan $^ $(CFLAGS) -L/usr/local/lib
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) qwktoss
|
||||
rm -f $(OBJ) $(SOBJ) qwktoss qwkscan
|
||||
|
@ -12,5 +12,7 @@ struct QwkHeader {
|
||||
unsigned char Msglive; /* Message active status*/
|
||||
unsigned char Msgarealo; /* Lo-byte message area */
|
||||
unsigned char Msgareahi; /* Hi-byte message area */
|
||||
unsigned char Msgfiller[3]; /* Filler bytes */
|
||||
unsigned char Msgofflo;
|
||||
unsigned char Msgoffhi;
|
||||
unsigned char Msgtagp;
|
||||
} __attribute__((packed));
|
@ -1,6 +1,11 @@
|
||||
[Main]
|
||||
Host = VERT
|
||||
Ftp server = vert.synchro.net
|
||||
Ftp user = username
|
||||
Ftp Password = password
|
||||
Message Path = /home/andrew/MagickaBBS/msgs/dovenet
|
||||
Inbound = /home/andrew/MagickaBBS/qwk/in
|
||||
Outbound = /home/andrew/MagickaBBS/qwk/out
|
||||
Temp Dir = /home/andrew/MagickaBBS/qwm/Temp
|
||||
Unpack Command = unzip -j -o *a -d *d
|
||||
Pack Command = zip -j *a *f
|
||||
|
55
utils/qwknet/qwknetftpc.py
Normal file
55
utils/qwknet/qwknetftpc.py
Normal file
@ -0,0 +1,55 @@
|
||||
from ftplib import FTP
|
||||
from ftplib import all_errors
|
||||
import configparser
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def dostuff(config_file):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_file)
|
||||
host = config.get("Main", "Ftp Server")
|
||||
username = config.get("Main", "Ftp User")
|
||||
password = config.get("Main", "Ftp Password")
|
||||
|
||||
ftp = FTP(host, timeout=300)
|
||||
ftp.login(username, password)
|
||||
|
||||
repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP"
|
||||
|
||||
i = 1
|
||||
|
||||
while True:
|
||||
exists = os.path.isfile(repfile)
|
||||
if exists:
|
||||
file = open(repfile, "rb")
|
||||
ftp.storbinary("STOR " + config.get("Main", "Host") + ".REP", file)
|
||||
file.close()
|
||||
os.remove(repfile)
|
||||
print("SENT: " + config.get("Main", "Host") + ".REP")
|
||||
repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP." + str(i)
|
||||
i = i + 1
|
||||
else:
|
||||
break
|
||||
|
||||
qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK"
|
||||
with open(qwkfile, 'wb') as file:
|
||||
def callback(data):
|
||||
file.write(data)
|
||||
|
||||
try:
|
||||
ftp.retrbinary("RETR " + config.get("Main", "Host") + ".QWK", callback)
|
||||
file.close()
|
||||
print("RETREIVED: " + config.get("Main", "Host") + ".QWK")
|
||||
except all_errors:
|
||||
file.close()
|
||||
os.remove(qwkfile)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage python qwknetftpc.py config.ini")
|
||||
exit(1)
|
||||
|
||||
server = dostuff(sys.argv[1])
|
455
utils/qwknet/qwkscan.c
Normal file
455
utils/qwknet/qwkscan.c
Normal file
@ -0,0 +1,455 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <fts.h>
|
||||
#include <errno.h>
|
||||
#include "qwk.h"
|
||||
#include "../../deps/jamlib/jam.h"
|
||||
#include "../../src/inih/ini.h"
|
||||
|
||||
char *outbound_path;
|
||||
char *message_base_path;
|
||||
char *temp_dir;
|
||||
char *pack_cmd;
|
||||
char *config_file;
|
||||
char *hostid;
|
||||
|
||||
int bases_exists = 0;
|
||||
|
||||
struct msg_bases {
|
||||
int baseno;
|
||||
char *path;
|
||||
};
|
||||
|
||||
struct msg_bases **msgbases;
|
||||
int msgbasecount = 0;
|
||||
|
||||
int recursive_delete(const char *dir) {
|
||||
int ret = 0;
|
||||
FTS *ftsp = NULL;
|
||||
FTSENT *curr;
|
||||
|
||||
char *files[] = { (char *) dir, NULL };
|
||||
|
||||
ftsp = fts_open(files, FTS_NOCHDIR | FTS_PHYSICAL | FTS_XDEV, NULL);
|
||||
if (!ftsp) {
|
||||
fprintf(stderr, "%s: fts_open failed: %s\n", dir, strerror(errno));
|
||||
ret = -1;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
while ((curr = fts_read(ftsp))) {
|
||||
switch (curr->fts_info) {
|
||||
case FTS_NS:
|
||||
case FTS_DNR:
|
||||
case FTS_ERR:
|
||||
fprintf(stderr, "%s: fts_read error: %s\n", curr->fts_accpath, strerror(curr->fts_errno));
|
||||
break;
|
||||
|
||||
case FTS_DC:
|
||||
case FTS_DOT:
|
||||
case FTS_NSOK:
|
||||
break;
|
||||
|
||||
case FTS_D:
|
||||
break;
|
||||
|
||||
case FTS_DP:
|
||||
case FTS_F:
|
||||
case FTS_SL:
|
||||
case FTS_SLNONE:
|
||||
case FTS_DEFAULT:
|
||||
if (remove(curr->fts_accpath) < 0) {
|
||||
fprintf(stderr, "%s: Failed to remove: %s", curr->fts_path, strerror(errno));
|
||||
ret = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
finish:
|
||||
if (ftsp) {
|
||||
fts_close(ftsp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
s_JamBase *open_jam_base(char *path) {
|
||||
int ret;
|
||||
s_JamBase *jb;
|
||||
|
||||
ret = JAM_OpenMB((char *)path, &jb);
|
||||
|
||||
if (ret != 0) {
|
||||
if (ret == JAM_IO_ERROR) {
|
||||
free(jb);
|
||||
ret = JAM_CreateMB((char *)path, 1, &jb);
|
||||
if (ret != 0) {
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return jb;
|
||||
}
|
||||
|
||||
static int handler(void* user, const char* section, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
if (strcasecmp(name, "message path") == 0) {
|
||||
message_base_path = strdup(value);
|
||||
} else if (strcasecmp(name, "outbound") == 0) {
|
||||
outbound_path = strdup(value);
|
||||
} else if (strcasecmp(name, "temp dir") == 0) {
|
||||
temp_dir = strdup(value);
|
||||
} else if (strcasecmp(name, "pack command") == 0) {
|
||||
pack_cmd = strdup(value);
|
||||
} else if (strcasecmp(name, "host") == 0) {
|
||||
hostid = strdup(value);
|
||||
}
|
||||
} else if (strcasecmp(section, "bases") == 0) {
|
||||
bases_exists = 1;
|
||||
if (msgbasecount == 0) {
|
||||
msgbases = (struct msg_bases **)malloc(sizeof(struct msg_bases *));
|
||||
} else {
|
||||
msgbases = (struct msg_bases **)realloc(msgbases, sizeof(struct msg_bases *) * (msgbasecount + 1));
|
||||
}
|
||||
|
||||
msgbases[msgbasecount] = (struct msg_bases *)malloc(sizeof(struct msg_bases));
|
||||
|
||||
msgbases[msgbasecount]->baseno = atoi(name);
|
||||
msgbases[msgbasecount]->path = strdup(value);
|
||||
msgbasecount++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int export_messages(int baseno, char *basefilename, int qwkidx) {
|
||||
int msgcount = 0;
|
||||
s_JamBase *jb;
|
||||
s_JamBaseHeader jbh;
|
||||
s_JamMsgHeader jmh;
|
||||
s_JamSubPacket* jsp;
|
||||
s_JamSubfield jsf;
|
||||
int i;
|
||||
int z;
|
||||
int len;
|
||||
int lenbytes;
|
||||
char buffer[PATH_MAX];
|
||||
|
||||
struct QwkHeader qh;
|
||||
struct tm msgtm;
|
||||
FILE *fptr;
|
||||
FILE *hdrptr;
|
||||
char text[128];
|
||||
char *msgbuf;
|
||||
char *msgptr;
|
||||
|
||||
long offset;
|
||||
|
||||
char *msgsubj = NULL;
|
||||
char *msgto = NULL;
|
||||
char *msgfrom = NULL;
|
||||
char *msgid = NULL;
|
||||
char *msgreplyid = NULL;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", message_base_path, basefilename);
|
||||
|
||||
jb = open_jam_base(buffer);
|
||||
if (jb) {
|
||||
JAM_ReadMBHeader(jb, &jbh);
|
||||
if (jbh.ActiveMsgs > 0) {
|
||||
for (i=0;i<jbh.ActiveMsgs;i++) {
|
||||
memset(&jmh, 0, sizeof(s_JamMsgHeader));
|
||||
z = JAM_ReadMsgHeader(jb, i, &jmh, &jsp);
|
||||
|
||||
if (z != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((jmh.Attribute & JAM_MSG_SENT) || !(jmh.Attribute & JAM_MSG_LOCAL)) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
continue;
|
||||
} else {
|
||||
// export message
|
||||
for (z=0;z<jsp->NumFields;z++) {
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||
msgsubj = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
||||
memset(msgsubj, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(msgsubj, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
|
||||
if (jsp->Fields[z]->DatLen > 24) {
|
||||
len = 24;
|
||||
} else {
|
||||
len = jsp->Fields[z]->DatLen;
|
||||
}
|
||||
memset(qh.MsgSubj, ' ', 25);
|
||||
memcpy(qh.MsgSubj, jsp->Fields[z]->Buffer, len);
|
||||
}
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
||||
msgfrom = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
||||
memset(msgfrom, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(msgfrom, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
if (jsp->Fields[z]->DatLen > 24) {
|
||||
len = 24;
|
||||
} else {
|
||||
len = jsp->Fields[z]->DatLen;
|
||||
}
|
||||
memset(qh.MsgFrom, ' ', 25);
|
||||
memcpy(qh.MsgFrom, jsp->Fields[z]->Buffer, len);
|
||||
}
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
||||
msgto = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
||||
memset(msgto, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(msgto, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
if (jsp->Fields[z]->DatLen > 24) {
|
||||
len = 24;
|
||||
} else {
|
||||
len = jsp->Fields[z]->DatLen;
|
||||
}
|
||||
memset(qh.MsgTo, ' ', 25);
|
||||
memcpy(qh.MsgTo, jsp->Fields[z]->Buffer, len);
|
||||
}
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
||||
msgid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
||||
memset(msgid, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(msgid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
}
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
||||
msgreplyid = (char *)malloc(jsp->Fields[z]->DatLen + 1);
|
||||
memset(msgreplyid, 0, jsp->Fields[z]->DatLen + 1);
|
||||
memcpy(msgreplyid, jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||
}
|
||||
}
|
||||
qh.Msgstat = ' ';
|
||||
snprintf(buffer, 7, "%d", baseno);
|
||||
memset(qh.Msgnum, ' ', 7);
|
||||
memcpy(qh.Msgnum, buffer, strlen(buffer));
|
||||
|
||||
localtime_r(&jmh.DateWritten, &msgtm);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%02d-%02d-%02d", msgtm.tm_mon + 1, msgtm.tm_mday, msgtm.tm_year - 100);
|
||||
memcpy(qh.Msgdate, buffer, 8);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%02d:%02d", msgtm.tm_hour, msgtm.tm_min);
|
||||
memcpy(qh.Msgtime, buffer, 5);
|
||||
|
||||
memset(qh.Msgpass, ' ', 12);
|
||||
memset(qh.Msgrply, ' ', 8);
|
||||
|
||||
len = jmh.TxtLen / 128 + 2;
|
||||
lenbytes = len * 128;
|
||||
|
||||
msgbuf = (char *)malloc(lenbytes);
|
||||
|
||||
memset(msgbuf, ' ', lenbytes);
|
||||
|
||||
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, msgbuf);
|
||||
|
||||
msgptr = msgbuf;
|
||||
while (*msgptr != '\0') {
|
||||
if (*msgptr == '\r') {
|
||||
*msgptr = '\xe3';
|
||||
}
|
||||
msgptr++;
|
||||
}
|
||||
|
||||
for (z=0;z<lenbytes;z++) {
|
||||
if (msgbuf[z] == '\0') {
|
||||
msgbuf[z] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buffer, 7, "%d", len);
|
||||
memset(qh.Msgrecs, ' ', 6);
|
||||
memcpy(qh.Msgrecs, buffer, strlen(buffer));
|
||||
|
||||
qh.Msglive = 0xE1;
|
||||
qh.Msgarealo = baseno & 0xff;
|
||||
qh.Msgareahi = (baseno >> 8) & 0xff;
|
||||
|
||||
qh.Msgoffhi = ((qwkidx + msgcount + 1) >> 8) & 0xff;
|
||||
qh.Msgofflo = (qwkidx + msgcount + 1) & 0xff;
|
||||
|
||||
qh.Msgtagp = '*';
|
||||
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s.MSG", temp_dir, hostid);
|
||||
fptr = fopen(buffer, "r+");
|
||||
if (!fptr) {
|
||||
fptr = fopen(buffer, "w");
|
||||
if (fptr) {
|
||||
memset(text, ' ', 128);
|
||||
memcpy(text, hostid, strlen(hostid));
|
||||
fwrite(text, 128, 1, fptr);
|
||||
} else {
|
||||
fprintf(stderr, "UNABLE TO OPEN %s!!\n", buffer);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
exit(-1);
|
||||
}
|
||||
} else {
|
||||
fseek(fptr, 0, SEEK_END);
|
||||
}
|
||||
|
||||
offset = ftell(fptr);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/HEADERS.DAT", temp_dir);
|
||||
hdrptr = fopen(buffer, "a");
|
||||
|
||||
fprintf(hdrptr, "[%lx]\n", offset);
|
||||
if (msgid != NULL) {
|
||||
fprintf(hdrptr, "Message-ID: %s\n", msgid);
|
||||
free(msgid);
|
||||
msgid = NULL;
|
||||
}
|
||||
if (msgreplyid != NULL) {
|
||||
fprintf(hdrptr, "In-Reply-To: %s\n", msgreplyid);
|
||||
free(msgreplyid);
|
||||
msgreplyid = NULL;
|
||||
}
|
||||
if (msgsubj != NULL) {
|
||||
fprintf(hdrptr, "Subject: %s\n", msgsubj);
|
||||
free(msgsubj);
|
||||
msgsubj = NULL;
|
||||
}
|
||||
if (msgto != NULL) {
|
||||
fprintf(hdrptr, "To: %s\n", msgto);
|
||||
free(msgto);
|
||||
msgto = NULL;
|
||||
}
|
||||
if (msgfrom != NULL) {
|
||||
fprintf(hdrptr, "Sender: %s\n", msgfrom);
|
||||
free(msgfrom);
|
||||
msgfrom = NULL;
|
||||
}
|
||||
|
||||
fprintf(hdrptr, "\n");
|
||||
fclose(hdrptr);
|
||||
|
||||
fwrite(&qh, 128, 1, fptr);
|
||||
fwrite(msgbuf, lenbytes - 128, 1, fptr);
|
||||
fclose(fptr);
|
||||
jmh.Attribute |= JAM_MSG_SENT;
|
||||
while (1) {
|
||||
z = JAM_LockMB(jb, 100);
|
||||
if (z == 0) {
|
||||
break;
|
||||
} else if (z == JAM_LOCK_FAILED) {
|
||||
sleep(1);
|
||||
} else {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
fprintf(stderr, "Error locking JAM base!\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
z =JAM_ChangeMsgHeader(jb, i, &jmh);
|
||||
JAM_UnlockMB(jb);
|
||||
JAM_DelSubPacket(jsp);
|
||||
free(msgbuf);
|
||||
msgcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
|
||||
return msgcount;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
message_base_path = NULL;
|
||||
outbound_path = NULL;
|
||||
temp_dir = NULL;
|
||||
int qwkidx = 0;
|
||||
int msgcount = 0;
|
||||
char buffer[PATH_MAX];
|
||||
char archive[PATH_MAX];
|
||||
int ret;
|
||||
struct stat st;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage:\n ./qwkscan config.ini\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
config_file = argv[1];
|
||||
|
||||
if (ini_parse(config_file, handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", config_file);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (temp_dir == NULL || message_base_path == NULL || outbound_path == NULL) {
|
||||
fprintf(stderr, "Outbound Path & Temp dir must both be set\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
mkdir(temp_dir, 0755);
|
||||
|
||||
for (i=0;i<msgbasecount;i++) {
|
||||
msgcount = export_messages(msgbases[i]->baseno, msgbases[i]->path, qwkidx);
|
||||
qwkidx += msgcount;
|
||||
fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount);
|
||||
}
|
||||
|
||||
if (qwkidx > 0) {
|
||||
|
||||
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
|
||||
i = 1;
|
||||
while (stat(archive, &st) == 0) {
|
||||
snprintf(archive, PATH_MAX, "%s/%s.REP.%d", outbound_path, hostid, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
char *b = buffer;
|
||||
size_t blen = sizeof buffer;
|
||||
for (const char *p = pack_cmd; *p != '\0' && blen >= 1; ++p) {
|
||||
if (*p != '*') {
|
||||
*b++ = *p;
|
||||
--blen;
|
||||
continue;
|
||||
}
|
||||
p++;
|
||||
size_t alen = 0;
|
||||
if (*p == 'a') {
|
||||
strncpy(b, archive, blen);
|
||||
alen = strlen(archive);
|
||||
} else if (*p == 'f') {
|
||||
snprintf(b, blen, "%s/%s.MSG %s/HEADERS.DAT", temp_dir, hostid, temp_dir);
|
||||
alen = strlen(b);
|
||||
} else if (*p == '*') {
|
||||
*b++ = '*';
|
||||
alen = 1;
|
||||
}
|
||||
b += alen;
|
||||
blen -= alen;
|
||||
}
|
||||
*b = '\0';
|
||||
|
||||
ret = system(buffer);
|
||||
if (ret == -1 || ret >> 8 == 127) {
|
||||
fprintf(stderr, "Failed to run archiver!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
recursive_delete(temp_dir);
|
||||
}
|
@ -15,6 +15,31 @@ char *inbound_path;
|
||||
char *message_base_path;
|
||||
char *temp_dir;
|
||||
char *unpack_cmd;
|
||||
char *config_file;
|
||||
|
||||
int bases_exists = 0;
|
||||
|
||||
struct msg_bases {
|
||||
int baseno;
|
||||
char *path;
|
||||
};
|
||||
|
||||
struct header_t {
|
||||
char *key;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct msg_headers_t {
|
||||
long offset;
|
||||
struct header_t **headers;
|
||||
int header_count;
|
||||
};
|
||||
|
||||
struct msg_headers_t **msg_headers;
|
||||
int msg_count = 0;
|
||||
|
||||
struct msg_bases **msgbases;
|
||||
int msgbasecount = 0;
|
||||
|
||||
int recursive_delete(const char *dir) {
|
||||
int ret = 0;
|
||||
@ -89,6 +114,58 @@ s_JamBase *open_jam_base(char *path) {
|
||||
return jb;
|
||||
}
|
||||
|
||||
static char *get_key_value(struct msg_headers_t *header, char *key) {
|
||||
if (header == NULL) return NULL;
|
||||
for (int i=0;i<header->header_count;i++) {
|
||||
if (strcmp(key, header->headers[i]->key) == 0) {
|
||||
return header->headers[i]->value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct msg_headers_t *get_header(long offset) {
|
||||
for (int i=0;i<msg_count;i++) {
|
||||
if (msg_headers[i]->offset == offset) {
|
||||
return msg_headers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int header_handler(void* user, const char* section, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
for (int i=0;i<msg_count;i++) {
|
||||
if (msg_headers[i]->offset == strtol(section, NULL, 16)) {
|
||||
msg_headers[i]->headers = (struct header_t **)realloc(msg_headers[i]->headers, sizeof(struct header_t *) * (msg_headers[i]->header_count + 1));
|
||||
msg_headers[i]->headers[msg_headers[i]->header_count] = (struct header_t *)malloc(sizeof(struct header_t));
|
||||
msg_headers[i]->headers[msg_headers[i]->header_count]->key = strdup(name);
|
||||
msg_headers[i]->headers[msg_headers[i]->header_count]->value = strdup(value);
|
||||
msg_headers[i]->header_count++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (msg_count == 0) {
|
||||
msg_headers = (struct msg_headers_t **)malloc(sizeof(struct msg_headers_t *));
|
||||
} else {
|
||||
msg_headers = (struct msg_headers_t **)realloc(msg_headers, sizeof(struct msg_headers_t *) * (msg_count + 1));
|
||||
}
|
||||
|
||||
msg_headers[msg_count] = (struct msg_headers_t *)malloc(sizeof(struct msg_headers_t));
|
||||
msg_headers[msg_count]->offset = strtol(section, NULL, 16);
|
||||
msg_headers[msg_count]->header_count = 1;
|
||||
msg_headers[msg_count]->headers = (struct header_t **)malloc(sizeof(struct header_t *));
|
||||
msg_headers[msg_count]->headers[0] = (struct header_t *)malloc(sizeof(struct header_t));
|
||||
msg_headers[msg_count]->headers[0]->key = strdup(name);
|
||||
msg_headers[msg_count]->headers[0]->value = strdup(value);
|
||||
|
||||
msg_count++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int handler(void* user, const char* section, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
@ -102,7 +179,20 @@ static int handler(void* user, const char* section, const char* name,
|
||||
} else if (strcasecmp(name, "unpack command") == 0) {
|
||||
unpack_cmd = strdup(value);
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(section, "bases") == 0) {
|
||||
bases_exists = 1;
|
||||
if (msgbasecount == 0) {
|
||||
msgbases = (struct msg_bases **)malloc(sizeof(struct msg_bases *));
|
||||
} else {
|
||||
msgbases = (struct msg_bases **)realloc(msgbases, sizeof(struct msg_bases *) * (msgbasecount + 1));
|
||||
}
|
||||
|
||||
msgbases[msgbasecount] = (struct msg_bases *)malloc(sizeof(struct msg_bases));
|
||||
|
||||
msgbases[msgbasecount]->baseno = atoi(name);
|
||||
msgbases[msgbasecount]->path = strdup(value);
|
||||
msgbasecount++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -130,7 +220,10 @@ size_t trimwhitespace(char *out, size_t len, const char *str) {
|
||||
|
||||
int process_msgs_dat(char *msgsdat) {
|
||||
FILE *fptr;
|
||||
FILE *cfgfptr;
|
||||
|
||||
char buffer[PATH_MAX];
|
||||
char headerfile[PATH_MAX];
|
||||
struct QwkHeader qhdr;
|
||||
int msgrecs;
|
||||
char *msgbody;
|
||||
@ -148,6 +241,16 @@ int process_msgs_dat(char *msgsdat) {
|
||||
s_JamSubPacket* jsp;
|
||||
s_JamSubfield jsf;
|
||||
int z;
|
||||
int basefound = 0;
|
||||
long offset;
|
||||
char *ptr;
|
||||
|
||||
struct msg_headers_t *header = NULL;
|
||||
|
||||
|
||||
snprintf(headerfile, PATH_MAX, "%s/HEADERS.DAT", temp_dir);
|
||||
|
||||
ini_parse(headerfile, header_handler, NULL);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", temp_dir, msgsdat);
|
||||
|
||||
@ -157,11 +260,15 @@ int process_msgs_dat(char *msgsdat) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fread(&qhdr, sizeof(struct QwkHeader), 1, fptr);
|
||||
while (!feof(fptr)) {
|
||||
offset = ftell(fptr);
|
||||
header = get_header(offset);
|
||||
if (fread(&qhdr, sizeof(struct QwkHeader), 1, fptr) != 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
msgrecs = atoi(qhdr.Msgrecs);
|
||||
msgbody = (char *)malloc((msgrecs * 128) + 1);
|
||||
memset(msgbody, 0, (msgrecs * 128) + 1);
|
||||
@ -212,12 +319,47 @@ int process_msgs_dat(char *msgsdat) {
|
||||
|
||||
msgconf = ((qhdr.Msgareahi & 0xff) << 8) | qhdr.Msgarealo;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%d", message_base_path, msgconf);
|
||||
basefound = 0;
|
||||
for (i=0;i<msgbasecount;i++) {
|
||||
if (msgbases[i]->baseno == msgconf) {
|
||||
basefound = 1;
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", message_base_path, msgbases[i]->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!basefound) {
|
||||
|
||||
|
||||
cfgfptr = fopen(config_file, "a");
|
||||
|
||||
if (!bases_exists) {
|
||||
fprintf(cfgfptr, "[bases]\n");
|
||||
bases_exists = 1;
|
||||
}
|
||||
|
||||
fprintf(cfgfptr, "%d = %d\n", msgconf, msgconf);
|
||||
fclose(cfgfptr);
|
||||
|
||||
if (msgbasecount == 0) {
|
||||
msgbases = (struct msg_bases **)malloc(sizeof(struct msg_bases *));
|
||||
} else {
|
||||
msgbases = (struct msg_bases **)realloc(msgbases, sizeof(struct msg_bases *) * (msgbasecount + 1));
|
||||
}
|
||||
|
||||
msgbases[msgbasecount] = (struct msg_bases *)malloc(sizeof(struct msg_bases));
|
||||
msgbases[msgbasecount]->baseno = msgconf;
|
||||
snprintf(buffer, PATH_MAX, "%d", msgconf);
|
||||
msgbases[msgbasecount]->path = strdup(buffer);
|
||||
msgbasecount++;
|
||||
snprintf(buffer, PATH_MAX, "%s/%d", message_base_path, msgconf);
|
||||
}
|
||||
|
||||
jb = open_jam_base(buffer);
|
||||
if (!jb) {
|
||||
fprintf(stderr, "Unable to open JAM base: %s\n", buffer);
|
||||
free(msgbody);
|
||||
fclose(fptr);
|
||||
return -1;
|
||||
}
|
||||
JAM_ClearMsgHeader( &jmh );
|
||||
@ -227,22 +369,60 @@ int process_msgs_dat(char *msgsdat) {
|
||||
|
||||
jsf.LoID = JAMSFLD_SENDERNAME;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(msgfrom);
|
||||
jsf.Buffer = (char *)msgfrom;
|
||||
|
||||
ptr = get_key_value(header, "Sender");
|
||||
if (ptr != NULL) {
|
||||
jsf.DatLen = strlen(ptr);
|
||||
jsf.Buffer = ptr;
|
||||
} else {
|
||||
jsf.DatLen = strlen(msgfrom);
|
||||
jsf.Buffer = (char *)msgfrom;
|
||||
}
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
jsf.LoID = JAMSFLD_RECVRNAME;
|
||||
jsf.LoID = JAMSFLD_RECVRNAME;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(msgto);
|
||||
jsf.Buffer = (char *)msgto;
|
||||
|
||||
ptr = get_key_value(header, "To");
|
||||
if (ptr != NULL) {
|
||||
jsf.DatLen = strlen(ptr);
|
||||
jsf.Buffer = (char *)ptr;
|
||||
} else {
|
||||
jsf.DatLen = strlen(msgto);
|
||||
jsf.Buffer = (char *)msgto;
|
||||
}
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
jsf.LoID = JAMSFLD_SUBJECT;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(msgsubj);
|
||||
jsf.Buffer = (char *)msgsubj;
|
||||
ptr = get_key_value(header, "Subject");
|
||||
if (ptr != NULL) {
|
||||
jsf.DatLen = strlen(ptr);
|
||||
jsf.Buffer = (char *)ptr;
|
||||
} else {
|
||||
jsf.DatLen = strlen(msgsubj);
|
||||
jsf.Buffer = (char *)msgsubj;
|
||||
}
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
|
||||
ptr = get_key_value(header, "Message-ID");
|
||||
if (ptr != NULL) {
|
||||
jsf.LoID = JAMSFLD_MSGID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(ptr);
|
||||
jsf.Buffer = (char *)ptr;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
}
|
||||
|
||||
ptr = get_key_value(header, "In-Reply-To");
|
||||
if (ptr != NULL) {
|
||||
jsf.LoID = JAMSFLD_REPLYID;
|
||||
jsf.HiID = 0;
|
||||
jsf.DatLen = strlen(ptr);
|
||||
jsf.Buffer = (char *)ptr;
|
||||
JAM_PutSubfield(jsp, &jsf);
|
||||
}
|
||||
|
||||
jmh.Attribute |= JAM_MSG_TYPEECHO;
|
||||
|
||||
while (1) {
|
||||
@ -253,6 +433,7 @@ int process_msgs_dat(char *msgsdat) {
|
||||
sleep(1);
|
||||
} else {
|
||||
fprintf(stderr, "Failed to lock msg base!\n");
|
||||
fclose(fptr);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
free(msgbody);
|
||||
@ -267,6 +448,7 @@ int process_msgs_dat(char *msgsdat) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
free(msgbody);
|
||||
fclose(fptr);
|
||||
return -1;
|
||||
} else {
|
||||
JAM_UnlockMB(jb);
|
||||
@ -358,8 +540,10 @@ int main(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ini_parse(argv[1], handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", argv[1]);
|
||||
config_file = argv[1];
|
||||
|
||||
if (ini_parse(config_file, handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", config_file);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,11 @@ ifeq ($(OS), Haiku)
|
||||
CFLAGS=
|
||||
LDFLAGS=-lsqlite3
|
||||
endif
|
||||
ifeq ($(OS), SunOS)
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
LDFLAGS=-lsqlite3
|
||||
endif
|
||||
|
||||
DEPS = ticproc.c
|
||||
|
||||
|
19
utils/wwivnet/wwivnet.h
Normal file
19
utils/wwivnet/wwivnet.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __WWIVNET_H__
|
||||
#define __WWIVNET_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct net_header_rec {
|
||||
uint16_t tosys, /* destination system */
|
||||
touser, /* destination user */
|
||||
fromsys, /* originating system */
|
||||
fromuser, /* originating user */
|
||||
main_type, /* main message type */
|
||||
minor_type, /* minor message type */
|
||||
list_len; /* # of entries in system list */
|
||||
uint32_t daten, /* date/time sent */
|
||||
length; /* # of bytes of msg after header */
|
||||
uint16_t method; /* method of compression */
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif
|
169
utils/wwivnet/wwivtoss.c
Normal file
169
utils/wwivnet/wwivtoss.c
Normal file
@ -0,0 +1,169 @@
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include "wwivnet.h"
|
||||
#include "../../deps/jamlib/jam.h"
|
||||
#include "../../src/inih/ini.h"
|
||||
|
||||
char *config_file;
|
||||
char *inbound_dir = NULL;
|
||||
char *outbound_dir = NULL;
|
||||
uint16_t wwivnet_node = 0;
|
||||
|
||||
static int handler(void* user, const char* section, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
if (strcasecmp(name, "inbound") == 0) {
|
||||
inbound_dir = strdup(value);
|
||||
} else if (strcasecmp(name, "outbound") == 0) {
|
||||
outbound_dir = strdup(value);
|
||||
} else if (strcasecmp(name, "wwiv node") == 0) {
|
||||
wwivnet_node = atoi(value);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void main_type_new_post(struct net_header_rec *msg_hdr, char *msg_txt) {
|
||||
char *subtype;
|
||||
char *ptr;
|
||||
char *title;
|
||||
|
||||
subtype = strdup(msg_txt);
|
||||
|
||||
ptr = msg_txt;
|
||||
while (*ptr != '\0') {
|
||||
ptr++;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
title = strdup(ptr);
|
||||
while (*ptr != '\0') {
|
||||
ptr++;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int process_file(char *filename) {
|
||||
char buffer[PATH_MAX];
|
||||
FILE *fptr;
|
||||
struct net_header_rec msg_hdr;
|
||||
char *msg_txt;
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s", inbound_dir, filename);
|
||||
|
||||
|
||||
|
||||
fptr = fopen(buffer, "rb");
|
||||
if (!fptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (!feof(fptr)) {
|
||||
if (fread(&msg_hdr, sizeof(struct net_header_rec), 1, fptr) != 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg_hdr.length > 0) {
|
||||
msg_txt = (char *)malloc(msg_hdr.length);
|
||||
if (fread(msg_txt, 1, msg_hdr.length, fptr) != msg_hdr.length) {
|
||||
free(msg_txt);
|
||||
fprintf(stderr, "Short read on message.\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
msg_txt = NULL;
|
||||
}
|
||||
|
||||
switch(msg_hdr.main_type) {
|
||||
case 0x0001:
|
||||
// main_type_net_info
|
||||
fprintf(stderr, "Got main_type_net_info\n");
|
||||
break;
|
||||
case 0x0002:
|
||||
// main_type_email
|
||||
fprintf(stderr, "Got main_type_email\n");
|
||||
break;
|
||||
case 0x0007:
|
||||
// main_type_email_name
|
||||
fprintf(stderr, "Got main_type_email_name\n");
|
||||
break;
|
||||
case 0x0009:
|
||||
// main_type_sub_list
|
||||
fprintf(stderr, "Got main_type_sub_list\n");
|
||||
break;
|
||||
case 0x000f:
|
||||
// main_type_ssm
|
||||
fprintf(stderr, "Got main_type_ssm\n");
|
||||
break;
|
||||
case 0x0010:
|
||||
// main_type_sub_add_req
|
||||
fprintf(stderr, "Got main_type_sub_add_req\n");
|
||||
break;
|
||||
case 0x0011:
|
||||
// main_type_sub_drop_req
|
||||
fprintf(stderr, "Got main_type_sub_drop_req\n");
|
||||
break;
|
||||
case 0x0012:
|
||||
// main_type_sub_add_resp
|
||||
fprintf(stderr, "Got main_type_sub_add_resp\n");
|
||||
break;
|
||||
case 0x0013:
|
||||
// main_type_sub_drop_resp
|
||||
fprintf(stderr, "Got main_type_sub_drop_resp\n");
|
||||
break;
|
||||
case 0x0014:
|
||||
// main_type_sub_list_info
|
||||
fprintf(stderr, "Got main_type_sub_list_info\n");
|
||||
break;
|
||||
case 0x001a:
|
||||
// main_type_new_post
|
||||
main_type_new_post(&msg_hdr, msg_txt);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported main type 0x%x\n", msg_hdr.main_type);
|
||||
break;
|
||||
}
|
||||
if (msg_txt != NULL) {
|
||||
free(msg_txt);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
DIR *inb;
|
||||
struct dirent *dent;
|
||||
char buffer[256];
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage:\n ./wwivtoss config.ini\n");
|
||||
return -1;
|
||||
}
|
||||
config_file = argv[1];
|
||||
|
||||
if (ini_parse(config_file, handler, NULL) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", config_file);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
snprintf(buffer, 256, "s%d.net", wwivnet_node);
|
||||
|
||||
inb = opendir(inbound_dir);
|
||||
if (!inb) {
|
||||
fprintf(stderr, "Error opening inbound directory\n");
|
||||
return -1;
|
||||
}
|
||||
while ((dent = readdir(inb)) != NULL) {
|
||||
if (strncmp(dent->d_name, buffer, strlen(buffer)) == 0) {
|
||||
if(process_file(dent->d_name)) {
|
||||
rewinddir(inb);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(inb);
|
||||
}
|
Reference in New Issue
Block a user