diff --git a/utils/mgpost/Makefile b/utils/mgpost/Makefile index 2709350..87b6839 100644 --- a/utils/mgpost/Makefile +++ b/utils/mgpost/Makefile @@ -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 diff --git a/utils/mgpost/mgpost.c b/utils/mgpost/mgpost.c index a94cf55..6834204 100644 --- a/utils/mgpost/mgpost.c +++ b/utils/mgpost/mgpost.c @@ -6,6 +6,7 @@ #include #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,10 +241,14 @@ int main(int argc, char **argv) { } } - 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); + 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 { @@ -309,6 +319,24 @@ int main(int argc, char **argv) { 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); + jsf.Buffer = (char *)buffer; + JAM_PutSubfield(jsp, &jsf); } while (1) { diff --git a/utils/mgpost/mgpost.ini b/utils/mgpost/mgpost.ini index 25af8a8..98acecf 100644 --- a/utils/mgpost/mgpost.ini +++ b/utils/mgpost/mgpost.ini @@ -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 \ No newline at end of file