home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 189.img / TCS120S.ZIP / PROT.PAS < prev    next >
Pascal/Delphi Source File  |  1987-05-07  |  4KB  |  164 lines

  1. overlay function protocolxfer (send,crcmode:boolean; fn:lstr):boolean;
  2.  
  3.   Function FindLine(comp,abt:lstr):boolean;
  4.   var tfile:text;
  5.       b:anystr;
  6.       done,i:boolean;
  7.   begin
  8.     findline:=false;
  9.     if exist ('complete') then begin
  10.       Assign(tfile,'complete');
  11.       Reset(tfile);
  12.       While not EOF(tfile) and (Not I) and (not Done) do
  13.       Begin
  14.         ReadLn(tfile,B);
  15.         if (Pos(upcase(abt),upcase(B))>0) and (abt<>'') then begin
  16.           done:=true;
  17.           i:=false;
  18.         end;
  19.         If (Pos(upcase(comp), upcase(B))>0) and (comp<>'') then begin
  20.           i:= True;
  21.           done:=true;
  22.         end;
  23.         FindLine:=i;
  24.       End;
  25.       textclose (tfile);
  26.     end;
  27.   end;
  28.  
  29.   procedure SetupXFer(prot:mstr; CmdLine:lstr; Send:boolean);
  30.   var fil:file;
  31.   begin
  32.     writeln(usr,' -- ',prot,' Invoked ');
  33.     write(prot);
  34.     if send then write(' Send ') else write(' Receive ');
  35.     writeln('Invoked.');
  36.     starttimer(numminsxfer);
  37.     assign(fil,'kermie');
  38.     if exist('kermie') then erase(fil);
  39.     if Zmodem and not send then begin
  40.       clearitall;
  41.       delay(2000);
  42.       clearitall;
  43.       repeat until hungupon or (numchars>0);
  44.     end;
  45.     uninit;
  46.     dos_shell(CmdLine);
  47.     if hungupon then exit;
  48.     setparam(usecom,baudrate,parity);
  49.   end;
  50.  
  51.   Function SendKermit:boolean;
  52.   var Haleh:anystr;
  53.   begin
  54.     starttimer(numminsxfer);
  55.     haleh:='kermit send '+fn+' >complete';
  56.     SetupXfer('Super Kermit',haleh,true);
  57.     SendKermit:=FindLine('100%','Failed');
  58.     stoptimer (numminsxfer);
  59.   end;
  60.  
  61.   Function ReceiveKermit:boolean;
  62.   var Haleh:anystr;
  63.   begin
  64.     starttimer(numminsxfer);
  65.     haleh:='kermit receive '+fn+' >complete';
  66.     SetupXfer('Super Kermit',haleh,false);
  67.     ReceiveKermit:=FindLine('100%','Failed');
  68.     stoptimer (numminsxfer);
  69.   end;
  70.  
  71.   Function SendXYModem(ymdm:boolean):boolean;
  72.   var Haleh:anystr;
  73.       Chksum:anystr;
  74.   begin
  75.     starttimer(numminsxfer);
  76.     haleh:='zmodem sx ';
  77.     if ymdm then haleh:=haleh+'-k ';
  78.     haleh:=haleh+fn;
  79.     if ymdm then ChkSum:='YModem-CRC' else Chksum:='XModem-';
  80.     if crcmode and not ymdm then
  81.       Chksum:=Chksum+'CRC' else Chksum:=Chksum+'Checksum';
  82.     SetupXfer(Chksum,haleh,true);
  83.     SendXYModem:=Exist('Complete');
  84.     stoptimer (numminsxfer);
  85.   end;
  86.  
  87.   Function ReceiveXYModem:boolean;
  88.   var Haleh:anystr;
  89.   begin
  90.     starttimer(numminsxfer);
  91.     haleh:='zmodem rx ';
  92.     if crcmode then haleh:=haleh+'-c ';
  93.     haleh:=haleh+fn;
  94.     SetupXfer('X/YModem Receive',haleh,false);
  95.     ReceiveXYModem:=Exist('Complete');
  96.     stoptimer (numminsxfer);
  97.   end;
  98.  
  99.   Function SendZmodem:boolean;
  100.   var Haleh:anystr;
  101.   begin
  102.     starttimer(numminsxfer);
  103.     haleh:='zmodem sz '+fn;
  104.     SetupXfer('Zmodem',haleh,true);
  105.     SendZmodem:=exist('Complete');
  106.     stoptimer (numminsxfer);
  107.   end;
  108.  
  109.   function ReceiveZmodem:boolean;
  110.   var Haleh:anystr;
  111.   begin
  112.     starttimer(numminsxfer);
  113.     haleh:='zmodem rz '+fn;
  114.     SetupXfer('Zmodem',haleh,false);
  115.     ReceiveZmodem:=Exist('Complete');
  116.     stoptimer (numminsxfer);
  117.   end;
  118.  
  119.   function SendWxmodem:boolean;
  120.   var Haleh:anystr;
  121.   begin
  122.     starttimer(numminsxfer);
  123.     haleh:='wxterm S '+fn+' '+strr(baudrate);
  124.     SetupXfer('WXModem',haleh,true);
  125.     stoptimer (numminsxfer);
  126.   end;
  127.  
  128.   Function ReceiveWxmodem :boolean;
  129.   var Haleh:anystr;
  130.   begin
  131.     starttimer(numminsxfer);
  132.     haleh:='wxterm R '+fn+' '+strr(baudrate);
  133.     SetupXfer('WXModem',haleh,false);
  134.     if exist ('complete') then ReceiveWxmodem:=true;
  135.     stoptimer (numminsxfer);
  136.   end;
  137.  
  138. begin
  139.  
  140.   If Wxmodem then if Send then protocolxfer:=SendWxmodem else
  141.     protocolxfer:=ReceiveWxmodem;
  142.  
  143. {  If YmodemG then if Send then protocolxfer:=SendXYModem(true) else
  144.     protocolxfer:=ReceiveXYModem(true); }
  145.  
  146.   If Zmodem then if Send then protocolxfer:=SendZmodem else
  147.     protocolxfer:=ReceiveZmodem;
  148.  
  149.   if Kermit then if Send then protocolxfer:=SendKermit else
  150.     protocolxfer:=ReceiveKermit;
  151.  
  152.   if not Kermit and not Wxmodem and not Zmodem then
  153.     if Send then protocolxfer:=SendXYModem(ymodem)
  154.       else protocolxfer:=ReceiveXYModem;
  155.  
  156.   Ymodem:=false;
  157.   Zmodem:=false;
  158.   Wxmodem:=false;
  159.   Kermit:=false;
  160.   CLink:=false;
  161.   YModemG:=false;
  162.  
  163. end;
  164.