[BBS Utils] Reading Mystic database files

After launching up XM Core BBS a few years ago. One has found that there are areas of improvement. To achieve this we have started writing up some utililties to help.

Last Callers

#!/usr/bin/env python3
# lastcallers.py
# (CC No-By)2019-2034 Dallas Makerspace, Some Rights Reserved.
# : Authors: Dwight Spencer (denzuko) <[email protected]>

## TODO workout OptionData Array[1..10] of String[60] and Array[1..53] of Byte/“B”

## Reference
## http://donsnotes.com/tech/charsets/ascii.html
## https://en.wikipedia.org/wiki/C_data_types
## http://wiki.freepascal.org/Data_type
## https://docs.python.org/2/library/struct.html#examples
## Record “header”: http://web.synchro.net/?page=001-forum.ssjs&sub=fsx_mys&thread=1212

import os
import sys

from struct import Struct

Callers_t = Struct(“I ? 15s 50s B I 30s 25s 30s B 35s 30s 60s 54?”)

def main(callers=“callers.dat”):


	with open(callers, ‘rb’).read() as data:
		for caller in data:
			print(Callers_t.unpack_from(data)[6].replace(“\t”, ‘’).strip())

# last caller  or first caller ^^

If __name__ == ‘__main__’:
	main()

Last callers is the beginning of the conversion from PASCAL headers found in docs/records.### over to a modern language. This is far from end all but merely the first steps. In this script we start parsing the callers.dat file for user names that have visited the board recently (up to the last 10) and print that out to STDOUT. Later iterations would place this on a mqtt subject for consumption by the website and influxdata’s telegraf.

Furthermore this series will dive into how to process messages areas and other data formats used by BBS’s.

As always, releases will go live on XM Core and Dallas Makerspace’s Github.

Next target, JAM message base format.

https://defsol.com/news/jammbp-the-joaquim-andrew-mats-message-base-proposal/

Reading message headers:

#!/usr/bin/env python3
# (CC No-By)2019-2034 Dallas Makerspace, Some Rights Reserved.
# : Authors: Dwight Spencer (denzuko) <[email protected]>

import os
import sys

from struct import Struct

MsgHdr_t = Struct("LHHLLLLLLLLLLLLLL")
message_s = {
  id: int(),
  offset: int(),
  length: int(),
  filename: str()
  body: str(),
}


class JamMessageBase():

    def __init__(self, header_file, message_file):
        self.msghdr_t . = Struct("LHHLLLLLLLLLLLLLLL")
        self.msg_schema =  { id: int(), offset: int(), length: int(), filename: str(), body: str() }
        self.header_file = header_file
        self.message_file = message_file
        self.read_message_headers()
        self.messages = list() # array of msg_schemas

    def read_message_at(self, offset, length=1):
        message = str()
        with open(self.messages, 'rb+') as messages:
            messages.seek(offset)
            message = messages.read(length)
         return message

    def read_headers(self):
        self.headers = list()

        with open(header_file, ‘rb+’).read() as headers:
             for header in headers:
              self.headers.append(list(MsgHdr_t.unpack_from(headers)))

    def get_messages(self):
         results = list(self.msg_schema.copy())

         self.read_message_header()

         for index, header in enumerate (self.headers):
             message = self.msg_schema.copy()
             message.id = index
             message.offset = 

# ... TODO Complete this as updated edit to the post