2013-09-05 18:07:25 -07:00
|
|
|
Program QwkPoll;
|
|
|
|
|
|
|
|
{$I M_OPS.PAS}
|
|
|
|
|
|
|
|
Uses
|
|
|
|
m_DateTime,
|
|
|
|
m_Strings,
|
|
|
|
m_FileIO,
|
|
|
|
m_TCP_Client_FTP,
|
|
|
|
BBS_Records,
|
|
|
|
BBS_DataBase,
|
|
|
|
BBS_MsgBase_QWK;
|
|
|
|
|
|
|
|
Var
|
|
|
|
TempPath : String;
|
|
|
|
|
2013-09-09 21:48:27 -07:00
|
|
|
Function PollByQWKNet (QwkNet: RecQwkNetwork) : Boolean;
|
|
|
|
Var
|
|
|
|
QWK : TQwkEngine;
|
|
|
|
FTP : TFTPClient;
|
|
|
|
User : RecUser;
|
|
|
|
SentFile : Boolean;
|
|
|
|
Begin
|
|
|
|
Result := False;
|
|
|
|
SentFile := False;
|
|
|
|
|
|
|
|
If (QwkNet.MemberType <> 1) or
|
|
|
|
(QwkNet.PacketID = '') or
|
|
|
|
(QwkNet.ArcType = '') Then Exit;
|
|
|
|
|
|
|
|
WriteLn ('- Exchanging Mail for ' + QwkNet.Description);
|
|
|
|
|
|
|
|
DirClean (TempPath, '');
|
|
|
|
|
|
|
|
User.Handle := QwkNet.Login;
|
|
|
|
User.QwkNetwork := QwkNet.Index;
|
|
|
|
|
|
|
|
QWK := TQwkEngine.Create (TempPath, QwkNet.PacketID, 1, User);
|
|
|
|
|
|
|
|
QWK.IsNetworked := True;
|
|
|
|
QWK.IsExtended := QwkNet.UseQWKE;
|
|
|
|
|
|
|
|
QWK.ExportPacket(True);
|
|
|
|
|
|
|
|
ExecuteArchive (TempPath, TempPath + QwkNet.PacketID + '.rep', QwkNet.ArcType, TempPath + '*', 1);
|
|
|
|
|
|
|
|
WriteLn (' - Exported @' + QwkNet.PacketID + '.rep -> ', QWK.TotalMessages, ' msgs ');
|
|
|
|
WriteLn (' - Connecting via FTP to ' + QWkNet.HostName);
|
|
|
|
|
|
|
|
If QWK.TotalMessages = 0 Then
|
|
|
|
DirClean (TempPath, '');
|
|
|
|
|
|
|
|
FTP := TFTPClient.Create(bbsCfg.inetInterface);
|
|
|
|
|
|
|
|
If FTP.OpenConnection(QwkNet.HostName) Then Begin
|
|
|
|
WriteLn (' - Connected');
|
|
|
|
|
|
|
|
If FTP.Authenticate(QwkNet.Login, QwkNet.Password) Then Begin
|
|
|
|
WriteLn (' - Logged in as ', QwkNet.Login);
|
|
|
|
|
2013-09-16 13:31:39 -07:00
|
|
|
If QWK.TotalMessages > 0 Then Begin
|
|
|
|
WriteLn (' - Sending reply packet');
|
|
|
|
|
|
|
|
Case FTP.SendFile(QwkNet.UsePassive, TempPath + QwkNet.PacketID + '.rep') of
|
|
|
|
ftpResOK : SentFile := True;
|
|
|
|
ftpResBadData : WriteLn (' - Unable to open data connection');
|
2013-09-17 19:28:47 -07:00
|
|
|
Else
|
|
|
|
WriteLn (' - Failed');
|
2013-09-16 13:31:39 -07:00
|
|
|
End;
|
|
|
|
End;
|
2013-09-09 21:48:27 -07:00
|
|
|
|
|
|
|
WriteLn (' - Downloading QWK packet');
|
|
|
|
|
2013-09-17 19:28:47 -07:00
|
|
|
Case FTP.GetFile(QwkNet.UsePassive, TempPath + QwkNet.PacketID + '.qwk') of
|
2013-09-16 13:31:39 -07:00
|
|
|
ftpResOK : WriteLn (' - OK: ' + QwkNet.PacketID + '.qwk', ' (' + strComma(FileByteSize(TempPath + QwkNet.PacketID + '.qwk')) + ' bytes)');
|
|
|
|
ftpResFailed : WriteLn (' - Failed');
|
|
|
|
ftpResBadData : WriteLn (' - Unable to open data connection');
|
2013-09-17 19:28:47 -07:00
|
|
|
ftpResNoFile : WriteLn (' - Packet does not exist on remote');
|
2013-09-16 13:31:39 -07:00
|
|
|
End;
|
2013-09-09 21:48:27 -07:00
|
|
|
End;
|
|
|
|
End;
|
2013-09-07 11:37:42 -07:00
|
|
|
|
2013-09-05 18:07:25 -07:00
|
|
|
FTP.Free;
|
2013-09-09 21:48:27 -07:00
|
|
|
|
|
|
|
If (QWK.TotalMessages > 0) and Not SentFile Then Begin
|
|
|
|
WriteLn (' - Send of REP failed; reseting export pointers');
|
|
|
|
|
|
|
|
QWK.ResetSentFlagByQLR;
|
|
|
|
End;
|
|
|
|
|
|
|
|
If FileExist(TempPath + QwkNet.PacketID + '.qwk') Then Begin
|
|
|
|
WriteLn (' - Unpacking QWK packet');
|
|
|
|
|
|
|
|
ExecuteArchive (TempPath, TempPath + QwkNet.PacketID + '.qwk', QwkNet.ArcType, '*', 2);
|
|
|
|
|
|
|
|
WriteLn (' - Importing QWK packet');
|
|
|
|
|
2013-09-17 19:28:47 -07:00
|
|
|
filecopy(temppath + qwknet.packetid + '.qwk', 'd:\s7\vert.qwk');
|
|
|
|
|
2013-09-09 21:48:27 -07:00
|
|
|
If QWK.ImportPacket(True) Then
|
|
|
|
WriteLn (' - Imported ', QWK.RepOK, ' messages (', QWK.RepFailed, ' failed)')
|
|
|
|
Else
|
|
|
|
WriteLn (' - Unable to find QWK packet');
|
2013-09-17 19:28:47 -07:00
|
|
|
End;
|
2013-09-09 21:48:27 -07:00
|
|
|
|
2013-09-05 18:07:25 -07:00
|
|
|
QWK.Free;
|
|
|
|
|
|
|
|
DirClean (TempPath, '');
|
|
|
|
|
|
|
|
WriteLn;
|
|
|
|
End;
|
|
|
|
|
2013-09-07 20:02:25 -07:00
|
|
|
Procedure ImportPacket (QwkNet: RecQwkNetwork; Path: String);
|
|
|
|
Var
|
|
|
|
QWK : TQwkEngine;
|
|
|
|
User : RecUser;
|
|
|
|
Begin
|
|
|
|
WriteLn ('- Importing ' + Path + QwkNet.PacketID + '.qwk');
|
|
|
|
|
|
|
|
ExecuteArchive (TempPath, Path + QwkNet.PacketID + '.qwk', QwkNet.ArcType, '*', 2);
|
|
|
|
|
2013-09-09 21:48:27 -07:00
|
|
|
User.Handle := QwkNet.Login;
|
2013-09-07 20:02:25 -07:00
|
|
|
User.QwkNetwork := QwkNet.Index;
|
|
|
|
|
|
|
|
QWK := TQwkEngine.Create (TempPath, QwkNet.PacketID, 1, User);
|
|
|
|
|
|
|
|
QWK.IsNetworked := True;
|
|
|
|
QWK.IsExtended := QwkNet.UseQWKE;
|
|
|
|
|
2013-09-09 21:48:27 -07:00
|
|
|
If QWK.ImportPacket(True) Then
|
|
|
|
WriteLn (' - Imported ', QWK.RepOK, ' messages (', QWK.RepFailed, ' failed)')
|
|
|
|
Else
|
|
|
|
WriteLn (' - Unable to find QWK packet');
|
2013-09-07 20:02:25 -07:00
|
|
|
|
|
|
|
QWK.Free;
|
|
|
|
End;
|
|
|
|
|
|
|
|
Procedure ExportPacket (QwkNet: RecQwkNetwork; Path: String);
|
|
|
|
Var
|
|
|
|
QWK : TQwkEngine;
|
|
|
|
User : RecUser;
|
|
|
|
Begin
|
|
|
|
WriteLn ('- Exporting ' + Path + QwkNet.PacketID + '.rep');
|
|
|
|
|
2013-09-09 21:48:27 -07:00
|
|
|
User.Handle := QwkNet.Login;
|
2013-09-07 20:02:25 -07:00
|
|
|
User.QwkNetwork := QwkNet.Index;
|
|
|
|
|
|
|
|
QWK := TQwkEngine.Create (TempPath, QwkNet.PacketID, 1, User);
|
|
|
|
|
|
|
|
QWK.IsNetworked := True;
|
|
|
|
QWK.IsExtended := QwkNet.UseQWKE;
|
|
|
|
|
|
|
|
QWK.ExportPacket(True);
|
|
|
|
|
|
|
|
If QWK.TotalMessages > 0 Then
|
|
|
|
ExecuteArchive (TempPath, Path + QwkNet.PacketID + '.rep', QwkNet.ArcType, TempPath + '*', 1);
|
|
|
|
|
2013-09-12 14:57:03 -07:00
|
|
|
DirClean (TempPath, '');
|
2013-09-07 20:02:25 -07:00
|
|
|
|
|
|
|
WriteLn (' - Exported ', QWK.TotalMessages, ' messages');
|
|
|
|
|
|
|
|
QWK.Free;
|
|
|
|
End;
|
|
|
|
|
2013-09-05 18:07:25 -07:00
|
|
|
Var
|
|
|
|
Str : String;
|
|
|
|
F : File;
|
|
|
|
QwkNet : RecQwkNetwork;
|
2013-09-06 13:32:58 -07:00
|
|
|
Mode : Byte;
|
2013-09-05 18:07:25 -07:00
|
|
|
Begin
|
|
|
|
WriteLn;
|
|
|
|
WriteLn ('QWKPOLL Version ' + mysVersion);
|
|
|
|
WriteLn;
|
|
|
|
|
|
|
|
Case bbsCfgStatus of
|
|
|
|
1 : WriteLn ('Unable to read MYSTIC.DAT');
|
|
|
|
2 : WriteLn ('Data file version mismatch');
|
|
|
|
End;
|
|
|
|
|
|
|
|
If bbsCfgStatus <> 0 Then Halt(1);
|
|
|
|
|
|
|
|
TempPath := bbsCfg.SystemPath + 'tempqwk' + PathChar;
|
|
|
|
|
|
|
|
DirCreate (TempPath);
|
|
|
|
|
|
|
|
WriteLn ('Program session start at ' + FormatDate(CurDateDT, 'NNN DD YYYY HH:II:SS'));
|
|
|
|
WriteLn;
|
|
|
|
|
|
|
|
Str := strUpper(strStripB(ParamStr(1), ' '));
|
|
|
|
|
2013-09-06 13:32:58 -07:00
|
|
|
If strUpper(ParamStr(2)) = 'EXPORT' Then
|
|
|
|
Mode := 1
|
|
|
|
Else
|
|
|
|
If strUpper(ParamStr(2)) = 'IMPORT' Then
|
|
|
|
Mode := 2
|
|
|
|
Else
|
|
|
|
Mode := 0;
|
|
|
|
|
2013-09-05 18:07:25 -07:00
|
|
|
If (Str = 'ALL') Then Begin
|
|
|
|
Assign (F, bbsCfg.DataPath + 'qwknet.dat');
|
|
|
|
|
|
|
|
If ioReset (F, SizeOf(RecQwkNetwork), fmRWDN) Then Begin
|
|
|
|
While Not Eof(F) Do Begin
|
|
|
|
ioRead (F, QwkNet);
|
|
|
|
|
2013-09-07 12:52:38 -07:00
|
|
|
Case Mode of
|
2013-09-07 20:52:18 -07:00
|
|
|
0 : PollByQwkNet(QwkNet);
|
2013-09-07 20:02:25 -07:00
|
|
|
1 : ExportPacket(QwkNet, DirSlash(ParamStr(3)));
|
|
|
|
2 : ImportPacket(QwkNet, DirSlash(ParamStr(3)));
|
2013-09-07 12:52:38 -07:00
|
|
|
End;
|
2013-09-05 18:07:25 -07:00
|
|
|
End;
|
|
|
|
|
|
|
|
Close (F);
|
|
|
|
End;
|
|
|
|
End Else
|
|
|
|
If strS2I(Str) > 0 Then Begin
|
|
|
|
If GetQwkNetByIndex(strS2I(Str), QwkNet) Then
|
2013-09-07 12:52:38 -07:00
|
|
|
Case Mode of
|
2013-09-07 20:52:18 -07:00
|
|
|
0 : PollByQwkNet(QwkNet);
|
2013-09-07 20:02:25 -07:00
|
|
|
1 : ExportPacket(QwkNet, DirSlash(ParamStr(3)));
|
|
|
|
2 : ImportPacket(QwkNet, DirSlash(ParamStr(3)));
|
2013-09-07 12:52:38 -07:00
|
|
|
End;
|
2013-09-05 18:07:25 -07:00
|
|
|
End Else Begin
|
|
|
|
WriteLn ('Invalid command line.');
|
|
|
|
WriteLn;
|
2013-09-06 13:32:58 -07:00
|
|
|
WriteLn ('Syntax: QWKPOLL [ALL]');
|
|
|
|
WriteLn (' [Qwk Network Index]');
|
2013-09-07 12:52:38 -07:00
|
|
|
WriteLn;
|
2013-09-06 13:32:58 -07:00
|
|
|
WriteLn (' [EXPORT] [QwkNet Index] [PATH TO CREATE REP]');
|
|
|
|
WriteLn (' [IMPORT] [QwkNet Index] [PATH OF QWK PACKET]');
|
|
|
|
WriteLn;
|
|
|
|
WriteLn ('Ex: QWKPOLL ALL - Exchange with ALL QWK hubs via FTP');
|
|
|
|
WriteLn (' QWKPOLL 1 - Exchange with only Qwk Network #1');
|
|
|
|
WriteLn (' QWKPOLL 1 EXPORT /bbs/qwknet - Create REP packet in /bbs/qwknet');
|
|
|
|
WriteLn (' QWKPOLL 1 IMPORT /bbs/qwknet - Import QWK packet from /bbs/qwknet');
|
2013-09-05 18:07:25 -07:00
|
|
|
WriteLn;
|
2013-09-06 13:32:58 -07:00
|
|
|
WriteLn ('NOTE: QWKPOLL automatically deals with QWK and REP packets during polling');
|
|
|
|
WriteLn (' The export and import functions are not needed, and only provided');
|
|
|
|
WriteLn (' for systems that may want to use an alternative transport method');
|
2013-09-05 18:07:25 -07:00
|
|
|
WriteLn;
|
|
|
|
End;
|
|
|
|
End.
|