Make mgpost mnet aware

This commit is contained in:
Andrew Pamment 2018-08-01 11:13:00 +10:00
parent 746ecca318
commit 26e753caa3
3 changed files with 49 additions and 8 deletions

View File

@ -3,6 +3,7 @@ CFLAGS=-I/usr/local/include
DEPS = mgpost.c DEPS = mgpost.c
JAMLIB = ../../deps/jamlib/jamlib.a JAMLIB = ../../deps/jamlib/jamlib.a
OBJ = mgpost.o ../../src/inih/ini.o OBJ = mgpost.o ../../src/inih/ini.o
LIBUUID = ../../deps/libuuid/.libs/libuuid.a
all: mgpost all: mgpost
@ -12,8 +13,15 @@ all: mgpost
$(JAMLIB): $(JAMLIB):
cd ../../deps/jamlib && make -f Makefile.linux cd ../../deps/jamlib && make -f Makefile.linux
mgpost: $(OBJ) $(JAMLIB) $(LIBUUID):
$(CC) -o mgpost -o $@ $^ $(CFLAGS) -L/usr/local/lib rm ../../deps/libuuid/ltmain.sh ../../deps/libuuid/libtool || true
cd ../../deps/libuuid/ && libtoolize
cd ../../deps/libuuid/ && autoreconf
cd ../../deps/libuuid && ./configure
cd ../../deps/libuuid && $(MAKE)
mgpost: $(OBJ) $(JAMLIB) $(LIBUUID)
$(CC) -o mgpost $^ $(CFLAGS) -L/usr/local/lib
.PHONY: clean .PHONY: clean

View File

@ -6,6 +6,7 @@
#include <sys/file.h> #include <sys/file.h>
#include "../../deps/jamlib/jam.h" #include "../../deps/jamlib/jam.h"
#include "../../src/inih/ini.h" #include "../../src/inih/ini.h"
#include "../../deps/libuuid/uuid.h"
s_JamBase *open_jam_base(char *path) { s_JamBase *open_jam_base(char *path) {
int ret; int ret;
@ -99,6 +100,7 @@ struct msg_t {
char *subject; char *subject;
char *origin; char *origin;
struct fido_addr *localAddress; struct fido_addr *localAddress;
int maginode;
}; };
static int handler(void* user, const char* section, const char* name, static int handler(void* user, const char* section, const char* name,
@ -110,6 +112,8 @@ static int handler(void* user, const char* section, const char* name,
if (strcasecmp(name, "echomail") == 0) { if (strcasecmp(name, "echomail") == 0) {
if (strcasecmp(value, "true") == 0) { if (strcasecmp(value, "true") == 0) {
msg->echo = 1; msg->echo = 1;
} else if (strcasecmp(value, "magi") == 0) {
msg->echo = 2;
} else { } else {
msg->echo = 0; msg->echo = 0;
} }
@ -127,6 +131,8 @@ static int handler(void* user, const char* section, const char* name,
msg->localAddress = parse_fido_addr(value); msg->localAddress = parse_fido_addr(value);
} else if (strcasecmp(name, "Origin Line") == 0) { } else if (strcasecmp(name, "Origin Line") == 0) {
msg->origin = strdup(value); msg->origin = strdup(value);
} else if (strcasecmp(name, "Magi Node") == 0) {
msg->maginode = atoi(value);
} }
} }
return 1; return 1;
@ -187,7 +193,7 @@ int main(int argc, char **argv) {
time_t thetime; time_t thetime;
int z; int z;
int i; int i;
uuid_t myuuid;
struct msg_t msg; struct msg_t msg;
if (argc < 2) { if (argc < 2) {
@ -235,10 +241,14 @@ int main(int argc, char **argv) {
} }
} }
if (msg.localAddress->point == 0) { if (msg.echo == 1) {
snprintf(buffer, 1024, "\r--- mgpost\r * Origin: %s (%d:%d/%d)\r", msg.origin, msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node); if (msg.localAddress->point == 0) {
} else { snprintf(buffer, 1024, "\r--- mgpost\r * Origin: %s (%d:%d/%d)\r", msg.origin, msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node);
snprintf(buffer, 1024, "\r--- mgpost\r * Origin: %s (%d:%d/%d.%d)\r", msg.origin, msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node, msg.localAddress->point); } else {
snprintf(buffer, 1024, "\r--- mgpost\r * Origin: %s (%d:%d/%d.%d)\r", msg.origin, msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node, msg.localAddress->point);
}
} else if (msg.echo == 2) {
snprintf(buffer, 1024, "\r--- mgpost\r * Origin: %s (@%d)\r", msg.maginode);
} }
totlen += strlen(buffer); totlen += strlen(buffer);
@ -285,7 +295,7 @@ int main(int argc, char **argv) {
jsf.Buffer = (char *)msg.subject; jsf.Buffer = (char *)msg.subject;
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
if (msg.echo) { if (msg.echo == 1) {
if (msg.localAddress->point == 0) { if (msg.localAddress->point == 0) {
sprintf(buffer, "%d:%d/%d", msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node); sprintf(buffer, "%d:%d/%d", msg.localAddress->zone, msg.localAddress->net, msg.localAddress->node);
} else { } else {
@ -309,6 +319,24 @@ int main(int argc, char **argv) {
jsf.DatLen = strlen(buffer); jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer; jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf); JAM_PutSubfield(jsp, &jsf);
} else if (msg.echo == 2) {
sprintf(buffer, "%d", msg.maginode);
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
memset(buffer, 0, 1024);
uuid_generate(myuuid);
uuid_unparse_lower(myuuid, buffer);
jsf.LoID = JAMSFLD_MSGID;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (char *)buffer;
JAM_PutSubfield(jsp, &jsf);
} }
while (1) { while (1) {

View File

@ -1,4 +1,8 @@
[main] [main]
; Echo mail:
; TRUE = Fido Echo
; MAGI = Mnet echo
; FALSE = Local Mail
Echomail = TRUE Echomail = TRUE
BBS Path = /home/andrew/MagickaBBS BBS Path = /home/andrew/MagickaBBS
Message File = /home/andrew/MagickaBBS/advert.txt Message File = /home/andrew/MagickaBBS/advert.txt
@ -7,3 +11,4 @@ From = SysOp
Subject = Magicka BBS Test Subject = Magicka BBS Test
Local AKA = 21:1/125.1 Local AKA = 21:1/125.1
Origin Line = Cauldron, Magicka Test BBS Origin Line = Cauldron, Magicka Test BBS
; Magi Node = 2