From be0f2b85761c40cbdc7339bbe722fad2d5e1eca4 Mon Sep 17 00:00:00 2001 From: g8bpq Date: Wed, 23 Nov 2022 10:56:20 +0000 Subject: 6.0.23.29 --- BBSUtilities.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'BBSUtilities.c') diff --git a/BBSUtilities.c b/BBSUtilities.c index 4d04579..0bf600b 100644 --- a/BBSUtilities.c +++ b/BBSUtilities.c @@ -43,6 +43,9 @@ RECT ConsoleRect; BOOL OpenConsole; BOOL OpenMon; +int reportNewMesageEvents = 0; + + extern struct ConsoleInfo BBSConsole; extern char LOC[7]; @@ -199,6 +202,14 @@ BOOL SendNewUserMessage = TRUE; BOOL AllowAnon = FALSE; BOOL UserCantKillT = FALSE; +typedef int (WINAPI FAR *FARPROCX)(); +FARPROCX pRunEventProgram; + +int RunEventProgram(char * Program, char * Param); + + +extern BOOL EventsEnabled; + #define BPQHOSTSTREAMS 64 // Although externally streams are numbered 1 to 64, internally offsets are 0 - 63 @@ -4796,7 +4807,7 @@ char * ReadInfoFile(char * File) FILE * hFile; char * MsgBytes; struct stat STAT; - char * ptr1 = 0; + char * ptr1 = 0, * ptr2; sprintf_s(MsgFile, sizeof(MsgFile), "%s/%s", BaseDir, File); @@ -4816,13 +4827,20 @@ char * ReadInfoFile(char * File) fclose(hFile); - MsgBytes[FileSize]=0; + MsgBytes[FileSize] = 0; -#ifndef WIN32 + ptr1 = MsgBytes; - // Replace LF with CR + // Replace LF or CRLF with CR - // Remove lf chars + // First remove cr from crlf + + while(ptr2 = strstr(ptr1, "\r\n")) + { + memmove(ptr2, ptr2 + 1, strlen(ptr2)); + } + + // Now replace lf with cr ptr1 = MsgBytes; @@ -4833,7 +4851,6 @@ char * ReadInfoFile(char * File) ptr1++; } -#endif return MsgBytes; } @@ -6295,6 +6312,33 @@ nextline: SaveMessageDatabase(); SaveBIDDatabase(); + // If Event Notifications enabled report a new message event + + if (reportNewMesageEvents) + { + char msg[200]; + + //12345 B 2053 TEST@ALL F6FBB 920325 This is the subject + + struct tm *tm = gmtime((time_t *)&Msg->datecreated); + + sprintf_s(msg, sizeof(msg),"%-6d %c %6d %-13s %-6s %02d%02d%02d %s\r", + Msg->number, Msg->type, Msg->length, Msg->to, + Msg->from, tm->tm_year-100, tm->tm_mon+1, tm->tm_mday, Msg->title); + +#ifdef WIN32 + if (pRunEventProgram) + pRunEventProgram("MailNewMsg.exe", msg); +#else + { + char prog[256]; + sprintf(prog, "%s/%s", BPQDirectory, "MailNewMsg"); + RunEventProgram(prog, msg); + } +#endif + } + + if (EnableUI) #ifdef LINBPQ SendMsgUI(Msg); -- cgit v1.2.3