diff --git a/Makefile.freebsd b/Makefile.freebsd index 051560f..ea83557 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -6,7 +6,7 @@ ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS= @@ -36,6 +36,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -46,4 +49,5 @@ clean: cd utils/magimail && $(MAKE) cleanfreebsd cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.freebsd.WWW b/Makefile.freebsd.WWW index dd27dcc..e2da8b6 100644 --- a/Makefile.freebsd.WWW +++ b/Makefile.freebsd.WWW @@ -8,7 +8,7 @@ B64 = deps/libb64-1.2/src/libb64.a MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS= @@ -41,6 +41,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -52,4 +55,5 @@ clean: cd utils/magimail && $(MAKE) cleanfreebsd cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.linux b/Makefile.linux index 1d974a6..7b9586f 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -6,7 +6,7 @@ ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS= @@ -36,6 +36,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -46,4 +49,5 @@ clean: cd utils/magimail && $(MAKE) cleanlinux cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.linux.WWW b/Makefile.linux.WWW index 9949410..b61ceec 100644 --- a/Makefile.linux.WWW +++ b/Makefile.linux.WWW @@ -8,7 +8,7 @@ B64 = deps/libb64-1.2/src/libb64.a MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS= @@ -41,6 +41,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -52,4 +55,5 @@ clean: cd utils/magimail && $(MAKE) cleanlinux cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.netbsd b/Makefile.netbsd index 8c4fe15..b14a6ce 100644 --- a/Makefile.netbsd +++ b/Makefile.netbsd @@ -6,7 +6,7 @@ ZMODEM = deps/Xmodem/libzmodem.a LUA = deps/lua/liblua.a ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS= @@ -36,6 +36,9 @@ magimail: $(JAMLIB) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -47,3 +50,4 @@ clean: cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.netbsd.WWW b/Makefile.netbsd.WWW index dd43733..01bf89b 100644 --- a/Makefile.netbsd.WWW +++ b/Makefile.netbsd.WWW @@ -8,7 +8,7 @@ B64 = deps/libb64-1.2/src/libb64.a MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS= @@ -41,6 +41,9 @@ magimail: $(JAMLIB) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -52,4 +55,5 @@ clean: cd utils/magimail && $(MAKE) cleanfreebsd cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.osx b/Makefile.osx index 0c10989..0cad998 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -8,7 +8,7 @@ ODOORS = deps/odoors/libs-`uname -s`/libODoors.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 -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS= @@ -37,6 +37,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -47,4 +50,5 @@ clean: cd utils/magimail && $(MAKE) cleanlinux cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/Makefile.osx.WWW b/Makefile.osx.WWW index 29c099d..03da41b 100644 --- a/Makefile.osx.WWW +++ b/Makefile.osx.WWW @@ -8,7 +8,7 @@ B64 = deps/libb64-1.2/src/libb64.a MICROHTTPD=-lmicrohttpd ODOORS = deps/odoors/libs-`uname -s`/libODoors.a -all: magicka magimail magiedit ticproc +all: magicka magimail magiedit ticproc mgpost ${LUA}: cd deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS= @@ -41,6 +41,9 @@ magiedit: $(ODOORS) ticproc: cd utils/ticproc && $(MAKE) +mgpost: $(JAMLIB) + cd utils/mgpost && $(MAKE) + .PHONY: clean clean: @@ -51,4 +54,5 @@ clean: cd utils/magimail && $(MAKE) cleanlinux cd utils/magiedit && $(MAKE) clean cd deps/odoors/ && rm -rf libs-`uname -s` objs-`uname -s` exe-`uname -s` - cd utils/ticproc && $(MAKE) clean \ No newline at end of file + cd utils/ticproc && $(MAKE) clean + cd utils/mgpost && $(MAKE) clean \ No newline at end of file diff --git a/utils/mgpost/Makefile b/utils/mgpost/Makefile index 66f976c..ec64561 100644 --- a/utils/mgpost/Makefile +++ b/utils/mgpost/Makefile @@ -1,13 +1,19 @@ CC=cc CFLAGS=-I/usr/local/include DEPS = mgpost.c -JAMLIB = ../../jamlib/jamlib.a +JAMLIB = ../../deps/jamlib/jamlib.a OBJ = mgpost.o ../../inih/ini.o + +all: mgpost + %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) -mgpost: $(OBJ) - $(CC) -o mgpost -o $@ $^ $(CFLAGS) -L/usr/local/lib $(JAMLIB) +$(JAMLIB): + cd ../../deps/jamlib && make -f Makefile.linux + +mgpost: $(OBJ) $(JAMLIB) + $(CC) -o mgpost -o $@ $^ $(CFLAGS) -L/usr/local/lib .PHONY: clean diff --git a/utils/mgpost/mgpost.c b/utils/mgpost/mgpost.c index d022d03..c011c14 100644 --- a/utils/mgpost/mgpost.c +++ b/utils/mgpost/mgpost.c @@ -4,7 +4,7 @@ #include #include #include -#include "../../jamlib/jam.h" +#include "../../deps/jamlib/jam.h" #include "../../inih/ini.h" s_JamBase *open_jam_base(char *path) { @@ -133,71 +133,27 @@ static int handler(void* user, const char* section, const char* name, } unsigned long generate_msgid(char *bbs_path) { - time_t theTime; - char buffer[1024]; - - struct tm timeStruct; - struct tm fileStruct; - unsigned long m; - unsigned long y; - unsigned long ya; - unsigned long j; - unsigned long msgid; - unsigned long c; - unsigned long d; - time_t lastread; + unsigned long lastid; FILE *fptr; - theTime = time(NULL); - localtime_r(&theTime, &timeStruct); - - m = timeStruct.tm_mon + 1; - y = timeStruct.tm_year + 1900; - d = timeStruct.tm_mday; - - if (m > 2) { - m = m - 3; - } else { - m = m + 9; - y = y - 1; - } - - c = y / 100; - ya = y - 100 * c; - j = (146097 * c) / 4 + (1461 * ya) / 4 + (153 * m + 2) / 5 + d + 1721119; - - msgid = (j % 0x800) * 0x200000; - snprintf(buffer, 1024, "%s/msgserial", bbs_path); fptr = fopen(buffer, "r+"); if (fptr) { flock(fileno(fptr), LOCK_EX); - fread(&lastread, sizeof(time_t), 1, fptr); fread(&lastid, sizeof(unsigned long), 1, fptr); - localtime_r(&lastread, &fileStruct); - - - if (fileStruct.tm_mon != timeStruct.tm_mon || fileStruct.tm_mday != timeStruct.tm_mday || fileStruct.tm_year != timeStruct.tm_year) { - lastread = time(NULL); - lastid = 1; - } else { - lastid++; - } + lastid++; rewind(fptr); - fwrite(&lastread, sizeof(time_t), 1, fptr); fwrite(&lastid, sizeof(unsigned long), 1, fptr); flock(fileno(fptr), LOCK_UN); fclose(fptr); } else { fptr = fopen(buffer, "w"); if (fptr) { - lastread = time(NULL); lastid = 1; flock(fileno(fptr), LOCK_EX); - fwrite(&lastread, sizeof(time_t), 1, fptr); fwrite(&lastid, sizeof(unsigned long), 1, fptr); flock(fileno(fptr), LOCK_UN); fclose(fptr); @@ -207,9 +163,9 @@ unsigned long generate_msgid(char *bbs_path) { } } - msgid += lastid; + - return msgid; + return lastid; } int main(int argc, char **argv) { @@ -294,12 +250,12 @@ int main(int argc, char **argv) { JAM_ClearMsgHeader( &jmh ); jmh.DateWritten = thetime; - jmh.Attribute |= MSG_LOCAL; + jmh.Attribute |= JAM_MSG_LOCAL; if (!msg.echo) { - jmh.Attribute |= MSG_TYPELOCAL; + jmh.Attribute |= JAM_MSG_TYPELOCAL; } else { - jmh.Attribute |= MSG_TYPEECHO; + jmh.Attribute |= JAM_MSG_TYPEECHO; } jsp = JAM_NewSubPacket();