resolve.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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. If Result then
  272. SaveHostEntry(@H);
  273. end;
  274. end;
  275. Function THostResolver.AddressLookup (Const Address: THostAddr) : Boolean;
  276. Var
  277. H : THostEntry;
  278. begin
  279. ClearData;
  280. Result:=ResolveHostByAddr(Address,H);
  281. If Result then
  282. SaveHostEntry(@H);
  283. end;
  284. Procedure THostResolver.SaveHostEntry(Entry : Pointer);
  285. Var
  286. PH : ^THostEntry;
  287. I : Integer;
  288. begin
  289. PH:=ENtry;
  290. FName:=PH^.Name;
  291. FHostAddress:=NetToHost(PH^.Addr);
  292. FAddressCount:=1;
  293. GetMem(FAddresses,SizeOf(THostAddr));
  294. FAddresses[0]:=NetToHost(PH^.Addr);
  295. FAliases.CommaText:=PH^.Aliases;
  296. end;
  297. {$else}
  298. Function THostResolver.NameLookup (Const S : String) : Boolean;
  299. Var
  300. FHostEntry : PHostEntry;
  301. begin
  302. Result:=Inherited NameLookup(S);
  303. If Result then
  304. begin
  305. FHostEntry:=GetHostByName(pchar(FName));
  306. Result:=FHostEntry<>Nil;
  307. If Result then
  308. SaveHostEntry(FHostEntry)
  309. else
  310. begin
  311. FLastError:=GetDNSError;
  312. CheckOperation(SErrHostByName);
  313. end;
  314. end;
  315. end;
  316. Procedure THostResolver.SaveHostEntry(Entry : Pointer);
  317. Var
  318. P : Pointer;
  319. I,Count : Integer;
  320. begin
  321. With PHostEntry(Entry)^ do
  322. begin
  323. FName:=StrPas(H_Name);
  324. FAddressCount:=0;
  325. While H_Addr[FAddressCount]<>Nil do
  326. Inc(FAddressCount);
  327. If FAddressCount>0 then
  328. begin
  329. GetMem(FAddresses,FAddressCount*SizeOf(THostAddr));
  330. For I:=0 to FAddressCount-1 do
  331. FAddresses[I]:=NetToHost(PHostAddr(H_Addr[I])^);
  332. FHostAddress:=FAddresses[0];
  333. end;
  334. SaveAliases(H_Aliases);
  335. end;
  336. end;
  337. Function THostResolver.AddressLookup (Const Address: THostAddr) : Boolean;
  338. Var
  339. FHostEntry : PHostEntry;
  340. begin
  341. ClearData;
  342. FHostEntry:=GetHostByAddr(Pchar(@Address),SizeOf(Address),AF_INET);
  343. Result:=FHostEntry<>Nil;
  344. If Result then
  345. SaveHostEntry(FHostEntry)
  346. else
  347. begin
  348. FLastError:=GetDNSError;
  349. CheckOperation(SErrHostByAddr);
  350. end;
  351. end;
  352. {$endif}
  353. Function THostResolver.GetNetAddress (Index : Integer) : THostAddr;
  354. begin
  355. Result:=HostToNet(Addresses[Index]);
  356. end;
  357. Function THostResolver.GetNetHostAddress : THostAddr;
  358. begin
  359. Result:=HostToNet(FHostAddress);
  360. end;
  361. { ---------------------------------------------------------------------
  362. TNetResolver
  363. ---------------------------------------------------------------------}
  364. {$ifdef usenetdb}
  365. Function TNetResolver.AddressLookup (Const Address: TNetAddr) : boolean;
  366. Var
  367. N : TNetworkEntry;
  368. begin
  369. ClearData;
  370. Result:=GetNetworkByAddr(Address,N);
  371. If Result then
  372. SaveNetEntry(@N);
  373. end;
  374. Function TNetResolver.NameLookup (Const S : String) : Boolean;
  375. Var
  376. N : TNetworkEntry;
  377. begin
  378. Result:=Inherited NameLookup(S);
  379. If Result then
  380. begin
  381. Result:=GetNetworkByName(S,N);
  382. If Result then
  383. SaveNetEntry(@N);
  384. end;
  385. end;
  386. Procedure TNetResolver.SaveNetEntry(Entry : Pointer);
  387. Var
  388. PN : ^TNetworkEntry;
  389. begin
  390. PN:=ENtry;
  391. FName:=PN^.Name;
  392. FNetAddress:=NetToHost(PN^.Addr);
  393. FAliases.CommaText:=PN^.Aliases;
  394. end;
  395. {$else}
  396. Function TNetResolver.NameLookup (Const S : String) : Boolean;
  397. Var
  398. FNetEntry : PNetEntry;
  399. begin
  400. Result:=Inherited NameLookup(S);
  401. If Result then
  402. begin
  403. FNetEntry:=GetNetByName(pchar(S));
  404. Result:=FNetEntry<>Nil;
  405. If Result then
  406. SaveNetEntry(FNetEntry)
  407. else
  408. begin
  409. FLastError:=GetDNSError;
  410. Checkoperation(SErrNetByName);
  411. end;
  412. end;
  413. end;
  414. Procedure TNetResolver.SaveNetEntry(Entry : Pointer);
  415. begin
  416. With PNetEntry(Entry)^ do
  417. begin
  418. FName:=StrPas(N_Name);
  419. FAddrType:=N_addrtype;
  420. FNetAddress:=NetToHost(TNetAddr(N_net));
  421. SaveAliases(N_Aliases);
  422. end;
  423. end;
  424. Function TNetResolver.AddressLookup (Const Address: TNetAddr) : boolean;
  425. Var
  426. FNetEntry : PNetEntry;
  427. begin
  428. ClearData;
  429. {$ifndef win32}
  430. FNetEntry:=GetNetByAddr(Longint(HostToNet(Address)),AF_INET);
  431. {$else}
  432. FNetEntry:=Nil;
  433. {$endif}
  434. Result:=FNetEntry<>Nil;
  435. If Result then
  436. SaveNetEntry(FNetEntry)
  437. else
  438. begin
  439. FLastError:=GetDNSError;
  440. CheckOperation(SErrNetByName);
  441. end;
  442. end;
  443. {$endif}
  444. Function TNetResolver.AddressLookup(Const S : String) : Boolean;
  445. begin
  446. Result:=AddressLookup(StrToNetAddr(S));
  447. end;
  448. Function TNetResolver.GetAsString : String;
  449. begin
  450. Result:=HostAddrToStr(FNetAddress);
  451. end;
  452. Function TNetResolver.GetNetAddress : TNetAddr;
  453. begin
  454. Result:=HostToNet(FNetAddress);
  455. end;
  456. Procedure TNetResolver.ClearData;
  457. begin
  458. Inherited;
  459. FNetAddress:=NoAddress;
  460. FAddrType:=0;
  461. end;
  462. { ---------------------------------------------------------------------
  463. TServiceResolver
  464. ---------------------------------------------------------------------}
  465. Function TServiceResolver.NameLookup (Const S : String) : Boolean;
  466. begin
  467. Result:=NameLookup(S,'');
  468. end;
  469. {$ifdef usenetdb}
  470. Function TServiceResolver.NameLookup (Const S,Proto : String) : Boolean;
  471. Var
  472. E : TServiceEntry;
  473. begin
  474. ClearData;
  475. Result:=GetServiceByName(S,Proto,E);
  476. If Result then
  477. SaveServiceEntry(@E);
  478. end;
  479. Function TServiceResolver.PortLookup (APort: Longint; Proto : String) : Boolean;
  480. Var
  481. E : TServiceEntry;
  482. begin
  483. ClearData;
  484. Result:=GetServiceByPort(APort,Proto,E);
  485. If Result then
  486. SaveServiceEntry(@E);
  487. end;
  488. Procedure TServiceResolver.SaveServiceEntry(Entry : Pointer);
  489. Var
  490. PE : ^TServiceEntry;
  491. begin
  492. PE:=Entry;
  493. FName:=PE^.Name;
  494. FPort:=PE^.Port;
  495. FProtocol:=PE^.Protocol;
  496. FAliases.CommaText:=PE^.Aliases;
  497. end;
  498. {$else}
  499. Function TServiceResolver.NameLookup (Const S,Proto : String) : Boolean;
  500. Var
  501. FServiceEntry : PServEntry;
  502. begin
  503. ClearData;
  504. FName:=S;
  505. FProtocol:=Proto;
  506. If (proto='') then
  507. FServiceEntry:=GetServByName(pchar(S),Nil)
  508. else
  509. FServiceEntry:=GetServByName(pchar(S),PChar(FProtocol));
  510. Result:=FServiceEntry<>Nil;
  511. If Result then
  512. SaveServiceEntry(FServiceEntry)
  513. else
  514. begin
  515. FLastError:=GetDNSError;
  516. CheckOperation(SErrServByName);
  517. end;
  518. end;
  519. Function TServiceResolver.PortLookup (APort: Longint; Proto : String) : Boolean;
  520. Var
  521. FServiceEntry : PServEntry;
  522. begin
  523. ClearData;
  524. APort:=ShortHostToNet(APort);
  525. FProtoCol:=Proto;
  526. If (Proto='') then
  527. FServiceEntry:=GetServByPort(APort,Nil)
  528. else
  529. FServiceEntry:=GetServByPort(APort,pchar(Proto));
  530. Result:=FServiceEntry<>Nil;
  531. If Result then
  532. SaveServiceEntry(FServiceEntry)
  533. else
  534. begin
  535. FLastError:=GetDNSError;
  536. CheckOperation(SErrServByPort);
  537. end;
  538. end;
  539. Procedure TServiceResolver.SaveServiceEntry(Entry : Pointer);
  540. begin
  541. With PServEntry(Entry)^ do
  542. begin
  543. FName:=strpas(s_name);
  544. FPort:=ShortHostToNet(S_port);
  545. FProtocol:=strpas(s_proto);
  546. SaveAliases(S_aliases);
  547. end;
  548. end;
  549. {$endif}
  550. Procedure TServiceResolver.ClearData;
  551. begin
  552. Inherited;
  553. FProtocol:='';
  554. FPort:=0;
  555. end;
  556. Function TServiceResolver.GetNetPort : Integer;
  557. begin
  558. Result:=ShortHostToNet(FPort);
  559. end;
  560. { ---------------------------------------------------------------------
  561. TURIParser
  562. ---------------------------------------------------------------------}
  563. Procedure TURIParser.SetElement (Index : Integer; Value : String);
  564. begin
  565. Case index of
  566. 0 : FProtocol := Value;
  567. 1 : FUsername := Value;
  568. 2 : FPassword := Value;
  569. 3 : FHost := Value;
  570. 4 : FPath := Value;
  571. 5 : FDocument := Value;
  572. 6 : FParams := Value;
  573. 7 : FBookmark := Value;
  574. else
  575. end;
  576. If FActive and not (csLoading in ComponentState) then
  577. FURI:=ComposeURI;
  578. end;
  579. Function TURIParser.GetElement(Index : Integer) : String;
  580. begin
  581. Case Index of
  582. 0 : Result := FProtocol;
  583. 1 : Result := FUsername;
  584. 2 : Result := FPassword;
  585. 3 : Result := FHost ;
  586. 4 : Result := FPath ;
  587. 5 : Result := FDocument;
  588. 6 : Result := FParams ;
  589. 7 : Result := FBookmark;
  590. else
  591. Result:='';
  592. end;
  593. end;
  594. Procedure TURIParser.SetPort(Value : Word);
  595. begin
  596. FPort:=Value;
  597. If FActive and not (csLoading in ComponentState) then
  598. FURI:=ComposeURI;
  599. end;
  600. Procedure TURIParser.SetURI(Value : String);
  601. begin
  602. If Active and not (csLoading in ComponentState) then
  603. begin
  604. Clear;
  605. ParseUri(Value);
  606. end;
  607. FURI:=Value;
  608. end;
  609. Procedure TURIParser.Clear;
  610. begin
  611. FProtocol :='';
  612. FUsername :='';
  613. FPassword :='';
  614. FHost :='';
  615. FPort :=0;
  616. FPath :='';
  617. FDocument :='';
  618. FParams :='';
  619. FBookmark :='';
  620. FURI :='';
  621. end;
  622. Procedure TURIParser.ParseUri(AURI : String);
  623. Var
  624. U : TURI;
  625. begin
  626. U:=UriParser.ParseURI(AUri);
  627. FProtocol := u.Protocol;
  628. FUsername := u.Username;
  629. FPassword := u.Password;
  630. FHost := u.Host ;
  631. FPort := u.Port ;
  632. FPath := u.Path ;
  633. FDocument := u.Document;
  634. FParams := u.Params ;
  635. FBookmark := u.Bookmark;
  636. end;
  637. Function TURIParser.ComposeURI : String;
  638. var
  639. U : TURI;
  640. begin
  641. U.Protocol := FProtocol;
  642. U.Username := FUsername;
  643. U.Password := FPassword;
  644. U.Host := FHost ;
  645. U.Port := FPort ;
  646. U.Path := FPath ;
  647. U.Document := FDocument;
  648. U.Params := FParams ;
  649. U.Bookmark := FBookmark;
  650. Result:=EncodeUri(U);
  651. end;
  652. {$ifdef usenetdb}
  653. Procedure InitResolve;
  654. begin
  655. end;
  656. Procedure FinalResolve;
  657. begin
  658. end;
  659. {$endif}
  660. Initialization
  661. InitResolve;
  662. Finalization
  663. FinalResolve;
  664. end.