From: Erik Margraf <erik.margraf@siemens.at>
Subject: Q: Howto use the C interfaces of Ada
Date: 1998/02/09
Date: 1998-02-09T00:00:00+00:00 [thread overview]
Message-ID: <34DEDCBD.2EB4F4FB@siemens.at> (raw)
I have a little question on using the C language interfaces
of Ada (using GNAT 3.10p on Linux, but I think that doesn't matter
that much in this case).
I basically tried to do the equvalent Ada code for the following
C code (It may be not 100% correct, because I didnt copy it from
the sources)
...
struct hostent *h;
struct sockaddr_in addr;
h = gethostbyname("some_hostname");
memcpy(&addr.sin_addr, h->h_addr, h->h_length);
...
The difficulties I have lie in the definition of the "Ada" hostent
structure and then of course the right "memcpy" statement.
I tried something like the following.
type hostent is record
h_name : interfaces.C.Strings.chars_ptr;
h_aliases : interfaces.C.strings.chars_ptr_array; -- ???
h_addrtype : interfaces.C.int;
h_length : interfaces:C.int;
h_addr_list : interfaces.C.strings.chars_ptr_array; -- ???
end record;
I think I did the definition of the sockaddr_in type right, because
when I hardcoded the address, the bind call worked. Also h_name,
h_addr_type and h_length were OK. But I could not get the the address
information from the hostent record.
Thanks in advance for any help.
Erik Margraf
--
----------------------------------------------------------------
-- Erik Margraf SIEMENS Austria, PSE KB24 --
-- erik.margraf@siemens.at --
----------------------------------------------------------------
reply other threads:[~1998-02-09 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox