home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS 1
/
BBS#1.iso
/
maximus
/
ublutils.arj
/
UBL2TM
/
UBL-2-TM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-29
|
11KB
|
334 lines
program UBL_TM;
{ Date: 12-02-1992 }
{ Convert UBLIST to TM.FON and TM.MEM }
type
{ Phone directory format for TeleMate 3.01 }
DIAL_RECORD = record { number of records = file length / FON_LEN }
name : string[30]; { name of remote system }
password : string[15]; { user password }
f1 : char; { filler }
script : string[8]; { name script file }
f2 : char;
log : string[8]; { name of log file }
f3 : char;
phone : string[20]; { phone number }
f4 : char;
para : string[9]; { COM parameter e.g. "115200N81" }
port : char; { COM Port '1'-'8', '0' use default (in TM.CFG) }
f5 : char;
total : string[5]; { Total number of connection }
f6 : string[2];
last : string[8]; { Last log on date "MM-DD-YY" }
f7 : char;
term : char; { terminal (T)ty (A)nsi VT(5)2 VT(1)02 }
connectTo : char; { Connect to (C)omputer (M)odem }
lineFeed : char; { Add line feed (Y)es (N)o }
carriageReturn : char; { Add carriage return (Y)es (N)o }
localEcho : char; { Local echo (Y)es (N)o }
wrap : char; { Auto wrap (Y)es (N)o }
destBs : char; { Destructive backspace (Y)es (N)o }
autoLog : char; { Auto log session (Y)es (N)o }
longDistance : char; { Long distance (Y)es (N)o }
stripHigh : char; { Strip high bit (Y)es (N)o }
tagSeparator : char; { 0=space, 1=enter, 2=comma }
guessInitial : char; { Use initial guessing (Y)es (N)o }
reserved : string[2]; { reserved for future usage }
prefix : char; { Prefix 1-4 }
suffix : char; { Suffix 1-4 }
protocol : char; { Protocol XYZRBGSTMAC }
cr : char; { End of line CR and LF}
lf : char;
end;
(*
} *dial_record[MAX_FON_SIZE];
char *dial_memo[MAX_FON_SIZE];
*)
{ format for UBLIST v.66 }
UBL_RECORD = record
len : char;
tag : char;
f1 : char;
BBS_name : array [1..26] of char;
f2 : array [1..2] of char;
phone : array [1..12] of char;
f3 : array [1..3] of char;
speed : array [1..19] of char;
f4 : array [1..2] of char;
weekday_time : array [1..11] of char;
f5 : array [1..3] of char;
weekend_time : array [1..3] of char;
f6 : array [1..3] of char;
SysOp : array [1..19] of char;
f7 : array [1..2] of char;
address : array [1..11] of char;
f8 : char;
voice_phone : array [1..8] of char;
f9 : char;
cr : char;
lf : char;
end;
UBL_RECOR = record
len : char;
rcd : UBL_RECORD;
end;
const
MAX_FON_SIZE = 1000;
FON_LEN = 131;
MEMO_LEN = 30;
month : array [1..12] of string[3] =
('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
var
buffer : string[255];
tstr : string;
fin : text;
fout1 : text; {file of DIAL_RECORD;}
fout2 : text;
ubl_rec : UBL_RECORD absolute buffer;
dial_memo : string[MEMO_LEN];
dial_tm : DIAL_RECORD;
parm_pass : string[15];
parm_speed: string[6];
parm_code : string[8];
i, line : integer;
Found : boolean;
{-------------------------------------------------------------------}
procedure Logo;
begin
WriteLn;
WriteLn('======================== FREE WARE ==============================');
WriteLn('UBL_V??.LST to TM.FON converter ver.1.0 Ivan Sinelobov');
WriteLn;
WriteLn('Night Director BBS: +7(095)938-0081, 2400/MNP5, 21:00-09:00//24h');
WriteLn('FIDONET: 2:5020/33.2; RELCOM: vano@comcp.msk.su');
WriteLn;
end;
{-------------------------------------------------------------------}
procedure Usage;
begin
WriteLn('Usage: ', ParamStr(0), ' UBL_file [/Sspeed] [/Ppassword] [/Ccode]');
WriteLn;
WriteLn(' UBL_file - UBLIST from MikDim s/h company ver.66 or later');
WriteLn(' speed - maximum baud rate (speed) of your modem');
WriteLn(' password - password to use at all BBS');
WriteLn(' code - phone number of your city (095 for Moscow, Russia)');
WriteLn;
WriteLn('Example: ', ParamStr(0), ' ubl_v66.lst /S2400 /Pmypass /C095-');
WriteLn;
Halt(1);
end;
{-------------------------------------------------------------------}
procedure Error;
begin
WriteLn;
WriteLn(chr(7), chr(7), '*** Error in command line ***');
WriteLn;
end;
{-------------------------------------------------------------------}
procedure NotFound;
begin
WriteLn;
WriteLn(chr(7), chr(7), '*** Can''t open file ***');
WriteLn;
end;
{-------------------------------------------------------------------}
function space(num : byte) : string;
var
i : byte;
res : string[255];
begin
res := '';
for num:=1 to num do
res := res + ' ';
space := res;
end;
{-------------------------------------------------------------------}
function AddBlankLeft(s : string; len : byte) : string;
begin
AddBlankLeft := space(len - Length(s)) + s;
end;
{-------------------------------------------------------------------}
function AddBlankRight(s : string; len : byte) : string;
begin
AddBlankRight := s + space(len - Length(s));
end;
{-------------------------------------------------------------------}
procedure InitDialRec;
begin
with dial_tm do begin
name := space(30); { name of remote system }
tstr := parm_pass; { user password }
password := AddBlankRight(tstr, 15);
f1 := ' '; { filler }
script := space(8); { name script file }
f2 := ' ';
log := space(8); { name of log file }
f3 := ' ';
phone := space(20); { phone number }
f4 := ' ';
tstr := parm_speed+'N81';{ COM parameter e.g. 115200N81 }
para := AddBlankLeft(tstr, 9);
port := '0'; { COM Port 1-8, 0 means default COM port }
f5 := ' ';
total := space(5); { Total number of connection }
f6 := space(2);
last := '..-..-..'; { Last log on date 'MM-DD-YY' }
f7 := ' ';
term := 'A'; { terminal (T)ty (A)nsi VT(5)2 VT(1)02 }
connectTo := 'M'; { Connect to (C)omputer (M)odem }
lineFeed := 'N'; { Add line feed (Y)es (N)o }
carriageReturn := 'Y'; { Add carriage return (Y)es (N)o }
localEcho := 'N'; { Local echo (Y)es (N)o }
wrap := 'Y'; { Auto wrap (Y)es (N)o }
destBs := 'Y'; { Destructive backspace (Y)es (N)o }
autoLog := 'N'; { Auto log session (Y)es (N)o }
longDistance := 'N';
stripHigh := 'N';
tagSeparator := 'N';
guessInitial := 'N';
reserved := space(2); { reserved for future usage }
prefix := '1'; { Prefix 1-4 }
suffix := '1'; { Suffix 1-4 }
protocol := 'Z'; { Protocol XYZRBGSTMAC }
cr := chr(13); { End of line CR and LF }
lf := chr(10);
end;
end;
{-------------------------------------------------------------------}
procedure FillOut;
begin
with dial_tm do begin
tstr := ubl_rec.BBS_name; { name of remote system }
name := AddBlankRight(tstr, 30);
tstr := ubl_rec.phone; { phone number }
if Pos(parm_code, tstr) = 1
then begin Found:= True; Delete(tstr, 1, Length(parm_code)); end;
phone := AddBlankRight(tstr, 20);
end;
end;
{-------------------------------------------------------------------}
procedure WriteOut;
begin
with dial_tm do begin
Write(fout1, name); { name of remote system }
Write(fout1, password); { user password }
Write(fout1, f1); { filler }
Write(fout1, script); { name script file }
Write(fout1, f2);
Write(fout1, log); { name of log file }
Write(fout1, f3);
Write(fout1, phone); { phone number }
Write(fout1, f4);
Write(fout1, para); { COM parameter e.g. 115200N81 }
Write(fout1, port); { COM Port 1-8, 0 means default COM port }
Write(fout1, f5);
Write(fout1, total); { Total number of connection }
Write(fout1, f6);
Write(fout1, last); { Last log on date 'MM-DD-YY' }
Write(fout1, f7);
Write(fout1, term); { terminal (T)ty (A)nsi VT(5)2 VT(1)02 }
Write(fout1, connectTo); { Connect to (C)omputer (M)odem }
Write(fout1, lineFeed); { Add line feed (Y)es (N)o }
Write(fout1, carriageReturn); { Add carriage return (Y)es (N)o }
Write(fout1, localEcho); { Local echo (Y)es (N)o }
Write(fout1, wrap); { Auto wrap (Y)es (N)o }
Write(fout1, destBs); { Destructive backspace (Y)es (N)o }
Write(fout1, autoLog); { Auto log session (Y)es (N)o }
Write(fout1, longDistance);
Write(fout1, stripHigh);
Write(fout1, tagSeparator);
Write(fout1, guessInitial);
Write(fout1, reserved); { reserved for future usage }
Write(fout1, prefix); { Prefix 1-4 }
Write(fout1, suffix); { Suffix 1-4 }
Write(fout1, protocol); { Protocol XYZRBGSTMAC }
WriteLn(fout1); { End of line CR and LF }
end;
end;
{-------------------------------------------------------------------}
procedure InitBuf;
begin
for i:=0 to 255 do buffer[i] := ' ';
end;
{-------------------------------------------------------------------}
begin
Logo;
if ParamCount < 1 then Usage;
parm_pass := space(15);
parm_speed := '1200';
parm_code := '000-';
Found := False;
for i:=2 to ParamCount do
begin
tstr := ParamStr(i);
if tstr[1] = '/' then
case tstr[2] of
'c', 'C': begin Delete(tstr, 1, 2); parm_code := tstr; end;
'p', 'P': begin Delete(tstr, 1, 2); parm_pass := tstr; end;
's', 'S': begin Delete(tstr, 1, 2); parm_speed:= tstr; end;
else begin Error; Usage; Halt(1) end;
end
else begin Error; Usage; Halt(1) end;
end;
Assign(fin, ParamStr(1));
{$I-} ReSet(fin); {$I+}
if IOResult <> 0 then begin NotFound; Halt(1) end;
Assign(fout1, 'TM.FON');
ReWrite(fout1);
Assign(fout2, 'TM.MEM');
ReWrite(fout2);
{skip up to '├'}
repeat
InitBuf;
ReadLn(fin, buffer);
until eof(fin) or (ubl_rec.tag = '├');
line := 0;
{loop}
repeat
for i:=0 to 255 do buffer[i] := chr(0);
ReadLn(fin, buffer);
Inc(line);
with ubl_rec do
begin
InitDialRec;
if (tag = '│') or (tag = '>') then
begin
Write(BBS_name, ' ', chr(13));
FillOut;
WriteOut;
WriteLn(fout2, line, ':', weekday_time, '/', weekend_time, ' ', SysOp);
end
else
WriteOut;
end; {with ubl_rec}
until eof(fin) or (ubl_rec.tag = '└');
Write('All done. ', chr(13));
close(fout1);
close(fout2);
if Not Found then
begin
Write(chr(7), '*** Warning: Phone code "', parm_code, '" not found ***');
end;
WriteLn;
end.
{-------------------------------------------------------------------}