This commit is contained in:
Andrew Pamment 2018-05-22 21:02:22 +10:00
parent e7a7133af2
commit 42fdc30972
26 changed files with 1048 additions and 75 deletions

9
.gitignore vendored
View File

@ -83,3 +83,12 @@ utils/reset_pass/reset_pass
last10v2.dat last10v2.dat
utils/filecenter/filecenter utils/filecenter/filecenter
utils/dosbox_shim/shim utils/dosbox_shim/shim
deps/libuuid/Makefile
deps/libuuid/config.h
deps/libuuid/libtool
deps/libuuid/libuuid.la
deps/libuuid/stamp-h1
deps/libuuid/uuid.pc
utils/mnetscan/mnetscan
mail.out
utils/mnettoss/mnettoss

View File

@ -19,6 +19,10 @@ LINE 111 MODIFIED
OLDSTRING: "\e[1;32mAttribs : \e[1;37m%s\r\n" OLDSTRING: "\e[1;32mAttribs : \e[1;37m%s\r\n"
NEWSTRING: "\e[1;32mAttribs : \e[1;37m%s \e[1;31m%s\r\n" NEWSTRING: "\e[1;32mAttribs : \e[1;37m%s \e[1;31m%s\r\n"
LINE 289 NEW
OLDSTRING: (NONE)
NEWSTRING: "\e[2J\e[1;1H\e[1;32mFrom : \e[1;37m%s (@%d)\r\n"
Changes from v0.9-alpha -> v0.10-alpha Changes from v0.9-alpha -> v0.10-alpha
-------------------------------------------------------------- --------------------------------------------------------------

4
deps/libuuid/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.deps
.libs
*.lo

View File

