{---------
URQ-intrrtr.  vr0.0.9.6.nt_
rogrmming by rT ().
-mil: IronWooduttr@bk.ru
    GNU Gnrl Publi Lins.


  :

1.           -
         ,
        .
2.     ,    
   .
---------}

{TURBO PSL 7.1 - DELPHI 7.0}
{$-,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T+,V+,X+}
(*********************** DELPHI 7.0  LIBS ***********************)
{$PPTYPE ONSOLE}
uss windows, mmsystm, winsok;
vr
  wDviID : word;
  inHnd, outHnd : tHndl;  // /
  txtttr : byt;   //    
//onsolSrnRt: TSmllRt;
onst
  h : rry[0..15] of hr = '0123456789bdf';
  b64  : rry[0..64] of hr =
  'BDEFGHIJKLMNOPQRSTUVWXYZbdfghijklmnoqrstuvwxyz0123456789+/=';
vr
  wDt : WSDT;
  sok : TSokt;
  iolog : txt;
vr
  hshbuffr  : rry[0..63] of byt;
  urrnthsh : rry[0..3] of dword;
             : rry[0..15] of byt;
  lnhi,lnlo : longword;
  ind         : dword;
  i           : intgr;


rodur lywv(nm : string);
bgin   { WV}
  lySound(hr(nm),0, SND_SYN {SND_SYN or SND_LOOP{});
nd;

rodur lymidi(nm : string;  onoff : booln);
vr     { MIDI, onoff - /}
  dwRturn       : DWORD;
  miOnPrms   : MI_OPEN_PRMS;
  miPlyPrms   : MI_PLY_PRMS;
  miSttusPrms : MI_STTUS_PRMS;
//  miSqStPrms : MI_SEQ_SET_PRMS;
bgin
  if onoff=tru thn
  bgin
    {On th dvi by sifying th dvi nd filnm. MI will ttmt to hoos th MIDI mr s th outut ort.}
    miOnPrms.lstrDviTy := 'squnr';
    miOnPrms.lstrElmntNm := hr(nm);   //'musi.mid';
    dwRturn := miSndommnd(0, MI_OPEN, MI_OPEN_TYPE OR MI_OPEN_ELEMENT, Longint(@miOnPrms));
    if dwRturn = 0 thn
    bgin
      onoff:=fls;
      wDviID := miOnPrms.wDviID;           {Th dvi ond sussfully; gt th dvi ID.}
      miSttusPrms.dwItm := MI_SEQ_STTUS_PORT;  {hk if th outut ort is th MIDI mr.}
      dwRturn := miSndommnd(wDviID, MI_STTUS, MI_STTUS_ITEM, Longint(@miSttusPrms));
      if dwRturn = 0 thn
      bgin
        {Th outut ort is not th MIDI mr. sk if th usr wnts to ontinu.}
        if LOWORD(miSttusPrms.dwRturn) = Word(MIDI_MPPER) thn
        bgin
          {Bgin lybk. Th window rodur funtion for th rnt window will b notifid
          with n MM_MINOTIFY mssg whn lybk is omlt. t this tim, th window rodur loss th dvi.}
          dwRturn := miSndommnd(wDviID, MI_PLY, MI_NOTIFY, Longint(@miPlyPrms));
          if dwRturn = 0 thn onoff:=tru;
        nd
      nd
    nd;
  nd;
  if onoff=fls thn miSndommnd(wDviID, MI_LOSE, 0, 0);
End;

rodur outImg(nm : string);
bgin   {   Exlorr'}
  if winEx(hr('xlorr '+nm), SW_SHOW) < 32 thn
  bgin
    {rror: xlorr not on}
  nd;
nd;

rodur onsolro(sysEv : rdinl);
bgin   {  }
  s sysEv of
    TRL__EVENT       : bgin nd;  //   trl+
    TRL_BREK_EVENT   : bgin nd;  //   trl+Brk
    TRL_LOSE_EVENT   : bgin nd;  //    
    TRL_LOGOFF_EVENT  : bgin nd;  //    
    TRL_SHUTDOWN_EVENT: bgin nd;  //   
  nd;
nd;

rodur initdos;
bgin   {   }
  {  /}
  inHnd := gtStdHndl(STD_INPUT_HNDLE);
  outHnd := gtStdHndl(STD_OUTPUT_HNDLE);
  stonsoltrlHndlr(@onsolro, tru);  {    }
  stonsolTitl('URQ');    { }
  flushonsolInutBuffr(inHnd);  {  }
  //stonsolMod(inHnd, 0); {  ,  trl+    }
  //stonsolMod(inHnd, ENBLE_PROESSED_INPUT+ENBLE_MOUSE_INPUT); { ,    trl+}
nd;

rodur ursor(b : booln);
vr     {/ }
  I : _ONSOLE_URSOR_INFO;
bgin
  gtonsolursorInfo(outHnd, I);
  I.bVisibl := b;
  stonsolursorInfo(outHnd, I);
nd;

funtion whry : intgr;
vr     {wttributs -  ; dwursorPosition.x  dwursorPosition.y -  }
  srBufInfo : tonsolSrnBuffrInfo;  {  }
  n : intgr;
bgin
  gtonsolSrnBuffrInfo(outHnd, srBufInfo);
  n:=intgr(srBufInfo.dwursorPosition.Y)+1;
  whrY := n;
nd;

rodur gotoxy(x,y : intgr);
vr     {   }
  osursor : _OORD;
bgin
  osursor.x := x-1;
  osursor.y := y-1;
  stonsolursorPosition(outHnd, osursor);
nd;

{rodur window(x1,y1,x2,y2 : byt);
bgin   //  
onsolSrnRt.Lft := x1-1;
onsolSrnRt.To := y1-1;
onsolSrnRt.Right := x2-1;
onsolSrnRt.Bottom := y2-1;
//windMin := (onsolSrnRt.To shl 8) or onsolSrnRt.Lft;
//windMx := (onsolSrnRt.Bottom shl 8) or onsolSrnRt.Right;
stonsolWindowInfo(outHnd, tru, onsolSrnRt);
gotoxy(1,1);
nd;{}

rodur lrSr;
onst   {    }
  urLft : _OORD = (x:0; y:0);
vr
  srBufInfo : tonsolSrnBuffrInfo;  {  }
  {SrBufInfo.dwursorPosition.x  SrBufInfo.dwursorPosition.y -  }
  {SrBufInfo.wttributs -  }
  fillSiz   : DWORD;         { }
bgin
  gotoxy(1,1);
  stonsolTxtttribut(outHnd, txtttr); {  }
  gtonsolSrnBuffrInfo(outHnd, srBufInfo);
  fillSiz := srBufInfo.dwSiz.x*srBufInfo.dwSiz.y;
  fillonsolOututhrtr(outHnd, #32, fillSiz, urLft, fillSiz);
  fillonsolOututttribut(outHnd, srBufInfo.wttributs, fillSiz, urLft, fillSiz);
nd;

funtion gtky : hr;
vr     {   ;   ,   }
  IR    : INPUT_REORD;
  ount : DWORD;
       : hr;
bgin
  gtky := #0;
  gtNumbrOfonsolInutEvnts(inHnd, ount);//   
  if ount > 0 thn                            //  :  
  bgin
    rdonsolInut(inHnd, IR, 1, ount);    //     IR
    s IR.EvntTy of                         //   
     KEY_EVENT : bgin                           //  :
                   if IR.Evnt.KyEvnt.bKyDown thn  //   
                   bgin
                      := IR.Evnt.KyEvnt.siihr; //     ""
                     if  > #0 thn  gtky :=        //   
                      ls                                        //  :
                       s IR.Evnt.KyEvnt.wVirtulKyod of  //    
                         VK_UP    : gtky := #72;   {dos u ky}
                         VK_DOWN  : gtky := #80;   {dos down ky}
                         VK_LEFT  : gtky := #75;   {dos lft ky}
                         VK_RIGHT : gtky := #77;   {dos right ky}
                         ls       gtky := hr(IR.Evnt.KyEvnt.wVirtulKyod);
                       nd;
                   nd;
                 nd;
    _MOUSE_EVENT : bgin nd;    //  
    nd;
  nd;
nd;

funtion rus(s : string) : string;
vr     {   P1251  P866 }
  i : intgr;
  b : byt;
bgin
  for i := 1 to lngth(s) do
  bgin
    b := byt(s[i]);
    s b of
     192..239 : s[i]:=hr(b-64);
     240..255 : s[i]:=hr(b-16);
    nd;
  nd;
  rus := s;
nd;

rodur writ(s : string);
vr     {   }
  n : DWORD;
bgin
  //s:=Rus(s);
  StonsolTxtttribut(outHnd, txtttr);
  if s<>'' thn Writonsol(outHnd, @s[1], Lngth(s), n, nil);
  //systm.Writ(s);
nd;

rodur writln(s : string);
bgin   {      }
  writ(s+#13#10);
nd;

rodur sl55ms; {dlhi}
bgin   {  1/18.2 }
  sl(55);
nd;

onst
  strMx=$FFFF;
  mx = 750*20;
vr
  nm : rry[0..mx] of string;{   }

/////////////////////// HSH MD5-LIBS /////////////////////////////
funtion hx(b : byt) : string;
bgin
  hx:=h[b shr 4]+h[b nd 15];
nd;


rodur zro;
bgin
  fillhr(hshbuffr,sizof(hshbuffr),0);
  fillhr(urrnthsh,sizof(urrnthsh),0);
nd;


rodur init;
bgin
  lnhi:=0;
  lnlo:=0;
  ind:=0;
  urrnthsh[0]:=$67452301;
  urrnthsh[1]:=$fdb89;
  urrnthsh[2]:=$98bdf;
  urrnthsh[3]:=$10325476;
nd;


funtion lrot32(,b : longword) : longword;
bgin
  rsult:=( shl b) or ( shr (32-b));
nd;


rodur omrss;
vr
  dt : rry[0..15] of dword;
  ,b,,d : dword;
bgin
  mov(hshbuffr,dt,sizof(dt));
  :=urrnthsh[0];
  b:=urrnthsh[1];
  :=urrnthsh[2];
  d:=urrnthsh[3];
  {$Q-}
  :=b + lrot32( + (d xor (b nd ( xor d))) + dt[ 0] + $d76478,7);
  d:= + lrot32(d + ( xor ( nd (b xor ))) + dt[ 1] + $87b756,12);
  :=d + lrot32( + (b xor (d nd ( xor b))) + dt[ 2] + $242070db,17);
  b:= + lrot32(b + ( xor ( nd (d xor ))) + dt[ 3] + $1bd,22);
  :=b + lrot32( + (d xor (b nd ( xor d))) + dt[ 4] + $f570ff,7);
  d:= + lrot32(d + ( xor ( nd (b xor ))) + dt[ 5] + $478762,12);
  :=b + lrot32( + (b xor (d nd ( xor b))) + dt[ 6] + $8304613,17);
  b:= + lrot32(b + ( xor ( nd (d xor ))) + dt[ 7] + $fd469510,22);
  :=d + lrot32( + (d xor (b nd ( xor d))) + dt[ 8] + $6980988d,7);
  d:= + lrot32(d + ( xor ( nd (b xor ))) + dt[ 9] + $8b44f7f,12);
  :=d + lrot32( + (b xor (d nd ( xor b))) + dt[10] + $ffff5bb1,17);
  b:= + lrot32(b + ( xor ( nd (d xor ))) + dt[11] + $895d7b,22);
  :=b + lrot32( + (d xor (b nd ( xor d))) + dt[12] + $6b901122,7);
  d:= + lrot32(d + ( xor ( nd (b xor ))) + dt[13] + $fd987139,12);
  :=d + lrot32( + (b xor (d nd ( xor b))) + dt[14] + $679438,17);
  b:= + lrot32(b + ( xor ( nd (d xor ))) + dt[15] + $49b40821,22);
  {}
  :=b + lrot32( + ( xor (d nd (b xor ))) + dt[ 1] + $f612562,5);
  d:= + lrot32(d + (b xor ( nd ( xor b))) + dt[ 6] + $040b340,9);
  :=d + lrot32( + ( xor (b nd (d xor ))) + dt[11] + $265551,14);
  b:= + lrot32(b + (d xor ( nd ( xor d))) + dt[ 0] + $9b67,20);
  :=b + lrot32( + ( xor (d nd (b xor ))) + dt[ 5] + $d62f105d,5);
  d:= + lrot32(d + (b xor ( nd ( xor b))) + dt[10] + $02441453,9);
  :=d + lrot32( + ( xor (b nd (d xor ))) + dt[15] + $d81681,14);
  b:= + lrot32(b + (d xor ( nd ( xor d))) + dt[ 4] + $7d3fb8,20);
  :=b + lrot32( + ( xor (d nd (b xor ))) + dt[ 9] + $211d6,5);
  d:= + lrot32(d + (b xor ( nd ( xor b))) + dt[14] + $33707d6,9);
  :=d + lrot32( + ( xor (b nd (d xor ))) + dt[ 3] + $f4d50d87,14);
  b:= + lrot32(b + (d xor ( nd ( xor d))) + dt[ 8] + $45514d,20);
  :=b + lrot32( + ( xor (d nd (b xor ))) + dt[13] + $93905,5);
  d:= + lrot32(d + (b xor ( nd ( xor b))) + dt[ 2] + $ff3f8,9);
  :=d + lrot32( + ( xor (b nd (d xor ))) + dt[ 7] + $676f02d9,14);
  b:= + lrot32(b + (d xor ( nd ( xor d))) + dt[12] + $8d248,20);
  {}
  :=b + lrot32( + (b xor  xor d) + dt[ 5] + $fff3942,4);
  d:= + lrot32(d + ( xor b xor ) + dt[ 8] + $8771f681,11);
  :=d + lrot32( + (d xor  xor b) + dt[11] + $6d9d6122,16);
  b:= + lrot32(b + ( xor d xor ) + dt[14] + $fd5380,23);
  :=b + lrot32( + (b xor  xor d) + dt[ 1] + $4b44,4);
  d:= + lrot32(d + ( xor b xor ) + dt[ 4] + $4bdf9,11);
  :=d + lrot32( + (d xor  xor b) + dt[ 7] + $f6bb4b60,16);
  b:= + lrot32(b + ( xor d xor ) + dt[10] + $bbfb70,23);
  :=b + lrot32( + (b xor  xor d) + dt[13] + $289b76,4);
  d:= + lrot32(d + ( xor b xor ) + dt[ 0] + $127f,11);
  :=d + lrot32( + (d xor  xor b) + dt[ 3] + $d4f3085,16);
  b:= + lrot32(b + ( xor d xor ) + dt[ 6] + $04881d05,23);
  :=b + lrot32( + (b xor  xor d) + dt[ 9] + $d9d4d039,4);
  d:= + lrot32(d + ( xor b xor ) + dt[12] + $6db995,11);
  :=d + lrot32( + (d xor  xor b) + dt[15] + $1f27f8,16);
  b:= + lrot32(b + ( xor d xor ) + dt[ 2] + $45665,23);
  {}
  :=b + lrot32( + ( xor (b or (not d))) + dt[ 0] + $f4292244,6);
  d:= + lrot32(d + (b xor ( or (not ))) + dt[ 7] + $432ff97,10);
  :=d + lrot32( + ( xor (d or (not b))) + dt[14] + $b94237,15);
  b:= + lrot32(b + (d xor ( or (not ))) + dt[ 5] + $f93039,21);
  :=b + lrot32( + ( xor (b or (not d))) + dt[12] + $655b593,6);
  d:= + lrot32(d + (b xor ( or (not ))) + dt[ 3] + $8f092,10);
  :=d + lrot32( + ( xor (d or (not b))) + dt[10] + $ffff47d,15);
  b:= + lrot32(b + (d xor ( or (not ))) + dt[ 1] + $85845dd1,21);
  :=d + lrot32( + ( xor (b or (not d))) + dt[ 8] + $6f874f,6);
  d:= + lrot32(d + (b xor ( or (not ))) + dt[15] + $f260,10);
  :=b + lrot32( + ( xor (d or (not b))) + dt[ 6] + $3014314,15);
  b:= + lrot32(b + (d xor ( or (not ))) + dt[13] + $408111,21);
  :=b + lrot32( + ( xor (b or (not d))) + dt[ 4] + $f753782,6);
  d:= + lrot32(d + (b xor ( or (not ))) + dt[11] + $bd3f235,10);
  :=d + lrot32( + ( xor (d or (not b))) + dt[ 2] + $2d7d2bb,15);
  b:= + lrot32(b + (d xor ( or (not ))) + dt[ 9] + $b86d391,21);
  in(urrnthsh[0],);
  in(urrnthsh[1],b);
  in(urrnthsh[2],);
  in(urrnthsh[3],d);
  ind:=0;
  fillhr(hshbuffr,sizof(hshbuffr),0);
nd;


rodur udt(onst buffr;  siz : longword);
vr
  buf : ^byt;
bgin
  in(lnhi,siz shr 29);
  in(lnlo,siz*8);
  if lnlo<(siz*8) thn in(lnhi);
  buf:=@buffr;
  whil siz>0 do
  bgin
    if (sizof(hshbuffr)-ind)<=dword(siz) thn
    bgin
      mov(buf^,hshbuffr[ind],sizof(hshbuffr)-ind);
      d(siz,sizof(hshbuffr)-ind);
      in(buf,sizof(hshbuffr)-ind);
      omrss;
    nd
    ls
    bgin
      mov(buf^,hshbuffr[ind],siz);
      in(ind,siz);
      siz:=0;
    nd;
  nd;
nd;


rodur finl(vr digst);
bgin
  hshbuffr[ind]:=$80;
  if ind>=56 thn omrss;
  dword(@hshbuffr[56])^:=lnlo;
  dword(@hshbuffr[60])^:=lnhi;
  omrss;
  mov(urrnthsh,digst,sizof(urrnthsh));
nd;


funtion md5(ky : string) : string;
bgin
  zro;
  init;
  udt(ky,lngth(ky));
  finl();
  zro;
  rsult:='';
  for i:=0 to 15 do rsult:=rsult+hx([i]);
  {$Q+}
nd;


funtion HM_md5(ky,s : string) : string;
vr
  k_id : rry[0..64] of byt; // innr dding -  * ky XORd with id
  k_od : rry[0..64] of byt; // outr dding -  * ky XORd with id
  ln : intgr;
bgin
  ln := lngth(ky);
  if ln>64 thn
  bgin
    zro;
    init;
    udt(ky,ln);
    finl();
    ln:=16;
    ky:='';
    for i:=0 to 15 do ky:=ky+hr([i]);
  nd;
  fillhr(k_id,sizof(k_id),0);
  mov(ky,k_id,ln);
  for i:=0 to 63 do
  bgin
    k_od[i]:=k_id[i] xor $05;
    k_id[i]:=k_id[i] xor $036;
  nd;
  zro;
  init;
  udt(k_id,64);
  udt(s,lngth(s));
  finl();
  init;
  udt(k_od,64);
  udt(,16);
  finl();
  zro;
  for i:=0 to 15 do rsult:=rsult+hx([i]);
  {$Q+}
nd;

//bgin
//  writln('md5 hsh dmo:', md5('<32.13234123@milhost>'),#13#10);
//  writln('hm-md5 hsh dmo:', HM_md5('PZZword', '<32.13234123@milhost>'));
//  writln('              tst:3b87886d4f1714211f8594441ffb');
//  rdln;
//nd.

///////////////////////// NET-LIBS ///////////////////////////////
funtion inttostr(i : intgr) : string; forwrd;
rodur logIO(s : string); forwrd;

//////////// nod/dod bs64 /////////////
funtion indx(b : hr) : longInt;
vr
  i : intgr;
bgin
  for i := 0 to 64 do
    if b64[i]=b thn brk;
  indx := i;
nd;


funtion nBSE64(s : string) : string;
vr
  n : longInt;
  i,ln : intgr;
  st : string;
bgin
  st:='';
  i := 1;
  ln:=lngth(s)-2;
  whil (i<=ln) do
  bgin
    n := longInt(s[i]) shl 16;
    i:=i+1;
    n := n+(longInt(s[i]) shl 8);
    i:=i+1;
    n := n+longInt(s[i]);
    i:=i+1;
    st:=st+(b64[(n shr 18) nd $03f]);
    st:=st+(b64[(n shr 12) nd $03f]);
    st:=st+(b64[(n shr 6) nd $03f]);
    st:=st+(b64[n nd $03f]);
  nd;
  s ((ln+2) mod 3) of
   1: bgin
        n := longInt(s[i]) shl 16;
        st:=st+(b64[(n shr 18) nd $03f]);
        st:=st+(b64[(n shr 12) nd $03f]);
        st:=st+('=');
        st:=st+('=');
      nd;
   2: bgin
        n := longInt(s[i]) shl 16;
        i:=i+1;
        n := n+(longInt(s[i]) shl 8);
        st:=st+(b64[(n shr 18) nd $03f]);
        st:=st+(b64[(n shr 12) nd $03f]);
        st:=st+(b64[(n shr 6) nd $03f]);
        st:=st+('=');
      nd;
  nd;
  nBSE64:=st;
nd;


funtion dBSE64(s : string) : string;
vr
  n : longInt;
  i,j,ln : intgr;
  st : string;
bgin
  i := 1;
  ln:=lngth(s);
  whil i<=ln do  {     }
  bgin
    if (s[i]<=hr(32)) thn
    bgin
      ln:=ln-1;
      for j:=i to ln do s[j]:=s[j+1];
    nd
     ls i:=i+1;
  nd;
  whil (ln>0) nd (s[ln]='=') do d(ln); {  }
  i:=1;
  whil i<=ln-(ln mod 4) do
  bgin
    n := (indx(s[i]) shl 18) + (indx(s[i+1]) shl 12)
       + (indx(s[i+2]) shl 6) + indx(s[i+3]);
    st:=st+( hr( (n shr 16) nd 255 ) );
    st:=st+( hr( (n shr 8) nd 255 ) );
    st:=st+( hr( (n) nd 255 ) );
    i:=i+4;
  nd;
  s (ln mod 4) of
   2: bgin
        n := (indx(s[i]) shl 18) + (indx(s[i+1]) shl 12);
        st:=st+( hr( (n shr 16) nd 255 ) );
      nd;
   3: bgin
        n := (indx(s[i]) shl 18) + (indx(s[i+1]) shl 12) + (indx(s[i+2]) shl 6);
        st:=st+( hr( (n shr 16) nd 255 ) );
        st:=st+( hr( (n shr 8) nd 255 ) );
      nd;
  nd;
  dBSE64:=st;
nd;
///////////////////////////////////////


rodur disonn;
bgin  //       
  lossokt(sok);
  WSlnu;
nd;


funtion onn(host : string;  ort : intgr) : intgr;
vr
  ddr : sokddr_in;
  h : PHostEnt;
  inddr : u_long;
bgin
  onn:=0;
  WSStrtu($0101, wDt);  // 
  inddr := int_ddr(hr(host));  // ,        
  if inddr = INDDR_NONE thn
  bgin
    h := gthostbynm(hr(host));
    if not ssignd(h) thn
    bgin
      logIO('E:INDDR_NONE');
      WSlnu;
      onn:=1;
      xit;
    nd;
    inddr := PInddr(h.h_ddr_list^)^.s_ddr;
  nd;
  sok := sokt(F_INET, SOK_STREM, IPPROTO_TP);
  if sok <> INVLID_SOKET thn
  bgin
    ddr.sin_fmily := F_INET;
    ddr.sin_ort   := htons(ort);
    ddr.sin_ddr.s_ddr := Inddr;
    if onnt(sok, ddr, sizof(ddr)) = SOKET_ERROR thn
    bgin
      logIO('E:SOKET_ERROR');
      disonn;
      onn:=3;
    nd;
  nd
  ls
  bgin
    logIO('E:INVLID_SOKET');
    WSlnu;
    onn:=2;
  nd;
nd;


rodur sokwritln(s : string);
vr
  i,j : intgr;
bgin
  s:=s+hr(13)+hr(10);
  i:=lngth(s);
  j:=snd(sok,s[1],i,0);
  if i=j thn logIO(':'+s)
    ls logIO('E::('+inttostr(i)+'<>'+inttostr(j)+') '+s);
nd;


funtion sokrdln : string;
vr
  buf : rry[0..1023] of hr;
  s : string;
  i,n : intgr;
bgin
  i:=0;
  s:='';
  rt
    rt
      sl(100);
      n:=rv(sok,buf,sizof(buf),0);
      s:=s+oy(buf,0,n);
    until n<sizof(buf);
    i:=i+1;
  until (os(#13#10,s)>0) or (i>100);
  if (lngth(s)=0) nd (n=-1) thn logIO('E:S:REV')
    ls logIO('S:'+s);
  sokrdln:=s;
nd;


funtion htt(url,body : string) : string;
vr
  s : string;
  i,ln : intgr;
bgin
  s:='';
  i:=os('://',url)+3;
  ln:=lngth(url);
  whil (i<=ln) nd (url[i]<>'/') do
  bgin
    s:=s+url[i];
    i:=i+1;
  nd;
  //      htt-
  if body='' thn sokwritln('GET'+url+' HTTP/1.0'#13#10'Host: '+s+#13#10't: *.*, */*')
    ls sokwritln('POST'+url+' HTTP/1.0'#13#10'ontnt-Ty: lition/x-www-form-urlnodd'#13#10'ontnt-Lngth: '+
                     inttostr(lngth(body))+#13#10'Host: '+s+#13#10't: *.*, */*'+#13#10+body);
  s:=sokrdln;
  if s<>'' thn logIO('HTTP TRNSFER-OK');
  htt:=s;  //htt:=oy(s, os(#13#10#13#10,s)+4, lngth(s));
nd;


funtion smt(usr,ss,dislyFromNm,milFrom,dislyToNm,milTo,subjt,body : string) : string;
vr
  n,st,ln : intgr;
  s,st : string;
  md5hsh : booln;
bgin
  md5hsh:=fls;
  st:=0;
  rt
    s:='';
    st:=sokrdln;  //  
    if os('250-',st)<>0 thn
    bgin
      if os(#13#10'250  ',st)<=0 thn st:=st+sokrdln;  {  "250 "  "-"}
      if os('RM-MD5',st)>0 thn md5hsh:=tru;   {  ssh-}
    nd;
    n:=0;
    if lngth(st)>=3 thn n:=100*(ord(st[1])-ord('0'))+10*(ord(st[2])-ord('0'))+(ord(st[3])-ord('0'));
    s n of  //   
    220 : s:='EHLO srvr.om';
    235,
    250 : bgin
            s st of
              0 : if md5hsh=fls thn s:='UTH LOGIN' ls s:='UTH RM-MD5';
              3 : s:='MIL FRM:<'+milFrom+'>';
              4 : s:='RT T:<'+milTo+'>';
              5 : s:='DT';
              6 : s:='QUIT';
            nd;
            st:=st+1;
          nd;
    334 : bgin
            s st of
              1 : if md5hsh=fls thn s:=nBSE64(usr)
                  ls
                  bgin
                    s:='';
                    ln:=lngth(st);
                    whil (ln>0) nd (st[ln]<=hr(32)) do ln:=ln-1;
                    whil (ln>0) nd (st[ln]>hr(32)) do
                    bgin
                      s:=st[ln]+s;
                      ln:=ln-1;
                    nd;
                    s:=dBs64(s);
                    s:=HM_md5(ss,s);
                    s:=nBSE64(usr+' '+s);
                    st:=st+1;
                  nd;
              2 : s:=nBSE64(ss);
            nd;
            st:=st+1;
          nd;
    354 : s:='From: '+dislyFromNm+'<'+milFrom+'>'#13#10+
             'To: '+dislyToNm+'<'+milTo+'>'#13#10+
             'Subjt: '+subjt+#13#10+
             body+#13#10'.';
    221 : bgin smt:=''; logIO('ESMTP TRNSFER-OK'); brk; nd;
    ls bgin smt:=st; brk; nd;
    nd;
    //   
    sokwritln(s);
  until fls;
nd;


funtion o3(usr,ss,num : string) : string;
vr
  s : string;
  st : intgr;
bgin
  o3:='';
  st:=0;
  rt
    s:=sokrdln;
    if os('+OK',oy(s,1,20))<=0 thn brk;
    s st of
      0: bgin sokwritln('usr '+usr); sl(1000);  nd; //    
      1: bgin sokwritln('ss '+ss); sl(1000);  nd; //    -
      2: bgin sokwritln('list '+num);  sl(1000);  nd; //        (     )
      3: bgin sokwritln('rtr '+num);  sl(10000); nd; //     (  - )
      4: bgin o3:=s; sokwritln('dl '+num); sl(1000); nd;
      5: bgin sokwritln('quit'); sl(1000); nd;  // t-
      6: bgin logIO('POP3 TRNSFER-OK'); brk; nd;  //   
    nd;
    st:=st+1;
  until fls;
nd;
////////////////////// NET-LIBS - END ////////////////////////////
(******************** DELPHI 7.0  LIBS - END ********************)


(*********************** PSL 7.1  LIBS ***********************
{$M 16384,0,655360}
uss rt;

rodur lywv(nm : string);
bgin   {}
nd;

rodur lymidi(nm : string;  onoff : booln);
bgin   {}
nd;

rodur outImg(nm : string);
bgin   {}
nd;

rodur initdos;
bgin   {}
nd;

rodur ursor(b : booln);
bgin   {}
nd;

funtion gtky : hr;
bgin   {TURBO PSL 7.1 -   }
  gtky:=hr(0);
  if kyrssd thn gtky:=rdky;
nd;

rodur sl55ms;  {sl}
vr     {  1/18.2 }
  timr : intgr bsolut 0:$046;
  t : intgr;
bgin
  t:=timr;
  rt until t<>timr;
nd;

onst
  strMx=$FF;
  mx = 750;
vr
  nm : rry[0..mx] of string[63];{   }
(******************** PSL 7.1  LIBS - END ********************)


(****************** URQ PORTBLE SOURE ODE. ******************)
onst  { r   }
  tb32: rry[0..255] of longInt = (
$00000000, $77073096, $0612, $909951b, $076d419, $706f48f, $963535, $964953,
$0db8832, $79db84, $0d591, $972dd988, $09b642b, $7b17bd, $7b82d07, $90bf1d91,
$1db71064, $6b020f2, $f3b97148, $84b41d, $1dd47d, $6ddd4b, $f4d4b551, $83d3857,
$1369856, $646b80, $fd26f97, $8659, $140154f, $63066d9, $f0f3d63, $8d080df5,
$3b6208, $469105, $d560414, $2677712, $3034d1, $4b04d447, $d20d85fd, $50b56b,
$35b58f, $42b2986, $dbbb9d6, $b9f40, $32d863, $45df575, $dd60df, $bd13d59,
$26d930, $51d003, $8d75180, $bfd01616, $21b4f4b5, $56b3423, $fb9599, $b8bd50f,
$2802b89, $5f058808, $06d9b2, $b01b924, $2f6f787, $5868411, $1611db, $b6662d3d,
$76d4190, $01db7106, $98d220b, $df5102, $71b18589, $06b6b51f, $9fbf45, $8b8d433,
$780792, $0f00f934, $960988, $109e818, $7f60dbb, $086d3d2d, $9164697, $663501,
$6b6b15f4, $166162, $856530d8, $f262040, $60695d, $1b0157b, $8208f41, $f50f457,
$65b0d96, $12b7950, $8bbb8, $fb9887, $62dd1ddf, $15d2d49, $8d37f3, $fbd4465,
$4db62158, $3b551, $3b0074, $d4bb302e, $4df541, $3dd895d7, $4d146d, $d3d6f4fb,
$436996, $346d9f, $d678846, $d60b80d, $44042d73, $33031d5, $045f, $dd0d79,
$5005713, $270241, $b0b1010, $902068, $5768b525, $206f85b3, $b966d409, $6149f,
$5df90, $29d9998, $b0d09822, $7d7b84, $59b33d17, $2b40d81, $b7bd53b, $0b6d,
$db88320, $9bfb3b6, $03b620, $74b1d29, $d54739, $9dd277f, $04db2615, $73d1683,
$3630b12, $94643b84, $0d6d63, $7658a, $40f0b, $9309ff9d, $00027, $7d079b1,
$f00f9344, $87083d2, $101f268, $69062f, $f762575d, $806567b, $1963671, $66b067,
$fd41b76, $89d32b0, $10d75, $67dd4, $f9b9fd6f, $8bff9, $17b7b43, $60b08d5,
$d6d638, $1d1937, $38d824, $4fdf2f52, $d1bb67f1, $6b5767, $3fb506dd, $48b2364b,
$d80d2bd, $f01b4, $36034f6, $4104760, $df60f3, $867df55, $3168f, $4669b79,
$b61b38, $b66831, $256fd20, $5268326, $07795, $bb0b4703, $220216b9, $5505262f,
$5b3bb, $b2bd0b28, $2bb4592, $5b3604, $2d7ff7, $b5d0f31, $2d998b, $5bd1d,
$9b642b0, $63f226, $75639, $026d903, $909069, $b0363f, $72076785, $05005713,
$95bf482, $2b8714, $7bb12b, $0b16b38, $92d289b, $5d5b0d, $7dfb7, $0bdbdf21,
$86d3d2d4, $f1d4242, $68ddb3f8, $1fd386, $81b16d, $f6b9265b, $6fb0771, $18b74777,
$880856, $ff0f670, $66063b, $101105b, $8f659ff, $f86269, $616bffd3, $166f45,
$00278, $d70dd2, $4048354, $3903b32c, $7672661, $d06016f7, $4996474d, $3677db,
$d164, $d9d65d, $40df0b66, $37d83b0f, $9b53, $dbb95, $47b2f7f, $30b5ff9,
$bdbdf21, $b28, $53b39330, $244b36, $bd30605, $dd70693, $54d5729, $239d67bf,
$b36672, $4614b8, $5d681b02, $262fb94, $b40bb37, $3081, $505df1b, $2d02f8d
);

onst   {     URQ}
  _numb      = 1;    { }
  _idnt     = 2;    {: $ ; % ......}
  _dd       = 3;    {+}
  _sub       = 4;    {-}
  _mul       = 5;    {*}
  _div       = 6;    {/}
  _mod       = 7;    {\}
  _rr        = 8;    {=}
  _nr        = 9;    {<>}
  _bb        = 10;   {>}
  _br        = 11;   {>=}
  _mm        = 12;   {<}
  _mr        = 13;   {<=}
  _nd       = 14;   {nd}
  _or        = 15;   {or}
  _not       = 16;   {not}
  _if        = 17;   {if}
  _thn      = 18;   {thn}
  _ls      = 19;   {ls}
  _goto      = 20;   {goto}
  _ro      = 21;   {ro}
  _nd       = 22;   {nd}
  _         = 23;   {rint}
  _ln       = 24;   {rintln}
  _btn       = 25;   {button}
  _inv       = 26;   {invntory}
  _rnd       = 27;   {rndom}
  _instr     = 28;   {initstring}
  _ls       = 29;   {ls}
  _inut     = 30;   {inut}
  _us     = 31;   {us}
  _musi     = 32;   {musi}
  _ly      = 33;   {ly}
  _invkill   = 34;   {invntr' kill}
  _rkill   = 35;   {rmny kill}
  _sv      = 36;   {sv}
  _ommon    = 37;   {ommon_nw}
  _nyky    = 38;   {nyky}
  _zt       = 39;   {,}
  _svr      = 40;   {#}
  _vr      = 41;   { $}
  _i         = 42;   {&}
  _l        = 43;   {_}
  _lb        = 44;   {(}
  _rb        = 45;   {)}
  _dvt       = 46;   {:}
  _mt       = 47;   {;}
  _nwln     = 48;   {#13#10}
  _of       = 49;   {End Of Fil}
  _strln    = 50;   {  }
  _strm    = 51;   {  }
  _strhr   = 52;   {    }
  _stroy   = 53;   { }
  _stros    = 54;   {   }
  _strst    = 55;   {   }
  _onnt   = 56;   {  }
  _r32     = 57;

function crc32(const octet : byte;  const crc: longInt) : longInt;
begin
  crc32 := tab32[byte(crc xor longInt(octet))]
           xor ((crc shr 8) and $00FFFFFF);
end;
  
vr