Added Import of FidoNet .NA files

This commit is contained in:
mysticbbs 2012-02-29 22:27:06 -05:00
parent ca5d090c37
commit 95fef37c5a
3 changed files with 138 additions and 4 deletions

View File

@ -43,7 +43,7 @@
; configured within Mystic BBS. default values are also taken from ; configured within Mystic BBS. default values are also taken from
; the system configuration for origin line, colors, etc. ; the system configuration for origin line, colors, etc.
netaddress = 1:1/124 netaddress = 1:1/1
acs_list = acs_list =
acs_read = acs_read =
acs_post = acs_post =

View File

@ -24,9 +24,87 @@ Const
Header_GENERAL = 'General'; Header_GENERAL = 'General';
Header_IMPORTNA = 'Import_FIDONET.NA'; Header_IMPORTNA = 'Import_FIDONET.NA';
Function strAddr2Str (Addr : RecEchoMailAddr) : String;
Function GenerateMBaseIndex : LongInt;
Function IsDupeMBase (FN: String) : Boolean;
Procedure AddMessageBase (Var MBase: RecMessageBase);
Implementation Implementation
Uses Uses
m_Strings; m_Strings;
Function strAddr2Str (Addr : RecEchoMailAddr) : String;
Var
Temp : String[20];
Begin
Temp := strI2S(Addr.Zone) + ':' + strI2S(Addr.Net) + '/' +
strI2S(Addr.Node);
If Addr.Point <> 0 Then Temp := Temp + '.' + strI2S(Addr.Point);
Result := Temp;
End;
Function IsDupeMBase (FN: String) : Boolean;
Var
MBaseFile : File of RecMessageBase;
MBase : RecMessageBase;
Begin
Result := False;
Assign (MBaseFile, bbsConfig.DataPath + 'mbases.dat');
{$I-} Reset (MBaseFile); {$I+}
If IoResult <> 0 Then Exit;
While Not Eof(MBaseFile) Do Begin
Read (MBaseFile, MBase);
{$IFDEF FS_SENSITIVE}
If MBase.FileName = FN Then Begin
{$ELSE}
If strUpper(MBase.FileName) = strUpper(FN) Then Begin
{$ENDIF}
Result := True;
Break;
End;
End;
Close (MBaseFile);
End;
Function GenerateMBaseIndex : LongInt;
Var
MBaseFile : File of RecMessageBase;
MBase : RecMessageBase;
Begin
Assign (MBaseFile, bbsConfig.DataPath + 'mbases.dat');
Reset (MBaseFile);
Result := FileSize(MBaseFile);
While Not Eof(MBaseFile) Do Begin
Read (MBaseFile, MBase);
If MBase.Index = Result Then Begin
Inc (Result);
Reset (MBaseFile);
End;
End;
Close (MBaseFile);
End;
Procedure AddMessageBase (Var MBase: RecMessageBase);
Var
MBaseFile : File of RecMessageBase;
Begin
Assign (MBaseFile, bbsConfig.DataPath + 'mbases.dat');
Reset (MBaseFile);
Seek (MBaseFile, FileSize(MBaseFile));
Write (MBaseFile, MBase);
Close (MBaseFile);
End;
End. End.

View File

