From abb20b63b5ca69282998b7fcd1a6633169f59615 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 12:13:32 +1000 Subject: [PATCH 01/38] Experimental 'make install' --- GNUmakefile.debian | 137 ++++++++++++++++++++++++++++++++++ dist/config/bbs.ini | 38 +++++----- dist/config/filesgen.ini | 2 +- dist/config/happynet.ini | 4 +- dist/config/localmail.ini | 4 +- dist/scripts/login_stanza.lua | 2 +- setup.sh | 20 +++-- src/GNUmakefile.common | 2 +- src/GNUmakefile.debian | 14 ++++ src/GNUmakefile.dragonfly | 3 + src/GNUmakefile.freebsd | 3 + src/GNUmakefile.haiku | 3 + src/GNUmakefile.linux | 3 + src/GNUmakefile.linux-musl | 3 + src/GNUmakefile.netbsd | 3 + src/GNUmakefile.openbsd | 3 + src/GNUmakefile.osx | 3 + src/GNUmakefile.sunos | 3 + utils/magiedit/magiedit.sh | 4 +- utils/magiedit/main.c | 29 ++++--- 20 files changed, 236 insertions(+), 47 deletions(-) create mode 100644 GNUmakefile.debian create mode 100644 src/GNUmakefile.debian diff --git a/GNUmakefile.debian b/GNUmakefile.debian new file mode 100644 index 0000000..f2f0bf1 --- /dev/null +++ b/GNUmakefile.debian @@ -0,0 +1,137 @@ +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 + +www: + cd src && $(MAKE) -f GNUmakefile.debian 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}${exec_prefix}/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" config/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/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 + + diff --git a/dist/config/bbs.ini b/dist/config/bbs.ini index 4b91ba9..febf54b 100644 --- a/dist/config/bbs.ini +++ b/dist/config/bbs.ini @@ -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 diff --git a/dist/config/filesgen.ini b/dist/config/filesgen.ini index ec292da..93fb2bb 100644 --- a/dist/config/filesgen.ini +++ b/dist/config/filesgen.ini @@ -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 diff --git a/dist/config/happynet.ini b/dist/config/happynet.ini index b93404d..97be383 100644 --- a/dist/config/happynet.ini +++ b/dist/config/happynet.ini @@ -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 diff --git a/dist/config/localmail.ini b/dist/config/localmail.ini index 73ce9d6..32cd7db 100644 --- a/dist/config/localmail.ini +++ b/dist/config/localmail.ini @@ -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 diff --git a/dist/scripts/login_stanza.lua b/dist/scripts/login_stanza.lua index 153cff8..2b0abdc 100644 --- a/dist/scripts/login_stanza.lua +++ b/dist/scripts/login_stanza.lua @@ -1,4 +1,4 @@ -local bulletin_path = "/home/andrew/MagickaBBS/ansis"; +local bulletin_path = "__SHAREPREFIX__/ansis"; function file_exists(name) diff --git a/setup.sh b/setup.sh index 69e3d5b..a3580fb 100755 --- a/setup.sh +++ b/setup.sh @@ -70,16 +70,20 @@ 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}@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@__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 diff --git a/src/GNUmakefile.common b/src/GNUmakefile.common index c38f6e6..c77d539 100644 --- a/src/GNUmakefile.common +++ b/src/GNUmakefile.common @@ -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 diff --git a/src/GNUmakefile.debian b/src/GNUmakefile.debian new file mode 100644 index 0000000..2ce730b --- /dev/null +++ b/src/GNUmakefile.debian @@ -0,0 +1,14 @@ +CC:= cc +CFLAGS:= -std=gnu99 -I/usr/local/include -ggdb +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 + +MAGIEDIT_ANSI_PATH:= "$(datarootdir)/magicka/ansis" +MAGIEDIT_DRAFT_PATH:= "$(localstatedir)/magicka" + +include GNUmakefile.common diff --git a/src/GNUmakefile.dragonfly b/src/GNUmakefile.dragonfly index 1312a93..5712519 100644 --- a/src/GNUmakefile.dragonfly +++ b/src/GNUmakefile.dragonfly @@ -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 diff --git a/src/GNUmakefile.freebsd b/src/GNUmakefile.freebsd index 98022de..edf6491 100644 --- a/src/GNUmakefile.freebsd +++ b/src/GNUmakefile.freebsd @@ -7,4 +7,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= freebsd DEPS_JAMLIB_MAKEFILE:= Makefile.linux +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.haiku b/src/GNUmakefile.haiku index 3e05fe5..4297846 100644 --- a/src/GNUmakefile.haiku +++ b/src/GNUmakefile.haiku @@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= haiku DEPS_JAMLIB_MAKEFILE:= Makefile.linux +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.linux b/src/GNUmakefile.linux index bb16c7e..c569ac1 100644 --- a/src/GNUmakefile.linux +++ b/src/GNUmakefile.linux @@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= linux DEPS_JAMLIB_MAKEFILE:= Makefile.linux +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.linux-musl b/src/GNUmakefile.linux-musl index 518983f..b95335d 100644 --- a/src/GNUmakefile.linux-musl +++ b/src/GNUmakefile.linux-musl @@ -10,4 +10,7 @@ DEPS_JAMLIB_MAKEFILE:= Makefile.linux-musl FTSLIB:= FTSLIB=1 +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.netbsd b/src/GNUmakefile.netbsd index d7d129c..289a4fc 100644 --- a/src/GNUmakefile.netbsd +++ b/src/GNUmakefile.netbsd @@ -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 diff --git a/src/GNUmakefile.openbsd b/src/GNUmakefile.openbsd index e28f497..d07cbfa 100644 --- a/src/GNUmakefile.openbsd +++ b/src/GNUmakefile.openbsd @@ -7,4 +7,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= bsd DEPS_JAMLIB_MAKEFILE:= Makefile.linux +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.osx b/src/GNUmakefile.osx index 935d44e..6f66ee0 100644 --- a/src/GNUmakefile.osx +++ b/src/GNUmakefile.osx @@ -7,4 +7,7 @@ LIBTOOLIZE:= glibtoolize DEPS_LUA_TARGET:= macosx DEPS_JAMLIB_MAKEFILE:= Makefile.linux +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/src/GNUmakefile.sunos b/src/GNUmakefile.sunos index fdea58c..b8b5777 100644 --- a/src/GNUmakefile.sunos +++ b/src/GNUmakefile.sunos @@ -8,4 +8,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= solaris DEPS_JAMLIB_MAKEFILE:= Makefile.sunos +MAGIEDIT_ANSI_PATH:= "" +MAGIEDIT_DRAFT_PATH:= "" + include GNUmakefile.common diff --git a/utils/magiedit/magiedit.sh b/utils/magiedit/magiedit.sh index fc90487..e6b095f 100755 --- a/utils/magiedit/magiedit.sh +++ b/utils/magiedit/magiedit.sh @@ -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__/magiedit +__EXECPREFIX__/magiedit -D __LOCALSTATEPREFIX__/node$1/dorinfo1.def -MSGTMP __LOCALSTATEPREFIX__/node$1 diff --git a/utils/magiedit/main.c b/utils/magiedit/main.c index 4a644b5..107e05a 100644 --- a/utils/magiedit/main.c +++ b/utils/magiedit/main.c @@ -16,6 +16,14 @@ #include #include +#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); @@ -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); @@ -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); From 8bf94b380e7214241e5109f7d13c15c6fa8fb9b6 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 12:21:10 +1000 Subject: [PATCH 02/38] Fix setup.sh --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index a3580fb..1819f41 100755 --- a/setup.sh +++ b/setup.sh @@ -71,7 +71,7 @@ fi $SED -i "s@__CONFIGPREFIX__/keys@${PWD}/keys@g" config/bbs.ini -$SED -i "s@__CONFIGPREFIX__@${PWD}@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 From e5135e654035d7ab3ec7db830d3b81ca17e07045 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 13:00:29 +1000 Subject: [PATCH 03/38] Another fixup for setup.sh --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 1819f41..325839b 100755 --- a/setup.sh +++ b/setup.sh @@ -82,7 +82,7 @@ $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@__LOCALSTATEPREFIX__@${PWD}@g" utils/magiedit/magiedit.sh +$SED -i "s@__LOCALSTATEPREFIX__@${PWD}/utils/magiedit@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 From 1205607d939ba9851f227ad9eecb68a87ec4345f Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 13:06:54 +1000 Subject: [PATCH 04/38] Another fix for setup.sh --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 325839b..31316b6 100755 --- a/setup.sh +++ b/setup.sh @@ -82,7 +82,8 @@ $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@__LOCALSTATEPREFIX__@${PWD}/utils/magiedit@g" utils/magiedit/magiedit.sh +$SED -i "s@cd __LOCALSTATEPREFIX__/magiedit@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 From 6dba7e8481037d3cf9f2135c6b49fb700258a208 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 13:25:37 +1000 Subject: [PATCH 05/38] Some fixes for make install --- GNUmakefile.debian | 6 ++++-- src/users.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/GNUmakefile.debian b/GNUmakefile.debian index f2f0bf1..8e67600 100644 --- a/GNUmakefile.debian +++ b/GNUmakefile.debian @@ -43,7 +43,7 @@ install: install -m755 -d ${DESTDIR}${datarootdir}/magicka/www/static/fonts install -m755 -d ${DESTDIR}${datarootdir}/magicka/menus - install -m755 magicka ${DESTDIR}${exec_prefix}/magicka + 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 @@ -75,7 +75,7 @@ install: 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" config/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 @@ -88,6 +88,8 @@ install: 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 diff --git a/src/users.c b/src/users.c index 5a2cd96..9368c72 100644 --- a/src/users.c +++ b/src/users.c @@ -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); From f26e31c660068d88c31df37f20da2510f5269199 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 13:40:56 +1000 Subject: [PATCH 06/38] more fixes for make install --- GNUmakefile.debian | 6 +++++- setup.sh | 2 +- src/GNUmakefile.debian | 4 ++-- utils/magiedit/magiedit.sh | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/GNUmakefile.debian b/GNUmakefile.debian index 8e67600..2915375 100644 --- a/GNUmakefile.debian +++ b/GNUmakefile.debian @@ -136,4 +136,8 @@ install: 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 diff --git a/setup.sh b/setup.sh index 31316b6..307fab0 100755 --- a/setup.sh +++ b/setup.sh @@ -82,7 +82,7 @@ $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__/magiedit@cd ${PWD}/utils/magiedit/@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 diff --git a/src/GNUmakefile.debian b/src/GNUmakefile.debian index 2ce730b..70d80b2 100644 --- a/src/GNUmakefile.debian +++ b/src/GNUmakefile.debian @@ -8,7 +8,7 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= linux DEPS_JAMLIB_MAKEFILE:= Makefile.linux -MAGIEDIT_ANSI_PATH:= "$(datarootdir)/magicka/ansis" -MAGIEDIT_DRAFT_PATH:= "$(localstatedir)/magicka" +MAGIEDIT_ANSI_PATH:= "$(datarootdir)/magicka/ansis/" +MAGIEDIT_DRAFT_PATH:= "$(localstatedir)/magicka/" include GNUmakefile.common diff --git a/utils/magiedit/magiedit.sh b/utils/magiedit/magiedit.sh index e6b095f..ddb629b 100755 --- a/utils/magiedit/magiedit.sh +++ b/utils/magiedit/magiedit.sh @@ -1,3 +1,3 @@ #!/bin/sh -cd __LOCALSTATEPREFIX__/magiedit +cd __LOCALSTATEPREFIX__ __EXECPREFIX__/magiedit -D __LOCALSTATEPREFIX__/node$1/dorinfo1.def -MSGTMP __LOCALSTATEPREFIX__/node$1 From 63438cea6d78af796c35cf36698629e81aa09be2 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 26 Oct 2018 14:20:45 +1000 Subject: [PATCH 07/38] More fixes for make install --- GNUmakefile.debian | 13 +++++++++++-- src/GNUmakefile.debian | 5 +---- utils/magiedit/GNUmakefile | 3 ++- utils/magiedit/main.c | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/GNUmakefile.debian b/GNUmakefile.debian index 2915375..fe1a9b2 100644 --- a/GNUmakefile.debian +++ b/GNUmakefile.debian @@ -18,10 +18,10 @@ all: magicka .PHONY: magicka www clean cleanwww install magicka: - cd src && $(MAKE) -f GNUmakefile.debian + 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 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 @@ -141,3 +141,12 @@ install: 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" + diff --git a/src/GNUmakefile.debian b/src/GNUmakefile.debian index 70d80b2..bb16c7e 100644 --- a/src/GNUmakefile.debian +++ b/src/GNUmakefile.debian @@ -1,5 +1,5 @@ CC:= cc -CFLAGS:= -std=gnu99 -I/usr/local/include -ggdb +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 @@ -8,7 +8,4 @@ LIBTOOLIZE:= libtoolize DEPS_LUA_TARGET:= linux DEPS_JAMLIB_MAKEFILE:= Makefile.linux -MAGIEDIT_ANSI_PATH:= "$(datarootdir)/magicka/ansis/" -MAGIEDIT_DRAFT_PATH:= "$(localstatedir)/magicka/" - include GNUmakefile.common diff --git a/utils/magiedit/GNUmakefile b/utils/magiedit/GNUmakefile index d295615..d7c8ed9 100644 --- a/utils/magiedit/GNUmakefile +++ b/utils/magiedit/GNUmakefile @@ -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 diff --git a/utils/magiedit/main.c b/utils/magiedit/main.c index 107e05a..03059ea 100644 --- a/utils/magiedit/main.c +++ b/utils/magiedit/main.c @@ -451,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) { @@ -501,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 From 26f1e850e26567aab8accf82eee16799e7a3c6dd Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 15:28:21 +1000 Subject: [PATCH 08/38] Some work on qwk tossing --- utils/qwknet/qwktoss.c | 73 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/utils/qwknet/qwktoss.c b/utils/qwknet/qwktoss.c index d97abc5..114c4b5 100644 --- a/utils/qwknet/qwktoss.c +++ b/utils/qwknet/qwktoss.c @@ -15,6 +15,17 @@ 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 msg_bases **msgbases; +int msgbasecount = 0; int recursive_delete(const char *dir) { int ret = 0; @@ -102,7 +113,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,6 +154,7 @@ 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]; struct QwkHeader qhdr; int msgrecs; @@ -148,7 +173,8 @@ int process_msgs_dat(char *msgsdat) { s_JamSubPacket* jsp; s_JamSubfield jsf; int z; - + int basefound = 0; + snprintf(buffer, PATH_MAX, "%s/%s", temp_dir, msgsdat); fptr = fopen(buffer, "rb"); @@ -212,7 +238,40 @@ 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;ibaseno == 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"); + } + + 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) { @@ -358,8 +417,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); } @@ -391,4 +452,4 @@ int main(int argc, char **argv) { closedir(inb); return 0; -} \ No newline at end of file +} From 17296c6753f1b6042af1e877d31b38ea7b4433c5 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 15:30:48 +1000 Subject: [PATCH 09/38] Fix bug in last commit --- utils/qwknet/qwktoss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/qwknet/qwktoss.c b/utils/qwknet/qwktoss.c index 114c4b5..3206b9a 100644 --- a/utils/qwknet/qwktoss.c +++ b/utils/qwknet/qwktoss.c @@ -254,6 +254,7 @@ int process_msgs_dat(char *msgsdat) { if (!bases_exists) { fprintf(cfgfptr, "[bases]\n"); + bases_exists = 1; } fprintf(cfgfptr, "%d = %d\n", msgconf, msgconf); From 05ac869bb705da2dc10f925e05f9054677011fe3 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 16:19:56 +1000 Subject: [PATCH 10/38] Fix for OpenIndiana --- utils/ticproc/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/ticproc/Makefile b/utils/ticproc/Makefile index 036712c..91ec4b3 100644 --- a/utils/ticproc/Makefile +++ b/utils/ticproc/Makefile @@ -35,6 +35,11 @@ ifeq ($(OS), Haiku) CFLAGS= LDFLAGS=-lsqlite3 endif +ifeq ($(OS), SunOS) + CC=gcc + CFLAGS= + LDFLAGS=-lsqlite3 +endif DEPS = ticproc.c From 8a3e8a2f6e82ce5c683475d0c1e63abf09bfed4c Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 22:32:21 +1000 Subject: [PATCH 11/38] Initial commit of QWK Scan --- src/bluewave.c | 4 +- src/mail_menu.c | 11 +- src/www_msgs.c | 3 + utils/qwknet/Makefile | 10 +- utils/qwknet/qwk.h | 4 +- utils/qwknet/qwk.ini | 4 +- utils/qwknet/qwkscan.c | 377 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 399 insertions(+), 14 deletions(-) create mode 100644 utils/qwknet/qwkscan.c diff --git a/src/bluewave.c b/src/bluewave.c index a81f500..37f1995 100644 --- a/src/bluewave.c +++ b/src/bluewave.c @@ -1082,8 +1082,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 \xFE MagickaBBS \xFE %s\r", + tagline); } else { snprintf(originlinebuffer, sizeof originlinebuffer, "\r"); } diff --git a/src/mail_menu.c b/src/mail_menu.c index ead0702..b640bd2 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -469,9 +469,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 \xFE MagickaBBS \xFE %s\r", + tagline); } else { snprintf(buffer, sizeof buffer, "\r"); } @@ -608,10 +607,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 \xFE MagickaBBS \xFE %s\r", + tagline); } else { strlcpy(buffer, "\r", sizeof buffer); } diff --git a/src/www_msgs.c b/src/www_msgs.c index 165eb38..9366597 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -1114,6 +1114,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 \xFE MagickaBBS \xFE %s\r", + tagline); } else { snprintf(buffer, sizeof buffer, "\r"); } diff --git a/utils/qwknet/Makefile b/utils/qwknet/Makefile index 8eb2f33..74b2eb9 100644 --- a/utils/qwknet/Makefile +++ b/utils/qwknet/Makefile @@ -1,10 +1,11 @@ CC=cc CFLAGS=-I/usr/local/include -ggdb -DEPS = qwktoss.c +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) @@ -14,7 +15,10 @@ $(JAMLIB): 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: diff --git a/utils/qwknet/qwk.h b/utils/qwknet/qwk.h index a24ffbe..fb99fa5 100644 --- a/utils/qwknet/qwk.h +++ b/utils/qwknet/qwk.h @@ -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)); \ No newline at end of file diff --git a/utils/qwknet/qwk.ini b/utils/qwknet/qwk.ini index 5e2c2ce..2f22317 100644 --- a/utils/qwknet/qwk.ini +++ b/utils/qwknet/qwk.ini @@ -1,6 +1,8 @@ [Main] +Host = SANDWICH 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 \ No newline at end of file +Unpack Command = unzip -j -o *a -d *d +Pack Command = zip -j *a *f diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c new file mode 100644 index 0000000..bbc19af --- /dev/null +++ b/utils/qwknet/qwkscan.c @@ -0,0 +1,377 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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; + char text[128]; + char *msgbuf; + char *msgptr; + + 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;iNumFields;z++) { + if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) { + if (jsp->Fields[z]->DatLen > 24) { + len = 24; + } else { + len = jsp->Fields[z]->DatLen; + } + memset(qh.MsgSubj, 0, 25); + memcpy(qh.MsgSubj, jsp->Fields[z]->Buffer, len); + } + if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) { + if (jsp->Fields[z]->DatLen > 24) { + len = 24; + } else { + len = jsp->Fields[z]->DatLen; + } + memset(qh.MsgFrom, 0, 25); + memcpy(qh.MsgFrom, jsp->Fields[z]->Buffer, len); + } + if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) { + if (jsp->Fields[z]->DatLen > 24) { + len = 24; + } else { + len = jsp->Fields[z]->DatLen; + } + memset(qh.MsgTo, 0, 25); + memcpy(qh.MsgTo, jsp->Fields[z]->Buffer, len); + } + } + 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, '\0', lenbytes); + + JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, msgbuf); + + msgptr = msgbuf; + while (*msgptr != '\0') { + if (*msgptr == '\r') { + *msgptr = '\xe3'; + } + msgptr++; + } + + msgptr = msgbuf + lenbytes; + while (*msgptr == '\0') { + *msgptr = ' '; + msgptr--; + } + + 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); + } + + 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; + 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); + } + + for (i=0;ibaseno, msgbases[i]->path, qwkidx); + qwkidx += msgcount; + fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount); + } + + snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); + + 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", temp_dir, hostid); + alen = strlen(b); + } else if (*p == '*') { + *b++ = '*'; + alen = 1; + } + b += alen; + blen -= alen; + } + *b = '\0'; + + ret = system(buffer); + if (ret == -1 || ret >> 8 == 127) { + return -1; + } + recursive_delete(temp_dir); +} \ No newline at end of file From 1a6637aa038d80b009fd1647da0bf034d36a1049 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 22:41:18 +1000 Subject: [PATCH 12/38] Fixes for QWK scan --- utils/qwknet/qwkscan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index bbc19af..d04d800 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -262,7 +262,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { fptr = fopen(buffer, "r+"); if (!fptr) { fptr = fopen(buffer, "w"); - if (!fptr) { + if (fptr) { memset(text, ' ', 128); memcpy(text, hostid, strlen(hostid)); fwrite(text, 128, 1, fptr); @@ -336,6 +336,8 @@ int main(int argc, char **argv) { exit(-1); } + mkdir(temp_dir, 0755); + for (i=0;ibaseno, msgbases[i]->path, qwkidx); qwkidx += msgcount; From b4ffc3a617579b869d89aa1839e9c6a0f1ee9c74 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 22:51:14 +1000 Subject: [PATCH 13/38] Fixes for qwkscan --- utils/qwknet/qwkscan.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index d04d800..bc3be07 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -183,7 +183,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { } else { len = jsp->Fields[z]->DatLen; } - memset(qh.MsgSubj, 0, 25); + memset(qh.MsgSubj, ' ', 25); memcpy(qh.MsgSubj, jsp->Fields[z]->Buffer, len); } if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) { @@ -192,7 +192,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { } else { len = jsp->Fields[z]->DatLen; } - memset(qh.MsgFrom, 0, 25); + memset(qh.MsgFrom, ' ', 25); memcpy(qh.MsgFrom, jsp->Fields[z]->Buffer, len); } if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) { @@ -201,7 +201,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { } else { len = jsp->Fields[z]->DatLen; } - memset(qh.MsgTo, 0, 25); + memset(qh.MsgTo, ' ', 25); memcpy(qh.MsgTo, jsp->Fields[z]->Buffer, len); } } @@ -238,7 +238,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { msgptr++; } - msgptr = msgbuf + lenbytes; + msgptr = &msgbuf[lenbytes]; while (*msgptr == '\0') { *msgptr = ' '; msgptr--; From 553d2ca686a1891ac7397737fc91f15b30d7e956 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 23:01:48 +1000 Subject: [PATCH 14/38] Fixes for qwkscan --- src/bluewave.c | 2 +- src/mail_menu.c | 4 ++-- src/www_msgs.c | 2 +- utils/qwknet/qwkscan.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bluewave.c b/src/bluewave.c index 37f1995..7e83815 100644 --- a/src/bluewave.c +++ b/src/bluewave.c @@ -1082,7 +1082,7 @@ 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---\r \xFE MagickaBBS \xFE %s\r", + snprintf(originlinebuffer, sizeof originlinebuffer, "\r---\r * MagickaBBS * %s\r", tagline); } else { snprintf(originlinebuffer, sizeof originlinebuffer, "\r"); diff --git a/src/mail_menu.c b/src/mail_menu.c index b640bd2..5294fc4 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -469,7 +469,7 @@ 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---\r \xFE MagickaBBS \xFE %s\r", + snprintf(buffer, sizeof buffer, "\r---\r * MagickaBBS * %s\r", tagline); } else { snprintf(buffer, sizeof buffer, "\r"); @@ -607,7 +607,7 @@ 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---\r \xFE MagickaBBS \xFE %s\r", + snprintf(buffer, sizeof buffer, "\r---\r * MagickaBBS * %s\r", tagline); } else { strlcpy(buffer, "\r", sizeof buffer); diff --git a/src/www_msgs.c b/src/www_msgs.c index 9366597..cc099fc 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -1115,7 +1115,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference, 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 \xFE MagickaBBS \xFE %s\r", + snprintf(buffer, sizeof buffer, "\r\r---\r * MagickaBBS * %s\r", tagline); } else { snprintf(buffer, sizeof buffer, "\r"); diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index bc3be07..ef68aa7 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -238,7 +238,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { msgptr++; } - msgptr = &msgbuf[lenbytes]; + msgptr = &msgbuf[lenbytes-1]; while (*msgptr == '\0') { *msgptr = ' '; msgptr--; From d579190bc9ccd2d9922eed36e8c254bd8b4f292c Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 27 Oct 2018 23:10:59 +1000 Subject: [PATCH 15/38] Lets try this... --- utils/qwknet/qwkscan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index ef68aa7..0927d2e 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -226,7 +226,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { msgbuf = (char *)malloc(lenbytes); - memset(msgbuf, '\0', lenbytes); + memset(msgbuf, ' ', lenbytes); JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, msgbuf); @@ -238,10 +238,10 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { msgptr++; } - msgptr = &msgbuf[lenbytes-1]; - while (*msgptr == '\0') { - *msgptr = ' '; - msgptr--; + for (z=0;z Date: Sat, 27 Oct 2018 23:20:21 +1000 Subject: [PATCH 16/38] Wrong bbs id --- utils/qwknet/qwk.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/qwknet/qwk.ini b/utils/qwknet/qwk.ini index 2f22317..8e4fce2 100644 --- a/utils/qwknet/qwk.ini +++ b/utils/qwknet/qwk.ini @@ -1,5 +1,5 @@ [Main] -Host = SANDWICH +Host = VERT Message Path = /home/andrew/MagickaBBS/msgs/dovenet Inbound = /home/andrew/MagickaBBS/qwk/in Outbound = /home/andrew/MagickaBBS/qwk/out From d483d82ca3ff8316f5eba09ed386ade92efb7334 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 28 Oct 2018 11:03:38 +1000 Subject: [PATCH 17/38] More work on qwknet --- utils/qwknet/qwk.ini | 3 ++ utils/qwknet/qwknetftpc.py | 50 +++++++++++++++++++++++++++++++ utils/qwknet/qwkscan.c | 60 ++++++++++++++++++++------------------ 3 files changed, 85 insertions(+), 28 deletions(-) create mode 100644 utils/qwknet/qwknetftpc.py diff --git a/utils/qwknet/qwk.ini b/utils/qwknet/qwk.ini index 8e4fce2..e3dca64 100644 --- a/utils/qwknet/qwk.ini +++ b/utils/qwknet/qwk.ini @@ -1,5 +1,8 @@ [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 diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py new file mode 100644 index 0000000..4828ba5 --- /dev/null +++ b/utils/qwknet/qwknetftpc.py @@ -0,0 +1,50 @@ +from ftplib import FTP +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) + ftp.login(username, password) + + repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP" + + 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") + + 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 ftplib.error_perm: + 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]) \ No newline at end of file diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index 0927d2e..1405243 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -344,36 +344,40 @@ int main(int argc, char **argv) { fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount); } - snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); + if (qwkidx > 0) { - 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", temp_dir, hostid); - alen = strlen(b); - } else if (*p == '*') { - *b++ = '*'; - alen = 1; - } - b += alen; - blen -= alen; - } - *b = '\0'; + snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); - ret = system(buffer); - if (ret == -1 || ret >> 8 == 127) { - return -1; + 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", temp_dir, hostid); + 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); } \ No newline at end of file From fc446b6e9245ff399d9b0da4c2f81118792ca33f Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 28 Oct 2018 11:07:08 +1000 Subject: [PATCH 18/38] forgot to commit this fix --- utils/qwknet/qwknetftpc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py index 4828ba5..3a0bd48 100644 --- a/utils/qwknet/qwknetftpc.py +++ b/utils/qwknet/qwknetftpc.py @@ -1,4 +1,5 @@ from ftplib import FTP +from ftplib import error_perm import configparser import os import sys @@ -34,7 +35,7 @@ def dostuff(config_file): ftp.retrbinary("RETR " + config.get("Main", "Host") + ".QWK", callback) file.close() print("RETREIVED: " + config.get("Main", "Host") + ".QWK") - except ftplib.error_perm: + except error_perm: file.close() os.remove(qwkfile) From 3e08583517f33a275bacbe0e8d246017564569ba Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 28 Oct 2018 12:44:41 +1000 Subject: [PATCH 19/38] Update mnet submodule --- utils/mnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/mnet b/utils/mnet index 31cd8fc..619660a 160000 --- a/utils/mnet +++ b/utils/mnet @@ -1 +1 @@ -Subproject commit 31cd8fcb781c73c97ac7cc963eed0f8caefbf86b +Subproject commit 619660a8c675531b432c5b24e0b389e1e4822ff6 From 13a74041945f5a4d5167a40b210d9a89d7851ce8 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 28 Oct 2018 17:45:50 +1000 Subject: [PATCH 20/38] Initial work on wwivnet tools --- utils/wwivnet/wwivnet.h | 19 +++++ utils/wwivnet/wwivtoss.c | 169 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 utils/wwivnet/wwivnet.h create mode 100644 utils/wwivnet/wwivtoss.c diff --git a/utils/wwivnet/wwivnet.h b/utils/wwivnet/wwivnet.h new file mode 100644 index 0000000..eda7cbe --- /dev/null +++ b/utils/wwivnet/wwivnet.h @@ -0,0 +1,19 @@ +#ifndef __WWIVNET_H__ +#define __WWIVNET_H__ + +#include + +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 diff --git a/utils/wwivnet/wwivtoss.c b/utils/wwivnet/wwivtoss.c new file mode 100644 index 0000000..f2cb309 --- /dev/null +++ b/utils/wwivnet/wwivtoss.c @@ -0,0 +1,169 @@ +#include +#include +#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); +} From 0a583eaa84ddd5ab84ed7787db6598510f0f7511 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Mon, 29 Oct 2018 17:04:10 +1000 Subject: [PATCH 21/38] Possible fix for website crashes --- src/www_msgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/www_msgs.c b/src/www_msgs.c index cc099fc..8778594 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -828,7 +828,7 @@ static char *www_wordwrap(char *content, int cutoff) { at = 0; len = strlen(content); - for (i = 0; i < len - 1; i++) { + for (i = 0; i < len - 2; i++) { if (content[i] == '>' && line_count < 4) { quote_line = 1; } From 463b77ba8bb0f14ed5e12854723c57dadf997529 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Tue, 30 Oct 2018 11:40:01 +1000 Subject: [PATCH 22/38] Fixes for taglines in lua_glue --- src/lua_glue.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lua_glue.c b/src/lua_glue.c index 9231682..509128f 100644 --- a/src/lua_glue.c +++ b/src/lua_glue.c @@ -521,7 +521,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 +535,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; From c5f59d252db8ad98d10d0f121348f2d4a1aa073c Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Tue, 30 Oct 2018 14:11:47 +1000 Subject: [PATCH 23/38] add missing Subject text on message view in web --- src/www_msgs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/www_msgs.c b/src/www_msgs.c index 8778594..344dbba 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -705,7 +705,10 @@ 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"); From d719141f6859dc96a0b9823d2167257522eba75a Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Tue, 30 Oct 2018 19:34:04 +1000 Subject: [PATCH 24/38] Alternative fix for www crashes --- src/www_msgs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/www_msgs.c b/src/www_msgs.c index 344dbba..7dae5f8 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -831,7 +831,7 @@ static char *www_wordwrap(char *content, int cutoff) { at = 0; len = strlen(content); - for (i = 0; i < len - 2; i++) { + for (i = 0; i < len - 1; i++) { if (content[i] == '>' && line_count < 4) { quote_line = 1; } @@ -857,7 +857,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; From 0b0078b1e7af90f51bd65806aac103bd0422b747 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 08:42:35 +1000 Subject: [PATCH 25/38] Basic support for syncronet's headers.dat --- src/bbs.h | 1 + src/bluewave.c | 10 +++ src/mail_menu.c | 29 +++++++++ src/main.c | 5 +- src/www_msgs.c | 28 ++++++++- utils/qwknet/qwkscan.c | 67 +++++++++++++++++++- utils/qwknet/qwktoss.c | 139 ++++++++++++++++++++++++++++++++++++++--- 7 files changed, 267 insertions(+), 12 deletions(-) diff --git a/src/bbs.h b/src/bbs.h index b0da565..fb0402f 100644 --- a/src/bbs.h +++ b/src/bbs.h @@ -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; diff --git a/src/bluewave.c b/src/bluewave.c index 7e83815..ffd8e51 100644 --- a/src/bluewave.c +++ b/src/bluewave.c @@ -698,6 +698,16 @@ 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) { + snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), 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; diff --git a/src/mail_menu.c b/src/mail_menu.c index 5294fc4..582daf6 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -1731,6 +1731,25 @@ 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) { + snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), 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; @@ -2181,6 +2200,16 @@ 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) { + snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), 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; diff --git a/src/main.c b/src/main.c index 518a6e8..be966ca 100644 --- a/src/main.c +++ b/src/main.c @@ -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,7 +1180,8 @@ 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) { fprintf(stderr, "Unable to load configuration ini (%s)!\n", argv[1]); diff --git a/src/www_msgs.c b/src/www_msgs.c index 7dae5f8..11f7e63 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -1049,7 +1049,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); @@ -1075,7 +1075,31 @@ 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) { + snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), 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)); + } } } } diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index 1405243..1c063c5 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -145,12 +145,22 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { 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); @@ -178,6 +188,10 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { // export message for (z=0;zNumFields;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 { @@ -187,6 +201,9 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { 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 { @@ -196,6 +213,9 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { 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 { @@ -204,6 +224,16 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { 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); @@ -276,6 +306,41 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { fseek(fptr, 0, SEEK_END); } + offset = ftell(fptr); + + snprintf(buffer, PATH_MAX, "%s/HEADERS.DAT", temp_dir); + hdrptr = fopen(buffer, "a"); + + fprintf(hdrptr, "[%x]\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); @@ -362,7 +427,7 @@ int main(int argc, char **argv) { strncpy(b, archive, blen); alen = strlen(archive); } else if (*p == 'f') { - snprintf(b, blen, "%s/%s.MSG", temp_dir, hostid); + snprintf(b, blen, "%s/%s.MSG %s/HEADERS.DAT", temp_dir, hostid, temp_dir); alen = strlen(b); } else if (*p == '*') { *b++ = '*'; diff --git a/utils/qwknet/qwktoss.c b/utils/qwknet/qwktoss.c index 3206b9a..e9eb4de 100644 --- a/utils/qwknet/qwktoss.c +++ b/utils/qwknet/qwktoss.c @@ -24,6 +24,20 @@ struct msg_bases { 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; @@ -100,6 +114,59 @@ 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;iheader_count;i++) { + if (strcmp(key, header->headers[i]->key) == 0) { + fprintf(stderr, "%s\n", header->headers[i]->value); + return header->headers[i]->value; + } + } + return NULL; +} + +static struct msg_headers_t *get_header(long offset) { + for (int i=0;ioffset == 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;ioffset == 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) { @@ -155,7 +222,9 @@ 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; @@ -174,7 +243,16 @@ int process_msgs_dat(char *msgsdat) { 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); fptr = fopen(buffer, "rb"); @@ -183,11 +261,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); @@ -278,6 +360,7 @@ int process_msgs_dat(char *msgsdat) { if (!jb) { fprintf(stderr, "Unable to open JAM base: %s\n", buffer); free(msgbody); + fclose(fptr); return -1; } JAM_ClearMsgHeader( &jmh ); @@ -287,22 +370,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) { @@ -313,6 +434,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); @@ -327,6 +449,7 @@ int process_msgs_dat(char *msgsdat) { JAM_CloseMB(jb); free(jb); free(msgbody); + fclose(fptr); return -1; } else { JAM_UnlockMB(jb); From a4d3f30f8b54af99fd83f3e11462d8cfa37c1847 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 08:46:54 +1000 Subject: [PATCH 26/38] Fix some warnings --- src/bluewave.c | 1 + src/mail_menu.c | 1 + src/www_msgs.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/bluewave.c b/src/bluewave.c index ffd8e51..cd8a610 100644 --- a/src/bluewave.c +++ b/src/bluewave.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "jamlib/jam.h" #include "libuuid/uuid.h" diff --git a/src/mail_menu.c b/src/mail_menu.c index 582daf6..180f2c9 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "jamlib/jam.h" #include "lua/lua.h" diff --git a/src/www_msgs.c b/src/www_msgs.c index 11f7e63..a1e101d 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "www_tree.h" #include "jamlib/jam.h" #include "libuuid/uuid.h" From 8a6348f5b151184d00ef380571e1c0e76b75ac48 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 09:21:49 +1000 Subject: [PATCH 27/38] improvement for qwknetftpc --- utils/qwknet/qwknetftpc.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py index 3a0bd48..736ce5c 100644 --- a/utils/qwknet/qwknetftpc.py +++ b/utils/qwknet/qwknetftpc.py @@ -1,5 +1,5 @@ from ftplib import FTP -from ftplib import error_perm +from ftplib import all_errors import configparser import os import sys @@ -35,12 +35,10 @@ def dostuff(config_file): ftp.retrbinary("RETR " + config.get("Main", "Host") + ".QWK", callback) file.close() print("RETREIVED: " + config.get("Main", "Host") + ".QWK") - except error_perm: + except all_errors: file.close() os.remove(qwkfile) - - if __name__ == "__main__": From e8eef519ed1f2429b1549e016b92a4cf0a3fc164 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Tue, 30 Oct 2018 22:32:01 +0000 Subject: [PATCH 28/38] Whitespace cleanups: trailing spaces. Remove them. Signed-off-by: Dan Cross --- src/GNUmakefile.common | 2 +- src/mail_menu.c | 2 +- src/users.c | 8 +- src/util.c | 2 +- src/www_blog.c | 38 ++--- src/www_email.c | 136 ++++++++--------- src/www_files.c | 58 +++---- src/www_last10.c | 20 +-- src/www_msgs.c | 180 +++++++++++----------- src/www_tree.c | 332 ++++++++++++++++++++--------------------- src/www_tree.h | 2 +- 11 files changed, 390 insertions(+), 390 deletions(-) diff --git a/src/GNUmakefile.common b/src/GNUmakefile.common index c77d539..c51e08a 100644 --- a/src/GNUmakefile.common +++ b/src/GNUmakefile.common @@ -67,7 +67,7 @@ endif ${CC} -c -o $@ $< ${CFLAGS} magickawww: ${OBJS} ${WWWOBJS} ${LUA} ${ZMODEM} ${B64} ${JAMLIB} ${JSMN} ${UUID} - ${CC} -o ../magicka $^ ${LIBS} -lmicrohttpd + ${CC} -o ../magicka $^ ${LIBS} -lmicrohttpd magicka: ${OBJS} ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID} ${CC} -o ../magicka $^ ${LIBS} diff --git a/src/mail_menu.c b/src/mail_menu.c index 180f2c9..5d40487 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -1600,7 +1600,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno free(from); ptr_vector_apply(&msg_lines, free); destroy_ptr_vector(&msg_lines); - return 0; + return 0; } s_printf(get_string(115)); s_readstring_inject(buffer, 64, subject); diff --git a/src/users.c b/src/users.c index 9368c72..883a6a6 100644 --- a/src/users.c +++ b/src/users.c @@ -542,21 +542,21 @@ void list_users(struct user_record *user) { int check_fullname_j(char *firstandlastname) { char *firstname = strdup(firstandlastname); - + if (!firstname) { return 0; } - + char *lastname = strchr(firstname, ' '); int ret; - + if (lastname == NULL) { return 0; } *lastname = '\0'; lastname++; ret = check_fullname(firstname, lastname); - + free(firstname); return ret; } diff --git a/src/util.c b/src/util.c index c45fca0..54ef069 100644 --- a/src/util.c +++ b/src/util.c @@ -249,5 +249,5 @@ FILE *fopen_node_path(const char *filename, const char *mode) { snprintf(buffer, PATH_MAX, "%s/node%d/%s", conf.bbs_path, mynode, filename); - return fopen(buffer, mode); + return fopen(buffer, mode); } diff --git a/src/www_blog.c b/src/www_blog.c index f2c6c9d..e5eec5e 100644 --- a/src/www_blog.c +++ b/src/www_blog.c @@ -15,7 +15,7 @@ char *www_blog() { struct www_tag *child_tag; struct www_tag *child_child_tag; struct www_tag *child_child_child_tag; - + page = www_tag_new(NULL, ""); cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); @@ -28,8 +28,8 @@ char *www_blog() { cur_tag = www_tag_new("p", NULL); www_tag_add_child(cur_tag, www_tag_new(NULL, "No Entries")); www_tag_add_child(page, cur_tag); - - + + return www_tag_unwravel(page); } for (size_t i = 0; i < ptr_vector_len(&entries); i++) { @@ -47,39 +47,39 @@ char *www_blog() { cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "blog-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "blog-title"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new("h3", NULL); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, entry->subject); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "blog-date"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, timebuf); www_tag_add_child(child_tag, child_child_tag); child_child_tag = www_tag_new(NULL, hour >= 12 ? "pm" : "am"); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); child_child_tag = www_tag_new(NULL, datebuf); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "blog-author"); www_tag_add_child(cur_tag, child_tag); child_child_tag = www_tag_new(NULL, "by "); - www_tag_add_child(child_tag, child_child_tag); - + www_tag_add_child(child_tag, child_child_tag); + child_child_tag = www_tag_new(NULL, entry->author); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "blog-entry"); @@ -87,9 +87,9 @@ char *www_blog() { child_tag = www_tag_new("p", NULL); www_tag_add_child(cur_tag, child_tag); - + stralloc blog_body = EMPTY_STRALLOC; - + for (char *p = entry->body; *p != '\0'; ++p) { if (*p != '\r') { stralloc_append1(&blog_body, *p); @@ -100,16 +100,16 @@ char *www_blog() { continue; } } - + child_child_tag = www_tag_new(NULL, blog_body.s); - + free(blog_body.s); - + www_tag_add_child(child_tag, child_child_tag); } ptr_vector_apply(&entries, free); destroy_ptr_vector(&entries); - + return www_tag_unwravel(page); } diff --git a/src/www_email.c b/src/www_email.c index e1c1b5a..d626a57 100644 --- a/src/www_email.c +++ b/src/www_email.c @@ -144,28 +144,28 @@ char *www_new_email() { struct www_tag *cur_tag; struct www_tag *child_tag; struct www_tag *child_child_tag; - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "New Email"); www_tag_add_child(child_tag, child_child_tag); cur_tag = www_tag_new("form", NULL); - + stralloc url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "email/"); stralloc_0(&url); - + www_tag_add_attrib(cur_tag, "action", url.s); free(url.s); - + www_tag_add_attrib(cur_tag, "method", "POST"); www_tag_add_attrib(cur_tag, "onsubmit", "return validate()"); www_tag_add_attrib(cur_tag, "enctype", "application/x-www-form-urlencoded"); @@ -173,26 +173,26 @@ char *www_new_email() { child_tag = www_tag_new(NULL, "To : "); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("input", NULL); www_tag_add_attrib(child_tag, "type", "text"); www_tag_add_attrib(child_tag, "name", "recipient"); www_tag_add_attrib(child_tag, "id", "recipient"); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("br", NULL); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new(NULL, "Subject : "); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("input", NULL); www_tag_add_attrib(child_tag, "type", "text"); www_tag_add_attrib(child_tag, "name", "subject"); www_tag_add_attrib(child_tag, "id", "subject"); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("br", NULL); www_tag_add_child(cur_tag, child_tag); @@ -203,13 +203,13 @@ char *www_new_email() { www_tag_add_attrib(child_tag, "cols", "79"); www_tag_add_attrib(child_tag, "id", "body"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, ""); www_tag_add_child(child_tag, child_child_tag); - + child_tag = www_tag_new("br", NULL); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("input", NULL); www_tag_add_attrib(child_tag, "type", "submit"); www_tag_add_attrib(child_tag, "name", "submit"); @@ -218,7 +218,7 @@ char *www_new_email() { child_tag = www_tag_new("br", NULL); www_tag_add_child(cur_tag, child_tag); - + return www_tag_unwravel(page); } @@ -280,17 +280,17 @@ char *www_email_display(struct user_record *user, int email) { if (sqlite3_step(res) != SQLITE_ROW) { page = www_tag_new(NULL, ""); - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "No such email!"); www_tag_add_child(child_tag, child_child_tag); - + return www_tag_unwravel(page); } id = sqlite3_column_int(res, 0); @@ -301,14 +301,14 @@ char *www_email_display(struct user_record *user, int email) { localtime_r(&date, &msg_date); page = www_tag_new(NULL, ""); - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "Your Email"); www_tag_add_child(child_tag, child_child_tag); @@ -319,42 +319,42 @@ char *www_email_display(struct user_record *user, int email) { child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "email-view-subject"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, subject); www_tag_add_child(child_tag, child_child_tag); child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "email-view-from"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, from); www_tag_add_child(child_tag, child_child_tag); child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "email-view-date"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "Date: "); www_tag_add_child(child_tag, child_child_tag); - + if (conf.date_style == 1) strftime(datebuf, sizeof datebuf, "%H:%M %m-%d-%y", &msg_date); else strftime(datebuf, sizeof datebuf, "%H:%M %d-%m-%y", &msg_date); - + child_child_tag = www_tag_new(NULL, datebuf); www_tag_add_child(child_tag, child_child_tag); - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "id", "msgbody"); www_tag_add_child(page, cur_tag); - + aha(body, cur_tag); cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "email-reply-form"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h3", NULL); www_tag_add_child(cur_tag, child_tag); @@ -362,20 +362,20 @@ char *www_email_display(struct user_record *user, int email) { www_tag_add_child(child_tag, child_child_tag); child_tag = www_tag_new("form", NULL); - + stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "email/"); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "action", url.s); free(url.s); - + www_tag_add_attrib(child_tag, "method", "POST"); www_tag_add_attrib(child_tag, "enctype", "application/x-www-form-urlencoded"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new("input", NULL); www_tag_add_attrib(child_child_tag, "type", "hidden"); www_tag_add_attrib(child_child_tag, "name", "recipient"); @@ -383,21 +383,21 @@ char *www_email_display(struct user_record *user, int email) { 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); - + 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"); stralloc subj = EMPTY_STRALLOC; - + if (strncasecmp(subject, "re:", 3) != 0) stralloc_cats(&subj, "RE: "); stralloc_cats(&subj, subject); stralloc_0(&subj); www_tag_add_attrib(child_child_tag, "value", subj.s); free(subj.s); - + www_tag_add_child(child_tag, child_child_tag); child_child_tag = www_tag_new("br", NULL); @@ -410,7 +410,7 @@ char *www_email_display(struct user_record *user, int email) { www_tag_add_attrib(child_child_tag, "cols", "79"); www_tag_add_attrib(child_child_tag, "id", "replybody"); www_tag_add_child(child_tag, child_child_tag); - + stralloc content = EMPTY_STRALLOC; stralloc_cats(&content, from); @@ -429,12 +429,12 @@ char *www_email_display(struct user_record *user, int email) { stralloc_append1(&content, *p); ++column; } - + stralloc_0(&content); - + child_child_child_tag = www_tag_new(NULL, content.s); free(content.s); - + www_tag_add_child(child_child_tag, child_child_child_tag); child_child_tag = www_tag_new("br", NULL); @@ -511,14 +511,14 @@ char *www_email_summary(struct user_record *user) { sqlite3_bind_text(res, 1, user->loginname, -1, 0); page = www_tag_new(NULL, ""); - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "Your Email"); www_tag_add_child(child_tag, child_child_tag); @@ -528,7 +528,7 @@ char *www_email_summary(struct user_record *user) { child_tag = www_tag_new("a", NULL); stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "email/new"); stralloc_0(&url); @@ -543,7 +543,7 @@ char *www_email_summary(struct user_record *user) { cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "div-table"); www_tag_add_child(page, cur_tag); - + while (sqlite3_step(res) == SQLITE_ROW) { char datebuf[32]; @@ -556,7 +556,7 @@ char *www_email_summary(struct user_record *user) { time_t date = (time_t)sqlite3_column_int(res, 4); localtime_r(&date, &msg_date); - + child_tag = www_tag_new("div", NULL); if (seen != 0) { @@ -566,7 +566,7 @@ char *www_email_summary(struct user_record *user) { } www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "email-id"); www_tag_add_child(child_tag, child_child_tag); @@ -574,30 +574,30 @@ char *www_email_summary(struct user_record *user) { url = EMPTY_STRALLOC; stralloc_cat_long(&url, msgid); stralloc_0(&url); - + child_child_child_tag = www_tag_new(NULL, url.s); free(url.s); - + www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "email-subject"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new("a", NULL); url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "email/"); stralloc_cat_long(&url, msgid); stralloc_0(&url); - + www_tag_add_attrib(child_child_child_tag, "href", url.s); free(url.s); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_child_child_tag = www_tag_new(NULL, subject); www_tag_add_child(child_child_child_tag, child_child_child_child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "email-from"); www_tag_add_child(child_tag, child_child_tag); @@ -609,33 +609,33 @@ char *www_email_summary(struct user_record *user) { child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "email-date"); www_tag_add_child(child_tag, child_child_tag); - + if (conf.date_style == 1) strftime(datebuf, sizeof datebuf, "%H:%M %m-%d-%y", &msg_date); else strftime(datebuf, sizeof datebuf, "%H:%M %d-%m-%y", &msg_date); - + child_child_child_tag = www_tag_new(NULL, datebuf); - www_tag_add_child(child_child_tag, child_child_child_tag); - + www_tag_add_child(child_child_tag, child_child_child_tag); + child_child_tag = www_tag_new("a", NULL); url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "email/delete/"); stralloc_cat_long(&url, id); - stralloc_0(&url); + stralloc_0(&url); www_tag_add_attrib(child_child_tag, "href", url.s); free(url.s); - - www_tag_add_child(child_tag, child_child_tag); - + + www_tag_add_child(child_tag, child_child_tag); + child_child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_child_tag, "class", "email-delete"); - www_tag_add_child(child_child_tag, child_child_child_tag); - + www_tag_add_child(child_child_tag, child_child_child_tag); + child_child_child_child_tag = www_tag_new(NULL, ""); - www_tag_add_child(child_child_child_tag, child_child_child_child_tag); + www_tag_add_child(child_child_child_tag, child_child_child_child_tag); } diff --git a/src/www_files.c b/src/www_files.c index 8886da2..07cd901 100644 --- a/src/www_files.c +++ b/src/www_files.c @@ -318,7 +318,7 @@ char *www_files_display_listing(int dir, int sub) { struct file_sub *fsub = ptr_vector_get(&fdir->file_subs, sub); assert(fsub != NULL); - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); @@ -351,53 +351,53 @@ char *www_files_display_listing(int dir, int sub) { www_tag_destroy(page); return NULL; } - + cur_tag = www_tag_new("table", NULL); www_tag_add_attrib(cur_tag, "class", "fileentry"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("thead", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new("tr", NULL); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new("td", NULL); www_tag_add_child(child_child_tag, child_child_child_tag); child_child_child_child_tag = www_tag_new(NULL, "Filename"); - www_tag_add_child(child_child_child_tag, child_child_child_child_tag); + www_tag_add_child(child_child_child_tag, child_child_child_child_tag); child_child_child_tag = www_tag_new("td", NULL); www_tag_add_child(child_child_tag, child_child_child_tag); child_child_child_child_tag = www_tag_new(NULL, "Size"); - www_tag_add_child(child_child_child_tag, child_child_child_child_tag); + www_tag_add_child(child_child_child_tag, child_child_child_child_tag); child_child_child_tag = www_tag_new("td", NULL); www_tag_add_child(child_child_tag, child_child_child_tag); child_child_child_child_tag = www_tag_new(NULL, "Description"); - www_tag_add_child(child_child_child_tag, child_child_child_child_tag); + www_tag_add_child(child_child_child_tag, child_child_child_child_tag); child_tag = www_tag_new("tbody", NULL); - www_tag_add_child(cur_tag, child_tag); + www_tag_add_child(cur_tag, child_tag); while (sqlite3_step(res) == SQLITE_ROW) { char *filename = strdup((char *)sqlite3_column_text(res, 1)); char *base_filename = basename(filename); child_child_tag = www_tag_new("tr", NULL); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new("td", NULL); www_tag_add_attrib(child_child_child_tag, "class", "filename"); www_tag_add_child(child_child_tag, child_child_child_tag); child_child_child_child_tag = www_tag_new("a", NULL); - www_tag_add_child(child_child_child_tag, child_child_child_child_tag); + www_tag_add_child(child_child_child_tag, child_child_child_child_tag); stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "files/areas/"); stralloc_cat_long(&url, dir); @@ -405,20 +405,20 @@ char *www_files_display_listing(int dir, int sub) { stralloc_cat_long(&url, sub); stralloc_append1(&url, '/'); www_encode(&url, base_filename); - + stralloc_0(&url); - + www_tag_add_attrib(child_child_child_child_tag, "href", url.s); free(url.s); child_child_child_child_child_tag = www_tag_new(NULL, base_filename); - www_tag_add_child(child_child_child_child_tag, child_child_child_child_child_tag); + www_tag_add_child(child_child_child_child_tag, child_child_child_child_child_tag); int size = sqlite3_column_int(res, 3); child_child_child_tag = www_tag_new("td", NULL); www_tag_add_attrib(child_child_child_tag, "class", "filesize"); www_tag_add_child(child_child_tag, child_child_child_tag); - + int c = 'b'; if (size > 1024) { size /= 1024; @@ -432,9 +432,9 @@ char *www_files_display_listing(int dir, int sub) { size /= 1024; c = 'G'; } - + stralloc size_str = EMPTY_STRALLOC; - + stralloc_cat_long(&size_str, size); stralloc_append1(&size_str, c); @@ -445,7 +445,7 @@ char *www_files_display_listing(int dir, int sub) { child_child_child_tag = www_tag_new("td", NULL); www_tag_add_attrib(child_child_child_tag, "class", "filedesc"); www_tag_add_child(child_child_tag, child_child_child_tag); - + char *description = strdup((char *)sqlite3_column_text(res, 2)); for (char *p = description; *p != '\0'; ++p) { if (*p == '\n') @@ -468,14 +468,14 @@ char *www_files_areas() { struct www_tag *cur_tag; struct www_tag *child_tag; struct www_tag *child_child_tag; - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "File Directories"); www_tag_add_child(child_tag, child_child_tag); @@ -483,11 +483,11 @@ char *www_files_areas() { struct file_directory *dir = ptr_vector_get(&conf.file_directories, i); if (!dir->display_on_web) continue; - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "conference-list-item"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new(NULL, dir->name); www_tag_add_child(cur_tag, child_tag); @@ -496,22 +496,22 @@ char *www_files_areas() { cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "area-list-item"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("a", NULL); - + stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "files/areas/"); stralloc_cat_long(&url, i); stralloc_append1(&url, '/'); stralloc_cat_long(&url, j); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "href", url.s); free(url.s); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, sub->name); www_tag_add_child(child_tag, child_child_tag); } diff --git a/src/www_last10.c b/src/www_last10.c index 75a448b..9d1b911 100644 --- a/src/www_last10.c +++ b/src/www_last10.c @@ -35,10 +35,10 @@ char *www_last10() { cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "Last 10 Callers"); www_tag_add_child(child_tag, child_child_tag); @@ -53,11 +53,11 @@ char *www_last10() { child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "last10-row"); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "last10-name"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, callers[i].name); www_tag_add_child(child_child_tag, child_child_child_tag); @@ -65,10 +65,10 @@ char *www_last10() { child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "last10-location"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, callers[i].location); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "last10-date"); www_tag_add_child(child_tag, child_child_tag); @@ -86,14 +86,14 @@ char *www_last10() { child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "last10-new"); www_tag_add_child(child_tag, child_child_tag); - - + + stralloc url = EMPTY_STRALLOC; - + stralloc_copys(&url, conf.www_url); stralloc_cats(&url, "static/newuser.png"); stralloc_0(&url); - + child_child_child_tag = www_tag_new("img", NULL); www_tag_add_attrib(child_child_child_tag, "src", url.s); free(url.s); diff --git a/src/www_msgs.c b/src/www_msgs.c index a1e101d..62bdeed 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -110,7 +110,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i char *from; char *subject; char datebuf[32]; - + stralloc url; struct www_tag *page; @@ -119,7 +119,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i struct www_tag *child_child_tag; struct www_tag *child_child_child_tag; struct www_tag *child_child_child_child_tag; - + if (conference < 0 || conference >= ptr_vector_len(&conf.mail_conferences)) return NULL; struct mail_conference *mc = get_conf(conference); @@ -134,10 +134,10 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, mc->name); www_tag_add_child(child_tag, child_child_tag); - + child_child_tag = www_tag_new(NULL, " - "); www_tag_add_child(child_tag, child_child_tag); @@ -148,9 +148,9 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "button"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("a", NULL); - + url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/new/"); @@ -158,12 +158,12 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i stralloc_append1(&url, '/'); stralloc_cat_long(&url, area); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "href", url.s); free(url.s); - + www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "New Message"); www_tag_add_child(child_tag, child_child_tag); } @@ -172,7 +172,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i if (mhrs == NULL) { cur_tag = www_tag_new("h3", NULL); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new(NULL, "No Messages"); www_tag_add_child(cur_tag, child_tag); } else { @@ -206,7 +206,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i subject = strdup(mhrs->msgs[i]->subject); child_tag = www_tag_new("div", NULL); - + if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) { www_tag_add_attrib(child_tag, "class", "msg-summary-flag"); } else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) { @@ -215,23 +215,23 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i www_tag_add_attrib(child_tag, "class", "msg-summary-seen"); } www_tag_add_child(cur_tag, child_tag); - - + + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "msg-summary-id"); www_tag_add_child(child_tag, child_child_tag); - + url = EMPTY_STRALLOC; stralloc_cat_long(&url, mhrs->msgs[i]->msg_no + 1); stralloc_0(&url); - + child_child_child_tag = www_tag_new(NULL, url.s); free(url.s); www_tag_add_child(child_child_tag, child_child_child_tag); child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "msg-summary-subject"); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); @@ -242,41 +242,41 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i stralloc_append1(&url, '/'); stralloc_cat_long(&url, mhrs->msgs[i]->msg_h->MsgNum); stralloc_0(&url); - + child_child_child_tag = www_tag_new("a", NULL); www_tag_add_attrib(child_child_child_tag, "href", url.s); free(url.s); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_child_child_tag = www_tag_new(NULL, subject); www_tag_add_child(child_child_child_tag, child_child_child_child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "msg-summary-from"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, from); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "msg-summary-to"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, to); - www_tag_add_child(child_child_tag, child_child_child_tag); - + www_tag_add_child(child_child_tag, child_child_child_tag); + child_child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_child_tag, "class", "msg-summary-date"); www_tag_add_child(child_tag, child_child_tag); - + if (conf.date_style == 1) strftime(datebuf, sizeof datebuf, "%H:%M %m-%d-%y", &msg_date); else strftime(datebuf, sizeof datebuf, "%H:%M %d-%m-%y", &msg_date); - + child_child_child_tag = www_tag_new(NULL, datebuf); www_tag_add_child(child_child_tag, child_child_child_tag); - + free(to); free(from); free(subject); @@ -286,11 +286,11 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "msg-summary-next"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("a", NULL); - + url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/"); stralloc_cat_long(&url, conference); @@ -299,7 +299,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i stralloc_cats(&url, "/?skip="); stralloc_cat_long(&url, skip + 50); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "href", url.s); free(url.s); www_tag_add_child(cur_tag, child_tag); @@ -310,7 +310,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i if (skip > 0) { cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "msg-summary-prev"); - www_tag_add_child(page, cur_tag); + www_tag_add_child(page, cur_tag); child_tag = www_tag_new("a", NULL); url = EMPTY_STRALLOC; if (skip - 50 < 0) { @@ -329,10 +329,10 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i stralloc_cats(&url, "/?skip="); stralloc_cat_long(&url, skip - 50); } - stralloc_0(&url); + stralloc_0(&url); www_tag_add_attrib(child_tag, "href", url.s); free(url.s); - + www_tag_add_child(cur_tag, child_tag); child_child_tag = www_tag_new(NULL, "Prev"); www_tag_add_child(child_tag, child_child_tag); @@ -380,7 +380,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i struct www_tag *child_tag; struct www_tag *child_child_tag; struct www_tag *child_child_child_tag; - + if (conference < 0 || conference >= ptr_vector_len(&conf.mail_conferences)) return NULL; struct mail_conference *mc = get_conf(conference); @@ -475,24 +475,24 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i JAM_WriteLastRead(jb, user->id, &jlr); JAM_CloseMB(jb); free(jb); - + page = www_tag_new(NULL, ""); cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("a", NULL); - + stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/"); stralloc_cat_long(&url, conference); stralloc_append1(&url, '/'); stralloc_cat_long(&url, area); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "href", url.s); free(url.s); www_tag_add_child(cur_tag, child_tag); @@ -508,17 +508,17 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i child_child_child_tag = www_tag_new(NULL, ma->name); www_tag_add_child(child_child_tag, child_child_child_tag); - + cur_tag = www_tag_new("div", NULL); - + if (msgbase_is_flagged(user, conference, area, msg)) { www_tag_add_attrib(cur_tag, "class", "msg-view-header-flagged"); } else { www_tag_add_attrib(cur_tag, "class", "msg-view-header"); } - + www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("div", NULL); www_tag_add_attrib(child_tag, "class", "msg-view-subject"); www_tag_add_child(cur_tag, child_tag); @@ -551,7 +551,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i child_child_tag = www_tag_new("span", NULL); www_tag_add_attrib(child_child_tag, "class", "bbsname"); www_tag_add_child(child_tag, child_child_tag); - + child_child_child_tag = www_tag_new(NULL, nodename); www_tag_add_child(child_child_tag, child_child_child_tag); @@ -574,7 +574,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i } else { snprintf(buffer, sizeof buffer, "From: %s", from); child_child_tag = www_tag_new(NULL, buffer); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); } child_tag = www_tag_new("div", NULL); @@ -583,7 +583,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i child_child_tag = www_tag_new(NULL, "To : "); www_tag_add_child(child_tag, child_child_tag); - + child_child_tag = www_tag_new(NULL, to); www_tag_add_child(child_tag, child_child_tag); @@ -609,9 +609,9 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i www_tag_add_child(cur_tag, child_tag); child_child_tag = www_tag_new("a", NULL); - + url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/flag/"); stralloc_cat_long(&url, conference); @@ -620,24 +620,24 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i stralloc_append1(&url, '/'); stralloc_cat_long(&url, msg); stralloc_0(&url); - + www_tag_add_attrib(child_child_tag, "href", url.s); free(url.s); www_tag_add_child(child_tag, child_child_tag); child_child_child_tag = www_tag_new("img", NULL); - + url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "static/flag.png"); stralloc_0(&url); www_tag_add_attrib(child_child_child_tag, "src", url.s); free(url.s); www_tag_add_child(child_child_tag, child_child_child_tag); - + cur_tag = www_tag_new("div", NULL); - + www_tag_add_attrib(cur_tag, "id", "msgbody"); www_tag_add_child(page, cur_tag); @@ -650,23 +650,23 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "msg-reply-form"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h3", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "Reply"); www_tag_add_child(child_tag, child_child_tag); - + child_tag = www_tag_new("form", NULL); url = EMPTY_STRALLOC; stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/"); stralloc_0(&url); - + www_tag_add_attrib(child_tag, "action", url.s); free(url.s); - + www_tag_add_attrib(child_tag, "method", "POST"); www_tag_add_attrib(child_tag, "enctype", "application/x-www-form-urlencoded;charset=UTF-8"); www_tag_add_child(cur_tag, child_tag); @@ -697,13 +697,13 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i child_child_tag = www_tag_new(NULL, "To : "); 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", "recipient"); www_tag_add_attrib(child_child_tag, "value", from); www_tag_add_child(child_tag, child_child_tag); - + child_child_tag = www_tag_new("br", NULL); www_tag_add_child(child_tag, child_child_tag); @@ -713,16 +713,16 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i 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"); - + if (strncasecmp(subject, "re:", 3) != 0) { snprintf(buffer, sizeof buffer, "RE: %s", subject); www_tag_add_attrib(child_child_tag, "value", buffer); } else { www_tag_add_attrib(child_child_tag, "value", subject); } - + www_tag_add_child(child_tag, child_child_tag); - + child_child_tag = www_tag_new("br", NULL); www_tag_add_child(child_tag, child_child_tag); @@ -733,9 +733,9 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i www_tag_add_attrib(child_child_tag, "wrap", "soft"); www_tag_add_attrib(child_child_tag, "id", "replybody"); www_tag_add_child(child_tag, child_child_tag); - + stralloc text = EMPTY_STRALLOC; - + stralloc_append1(&text, ' '); stralloc_append1(&text, from[0]); stralloc_cats(&text, "> "); @@ -781,20 +781,20 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i stralloc_cats(&text, buffer); } free(body2); - + stralloc_0(&text); - + child_child_child_tag = www_tag_new(NULL, text.s); www_tag_add_child(child_child_tag, child_child_child_tag); - + child_child_tag = www_tag_new("br", NULL); 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", "submit"); www_tag_add_attrib(child_child_tag, "name", "submit"); www_tag_add_attrib(child_child_tag, "value", "Reply"); - www_tag_add_child(child_tag, child_child_tag); + www_tag_add_child(child_tag, child_child_tag); child_child_tag = www_tag_new("br", NULL); www_tag_add_child(child_tag, child_child_tag); } @@ -1148,11 +1148,11 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference, } else { snprintf(buffer, sizeof buffer, "\r"); } - + char *p = body; stralloc unhtmlized = EMPTY_STRALLOC; - - + + // remove nbsp while (*p != '\0') { if ((*p & 0xff) == 0xc2 && (*(p + 1) & 0xff) == 0xa0) { @@ -1161,12 +1161,12 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference, } else { stralloc_append1(&unhtmlized, *p); } - + p++; } - + stralloc_0(&unhtmlized); - + body2 = www_wordwrap(unhtmlized.s, 73); free(unhtmlized.s); if (body2 == NULL) { @@ -1176,9 +1176,9 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference, free(jb); return 0; } - - - + + + body3 = str2dup(body2, buffer); if (body3 == NULL) { free(body2); @@ -1237,28 +1237,28 @@ char *www_new_msg(struct user_record *user, int conference, int area) { struct www_tag *cur_tag; struct www_tag *child_tag; struct www_tag *child_child_tag; - + char buffer[10]; - + cur_tag = www_tag_new("div", NULL); www_tag_add_attrib(cur_tag, "class", "content-header"); www_tag_add_child(page, cur_tag); - + child_tag = www_tag_new("h2", NULL); www_tag_add_child(cur_tag, child_tag); - + child_child_tag = www_tag_new(NULL, "New Message"); www_tag_add_child(child_tag, child_child_tag); - + cur_tag = www_tag_new("form", NULL); - + stralloc url = EMPTY_STRALLOC; - + stralloc_cats(&url, conf.www_url); stralloc_cats(&url, "msgs/"); stralloc_0(&url); - + www_tag_add_attrib(cur_tag, "action", url.s); free(url.s); @@ -1273,7 +1273,7 @@ char *www_new_msg(struct user_record *user, int conference, int area) { snprintf(buffer, sizeof buffer, "%d", conference); www_tag_add_attrib(child_tag, "value", buffer); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("input", NULL); www_tag_add_attrib(child_tag, "type", "hidden"); www_tag_add_attrib(child_tag, "name", "area"); @@ -1332,7 +1332,7 @@ char *www_new_msg(struct user_record *user, int conference, int area) { www_tag_add_attrib(child_tag, "name", "submit"); www_tag_add_attrib(child_tag, "value", "Send"); www_tag_add_child(cur_tag, child_tag); - + child_tag = www_tag_new("br", NULL); www_tag_add_child(cur_tag, child_tag); diff --git a/src/www_tree.c b/src/www_tree.c index 456225d..7db1df2 100644 --- a/src/www_tree.c +++ b/src/www_tree.c @@ -17,95 +17,95 @@ static char *www_tag_sanatize(char *data, int isdata) { case '>': stralloc_cats(&str, ">"); break; - case '\x01': + case '\x01': stralloc_cats(&str, "☺"); break; - case '\x02': + case '\x02': stralloc_cats(&str, "☻"); break; - case '\x03': + case '\x03': stralloc_cats(&str, "♥"); break; - case '\x04': + case '\x04': stralloc_cats(&str, "♦"); break; - case '\x05': + case '\x05': stralloc_cats(&str, "♣"); break; - case '\x06': + case '\x06': stralloc_cats(&str, "♠"); break; - case '\x07': + case '\x07': stralloc_cats(&str, "•"); break; - case '\x08': + case '\x08': stralloc_cats(&str, "◘"); break; - case '\x09': + case '\x09': stralloc_cats(&str, "○"); break; - case '\x0b': + case '\x0b': stralloc_cats(&str, "♂"); break; - case '\x0c': + case '\x0c': stralloc_cats(&str, "♀"); break; - case '\x0e': + case '\x0e': stralloc_cats(&str, "♫"); break; case '\x0f': stralloc_cats(&str, "☼"); break; - case '\x10': + case '\x10': stralloc_cats(&str, "▸"); break; - case '\x11': + case '\x11': stralloc_cats(&str, "◂"); break; - case '\x12': + case '\x12': stralloc_cats(&str, "↕"); break; - case '\x13': + case '\x13': stralloc_cats(&str, "‼"); break; - case '\x14': + case '\x14': stralloc_cats(&str, "¶"); break; - case '\x15': + case '\x15': stralloc_cats(&str, "§"); break; - case '\x16': + case '\x16': stralloc_cats(&str, "▬"); break; - case '\x17': + case '\x17': stralloc_cats(&str, "↨"); break; - case '\x18': + case '\x18': stralloc_cats(&str, "↑"); break; - case '\x19': + case '\x19': stralloc_cats(&str, "↓"); break; - case '\x1a': + case '\x1a': stralloc_cats(&str, "→"); break; - case '\x1b': + case '\x1b': stralloc_cats(&str, "←"); break; - case '\x1c': + case '\x1c': stralloc_cats(&str, "∟"); break; - case '\x1d': + case '\x1d': stralloc_cats(&str, "↔"); break; - case '\x1e': + case '\x1e': stralloc_cats(&str, "▴"); break; - case '\x1f': + case '\x1f': stralloc_cats(&str, "▾"); break; /* - case '\x21': + case '\x21': stralloc_cats(&str, "!"); break; case '\x22': @@ -166,364 +166,364 @@ static char *www_tag_sanatize(char *data, int isdata) { case '\x88': stralloc_cats(&str, "ê"); break; - case '\x89': + case '\x89': stralloc_cats(&str, "ë"); break; - case '\x8a': + case '\x8a': stralloc_cats(&str, "è"); break; - case '\x8b': + case '\x8b': stralloc_cats(&str, "ï"); break; - case '\x8c': + case '\x8c': stralloc_cats(&str, "î"); break; - case '\x8d': + case '\x8d': stralloc_cats(&str, "ì"); break; - case '\x8e': + case '\x8e': stralloc_cats(&str, "Ä"); break; - case '\x8f': + case '\x8f': stralloc_cats(&str, "Å"); break; - case '\x90': + case '\x90': stralloc_cats(&str, "É"); break; - case '\x91': + case '\x91': stralloc_cats(&str, "æ"); break; - case '\x92': + case '\x92': stralloc_cats(&str, "Æ"); break; - case '\x93': + case '\x93': stralloc_cats(&str, "ô"); break; - case '\x94': + case '\x94': stralloc_cats(&str, "ö"); break; - case '\x95': + case '\x95': stralloc_cats(&str, "ò"); break; - case '\x96': + case '\x96': stralloc_cats(&str, "û"); break; - case '\x97': + case '\x97': stralloc_cats(&str, "ù"); break; - case '\x98': + case '\x98': stralloc_cats(&str, "ÿ"); break; - case '\x99': + case '\x99': stralloc_cats(&str, "Ö"); break; - case '\x9a': + case '\x9a': stralloc_cats(&str, "Ü"); break; - case '\x9b': + case '\x9b': stralloc_cats(&str, "¢"); break; - case '\x9c': + case '\x9c': stralloc_cats(&str, "£"); break; - case '\x9d': + case '\x9d': stralloc_cats(&str, "¥"); break; - case '\x9e': + case '\x9e': stralloc_cats(&str, "₧"); break; - case '\x9f': + case '\x9f': stralloc_cats(&str, "ƒ"); break; - case '\xa0': + case '\xa0': stralloc_cats(&str, "á"); break; - case '\xa1': + case '\xa1': stralloc_cats(&str, "í"); break; - case '\xa2': + case '\xa2': stralloc_cats(&str, "ó"); break; - case '\xa3': + case '\xa3': stralloc_cats(&str, "ú"); break; - case '\xa4': + case '\xa4': stralloc_cats(&str, "ñ"); break; - case '\xa5': + case '\xa5': stralloc_cats(&str, "Ñ"); break; - case '\xa6': + case '\xa6': stralloc_cats(&str, "ª"); break; - case '\xa7': + case '\xa7': stralloc_cats(&str, "º"); break; - case '\xa8': + case '\xa8': stralloc_cats(&str, "¿"); break; - case '\xa9': + case '\xa9': stralloc_cats(&str, "⌐"); break; - case '\xaa': + case '\xaa': stralloc_cats(&str, "¬"); break; - case '\xab': + case '\xab': stralloc_cats(&str, "½"); break; - case '\xac': + case '\xac': stralloc_cats(&str, "¼"); break; - case '\xad': + case '\xad': stralloc_cats(&str, "¡"); break; - case '\xae': + case '\xae': stralloc_cats(&str, "«"); break; - case '\xaf': + case '\xaf': stralloc_cats(&str, "»"); break; - case '\xb0': + case '\xb0': stralloc_cats(&str, "░"); break; - case '\xb1': + case '\xb1': stralloc_cats(&str, "▒"); break; - case '\xb2': + case '\xb2': stralloc_cats(&str, "▓"); break; - case '\xb3': + case '\xb3': stralloc_cats(&str, "│"); break; - case '\xb4': + case '\xb4': stralloc_cats(&str, "┤"); break; - case '\xb5': + case '\xb5': stralloc_cats(&str, "╡"); break; - case '\xb6': + case '\xb6': stralloc_cats(&str, "╢"); break; - case '\xb7': + case '\xb7': stralloc_cats(&str, "╖"); break; - case '\xb8': + case '\xb8': stralloc_cats(&str, "╕"); break; - case '\xb9': + case '\xb9': stralloc_cats(&str, "╣"); break; - case '\xba': + case '\xba': stralloc_cats(&str, "║"); break; - case '\xbb': + case '\xbb': stralloc_cats(&str, "╗"); break; - case '\xbc': + case '\xbc': stralloc_cats(&str, "╝"); break; - case '\xbd': + case '\xbd': stralloc_cats(&str, "╜"); break; - case '\xbe': + case '\xbe': stralloc_cats(&str, "╛"); break; - case '\xbf': + case '\xbf': stralloc_cats(&str, "┐"); break; - case '\xc0': + case '\xc0': stralloc_cats(&str, "└"); break; - case '\xc1': + case '\xc1': stralloc_cats(&str, "┴"); break; - case '\xc2': + case '\xc2': stralloc_cats(&str, "┬"); break; - case '\xc3': + case '\xc3': stralloc_cats(&str, "├"); break; - case '\xc4': + case '\xc4': stralloc_cats(&str, "─"); break; - case '\xc5': + case '\xc5': stralloc_cats(&str, "┼"); break; - case '\xc6': + case '\xc6': stralloc_cats(&str, "╞"); break; - case '\xc7': + case '\xc7': stralloc_cats(&str, "╟"); break; - case '\xc8': + case '\xc8': stralloc_cats(&str, "╚"); break; - case '\xc9': + case '\xc9': stralloc_cats(&str, "╔"); break; - case '\xca': + case '\xca': stralloc_cats(&str, "╩"); break; - case '\xcb': + case '\xcb': stralloc_cats(&str, "╦"); break; - case '\xcc': + case '\xcc': stralloc_cats(&str, "╠"); break; - case '\xcd': + case '\xcd': stralloc_cats(&str, "═"); break; - case '\xce': + case '\xce': stralloc_cats(&str, "╬"); break; - case '\xcf': + case '\xcf': stralloc_cats(&str, "╧"); break; - case '\xd0': + case '\xd0': stralloc_cats(&str, "╨"); break; - case '\xd1': + case '\xd1': stralloc_cats(&str, "╤"); break; - case '\xd2': + case '\xd2': stralloc_cats(&str, "╥"); break; - case '\xd3': + case '\xd3': stralloc_cats(&str, "╙"); break; - case '\xd4': + case '\xd4': stralloc_cats(&str, "╛"); break; - case '\xd5': + case '\xd5': stralloc_cats(&str, "╒"); break; - case '\xd6': + case '\xd6': stralloc_cats(&str, "╓"); break; - case '\xd7': + case '\xd7': stralloc_cats(&str, "╫"); break; - case '\xd8': + case '\xd8': stralloc_cats(&str, "╪"); break; - case '\xd9': + case '\xd9': stralloc_cats(&str, "┘"); break; - case '\xda': + case '\xda': stralloc_cats(&str, "┌"); break; - case '\xdb': + case '\xdb': stralloc_cats(&str, "█"); break; - case '\xdc': + case '\xdc': stralloc_cats(&str, "▄"); break; - case '\xdd': + case '\xdd': stralloc_cats(&str, "▌"); break; - case '\xde': + case '\xde': stralloc_cats(&str, "▐"); break; - case '\xdf': + case '\xdf': stralloc_cats(&str, "▀"); break; - case '\xe0': + case '\xe0': stralloc_cats(&str, "α"); break; - case '\xe1': + case '\xe1': stralloc_cats(&str, "β"); break; - case '\xe2': + case '\xe2': stralloc_cats(&str, "Γ"); break; - case '\xe3': + case '\xe3': stralloc_cats(&str, "π"); break; - case '\xe4': + case '\xe4': stralloc_cats(&str, "Σ"); break; - case '\xe5': + case '\xe5': stralloc_cats(&str, "σ"); break; - case '\xe6': + case '\xe6': stralloc_cats(&str, "µ"); break; - case '\xe7': + case '\xe7': stralloc_cats(&str, "τ"); break; - case '\xe8': + case '\xe8': stralloc_cats(&str, "Φ"); break; - case '\xe9': + case '\xe9': stralloc_cats(&str, "Θ"); break; - case '\xea': + case '\xea': stralloc_cats(&str, "Ω"); break; - case '\xeb': + case '\xeb': stralloc_cats(&str, "δ"); break; - case '\xec': + case '\xec': stralloc_cats(&str, "∞"); break; - case '\xed': + case '\xed': stralloc_cats(&str, "∅"); break; - case '\xee': + case '\xee': stralloc_cats(&str, "∈"); break; - case '\xef': + case '\xef': stralloc_cats(&str, "∩"); break; - case '\xf0': + case '\xf0': stralloc_cats(&str, "≡"); break; - case '\xf1': + case '\xf1': stralloc_cats(&str, "±"); break; - case '\xf2': + case '\xf2': stralloc_cats(&str, "≥"); break; - case '\xf3': + case '\xf3': stralloc_cats(&str, "≤"); break; - case '\xf4': + case '\xf4': stralloc_cats(&str, "⌠"); break; - case '\xf5': + case '\xf5': stralloc_cats(&str, "⌡"); break; - case '\xf6': + case '\xf6': stralloc_cats(&str, "÷"); break; - case '\xf7': + case '\xf7': stralloc_cats(&str, "≈"); break; - case '\xf8': + case '\xf8': stralloc_cats(&str, "°"); break; - case '\xf9': + case '\xf9': stralloc_cats(&str, "∙"); break; - case '\xfa': + case '\xfa': stralloc_cats(&str, "·"); break; - case '\xfb': + case '\xfb': stralloc_cats(&str, "√"); break; - case '\xfc': + case '\xfc': stralloc_cats(&str, "ⁿ"); break; - case '\xfd': + case '\xfd': stralloc_cats(&str, "²"); break; - case '\xfe': - stralloc_cats(&str, "▪"); + case '\xfe': + stralloc_cats(&str, "▪"); break; case ' ': if (isdata) { if (*(p+1) == ' ') { - stralloc_cats(&str, " "); + stralloc_cats(&str, " "); } else { if (p > data && (*(p-1) == ' ' || *(p-1) == '\n')) { stralloc_cats(&str, " "); @@ -541,7 +541,7 @@ static char *www_tag_sanatize(char *data, int isdata) { default: stralloc_append1(&str, *p); break; - } + } } stralloc_0(&str); return str.s; @@ -549,27 +549,27 @@ static char *www_tag_sanatize(char *data, int isdata) { struct www_tag *www_tag_new(char *tag, char *data) { struct www_tag *new_tag = malloz(sizeof(struct www_tag)); - - + + new_tag->attribs = EMPTY_PTR_VECTOR; new_tag->values = EMPTY_PTR_VECTOR; new_tag->children = EMPTY_PTR_VECTOR; - + if (tag == NULL) { new_tag->tag = NULL; - + /* SANATIZE DATA HERE */ new_tag->data = www_tag_sanatize(data, 1); } else { new_tag->tag = strdup(tag); new_tag->data = NULL; - + init_ptr_vector(&new_tag->attribs); init_ptr_vector(&new_tag->values); } - + init_ptr_vector(&new_tag->children); - + return new_tag; } @@ -595,14 +595,14 @@ char *www_tag_destroy(struct www_tag *tag) { struct www_tag *child = ptr_vector_del(&tag->children, 0); www_tag_destroy(child); } - + if (tag->tag != NULL) { ptr_vector_apply(&tag->attribs, free); destroy_ptr_vector(&tag->attribs); ptr_vector_apply(&tag->values, free); destroy_ptr_vector(&tag->values); } - destroy_ptr_vector(&tag->children); + destroy_ptr_vector(&tag->children); } char *www_tag_unwravel(struct www_tag *tag) { @@ -621,14 +621,14 @@ char *www_tag_unwravel(struct www_tag *tag) { stralloc_cats(&thedata, (char *)ptr_vector_get(&child->values, i)); stralloc_append1(&thedata, '\"'); } - - + + stralloc_append1(&thedata, '>'); } char *data = www_tag_unwravel(child); stralloc_cats(&thedata, data); free(data); - + if (child->tag != NULL) { stralloc_cats(&thedata, "tag); @@ -654,17 +654,17 @@ char *www_tag_unwravel(struct www_tag *tag) { ptr_vector_apply(&child->attribs, free); destroy_ptr_vector(&child->attribs); ptr_vector_apply(&child->values, free); - destroy_ptr_vector(&child->values); + destroy_ptr_vector(&child->values); } else { stralloc_cats(&thedata, child->data); - } + } } destroy_ptr_vector(&child->children); - + } stralloc_0(&thedata); - + return thedata.s; } diff --git a/src/www_tree.h b/src/www_tree.h index fbc7f41..11de81c 100644 --- a/src/www_tree.h +++ b/src/www_tree.h @@ -9,7 +9,7 @@ struct www_tag { char *data; struct ptr_vector attribs; struct ptr_vector values; - + struct ptr_vector children; }; From 64ae6556f1455d3d4491162cb41687523823b814 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 11:29:17 +1000 Subject: [PATCH 29/38] add a timeout to qwknetftpc --- utils/qwknet/qwknetftpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py index 736ce5c..0b69045 100644 --- a/utils/qwknet/qwknetftpc.py +++ b/utils/qwknet/qwknetftpc.py @@ -12,7 +12,7 @@ def dostuff(config_file): username = config.get("Main", "Ftp User") password = config.get("Main", "Ftp Password") - ftp = FTP(host) + ftp = FTP(host, timeout=300) ftp.login(username, password) repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP" @@ -46,4 +46,4 @@ if __name__ == "__main__": print("Usage python qwknetftpc.py config.ini") exit(1) - server = dostuff(sys.argv[1]) \ No newline at end of file + server = dostuff(sys.argv[1]) From 99feabb6e5c68b30374e1b7287c4d09461be9e5b Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 12:54:00 +1000 Subject: [PATCH 30/38] Don't clobber old qwk rep files --- utils/qwknet/qwknetftpc.py | 20 +++++++++++++------- utils/qwknet/qwkscan.c | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py index 0b69045..d5bedf5 100644 --- a/utils/qwknet/qwknetftpc.py +++ b/utils/qwknet/qwknetftpc.py @@ -17,14 +17,20 @@ def dostuff(config_file): repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP" - exists = os.path.isfile(repfile) + i = 1 - 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") + 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." + i + i = i + 1 + else: + break qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK" with open(qwkfile, 'wb') as file: diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index 1c063c5..848aca3 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -384,6 +384,8 @@ int main(int argc, char **argv) { 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; @@ -412,6 +414,11 @@ int main(int argc, char **argv) { 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; From 876037e0ac601c3dd2336a1b963aa2dd4d6065b4 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 31 Oct 2018 15:22:27 +1000 Subject: [PATCH 31/38] Fix bug in qwknetftpc and remove debugging output --- utils/qwknet/qwknetftpc.py | 2 +- utils/qwknet/qwktoss.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/qwknet/qwknetftpc.py b/utils/qwknet/qwknetftpc.py index d5bedf5..7a23dae 100644 --- a/utils/qwknet/qwknetftpc.py +++ b/utils/qwknet/qwknetftpc.py @@ -27,7 +27,7 @@ def dostuff(config_file): file.close() os.remove(repfile) print("SENT: " + config.get("Main", "Host") + ".REP") - repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP." + i + repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP." + str(i) i = i + 1 else: break diff --git a/utils/qwknet/qwktoss.c b/utils/qwknet/qwktoss.c index e9eb4de..c84033d 100644 --- a/utils/qwknet/qwktoss.c +++ b/utils/qwknet/qwktoss.c @@ -118,7 +118,6 @@ static char *get_key_value(struct msg_headers_t *header, char *key) { if (header == NULL) return NULL; for (int i=0;iheader_count;i++) { if (strcmp(key, header->headers[i]->key) == 0) { - fprintf(stderr, "%s\n", header->headers[i]->value); return header->headers[i]->value; } } From 18443d247e1035b0beb3763d12b7a239e6d3d8ef Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Thu, 1 Nov 2018 13:55:51 +1000 Subject: [PATCH 32/38] use uuids for qwk message ids --- src/bluewave.c | 8 ++++++-- src/mail_menu.c | 13 ++++++++++--- src/www_msgs.c | 7 +++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/bluewave.c b/src/bluewave.c index cd8a610..62c5878 100644 --- a/src/bluewave.c +++ b/src/bluewave.c @@ -592,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) { @@ -701,7 +702,10 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char JAM_PutSubfield(jsp, &jsf); if (conf.external_address != NULL) { - snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), conf.external_address); + + 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; diff --git a/src/mail_menu.c b/src/mail_menu.c index 5d40487..8b6918b 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -1388,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; @@ -1411,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,7 +1736,9 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno JAM_PutSubfield(jsp, &jsf); if (conf.external_address != NULL) { - snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), conf.external_address); + 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; @@ -2027,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; @@ -2203,7 +2208,9 @@ void post_message(struct user_record *user) { JAM_PutSubfield(jsp, &jsf); if (conf.external_address != NULL) { - snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), conf.external_address); + 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; diff --git a/src/www_msgs.c b/src/www_msgs.c index 62bdeed..5d86a16 100644 --- a/src/www_msgs.c +++ b/src/www_msgs.c @@ -945,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; @@ -956,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; @@ -1086,7 +1087,9 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference, JAM_PutSubfield(jsp, &jsf); if (conf.external_address != NULL) { - snprintf(buffer, sizeof buffer, "<%lx.%s@%s>", generate_msgid(), basename(ma->path), conf.external_address); + 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; From 13dd9353519046574101f4e1fd7105ae538431a3 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 3 Nov 2018 16:55:57 +1000 Subject: [PATCH 33/38] Add other nettype support to lua_glue --- src/lua_glue.c | 102 ++++++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/src/lua_glue.c b/src/lua_glue.c index 509128f..7100451 100644 --- a/src/lua_glue.c +++ b/src/lua_glue.c @@ -407,7 +407,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 +466,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) { From 27f0c26e29d2e129d2220b9460ad462673b3db82 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 3 Nov 2018 17:33:04 +1000 Subject: [PATCH 34/38] add location to lua_glue --- src/lua_glue.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_glue.c b/src/lua_glue.c index 7100451..dfab524 100644 --- a/src/lua_glue.c +++ b/src/lua_glue.c @@ -203,6 +203,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); @@ -644,6 +650,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); From 8b206c25127e5b7157095d72a1eb56be1d720328 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 3 Nov 2018 17:37:06 +1000 Subject: [PATCH 35/38] fix missing include --- src/lua_glue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_glue.c b/src/lua_glue.c index dfab524..901830f 100644 --- a/src/lua_glue.c +++ b/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; From 83c4a41f741dc9c5bb8c963eef7dde8a2fdd28eb Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 4 Nov 2018 12:52:48 +1000 Subject: [PATCH 36/38] Update mnet --- utils/mnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/mnet b/utils/mnet index 619660a..31cd8fc 160000 --- a/utils/mnet +++ b/utils/mnet @@ -1 +1 @@ -Subproject commit 619660a8c675531b432c5b24e0b389e1e4822ff6 +Subproject commit 31cd8fcb781c73c97ac7cc963eed0f8caefbf86b From a9d4afb76d90c6a05f7889ed67553cf7d4848211 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 4 Nov 2018 12:55:07 +1000 Subject: [PATCH 37/38] update mnet --- utils/mnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/mnet b/utils/mnet index 31cd8fc..6dc6b75 160000 --- a/utils/mnet +++ b/utils/mnet @@ -1 +1 @@ -Subproject commit 31cd8fcb781c73c97ac7cc963eed0f8caefbf86b +Subproject commit 6dc6b7559cd0730e44b61447df18761a0fc497f9 From 988151d11ae1f461c21bbc040c1c13e56bbc4f7b Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 4 Nov 2018 17:45:02 +1000 Subject: [PATCH 38/38] qwknet added to main makefile --- src/GNUmakefile.common | 8 ++++++-- utils/qwknet/Makefile | 6 +++--- utils/qwknet/qwkscan.c | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/GNUmakefile.common b/src/GNUmakefile.common index c51e08a..748ace6 100644 --- a/src/GNUmakefile.common +++ b/src/GNUmakefile.common @@ -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} @@ -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 diff --git a/utils/qwknet/Makefile b/utils/qwknet/Makefile index 74b2eb9..4d06f48 100644 --- a/utils/qwknet/Makefile +++ b/utils/qwknet/Makefile @@ -1,5 +1,5 @@ CC=cc -CFLAGS=-I/usr/local/include -ggdb +CFLAGS=-I/usr/local/include DEPS = qwktoss.c qwkscan.c JAMLIB = ../../deps/jamlib/jamlib.a OBJ = qwktoss.o ../../src/inih/ini.o @@ -11,7 +11,7 @@ all: qwktoss qwkscan $(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 @@ -22,4 +22,4 @@ qwkscan: $(SOBJ) $(JAMLIB) .PHONY: clean clean: - rm -f $(OBJ) qwktoss \ No newline at end of file + rm -f $(OBJ) $(SOBJ) qwktoss qwkscan diff --git a/utils/qwknet/qwkscan.c b/utils/qwknet/qwkscan.c index 848aca3..4861c56 100644 --- a/utils/qwknet/qwkscan.c +++ b/utils/qwknet/qwkscan.c @@ -311,7 +311,7 @@ int export_messages(int baseno, char *basefilename, int qwkidx) { snprintf(buffer, PATH_MAX, "%s/HEADERS.DAT", temp_dir); hdrptr = fopen(buffer, "a"); - fprintf(hdrptr, "[%x]\n", offset); + fprintf(hdrptr, "[%lx]\n", offset); if (msgid != NULL) { fprintf(hdrptr, "Message-ID: %s\n", msgid); free(msgid); @@ -452,4 +452,4 @@ int main(int argc, char **argv) { } } recursive_delete(temp_dir); -} \ No newline at end of file +}