mysticbbs/mystic/mutil.pas

230 lines
5.8 KiB
ObjectPascal
Raw Normal View History

2012-02-29 17:45:16 -08:00
Program MUTIL;
// ====================================================================
2013-02-26 04:45:01 -08:00
// Mystic BBS Software Copyright 1997-2013 By James Coyle
2012-02-29 17:45:16 -08:00
// ====================================================================
//
// 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 <http://www.gnu.org/licenses/>.
//
// ====================================================================
{$I M_OPS.PAS}
Uses
2012-03-01 15:21:16 -08:00
{$IFDEF DEBUG}
HeapTrc,
LineInfo,
{$ENDIF}
2012-02-29 17:45:16 -08:00
m_Output,
m_DateTime,
m_Strings,
m_FileIO,
2012-08-08 10:51:32 -07:00
m_IniReader,
2013-08-29 03:04:20 -07:00
BBS_Records,
2012-09-08 01:27:20 -07:00
mUtil_Common,
mUtil_Status,
mUtil_ImportNA,
2013-03-08 04:21:13 -08:00
mUtil_ImportMsgBase,
2012-09-08 01:27:20 -07:00
mUtil_FileBone,
mUtil_Upload,
mUtil_TopLists,
mUtil_FilesBBS,
mUtil_AllFiles,
mUtil_MsgPurge,
2012-09-25 16:20:59 -07:00
mUtil_MsgPack,
2012-09-26 13:51:07 -07:00
mUtil_MsgPost,
2013-03-17 04:01:46 -07:00
mUtil_EchoExport,
2013-03-18 22:48:11 -07:00
mUtil_EchoImport,
bbs_DataBase;
2012-02-29 17:45:16 -08:00
{$I MUTIL_ANSI.PAS}
Function CheckProcess (pName: String) : Boolean;
Begin
2012-09-26 13:51:07 -07:00
Result := INI.ReadBoolean(Header_General, pName, False);
2012-02-29 17:45:16 -08:00
2012-09-26 13:51:07 -07:00
If Result Then Begin
2012-02-29 17:45:16 -08:00
Inc (ProcessTotal);
2012-09-24 20:57:45 -07:00
Log (2, '+', ' EXEC ' + pName);
End Else
2013-03-18 22:48:11 -07:00
Log (3, '+', ' SKIP ' + pName);
2012-02-29 17:45:16 -08:00
End;
Procedure ApplicationShutdown;
Begin
2012-09-28 15:24:50 -07:00
Log (1, '+', '=> Shutdown');
2012-09-24 20:57:45 -07:00
Log (1, '+', '');
2012-02-29 17:45:16 -08:00
If Assigned(Console) Then Begin
Console.SetWindow (1, 1, 80, 25, False);
Console.CursorXY (3, 22);
Console.TextAttr := 15;
2012-11-18 05:51:32 -08:00
Console.WriteLine('> Execution of ' + strI2S(ProcessTotal) + ' processes complete');
2012-02-29 17:45:16 -08:00
Console.TextAttr := 7;
End;
BarOne.Free;
BarAll.Free;
INI.Free;
Console.Free;
End;
Procedure ApplicationStartup;
Var
FN : String;
CF : File of RecConfig;
2013-03-18 22:48:11 -07:00
F : File;
2012-02-29 17:45:16 -08:00
Begin
ExitProc := @ApplicationShutdown;
Console := TOutput.Create(strUpper(ParamStr(2)) <> '-NOSCREEN');
2012-02-29 17:45:16 -08:00
If Console.Active Then DrawStatusScreen;
2012-02-29 17:45:16 -08:00
2012-11-18 05:51:32 -08:00
Console.SetWindow(5, 14, 76, 20, True);
2012-02-29 17:45:16 -08:00
If FileExist(ParamStr(1)) Then
FN := ParamStr(1)
Else
2013-09-03 05:02:29 -07:00
If FileExist(ParamStr(1) + '.ini') Then
FN := ParamStr(1) + '.ini'
Else
2012-09-24 20:57:45 -07:00
If FileExist('mutil.ini') Then
FN := 'mutil.ini'
2012-02-29 17:45:16 -08:00
Else Begin
ProcessName ('Load configuration', False);
2012-09-24 20:57:45 -07:00
ProcessStatus ('Missing file', True);
ProcessResult (rFATAL, False);
2012-02-29 17:45:16 -08:00
Halt(1);
End;
2012-08-08 10:51:32 -07:00
INI := TINIReader.Create(FN);
2012-02-29 17:45:16 -08:00
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);
2012-09-24 20:57:45 -07:00
ProcessStatus ('Missing MYSTIC.DAT', True);
ProcessResult (rFATAL, False);
2012-02-29 17:45:16 -08:00
Halt(1);
End;
Read (CF, bbsCfg);
2012-02-29 17:45:16 -08:00
Close (CF);
If bbsCfg.DataChanged <> mysDataChanged Then Begin
2012-02-29 17:45:16 -08:00
ProcessName ('Load configuration', False);
2012-09-24 20:57:45 -07:00
ProcessStatus ('Version mismatch', True);
ProcessResult (rFATAL, False);
2012-02-29 17:45:16 -08:00
Halt(1);
End;
TempPath := bbsCfg.SystemPath + 'temputil' + PathChar;
2012-03-01 15:21:16 -08:00
GetDIR (0, StartPath);
{$I-}
MkDir (TempPath);
{$I+}
2012-03-02 13:19:35 -08:00
If IoResult <> 0 Then;
2012-03-01 15:21:16 -08:00
DirClean (TempPath, '');
2012-09-24 20:57:45 -07:00
LogFile := INI.ReadString(Header_GENERAL, 'logfile', '');
If (LogFile <> '') and (Pos(PathChar, LogFile) = 0) Then
LogFile := bbsCfg.LogsPath + LogFile;
2012-09-24 20:57:45 -07:00
LogLevel := INI.ReadInteger(Header_GENERAL, 'loglevel', 1);
2012-02-29 17:45:16 -08:00
BarOne := TStatusBar.Create(3);
BarAll := TStatusBar.Create(6);
2013-03-18 22:48:11 -07:00
If LogFile <> '' Then Begin
Assign (F, LogFile);
If Not ioReset(F, 1, fmRWDN) Then ReWrite(F);
Close (F);
End;
2012-02-29 17:45:16 -08:00
End;
Var
2012-03-01 15:21:16 -08:00
DoImportNA : Boolean;
2012-08-17 11:34:23 -07:00
DoFilesBBS : Boolean;
2012-03-03 20:38:56 -08:00
DoFileBone : Boolean;
2012-03-01 15:21:16 -08:00
DoMassUpload : Boolean;
DoTopLists : Boolean;
2012-09-08 01:27:20 -07:00
DoAllFiles : Boolean;
2013-03-17 04:01:46 -07:00
DoEchoExport : Boolean;
2013-03-18 22:48:11 -07:00
DoEchoImport : Boolean;
2012-09-08 01:27:20 -07:00
DoMsgPurge : Boolean;
DoMsgPack : Boolean;
2012-09-25 16:20:59 -07:00
DoMsgPost : Boolean;
2013-03-08 04:21:13 -08:00
DoImportMB : Boolean;
2012-02-29 17:45:16 -08:00
Begin
ApplicationStartup;
2012-09-28 15:24:50 -07:00
Log (1, '+', '=> Startup using ' + JustFile(INI.FileName));
2012-09-24 20:57:45 -07:00
2012-02-29 17:45:16 -08:00
// Build process list
2012-03-01 15:21:16 -08:00
DoImportNA := CheckProcess(Header_IMPORTNA);
2013-03-08 04:21:13 -08:00
DoImportMB := CheckProcess(Header_IMPORTMB);
2012-03-03 20:38:56 -08:00
DoFileBone := CheckProcess(Header_FILEBONE);
2012-03-01 15:21:16 -08:00
DoMassUpload := CheckProcess(Header_UPLOAD);
DoTopLists := CheckProcess(Header_TOPLISTS);
2012-08-17 11:34:23 -07:00
DoFilesBBS := CheckProcess(Header_FILESBBS);
2012-09-08 01:27:20 -07:00
DoAllFiles := CheckProcess(Header_ALLFILES);
2013-03-17 04:01:46 -07:00
DoEchoExport := CheckProcess(Header_ECHOEXPORT);
2013-03-18 22:48:11 -07:00
DoEchoImport := CheckProcess(Header_ECHOIMPORT);
2012-09-08 01:27:20 -07:00
DoMsgPurge := CheckProcess(Header_MSGPURGE);
DoMsgPack := CheckProcess(Header_MSGPACK);
2012-09-25 16:20:59 -07:00
DoMsgPost := CheckProcess(Header_MSGPOST);
2012-02-29 17:45:16 -08:00
// Exit with an error if nothing is configured
If ProcessTotal = 0 Then Begin
ProcessName ('Load configuration', False);
2013-03-22 20:17:33 -07:00
ProcessStatus ('No processes configured', True);
ProcessResult (rFATAL, False);
2012-02-29 17:45:16 -08:00
Halt(1);
End;
// We're good lets execute this stuff!
2012-03-01 15:21:16 -08:00
If DoImportNA Then uImportNA;
2012-03-03 20:38:56 -08:00
If DoFileBone Then uImportFileBone;
2012-08-17 11:34:23 -07:00
If DoFilesBBS Then uImportFilesBBS;
2012-03-01 15:21:16 -08:00
If DoMassUpload Then uMassUpload;
If DoTopLists Then uTopLists;
2012-09-08 01:27:20 -07:00
If DoAllFiles Then uAllFilesList;
2013-03-18 22:48:11 -07:00
If DoEchoImport Then uEchoImport;
2013-03-31 22:08:13 -07:00
If DoEchoExport Then uEchoExport;
2012-09-08 01:27:20 -07:00
If DoMsgPurge Then uPurgeMessageBases;
If DoMsgPack Then uPackMessageBases;
2012-09-25 16:20:59 -07:00
If DoMsgPost Then uPostMessages;
2013-03-18 22:48:11 -07:00
If DoImportMB Then uImportMessageBases;
2012-02-29 17:45:16 -08:00
End.