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
JAMLIB = ../../deps/jamlib/jamlib.a
OBJ = mgpost.o ../../src/inih/ini.o
LIBUUID = ../../deps/libuuid/.libs/libuuid.a
all: mgpost
@ -12,8 +13,15 @@ all: mgpost
$(JAMLIB):
cd ../../deps/jamlib && make -f Makefile.linux
mgpost: $(OBJ) $(JAMLIB)
$(CC) -o mgpost -o $@ $^ $(CFLAGS) -L/usr/local/lib
$(LIBUUID):
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

View File

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

View File

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