diff --git a/mystic/mutil.pas b/mystic/mutil.pas new file mode 100644 index 0000000..8dc115b --- /dev/null +++ b/mystic/mutil.pas @@ -0,0 +1,153 @@ +Program MUTIL; + +// ==================================================================== +// Mystic BBS Software Copyright 1997-2012 By James Coyle +// ==================================================================== +// +// This file is part of Mystic BBS. +// +// Mystic BBS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Mystic BBS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Mystic BBS. If not, see . +// +// ==================================================================== + +{$I M_OPS.PAS} + +// MBBSUTIL replacement WIP +// +// Eventually all of MBBSUTIL stuff will be incorporated into this program. +// MBBSUTIL and MYSTPACK will be phased out in favor of this program. +// +// The goal of this program is to have basically everything under the sun +// all in one utility. Eventually it may even have a full blown FIDO-style +// tosser too. TOP 10 generators, etc. It's all planned for MUTIL. + +Uses + INIFiles, + m_Output, + m_DateTime, + m_Strings, + m_FileIO, + mutil_Common, + mutil_Status, + mutil_ImportNA; + +{$I MUTIL_ANSI.PAS} + +Function CheckProcess (pName: String) : Boolean; +Begin + Result := False; + + If strUpper(INI.ReadString(Header_General, pName, 'FALSE')) = 'TRUE' Then Begin + Result := True; + + Inc (ProcessTotal); + End; +End; + +Procedure ApplicationShutdown; +Begin + If Assigned(Console) Then Begin + Console.SetWindow (1, 1, 80, 25, False); + Console.CursorXY (3, 22); + + Console.TextAttr := 15; + Console.WriteLine('> Execution complete'); + Console.TextAttr := 7; + End; + + BarOne.Free; + BarAll.Free; + INI.Free; + Console.Free; +End; + +Procedure ApplicationStartup; +Var + FN : String; + CF : File of RecConfig; +Begin + ExitProc := @ApplicationShutdown; + Console := TOutput.Create(True); + + DrawStatusScreen; + + Console.SetWindow(5, 14, 76, 21, True); + + If FileExist(ParamStr(1)) Then + FN := ParamStr(1) + Else + If FileExist('mutil.cfg') Then + FN := 'mutil.cfg' + Else Begin + ProcessName ('Load configuration', False); + ProcessStatus ('Missing file'); + ProcessResult (rFATAL, True); + + Halt(1); + End; + + INI := TINIFile.Create(FN); + + Console.WriteXY (26, 10, 8, FN); + + Assign (CF, INI.ReadString(Header_GENERAL, 'mystic_directory', 'mystic.dat')); + + {$I-} Reset(CF); {$I+} + + If IoResult <> 0 Then Begin + ProcessName ('Load configuration', False); + ProcessStatus ('Missing MYSTIC.DAT'); + ProcessResult (rFATAL, True); + + Halt(1); + End; + + Read (CF, bbsConfig); + Close (CF); + + If bbsConfig.DataChanged <> mysDataChanged Then Begin + ProcessName ('Load configuration', False); + ProcessStatus ('Version mismatch'); + ProcessResult (rFATAL, True); + + Halt(1); + End; + + BarOne := TStatusBar.Create(3); + BarAll := TStatusBar.Create(6); +End; + +Var + DoImportNA : Boolean; +Begin + ApplicationStartup; + + // Build process list + + DoImportNA := CheckProcess(Header_IMPORTNA); + + // Exit with an error if nothing is configured + + If ProcessTotal = 0 Then Begin + ProcessName ('Load configuration', False); + ProcessStatus ('No processes are configured!'); + ProcessResult (rFATAL, True); + + Halt(1); + End; + + // We're good lets execute this stuff! + + If DoImportNA Then uImportNA; +End. diff --git a/mystic/mutil_ansi.ans b/mystic/mutil_ansi.ans new file mode 100644 index 0000000..ff1504b --- /dev/null +++ b/mystic/mutil_ansi.ans @@ -0,0 +1,23 @@ +[?7hÜÜÜÜ °²ÜܲÜÜܲ °±²ÜÜÜ °Ü + ŽŪÜÜž ß Ż °°°Ž²ßßßßßßßßß ßßßßßßßßßßß ßßßßßßßßßßßßßßßßßßßßßßŪ² + °ŪŪŪÜÜÜßÜÜŪŪŪŽ°Ż% °± +ß²ŪŪŪŪÜÜßŪ²ßÜŪŪŪŪŪ²Ž² +²±²²²ŪßßŪÜÜŪßßŪ²²²±Ž°žśÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Äś °²Ū +ß Ū°°°Ū ßßßß Ū°°°Ū% °² +°°²ŪŪŪŪ ²ÜÜÜܲ ŪŪŪŪŪ ±Ż² +ÜÜž ßß² ± °°²ÜÜÜÜÜÜܲÜÜÜÜÜÜÜÜÜÜܲ ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜÜ Ü ÜÜÜÜÜÜÜ Ü²Ū +° mUTIL vÜßßßß° ß° + °ß ÜÜß + + Ž Process ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Ä Status ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Result ÄÄÄÄś + ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄijÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄijÄÄÄÄÄÄÄÄÄÄÄÄæ + + + + + + + + ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ + + \ No newline at end of file diff --git a/mystic/mutil_ansi.pas b/mystic/mutil_ansi.pas new file mode 100644 index 0000000..0241bce --- /dev/null +++ b/mystic/mutil_ansi.pas @@ -0,0 +1,39 @@ +Procedure DrawStatusScreen; +Const + IMAGEDATA_WIDTH=80; + IMAGEDATA_DEPTH=23; + IMAGEDATA_LENGTH=475; + IMAGEDATA : array [1..475] of Char = ( + #1,#16,'Ü','Ü',#25,#10, #8,'Ü','Ü',#25, #3, #7,'°', #0,#23,'²',#16, + ' ',' ', #8,'Ü',#25, #7,'Ü',#25,#11,'²','Ü','Ü',#25,#16,'Ü','²',' ', + '°','±','²','Ü','Ü','Ü',#25, #2,'°','Ü',#24,' ', #9,#17,'Ž',#16,'Ū', + #17,'Ü', #1,#16,'Ü',#25, #4, #8,'ž',' ','ß',' ',' ','Ż',' ', #1,'°', + '°', #9,'°',#17,'Ž',#16,' ', #8,'²',#26, #8,'ß',' ',#26,#10,'ß',#25, + #3,#26,#17,'ß',#25, #6,#26, #3,'ß','Ū','²',#24,' ', #9,'°','Ū',#11, + 'Ū','Ū', #9,#17,'Ü', #1,#16,'Ü',#25, #5, #8,'Ü','ß', #1,'Ü', #9,#17, + 'Ü','Ū','Ū','Ū','Ž', #8,#16,'°','Ż',#25,'2','%',' ',' ','°','±',#24, + #11,#23,'ß',#16,' ', #9,'²',#26, #3,'Ū',#17,'Ü', #1,#16,'Ü', #8,'ß', + 'Ū',#23,'²',#16,'ß', #1,'Ü', #9,#17,'Ū','Ū',#11,#16,'Ū', #9,#17,'Ū', + 'Ū',#16,'²',#17,'Ž',#16,#25,'8', #8,'²',#24,#23,'²',#16,' ', #9,'±', + #17,'²','²','²',#16,'Ū','ß',#17,'ß','Ū',#16,'Ü','Ü',#17,'Ū','ß',#16, + 'ß',#17,'Ū','²','²','²',#16,'±', #1,'Ž', #8,'°','ž','ś',#26,',','Ä', + ' ','Ä','ś',#25, #3,'°','²','Ū',#24,'ß',' ', #1,'Ū', #9,#17,'°','°', + '°', #1,#16,'Ū',' ',' ','ß', #9,#17,'ß','ß', #1,#16,'ß',' ',' ','Ū', + #9,#17,'°','°','°', #1,#16,'Ū',#25,'5', #8,'%',' ',' ','°','²',#24, + #1,'°','°','²',#26, #3,'Ū',' ', #8,#17,'²',#16,#26, #3,'Ü','²',' ', + #1,#26, #4,'Ū',' ', #8,'±','Ż',#25,'6','²',#24,'Ü','Ü','ž',' ', #1, + 'ß','ß','²',' ', #8,'±',' ',' ','°','°','²',#26, #6,'Ü','²',#26,#10, + 'Ü','²',' ',#26,#17,'Ü',' ',' ',#26, #7,'Ü',' ',' ','Ü',' ',' ',#26, + #6,'Ü',' ','Ü','²','Ū',#24,#25, #7,'°',' ','m', #7,'U','T','I','L', + ' ','v',#25, #4, #8,'Ü','ß',#25,#10,'ß',#25,#16,'ß','ß',#25, #8,'°', + ' ',' ','ß',#25, #9,'°',#24,' ',' ', #1,'°',#25,#14, #8,'ß',' ','Ü', + 'Ü','ß',#24,#24,' ',' ','Ž',' ',#15,'P','r','o','c','e','s','s',' ', + #8,#26,#16,'Ä',' ','Ä',' ',#15,'S','t','a','t','u','s',' ', #8,#26, + #24,'Ä',' ',#15,'R','e','s','u','l','t',' ', #8,#26, #3,'Ä','ś',#24, + ' ',' ','Ś',#26,#26,'Ä','³',#26,#31,'Ä','³',#26,#11,'Ä','æ',#24,#24, + #24,#24,#24,#24,#24,#24,' ',' ','Ą',#26,'H','Ä','Ł',#24,#24,#24); + +Begin + Console.LoadScreenImage(ImageData, ImageData_Length, ImageData_Width, 1, 1); + Console.WriteXY (18, 9, 15, Copy(mysVersion, 1, 4)); +End; diff --git a/mystic/mutil_common.pas b/mystic/mutil_common.pas new file mode 100644 index 0000000..aecba93 --- /dev/null +++ b/mystic/mutil_common.pas @@ -0,0 +1,32 @@ +Unit MUTIL_Common; + +{$I M_OPS.PAS} + +Interface + +Uses + INIFiles, + m_Output, + mutil_Status; + +{$I RECORDS.PAS} + +Var + Console : TOutput; + INI : TINIFile; + BarOne : TStatusBar; + BarAll : TStatusBar; + ProcessTotal : Byte = 0; + ProcessPos : Byte = 0; + bbsConfig : RecConfig; + +Const + Header_GENERAL = 'General'; + Header_IMPORTNA = 'Import_FIDONET.NA'; + +Implementation + +Uses + m_Strings; + +End. diff --git a/mystic/mutil_importna.pas b/mystic/mutil_importna.pas new file mode 100644 index 0000000..a59cfe1 --- /dev/null +++ b/mystic/mutil_importna.pas @@ -0,0 +1,62 @@ +Unit MUTIL_ImportNA; + +{$I M_OPS.PAS} + +Interface + +Procedure uImportNA; + +Implementation + +Uses + m_Strings, + mutil_Common, + mutil_Status; + +Procedure uImportNA; +Var + CreatedBases : LongInt = 0; + InFile : Text; + Str : String; + Buffer : Array[1..2048] of Byte; + TagName : String; + BaseName : String; +Begin + ProcessName ('Import FIDONET.NA', True); + ProcessResult (rWORKING, False); + + Assign (InFile, INI.ReadString(Header_IMPORTNA, 'filename', 'fidonet.na')); + SetTextBuf (InFile, Buffer); + + {$I-} Reset(InFile); {$I+} + + If IoResult <> 0 Then Begin + ProcessStatus ('Cannot find NA file'); + ProcessResult (rWARN, True); + + Exit; + End; + + While Not Eof(InFile) Do Begin + ReadLn(InFile, Str); + + Str := strStripB(Str, ' '); + + If (Str[1] = ';') or (Str = '') Then Continue; + + TagName := strWordGet(1, Str, ' '); + BaseName := strStripB(strWordGet(2, Str, ' '), ' '); + + ProcessStatus (BaseName); + End; + + Close (InFile); + + ProcessStatus ('Created |15' + strI2S(CreatedBases) + ' |07base(s)'); + ProcessResult (rDONE, True); + + BarOne.Update(100, 100); + BarAll.Update(ProcessPos, ProcessTotal); +End; + +End. diff --git a/mystic/mutil_status.pas b/mystic/mutil_status.pas new file mode 100644 index 0000000..4094e2a --- /dev/null +++ b/mystic/mutil_status.pas @@ -0,0 +1,101 @@ +Unit MUTIL_Status; + +{$I M_OPS.PAS} + +Interface + +Type + TStatusBar = Class + LastPercent : Byte; + LinePosition : Byte; + + Constructor Create (LinePos: Byte); + Destructor Destroy; Override; + + Procedure Reset; + Procedure Update (Part, Whole: LongInt); + End; + + TProcessResult = (rDONE, rWARN, rWORKING, rFATAL); + +Procedure ProcessName (Str: String; Start: Boolean); +Procedure ProcessStatus (Str: String); +Procedure ProcessResult (Res: TProcessResult; Done: Boolean); + +Implementation + +Uses + m_Strings, + mutil_Common; + +Procedure ProcessName (Str: String; Start: Boolean); +Begin + Console.WriteXYPipe (5, Console.CursorY, 7, 26, Str); + + If Start Then Inc (ProcessPos); +End; + +Procedure ProcessStatus (Str: String); +Begin + Console.WriteXYPipe (33, Console.CursorY, 7, 31, Str); +End; + +Procedure ProcessResult (Res: TProcessResult; Done: Boolean); +Begin + Case Res of + rDONE : Console.WriteXYPipe(66, Console.CursorY, 10, 11, 'DONE'); + rWARN : Console.WriteXYPipe(66, Console.CursorY, 12, 11, 'WARNING'); + rWORKING : Console.WriteXYPipe(66, Console.CursorY, 15, 11, 'WORKING'); + rFATAL : Console.WriteXYPipe(66, Console.CursorY, 12, 11, 'FATAL'); + End; + + If Done Then Console.WriteLine(''); +End; + +Procedure TStatusBar.Reset; +Begin + Console.WriteXY (24, LinePosition, 8, strRep(#176, 50)); + Console.WriteXY (24, LinePosition + 1, 8, strRep(#176, 50)); + + Console.WriteXY (75, LinePosition + 1, 7, '0 '); + + LastPercent := 0; +End; + +Procedure TStatusBar.Update (Part, Whole: LongInt); +Var + Percent : Byte; + PerStr : String; +Begin + Percent := Round(Part / Whole * 100); + + If Percent <> LastPercent Then Begin + LastPercent := Percent; + + If Percent >= 2 Then Begin + PerStr := strRep(' ', (Percent DIV 2) - 1) + #222; + + Console.WriteXY (24, LinePosition, 25, PerStr); + Console.WriteXY (24, LinePosition + 1, 25, PerStr); + End; + + Console.WriteXY (75, LinePosition + 1, 7, strPadR(strI2S(Percent), 3, ' ')); + End; +End; + +Constructor TStatusBar.Create (LinePos: Byte); +Begin + Inherited Create; + + LinePosition := LinePos; + + Reset; +End; + +Destructor TStatusBar.Destroy; +Begin + Inherited Destroy; +End; + + +End.