@ -286,3 +286,4 @@ Read Now ? (Y / N):
\r\n\r\n\e[1;37mEnter a title:\e[0m \r\n\r\n\e[1;37mEnter a title:\e[0m
\e[1;30m[\e[1;34;44m%5d\e[1;30;40m]\e[1;31m!\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n \e[1;30m[\e[1;34;44m%5d\e[1;30;40m]\e[1;31m!\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[1;30m[\e[1;34m%5d\e[1;30m]\e[1;31m!\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n \e[1;30m[\e[1;34m%5d\e[1;30m]\e[1;31m!\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
\e[2J\e[1;1H\e[1;32mFrom : \e[1;37m%s (@%d)\r\n

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -29,11 +30,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${JSMN} magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_blog.o www_files.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_blog.o www_files.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD) $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -29,12 +30,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_blog.o www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_blog.o www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD) $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD)
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -29,11 +30,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
magiedit: $(ODOORS) magiedit: $(ODOORS)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD) $(CC) -o ../magicka $^ $(CFLAGS) -R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
magiedit: $(ODOORS) magiedit: $(ODOORS)

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -29,11 +30,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv
magiedit: $(ODOORS) magiedit: $(ODOORS)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD) $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lutil -lm -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
magiedit: $(ODOORS) magiedit: $(ODOORS)

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
@ -31,10 +32,14 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv $(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv $(MICROHTTPD) $(CC) -o ../magicka $^ $(CFLAGS) -L/opt/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -liconv $(MICROHTTPD)
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -7,6 +7,7 @@ LUA = ../deps/lua/liblua.a
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
@ -29,12 +30,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} magicka: $(OBJ) ${LUA} ${ZMODEM} ${JAMLIB} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lnsl -lsocket $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh -lnsl -lsocket
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -9,6 +9,7 @@ MICROHTTPD=-lmicrohttpd
ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a CDK = ../deps/cdk-5-20161210/libcdk.a
UUID = ../deps/libuuid/.libs/libuuid.a
all: magicka magimail magiedit ticproc mgpost magichat filecenter magiftpd reset_pass all: magicka magimail magiedit ticproc mgpost magichat filecenter magiftpd reset_pass
@ -34,11 +35,15 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE) cd ../deps/cdk-5.0-20161210/ && $(MAKE)
$(UUID):
cd ../deps/libuuid/ && ./configure
cd ../deps/libuuid/ && $(MAKE)
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o www_files.o www_blog.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o www_files.o www_blog.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o
%.o: %.c $(DEPS) %.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} magicka: $(OBJ) ${LUA} ${JAMLIB} ${ZMODEM} ${B64} ${JSMN} ${UUID}
$(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD) -lnsl -lsocket $(CC) -o ../magicka $^ $(CFLAGS) -L/usr/local/lib -lsqlite3 -lm -ldl -lssl -lcrypto -lssh $(MICROHTTPD) -lnsl -lsocket
magimail: $(JAMLIB) magimail: $(JAMLIB)

View File

@ -17,6 +17,7 @@
#define NETWORK_FIDO 1 #define NETWORK_FIDO 1
#define NETWORK_WWIV 2 #define NETWORK_WWIV 2
#define NETWORK_MAGI 3
#define TYPE_LOCAL_AREA 0 #define TYPE_LOCAL_AREA 0
#define TYPE_NETMAIL_AREA 1 #define TYPE_NETMAIL_AREA 1
@ -80,6 +81,7 @@ struct mail_conference {
struct mail_area **mail_areas; struct mail_area **mail_areas;
struct fido_addr *fidoaddr; struct fido_addr *fidoaddr;
int wwivnode; int wwivnode;
int maginode;
}; };
struct file_sub { struct file_sub {

View File

@ -8,6 +8,7 @@
#include "bluewave.h" #include "bluewave.h"
#include "jamlib/jam.h" #include "jamlib/jam.h"
#include "bbs.h" #include "bbs.h"
#include "libuuid/uuid.h"
extern struct bbs_config conf; extern struct bbs_config conf;
extern struct user_record *gUser; extern struct user_record *gUser;
@ -573,6 +574,7 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
s_JamSubfield jsf; s_JamSubfield jsf;
int z; int z;
char buffer[256]; char buffer[256];
uuid_t magi_msgid;
jb = open_jam_base(conf.mail_conferences[confr]->mail_areas[area]->path); jb = open_jam_base(conf.mail_conferences[confr]->mail_areas[area]->path);
if (!jb) { if (!jb) {
@ -623,6 +625,8 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
if (conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_ECHOMAIL_AREA || conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_NEWSGROUP_AREA) { if (conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_ECHOMAIL_AREA || conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_NEWSGROUP_AREA) {
jmh.Attribute |= JAM_MSG_TYPEECHO; jmh.Attribute |= JAM_MSG_TYPEECHO;
if (conf.mail_conferences[confr]->nettype == NETWORK_FIDO) {
if (conf.mail_conferences[confr]->fidoaddr->point) { if (conf.mail_conferences[confr]->fidoaddr->point) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[confr]->fidoaddr->zone, sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[confr]->fidoaddr->zone,
conf.mail_conferences[confr]->fidoaddr->net, conf.mail_conferences[confr]->fidoaddr->net,
@ -651,8 +655,26 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
jsf.Buffer = (char *)buffer; jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
} else if (conf.mail_conferences[confr]->nettype == NETWORK_MAGI) {
sprintf(buffer, "%d", conf.mail_conferences[confr]->maginode);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
} else if (conf.mail_conferences[confr]->mail_areas[confr]->type == TYPE_NETMAIL_AREA) {
uuid_generate(magi_msgid);
uuid_unparse_lower(magi_msgid, buffer);
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 (conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_NETMAIL_AREA && conf.mail_conferences[confr]->nettype == NETWORK_FIDO) {
jmh.Attribute |= JAM_MSG_TYPENET; jmh.Attribute |= JAM_MSG_TYPENET;
jmh.Attribute |= JAM_MSG_PRIVATE; jmh.Attribute |= JAM_MSG_PRIVATE;
@ -1013,8 +1035,10 @@ void bwave_upload_reply() {
conf.mail_conferences[confr]->fidoaddr->node, conf.mail_conferences[confr]->fidoaddr->node,
conf.mail_conferences[confr]->fidoaddr->point); conf.mail_conferences[confr]->fidoaddr->point);
} }
} else if (conf.mail_conferences[confr]->nettype == NETWORK_MAGI) {
snprintf(originlinebuffer, 256, "\r--- %s\r * Origin: %s (@%d)\r", upl_hdr.reader_tear, tagline, conf.mail_conferences[confr]->maginode);
} else { } else {
snprintf(originlinebuffer, 256, "\r--- %s\r * Origin: %s \r", upl_hdr.reader_tear, tagline); snprintf(originlinebuffer, 256, "\r");
} }
if (stat(msgbuffer, &s) != 0) { if (stat(msgbuffer, &s) != 0) {

View File

@ -13,6 +13,8 @@
#include "lua/lua.h" #include "lua/lua.h"
#include "lua/lualib.h" #include "lua/lualib.h"
#include "lua/lauxlib.h" #include "lua/lauxlib.h"
#include "libuuid/uuid.h"
#ifdef __sun #ifdef __sun
#include "os/sunos.h" #include "os/sunos.h"
#endif #endif
@ -140,6 +142,7 @@ int msg_is_to(struct user_record *user, char *addressed_to, char *address, int t
char *myname; char *myname;
struct fido_addr *dest; struct fido_addr *dest;
int j; int j;
int magi_dest;
if (rn) { if (rn) {
myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
sprintf(myname, "%s %s", user->firstname, user->lastname); sprintf(myname, "%s %s", user->firstname, user->lastname);
@ -161,6 +164,16 @@ int msg_is_to(struct user_record *user, char *addressed_to, char *address, int t
} }
free(myname); free(myname);
return 0; return 0;
} else if (type == NETWORK_MAGI && address != NULL) {
if (strcasecmp(myname, addressed_to) == 0) {
magi_dest = atoi(address);
if (magi_dest == conf.mail_conferences[msgconf]->maginode) {
free(myname);
return 1;
}
}
free(myname);
return 0;
} else { } else {
if (strcasecmp(myname, addressed_to) == 0) { if (strcasecmp(myname, addressed_to) == 0) {
free(myname); free(myname);
@ -175,13 +188,15 @@ int msg_is_from(struct user_record *user, char *addressed_from, char *address, i
char *myname; char *myname;
struct fido_addr *orig; struct fido_addr *orig;
int j; int j;
int magi_orig;
if (rn) { if (rn) {
myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2); myname = (char *)malloc(strlen(user->firstname) + strlen(user->lastname) + 2);
sprintf(myname, "%s %s", user->firstname, user->lastname); sprintf(myname, "%s %s", user->firstname, user->lastname);
} else { } else {
myname = strdup(user->loginname); myname = strdup(user->loginname);
} }
if (type == NETWORK_FIDO) { if (type == NETWORK_FIDO && address != NULL) {
if (strcasecmp(myname, addressed_from) == 0) { if (strcasecmp(myname, addressed_from) == 0) {
orig = parse_fido_addr(address); orig = parse_fido_addr(address);
if (conf.mail_conferences[msgconf]->fidoaddr->zone == orig->zone && if (conf.mail_conferences[msgconf]->fidoaddr->zone == orig->zone &&
@ -196,6 +211,16 @@ int msg_is_from(struct user_record *user, char *addressed_from, char *address, i
} }
free(myname); free(myname);
return 0; return 0;
} else if (type == NETWORK_MAGI && address != NULL) {
if (strcasecmp(myname, addressed_from) == 0) {
magi_orig = atoi(address);
if (magi_orig == conf.mail_conferences[msgconf]->maginode) {
free(myname);
return 1;
}
}
free(myname);
return 0;
} else { } else {
if (strcasecmp(myname, addressed_from) == 0) { if (strcasecmp(myname, addressed_from) == 0) {
free(myname); free(myname);
@ -528,8 +553,10 @@ char *external_editor(struct user_record *user, char *to, char *from, char *quot
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} }
} else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI && !email) {
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (@%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, conf.mail_conferences[user->cur_mail_conf]->maginode);
} else { } else {
snprintf(buffer, 256, "\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, 256, "\r");
} }
if (user->autosig) { if (user->autosig) {
body2 = (char *)malloc(totlen + 3 + strlen(buffer) + strlen(user->signature)); body2 = (char *)malloc(totlen + 3 + strlen(buffer) + strlen(user->signature));
@ -662,8 +689,10 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node, conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point); conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} }
} else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI && !email) {
snprintf(buffer, 256, "\r--- MagickaBBS v%d.%d%s (%s/%s)\r * Origin: %s (@%d)\r", VERSION_MAJOR, VERSION_MINOR, VERSION_STR, name.sysname, name.machine, tagline, conf.mail_conferences[user->cur_mail_conf]->maginode);
} else { } else {
snprintf(buffer, 256, "\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, 256, "\r");
} }
if (user->autosig) { if (user->autosig) {
size += 3; size += 3;
@ -1525,6 +1554,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
int should_break; int should_break;
int position; int position;
int y; int y;
uuid_t magi_msgid;
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
@ -1549,6 +1579,8 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
from_addr = parse_fido_addr(msghs->msgs[mailno]->oaddress); from_addr = parse_fido_addr(msghs->msgs[mailno]->oaddress);
s_printf(get_string(105), msghs->msgs[mailno]->from, from_addr->zone, from_addr->net, from_addr->node, from_addr->point); s_printf(get_string(105), msghs->msgs[mailno]->from, from_addr->zone, from_addr->net, from_addr->node, from_addr->point);
free(from_addr); free(from_addr);
} else if (msghs->msgs[mailno]->oaddress != NULL && conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI) {
s_printf(get_string(288), msghs->msgs[mailno]->from, atoi(msghs->msgs[mailno]->oaddress));
} else { } else {
s_printf(get_string(106), msghs->msgs[mailno]->from); s_printf(get_string(106), msghs->msgs[mailno]->from);
} }
@ -1806,8 +1838,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
if (msghs->msgs[mailno]->msgid != NULL) { if (msghs->msgs[mailno]->msgid != NULL) {
sprintf(buffer, "%s", msghs->msgs[mailno]->msgid); sprintf(buffer, "%s", msghs->msgs[mailno]->msgid);
}
jsf.LoID = JAMSFLD_REPLYID; jsf.LoID = JAMSFLD_REPLYID;
jsf.HiID = 0; jsf.HiID = 0;
jsf.DatLen = strlen(buffer); jsf.DatLen = strlen(buffer);
@ -1815,6 +1845,34 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer));
} }
} else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI) {
sprintf(buffer, "%d", conf.mail_conferences[user->cur_mail_conf]->maginode);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
uuid_generate(magi_msgid);
uuid_unparse_lower(magi_msgid, buffer);
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) {
sprintf(buffer, "%s", msghs->msgs[mailno]->msgid);
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 (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { } else if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {
jmh.Attribute |= JAM_MSG_TYPENET; jmh.Attribute |= JAM_MSG_TYPENET;
jmh.Attribute |= JAM_MSG_PRIVATE; jmh.Attribute |= JAM_MSG_PRIVATE;
@ -1871,8 +1929,6 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
if (msghs->msgs[mailno]->msgid != NULL) { if (msghs->msgs[mailno]->msgid != NULL) {
sprintf(buffer, "%s", msghs->msgs[mailno]->msgid); sprintf(buffer, "%s", msghs->msgs[mailno]->msgid);
}
jsf.LoID = JAMSFLD_REPLYID; jsf.LoID = JAMSFLD_REPLYID;
jsf.HiID = 0; jsf.HiID = 0;
jsf.DatLen = strlen(buffer); jsf.DatLen = strlen(buffer);
@ -1881,6 +1937,7 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.ReplyCRC = JAM_Crc32(buffer, strlen(buffer));
} }
} }
}
while (1) { while (1) {
z = JAM_LockMB(jb, 100); z = JAM_LockMB(jb, 100);
@ -2108,6 +2165,7 @@ void post_message(struct user_record *user) {
int z; int z;
int sem_fd; int sem_fd;
char *bbsname; char *bbsname;
uuid_t magi_msgid;
s_JamBase *jb; s_JamBase *jb;
s_JamMsgHeader jmh; s_JamMsgHeader jmh;
@ -2128,14 +2186,7 @@ void post_message(struct user_record *user) {
if (strlen(buffer) == 0) { if (strlen(buffer) == 0) {
strcpy(buffer, "ALL"); strcpy(buffer, "ALL");
} }
/*
if (conf.mail_conferences[user->cur_mail_conf]->networked == 0 && strcasecmp(buffer, "ALL") != 0) {
if (check_user(buffer)) {
s_printf(get_string(55));
return;
}
}
*/
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {
s_printf(get_string(121)); s_printf(get_string(121));
s_readstring(buffer2, 32); s_readstring(buffer2, 32);
@ -2257,6 +2308,25 @@ void post_message(struct user_record *user) {
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
} else if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_MAGI) {
sprintf(buffer, "%d", conf.mail_conferences[user->cur_mail_conf]->maginode);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
uuid_generate(magi_msgid);
uuid_unparse_lower(magi_msgid, buffer);
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 } else
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {

View File

@ -335,11 +335,15 @@ static int mail_area_handler(void* user, const char* section, const char* name,
if (strcasecmp(name, "type") == 0) { if (strcasecmp(name, "type") == 0) {
if (strcasecmp(value, "fido") == 0) { if (strcasecmp(value, "fido") == 0) {
mc->nettype = NETWORK_FIDO; mc->nettype = NETWORK_FIDO;
} else if (strcasecmp(value, "magi") == 0) {
mc->nettype = NETWORK_MAGI;
} }
} else if (strcasecmp(name, "fido node") == 0) { } else if (strcasecmp(name, "fido node") == 0) {
mc->fidoaddr = parse_fido_addr(value); mc->fidoaddr = parse_fido_addr(value);
} else if (strcasecmp(name, "domain") == 0) { } else if (strcasecmp(name, "domain") == 0) {
mc->domain = strdup(value); mc->domain = strdup(value);
} else if (strcasecmp(name, "magi node") == 0) {
mc->maginode = atoi(value);
} }
} else { } else {
// check if it's partially filled in // check if it's partially filled in

View File

@ -7,6 +7,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "bbs.h" #include "bbs.h"
#include "jamlib/jam.h" #include "jamlib/jam.h"
#include "libuuid/uuid.h"
#define IN 0 #define IN 0
#define OUT 1 #define OUT 1
@ -862,6 +863,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
struct utsname name; struct utsname name;
int pos; int pos;
char *body3; char *body3;
uuid_t magi_msgid;
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) { if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
return 0; return 0;
@ -880,18 +882,10 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
jmh.Attribute |= JAM_MSG_LOCAL; jmh.Attribute |= JAM_MSG_LOCAL;
if (conf.mail_conferences[conference]->realnames == 0) { if (conf.mail_conferences[conference]->realnames == 0) {
if (conf.mail_conferences[conference]->nettype == NETWORK_WWIV) {
sprintf(buffer, "%s #%d @%d", user->loginname, user->id, conf.mail_conferences[conference]->wwivnode);
} else {
strcpy(buffer, user->loginname); strcpy(buffer, user->loginname);
}
} else {
if (conf.mail_conferences[conference]->nettype == NETWORK_WWIV) {
sprintf(buffer, "%s #%d @%d (%s)", user->loginname, user->id, conf.mail_conferences[conference]->wwivnode, user->firstname);
} else { } else {
sprintf(buffer, "%s %s", user->firstname, user->lastname); sprintf(buffer, "%s %s", user->firstname, user->lastname);
} }
}
jsp = JAM_NewSubPacket(); jsp = JAM_NewSubPacket();
jsf.LoID = JAMSFLD_SENDERNAME; jsf.LoID = JAMSFLD_SENDERNAME;
@ -945,6 +939,32 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer)); jmh.MsgIdCRC = JAM_Crc32(buffer, strlen(buffer));
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(buffer, strlen(replyid));
}
} else if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
sprintf(buffer, "%d", conf.mail_conferences[conference]->maginode);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
uuid_generate(magi_msgid);
uuid_unparse_lower(magi_msgid, buffer);
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));
if (strcasecmp(replyid, "NULL") != 0) { if (strcasecmp(replyid, "NULL") != 0) {
jsf.LoID = JAMSFLD_REPLYID; jsf.LoID = JAMSFLD_REPLYID;
jsf.HiID = 0; jsf.HiID = 0;
@ -992,8 +1012,10 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
conf.mail_conferences[conference]->fidoaddr->node, conf.mail_conferences[conference]->fidoaddr->node,
conf.mail_conferences[conference]->fidoaddr->point); conf.mail_conferences[conference]->fidoaddr->point);
} }
} else if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
snprintf(buffer, 256, "\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, conf.mail_conferences[conference]->maginode);
} else { } else {
snprintf(buffer, 256, "\r\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, 256, "\r");
} }
body2 = www_wordwrap(body, 73); body2 = www_wordwrap(body, 73);
if (body2 == NULL) { if (body2 == NULL) {

21
utils/mnetscan/Makefile Normal file
View File

@ -0,0 +1,21 @@
CC=cc
CFLAGS=-I/usr/local/include -I../../deps/
DEPS = mnetscan.c
JAMLIB = ../../deps/jamlib/jamlib.a
OBJ = mnetscan.o
all: mnetscan
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(JAMLIB):
cd ../../deps/jamlib && make -f Makefile.linux
mnetscan: $(OBJ) $(JAMLIB)
$(CC) -o mnetscan $^ $(CFLAGS) -L/usr/local/lib
.PHONY: clean
clean:
rm -f $(OBJ) mnetscan

View File

@ -0,0 +1,5 @@
INDIR /home/andrew/MagickaBBS/mnet/out/2
OUTDIR /home/andrew/MagickaBBS/mnet/out
MSGAREA 1, /home/andrew/MagickaBBS/msgs/mnet_general, 2, 3, 4

335
utils/mnetscan/mnetscan.c Normal file
View File

@ -0,0 +1,335 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <unistd.h>
#include "jamlib/jam.h"
char *baseoutdir = NULL;
struct msgarea_t {
int id;
char *basedir;
int *links;
int link_count;
};
struct msg_t {
int area;
char from[32];
char to[32];
char subject[64];
uint32_t timedate;
int oaddr;
int daddr;
char reply[36];
} __attribute__ ((packed));
struct msgarea_t **areas;
int area_count;
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;
}
size_t trimwhitespace(char *out, size_t len, const char *str) {
if(len == 0)
return 0;
const char *end;
size_t out_size;
// Trim leading space
while(isspace((unsigned char)*str)) str++;
if(*str == 0) {
*out = 0;
return 1;
}
// Trim trailing space
end = str + strlen(str) - 1;
while(end > str && isspace((unsigned char)*end)) end--;
end++;
// Set output size to minimum of trimmed string length and buffer size minus 1
out_size = (end - str) < len-1 ? (end - str) : len-1;
// Copy trimmed string and add null terminator
memcpy(out, str, out_size);
out[out_size] = 0;
return out_size;
}
int parse_config_file(char *filename) {
FILE *fptr;
char buffer[256];
char bufferw[256];
char *ptr;
struct msgarea_t *newarea;
area_count = 0;
fptr = fopen(filename, "r");
if (!fptr) {
return 0;
}
fgets(buffer, 256, fptr);
while (!feof(fptr)) {
if (buffer[0] != ';') {
if (buffer[strlen(buffer) - 1] == '\n'){
buffer[strlen(buffer) - 1] = '\0';
if (strncasecmp(buffer, "OUTDIR", 6) == 0) {
trimwhitespace(bufferw, 256, &buffer[7]);
baseoutdir = strdup(bufferw);
} else if (strncasecmp(buffer, "MSGAREA", 7) == 0) {
newarea = NULL;
ptr = strtok(&buffer[8], ",");
if (ptr != NULL) {
newarea = (struct msgarea_t *)malloc(sizeof(struct msgarea_t));
trimwhitespace(bufferw, 256, ptr);
newarea->id = atoi(bufferw);
newarea->link_count = 0;
ptr = strtok(NULL, ",");
if (ptr != NULL) {
trimwhitespace(bufferw, 256, ptr);
newarea->basedir = strdup(bufferw);
ptr = strtok(NULL, ",");
while (ptr != NULL) {
trimwhitespace(bufferw, 256, ptr);
if (newarea->link_count == 0) {
newarea->links = (int *)malloc(sizeof(int));
} else {
newarea->links = (int *)realloc(newarea->links, sizeof(int) * (newarea->link_count + 1));
}
newarea->links[newarea->link_count] = atoi(bufferw);
newarea->link_count++;
ptr = strtok(NULL, ",");
}
}
}
if (newarea != NULL) {
if (area_count == 0) {
areas = (struct msgarea_t **)malloc(sizeof(struct msgarea_t *));
} else {
areas = (struct msgarea_t **)realloc(areas, sizeof(struct msgarea_t *) * (area_count + 1));
}
areas[area_count] = newarea;
area_count++;
}
}
} else {
fclose(fptr);
return 0;
}
}
fgets(buffer, 256, fptr);
}
fclose(fptr);
return 1;
}
int export_messages(int area) {
s_JamBase *jb;
s_JamBaseHeader jbh;
s_JamMsgHeader jmh;
s_JamSubPacket* jsp;
FILE *fptr;
char buffer[PATH_MAX];
int i;
int z;
int len;
int n;
int scanned = 0;
struct msg_t msg;
char msgid[37];
char *body;
struct stat st;
jb = open_jam_base(areas[area]->basedir);
if (!jb) {
return 0;
}
JAM_ReadMBHeader(jb, &jbh);
if (jbh.ActiveMsgs > 0) {
for (i=0;i<jbh.ActiveMsgs;i++) {
memset(&msg, 0, sizeof(struct msg_t));
memset(&jmh, 0, sizeof(s_JamMsgHeader));
z = JAM_ReadMsgHeader(jb, i, &jmh, &jsp);
if (z != 0) {
continue;
}
if (jmh.Attribute & JAM_MSG_DELETED) {
JAM_DelSubPacket(jsp);
continue;
}
if ((jmh.Attribute & JAM_MSG_SENT) || !(jmh.Attribute & JAM_MSG_LOCAL)) {
JAM_DelSubPacket(jsp);
continue;
} else {
for (z=0;z<jsp->NumFields;z++) {
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
if (jsp->Fields[z]->DatLen > 63) {
len = 64;
} else {
len = jsp->Fields[z]->DatLen;
}
memcpy(msg.subject, jsp->Fields[z]->Buffer, len);
}
if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
if (jsp->Fields[z]->DatLen > 61) {
len = 32;
} else {
len = jsp->Fields[z]->DatLen;
}
memcpy(msg.from, jsp->Fields[z]->Buffer, len);
}
if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
if (jsp->Fields[z]->DatLen > 61) {
len = 32;
} else {
len = jsp->Fields[z]->DatLen;
}
memcpy(msg.to, jsp->Fields[z]->Buffer, len);
}
if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
msg.daddr = atoi(jsp->Fields[z]->Buffer);
}
if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
msg.oaddr = atoi(jsp->Fields[z]->Buffer);
}
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
memset(msgid, 0, 37);
memcpy(msgid, jsp->Fields[z]->Buffer, (jsp->Fields[z]->DatLen > 36 ? 36 : jsp->Fields[z]->DatLen));
}
if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
memcpy(msg.reply, jsp->Fields[z]->Buffer, (jsp->Fields[z]->DatLen > 36 ? 36 : jsp->Fields[z]->DatLen));
}
}
msg.timedate = jmh.DateWritten;
body = (char *)malloc(jmh.TxtLen + 1);
memset(body, 0, jmh.TxtLen + 1);
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
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 {
free(body);
JAM_DelSubPacket(jsp);
JAM_CloseMB(jb);
free(jb);
fprintf(stderr, "Error locking JAM base!\n");
return scanned;
}
}
n =JAM_ChangeMsgHeader(jb, i, &jmh);
if (n != 0) {
fprintf(stderr, "Error updating message header %d %d\n", n, JAM_Errno(jb));
}
JAM_UnlockMB(jb);
JAM_DelSubPacket(jsp);
msg.area = areas[area]->id;
for (n = 0; n < areas[area]->link_count; n++) {
snprintf(buffer, PATH_MAX, "%s/%d/", baseoutdir, areas[area]->links[n]);
if (stat(buffer, &st) != 0) {
if (mkdir(buffer, 0755) != 0) {
fprintf(stderr, "Error making directory %s\n", buffer);
continue;
}
}
snprintf(buffer, PATH_MAX, "%s/%d/%s.message", baseoutdir, areas[area]->links[n], msgid);
fptr = fopen(buffer, "wb");
if (fptr == NULL) {
fprintf(stderr, "Error creating file %s\n", buffer);
continue;
}
fwrite(&msg, sizeof(struct msg_t), 1, fptr);
fwrite(body, strlen(body), 1, fptr);
fclose(fptr);
}
scanned++;
}
}
}
JAM_CloseMB(jb);
free(jb);
return scanned;
}
int main(int argc, char **argv) {
int i;
int l;
if (argc < 2) {
fprintf(stderr, "Usage ./mnetscan mnet.cfg\n");
return -1;
}
if (!parse_config_file(argv[1])) {
fprintf(stderr, "Error parsing config file: %s\n", argv[1]);
return -1;
}
if (baseoutdir == NULL) {
fprintf(stderr, "OUTDIR must be defined\n");
return -1;
}
printf("Out Base Dir: %s\n", baseoutdir);
for (i=0;i<area_count;i++) {
printf("MsgArea: %d\n", areas[i]->id);
printf(" - path %s\n", areas[i]->basedir);
printf(" - links: ");
for (l=0;l<areas[i]->link_count;l++) {
printf("%d, ", areas[i]->links[l]);
}
printf("\n");
printf("\nExported %d messages\n", export_messages(i));
}
return 0;
}

21
utils/mnettoss/Makefile Normal file
View File

@ -0,0 +1,21 @@
CC=cc
CFLAGS=-I/usr/local/include -I../../deps/
DEPS = mnettoss.c
JAMLIB = ../../deps/jamlib/jamlib.a
OBJ = mnettoss.o
all: mnettoss
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(JAMLIB):
cd ../../deps/jamlib && make -f Makefile.linux
mnettoss: $(OBJ) $(JAMLIB)
$(CC) -o mnettoss $^ $(CFLAGS) -L/usr/local/lib
.PHONY: clean
clean:
rm -f $(OBJ) mnettoss

393
utils/mnettoss/mnettoss.c Normal file
View File

@ -0,0 +1,393 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include "jamlib/jam.h"
char *baseindir = NULL;
struct msgarea_t {
int id;
char *basedir;
int *links;
int link_count;
};
struct msg_t {
int area;
char from[32];
char to[32];
char subject[64];
uint32_t timedate;
int oaddr;
int daddr;
char reply[36];
} __attribute__ ((packed));
struct msgarea_t **areas;
int area_count;
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;
}
size_t trimwhitespace(char *out, size_t len, const char *str) {
if(len == 0)
return 0;
const char *end;
size_t out_size;
// Trim leading space
while(isspace((unsigned char)*str)) str++;
if(*str == 0) {
*out = 0;
return 1;
}
// Trim trailing space
end = str + strlen(str) - 1;
while(end > str && isspace((unsigned char)*end)) end--;
end++;
// Set output size to minimum of trimmed string length and buffer size minus 1
out_size = (end - str) < len-1 ? (end - str) : len-1;
// Copy trimmed string and add null terminator
memcpy(out, str, out_size);
out[out_size] = 0;
return out_size;
}
int parse_config_file(char *filename) {
FILE *fptr;
char buffer[256];
char bufferw[256];
char *ptr;
struct msgarea_t *newarea;
area_count = 0;
fptr = fopen(filename, "r");
if (!fptr) {
return 0;
}
fgets(buffer, 256, fptr);
while (!feof(fptr)) {
if (buffer[0] != ';') {
if (buffer[strlen(buffer) - 1] == '\n'){
buffer[strlen(buffer) - 1] = '\0';
if (strncasecmp(buffer, "INDIR", 5) == 0) {
trimwhitespace(bufferw, 256, &buffer[6]);
baseindir = strdup(bufferw);
} else if (strncasecmp(buffer, "MSGAREA", 7) == 0) {
newarea = NULL;
ptr = strtok(&buffer[8], ",");
if (ptr != NULL) {
newarea = (struct msgarea_t *)malloc(sizeof(struct msgarea_t));
trimwhitespace(bufferw, 256, ptr);
newarea->id = atoi(bufferw);
newarea->link_count = 0;
ptr = strtok(NULL, ",");
if (ptr != NULL) {
trimwhitespace(bufferw, 256, ptr);
newarea->basedir = strdup(bufferw);
ptr = strtok(NULL, ",");
while (ptr != NULL) {
trimwhitespace(bufferw, 256, ptr);
if (newarea->link_count == 0) {
newarea->links = (int *)malloc(sizeof(int));
} else {
newarea->links = (int *)realloc(newarea->links, sizeof(int) * (newarea->link_count + 1));
}
newarea->links[newarea->link_count] = atoi(bufferw);
newarea->link_count++;
ptr = strtok(NULL, ",");
}
}
}
if (newarea != NULL) {
if (area_count == 0) {
areas = (struct msgarea_t **)malloc(sizeof(struct msgarea_t *));
} else {
areas = (struct msgarea_t **)realloc(areas, sizeof(struct msgarea_t *) * (area_count + 1));
}
areas[area_count] = newarea;
area_count++;
}
}
} else {
fclose(fptr);
return 0;
}
}
fgets(buffer, 256, fptr);
}
fclose(fptr);
return 1;
}
int isdupe(struct msg_t *msg, char *uuid) {
s_JamBase *jb;
s_JamBaseHeader jbh;
s_JamMsgHeader jmh;
s_JamSubPacket* jsp;
int areaid;
int i;
int z;
for (i=0;i<area_count;i++) {
if (msg->area == areas[i]->id) {
areaid = i;
break;
}
}
jb = open_jam_base(areas[areaid]->basedir);
if (!jb) {
return -1;
}
JAM_ReadMBHeader(jb, &jbh);
if (jbh.ActiveMsgs > 0) {
for (i=0;i<jbh.ActiveMsgs;i++) {
memset(&jmh, 0, sizeof(s_JamMsgHeader));
z = JAM_ReadMsgHeader(jb, i, &jmh, &jsp);
if (z != 0) {
continue;
}
for (z=0;z<jsp->NumFields;z++) {
if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
if (strncasecmp(uuid, jsp->Fields[z]->Buffer, 36) == 0) {
JAM_DelSubPacket(jsp);
JAM_CloseMB(jb);
free(jb);
return 1;
}
}
}
}
}
JAM_CloseMB(jb);
free(jb);
return 0;
}
int import(char *filename) {
FILE *fptr;
char buffer[PATH_MAX];
char uuid[37];
struct msg_t msg;
int ret;
int areaid;
struct stat st;
int z;
int i;
char *body;
s_JamBase *jb;
s_JamBaseHeader jbh;
s_JamMsgHeader jmh;
s_JamSubPacket* jsp;
s_JamSubfield jsf;
snprintf(buffer, PATH_MAX, "%s/%s", baseindir, filename);
strncpy(uuid, filename, 36);
uuid[36] = '\0';
if (stat(buffer, &st) != 0) {
return 0;
}
fptr = fopen(buffer, "rb");
if (!fptr) {
return 0;
}
fread(&msg, sizeof(struct msg_t), 1, fptr);
ret = isdupe(&msg, uuid);
if (ret == -1) {
fclose(fptr);
return 0;
} else if (ret == 1) {
fclose(fptr);
return 1;
}
body = malloc(st.st_size - sizeof(struct msg_t) + 1);
memset(body, 0, st.st_size - sizeof(struct msg_t) + 1);
fread(body, st.st_size - sizeof(struct msg_t), 1, fptr);
fclose(fptr);
JAM_ClearMsgHeader(&jmh);
jmh.DateWritten = msg.timedate;
jmh.Attribute |= JAM_MSG_TYPEECHO;
jsp = JAM_NewSubPacket();
jsf.LoID = JAMSFLD_SENDERNAME;
jsf.HiID = 0;
jsf.DatLen = strlen(msg.from);
jsf.Buffer = msg.from;
JAM_PutSubfield(jsp, &jsf);
jsf.LoID = JAMSFLD_RECVRNAME;
jsf.HiID = 0;
jsf.DatLen = strlen(msg.to);
jsf.Buffer = msg.to;
JAM_PutSubfield(jsp, &jsf);
jsf.LoID = JAMSFLD_SUBJECT;
jsf.HiID = 0;
jsf.DatLen = strlen(msg.subject);
jsf.Buffer = msg.subject;
JAM_PutSubfield(jsp, &jsf);
sprintf(buffer, "%d", msg.oaddr);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = buffer;
JAM_PutSubfield(jsp, &jsf);
jsf.LoID = JAMSFLD_MSGID;
jsf.HiID = 0;
jsf.DatLen = strlen(uuid);
jsf.Buffer = uuid;
JAM_PutSubfield(jsp, &jsf);
if (strlen(msg.reply)> 0) {
jsf.LoID = JAMSFLD_REPLYID;
jsf.HiID = 0;
jsf.DatLen = strlen(msg.reply);
jsf.Buffer = msg.reply;
JAM_PutSubfield(jsp, &jsf);
jmh.ReplyCRC = JAM_Crc32(msg.reply, strlen(msg.reply));
}
for (i=0;i<area_count;i++) {
if (msg.area == areas[i]->id) {
areaid = i;
break;
}
}
jb = open_jam_base(areas[areaid]->basedir);
if (!jb) {
return 0;
}
while (1) {
z = JAM_LockMB(jb, 100);
if (z == 0) {
break;
} else if (z == JAM_LOCK_FAILED) {
sleep(1);
} else {
free(body);
JAM_DelSubPacket(jsp);
JAM_CloseMB(jb);
free(jb);
fprintf(stderr, "Error locking JAM base!\n");
return 0;
}
}
if (JAM_AddMessage(jb, &jmh, jsp, body, strlen(body))) {
JAM_UnlockMB(jb);
JAM_DelSubPacket(jsp);
JAM_CloseMB(jb);
free(jb);
fprintf(stderr, "Error Adding Message!\n");
free(body);
return 0;
}
JAM_UnlockMB(jb);
JAM_DelSubPacket(jsp);
JAM_CloseMB(jb);
free(jb);
free(body);
return 1;
}
int main(int argc, char **argv) {
int i;
int l;
int processed = 0;
DIR *indir;
struct dirent *dent;
char buffer[PATH_MAX];
if (argc < 2) {
fprintf(stderr, "Usage ./mnettoss mnet.cfg\n");
return -1;
}
if (!parse_config_file(argv[1])) {
fprintf(stderr, "Error parsing config file: %s\n", argv[1]);
return -1;
}
if (baseindir == NULL) {
fprintf(stderr, "INDIR must be defined\n");
return -1;
}
printf("In Base Dir: %s\n", baseindir);
indir = opendir(baseindir);
if (!indir) {
fprintf(stderr, "Error opening inbound directory!\n");
return -1;
}
while ((dent = readdir(indir)) != NULL) {
if (strlen(dent->d_name) < 8) {
continue;
}
if (strcasecmp(&dent->d_name[strlen(dent->d_name) - 8], ".message") == 0) {
if (import(dent->d_name)) {
processed++;
snprintf(buffer, PATH_MAX, "%s/%s", baseindir, dent->d_name);
unlink(buffer);
rewinddir(indir);
}
}
}
closedir(indir);
printf("Processed %d Messages\n", processed);
return 0;
}