From c116f2433b166c45d18fa2e78f5a3a2793380b3e Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 16 Apr 2020 07:39:46 +0000
Subject: [PATCH] A new Baja function <gasp>: MSG_LIST which will list the
 messages in the current sub, executing the configured "List Msgs Module" if
 there is one configured in SCFG->System->Loadable Modules (e.g. msglist.js)

---
 src/sbbs3/baja.c      |  3 +++
 src/sbbs3/cmdshell.h  | 16 ++++++++--------
 src/sbbs3/execmsg.cpp |  5 ++++-
 src/sbbs3/unbaja.c    |  4 ++--
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/sbbs3/baja.c b/src/sbbs3/baja.c
index 428dbcef15..c0a55b4105 100644
--- a/src/sbbs3/baja.c
+++ b/src/sbbs3/baja.c
@@ -3222,6 +3222,9 @@ void compile(char *src)
 		if(!stricmp(p,"MSG_YOUR_SCAN_ALL")) {
 			fprintf(out,"%c",CS_MSG_YOUR_SCAN_ALL);
 			continue; }
+		if(!stricmp(p,"MSG_LIST")) {
+			fprintf(out,"%c",CS_MSG_LIST);
+			continue; }
 		if(!stricmp(p,"CHAT_SECTION")) {
 			fprintf(out,"%c",CS_CHAT_SECTION);
 			continue; }
diff --git a/src/sbbs3/cmdshell.h b/src/sbbs3/cmdshell.h
index ef6e445b18..5cc376aa3c 100644
--- a/src/sbbs3/cmdshell.h
+++ b/src/sbbs3/cmdshell.h
@@ -234,7 +234,7 @@ enum {
 	,CS_MSG_YOUR_SCAN_ALL
 	,CS_MSG_NEW_SCAN_SUB
 	,CS_MSG_SET_GROUP
-	,CS_MSG_UNUSED4
+	,CS_MSG_LIST
 	,CS_MSG_UNUSED3
 	,CS_MSG_UNUSED2
 	,CS_MSG_UNUSED1
@@ -326,7 +326,7 @@ enum {
 
 /* Variable instructions (sub-op-code) */
 
-/* Preceeded by CS_VAR_INSTRUCTION */
+/* Preceded by CS_VAR_INSTRUCTION */
 
 enum {
 
@@ -469,14 +469,14 @@ enum {
 	,MATCHUSER						/* Set int var to user number of user name (str var) */
 	};
 
-/* Preceeded by CS_STR_FUNCTION */
+/* Preceded by CS_STR_FUNCTION */
 									
 enum {								/* More string arg functions */
 	 CS_LOGIN						/* Login/password prompt */
 	,CS_LOAD_TEXT					/* Load alternative TEXT.DAT */
 	};
 
-/* Preceeded by CS_ONE_MORE_BYTE */
+/* Preceded by CS_ONE_MORE_BYTE */
 enum {								/* More single byte instructions */
 	 CS_ONLINE						/* Online execution only */
 	,CS_OFFLINE 					/* Offline execution allowed */
@@ -490,18 +490,18 @@ enum {								/* More single byte instructions */
 	,CS_END_LOOP					/* End of looping code block */
 	};
 
-/* Preceeded by CS_TWO_MORE_BYTES */
+/* Preceded by CS_TWO_MORE_BYTES */
 enum {								/* More two byte instructions */
 	 CS_USER_EVENT					/* External user event */
 	};
 
-/* Preceeded by CS_NET_FUNCTION */
+/* Preceded by CS_NET_FUNCTION */
 
 enum {
 	 CS_SOCKET_OPEN					/* Open a socket */
 	,CS_SOCKET_CLOSE				/* Close a socket */
 	,CS_SOCKET_CONNECT				/* Outbound connection */
-	,CS_SOCKET_ACCEPT				/* Accept an incomming connection */
+	,CS_SOCKET_ACCEPT				/* Accept an incoming connection */
 	,CS_SOCKET_NREAD				/* Get number of bytes in input buffer */
 	,CS_SOCKET_PEEK					/* Peek at input buffer */
 	,CS_SOCKET_READ					/* Read input buffer */
@@ -533,7 +533,7 @@ enum {
 	,CS_FTP_UNUSED1
 	};
 
-/* Preceeded by CS_FIO_FUNCTION */
+/* Preceded by CS_FIO_FUNCTION */
 enum {
 	 FIO_OPEN						/* Open file (static filename) */
 	,FIO_CLOSE						/* Close file */
diff --git a/src/sbbs3/execmsg.cpp b/src/sbbs3/execmsg.cpp
index 5aca7ebe5b..8f772f551e 100644
--- a/src/sbbs3/execmsg.cpp
+++ b/src/sbbs3/execmsg.cpp
@@ -328,7 +328,10 @@ int sbbs_t::exec_msg(csi_t *csi)
 			return(0);
 		case CS_MSG_YOUR_SCAN_ALL:
 			scanallsubs(SCAN_TOYOU);
-			return(0); 
+			return(0);
+		case CS_MSG_LIST:
+			listsub(usrsub[curgrp][cursub[curgrp]], SCAN_INDEX, /* start: */0, /* search: */NULL);
+			return(0);
 	}
 	errormsg(WHERE,ERR_CHK,"shell function",*(csi->ip-1));
 	return(0);
diff --git a/src/sbbs3/unbaja.c b/src/sbbs3/unbaja.c
index 5ea62838f8..c285193291 100644
--- a/src/sbbs3/unbaja.c
+++ b/src/sbbs3/unbaja.c
@@ -2131,8 +2131,8 @@ void decompile(FILE *bin, FILE *srcfile)
 				NONE("MSG_NEW_SCAN_SUB");
 			case CS_MSG_SET_GROUP:
 				NONE("MSG_SET_GROUP");
-			case CS_MSG_UNUSED4:
-				NONE("MSG_UNUSED4");
+			case CS_MSG_LIST:
+				NONE("MSG_LIST");
 			case CS_MSG_UNUSED3:
 				NONE("MSG_UNUSED3");
 			case CS_MSG_UNUSED2:
-- 
GitLab