Update mgpost and add to new build system
This commit is contained in:
parent
a37f867948
commit
ac729c1f69
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
cd utils/ticproc && $(MAKE) clean
|
||||
cd utils/mgpost && $(MAKE) clean
|
@ -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
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/file.h>
|
||||
#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();
|
||||
|
Reference in New Issue
Block a user