@ -21,6 +21,9 @@ Var
Buffer : Array[1..2048] of Byte; Buffer : Array[1..2048] of Byte;
TagName : String; TagName : String;
BaseName : String; BaseName : String;
MBaseFile : File of RecMessageBase;
MBase : RecMessageBase;
Count : Byte;
Begin Begin
ProcessName ('Import FIDONET.NA', True); ProcessName ('Import FIDONET.NA', True);
ProcessResult (rWORKING, False); ProcessResult (rWORKING, False);
@ -45,9 +48,62 @@ Begin
If (Str[1] = ';') or (Str = '') Then Continue; If (Str[1] = ';') or (Str = '') Then Continue;
TagName := strWordGet(1, Str, ' '); TagName := strWordGet(1, Str, ' ');
BaseName := strStripB(strWordGet(2, Str, ' '), ' '); BaseName := strStripB(Copy(Str, Pos(' ', Str), 255), ' ');
ProcessStatus (BaseName); ProcessStatus (BaseName);
If Not IsDupeMBase(TagName) Then Begin
FillChar (MBase, SizeOf(MBase), #0);
Inc (CreatedBases);
MBase.Index := GenerateMBaseIndex;
MBase.Name := BaseName;
MBase.QWKName := TagName;
MBase.NewsName := strReplace(BaseName, ' ', '.');
MBase.FileName := TagName;
MBase.Path := bbsConfig.MsgsPath;
MBase.NetType := 1;
MBase.ColQuote := bbsConfig.ColorQuote;
MBase.ColText := bbsConfig.ColorText;
MBase.ColTear := bbsConfig.ColorTear;
MBase.ColOrigin := bbsConfig.ColorOrigin;
MBase.ColKludge := bbsConfig.ColorKludge;
MBase.Origin := bbsConfig.Origin;
MBase.BaseType := strS2I(INI.ReadString(Header_IMPORTNA, 'base_format', '0'));
MBase.ListACS := INI.ReadString(Header_IMPORTNA, 'acs_list', '');
MBase.ReadACS := INI.ReadString(Header_IMPORTNA, 'acs_read', '');
MBase.PostACS := INI.ReadString(Header_IMPORTNA, 'acs_post', '');
MBase.NewsACS := INI.ReadString(Header_IMPORTNA, 'acs_news', '');
MBase.SysopACS := INI.ReadString(Header_IMPORTNA, 'acs_sysop', 's255');
MBase.Header := INI.ReadString(Header_IMPORTNA, 'header', 'msghead');
MBase.RTemplate := INI.ReadString(Header_IMPORTNA, 'read_template', 'ansimrd');
MBase.ITemplate := INI.ReadString(Header_IMPORTNA, 'index_template', 'ansimlst');
MBase.MaxMsgs := strS2I(INI.ReadString(Header_IMPORTNA, 'max_msgs', '500'));
MBase.MaxAge := strS2I(INI.ReadString(Header_IMPORTNA, 'max_msgs_age', '365'));
MBase.DefNScan := strS2I(INI.ReadString(Header_IMPORTNA, 'new_scan', '1'));
MBase.DefQScan := strS2I(INI.ReadString(Header_IMPORTNA, 'qwk_scan', '1'));
MBase.NetAddr := 1;
For Count := 1 to 30 Do
If strAddr2Str(bbsConfig.NetAddress[Count]) = INI.ReadString(Header_IMPORTNA, 'netaddress', '') Then Begin
MBase.NetAddr := Count;
Break;
End;
If INI.ReadString(Header_IMPORTNA, 'use_autosig', '1') = '1' Then
MBase.Flags := MBase.Flags OR MBAutoSigs;
If INI.ReadString(Header_IMPORTNA, 'use_realname', '0') = '1' Then
MBase.Flags := MBase.Flags OR MBRealNames;
If INI.ReadString(Header_IMPORTNA, 'kill_kludge', '1') = '1' Then
MBase.Flags := MBase.Flags OR MBKillKludge;
If INI.ReadString(Header_IMPORTNA, 'private_base', '0') = '1' Then
MBase.Flags := MBase.Flags OR MBPrivate;
AddMessageBase(MBase);
End;
End; End;
Close (InFile); Close (InFile);
@ -55,8 +111,8 @@ Begin
ProcessStatus ('Created |15' + strI2S(CreatedBases) + ' |07base(s)'); ProcessStatus ('Created |15' + strI2S(CreatedBases) + ' |07base(s)');
ProcessResult (rDONE, True); ProcessResult (rDONE, True);
BarOne.Update(100, 100); BarOne.Update (100, 100);
BarAll.Update(ProcessPos, ProcessTotal); BarAll.Update (ProcessPos, ProcessTotal);
End; End;
End. End.