Add build script.
[brdnet.git] / dhtWebBoot.pas
blobf517ce966d565d7c769d7c144db45e04cce4a4f9
1 unit dhtWebBoot;
3 INTERFACE
5 procedure Bootstrap(url:ansistring);
7 IMPLEMENTATION
8 uses sockets,netdb,uriparser,NetAddr;
10 type t=object
11 s:tSocket;
12 procedure Init(url:ansistring);
13 end;
15 procedure t.Init(url:ansistring);
16 var uri:tURI;
17 var he:tHostEntry;
18 var addr:tNetAddr;
19 begin
20 uri:=ParseURI(url);
21 if uri.port=0 then uri.port:=80;
22 uri.path:=uri.path+uri.document;
23 writeln('Boot: ',uri.host,' ',uri.port,' ',uri.path,' ',uri.params);
24 if NetDB.ResolveHostByName(uri.host,he) then begin
25 addr.data.family:=afInet;
26 addr.data.inet.addr:=he.Addr;
27 addr.data.inet.port:=htons(uri.port);
28 writeln('Boot: ',string(addr)+'/'+uri.path+'?'+uri.params);
29 end else writeln('fuck');
30 end;
32 procedure Bootstrap(url:ansistring);
33 var o:^t;
34 begin
35 New(o);
36 o^.Init(url);
37 end;
39 END.