* Q: Howto use the C interfaces of Ada
@ 1998-02-09 0:00 Erik Margraf
0 siblings, 0 replies; only message in thread
From: Erik Margraf @ 1998-02-09 0:00 UTC (permalink / 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 --
----------------------------------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-02-09 0:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-09 0:00 Q: Howto use the C interfaces of Ada Erik Margraf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox