From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,41ccc2330807735c X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Help with calling gethostbyname in Win32-winsock binding Date: 2000/08/04 Message-ID: #1/1 X-Deja-AN: 654607686 References: <398B43E9.C5EE7187@acm.org> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 965431861 24.20.190.201 (Fri, 04 Aug 2000 16:31:01 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Fri, 04 Aug 2000 16:31:01 PDT Newsgroups: comp.lang.ada Date: 2000-08-04T00:00:00+00:00 List-Id: > type HOSTENT is > record > h_name : Win32.PSTR; > h_aliases : PPCHAR; > h_addrtype : Win32.SHORT; > h_length : Win32.SHORT; > h_addr_list: PPCHAR; > end record; Extracted from the private part of Claw.Sockets' spec (approximately): type Network_Address_Type is new Interfaces.C.Unsigned_Long; -- In network byte order. type Ptr_To_Network_Address_Type is access all Network_Address_Type; Max_Host_Count : constant := 10; type Host_Address_List_Type is array(1 .. Max_Host_Count) of Ptr_To_Network_Address_Type; -- (1 .. N), null terminated. Declare fixed size so no dope vector. type Host_Address_List_Ptr_Type is access all Host_Address_List_Type; subtype Host_Alias_Ptr_List_Type is Interfaces.C.Strings.Chars_Ptr_Array (1 .. Max_Host_Count); -- (1 .. N), null terminated. Declare fixed size so no dope vector. type Host_Alias_List_Ptr_Type is access all Host_Alias_Ptr_List_Type; PF_INET : constant := 2; type HOSTENTs is record Host_Name_Ptr : Interfaces.C.Strings.Chars_Ptr; -- h_name Host_Alias_Ptr_List : Host_Alias_List_Ptr_Type; -- h_aliases Host_Address_Kind : Interfaces.C.Short:=PF_INET; -- h_addrtype Host_Address_Length : Interfaces.C.Short:= 4; -- h_length Host_Address_List_Ptr : Host_Address_List_Ptr_Type; -- h_addr_list end record; for Hostents use record Host_Name_Ptr at 0 range 0 .. 31; Host_Alias_Ptr_List at 4 range 0 .. 31; Host_Address_Kind at 8 range 0 .. 15; Host_Address_Length at 10 range 0 .. 15; Host_Address_List_Ptr at 12 range 0 .. 31; end record; for Hostents'size use 16*8; -- Note: in Claw.Win32, type Lpcstr is access all Interfaces.C.Char; function gethostbyname(name: Claw.Win32.LPCStr) return Hostent_Ptr_Type; pragma Import(Stdcall, gethostbyname, "gethostbyname"); type Host_Info_Type is record Hostent : Hostents; ... and in the body: function Host_Address (Info : in Host_Info_Type; I : in Positive) return Network_Address_Type is -- return the Ith network address in Info begin for j in Host_Address_List_Type'range loop exit when Info.Hostent.Host_Address_List_Ptr.all(j) = null; if I = j then return Info.Hostent.Host_Address_List_Ptr.all(j).all; end if; end loop; ...