resolve.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. {$MODE OBJFPC}
  2. {$H+}
  3. Unit resolve;
  4. {$ifndef win32}
  5. // Here till BSD supports the netbsd unit.
  6. // MvdV: NetBSD unit? Where?
  7. {$ifdef Unix}
  8. // Undefine this to use the C library resolve routines.
  9. // Don't use under win32, netdb does not work on Win32 (yet) !!
  10. {$define usenetdb}
  11. {$endif Unix}
  12. {$endif}
  13. { --------------------------------------------------------------------
  14. Unit for internet domain calls.
  15. Copyright (C) 2003 Michael Van Canneyt
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 1, or (at your option)
  19. any later version.
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. GNU General Public License for more details.
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software
  26. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. ------------------------------------------------------------------- }
  28. interface
  29. uses
  30. Sockets,Classes,UriParser;
  31. Type
  32. THostAddr = in_addr;
  33. PHostAddr = ^THostAddr;
  34. TNetAddr = in_addr;
  35. PNetAddr = ^TNetAddr;
  36. Type
  37. { ---------------------------------------------------------------------
  38. TResolver
  39. ---------------------------------------------------------------------}
  40. TResolver = Class (TComponent)
  41. Private
  42. FName : String;
  43. FAliases : TStringList;
  44. FRaiseOnError : Boolean;
  45. FLastError: Integer;
  46. Function GetAlias(Index : Integer) : STring;
  47. Function GetAliasCount : Integer;
  48. Function GetAliasSorted : Boolean;
  49. Procedure SetAliasSorted (Value : Boolean);
  50. Protected
  51. Procedure CheckOperation(Msg : String);
  52. Function NameLookup(Const S : String) : Boolean; virtual;
  53. Procedure SaveAliases(P : PPChar);
  54. Public
  55. Constructor Create(AOwner : TComponent); override;
  56. Destructor Destroy; override;
  57. Procedure ClearData; virtual;
  58. Property ResolvedName : String Read FName;
  59. Property Aliases [Index : integer ] : string Read GetAlias;
  60. Property AliasCount : Integer read GetAliasCount;
  61. Property SortAliases : Boolean Read GetAliasSorted Write SetAliasSorted;
  62. Property RaiseOnError : Boolean Read FRaiseOnError Write FRAiseOnError;
  63. Property LastError : Integer Read FlastError;
  64. end;
  65. { ---------------------------------------------------------------------
  66. THostResolver
  67. ---------------------------------------------------------------------}
  68. THostResolver = Class(TResolver)
  69. Private
  70. FHostAddress : THostAddr;
  71. FAddressCount : Integer;
  72. FAddresses : PHostAddr;
  73. Function GetAddress (Index : Integer) : THostAddr;
  74. Function GetNetAddress (Index : Integer) : THostAddr;
  75. Function GetNetHostAddress : THostAddr;
  76. Function GetAsString : String;
  77. Procedure SaveHostEntry (Entry : Pointer);
  78. Public
  79. Procedure ClearData; Override;
  80. Function NameLookup(Const S : String) : Boolean; override;
  81. Function AddressLookup(Const S : String) : Boolean; virtual;
  82. Function AddressLookup(Const Address : THostAddr) : Boolean; virtual;
  83. Property HostAddress : THostAddr Read FHostAddress;
  84. Property NetHostAddress : THostAddr Read GetNetHostAddress;
  85. Property AddressAsString : String Read GetAsString;
  86. Property AddressCount : Integer Read FAddressCount ;
  87. Property Addresses [Index : Integer] : ThostAddr Read GetAddress;
  88. Property NetAddresses [Index : Integer] : ThostAddr Read GetNetAddress;
  89. end;
  90. { ---------------------------------------------------------------------
  91. TNetResolver
  92. ---------------------------------------------------------------------}
  93. TNetResolver = Class(TResolver)
  94. Private
  95. FNetAddress : TNetAddr;
  96. FAddrType : Integer;
  97. Function GetAsString : String;
  98. Procedure SaveNetEntry(Entry : Pointer);
  99. Function GetNetAddress : TNetAddr;
  100. Public
  101. Procedure ClearData; override;
  102. Function NameLookup(Const S : String) : boolean; override;
  103. Function AddressLookup(Const S : String) : Boolean; virtual;
  104. Function AddressLookup(Const Address : TNetAddr) : Boolean; virtual;
  105. Property NetAddress : TNetAddr Read FNetAddress;
  106. Property NetNetAddress : TNetAddr Read GetNetAddress;
  107. Property AddressAsString : String Read GetAsString;
  108. Property AddressType : Integer Read FAddrType;
  109. end;
  110. { ---------------------------------------------------------------------
  111. TServiceResolver
  112. ---------------------------------------------------------------------}
  113. TServiceResolver = Class(TResolver)
  114. private
  115. FProtocol : String;
  116. FPort : Integer;
  117. Procedure SaveServiceEntry(Entry : Pointer);
  118. Function GetNetPort : Integer ;
  119. public
  120. Procedure ClearData; override;
  121. Function NameLookup (Const S : String) : boolean; override;
  122. Function NameLookup (Const S,Proto : String) : Boolean;
  123. Function PortLookup (APort : Longint; Proto: string) : Boolean;
  124. Property Protocol : String Read FProtocol;
  125. Property Port : Integer Read FPort;
  126. Property NetPort : Integer Read GetNetPort;
  127. end;
  128. TURIParser = Class(TComponent)
  129. Private
  130. FActive : Boolean;
  131. FProtocol: String;
  132. FUsername: String;
  133. FPassword: String;
  134. FHost: String;
  135. FPort: Word;
  136. FPath: String;
  137. FDocument: String;
  138. FParams: String;
  139. FBookmark: String;
  140. FURI : String;
  141. Protected
  142. Procedure SetElement (Index : Integer; Value : String);Virtual;
  143. Function GetElement(Index : Integer) : String;
  144. Procedure SetPort(Value : Word);
  145. Procedure SetURI(Value : String);
  146. Public
  147. Procedure Clear;
  148. Procedure ParseUri(AURI : String);
  149. Function ComposeURI : String;
  150. Published
  151. Property Port: Word Read FPort Write SetPort;
  152. Property Protocol: String Index 0 Read GetElement Write SetElement;
  153. Property Username: String Index 1 Read GetElement Write SetElement;
  154. Property Password: String Index 2 Read GetElement Write SetElement;
  155. Property Host: String Index 3 Read GetElement Write SetElement;
  156. Property Path: String index 4 Read GetElement Write SetElement;
  157. Property Document: String index 5 read GetElement Write SetElement;
  158. Property Params: String Index 6 read GetElement Write SetElement;
  159. Property Bookmark: String Index 7 Read GetElement Write SetElement;
  160. Property URI : String Read FURI write SetURI;
  161. Property Active : Boolean Read FActive Write FActive;
  162. end;
  163. Resourcestring
  164. SErrHostByName = 'Host by name';
  165. SErrHostByAddr = 'Host by address';
  166. SErrNetByName = 'Net by name';
  167. SErrServByName = 'Service by name';
  168. SErrServByPort = 'Service by port';
  169. Implementation
  170. { ---------------------------------------------------------------------
  171. Include system dependent stuff.
  172. ---------------------------------------------------------------------}
  173. {$ifdef usenetdb}
  174. uses netdb;
  175. {$else}
  176. {$i resolve.inc}
  177. {$endif}
  178. { ---------------------------------------------------------------------
  179. TResolver
  180. ---------------------------------------------------------------------}
  181. Constructor TResolver.Create(AOwner : TComponent);
  182. begin
  183. Inherited;
  184. FAliases:=TstringList.Create;
  185. end;
  186. Destructor TResolver.Destroy;
  187. begin
  188. ClearData;
  189. FAliases.Free;
  190. end;
  191. Procedure TResolver.ClearData;
  192. begin
  193. FName:='';
  194. FAliases.Clear;
  195. end;
  196. Function TResolver.GetAlias(Index : Integer) : STring;
  197. begin
  198. Result:=FAliases[Index];
  199. end;
  200. Function TResolver.GetAliasCount : Integer;
  201. begin
  202. Result:=FAliases.Count;
  203. end;
  204. Function TResolver.GetAliasSorted : Boolean;
  205. begin
  206. Result:=FAliases.Sorted;
  207. end;
  208. Procedure TResolver.SetAliasSorted (Value : Boolean);
  209. begin
  210. FAliases.Sorted:=Value;
  211. end;
  212. Procedure TResolver.CheckOperation(Msg : String);
  213. begin
  214. end;
  215. Function TResolver.NameLookup(Const S : String) : Boolean;
  216. begin
  217. ClearData;
  218. FName:=S;
  219. Result:=True;
  220. end;
  221. Procedure TResolver.SaveAliases(P : PPChar);
  222. Var
  223. I : Integer;
  224. begin
  225. If (P<>Nil) then
  226. begin
  227. I:=0;
  228. While P[I]<>Nil do
  229. begin
  230. FAliases.Add(StrPas(P[I]));
  231. Inc(I);
  232. end;
  233. end;
  234. end;
  235. { ---------------------------------------------------------------------
  236. THostResolver
  237. ---------------------------------------------------------------------}
  238. Function THostResolver.GetAddress (Index : Integer) : THostAddr;
  239. begin
  240. If (Index>=0) and (Index<FAddressCount) then
  241. Result:=FAddresses[Index];
  242. end;
  243. Function THostResolver.GetAsString : String;
  244. begin
  245. Result:=HostAddrToStr(FHostAddress);
  246. end;
  247. Procedure THostResolver.ClearData;
  248. begin
  249. Inherited;
  250. FHostAddress:=NoAddress;
  251. If FAddressCount<>0 Then
  252. FreeMem(FAddresses);
  253. FAddressCount:=0;
  254. FAddresses:=Nil;
  255. end;
  256. Function THostResolver.AddressLookup(Const S : String) : Boolean;
  257. begin
  258. Result:=AddressLookup(StrToHostAddr(S));
  259. end;
  260. {$ifdef usenetdb}
  261. Function THostResolver.NameLookup (Const S : String) : Boolean;
  262. Var
  263. H : THostEntry;
  264. begin
  265. Result:=Inherited NameLookup(S);
  266. If Result then
  267. begin
  268. Result:=GetHostByName(S,H);
  269. if not Result then
  270. Result:=ResolveHostByName(S,H)
  271. else
  272. H.Addr:=HostToNet(H.Addr);
  273. If Result then
  274. SaveHostEntry(@H);
  275. end;
  276. end;
  277. Function THostResolver.AddressLookup (Const Address: THostAddr) : Boolean;
  278. Var
  279. H : THostEntry;
  280. begin
  281. ClearData;
  282. Result:=ResolveHostByAddr(Address,H);
  283. If Result then
  284. SaveHostEntry(@H);
  285. end;
  286. Procedure THostResolver.SaveHostEntry(Entry : Pointer);
  287. Var
  288. PH : ^THostEntry;
  289. I : Integer;
  290. begin
  291. PH:=ENtry;
  292. FName:=PH^.Name;
  293. FHostAddress:=NetToHost(PH^.Addr);
  294. FAddressCount:=1;
  295. GetMem(FAddresses,SizeOf(THostAddr));
  296. FAddresses[0]:=NetToHost(PH^.Addr);
  297. FAliases.CommaText:=PH^.Aliases;
  298. end;
  299. {$else}
  300. Function THostResolver.NameLookup (Const S : String) : Boolean;
  301. Var
  302. FHostEntry : PHostEntry;
  303. begin
  304. Result:=Inherited NameLookup(S);
  305. If Result then
  306. begin
  307. FHostEntry:=GetHostByName(pchar(FName));
  308. Result:=FHostEntry<>Nil;
  309. If Result then
  310. SaveHostEntry(FHostEntry)
  311. else
  312. begin
  313. FLastError:=GetDNSError;
  314. CheckOperation(SErrHostByName);
  315. end;
  316. end;
  317. end;
  318. Procedure THostResolver.SaveHostEntry(Entry : Pointer);
  319. Var
  320. P : Pointer;
  321. I,Count : Integer;
  322. begin
  323. With PHostEntry(Entry)^ do
  324. begin
  325. FName:=StrPas(H_Name);
  326. FAddressCount:=0;
  327. While H_Addr[FAddressCount]<>Nil do
  328. Inc(FAddressCount);
  329. If FAddressCount>0 then
  330. begin
  331. GetMem(FAddresses,FAddressCount*SizeOf(THostAddr));
  332. For I:=0 to FAddressCount-1 do
  333. FAddresses[I]:=NetToHost(PHostAddr(H_Addr[I])^);
  334. FHostAddress:=FAddresses[0];
  335. end;
  336. SaveAliases(H_Aliases);
  337. end;
  338. end;
  339. Function THostResolver.AddressLookup (Const Address: THostAddr) : Boolean;
  340. Var
  341. FHostEntry : PHostEntry;
  342. begin
  343. ClearData;
  344. FHostEntry:=GetHostByAddr(Pchar(@Address),SizeOf(Address),AF_INET);
  345. Result:=FHostEntry<>Nil;
  346. If Result then
  347. SaveHostEntry(FHostEntry)
  348. else
  349. begin
  350. FLastError:=GetDNSError;
  351. CheckOperation(SErrHostByAddr);
  352. end;
  353. end;
  354. {$endif}
  355. Function THostResolver.GetNetAddress (Index : Integer) : THostAddr;
  356. begin
  357. Result:=HostToNet(Addresses[Index]);
  358. end;
  359. Function THostResolver.GetNetHostAddress : THostAddr;
  360. begin
  361. Result:=HostToNet(FHostAddress);
  362. end;
  363. { ---------------------------------------------------------------------
  364. TNetResolver
  365. ---------------------------------------------------------------------}
  366. {$ifdef usenetdb}
  367. Function TNetResolver.AddressLookup (Const Address: TNetAddr) : boolean;
  368. Var
  369. N : TNetworkEntry;
  370. begin
  371. ClearData;
  372. Result:=GetNetworkByAddr(Address,N);
  373. If Result then
  374. SaveNetEntry(@N);
  375. end;
  376. Function TNetResolver.NameLookup (Const S : String) : Boolean;
  377. Var
  378. N : TNetworkEntry;
  379. begin
  380. Result:=Inherited NameLookup(S);
  381. If Result then
  382. begin
  383. Result:=GetNetworkByName(S,N);
  384. If Result then
  385. SaveNetEntry(@N);
  386. end;
  387. end;
  388. Procedure TNetResolver.SaveNetEntry(Entry : Pointer);
  389. Var
  390. PN : ^TNetworkEntry;
  391. begin
  392. PN:=ENtry;
  393. FName:=PN^.Name;
  394. FNetAddress:=NetToHost(PN^.Addr);
  395. FAliases.CommaText:=PN^.Aliases;
  396. end;
  397. {$else}
  398. Function TNetResolver.NameLookup (Const S : String) : Boolean;
  399. Var
  400. FNetEntry : PNetEntry;
  401. begin
  402. Result:=Inherited NameLookup(S);
  403. If Result then
  404. begin
  405. FNetEntry:=GetNetByName(pchar(S));
  406. Result:=FNetEntry<>Nil;
  407. If Result then
  408. SaveNetEntry(FNetEntry)
  409. else
  410. begin
  411. FLastError:=GetDNSError;
  412. Checkoperation(SErrNetByName);
  413. end;
  414. end;
  415. end;
  416. Procedure TNetResolver.SaveNetEntry(Entry : Pointer);
  417. begin
  418. With PNetEntry(Entry)^ do
  419. begin
  420. FName:=StrPas(N_Name);
  421. FAddrType:=N_addrtype;
  422. FNetAddress:=NetToHost(TNetAddr(N_net));
  423. SaveAliases(N_Aliases);
  424. end;
  425. end;
  426. Function TNetResolver.AddressLookup (Const Address: TNetAddr) : boolean;
  427. Var
  428. FNetEntry : PNetEntry;
  429. begin
  430. ClearData;
  431. {$ifndef win32}
  432. FNetEntry:=GetNetByAddr(Longint(HostToNet(Address)),AF_INET);
  433. {$else}
  434. FNetEntry:=Nil;
  435. {$endif}
  436. Result:=FNetEntry<>Nil;
  437. If Result then
  438. SaveNetEntry(FNetEntry)
  439. else
  440. begin
  441. FLastError:=GetDNSError;
  442. CheckOperation(SErrNetByName);
  443. end;
  444. end;
  445. {$endif}
  446. Function TNetResolver.AddressLookup(Const S : String) : Boolean;
  447. begin
  448. Result:=AddressLookup(StrToNetAddr(S));
  449. end;
  450. Function TNetResolver.GetAsString : String;
  451. begin
  452. Result:=HostAddrToStr(FNetAddress);
  453. end;
  454. Function TNetResolver.GetNetAddress : TNetAddr;
  455. begin
  456. Result:=HostToNet(FNetAddress);
  457. end;
  458. Procedure TNetResolver.ClearData;
  459. begin
  460. Inherited;
  461. FNetAddress:=NoAddress;
  462. FAddrType:=0;
  463. end;
  464. { ---------------------------------------------------------------------
  465. TServiceResolver
  466. ---------------------------------------------------------------------}
  467. Function TServiceResolver.NameLookup (Const S : String) : Boolean;
  468. begin
  469. Result:=NameLookup(S,'');
  470. end;
  471. {$ifdef usenetdb}
  472. Function TServiceResolver.NameLookup (Const S,Proto : String) : Boolean;
  473. Var
  474. E : TServiceEntry;
  475. begin
  476. ClearData;
  477. Result:=GetServiceByName(S,Proto,E);
  478. If Result then
  479. SaveServiceEntry(@E);
  480. end;
  481. Function TServiceResolver.PortLookup (APort: Longint; Proto : String) : Boolean;
  482. Var
  483. E : TServiceEntry;
  484. begin
  485. ClearData;
  486. Result:=GetServiceByPort(APort,Proto,E);
  487. If Result then
  488. SaveServiceEntry(@E);
  489. end;
  490. Procedure TServiceResolver.SaveServiceEntry(Entry : Pointer);
  491. Var
  492. PE : ^TServiceEntry;
  493. begin
  494. PE:=Entry;
  495. FName:=PE^.Name;
  496. FPort:=PE^.Port;
  497. FProtocol:=PE^.Protocol;
  498. FAliases.CommaText:=PE^.Aliases;
  499. end;
  500. {$else}
  501. Function TServiceResolver.NameLookup (Const S,Proto : String) : Boolean;
  502. Var
  503. FServiceEntry : PServEntry;
  504. begin
  505. ClearData;
  506. FName:=S;
  507. FProtocol:=Proto;
  508. If (proto='') then
  509. FServiceEntry:=GetServByName(pchar(S),Nil)
  510. else
  511. FServiceEntry:=GetServByName(pchar(S),PChar(FProtocol));
  512. Result:=FServiceEntry<>Nil;
  513. If Result then
  514. SaveServiceEntry(FServiceEntry)
  515. else
  516. begin
  517. FLastError:=GetDNSError;
  518. CheckOperation(SErrServByName);
  519. end;
  520. end;
  521. Function TServiceResolver.PortLookup (APort: Longint; Proto : String) : Boolean;
  522. Var
  523. FServiceEntry : PServEntry;
  524. begin
  525. ClearData;
  526. APort:=ShortHostToNet(APort);
  527. FProtoCol:=Proto;
  528. If (Proto='') then
  529. FServiceEntry:=GetServByPort(APort,Nil)
  530. else
  531. FServiceEntry:=GetServByPort(APort,pchar(Proto));
  532. Result:=FServiceEntry<>Nil;
  533. If Result then
  534. SaveServiceEntry(FServiceEntry)
  535. else
  536. begin
  537. FLastError:=GetDNSError;
  538. CheckOperation(SErrServByPort);
  539. end;
  540. end;
  541. Procedure TServiceResolver.SaveServiceEntry(Entry : Pointer);
  542. begin
  543. With PServEntry(Entry)^ do
  544. begin
  545. FName:=strpas(s_name);
  546. FPort:=ShortHostToNet(S_port);
  547. FProtocol:=strpas(s_proto);
  548. SaveAliases(S_aliases);
  549. end;
  550. end;
  551. {$endif}
  552. Procedure TServiceResolver.ClearData;
  553. begin
  554. Inherited;
  555. FProtocol:='';
  556. FPort:=0;
  557. end;
  558. Function TServiceResolver.GetNetPort : Integer;
  559. begin
  560. Result:=ShortHostToNet(FPort);
  561. end;
  562. { ---------------------------------------------------------------------
  563. TURIParser
  564. ---------------------------------------------------------------------}
  565. Procedure TURIParser.SetElement (Index : Integer; Value : String);
  566. begin
  567. Case index of
  568. 0 : FProtocol := Value;
  569. 1 : FUsername := Value;
  570. 2 : FPassword := Value;
  571. 3 : FHost := Value;
  572. 4 : FPath := Value;
  573. 5 : FDocument := Value;
  574. 6 : FParams := Value;
  575. 7 : FBookmark := Value;
  576. else
  577. end;
  578. If FActive and not (csLoading in ComponentState) then
  579. FURI:=ComposeURI;
  580. end;
  581. Function TURIParser.GetElement(Index : Integer) : String;
  582. begin
  583. Case Index of
  584. 0 : Result := FProtocol;
  585. 1 : Result := FUsername;
  586. 2 : Result := FPassword;
  587. 3 : Result := FHost ;
  588. 4 : Result := FPath ;
  589. 5 : Result := FDocument;
  590. 6 : Result := FParams ;
  591. 7 : Result := FBookmark;
  592. else
  593. Result:='';
  594. end;
  595. end;
  596. Procedure TURIParser.SetPort(Value : Word);
  597. begin
  598. FPort:=Value;
  599. If FActive and not (csLoading in ComponentState) then
  600. FURI:=ComposeURI;
  601. end;
  602. Procedure TURIParser.SetURI(Value : String);
  603. begin
  604. If Active and not (csLoading in ComponentState) then
  605. begin
  606. Clear;
  607. ParseUri(Value);
  608. end;
  609. FURI:=Value;
  610. end;
  611. Procedure TURIParser.Clear;
  612. begin
  613. FProtocol :='';
  614. FUsername :='';
  615. FPassword :='';
  616. FHost :='';
  617. FPort :=0;
  618. FPath :='';
  619. FDocument :='';
  620. FParams :='';
  621. FBookmark :='';
  622. FURI :='';
  623. end;
  624. Procedure TURIParser.ParseUri(AURI : String);
  625. Var
  626. U : TURI;
  627. begin
  628. U:=UriParser.ParseURI(AUri);
  629. FProtocol := u.Protocol;
  630. FUsername := u.Username;
  631. FPassword := u.Password;
  632. FHost := u.Host ;
  633. FPort := u.Port ;
  634. FPath := u.Path ;
  635. FDocument := u.Document;
  636. FParams := u.Params ;
  637. FBookmark := u.Bookmark;
  638. end;
  639. Function TURIParser.ComposeURI : String;
  640. var
  641. U : TURI;
  642. begin
  643. U.Protocol := FProtocol;
  644. U.Username := FUsername;
  645. U.Password := FPassword;
  646. U.Host := FHost ;
  647. U.Port := FPort ;
  648. U.Path := FPath ;
  649. U.Document := FDocument;
  650. U.Params := FParams ;
  651. U.Bookmark := FBookmark;
  652. Result:=EncodeUri(U);
  653. end;
  654. {$ifdef usenetdb}
  655. Procedure InitResolve;
  656. begin
  657. end;
  658. Procedure FinalResolve;
  659. begin
  660. end;
  661. {$endif}
  662. Initialization
  663. InitResolve;
  664. Finalization
  665. FinalResolve;
  666. end.